How to Use the Meshes as Group
From KratosWiki
In kratos each modelpart can store several meshes. This meshes can be accessed via a unique id of the mesh given from input file with GetMesh (or pGetMesh ) method:
ModelPart::MeshType& inlet_mesh = rThisModelPart.GetMesh(12); // 12 is the inlet group id in the input file
Loop Over Nodes
One can use the mesh object for accessing the node via NodesBegin and NodesEnd methods.
for(ModelPart::NodeIterator i_node = inlet_mesh.NodesBegin(12); i_node != inlet_mesh.NodesEnd(12); i_node++) { KRATOS_WATCH(i_node->Id()); //print the value of the node Id which belongs to inlet }
However the modelpart also provides the same methods with mesh Id as input to make the loop over the nodes of a mesh:
for(ModelPart::NodeIterator i_node = model_part.NodesBegin(12); i_node != model_part.NodesEnd(12); i_node++) { KRATOS_WATCH(i_node->Id()); //print the value of the node Id which belongs to inlet }
Loop over other entities
The loop over elements and conditions in a mesh is similar to the nodes described before. One can access it with a mesh reference:
ModelPart::MeshType& structure_mesh = rThisModelPart.GetMesh(10); // 10 is the structure group id in the input file for(ModelPart::ElementIterator i_element = structure_mesh.NodesBegin(12); i_element != structure_mesh.NodesEnd(12); i_element++) { KRATOS_WATCH(i_element->Id()); //print the value of the element Id which belongs to structure }
or via modelpart methods:
for(ModelPart::ElementIterator i_element = model_part.NodesBegin(12); i_element != model_part.NodesEnd(12); i_element++) { KRATOS_WATCH(i_element->Id()); //print the value of the element Id which belongs to structure }