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
5d54bf3b
Commit
5d54bf3b
authored
15 years ago
by
Jonathan Lambrechts
Browse files
Options
Downloads
Patches
Plain Diff
use externat views in extract plugin
parent
f505c8a1
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
Plugin/Extract.cpp
+47
-7
47 additions, 7 deletions
Plugin/Extract.cpp
Solver/dgMainLua.cpp
+0
-62
0 additions, 62 deletions
Solver/dgMainLua.cpp
with
47 additions
and
69 deletions
Plugin/Extract.cpp
+
47
−
7
View file @
5d54bf3b
...
...
@@ -7,10 +7,13 @@
#include
"GmshDefines.h"
#include
"Extract.h"
#include
"mathEvaluator.h"
#include
"OctreePost.h"
StringXNumber
ExtractOptions_Number
[]
=
{
{
GMSH_FULLRC
,
"TimeStep"
,
NULL
,
-
1.
},
{
GMSH_FULLRC
,
"iView"
,
NULL
,
-
1.
}
{
GMSH_FULLRC
,
"iView"
,
NULL
,
-
1.
},
{
GMSH_FULLRC
,
"ExternalView"
,
NULL
,
-
1.
},
{
GMSH_FULLRC
,
"ExternalTimeStep"
,
NULL
,
-
1.
}
};
StringXString
ExtractOptions_String
[]
=
{
...
...
@@ -49,11 +52,12 @@ std::string GMSH_ExtractPlugin::getHelp() const
"Fabs, etc.) and operators (+, -, *, /, ^), all
\n
"
"expressions can contain the symbols v0, v1, v2,
\n
"
" ..., vn, which represent the n components of the
\n
"
"field, and the symbols x, y and z, which represent
\n
"
"the three spatial coordinates. If `TimeStep' < 0,
\n
"
"the plugin extracts data from all the time steps
\n
"
"in the view. If `iView' < 0, the plugin is run on
\n
"
"the current view.
\n
"
"field, w0, w1, w2,..., wn which represent the n components
\n
"
"of the external view and the symbols x, y and z,
\n
"
"which represent the three spatial coordinates.
\n
"
"If `TimeStep' < 0, the plugin extracts data from
\n
"
"all the time steps in the view.
\n
"
"If `iView' < 0, the plugin is run on the current view.
\n
"
"
\n
"
"Plugin(Extract) creates one new view.
\n
"
;
}
...
...
@@ -130,6 +134,8 @@ PView *GMSH_ExtractPlugin::execute(PView *view)
{
int
timeStep
=
(
int
)
ExtractOptions_Number
[
0
].
def
;
int
iView
=
(
int
)
ExtractOptions_Number
[
1
].
def
;
int
iExternalView
=
(
int
)
ExtractOptions_Number
[
2
].
def
;
int
stepExternal
=
(
int
)
ExtractOptions_Number
[
3
].
def
;
std
::
vector
<
std
::
string
>
expr
(
9
);
for
(
int
i
=
0
;
i
<
9
;
i
++
)
expr
[
i
]
=
ExtractOptions_String
[
i
].
def
;
...
...
@@ -141,6 +147,27 @@ PView *GMSH_ExtractPlugin::execute(PView *view)
Msg
::
Error
(
"Extract plugin cannot be applied to multi-mesh views"
);
return
view
;
}
PView
*
externalView
=
NULL
;
PViewData
*
dataExternal
=
NULL
;
OctreePost
*
octree
=
0
;
if
(
iExternalView
>=
0
){
externalView
=
getView
(
iExternalView
,
view
);
if
(
!
externalView
){
Msg
::
Error
(
"Extract plugin cannot found external view %i"
,
iExternalView
);
return
view
;
}
dataExternal
=
externalView
->
getData
();
if
(
dataExternal
->
hasMultipleMeshes
()){
Msg
::
Error
(
"Extract plugin cannot be applied to multi-mesh views"
);
return
view
;
}
if
((
data1
->
getNumEntities
()
!=
dataExternal
->
getNumEntities
())
||
(
data1
->
getNumElements
()
!=
dataExternal
->
getNumElements
())){
Msg
::
Info
(
"External view based on different grid: interpolating..."
);
octree
=
new
OctreePost
(
externalView
);
}
}
int
numComp2
;
if
(
expr
[
3
].
size
()
||
expr
[
4
].
size
()
||
expr
[
5
].
size
()
||
...
...
@@ -160,7 +187,7 @@ PView *GMSH_ExtractPlugin::execute(PView *view)
expr
.
resize
(
numComp2
);
const
char
*
names
[]
=
{
"x"
,
"y"
,
"z"
,
"v0"
,
"v1"
,
"v2"
,
"v3"
,
"v4"
,
"v5"
,
"v6"
,
"v7"
,
"v8"
};
{
"x"
,
"y"
,
"z"
,
"v0"
,
"v1"
,
"v2"
,
"v3"
,
"v4"
,
"v5"
,
"v6"
,
"v7"
,
"v8"
,
"w0"
,
"w1"
,
"w2"
,
"w3"
,
"w4"
,
"w5"
,
"w6"
,
"w7"
,
"w8"
,
"w9"
};
unsigned
int
numVariables
=
sizeof
(
names
)
/
sizeof
(
names
[
0
]);
std
::
vector
<
std
::
string
>
variables
(
numVariables
);
for
(
unsigned
int
i
=
0
;
i
<
numVariables
;
i
++
)
variables
[
i
]
=
names
[
i
];
...
...
@@ -186,7 +213,9 @@ PView *GMSH_ExtractPlugin::execute(PView *view)
int
numNodes
=
data1
->
getNumNodes
(
0
,
ent
,
ele
);
int
type
=
data1
->
getType
(
0
,
ent
,
ele
);
int
numComp
=
data1
->
getNumComponents
(
0
,
ent
,
ele
);
int
numCompExternal
=
!
dataExternal
?
9
:
octree
?
9
:
dataExternal
->
getNumComponents
(
stepExternal
,
ent
,
ele
);
std
::
vector
<
double
>
*
out
=
incrementList
(
data2
,
numComp2
,
type
);
std
::
vector
<
double
>
w
(
std
::
max
(
9
,
numCompExternal
),
0.
);
std
::
vector
<
double
>
x
(
numNodes
),
y
(
numNodes
),
z
(
numNodes
);
for
(
int
nod
=
0
;
nod
<
numNodes
;
nod
++
)
data1
->
getNode
(
0
,
ent
,
ele
,
nod
,
x
[
nod
],
y
[
nod
],
z
[
nod
]);
...
...
@@ -201,7 +230,18 @@ PView *GMSH_ExtractPlugin::execute(PView *view)
for
(
int
comp
=
0
;
comp
<
numComp
;
comp
++
)
data1
->
getValue
(
step
,
ent
,
ele
,
nod
,
comp
,
v
[
comp
]);
values
[
0
]
=
x
[
nod
];
values
[
1
]
=
y
[
nod
];
values
[
2
]
=
z
[
nod
];
if
(
dataExternal
){
if
(
octree
){
if
(
!
octree
->
searchScalar
(
x
[
nod
],
y
[
nod
],
z
[
nod
],
&
w
[
0
],
stepExternal
))
if
(
!
octree
->
searchVector
(
x
[
nod
],
y
[
nod
],
z
[
nod
],
&
w
[
0
],
stepExternal
))
octree
->
searchTensor
(
x
[
nod
],
y
[
nod
],
z
[
nod
],
&
w
[
0
],
stepExternal
);
}
else
for
(
int
comp
=
0
;
comp
<
numCompExternal
;
comp
++
)
dataExternal
->
getValue
(
stepExternal
,
ent
,
ele
,
nod
,
comp
,
w
[
comp
]);
}
for
(
int
i
=
0
;
i
<
9
;
i
++
)
values
[
3
+
i
]
=
v
[
i
];
for
(
int
i
=
0
;
i
<
9
;
i
++
)
values
[
12
+
i
]
=
w
[
i
];
if
(
f
.
eval
(
values
,
res
))
for
(
int
i
=
0
;
i
<
numComp2
;
i
++
)
out
->
push_back
(
res
[
i
]);
...
...
This diff is collapsed.
Click to expand it.
Solver/dgMainLua.cpp
deleted
100644 → 0
+
0
−
62
View file @
f505c8a1
#include
<iostream>
#include
"Gmsh.h"
#include
"Bindings.h"
#include
"dgSystemOfEquations.h"
#include
"luaFunction.h"
#include
"function.h"
#include
"dgGroupOfElements.h"
#include
"dgConservationLawShallowWater2d.h"
#include
"dgConservationLawAdvection.h"
#include
"dgConservationLawPerfectGas.h"
#include
"dgConservationLawWaveEquation.h"
extern
"C"
{
#include
"lua.h"
#include
"lualib.h"
#include
"lauxlib.h"
}
void
report_errors
(
lua_State
*
L
,
int
status
)
{
if
(
status
!=
0
)
{
std
::
cerr
<<
"-- "
<<
lua_tostring
(
L
,
-
1
)
<<
std
::
endl
;
lua_pop
(
L
,
1
);
// remove error message
}
}
int
main
(
int
argc
,
char
*
argv
[])
{
GmshInitialize
(
argc
,
argv
);
lua_State
*
L
=
lua_open
();
luaopen_base
(
L
);
luaopen_table
(
L
);
luaopen_os
(
L
);
//luaopen_io(L);
luaopen_string
(
L
);
luaopen_math
(
L
);
luaopen_debug
(
L
);
// Register Lua bindings
classBinding
<
GModel
>::
Register
(
L
);
classBinding
<
dgSystemOfEquations
>::
Register
(
L
);
classBinding
<
dgBoundaryCondition
>::
Register
(
L
);
classBinding
<
dgConservationLaw
>::
Register
(
L
);
classBinding
<
dgConservationLawShallowWater2d
>::
Register
(
L
);
classBinding
<
dgConservationLawAdvection
>::
Register
(
L
);
classBinding
<
dgConservationLawWaveEquation
>::
Register
(
L
);
classBinding
<
dgPerfectGasLaw2d
>::
Register
(
L
);
classBinding
<
fullMatrix
<
double
>
>::
Register
(
L
);
classBinding
<
function
>::
Register
(
L
);
classBinding
<
functionLua
>::
Register
(
L
);
classBinding
<
functionConstant
>::
Register
(
L
);
function
::
registerDefaultFunctions
();
int
s
=
luaL_loadfile
(
L
,
argv
[
1
]);
if
(
s
==
0
)
{
printf
(
"lua executes %s
\n
"
,
argv
[
1
]);
s
=
lua_pcall
(
L
,
0
,
LUA_MULTRET
,
0
);
}
report_errors
(
L
,
s
);
lua_close
(
L
);
return
0
;
}
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