Mesh Class Reference
[Finite Element Mesh]
#include <Mesh.h>
Detailed Description
To store and manipulate finite element meshes.Class Mesh enables defining as an object a finite element mesh. A finite element mesh is characterized by its nodes, elements and sides. Each of these types of data constitutes a class in the OFELI library.
Although each instance of classes Element, Node and Side can be accessed individually, it is highly recommended for a developer to modify any information about these classes only by using the Mesh members. Otherwise, the modifications would have no effect on the global mesh.
The standard procedure to introduce the finite element mesh is to provide an input file containing its data. For this, we have defined our own mesh data file (called an MDF file). Of course, a developer can write his own function to read his finite element mesh file using the methods in Mesh.
Public Types | |
| enum | ElementShape { LINE, TRIANGLE, QUADRILATERAL, TETRAHEDRON, HEXAHEDRON, PENTAHEDRON } |
Public Member Functions | |
| void | Add (size_t num, double *x) |
| Add a node by giving its label and an array containing its coordinates. | |
| void | Add (Edge *ed) |
| Add an edge to mesh. | |
| void | Add (Side *sd) |
| Add a side to mesh. | |
| void | Add (Element *el) |
| Add an element to mesh. | |
| void | Add (Node *nd) |
| Add a node to mesh. | |
| void | AddMidNodes (int g=0) |
| Add mid-side nodes. | |
| void | Bput (const string &mesh_file) const |
| Write mesh data on a binary file. | |
| int | createBoundarySideList () |
| Create list of boundary sides. | |
| int | createInternalSideList () |
| Create list of internal sides (not on the boundary). | |
| void | Delete (Edge *ed) |
| Remove an edge given by its pointer. | |
| void | Delete (Side *sd) |
| Remove a side given by its pointer. | |
| void | Delete (Element *el) |
| Remove a node given by its pointer. | |
| void | Delete (Node *nd) |
| Remove a node given by its pointer. | |
| void | DeleteElement (size_t label) |
| Remove an element given by its label. | |
| void | DeleteNode (size_t label) |
| Remove a node given by its label. | |
| void | DeleteSide (size_t label) |
| Remove a side given by its label. | |
| bool | EdgesAreDOF () const |
| Return information about DOF type. | |
| bool | ElementsAreDOF () const |
| Return information about DOF type. | |
| void | EliminateImposedDOF () |
| Eliminate equations corresponding to imposed DOF. | |
| void | get (const string &mesh_file) |
| Read mesh data in file written in MDF Format. | |
| int | getAllEdges () |
| Determine all edges. | |
| int | getAllSides (int opt=1) |
| Determine all mesh sides. | |
| Edge * | getBoundaryEdge () |
| Return pointer to current boundary edge and move to next one (Non constant version). | |
| const Edge * | getBoundaryEdge () const |
| Return pointer to current boundary edge and move to next one (Constant version). | |
| Side * | getBoundarySide () |
| Return pointer to current boundary side and move to next one (Non constant version). | |
| const Side * | getBoundarySide () const |
| Return pointer to current boundary side and move to next one (Constant version). | |
| int | getBoundarySides (int opt=1) |
| Determine all boundary sides. | |
| size_t | getDim () const |
| Return space dimension. | |
| Edge * | getEdge () |
| Return pointer to current edge and move to next one (Non constant version). | |
| const Edge * | getEdge () const |
| Return pointer to current edge and move to next one (Constant version). | |
| Edge & | getEdge (size_t i) const |
| Return reference to edge with label i. | |
| size_t | getEdgeLabel (size_t i) const |
| Return label of i-th edge. | |
| Element * | getElement () |
| Return pointer to current element and move to next one (Non constant version). | |
| const Element * | getElement () const |
| Return pointer to current element and move to next one (Constant version). | |
| Element & | getElement (size_t i) const |
| Return reference to element with label i. | |
| size_t | getElementLabel (size_t i) const |
| Return label of i-th element. | |
| void | getElementNeighborElements () |
| Create element neighboring elements. | |
| Side * | getInternalSide () |
| Return pointer to current internal side and move to next one (Non constant version). | |
| const Side * | getInternalSide () const |
| Return pointer to current internal side and move to next one (Constant version). | |
| Node * | getMarkedNode () |
| Return pointer to current marked node and move to next one (Non constant version). | |
| const Node * | getMarkedNode () const |
| Return pointer to current marked node and move to next one (Constant version). | |
| Point< double > | getMaxCoord () const |
| Return maximum coordinates of nodes. | |
| Point< double > | getMinCoord () const |
| Return minimum coordinates of nodes. | |
| size_t | getNbBoundarySides () const |
| Return number of boundary sides. | |
| size_t | getNbDOF () const |
| Return total number of degrees of freedom (DOF). | |
| size_t | getNbEdges () const |
| Return number of sides. | |
| size_t | getNbElements () const |
| Return number of elements. | |
| size_t | getNbEq () const |
| Return number of equations. | |
| size_t | getNbInternalSides () const |
| Return number of internal sides. | |
| size_t | getNbMarkedNodes () const |
| Return number of marked nodes. | |
| size_t | getNbMat () const |
| Return number of materials. | |
| size_t | getNbNodes () const |
| Return number of nodes. | |
| size_t | getNbSides () const |
| Return number of sides. | |
| size_t | getNbVertices () const |
| Return number of vertices. | |
| Node * | getNode () |
| Return pointer to current node and move to next one (Non constant version). | |
| const Node * | getNode () const |
| Return pointer to current node and move to next one (Constant version). | |
| Node & | getNode (size_t i) const |
| Return refenrece to node with label i. | |
| size_t | getNodeLabel (size_t i) const |
| Return label of i-th node. | |
| void | getNodeNeighborElements () |
| Create node neighboring elements. | |
| size_t | getNodeNewLabel (size_t n) const |
| Return new label of node of a renumbered node. | |
| Edge * | getPtrEdge (size_t i) const |
| Return pointer to edge with label i. | |
| Element * | getPtrElement (size_t i) const |
| Return pointer to element with label i. | |
| Node * | getPtrNode (size_t i) const |
| Return pointer to node with label i. | |
| Side * | getPtrSide (size_t i) const |
| Return pointer to side with label i. | |
| int | getShape () const |
| Determine shape of elements Returns Shape index (see enum ElementShape) if all elements have the same shape, 0 if not. | |
| Side * | getSide () |
| Return pointer to current side and move to next one (Non constant version). | |
| const Side * | getSide () const |
| Return pointer to current side and move to next one (Constant version). | |
| Side & | getSide (size_t i) const |
| Return reference to side with label i. | |
| size_t | getSideLabel (size_t i) const |
| Return label of i-th side. | |
| int | getVerbose () const |
| Return Verbose Parameter. | |
| bool | isStructured () const |
| Return true is mesh is structured, false if not. | |
| Mesh (const Mesh &ms) | |
| Copy Constructor. | |
| Mesh (const Mesh &m, const Point< double > &x_bl, const Point< double > &x_tr) | |
| Constructor that extracts the mesh of a rectangular region from an initial mesh. | |
| Mesh (double x_min, double x_max, double y_min, double y_max, size_t nx, size_t ny, int c1, int c2, int c3, int c4, int with_elements=0) | |
| Constructor for a uniform finite difference grid. | |
| Mesh (const Grid &g, int opt=QUADRILATERAL) | |
| Constructor for a uniform finite difference grid given by and instance of class Grid. | |
| Mesh (double Lmin, double Lmax, size_t nb_el, size_t p=1, size_t nb_dof=1) | |
| Constructor for a 1-D mesh. | |
| Mesh (const string &file, bool bc=false, int opt=NODE_DOF) | |
| Constructor using a mesh file (MDF format). | |
| Mesh () | |
| Default constructor (Empty mesh). | |
| bool | NodesAreDOF () const |
| Return information about DOF type. | |
| size_t | NumberEquations (size_t dof=0) |
| Renumber Equations. | |
| size_t | operator() (size_t i, size_t n) |
| Operator () : Returns pointer to i-th node of n-th element. | |
| Element * | operator() (size_t i) |
| Operator () : Returns pointer to i-th element. | |
| Mesh & | operator= (Mesh &ms) |
| Operator = : Assign a Mesh instance. | |
| Node * | operator[] (size_t i) |
| Operator [] : Returns pointer to i-th node. | |
| void | put (const string &mesh_file) const |
| Write mesh data on an MDF file. | |
| void | Refresh () |
| Refresh mesh after deletions. | |
| void | removeImposedDOF () |
| Eliminate equations corresponding to imposed DOF. | |
| void | RenumberEdge (size_t n1, size_t n2) |
| Renumber an edge. | |
| void | RenumberElement (size_t n1, size_t n2) |
| Renumber an element. | |
| void | RenumberNode (size_t n1, size_t n2) |
| Renumber a node. | |
| void | RenumberSide (size_t n1, size_t n2) |
| Renumber a side. | |
| void | Reorder (size_t m=GRAPH_MEMORY) |
| Renumber mesh nodes according to reverse Cuthill Mc Kee algorithm. | |
| void | setBoundaryOrientation () |
| Orient boundary sides in the direct sense. | |
| void | setDim (size_t dim) |
| Define space dimension. | |
| void | setDOFSupport (int opt) |
| Define supports of degrees of freedom. | |
| void | setElementView (size_t n1, size_t n2) |
| Set viewing window for elements. | |
| void | setMaterial (int code, const string &mname) |
| Associate material to code of element. | |
| void | setNodeView (size_t n1, size_t n2) |
| Set viewing window for nodes. | |
| void | setPointInDomain (Point< double > x) |
| Define a point in the domain. | |
| void | setSideView (size_t n1, size_t n2) |
| Set viewing window for sides. | |
| void | setVerbose (int verb) |
| Define Verbose Parameter. | |
| bool | SidesAreDOF () const |
| Return information about DOF type. | |
| void | topBoundaryEdge () const |
| Reset list of boundary edges at its top position (Constant version). | |
| void | topBoundaryEdge () |
| Reset list of boundary edges at its top position (Non constant version). | |
| void | topBoundarySide () const |
| Reset list of boundary sides at its top position (Constant version). | |
| void | topBoundarySide () |
| Reset list of boundary sides at its top position (Non constant version). | |
| void | topEdge () const |
| Reset list of edges at its top position (Constant version). | |
| void | topEdge () |
| Reset list of edges at its top position (Non constant version). | |
| void | topElement () const |
| Reset list of elements at its top position (Constant version). | |
| void | topElement () |
| Reset list of elements at its top position (Non constant version). | |
| void | topInternalSide () const |
| Reset list of internal sides at its top position (Constant version). | |
| void | topInternalSide () |
| Reset list of intrenal sides at its top position (Non constant version). | |
| void | topMarkedNode () const |
| Reset list of marked nodes at its top position (Constant version). | |
| void | topMarkedNode () |
| Reset list of marked nodes at its top position (Non constant version). | |
| void | topNode () const |
| Reset list of nodes at its top position (Constant version). | |
| void | topNode () |
| Reset list of nodes at its top position (Non constant version). | |
| void | topSide () const |
| Reset list of sides at its top position (Constant version). | |
| void | topSide () |
| Reset list of sides at its top position (Non constant version). | |
| bool | withImposedDOF () const |
| Return true if imposed DOF count in equations, false if not. | |
| ~Mesh () | |
| Destructor. | |
Friends | |
| void | Refine (Mesh &in_mesh, Mesh &out_mesh) |
| Refine mesh. | |
Member Enumeration Documentation
| enum ElementShape |
Constructor & Destructor Documentation
| Mesh | ( | const string & | file, | |
| bool | bc = false, |
|||
| int | opt = NODE_DOF | |||
| ) |
Constructor using a mesh file (MDF format).
- Parameters:
-
[in] file File containing mesh data in MDF format [in] bc Flag to remove (true) or not (false) imposed Degrees of Freedom [default: false] [in] opt Type of DOF support: To choose among enumerated values NODE_DOF, SIDE_DOF or ELEMENT_DOF. Say if degrees of freedom (unknowns) are supported by nodes, sides or elements.
| Mesh | ( | double | Lmin, | |
| double | Lmax, | |||
| size_t | nb_el, | |||
| size_t | p = 1, |
|||
| size_t | nb_dof = 1 | |||
| ) |
Constructor for a 1-D mesh.
The domain is the interval [Lmin,Lmax]
- Parameters:
-
[in] Lmin First end of the interval [in] Lmax Second end of the interval [in] nb_el Number of elements to generate [in] p Degree of finite element polynomial (Default = 1) [in] nb_dof Number of degrees of freedom for each node (Default = 1)
| Mesh | ( | double | x_min, | |
| double | x_max, | |||
| double | y_min, | |||
| double | y_max, | |||
| size_t | nx, | |||
| size_t | ny, | |||
| int | c1, | |||
| int | c2, | |||
| int | c3, | |||
| int | c4, | |||
| int | with_elements = 0 | |||
| ) |
Constructor for a uniform finite difference grid.
The domain is the rectangle (x_min,x_max)x(y_min,y_max)
- Parameters:
-
[in] x_min Min. value for x coordinate [in] x_max Max. value for y coordinate [in] y_min Min. value for x coordinate [in] y_max Max. value for y coordinate [in] nx Number of subintervals on the x-axis [in] ny Number of subintervals on the y-axis [in] c1 Code for nodes generated on the line y=y_min [in] c2 Code for nodes generated on the line x=x_max [in] c3 Code for nodes generated on the line y=y_max [in] c4 Code for nodes generated on the line x=x_min [in] with_elements Flag to generate elements as well (if not zero) ( Default = 0).
Constructor that extracts the mesh of a rectangular region from an initial mesh.
This constructor is useful for zooming purposes for instance.
- Parameters:
-
[in] m Initial mesh from which the submesh is extracted [in] x_bl Coordinate of bottom left vertex of the rectangle [in] x_tr Coordinate of top right vertex of the rectangle
Member Function Documentation
| void Add | ( | size_t | num, | |
| double * | x | |||
| ) |
Add a node by giving its label and an array containing its coordinates.
- Parameters:
-
[in] num Label of node to add [in] x C-array of node coordinates
| void AddMidNodes | ( | int | g = 0 |
) |
Add mid-side nodes.
This is function is valid for triangles only
- Parameters:
-
[in] g Option to say of barycentre node is to be added (>0) or not (=0)
| void Bput | ( | const string & | mesh_file | ) | const |
| int createBoundarySideList | ( | ) |
Create list of boundary sides.
This function is useful to loop over boundary sides without testing One this one is called, the function getNbBoundarySides() is available. Moreover, looping over boundary sides is available via the member functions topBoundarySide() and getBoundarySide()
- Return values:
-
n Number of boundary sides.
| int createInternalSideList | ( | ) |
Create list of internal sides (not on the boundary).
This function is useful to loop over internal sides without testing One this one is called, the function getNbInternalSides() is available. Moreover, looping over internal sides is available via the member functions topInternalSide() and getInternalSide()
- Return values:
-
n Number of internal sides.
| void Delete | ( | Edge * | ed | ) |
Remove an edge given by its pointer.
This function does not release the space previously occupied
- Parameters:
-
[in] ed Pointer to edge to delete
| void Delete | ( | Side * | sd | ) |
Remove a side given by its pointer.
This function does not release the space previously occupied
- Parameters:
-
[in] sd Pointer to side to delete
| void Delete | ( | Element * | el | ) |
Remove a node given by its pointer.
This function does not release the space previously occupied
- Parameters:
-
[in] el Pointer to element to delete
| void Delete | ( | Node * | nd | ) |
Remove a node given by its pointer.
This function does not release the space previously occupied
- Parameters:
-
[in] nd Pointer to node to delete
Referenced by Mesh::DeleteElement(), Mesh::DeleteNode(), and Mesh::DeleteSide().
| void DeleteElement | ( | size_t | label | ) |
Remove an element given by its label.
This function does not release the space previously occupied
- Parameters:
-
[in] label Label of element to delete
References Mesh::Delete(), and Mesh::getPtrElement().
| void DeleteNode | ( | size_t | label | ) |
Remove a node given by its label.
This function does not release the space previously occupied
- Parameters:
-
[in] label Label of node to delete
References Mesh::Delete(), and Mesh::getPtrNode().
| void DeleteSide | ( | size_t | label | ) |
Remove a side given by its label.
This function does not release the space previously occupied
- Parameters:
-
[in] label Label of side to delete
References Mesh::Delete(), and Mesh::getPtrSide().
| bool EdgesAreDOF | ( | ) | const |
Return information about DOF type.
- Return values:
-
true if DOF are supported by edges, false otherwise
| bool ElementsAreDOF | ( | ) | const |
Return information about DOF type.
- Return values:
-
true if DOF are supported by elements, false otherwise
Referenced by SkSMatrix::setMesh(), SkSMatrix::setSkyline(), and SkMatrix::setSkyline().
| void get | ( | const string & | mesh_file | ) |
| int getAllEdges | ( | ) |
Determine all edges.
- Return values:
-
nb Number of all edges.
| int getAllSides | ( | int | opt = 1 |
) |
Determine all mesh sides.
- Parameters:
-
[in] opt Orient (1) or not (0) boundary sides. Default value is 1. The orientation is counter clockwise. The orientation parameter has sense only in the 2-D case
- Return values:
-
nb Number of all sides.
| int getBoundarySides | ( | int | opt = 1 |
) |
Determine all boundary sides.
- Parameters:
-
[in] opt Orient (1) or not (0) boundary sides. Default value is 1. The orientation is counter clockwise.
- Return values:
-
n Number of boundary sides.
| size_t getEdgeLabel | ( | size_t | i | ) | const |
| size_t getElementLabel | ( | size_t | i | ) | const |
| size_t getNbBoundarySides | ( | ) | const |
Return number of boundary sides.
This function is valid if member function getAllSides or getBoundarySides has been invoked before
| size_t getNbInternalSides | ( | ) | const |
Return number of internal sides.
This function is valid if member functions getAllSides and createInternalSideList have been invoked before
| size_t getNodeLabel | ( | size_t | i | ) | const |
| int getShape | ( | ) | const |
Determine shape of elements Returns Shape index (see enum ElementShape) if all elements have the same shape, 0 if not.
| size_t getSideLabel | ( | size_t | i | ) | const |
| bool NodesAreDOF | ( | ) | const |
Return information about DOF type.
- Return values:
-
true if DOF are supported by nodes, false otherwise
Referenced by Vect::insertBC(), SkSMatrix::setMesh(), SkSMatrix::setSkyline(), SkMatrix::setSkyline(), and Vect::transferBC().
| size_t NumberEquations | ( | size_t | dof = 0 |
) |
Renumber Equations.
- Parameters:
-
[in] dof Label of degree of freedom for which numbering is performed. Default value (0) means that all degrees of freedom are taken into account
Referenced by Mesh::EliminateImposedDOF(), and Mesh::removeImposedDOF().
| void put | ( | const string & | mesh_file | ) | const |
| void RenumberEdge | ( | size_t | n1, | |
| size_t | n2 | |||
| ) |
Renumber an edge.
- Parameters:
-
[in] n1 Old label [in] n2 New label
| void RenumberElement | ( | size_t | n1, | |
| size_t | n2 | |||
| ) |
Renumber an element.
- Parameters:
-
[in] n1 Old label [in] n2 New label
| void RenumberNode | ( | size_t | n1, | |
| size_t | n2 | |||
| ) |
Renumber a node.
- Parameters:
-
[in] n1 Old label [in] n2 New label
| void RenumberSide | ( | size_t | n1, | |
| size_t | n2 | |||
| ) |
Renumber a side.
- Parameters:
-
[in] n1 Old label [in] n2 New label
| void Reorder | ( | size_t | m = GRAPH_MEMORY |
) |
Renumber mesh nodes according to reverse Cuthill Mc Kee algorithm.
- Parameters:
-
[in] m Memory size needed for matrix graph (default value is GRAPH_MEMORT, see OFELI_Config.h)
| void setBoundaryOrientation | ( | ) |
Orient boundary sides in the direct sense.
This one is defined such that outer boundary sides are oriented counterclockwise
| void setDim | ( | size_t | dim | ) |
Define space dimension.
Normally, between 1 and 3.
- Parameters:
-
[in] dim Space dimension to set (must be between 1 and 3)
| void setDOFSupport | ( | int | opt | ) |
Define supports of degrees of freedom.
- Parameters:
-
[in] opt DOF type = - NODE_DOF, Degrees of freedom are supported by nodes
- SIDE_DOF, Degrees of freedom are supported by sides
- EDGE_DOF, Degrees of freedom are supported by edges
- ELEMENT_DOF, Degrees of freedom are supported by elements
- Note:
- This member function creates all mesh sides if the option ELEMENT_DOF or SIDE_DOF is selected. So it not necessary to call getAllSides() after
| void setElementView | ( | size_t | n1, | |
| size_t | n2 | |||
| ) |
Set viewing window for elements.
- Parameters:
-
[in] n1 First element to view [in] n2 last element to view
| void setMaterial | ( | int | code, | |
| const string & | mname | |||
| ) |
Associate material to code of element.
- Parameters:
-
[in] code Element code for which material is assigned [in] mname Name of material
| void setNodeView | ( | size_t | n1, | |
| size_t | n2 | |||
| ) |
Set viewing window for nodes.
- Parameters:
-
[in] n1 First node to view [in] n2 last node to view
| void setPointInDomain | ( | Point< double > | x | ) |
Define a point in the domain.
This function makes sense only if boundary mesh is given without internal mesh (Case of Boundary Elements)
- Parameters:
-
[in] x Coordinates of point to define
| void setSideView | ( | size_t | n1, | |
| size_t | n2 | |||
| ) |
Set viewing window for sides.
- Parameters:
-
[in] n1 First side to view [in]