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
Package registry
Model registry
Operate
Terraform modules
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
Romin Tomasetti
gmsh
Commits
083a6564
Commit
083a6564
authored
7 years ago
by
Christophe Geuzaine
Browse files
Options
Downloads
Patches
Plain Diff
more work on api
parent
aa65af63
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
Common/gmsh.cpp
+91
-31
91 additions, 31 deletions
Common/gmsh.cpp
Common/gmsh.h
+14
-17
14 additions, 17 deletions
Common/gmsh.h
utils/api_demos/t0.cpp
+28
-2
28 additions, 2 deletions
utils/api_demos/t0.cpp
with
133 additions
and
50 deletions
Common/gmsh.cpp
+
91
−
31
View file @
083a6564
...
...
@@ -3,11 +3,22 @@
// See the LICENSE.txt file for license information. Please report all
// bugs and problems to the public mailing list <gmsh@onelab.info>.
#include
"gmsh.h"
#include
"GmshGlobal.h"
#include
"GModel.h"
#include
"GModelIO_GEO.h"
#include
"GModelIO_OCC.h"
#include
"GVertex.h"
#include
"GEdge.h"
#include
"GFace.h"
#include
"GRegion.h"
#include
"MPoint.h"
#include
"MLine.h"
#include
"MTriangle.h"
#include
"MQuadrangle.h"
#include
"MTetrahedron.h"
#include
"MHexahedron.h"
#include
"MPrism.h"
#include
"MPyramid.h"
// gmsh
...
...
@@ -128,24 +139,24 @@ int gmshModelDestroy()
return
1
;
}
int
gmshModelGetE
lementaryTags
(
int
dim
,
std
::
vector
<
int
>
&
t
ags
)
int
gmshModelGetE
ntities
(
std
::
vector
<
std
::
pair
<
int
,
int
>
>
&
dimT
ags
)
{
std
::
vector
<
GEntity
*>
entities
;
GModel
::
current
()
->
getEntities
(
entities
,
dim
);
tags
.
clear
();
GModel
::
current
()
->
getEntities
(
entities
);
for
(
unsigned
int
i
=
0
;
i
<
entities
.
size
();
i
++
)
t
ags
.
push_back
(
entities
[
i
]
->
tag
());
dimT
ags
.
push_back
(
std
::
pair
<
int
,
int
>
(
entities
[
i
]
->
dim
(),
entities
[
i
]
->
tag
())
)
;
return
0
;
}
int
gmshModelGetPhysical
Tags
(
int
dim
,
std
::
vector
<
int
>
&
t
ags
)
int
gmshModelGetPhysical
Groups
(
std
::
vector
<
std
::
pair
<
int
,
int
>
>
&
dimT
ags
)
{
std
::
map
<
int
,
std
::
vector
<
GEntity
*>
>
groups
;
GModel
::
current
()
->
getPhysicalGroups
(
dim
,
groups
);
tags
.
clear
();
for
(
std
::
map
<
int
,
std
::
vector
<
GEntity
*>
>::
iterator
it
=
groups
.
begin
();
it
!=
groups
.
end
();
it
++
)
tags
.
push_back
(
it
->
first
);
std
::
map
<
int
,
std
::
vector
<
GEntity
*>
>
groups
[
4
];
GModel
::
current
()
->
getPhysicalGroups
(
groups
);
for
(
int
dim
=
0
;
dim
<
4
;
dim
++
){
for
(
std
::
map
<
int
,
std
::
vector
<
GEntity
*>
>::
iterator
it
=
groups
[
dim
].
begin
();
it
!=
groups
[
dim
].
end
();
it
++
)
dimTags
.
push_back
(
std
::
pair
<
int
,
int
>
(
dim
,
it
->
first
));
}
return
0
;
}
...
...
@@ -160,13 +171,12 @@ int gmshModelAddPhysicalGroup(int dim, int tag, const std::vector<int> &tags)
return
1
;
}
int
gmshModelGetE
lementaryTag
sForPhysicalGroup
(
int
dim
,
int
tag
,
int
gmshModelGetE
ntitie
sForPhysicalGroup
(
int
dim
,
int
tag
,
std
::
vector
<
int
>
&
tags
)
{
std
::
map
<
int
,
std
::
vector
<
GEntity
*>
>
groups
;
GModel
::
current
()
->
getPhysicalGroups
(
dim
,
groups
);
std
::
map
<
int
,
std
::
vector
<
GEntity
*>
>::
iterator
it
=
groups
.
find
(
tag
);
tags
.
clear
();
if
(
it
!=
groups
.
end
()){
for
(
unsigned
j
=
0
;
j
<
it
->
second
.
size
();
j
++
)
tags
.
push_back
(
it
->
second
[
j
]
->
tag
());
...
...
@@ -198,7 +208,7 @@ int gmshModelGetVertexCoordinates(int tag, double &x, double &y, double &z)
return
1
;
}
int
gmshModelGetBoundary
Tags
(
const
std
::
vector
<
std
::
pair
<
int
,
int
>
>
&
inDimTags
,
int
gmshModelGetBoundary
(
const
std
::
vector
<
std
::
pair
<
int
,
int
>
>
&
inDimTags
,
std
::
vector
<
std
::
pair
<
int
,
int
>
>
&
outDimTags
,
bool
combined
,
bool
oriented
,
bool
recursive
)
{
...
...
@@ -208,7 +218,7 @@ int gmshModelGetBoundaryTags(const std::vector<std::pair<int, int> > &inDimTags,
return
1
;
}
int
gmshModelGetE
lementaryTag
sInBoundingBox
(
int
dim
,
int
gmshModelGetE
ntitie
sInBoundingBox
(
int
dim
,
double
x1
,
double
y1
,
double
z1
,
double
x2
,
double
y2
,
double
z2
,
std
::
vector
<
int
>
&
tags
)
...
...
@@ -216,7 +226,6 @@ int gmshModelGetElementaryTagsInBoundingBox(int dim,
SBoundingBox3d
box
(
x1
,
y1
,
z1
,
x2
,
y2
,
z2
);
std
::
vector
<
GEntity
*>
entities
;
GModel
::
current
()
->
getEntitiesInBox
(
entities
,
box
,
dim
);
tags
.
clear
();
for
(
unsigned
int
i
=
0
;
i
<
entities
.
size
();
i
++
)
tags
.
push_back
(
entities
[
i
]
->
tag
());
return
0
;
...
...
@@ -256,28 +265,79 @@ int gmshModelMesh(int dim)
}
int
gmshModelGetMeshVertices
(
int
dim
,
int
tag
,
std
::
vector
<
int
>
&
vertexTags
,
std
::
vector
<
double
>
&
coords
,
std
::
vector
<
double
>
&
parametricCoords
)
std
::
vector
<
double
>
&
coords
)
{
GEntity
*
ge
=
GModel
::
current
()
->
getEntityByTag
(
dim
,
tag
);
if
(
!
ge
)
return
1
;
for
(
unsigned
int
i
=
0
;
i
<
ge
->
mesh_vertices
.
size
();
i
++
){
MVertex
*
v
=
ge
->
mesh_vertices
[
i
];
vertexTags
.
push_back
(
v
->
getNum
());
coords
.
push_back
(
v
->
x
());
coords
.
push_back
(
v
->
y
());
coords
.
push_back
(
v
->
z
());
}
return
0
;
}
int
gmshModelGetMeshElements
(
int
dim
,
int
tag
,
std
::
vector
<
int
>
&
types
,
template
<
class
T
>
static
void
addElementInfo
(
std
::
vector
<
T
*>
&
ele
,
std
::
vector
<
int
>
&
elementType
,
std
::
vector
<
std
::
vector
<
int
>
>
&
elementTags
,
std
::
vector
<
std
::
vector
<
int
>
>
&
vertexTags
)
{
return
0
;
if
(
ele
.
empty
())
return
;
elementType
.
push_back
(
ele
.
front
()
->
getTypeForMSH
());
elementTags
.
push_back
(
std
::
vector
<
int
>
());
vertexTags
.
push_back
(
std
::
vector
<
int
>
());
for
(
unsigned
int
i
=
0
;
i
<
ele
.
size
();
i
++
){
elementTags
.
back
().
push_back
(
ele
[
i
]
->
getNum
());
for
(
unsigned
int
j
=
0
;
j
<
ele
[
i
]
->
getNumVertices
();
j
++
){
vertexTags
.
back
().
push_back
(
ele
[
i
]
->
getVertex
(
j
)
->
getNum
());
}
}
}
int
gmshModelSetMeshSize
(
int
dim
,
int
tag
,
double
size
)
int
gmshModelGetMeshElements
(
int
dim
,
int
tag
,
std
::
vector
<
int
>
&
types
,
std
::
vector
<
std
::
vector
<
int
>
>
&
elementTags
,
std
::
vector
<
std
::
vector
<
int
>
>
&
vertexTags
)
{
GEntity
*
ge
=
GModel
::
current
()
->
getEntityByTag
(
dim
,
tag
);
if
(
!
ge
)
return
1
;
switch
(
dim
){
case
0
:
{
GVertex
*
v
=
static_cast
<
GVertex
*>
(
ge
);
addElementInfo
(
v
->
points
,
types
,
elementTags
,
vertexTags
);
break
;
}
case
1
:
{
GEdge
*
e
=
static_cast
<
GEdge
*>
(
ge
);
addElementInfo
(
e
->
lines
,
types
,
elementTags
,
vertexTags
);
break
;
}
case
2
:
{
GFace
*
f
=
static_cast
<
GFace
*>
(
ge
);
addElementInfo
(
f
->
triangles
,
types
,
elementTags
,
vertexTags
);
addElementInfo
(
f
->
quadrangles
,
types
,
elementTags
,
vertexTags
);
break
;
}
case
3
:
{
GRegion
*
r
=
static_cast
<
GRegion
*>
(
ge
);
addElementInfo
(
r
->
tetrahedra
,
types
,
elementTags
,
vertexTags
);
addElementInfo
(
r
->
hexahedra
,
types
,
elementTags
,
vertexTags
);
addElementInfo
(
r
->
prisms
,
types
,
elementTags
,
vertexTags
);
addElementInfo
(
r
->
pyramids
,
types
,
elementTags
,
vertexTags
);
break
;
}
}
return
0
;
}
int
gmshModelSet
Compound
(
int
dim
,
const
std
::
vector
<
int
>
&
tags
)
int
gmshModelSet
MeshSize
(
int
dim
,
int
tag
,
double
size
)
{
if
(
dim
)
return
2
;
GVertex
*
gv
=
GModel
::
current
()
->
getVertexByTag
(
tag
);
if
(
gv
){
gv
->
setPrescribedMeshSizeAtVertex
(
size
);
return
0
;
}
return
1
;
}
int
gmshModelSetTransfiniteLine
(
int
tag
,
int
nPoints
,
int
type
,
double
coef
)
{
...
...
This diff is collapsed.
Click to expand it.
Common/gmsh.h
+
14
−
17
View file @
083a6564
...
...
@@ -29,7 +29,7 @@
#endif
// gmsh
GMSH_API
gmshInitialize
(
int
argc
,
char
**
argv
);
GMSH_API
gmshInitialize
(
int
argc
=
0
,
char
**
argv
=
0
);
GMSH_API
gmshFinalize
();
GMSH_API
gmshOpen
(
const
std
::
string
&
fileName
);
GMSH_API
gmshMerge
(
const
std
::
string
&
fileName
);
...
...
@@ -46,34 +46,31 @@ GMSH_API gmshOptionGetString(const std::string &name, std::string &value);
GMSH_API
gmshModelCreate
(
const
std
::
string
&
name
);
GMSH_API
gmshModelSetCurrent
(
const
std
::
string
&
name
);
GMSH_API
gmshModelDestroy
();
GMSH_API
gmshModelGetE
lementaryTags
(
int
dim
,
std
::
vector
<
int
>
&
t
ags
);
GMSH_API
gmshModelGetPhysical
Tags
(
int
dim
,
std
::
vector
<
int
>
&
t
ags
);
GMSH_API
gmshModelGetE
ntities
(
std
::
vector
<
std
::
pair
<
int
,
int
>
>
&
dimT
ags
);
GMSH_API
gmshModelGetPhysical
Groups
(
std
::
vector
<
std
::
pair
<
int
,
int
>
>
&
dimT
ags
);
GMSH_API
gmshModelAddPhysicalGroup
(
int
dim
,
int
tag
,
const
std
::
vector
<
int
>
&
tags
);
GMSH_API
gmshModelGetElementaryTagsForPhysicalGroup
(
int
dim
,
int
tag
,
std
::
vector
<
int
>
&
tags
);
GMSH_API
gmshModelGetEntitiesForPhysicalGroup
(
int
dim
,
int
tag
,
std
::
vector
<
int
>
&
tags
);
GMSH_API
gmshModelSetPhysicalName
(
int
dim
,
int
tag
,
const
std
::
string
&
name
);
GMSH_API
gmshModelGetPhysicalName
(
int
dim
,
int
tag
,
std
::
string
&
name
);
GMSH_API
gmshModelGetVertexCoordinates
(
int
tag
,
std
::
vector
<
double
>
&
coord
);
GMSH_API
gmshModelGetBoundary
Tags
(
const
std
::
vector
<
std
::
pair
<
int
,
int
>
>
&
inDimTags
,
GMSH_API
gmshModelGetBoundary
(
const
std
::
vector
<
std
::
pair
<
int
,
int
>
>
&
inDimTags
,
std
::
vector
<
std
::
pair
<
int
,
int
>
>
&
outDimTags
,
bool
combined
,
bool
oriented
,
bool
recursive
);
GMSH_API
gmshModelGetElementaryTagsInBoundingBox
(
int
dim
,
double
x1
,
double
y1
,
double
z1
,
bool
combined
=
true
,
bool
oriented
=
true
,
bool
recursive
=
false
);
GMSH_API
gmshModelGetEntitiesInBoundingBox
(
int
dim
,
double
x1
,
double
y1
,
double
z1
,
double
x2
,
double
y2
,
double
z2
,
std
::
vector
<
int
>
&
tags
);
GMSH_API
gmshModelGetBoundingBox
(
int
dim
,
int
tag
,
double
&
x1
,
double
&
y1
,
double
&
z1
,
double
&
x2
,
double
&
y2
,
double
&
z2
);
GMSH_API
gmshModelGetBoundingBox
(
int
dim
,
int
tag
,
double
&
x1
,
double
&
y1
,
double
&
z1
,
double
&
x2
,
double
&
y2
,
double
&
z2
);
GMSH_API
gmshModelRemove
(
const
std
::
vector
<
std
::
pair
<
int
,
int
>
>
&
dimTags
,
bool
recursive
=
false
);
GMSH_API
gmshModelMesh
(
int
dim
);
GMSH_API
gmshModelGetMeshVertices
(
int
dim
,
int
tag
,
std
::
vector
<
int
>
&
vertexTags
,
std
::
vector
<
double
>
&
coords
,
std
::
vector
<
double
>
&
parametricCoords
);
std
::
vector
<
double
>
&
coords
);
GMSH_API
gmshModelGetMeshElements
(
int
dim
,
int
tag
,
std
::
vector
<
int
>
&
types
,
std
::
vector
<
std
::
vector
<
int
>
>
&
elementTags
,
std
::
vector
<
std
::
vector
<
int
>
>
&
vertexTags
);
GMSH_API
gmshModelSetMeshSize
(
int
dim
,
int
tag
,
double
size
);
GMSH_API
gmshModelSetCompound
(
int
dim
,
const
std
::
vector
<
int
>
&
tags
);
GMSH_API
gmshModelSetTransfiniteLine
(
int
tag
,
int
nPoints
,
int
type
,
double
coef
);
GMSH_API
gmshModelSetTransfiniteSurface
(
int
tag
,
int
arrangement
,
const
std
::
vector
<
int
>
&
cornerTags
);
...
...
This diff is collapsed.
Click to expand it.
utils/api_demos/t0.cpp
+
28
−
2
View file @
083a6564
#include
<iostream>
#include
<gmsh.h>
int
main
(
int
argc
,
char
**
argv
)
{
gmshInitialize
(
argc
,
argv
);
if
(
argc
<
2
){
std
::
cout
<<
"Usage: "
<<
argv
[
0
]
<<
" file.geo [options]
\n
"
;
return
1
;
}
gmshInitialize
();
gmshOptionSetNumber
(
"General.Terminal"
,
1
);
gmshOptionSetNumber
(
"Mesh.Algorithm"
,
5
);
gmshOpen
(
"test.geo"
);
gmshOpen
(
argv
[
1
]
);
gmshModelMesh
(
3
);
std
::
vector
<
std
::
pair
<
int
,
int
>
>
entities
;
gmshModelGetEntities
(
entities
);
for
(
unsigned
int
i
=
0
;
i
<
entities
.
size
();
i
++
){
std
::
vector
<
int
>
vertexTags
;
std
::
vector
<
double
>
vertexCoords
;
int
dim
=
entities
[
i
].
first
,
tag
=
entities
[
i
].
second
;
gmshModelGetMeshVertices
(
dim
,
tag
,
vertexTags
,
vertexCoords
);
std
::
vector
<
int
>
elemTypes
;
std
::
vector
<
std
::
vector
<
int
>
>
elemTags
,
elemVertexTags
;
gmshModelGetMeshElements
(
dim
,
tag
,
elemTypes
,
elemTags
,
elemVertexTags
);
int
numElem
=
0
;
for
(
unsigned
int
i
=
0
;
i
<
elemTags
.
size
();
i
++
)
numElem
+=
elemTags
[
i
].
size
();
std
::
cout
<<
vertexTags
.
size
()
<<
" mesh vertices and "
<<
numElem
<<
" mesh elements on entity ("
<<
dim
<<
","
<<
tag
<<
")
\n
"
;
}
gmshExport
(
"test.msh"
);
gmshExport
(
"test.unv"
);
gmshFinalize
();
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