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
b4d966be
Commit
b4d966be
authored
15 years ago
by
Jonathan Lambrechts
Browse files
Options
Downloads
Patches
Plain Diff
support functions with more than one dataCacheMap
parent
611d0cf0
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
+33
-27
33 additions, 27 deletions
Solver/function.cpp
Solver/function.h
+5
-1
5 additions, 1 deletion
Solver/function.h
with
38 additions
and
28 deletions
Solver/function.cpp
+
33
−
27
View file @
b4d966be
...
...
@@ -13,7 +13,7 @@
#include
"Bindings.h"
void
function
::
call
(
dataCacheMap
*
m
,
fullMatrix
<
double
>
&
res
,
std
::
vector
<
const
fullMatrix
<
double
>*>
&
depM
)
{
switch
(
dep
.
size
())
{
switch
(
arguments
.
size
())
{
case
0
:
call
(
m
,
res
);
break
;
case
1
:
call
(
m
,
*
depM
[
0
],
res
);
break
;
case
2
:
call
(
m
,
*
depM
[
0
],
*
depM
[
1
],
res
);
break
;
...
...
@@ -21,7 +21,7 @@ void function::call (dataCacheMap *m, fullMatrix<double> &res, std::vector<const
case
4
:
call
(
m
,
*
depM
[
0
],
*
depM
[
1
],
*
depM
[
2
],
*
depM
[
3
],
res
);
break
;
case
5
:
call
(
m
,
*
depM
[
0
],
*
depM
[
1
],
*
depM
[
2
],
*
depM
[
3
],
*
depM
[
4
],
res
);
break
;
case
6
:
call
(
m
,
*
depM
[
0
],
*
depM
[
1
],
*
depM
[
2
],
*
depM
[
3
],
*
depM
[
4
],
*
depM
[
5
],
res
);
break
;
default
:
Msg
::
Error
(
"function are not implemented for %i arguments
\n
"
,
dep
.
size
());
default
:
Msg
::
Error
(
"function are not implemented for %i arguments
\n
"
,
arguments
.
size
());
}
}
function
::
function
(
int
nbCol
)
:
_nbCol
(
nbCol
){};
...
...
@@ -37,6 +37,30 @@ void dataCacheDouble::addMeAsDependencyOf (dataCacheDouble *newDep)
}
}
dataCacheDouble
::
dataCacheDouble
(
dataCacheMap
&
map
,
int
nRowByPoint
,
int
nCol
)
:
_cacheMap
(
map
),
_value
(
nRowByPoint
==
0
?
1
:
nRowByPoint
*
map
.
getNbEvaluationPoints
(),
nCol
)
{
_nRowByPoint
=
nRowByPoint
;
map
.
addDataCacheDouble
(
this
);
};
dataCacheDouble
::
dataCacheDouble
(
dataCacheMap
*
m
,
function
*
f
)
:
_cacheMap
(
*
m
),
_value
(
m
->
getNbEvaluationPoints
(),
f
->
getNbCol
())
{
_nRowByPoint
=
1
;
m
->
addDataCacheDouble
(
this
);
_function
=
f
;
_dependencies
.
resize
(
_function
->
arguments
.
size
());
_depM
.
resize
(
_function
->
arguments
.
size
());
for
(
int
i
=
0
;
i
<
_function
->
arguments
.
size
();
i
++
)
_dependencies
[
i
]
=
&
m
[
_function
->
arguments
[
i
].
first
].
get
(
_function
->
arguments
[
i
].
second
,
this
);
}
void
dataCacheDouble
::
resize
()
{
_value
=
fullMatrix
<
double
>
(
_nRowByPoint
==
0
?
1
:
_nRowByPoint
*
_cacheMap
.
getNbEvaluationPoints
(),
_value
.
size2
());
}
//dataCacheMap members
static
dataCacheDouble
&
returnDataCacheDouble
(
dataCacheDouble
*
data
,
dataCacheDouble
*
caller
)
...
...
@@ -213,7 +237,7 @@ class functionStructuredGridFile : public function {
}
functionStructuredGridFile
(
const
std
::
string
filename
,
const
function
*
coordFunction
)
:
function
(
1
){
std
::
ifstream
input
(
filename
.
c_str
());
dep
.
push_back
(
coordFunction
);
addArgument
(
coordFunction
);
if
(
!
input
)
Msg
::
Error
(
"cannot open file : %s"
,
filename
.
c_str
());
if
(
filename
.
substr
(
filename
.
size
()
-
4
,
4
)
!=
".bin"
)
{
...
...
@@ -252,7 +276,9 @@ class functionLua : public function {
functionLua
(
int
nbCol
,
std
::
string
luaFunctionName
,
std
::
vector
<
const
function
*>
dependencies
,
lua_State
*
L
)
:
function
(
nbCol
),
_luaFunctionName
(
luaFunctionName
),
_L
(
L
)
{
dep
=
dependencies
;
for
(
std
::
vector
<
const
function
*>::
iterator
it
=
dependencies
.
begin
();
it
!=
dependencies
.
end
();
it
++
)
{
addArgument
(
*
it
);
}
}
};
#endif
...
...
@@ -304,28 +330,6 @@ void dataCacheMap::setNbEvaluationPoints(int nbEvaluationPoints) {
}
}
dataCacheDouble
::
dataCacheDouble
(
dataCacheMap
&
map
,
int
nRowByPoint
,
int
nCol
)
:
_cacheMap
(
map
),
_value
(
nRowByPoint
==
0
?
1
:
nRowByPoint
*
map
.
getNbEvaluationPoints
(),
nCol
){
_nRowByPoint
=
nRowByPoint
;
map
.
addDataCacheDouble
(
this
);
};
dataCacheDouble
::
dataCacheDouble
(
dataCacheMap
*
m
,
function
*
f
)
:
_cacheMap
(
*
m
),
_value
(
m
->
getNbEvaluationPoints
(),
f
->
getNbCol
())
{
_nRowByPoint
=
1
;
m
->
addDataCacheDouble
(
this
);
_function
=
f
;
_dependencies
.
resize
(
_function
->
dep
.
size
());
_depM
.
resize
(
_function
->
dep
.
size
());
for
(
int
i
=
0
;
i
<
_function
->
dep
.
size
();
i
++
)
_dependencies
[
i
]
=
&
m
->
get
(
_function
->
dep
[
i
],
this
);
}
void
dataCacheDouble
::
resize
()
{
_value
=
fullMatrix
<
double
>
(
_nRowByPoint
==
0
?
1
:
_nRowByPoint
*
_cacheMap
.
getNbEvaluationPoints
(),
_value
.
size2
());
}
//functionC
class
functionC
:
public
function
{
void
(
*
callback
)(
void
);
...
...
@@ -370,7 +374,9 @@ class functionC : public function {
functionC
(
std
::
string
file
,
std
::
string
symbol
,
int
nbCol
,
std
::
vector
<
const
function
*>
dependencies
)
:
function
(
nbCol
)
{
dep
=
(
dependencies
);
for
(
std
::
vector
<
const
function
*>::
iterator
it
=
dependencies
.
begin
();
it
!=
dependencies
.
end
();
it
++
)
{
addArgument
(
*
it
);
}
void
*
dlHandler
;
dlHandler
=
dlopen
(
file
.
c_str
(),
RTLD_NOW
);
callback
=
(
void
(
*
)(
void
))
dlsym
(
dlHandler
,
symbol
.
c_str
());
...
...
This diff is collapsed.
Click to expand it.
Solver/function.h
+
5
−
1
View file @
b4d966be
...
...
@@ -44,7 +44,11 @@ class function {
virtual
void
call
(
dataCacheMap
*
m
,
const
fullMatrix
<
double
>
&
arg0
,
const
fullMatrix
<
double
>
&
arg1
,
const
fullMatrix
<
double
>
&
arg2
,
const
fullMatrix
<
double
>
&
arg3
,
const
fullMatrix
<
double
>
&
arg4
,
fullMatrix
<
double
>
&
res
)
{
throw
;};
virtual
void
call
(
dataCacheMap
*
m
,
const
fullMatrix
<
double
>
&
arg0
,
const
fullMatrix
<
double
>
&
arg1
,
const
fullMatrix
<
double
>
&
arg2
,
const
fullMatrix
<
double
>
&
arg3
,
const
fullMatrix
<
double
>
&
arg4
,
const
fullMatrix
<
double
>
&
arg5
,
fullMatrix
<
double
>
&
res
)
{
throw
;};
public
:
std
::
vector
<
const
function
*>
dep
;
std
::
vector
<
std
::
pair
<
int
,
const
function
*>
>
arguments
;
void
addArgument
(
const
function
*
f
,
int
iMap
=
0
)
{
//iMap is the id of the dataCacheMap, e.g. on interfaces
arguments
.
push_back
(
std
::
pair
<
int
,
const
function
*>
(
iMap
,
f
));
}
virtual
~
function
(){};
static
void
registerBindings
(
binding
*
b
);
virtual
void
call
(
dataCacheMap
*
m
,
fullMatrix
<
double
>
&
res
,
std
::
vector
<
const
fullMatrix
<
double
>*>
&
depM
);
...
...
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