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
a4c9bec7
Commit
a4c9bec7
authored
7 years ago
by
Christophe Geuzaine
Browse files
Options
Downloads
Patches
Plain Diff
comment + fix finalize
parent
afb335cb
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Common/gmsh.cpp
+6
-1
6 additions, 1 deletion
Common/gmsh.cpp
demos/api/t1.cpp
+6
-2
6 additions, 2 deletions
demos/api/t1.cpp
demos/api/t2.cpp
+19
-4
19 additions, 4 deletions
demos/api/t2.cpp
with
31 additions
and
7 deletions
Common/gmsh.cpp
+
6
−
1
View file @
a4c9bec7
...
@@ -59,7 +59,12 @@ int gmshInitialize(int argc, char **argv)
...
@@ -59,7 +59,12 @@ int gmshInitialize(int argc, char **argv)
int
gmshFinalize
()
int
gmshFinalize
()
{
{
if
(
!
isInitialized
())
return
-
1
;
if
(
!
isInitialized
())
return
-
1
;
return
!
GmshFinalize
();
if
(
GmshFinalize
()){
_initialized
=
0
;
return
0
;
}
Msg
::
Error
(
"Something went wrong when finalizing Gmsh"
);
return
1
;
}
}
int
gmshOpen
(
const
std
::
string
&
fileName
)
int
gmshOpen
(
const
std
::
string
&
fileName
)
...
...
This diff is collapsed.
Click to expand it.
demos/api/t1.cpp
+
6
−
2
View file @
a4c9bec7
// This reimplements gmsh/tutorial/t1.geo in C++. For all the elementary
// This reimplements gmsh/tutorial/t1.geo in C++. For all the elementary
// explanations about the general philosphy of entities in Gmsh, see the
// explanations about the general philosphy of entities in Gmsh, see the
// comments in the .geo file. Comments here will focus on the specifics of the
// comments in the .geo file. Comments here will focus on the specifics of the
...
@@ -64,12 +63,17 @@ int main(int argc, char **argv)
...
@@ -64,12 +63,17 @@ int main(int argc, char **argv)
// entity.
// entity.
gmshModelSetPhysicalName
(
2
,
6
,
"My surface"
);
gmshModelSetPhysicalName
(
2
,
6
,
"My surface"
);
// Before it can be meshed, the internal CAD representation (here in the
// built-in "Geo" CAD kernel) must be synchronized with the Gmsh model, which
// will create the relevant Gmsh data structure to represent the full topology
// of the model. This is achieved by the gmshModelGeoSynchronize() API call.
gmshModelGeoSynchronize
();
gmshModelGeoSynchronize
();
// We can then generate a 2D mesh, and save it to disk.
gmshModelMesh
(
2
);
gmshModelMesh
(
2
);
gmshExport
(
"t1.msh"
);
gmshExport
(
"t1.msh"
);
// Gmsh finalize should be called at the end.
gmshFinalize
();
gmshFinalize
();
return
0
;
return
0
;
}
}
This diff is collapsed.
Click to expand it.
demos/api/t2.cpp
+
19
−
4
View file @
a4c9bec7
#include
<gmsh.h>
// This reimplements gmsh/tutorial/t2.geo in C++. Comments focus on the new API
// functions used compared to t1.cpp.
// this reimplements gmsh/tutorial/t2.geo
#include
<gmsh.h>
int
main
(
int
argc
,
char
**
argv
)
int
main
(
int
argc
,
char
**
argv
)
{
{
...
@@ -9,7 +10,7 @@ int main(int argc, char **argv)
...
@@ -9,7 +10,7 @@ int main(int argc, char **argv)
gmshModelCreate
(
"t2"
);
gmshModelCreate
(
"t2"
);
//
c
opy/paste from t1.cpp
//
C
opy/paste from t1.cpp
double
lc
=
1e-2
;
double
lc
=
1e-2
;
int
o
;
int
o
;
gmshModelGeoAddPoint
(
1
,
0
,
0
,
0
,
o
,
lc
);
gmshModelGeoAddPoint
(
1
,
0
,
0
,
0
,
o
,
lc
);
...
@@ -28,12 +29,20 @@ int main(int argc, char **argv)
...
@@ -28,12 +29,20 @@ int main(int argc, char **argv)
gmshModelAddPhysicalGroup
(
1
,
2
,
{
1
,
2
});
gmshModelAddPhysicalGroup
(
1
,
2
,
{
1
,
2
});
gmshModelAddPhysicalGroup
(
2
,
6
,
{
1
});
gmshModelAddPhysicalGroup
(
2
,
6
,
{
1
});
gmshModelSetPhysicalName
(
2
,
6
,
"My surface"
);
gmshModelSetPhysicalName
(
2
,
6
,
"My surface"
);
//
e
nd copy/paste
//
E
nd copy/paste
gmshModelGeoAddPoint
(
5
,
0
,
.4
,
0
,
o
,
lc
);
gmshModelGeoAddPoint
(
5
,
0
,
.4
,
0
,
o
,
lc
);
gmshModelGeoAddLine
(
5
,
4
,
5
,
o
);
gmshModelGeoAddLine
(
5
,
4
,
5
,
o
);
// Geometrical transformations take a std::vector of std::pair<int, int> as
// first argument, which contains the list of entities, represented by
// (dimension,tag) pairs. Here we translate point 3 (dimension = 0, tag = 3),
// by dx=-0.05, dy=0, dz=0.
gmshModelGeoTranslate
({{
0
,
3
}},
-
0.05
,
0
,
0
);
gmshModelGeoTranslate
({{
0
,
3
}},
-
0.05
,
0
,
0
);
// The "Duplicata" functionality in .geo files is handled by
// gmshModelGeoCopy(), which takes a vector of (dim,tag) pairs as input, and
// returns another vector of (dim,tag) pairs.
std
::
vector
<
std
::
pair
<
int
,
int
>
>
ov
,
ov2
;
std
::
vector
<
std
::
pair
<
int
,
int
>
>
ov
,
ov2
;
gmshModelGeoCopy
({{
0
,
3
}},
ov
);
gmshModelGeoCopy
({{
0
,
3
}},
ov
);
gmshModelGeoTranslate
(
ov
,
0
,
0.1
,
0
);
gmshModelGeoTranslate
(
ov
,
0
,
0.1
,
0
);
...
@@ -73,11 +82,17 @@ int main(int argc, char **argv)
...
@@ -73,11 +82,17 @@ int main(int argc, char **argv)
gmshModelGeoAddLineLoop
(
126
,
{
115
,
116
,
117
,
114
},
o
);
gmshModelGeoAddLineLoop
(
126
,
{
115
,
116
,
117
,
114
},
o
);
gmshModelGeoAddPlaneSurface
(
127
,
{
126
},
o
);
gmshModelGeoAddPlaneSurface
(
127
,
{
126
},
o
);
// The API to create surface loops ("shells") and volumes is similar to the
// one use to create line loops and surfaces.
gmshModelGeoAddSurfaceLoop
(
128
,
{
127
,
119
,
121
,
123
,
125
,
11
},
o
);
gmshModelGeoAddSurfaceLoop
(
128
,
{
127
,
119
,
121
,
123
,
125
,
11
},
o
);
gmshModelGeoAddVolume
(
129
,
{
128
},
o
);
gmshModelGeoAddVolume
(
129
,
{
128
},
o
);
// Extrusion works as expected, by providing a vector of (dim,tag) pairs as
// input, the translation vector, and a vector of (dim,tag) pairs as output.
gmshModelGeoExtrude
({
ov
[
1
]},
0
,
0
,
0.12
,
ov2
);
gmshModelGeoExtrude
({
ov
[
1
]},
0
,
0
,
0.12
,
ov2
);
// Mesh sizes associated to geometrical points can be set by passing a vector
// of (dim,tag) pairs for the corresponding entities
gmshModelGeoSetMeshSize
({{
0
,
103
},
{
0
,
105
},
{
0
,
109
},
{
0
,
102
},
{
0
,
28
},
gmshModelGeoSetMeshSize
({{
0
,
103
},
{
0
,
105
},
{
0
,
109
},
{
0
,
102
},
{
0
,
28
},
{
0
,
24
},
{
0
,
6
},
{
0
,
5
}},
lc
*
3
);
{
0
,
24
},
{
0
,
6
},
{
0
,
5
}},
lc
*
3
);
...
...
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