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
df4b612c
Commit
df4b612c
authored
14 years ago
by
Jonathan Lambrechts
Browse files
Options
Downloads
Patches
Plain Diff
dg : functionPython/functionC (I forgot to commit this one week ago)
parent
b44d1db7
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
Common/gmshpy.i
+18
-0
18 additions, 0 deletions
Common/gmshpy.i
Solver/function.cpp
+90
-101
90 additions, 101 deletions
Solver/function.cpp
Solver/function.h
+20
-0
20 additions, 0 deletions
Solver/function.h
Solver/functionPython.h
+8
-7
8 additions, 7 deletions
Solver/functionPython.h
with
136 additions
and
108 deletions
Common/gmshpy.i
+
18
−
0
View file @
df4b612c
...
@@ -34,6 +34,24 @@
...
@@ -34,6 +34,24 @@
#include "DivideAndConquer.h"
#include "DivideAndConquer.h"
#include "Gmsh.h"
#include "Gmsh.h"
#include "functionPython.h"
#include "functionPython.h"
class errorHandler: public GmshMessage {
void operator()(std::string level, std::string message){
//const char *color = colorDefault;
std::cout<<level<<" : "<<message<<std::endl;
if (level=="Error" || level == "Fatal") {
//color = colorRed;
//color confuses ctest/cdash
//std::cout<<color<<level<<" : "<<message<<colorDefault<<"\n";
throw;
}
}
};
%}
%
init
%
{
errorHandler *eH = new errorHandler;
Msg::SetCallback(eH);
GmshInitialize();
%}
%}
namespace
std
{
namespace
std
{
...
...
This diff is collapsed.
Click to expand it.
Solver/function.cpp
+
90
−
101
View file @
df4b612c
...
@@ -71,25 +71,19 @@ function *function::getSolution()
...
@@ -71,25 +71,19 @@ function *function::getSolution()
// Get Solution Gradient + Additionnal class
// Get Solution Gradient + Additionnal class
class
functionSolutionGradient
:
public
function
{
functionSolutionGradient
::
functionSolutionGradient
()
:
function
(
0
){}
static
functionSolutionGradient
*
_instance
;
void
functionSolutionGradient
::
call
(
dataCacheMap
*
m
,
fullMatrix
<
double
>
&
sol
)
// constructor is private only 1 instance can exists, call get to
// access the instance
functionSolutionGradient
()
:
function
(
0
){}
public
:
void
call
(
dataCacheMap
*
m
,
fullMatrix
<
double
>
&
sol
)
{
{
Msg
::
Error
(
"a function requires the gradient of the solution but "
Msg
::
Error
(
"a function requires the gradient of the solution but "
"this algorithm does not provide the gradient of the solution"
);
"this algorithm does not provide the gradient of the solution"
);
throw
;
throw
;
}
}
static
function
*
get
()
function
*
functionSolutionGradient
::
get
()
{
{
if
(
!
_instance
)
if
(
!
_instance
)
_instance
=
new
functionSolutionGradient
();
_instance
=
new
functionSolutionGradient
();
return
_instance
;
return
_instance
;
}
}
};
functionSolutionGradient
*
functionSolutionGradient
::
_instance
=
NULL
;
functionSolutionGradient
*
functionSolutionGradient
::
_instance
=
NULL
;
...
@@ -606,11 +600,7 @@ class functionLua : public function {
...
@@ -606,11 +600,7 @@ class functionLua : public function {
// functionC
// functionC
class
functionC
:
public
function
{
void
functionC
::
buildLibrary
(
std
::
string
code
,
std
::
string
filename
)
std
::
vector
<
fullMatrix
<
double
>
>
args
;
void
(
*
callback
)(
void
);
public:
static
void
buildLibrary
(
std
::
string
code
,
std
::
string
filename
)
{
{
//todo use CMAKE_CXX_COMPILER
//todo use CMAKE_CXX_COMPILER
//todo use clean temporary file names
//todo use clean temporary file names
...
@@ -630,7 +620,7 @@ class functionC : public function {
...
@@ -630,7 +620,7 @@ class functionC : public function {
UnlinkFile
(
"_tmpSrc.cpp"
);
UnlinkFile
(
"_tmpSrc.cpp"
);
UnlinkFile
(
"_tmpMake.cpp"
);
UnlinkFile
(
"_tmpMake.cpp"
);
}
}
void
call
(
dataCacheMap
*
m
,
fullMatrix
<
double
>
&
val
)
void
functionC
::
call
(
dataCacheMap
*
m
,
fullMatrix
<
double
>
&
val
)
{
{
switch
(
args
.
size
())
{
switch
(
args
.
size
())
{
case
0
:
case
0
:
...
@@ -673,7 +663,7 @@ class functionC : public function {
...
@@ -673,7 +663,7 @@ class functionC : public function {
Msg
::
Error
(
"C callback not implemented for %i argurments"
,
args
.
size
());
Msg
::
Error
(
"C callback not implemented for %i argurments"
,
args
.
size
());
}
}
}
}
functionC
(
std
::
string
file
,
std
::
string
symbol
,
int
nbCol
,
functionC
::
functionC
(
std
::
string
file
,
std
::
string
symbol
,
int
nbCol
,
std
::
vector
<
const
function
*>
dependencies
)
:
std
::
vector
<
const
function
*>
dependencies
)
:
function
(
nbCol
)
function
(
nbCol
)
{
{
...
@@ -691,7 +681,6 @@ class functionC : public function {
...
@@ -691,7 +681,6 @@ class functionC : public function {
Msg
::
Error
(
"Cannot construct functionC without dlopen"
);
Msg
::
Error
(
"Cannot construct functionC without dlopen"
);
#endif
#endif
}
}
};
void
function
::
registerBindings
(
binding
*
b
)
void
function
::
registerBindings
(
binding
*
b
)
...
...
This diff is collapsed.
Click to expand it.
Solver/function.h
+
20
−
0
View file @
df4b612c
...
@@ -110,6 +110,16 @@ class functionSolution : public function {
...
@@ -110,6 +110,16 @@ class functionSolution : public function {
}
}
};
};
class
functionSolutionGradient
:
public
function
{
static
functionSolutionGradient
*
_instance
;
// constructor is private only 1 instance can exists, call get to
// access the instance
functionSolutionGradient
();
public:
void
call
(
dataCacheMap
*
m
,
fullMatrix
<
double
>
&
sol
);
static
function
*
get
();
};
class
functionReplaceCache
{
class
functionReplaceCache
{
public:
public:
dataCacheMap
*
map
;
dataCacheMap
*
map
;
...
@@ -270,6 +280,16 @@ class functionConstant : public function {
...
@@ -270,6 +280,16 @@ class functionConstant : public function {
void
set
(
double
val
);
void
set
(
double
val
);
};
};
class
functionC
:
public
function
{
std
::
vector
<
fullMatrix
<
double
>
>
args
;
void
(
*
callback
)(
void
);
public:
static
void
buildLibrary
(
std
::
string
code
,
std
::
string
filename
)
;
void
call
(
dataCacheMap
*
m
,
fullMatrix
<
double
>
&
val
)
;
functionC
(
std
::
string
file
,
std
::
string
symbol
,
int
nbCol
,
std
::
vector
<
const
function
*>
dependencies
);
};
functionConstant
*
functionConstantNew
(
const
std
::
vector
<
double
>&
);
functionConstant
*
functionConstantNew
(
const
std
::
vector
<
double
>&
);
functionConstant
*
functionConstantNew
(
double
);
functionConstant
*
functionConstantNew
(
double
);
...
...
This diff is collapsed.
Click to expand it.
Solver/functionPython.h
+
8
−
7
View file @
df4b612c
...
@@ -26,14 +26,15 @@ class functionPython : public function {
...
@@ -26,14 +26,15 @@ class functionPython : public function {
}
}
switch
(
args
.
size
())
{
switch
(
args
.
size
())
{
case
0
:
_pyargs
=
Py_BuildValue
(
"(O)"
,
_swigR
);
break
;
case
0
:
_pyargs
=
Py_BuildValue
(
"(O)"
,
_swigR
);
break
;
case
1
:
_pyargs
=
Py_BuildValue
(
"(OO)"
,
_swigR
,
_swigA
[
0
]
,
_swigA
[
1
],
_swigA
[
2
],
_swigA
[
3
],
_swigA
[
4
],
_swigA
[
5
],
_swigA
[
6
]
);
break
;
case
1
:
_pyargs
=
Py_BuildValue
(
"(OO)"
,
_swigR
,
_swigA
[
0
]);
break
;
case
2
:
_pyargs
=
Py_BuildValue
(
"(OOO)"
,
_swigR
,
_swigA
[
0
],
_swigA
[
1
]
,
_swigA
[
2
],
_swigA
[
3
],
_swigA
[
4
],
_swigA
[
5
],
_swigA
[
6
]
);
break
;
case
2
:
_pyargs
=
Py_BuildValue
(
"(OOO)"
,
_swigR
,
_swigA
[
0
],
_swigA
[
1
]);
break
;
case
3
:
_pyargs
=
Py_BuildValue
(
"(OOOO)"
,
_swigR
,
_swigA
[
0
],
_swigA
[
1
],
_swigA
[
2
]
,
_swigA
[
3
],
_swigA
[
4
],
_swigA
[
5
],
_swigA
[
6
]
);
break
;
case
3
:
_pyargs
=
Py_BuildValue
(
"(OOOO)"
,
_swigR
,
_swigA
[
0
],
_swigA
[
1
],
_swigA
[
2
]);
break
;
case
4
:
_pyargs
=
Py_BuildValue
(
"(OOOOO)"
,
_swigR
,
_swigA
[
0
],
_swigA
[
1
],
_swigA
[
2
],
_swigA
[
3
]
,
_swigA
[
4
],
_swigA
[
5
],
_swigA
[
6
]
);
break
;
case
4
:
_pyargs
=
Py_BuildValue
(
"(OOOOO)"
,
_swigR
,
_swigA
[
0
],
_swigA
[
1
],
_swigA
[
2
],
_swigA
[
3
]);
break
;
case
5
:
_pyargs
=
Py_BuildValue
(
"(OOOOOO)"
,
_swigR
,
_swigA
[
0
],
_swigA
[
1
],
_swigA
[
2
],
_swigA
[
3
],
_swigA
[
4
]
,
_swigA
[
5
],
_swigA
[
6
]
);
break
;
case
5
:
_pyargs
=
Py_BuildValue
(
"(OOOOOO)"
,
_swigR
,
_swigA
[
0
],
_swigA
[
1
],
_swigA
[
2
],
_swigA
[
3
],
_swigA
[
4
]);
break
;
case
6
:
_pyargs
=
Py_BuildValue
(
"(OOOOOOO)"
,
_swigR
,
_swigA
[
0
],
_swigA
[
1
],
_swigA
[
2
],
_swigA
[
3
],
_swigA
[
4
],
_swigA
[
5
]
,
_swigA
[
6
]
);
break
;
case
6
:
_pyargs
=
Py_BuildValue
(
"(OOOOOOO)"
,
_swigR
,
_swigA
[
0
],
_swigA
[
1
],
_swigA
[
2
],
_swigA
[
3
],
_swigA
[
4
],
_swigA
[
5
]);
break
;
case
7
:
_pyargs
=
Py_BuildValue
(
"(OOOOOOOO)"
,
_swigR
,
_swigA
[
0
],
_swigA
[
1
],
_swigA
[
2
],
_swigA
[
3
],
_swigA
[
4
],
_swigA
[
5
],
_swigA
[
6
]);
break
;
case
7
:
_pyargs
=
Py_BuildValue
(
"(OOOOOOOO)"
,
_swigR
,
_swigA
[
0
],
_swigA
[
1
],
_swigA
[
2
],
_swigA
[
3
],
_swigA
[
4
],
_swigA
[
5
],
_swigA
[
6
]);
break
;
default:
Msg
::
Error
(
"python function not implemented for more than 7 arguments"
);
case
8
:
_pyargs
=
Py_BuildValue
(
"(OOOOOOOOO)"
,
_swigR
,
_swigA
[
0
],
_swigA
[
1
],
_swigA
[
2
],
_swigA
[
3
],
_swigA
[
4
],
_swigA
[
5
],
_swigA
[
6
],
_swigA
[
7
]);
break
;
default:
Msg
::
Error
(
"python function not implemented for more than 8 arguments"
);
}
}
}
}
};
};
...
...
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