Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gmsh
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Larry Price
gmsh
Commits
02524835
Commit
02524835
authored
15 years ago
by
Jonathan Lambrechts
Browse files
Options
Downloads
Patches
Plain Diff
Merge dataCache and dataCacheDouble
parent
ab2bfed8
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Solver/function.cpp
+6
-10
6 additions, 10 deletions
Solver/function.cpp
Solver/function.h
+22
-20
22 additions, 20 deletions
Solver/function.h
with
28 additions
and
30 deletions
Solver/function.cpp
+
6
−
10
View file @
02524835
...
@@ -53,16 +53,12 @@ dataCacheDouble *function::newDataCache(dataCacheMap *m)
...
@@ -53,16 +53,12 @@ dataCacheDouble *function::newDataCache(dataCacheMap *m)
return
new
data
(
this
,
m
);
return
new
data
(
this
,
m
);
}
}
// dataCache members
dataCache
::
dataCache
(
dataCacheMap
*
cacheMap
)
:
_valid
(
false
)
{
cacheMap
->
addDataCache
(
this
);
//this dataCache can be deleted when the dataCacheMap is deleted
}
void
dataCache
::
addMeAsDependencyOf
(
dataCache
*
newDep
)
void
dataCache
Double
::
addMeAsDependencyOf
(
dataCache
Double
*
newDep
)
{
{
_dependOnMe
.
insert
(
newDep
);
_dependOnMe
.
insert
(
newDep
);
newDep
->
_iDependOn
.
insert
(
this
);
newDep
->
_iDependOn
.
insert
(
this
);
for
(
std
::
set
<
dataCache
*>::
iterator
it
=
_iDependOn
.
begin
();
for
(
std
::
set
<
dataCache
Double
*>::
iterator
it
=
_iDependOn
.
begin
();
it
!=
_iDependOn
.
end
();
it
++
)
{
it
!=
_iDependOn
.
end
();
it
++
)
{
(
*
it
)
->
_dependOnMe
.
insert
(
newDep
);
(
*
it
)
->
_dependOnMe
.
insert
(
newDep
);
newDep
->
_iDependOn
.
insert
(
*
it
);
newDep
->
_iDependOn
.
insert
(
*
it
);
...
@@ -71,14 +67,14 @@ void dataCache::addMeAsDependencyOf (dataCache *newDep)
...
@@ -71,14 +67,14 @@ void dataCache::addMeAsDependencyOf (dataCache *newDep)
//dataCacheMap members
//dataCacheMap members
static
dataCacheDouble
&
returnDataCacheDouble
(
dataCacheDouble
*
data
,
dataCache
*
caller
)
static
dataCacheDouble
&
returnDataCacheDouble
(
dataCacheDouble
*
data
,
dataCache
Double
*
caller
)
{
{
if
(
data
==
NULL
)
throw
;
if
(
data
==
NULL
)
throw
;
if
(
caller
)
if
(
caller
)
data
->
addMeAsDependencyOf
(
caller
);
data
->
addMeAsDependencyOf
(
caller
);
return
*
data
;
return
*
data
;
}
}
dataCacheDouble
&
dataCacheMap
::
get
(
const
function
*
f
,
dataCache
*
caller
)
dataCacheDouble
&
dataCacheMap
::
get
(
const
function
*
f
,
dataCache
Double
*
caller
)
{
{
dataCacheDouble
*&
r
=
_cacheDoubleMap
[
f
];
dataCacheDouble
*&
r
=
_cacheDoubleMap
[
f
];
if
(
r
==
NULL
)
if
(
r
==
NULL
)
...
@@ -125,7 +121,7 @@ dataCacheDouble &dataCacheMap::provideNormals()
...
@@ -125,7 +121,7 @@ dataCacheDouble &dataCacheMap::provideNormals()
dataCacheMap
::~
dataCacheMap
()
dataCacheMap
::~
dataCacheMap
()
{
{
for
(
std
::
set
<
dataCache
*>::
iterator
it
=
_toDelete
.
begin
();
for
(
std
::
set
<
dataCache
Double
*>::
iterator
it
=
_toDelete
.
begin
();
it
!=
_toDelete
.
end
();
it
++
)
{
it
!=
_toDelete
.
end
();
it
++
)
{
delete
*
it
;
delete
*
it
;
}
}
...
@@ -337,7 +333,7 @@ void dataCacheMap::setNbEvaluationPoints(int nbEvaluationPoints) {
...
@@ -337,7 +333,7 @@ void dataCacheMap::setNbEvaluationPoints(int nbEvaluationPoints) {
}
}
dataCacheDouble
::
dataCacheDouble
(
dataCacheMap
&
map
,
int
nRowByPoint
,
int
nCol
)
:
dataCacheDouble
::
dataCacheDouble
(
dataCacheMap
&
map
,
int
nRowByPoint
,
int
nCol
)
:
dataCache
(
&
map
),
_cacheMap
(
map
),
_value
(
nRowByPoint
==
0
?
1
:
nRowByPoint
*
map
.
getNbEvaluationPoints
(),
nCol
){
_cacheMap
(
map
),
_value
(
nRowByPoint
==
0
?
1
:
nRowByPoint
*
map
.
getNbEvaluationPoints
(),
nCol
){
_nRowByPoint
=
nRowByPoint
;
_nRowByPoint
=
nRowByPoint
;
map
.
addDataCacheDouble
(
this
);
map
.
addDataCacheDouble
(
this
);
};
};
...
...
This diff is collapsed.
Click to expand it.
Solver/function.h
+
22
−
20
View file @
02524835
...
@@ -30,26 +30,27 @@ class dgDofContainer;
...
@@ -30,26 +30,27 @@ class dgDofContainer;
class
function
;
class
function
;
class
dataCache
{
// dataCache when the value is a matrix of double
// the user should provide the number of rows by evaluating points and the number of columns
// then the size of the matrix is automatically adjusted
class
dataCacheDouble
{
friend
class
dataCacheMap
;
friend
class
dataCacheMap
;
// pointers to all of the dataCache depending on me
// pointers to all of the dataCache depending on me
std
::
set
<
dataCache
*>
_dependOnMe
;
std
::
set
<
dataCache
Double
*>
_dependOnMe
;
std
::
set
<
dataCache
*>
_iDependOn
;
std
::
set
<
dataCache
Double
*>
_iDependOn
;
protected
:
protected
:
bool
_valid
;
bool
_valid
;
// invalidates all the cached data that depends on me
// invalidates all the cached data that depends on me
inline
void
_invalidateDependencies
()
inline
void
_invalidateDependencies
()
{
{
// if this is too slow we can keep a C array cache of the _dependOnMe set
// if this is too slow we can keep a C array cache of the _dependOnMe set
for
(
std
::
set
<
dataCache
*>::
iterator
it
=
_dependOnMe
.
begin
();
for
(
std
::
set
<
dataCache
Double
*>::
iterator
it
=
_dependOnMe
.
begin
();
it
!=
_dependOnMe
.
end
();
it
++
)
it
!=
_dependOnMe
.
end
();
it
++
)
(
*
it
)
->
_valid
=
false
;
(
*
it
)
->
_valid
=
false
;
}
}
dataCache
(
dataCacheMap
*
cacheMap
);
virtual
~
dataCache
(){};
public
:
public
:
// dataCacheMap is the only one supposed to call this
// dataCacheMap is the only one supposed to call this
void
addMeAsDependencyOf
(
dataCache
*
newDep
);
void
addMeAsDependencyOf
(
dataCache
Double
*
newDep
);
inline
bool
somethingDependOnMe
()
{
inline
bool
somethingDependOnMe
()
{
return
!
_dependOnMe
.
empty
();
return
!
_dependOnMe
.
empty
();
}
}
...
@@ -60,12 +61,10 @@ public :
...
@@ -60,12 +61,10 @@ public :
return
_iDependOn
.
size
();
return
_iDependOn
.
size
();
}
}
};
// dataCache when the value is a matrix of double
// the user should provide the number of rows by evaluating points and the number of columns
// then the size of the matrix is automatically adjusted
class
dataCacheDouble
:
public
dataCache
{
int
_nRowByPoint
;
int
_nRowByPoint
;
dataCacheMap
&
_cacheMap
;
dataCacheMap
&
_cacheMap
;
protected
:
protected
:
...
@@ -75,21 +74,24 @@ class dataCacheDouble : public dataCache {
...
@@ -75,21 +74,24 @@ class dataCacheDouble : public dataCache {
public
:
public
:
//set the value (without computing it by _eval) and invalidate the dependencies
//set the value (without computing it by _eval) and invalidate the dependencies
inline
void
set
(
const
fullMatrix
<
double
>
&
mat
)
{
inline
void
set
(
const
fullMatrix
<
double
>
&
mat
)
{
_invalidateDependencies
();
if
(
_valid
)
_invalidateDependencies
();
_value
=
mat
;
_value
=
mat
;
_valid
=
true
;
_valid
=
true
;
}
}
// take care if you use this you must ensure that the value pointed to are not modified
// take care if you use this you must ensure that the value pointed to are not modified
// without further call to setAsProxy because the dependencies won't be invalidate
// without further call to setAsProxy because the dependencies won't be invalidate
inline
void
setAsProxy
(
const
fullMatrix
<
double
>
&
mat
,
int
cShift
,
int
c
)
{
inline
void
setAsProxy
(
const
fullMatrix
<
double
>
&
mat
,
int
cShift
,
int
c
)
{
_invalidateDependencies
();
if
(
_valid
)
_invalidateDependencies
();
_value
.
setAsProxy
(
mat
,
cShift
,
c
);
_value
.
setAsProxy
(
mat
,
cShift
,
c
);
_valid
=
true
;
_valid
=
true
;
}
}
// take care if you use this you must ensure that the value pointed to are not modified
// take care if you use this you must ensure that the value pointed to are not modified
// without further call to setAsProxy because the dependencies won't be invalidate
// without further call to setAsProxy because the dependencies won't be invalidate
inline
void
setAsProxy
(
const
fullMatrix
<
double
>
&
mat
)
{
inline
void
setAsProxy
(
const
fullMatrix
<
double
>
&
mat
)
{
_invalidateDependencies
();
if
(
_valid
)
_invalidateDependencies
();
_value
.
setAsProxy
(
mat
,
0
,
mat
.
size2
());
_value
.
setAsProxy
(
mat
,
0
,
mat
.
size2
());
_valid
=
true
;
_valid
=
true
;
}
}
...
@@ -97,7 +99,8 @@ class dataCacheDouble : public dataCache {
...
@@ -97,7 +99,8 @@ class dataCacheDouble : public dataCache {
// but you cannot keep the reference to the _value, you should always use the set function
// but you cannot keep the reference to the _value, you should always use the set function
// to modify the _value
// to modify the _value
inline
fullMatrix
<
double
>
&
set
()
{
inline
fullMatrix
<
double
>
&
set
()
{
_invalidateDependencies
();
if
(
_valid
)
_invalidateDependencies
();
_valid
=
true
;
_valid
=
true
;
return
_value
;
return
_value
;
}
}
...
@@ -147,7 +150,6 @@ class function {
...
@@ -147,7 +150,6 @@ class function {
// more explanation at the head of this file
// more explanation at the head of this file
class
dataCacheMap
{
class
dataCacheMap
{
friend
class
dataCache
;
friend
class
dataCacheDouble
;
friend
class
dataCacheDouble
;
private:
private:
int
_nbEvaluationPoints
;
int
_nbEvaluationPoints
;
...
@@ -165,14 +167,14 @@ class dataCacheMap {
...
@@ -165,14 +167,14 @@ class dataCacheMap {
map
.
_toInvalidateOnElement
.
erase
(
this
);
map
.
_toInvalidateOnElement
.
erase
(
this
);
}
}
};
};
std
::
set
<
dataCache
*>
_toDelete
;
std
::
set
<
dataCache
Double
*>
_toDelete
;
std
::
set
<
dataCacheDouble
*>
_toResize
;
std
::
set
<
dataCacheDouble
*>
_toResize
;
std
::
set
<
dataCacheDouble
*>
_toInvalidateOnElement
;
std
::
set
<
dataCacheDouble
*>
_toInvalidateOnElement
;
MElement
*
_element
;
MElement
*
_element
;
protected
:
protected
:
void
addDataCache
(
dataCache
*
data
){
void
addDataCache
(
dataCache
Double
*
data
){
_toDelete
.
insert
(
data
);
_toDelete
.
insert
(
data
);
}
}
void
addDataCacheDouble
(
dataCacheDouble
*
data
){
void
addDataCacheDouble
(
dataCacheDouble
*
data
){
...
@@ -190,7 +192,7 @@ class dataCacheMap {
...
@@ -190,7 +192,7 @@ class dataCacheMap {
dataCacheDouble
&
provideParametricCoordinates
();
dataCacheDouble
&
provideParametricCoordinates
();
dataCacheDouble
&
provideNormals
();
dataCacheDouble
&
provideNormals
();
dataCacheDouble
&
get
(
const
function
*
f
,
dataCache
*
caller
=
0
);
dataCacheDouble
&
get
(
const
function
*
f
,
dataCache
Double
*
caller
=
0
);
inline
void
setElement
(
MElement
*
element
)
{
inline
void
setElement
(
MElement
*
element
)
{
_element
=
element
;
_element
=
element
;
for
(
std
::
set
<
dataCacheDouble
*>::
iterator
it
=
_toInvalidateOnElement
.
begin
();
it
!=
_toInvalidateOnElement
.
end
();
it
++
)
{
for
(
std
::
set
<
dataCacheDouble
*>::
iterator
it
=
_toInvalidateOnElement
.
begin
();
it
!=
_toInvalidateOnElement
.
end
();
it
++
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment