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
6f765dba
Commit
6f765dba
authored
15 years ago
by
Jonathan Lambrechts
Browse files
Options
Downloads
Patches
Plain Diff
LuaBindings : accept reference as argument
parent
16ffea1d
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Common/LuaBindings.h
+38
-2
38 additions, 2 deletions
Common/LuaBindings.h
Solver/TESTCASES/WavePulse.lua
+0
-64
0 additions, 64 deletions
Solver/TESTCASES/WavePulse.lua
with
38 additions
and
66 deletions
Common/LuaBindings.h
+
38
−
2
View file @
6f765dba
...
...
@@ -58,7 +58,7 @@ class luaStack {
printf
(
"error cannot get generic class in lua, only pointers are implemented
\n
"
);
}
static
void
push
(
lua_State
*
L
,
type
obj
){
printf
(
"e
rror
cannot push generic class in lua, only pointers are implemented
\n
"
);
Msg
::
E
rror
(
"
cannot push generic class in lua, only pointers are implemented
\n
"
);
}
};
...
...
@@ -69,7 +69,7 @@ class luaStack<lua_State *>{
return
L
;
}
static
void
push
(
lua_State
*
L
,
int
i
){
printf
(
"error cannot push a lua_State in lua
\n
"
);
Msg
::
Error
(
"error cannot push a lua_State in lua
\n
"
);
}
};
...
...
@@ -159,6 +159,42 @@ class luaStack<const type *>{
}
};
template
<
typename
type
>
class
luaStack
<
type
&>
{
typedef
struct
{
type
*
pT
;}
userdataType
;
public
:
static
type
&
get
(
lua_State
*
L
,
int
ia
){
userdataType
*
ud
=
static_cast
<
userdataType
*>
(
lua_touserdata
(
L
,
ia
));
if
(
!
ud
)
luaL_typerror
(
L
,
ia
,
className
<
type
>::
get
().
c_str
());
return
*
ud
->
pT
;
}
static
void
push
(
lua_State
*
L
,
type
&
obj
){
/* userdataType *ud = static_cast<userdataType*>(lua_newuserdata(L, sizeof(userdataType)));
ud->pT=&obj;
luaL_getmetatable(L,className<type>::get().c_str()); // lookup metatable in Lua registry
lua_setmetatable(L, -2);*/
Msg
::
Error
(
"cannot push a reference lua
\n
"
);
}
};
template
<
typename
type
>
class
luaStack
<
const
type
&>
{
typedef
struct
{
type
*
pT
;}
userdataType
;
public
:
static
type
&
get
(
lua_State
*
L
,
int
ia
){
userdataType
*
ud
=
static_cast
<
userdataType
*>
(
lua_touserdata
(
L
,
ia
));
if
(
!
ud
)
luaL_typerror
(
L
,
ia
,
className
<
type
>::
get
().
c_str
());
return
*
ud
->
pT
;
}
static
void
push
(
lua_State
*
L
,
const
type
&
obj
){
/*userdataType *ud = static_cast<userdataType*>(lua_newuserdata(L, sizeof(userdataType)));
ud->pT=(type*)&obj;
luaL_getmetatable(L,className<type>::get().c_str()); // lookup metatable in Lua registry
lua_setmetatable(L, -2);*/
Msg
::
Error
(
"cannot push a reference lua
\n
"
);
}
};
/*** template to call c function from the lua stack ***/
//static, return
template
<
typename
tRet
,
typename
t0
,
typename
t1
,
typename
t2
,
typename
t3
>
...
...
This diff is collapsed.
Click to expand it.
Solver/TESTCASES/WavePulse.lua
deleted
100644 → 0
+
0
−
64
View file @
16ffea1d
--[[
Function for initial conditions
--]]
function
initial_condition
(
xyz
,
f
)
for
i
=
0
,
xyz
:
size1
()
-
1
do
X
=
xyz
:
get
(
i
,
0
)
-
.
5
Y
=
xyz
:
get
(
i
,
1
)
-
.
5
Z
=
xyz
:
get
(
i
,
2
)
-- X2 = xyz:get(i,0) - 1.5
-- Y2 = xyz:get(i,1) - .5
-- Z2 = xyz:get(i,2)
VALUE
=
math.exp
(
-
40
*
(
X
*
X
+
Y
*
Y
+
Z
*
Z
))
-- + math.exp(-40*(X2*X2+Y2*Y2+Z2*Z2));
f
:
set
(
i
,
0
,
VALUE
)
f
:
set
(
i
,
1
,
0
.
0
)
f
:
set
(
i
,
2
,
0
.
0
)
end
end
print
'*** Loading the mesh and the model ***'
myModel
=
GModel
()
--myModel:load('box.geo')
--myModel:load('box.msh')
--myModel:load('square_quads.msh')
myModel
:
load
(
'square_mixed.msh'
)
print
'*** Create a dg solver ***'
DG
=
dgSystemOfEquations
(
myModel
)
DG
:
setOrder
(
3
)
law
=
dgConservationLawWaveEquation
(
2
)
DG
:
setConservationLaw
(
law
)
law
:
addBoundaryCondition
(
'Border'
,
law
:
newBoundaryWall
())
DG
:
setup
()
initialCondition
=
functionLua
(
3
,
'initial_condition'
,{
'XYZ'
}):
getName
()
print
'*** setting the initial solution ***'
DG
:
L2Projection
(
initialCondition
)
print
'*** export ***'
DG
:
exportSolution
(
'output/solution_000'
)
print
'*** solve ***'
N
=
100
;
CFL
=
2
.
1
;
dt
=
CFL
*
DG
:
computeInvSpectralRadius
();
print
(
'DT = '
,
dt
)
for
i
=
1
,
N
do
-- norm = DG:multirateRK43(dt)
norm
=
DG
:
RK44
(
dt
)
if
(
i
%
100
==
0
)
then
print
(
'*** ITER ***'
,
i
,
norm
)
DG
:
exportSolution
(
string.format
(
"output/solution-%04d"
,
i
))
end
end
print
'*** done ***'
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