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
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Romin Tomasetti
gmsh
Commits
cad7d7e9
Commit
cad7d7e9
authored
Apr 10, 2020
by
Christophe Geuzaine
Browse files
Options
Downloads
Patches
Plain Diff
print entity names
parent
85a15942
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
tutorial/c++/x1.cpp
+21
-5
21 additions, 5 deletions
tutorial/c++/x1.cpp
tutorial/python/x1.py
+20
-3
20 additions, 3 deletions
tutorial/python/x1.py
with
41 additions
and
8 deletions
tutorial/c++/x1.cpp
+
21
−
5
View file @
cad7d7e9
...
@@ -30,6 +30,11 @@ int main(int argc, char **argv)
...
@@ -30,6 +30,11 @@ int main(int argc, char **argv)
// in the MSH format: `t1.exe file.msh'
// in the MSH format: `t1.exe file.msh'
gmsh
::
open
(
argv
[
1
]);
gmsh
::
open
(
argv
[
1
]);
// Print the model name and dimension:
std
::
string
name
;
gmsh
::
model
::
getCurrent
(
name
);
std
::
cout
<<
"Model "
<<
name
<<
" ("
<<
gmsh
::
model
::
getDimension
()
<<
"D)
\n
"
;
// Geometrical data is made of elementary model `entities', called `points'
// Geometrical data is made of elementary model `entities', called `points'
// (entities of dimension 0), `curves' (entities of dimension 1), `surfaces'
// (entities of dimension 0), `curves' (entities of dimension 1), `surfaces'
// (entities of dimension 2) and `volumes' (entities of dimension 3). As we
// (entities of dimension 2) and `volumes' (entities of dimension 3). As we
...
@@ -80,7 +85,11 @@ int main(int argc, char **argv)
...
@@ -80,7 +85,11 @@ int main(int argc, char **argv)
// * Type of the entity:
// * Type of the entity:
std
::
string
type
;
std
::
string
type
;
gmsh
::
model
::
getType
(
dim
,
tag
,
type
);
gmsh
::
model
::
getType
(
dim
,
tag
,
type
);
std
::
cout
<<
"Entity ("
<<
dim
<<
","
<<
tag
<<
") of type "
<<
type
<<
"
\n
"
;
std
::
string
name
;
gmsh
::
model
::
getEntityName
(
dim
,
tag
,
name
);
if
(
name
.
size
())
name
+=
" "
;
std
::
cout
<<
"Entity "
<<
name
<<
"("
<<
dim
<<
","
<<
tag
<<
") of type "
<<
type
<<
"
\n
"
;
// * Number of mesh nodes and elements:
// * Number of mesh nodes and elements:
int
numElem
=
0
;
int
numElem
=
0
;
...
@@ -102,9 +111,13 @@ int main(int argc, char **argv)
...
@@ -102,9 +111,13 @@ int main(int argc, char **argv)
std
::
vector
<
int
>
physicalTags
;
std
::
vector
<
int
>
physicalTags
;
gmsh
::
model
::
getPhysicalGroupsForEntity
(
dim
,
tag
,
physicalTags
);
gmsh
::
model
::
getPhysicalGroupsForEntity
(
dim
,
tag
,
physicalTags
);
if
(
physicalTags
.
size
())
{
if
(
physicalTags
.
size
())
{
std
::
cout
<<
" - Physical group tags:"
;
std
::
cout
<<
" - Physical group: "
;
for
(
std
::
size_t
j
=
0
;
j
<
physicalTags
.
size
();
j
++
)
for
(
std
::
size_t
j
=
0
;
j
<
physicalTags
.
size
();
j
++
)
{
std
::
cout
<<
" "
<<
physicalTags
[
j
];
std
::
string
n
;
gmsh
::
model
::
getPhysicalName
(
dim
,
physicalTags
[
j
],
n
);
if
(
n
.
size
())
n
+=
" "
;
std
::
cout
<<
n
<<
"("
<<
dim
<<
", "
<<
physicalTags
[
j
]
<<
") "
;
}
std
::
cout
<<
"
\n
"
;
std
::
cout
<<
"
\n
"
;
}
}
...
@@ -135,6 +148,9 @@ int main(int argc, char **argv)
...
@@ -135,6 +148,9 @@ int main(int argc, char **argv)
}
}
}
}
// We can use this to clear all the model data:
gmsh
::
clear
();
gmsh
::
finalize
();
gmsh
::
finalize
();
return
0
;
return
0
;
}
}
This diff is collapsed.
Click to expand it.
tutorial/python/x1.py
+
20
−
3
View file @
cad7d7e9
...
@@ -28,6 +28,10 @@ gmsh.option.setNumber("General.Terminal", 1)
...
@@ -28,6 +28,10 @@ gmsh.option.setNumber("General.Terminal", 1)
gmsh
.
open
(
sys
.
argv
[
1
])
gmsh
.
open
(
sys
.
argv
[
1
])
# Print the model name and dimension:
print
(
'
Model
'
+
gmsh
.
model
.
getCurrent
()
+
'
(
'
+
str
(
gmsh
.
model
.
getDimension
())
+
'
D)
'
)
# Geometrical data is made of elementary model `entities', called `points'
# Geometrical data is made of elementary model `entities', called `points'
# (entities of dimension 0), `curves' (entities of dimension 1), `surfaces'
# (entities of dimension 0), `curves' (entities of dimension 1), `surfaces'
# (entities of dimension 2) and `volumes' (entities of dimension 3). As we have
# (entities of dimension 2) and `volumes' (entities of dimension 3). As we have
...
@@ -71,8 +75,11 @@ for e in entities:
...
@@ -71,8 +75,11 @@ for e in entities:
# Let's print a summary of the information available on the entity and its
# Let's print a summary of the information available on the entity and its
# mesh.
# mesh.
# * Type of the entity:
# * Type and name of the entity:
print
(
"
Entity
"
+
str
(
e
)
+
"
of type
"
+
gmsh
.
model
.
getType
(
e
[
0
],
e
[
1
]))
type
=
gmsh
.
model
.
getType
(
e
[
0
],
e
[
1
])
name
=
gmsh
.
model
.
getEntityName
(
e
[
0
],
e
[
1
])
if
len
(
name
):
name
+=
'
'
print
(
"
Entity
"
+
name
+
str
(
e
)
+
"
of type
"
+
type
)
# * Number of mesh nodes and elements:
# * Number of mesh nodes and elements:
numElem
=
sum
(
len
(
i
)
for
i
in
elemTags
)
numElem
=
sum
(
len
(
i
)
for
i
in
elemTags
)
...
@@ -87,7 +94,12 @@ for e in entities:
...
@@ -87,7 +94,12 @@ for e in entities:
# * Does the entity belong to physical groups?
# * Does the entity belong to physical groups?
physicalTags
=
gmsh
.
model
.
getPhysicalGroupsForEntity
(
dim
,
tag
)
physicalTags
=
gmsh
.
model
.
getPhysicalGroupsForEntity
(
dim
,
tag
)
if
len
(
physicalTags
):
if
len
(
physicalTags
):
print
(
"
- Physical group tags:
"
+
str
(
physicalTags
))
s
=
''
for
p
in
physicalTags
:
n
=
gmsh
.
model
.
getPhysicalName
(
dim
,
p
)
if
n
:
n
+=
'
'
s
+=
n
+
'
(
'
+
str
(
dim
)
+
'
,
'
+
str
(
p
)
+
'
)
'
print
(
"
- Physical groups:
"
+
s
)
# * Is the entity a partition entity? If so, what is its parent entity?
# * Is the entity a partition entity? If so, what is its parent entity?
partitions
=
gmsh
.
model
.
getPartitions
(
e
[
0
],
e
[
1
])
partitions
=
gmsh
.
model
.
getPartitions
(
e
[
0
],
e
[
1
])
...
@@ -100,3 +112,8 @@ for e in entities:
...
@@ -100,3 +112,8 @@ for e in entities:
name
,
dim
,
order
,
numv
,
parv
,
_
=
gmsh
.
model
.
mesh
.
getElementProperties
(
t
)
name
,
dim
,
order
,
numv
,
parv
,
_
=
gmsh
.
model
.
mesh
.
getElementProperties
(
t
)
print
(
"
- Element type:
"
+
name
+
"
, order
"
+
str
(
order
)
+
"
(
"
+
print
(
"
- Element type:
"
+
name
+
"
, order
"
+
str
(
order
)
+
"
(
"
+
str
(
numv
)
+
"
nodes in param coord:
"
+
str
(
parv
)
+
"
)
"
)
str
(
numv
)
+
"
nodes in param coord:
"
+
str
(
parv
)
+
"
)
"
)
# We can use this to clear all the model data:
gmsh
.
clear
()
gmsh
.
finalize
()
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