This page describes the management of Cartesian meshes in Arcane.
- Note
- For now, Arcane does not automatically handle the recalculation of structuring information when the mesh changes. You must explicitly call Arcane::ICartesianMesh::computeDirections() to perform this recalculation.
Initialization
To have information about a Cartesian mesh, it is necessary to have an instance of the Arcane::ICartesianMesh class. To retrieve such an instance, you must use the Arcane::ICartesianMesh::getReference() method:
Interface of a Cartesian mesh.
static ICartesianMesh * getReference(const MeshHandleOrMesh &mesh, bool create=true)
Retrieves or creates the reference associated with mesh.
- Warning
- Once the instance is created and before you can use it, it is necessary to calculate the direction information via the Arcane::ICartesianMesh::computeDirections() method. This call should only be made once if the mesh does not change, for example, during code initialization.
virtual void computeDirections()=0
Calculates information for directional access.
Using Directional Information
Once this is done, it is possible to get information about the entities for a given direction. The possible directions are provided by the #eMeshDirection type. It is also possible to use an integer to specify the direction, where 0 corresponds to the X direction, 1 to the Y direction, and 2 to the Z direction. For readability reasons, it is recommended to use the enumerated type if possible. For example, to retrieve information about cells in the Y direction:
Info about the cells in a specific X, Y, or Z direction of a structured mesh.
virtual CellDirectionMng cellDirection(eMeshDirection dir)=0
List of cells in direction dir.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
- Warning
- The objects managing entities by direction are temporary objects that should not be retained, particularly from one iteration to the next or when the mesh changes.
Once a direction is retrieved, it is possible to iterate over all entities in that direction and, for cells for example, to get the cell before and after:
}
Cell before and after a cell along a direction.
For boundary cells, it is possible that prev_cell or next_cell is null. This can be tested using the Arcane::Cell::null() method.
Retrieving nodes in a direction is done in the same way.
}
Node before and after a node following a direction.
virtual NodeDirectionMng nodeDirection(eMeshDirection dir)=0
List of nodes in direction dir.
Info about nodes in a specific direction X, Y, or Z of a structured mesh.
For faces, the writing is similar, but instead of retrieving the face before and after the current face, you can retrieve the cell before and after:
}
Info on the cell before and after a face along a direction.
Info on the faces of a specific direction X, Y, or Z of a structured mesh.
virtual FaceDirectionMng faceDirection(eMeshDirection dir)=0
List of faces in direction dir.
Finally, for cells, it is possible to retrieve directional information about the nodes of a cell following a direction, via the Arcane::DirCellNode class.
}
Cell with directional node information.
Similarly, it is also possible to know the face in front of and behind the cell in a given direction (this also works in 3D):
}
Cell with directional face information.
To iterate over all directions of a mesh, you can loop as follows:
Integer nb_dir = mesh->dimension();
for(
Integer idir=0; idir<nb_dir; ++idir){
...
}
}
Int32 Integer
Type representing an integer.
It is possible to know the global number of cells in a given direction via Arcane::CellDirectionMng::globalNbCell(). Similarly, assuming that the subdomain decomposition can be represented as a grid, it is possible to know the numbering in this grid via Arcane::CellDirectionMng::subDomainOffset(). This numbering starts at 0.
It is also possible to know the number of own cells of the subdomain in a given direction via Arcane::CellDirectionMng::ownNbCell(). It is also possible to know the offset in the grid of the first own cell via Arcane::CellDirectionMng::ownCellOffset().
- Warning
- This information is only accessible if the mesh was generated via the specific Cartesian generator. In particular, it is not accessible if the mesh comes from a file. For more information, refer to the description of these methods.
Using Cartesian Connectivities
In 2D, it is possible to access the cells around a node and the nodes of the cell without going through directional connectivities. This is done via the Arcane::CartesianConnectivity object returned by calling Arcane::ICartesianMesh::connectivity(). For example:
And similarly for cells:
}
Connectivity information of a Cartesian mesh.
Cell lowerRight(Node n) const
Cell bottom right of node n.
Cell upperLeft(Node n) const
Cell top left of node n.
Cell lowerLeft(Node n) const
Cell bottom left of node n.
Cell upperRight(Node n) const
Cell top right of node n.
virtual CartesianConnectivity connectivity()=0
Connectivity information.
These connectivities are also accessible in 3D. The nomenclature is the same as for 2D connectivities. The prefix topZ is used for the nodes above the same following the Z direction. For those below, there is no prefix, and therefore the method name is the same as in 2D. This potentially allows the use of the same code in 2D and 3D.
}
Cell topZUpperRight(Node n) const
In 3D, cell top right of node n.
Cell topZLowerRight(Node n) const
In 3D, cell bottom right of node n.
Cell topZLowerLeft(Node n) const
In 3D, cell bottom left of node n.
Cell topZUpperLeft(Node n) const
In 3D, cell top left of node n.