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
a6a935f1
Commit
a6a935f1
authored
14 years ago
by
Jonathan Lambrechts
Browse files
Options
Downloads
Patches
Plain Diff
change solutionFunction Mechanism
parent
81926f63
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Solver/function.cpp
+18
-5
18 additions, 5 deletions
Solver/function.cpp
Solver/function.h
+7
-1
7 additions, 1 deletion
Solver/function.h
with
25 additions
and
6 deletions
Solver/function.cpp
+
18
−
5
View file @
a6a935f1
...
...
@@ -229,8 +229,19 @@ void dataCacheDouble::_eval()
_valid
=
true
;
}
dataCacheDouble
&
dataCacheMap
::
get
(
const
function
*
f
,
dataCacheDouble
*
caller
)
dataCacheDouble
*
dataCacheMap
::
get
(
const
function
*
f
,
dataCacheDouble
*
caller
,
bool
createIfNotPresent
)
{
//special case
if
(
f
==
function
::
getSolution
())
{
f
=
_functionSolution
;
if
(
f
==
NULL
)
Msg
::
Error
(
"solution function has not been set"
);
}
else
if
(
f
==
function
::
getSolutionGradient
())
{
f
=
_functionSolutionGradient
;
if
(
f
==
NULL
)
Msg
::
Error
(
"solution function gradient has not been set"
);
}
// do I have a cache for this function ?
dataCacheDouble
*&
r
=
_cacheDoubleMap
[
f
];
// can I use the cache of my parent ?
...
...
@@ -247,15 +258,17 @@ dataCacheDouble &dataCacheMap::get(const function *f, dataCacheDouble *caller)
}
}
if
(
okFromParent
)
r
=
&
_parent
->
get
(
f
,
caller
);
r
=
_parent
->
get
(
f
,
caller
);
}
// no cache found, create a new one
if
(
r
==
NULL
)
{
if
(
!
createIfNotPresent
)
return
NULL
;
r
=
new
dataCacheDouble
(
this
,
(
function
*
)(
f
));
r
->
_directDependencies
.
resize
(
f
->
arguments
.
size
());
for
(
unsigned
int
i
=
0
;
i
<
f
->
arguments
.
size
();
i
++
)
{
r
->
_directDependencies
[
i
]
=
&
getSecondaryCache
(
f
->
arguments
[
i
].
iMap
)
->
get
(
f
->
arguments
[
i
].
f
,
r
);
getSecondaryCache
(
f
->
arguments
[
i
].
iMap
)
->
get
(
f
->
arguments
[
i
].
f
,
r
);
}
for
(
unsigned
i
=
0
;
i
<
f
->
_functionReplaces
.
size
();
i
++
)
{
functionReplaceCache
replaceCache
;
...
...
@@ -274,7 +287,7 @@ dataCacheDouble &dataCacheMap::get(const function *f, dataCacheDouble *caller)
}
for
(
std
::
vector
<
function
::
argument
>::
iterator
it
=
replace
->
_toCompute
.
begin
();
it
!=
replace
->
_toCompute
.
end
();
it
++
)
{
replaceCache
.
toCompute
.
push_back
(
&
rMap
->
getSecondaryCache
(
it
->
iMap
)
->
get
(
it
->
f
,
r
));
replaceCache
.
toCompute
.
push_back
(
rMap
->
getSecondaryCache
(
it
->
iMap
)
->
get
(
it
->
f
,
r
));
}
replaceCache
.
map
=
rMap
;
r
->
functionReplaceCaches
.
push_back
(
replaceCache
);
...
...
@@ -292,7 +305,7 @@ dataCacheDouble &dataCacheMap::get(const function *f, dataCacheDouble *caller)
caller
->
_iDependOn
.
insert
(
*
it
);
}
}
return
*
r
;
return
r
;
}
// dataCacheMap
...
...
This diff is collapsed.
Click to expand it.
Solver/function.h
+
7
−
1
View file @
a6a935f1
...
...
@@ -201,6 +201,7 @@ class dataCacheDouble {
};
class
dataCacheMap
{
const
function
*
_functionSolution
,
*
_functionSolutionGradient
;
public:
dataCacheMap
*
_parent
;
std
::
list
<
dataCacheMap
*>
_children
;
...
...
@@ -211,6 +212,7 @@ class dataCacheMap {
std
::
set
<
dataCacheDouble
*>
_toInvalidateOnElement
;
MElement
*
_element
;
dataCacheMap
()
{
_functionSolution
=
_functionSolutionGradient
=
NULL
;
_nbEvaluationPoints
=
0
;
_parent
=
NULL
;
}
...
...
@@ -236,7 +238,7 @@ class dataCacheMap {
{
_secondaryCaches
.
push_back
(
s
);
}
dataCacheDouble
&
get
(
const
function
*
f
,
dataCacheDouble
*
caller
=
0
);
dataCacheDouble
*
get
(
const
function
*
f
,
dataCacheDouble
*
caller
=
0
,
bool
createIfNotPresent
=
true
);
virtual
void
setElement
(
MElement
*
element
)
{
_element
=
element
;
...
...
@@ -257,6 +259,10 @@ class dataCacheMap {
m
->
_nbEvaluationPoints
=
0
;
return
m
;
}
inline
void
setSolutionFunction
(
const
function
*
functionSolution
,
const
function
*
functionSolutionGradient
)
{
_functionSolution
=
functionSolution
;
_functionSolutionGradient
=
functionSolutionGradient
;
}
void
setNbEvaluationPoints
(
int
nbEvaluationPoints
);
inline
int
getNbEvaluationPoints
()
{
return
_nbEvaluationPoints
;
}
};
...
...
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