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
703d17ad
Commit
703d17ad
authored
13 years ago
by
Axel Modave
Browse files
Options
Downloads
Patches
Plain Diff
new plugin: Scal2Vec
parent
a2c4d730
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
Plugin/CMakeLists.txt
+1
-0
1 addition, 0 deletions
Plugin/CMakeLists.txt
Plugin/PluginManager.cpp
+3
-0
3 additions, 0 deletions
Plugin/PluginManager.cpp
Plugin/Scal2Vec.cpp
+158
-0
158 additions, 0 deletions
Plugin/Scal2Vec.cpp
Plugin/Scal2Vec.h
+33
-0
33 additions, 0 deletions
Plugin/Scal2Vec.h
with
195 additions
and
0 deletions
Plugin/CMakeLists.txt
+
1
−
0
View file @
703d17ad
...
...
@@ -28,6 +28,7 @@ set(SRC
FieldFromAmplitudePhase.cpp
Bubbles.cpp NearToFarField.cpp
DiscretizationError.cpp
Scal2Vec.cpp
)
file
(
GLOB HDR RELATIVE
${
CMAKE_CURRENT_SOURCE_DIR
}
*.h
)
...
...
This diff is collapsed.
Click to expand it.
Plugin/PluginManager.cpp
+
3
−
0
View file @
703d17ad
...
...
@@ -53,6 +53,7 @@
#include
"Bubbles.h"
#include
"NearToFarField.h"
#include
"DiscretizationError.h"
#include
"Scal2Vec.h"
// for testing purposes only :-)
#undef HAVE_DLOPEN
...
...
@@ -234,6 +235,8 @@ void PluginManager::registerDefaultPlugins()
(
"Bubbles"
,
GMSH_RegisterBubblesPlugin
()));
allPlugins
.
insert
(
std
::
pair
<
std
::
string
,
GMSH_Plugin
*>
(
"DiscretizationError"
,
GMSH_RegisterDiscretizationErrorPlugin
()));
allPlugins
.
insert
(
std
::
pair
<
std
::
string
,
GMSH_Plugin
*>
(
"Scal2Vec"
,
GMSH_RegisterScal2VecPlugin
()));
#if defined(HAVE_TETGEN)
allPlugins
.
insert
(
std
::
pair
<
std
::
string
,
GMSH_Plugin
*>
...
...
This diff is collapsed.
Click to expand it.
Plugin/Scal2Vec.cpp
0 → 100644
+
158
−
0
View file @
703d17ad
// Gmsh - Copyright (C) 1997-2011 C. Geuzaine, J.-F. Remacle
//
// See the LICENSE.txt file for license information. Please report all
// bugs and problems to <gmsh@geuz.org>.
#include
"Scal2Vec.h"
#include
"PViewOptions.h"
#include
"shapeFunctions.h"
StringXNumber
Scal2VecOptions_Number
[]
=
{
{
GMSH_FULLRC
,
"View X"
,
NULL
,
-
1.
},
{
GMSH_FULLRC
,
"View Y"
,
NULL
,
-
1.
},
{
GMSH_FULLRC
,
"View Z"
,
NULL
,
-
1.
}
};
StringXString
Scal2VecOptions_String
[]
=
{
{
GMSH_FULLRC
,
"Name NewView"
,
NULL
,
"NewView"
}
};
extern
"C"
{
GMSH_Plugin
*
GMSH_RegisterScal2VecPlugin
()
{
return
new
GMSH_Scal2VecPlugin
();
}
}
std
::
string
GMSH_Scal2VecPlugin
::
getHelp
()
const
{
return
"Plugin(Scal2Vec) converts the scalar fields of 'View X', "
"'View Y' and/or 'View Z' into a vectorial field. "
"The new view 'Name NewView' contains it.
\n\n
"
"If the value of 'View X', 'View Y' or 'View Z' is -1, "
"the value of the vectorial field in the corresponding direction is 0."
;
}
int
GMSH_Scal2VecPlugin
::
getNbOptions
()
const
{
return
sizeof
(
Scal2VecOptions_Number
)
/
sizeof
(
StringXNumber
);
}
StringXNumber
*
GMSH_Scal2VecPlugin
::
getOption
(
int
iopt
)
{
return
&
Scal2VecOptions_Number
[
iopt
];
}
int
GMSH_Scal2VecPlugin
::
getNbOptionsStr
()
const
{
return
sizeof
(
Scal2VecOptions_String
)
/
sizeof
(
StringXString
);
}
StringXString
*
GMSH_Scal2VecPlugin
::
getOptionStr
(
int
iopt
)
{
return
&
Scal2VecOptions_String
[
iopt
];
}
PView
*
GMSH_Scal2VecPlugin
::
execute
(
PView
*
v
)
{
int
iViewX
=
(
int
)
Scal2VecOptions_Number
[
0
].
def
;
int
iViewY
=
(
int
)
Scal2VecOptions_Number
[
1
].
def
;
int
iViewZ
=
(
int
)
Scal2VecOptions_Number
[
2
].
def
;
std
::
string
nameNewView
=
Scal2VecOptions_String
[
0
].
def
;
PView
*
vRef
=
0
,
*
vX
=
0
,
*
vY
=
0
,
*
vZ
=
0
;
PViewData
*
dataRef
,
*
dataX
,
*
dataY
,
*
dataZ
;
// Load data
if
(
iViewX
>=
0
){
vX
=
getView
(
iViewX
,
v
);
if
(
!
vX
){
Msg
::
Error
(
"Scal2Vec plugin could not find View X: %i"
,
iViewX
);
return
v
;
}
dataX
=
vX
->
getData
();
if
(
!
vRef
){
vRef
=
vX
;
dataRef
=
dataX
;
}
}
if
(
iViewY
>=
0
){
vY
=
getView
(
iViewY
,
v
);
if
(
!
vY
){
Msg
::
Error
(
"Scal2Vec plugin could not find View Y: %i"
,
iViewY
);
return
v
;
}
dataY
=
vY
->
getData
();
if
(
!
vRef
){
vRef
=
vY
;
dataRef
=
dataY
;
}
}
if
(
iViewZ
>=
0
){
vZ
=
getView
(
iViewZ
,
v
);
if
(
!
vZ
){
Msg
::
Error
(
"Scal2Vec plugin could not find View Z: %i"
,
iViewZ
);
return
v
;
}
dataZ
=
vZ
->
getData
();
if
(
!
vRef
){
vRef
=
vZ
;
dataRef
=
dataZ
;
}
}
if
(
!
vRef
){
Msg
::
Error
(
"Scal2Vec plugin could not find any view."
,
iViewZ
);
return
v
;
}
// Initialize the new view
PView
*
vNew
=
new
PView
();
PViewDataList
*
dataNew
=
getDataList
(
vNew
);
for
(
int
ent
=
0
;
ent
<
dataRef
->
getNumEntities
(
0
);
ent
++
){
for
(
int
ele
=
0
;
ele
<
dataRef
->
getNumElements
(
0
,
ent
);
ele
++
){
if
(
dataRef
->
skipElement
(
0
,
ent
,
ele
))
continue
;
int
numComp
=
3
;
// The 3 components of the new view: x,y,z
int
type
=
dataRef
->
getType
(
0
,
ent
,
ele
);
std
::
vector
<
double
>
*
out
=
dataNew
->
incrementList
(
numComp
,
type
);
// Pointer in data of the new view
if
(
!
out
)
continue
;
int
numNodes
=
dataRef
->
getNumNodes
(
0
,
ent
,
ele
);
double
x
[
8
],
y
[
8
],
z
[
8
],
valX
,
valY
,
valZ
;
for
(
int
nod
=
0
;
nod
<
numNodes
;
nod
++
)
dataRef
->
getNode
(
0
,
ent
,
ele
,
nod
,
x
[
nod
],
y
[
nod
],
z
[
nod
]);
int
dim
=
dataRef
->
getDimension
(
0
,
ent
,
ele
);
elementFactory
factory
;
element
*
element
=
factory
.
create
(
numNodes
,
dim
,
x
,
y
,
z
);
if
(
!
element
)
continue
;
for
(
int
nod
=
0
;
nod
<
numNodes
;
nod
++
)
out
->
push_back
(
x
[
nod
]);
// Save coordinates (x,y,z)
for
(
int
nod
=
0
;
nod
<
numNodes
;
nod
++
)
out
->
push_back
(
y
[
nod
]);
for
(
int
nod
=
0
;
nod
<
numNodes
;
nod
++
)
out
->
push_back
(
z
[
nod
]);
for
(
int
step
=
0
;
step
<
dataRef
->
getNumTimeSteps
();
step
++
){
for
(
int
nod
=
0
;
nod
<
numNodes
;
nod
++
){
if
(
vX
)
dataX
->
getValue
(
step
,
ent
,
ele
,
nod
,
0
,
valX
);
else
valX
=
0
;
if
(
vY
)
dataY
->
getValue
(
step
,
ent
,
ele
,
nod
,
0
,
valY
);
else
valY
=
0
;
if
(
vZ
)
dataZ
->
getValue
(
step
,
ent
,
ele
,
nod
,
0
,
valZ
);
else
valZ
=
0
;
out
->
push_back
(
valX
);
// Save values (fx,fy,fz)
out
->
push_back
(
valY
);
out
->
push_back
(
valZ
);
}
}
delete
element
;
}
}
for
(
int
step
=
0
;
step
<
dataRef
->
getNumTimeSteps
();
step
++
){
if
(
dataRef
->
hasTimeStep
(
step
)){
double
time
=
dataRef
->
getTime
(
step
);
dataNew
->
Time
.
push_back
(
time
);
}
}
dataNew
->
setName
(
nameNewView
);
dataNew
->
setFileName
(
nameNewView
+
".pos"
);
dataNew
->
finalize
();
return
vNew
;
}
This diff is collapsed.
Click to expand it.
Plugin/Scal2Vec.h
0 → 100644
+
33
−
0
View file @
703d17ad
// Gmsh - Copyright (C) 1997-2011 C. Geuzaine, J.-F. Remacle
//
// See the LICENSE.txt file for license information. Please report all
// bugs and problems to <gmsh@geuz.org>.
#ifndef _SCAL2VEC_H_
#define _SCAL2VEC_H_
#include
"Plugin.h"
extern
"C"
{
GMSH_Plugin
*
GMSH_RegisterScal2VecPlugin
();
}
class
GMSH_Scal2VecPlugin
:
public
GMSH_PostPlugin
{
public:
GMSH_Scal2VecPlugin
(){}
std
::
string
getName
()
const
{
return
"Scal2Vec"
;
}
std
::
string
getShortHelp
()
const
{
return
"Convert some scalar fields into a vector field"
;
}
std
::
string
getHelp
()
const
;
int
getNbOptions
()
const
;
StringXNumber
*
getOption
(
int
iopt
);
int
getNbOptionsStr
()
const
;
StringXString
*
getOptionStr
(
int
iopt
);
PView
*
execute
(
PView
*
);
};
#endif
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