Skip to content
Snippets Groups Projects
Commit cad7d7e9 authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

print entity names

parent 85a15942
No related branches found
No related tags found
No related merge requests found
...@@ -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;
} }
...@@ -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()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment