Hermes2D
2.0
|
Represents a finite element mesh. Typical usage: Hermes::Hermes2D::Mesh mesh; Hermes::Hermes2D::MeshReaderH2DXML mloader; try { mloader.load("mesh.xml", &mesh); } catch(Exceptions::MeshLoadFailureException& e) { e.print_msg(); return -1; }. More...
#include <mesh.h>
Classes | |
class | ReferenceMeshCreator |
Class for creating reference mesh. More... | |
Public Member Functions | |
void | init (int size=H2D_DEFAULT_HASH_SIZE) |
virtual bool | isOkay () const |
State querying helpers. | |
std::string | getClassName () const |
Get class name, for the purpose of messaging. | |
bool | rescale (double x_ref, double y_ref) |
Rescales the mesh. | |
void | copy (const Mesh *mesh) |
Creates a copy of another mesh. | |
void | copy_base (Mesh *mesh) |
Copies the coarsest elements of another mesh. | |
void | copy_converted (Mesh *mesh) |
Copies the active elements of a converted mesh. | |
void | create (int nv, double2 *verts, int nt, int3 *tris, std::string *tri_markers, int nq, int4 *quads, std::string *quad_markers, int nm, int2 *mark, std::string *boundary_markers) |
Creates a mesh from given vertex, triangle, quad, and marker arrays. | |
void | free () |
Frees all data associated with the mesh. | |
Element * | get_element (int id) const |
Retrieves an element by its id number. | |
int | get_num_elements () const |
Returns the total number of elements stored. | |
int | get_num_base_elements () const |
Returns the number of base mesh elements. More... | |
int | get_num_used_base_elements () const |
Returns the number of used base mesh elements. More... | |
int | get_num_active_elements () const |
Returns the current number of active elements in the mesh. | |
int | get_max_element_id () const |
Returns the maximum node id number plus one. | |
int | get_num_vertex_nodes () const |
Returns the number of vertex nodes. | |
int | get_num_edge_nodes () const |
Returns the number of edge nodes. | |
void | refine_element_id (int id, int refinement=0) |
void | refine_all_elements (int refinement=0, bool mark_as_initial=false) |
void | refine_by_criterion (int(*criterion)(Element *e), int depth=1, bool mark_as_initial=false) |
void | refine_towards_vertex (int vertex_id, int depth=1, bool mark_as_initial=false) |
void | refine_towards_boundary (Hermes::vector< std::string > markers, int depth=1, bool aniso=true, bool mark_as_initial=false) |
void | refine_towards_boundary (std::string marker, int depth=1, bool aniso=true, bool mark_as_initial=false) |
void | refine_in_area (std::string marker, int depth=1, bool mark_as_initial=false) |
Refines all element sharing the marker passed. | |
void | refine_in_areas (Hermes::vector< std::string > markers, int depth=1, bool mark_as_initial=false) |
Refines all element sharing the markers passed. | |
int * | regularize (int n) |
void | unrefine_element_id (int id) |
void | unrefine_all_elements (bool keep_initial_refinements=true) |
Element * | get_element_fast (int id) const |
For internal use. | |
unsigned | get_seq () const |
For internal use. | |
void | set_seq (unsigned seq) |
For internal use. | |
ElementMarkersConversion & | get_element_markers_conversion () |
BoundaryMarkersConversion & | get_boundary_markers_conversion () |
Element * | create_quad (int marker, Node *v0, Node *v1, Node *v2, Node *v3, CurvMap *cm, int id=-1) |
Element * | create_triangle (int marker, Node *v0, Node *v1, Node *v2, CurvMap *cm, int id=-1) |
void | refine_element (Element *e, int refinement) |
void | refine_quad (Element *e, int refinement, Element **sons_out=NULL) |
void | refine_triangle_to_triangles (Element *e, Element **sons=NULL) |
![]() | |
Node * | get_node (int id) const |
Retrieves a node by its id number. | |
int | get_max_node_id () const |
Returns the maximum node id number plus one. | |
![]() | |
void | check () const |
Method to handle the state. | |
Static Public Member Functions | |
static double | vector_length (double a_1, double a_2) |
Computing vector length. | |
static bool | same_line (double p_1, double p_2, double q_1, double q_2, double r_1, double r_2) |
Checking whether the points p, q, r lie on the same line. | |
static bool | is_convex (double a_1, double a_2, double b_1, double b_2) |
Checking whether the angle of vectors 'a' and 'b' is between zero and Pi. | |
static void | check_triangle (int i, Node *&v0, Node *&v1, Node *&v2) |
static void | check_quad (int i, Node *&v0, Node *&v1, Node *&v2, Node *&v3) |
Public Attributes | |
Hermes::vector< std::pair < unsigned int, int > > | refinements |
Additional Inherited Members | |
![]() | |
int | get_num_nodes () const |
Returns the total number of nodes stored. | |
Node * | peek_vertex_node (int p1, int p2) const |
Returns a vertex node with parent id's p1 and p2 if it exists, NULL otherwise. | |
Node * | peek_edge_node (int p1, int p2) const |
Returns an edge node with parent id's p1 and p2 if it exists, NULL otherwise. | |
Node * | get_vertex_node (int p1, int p2) |
Node * | get_edge_node (int p1, int p2) |
void | init (int size=H2D_DEFAULT_HASH_SIZE) |
void | copy (const HashTable *ht) |
Copies another hash table contents. | |
void | rebuild () |
Reconstructs the hashtable, after, e.g., the nodes have been loaded from a file. | |
void | free () |
Frees all memory used by the instance. | |
void | remove_vertex_node (int id) |
Removes a vertex node with parent id's p1 and p2. | |
void | remove_edge_node (int id) |
Removes an edge node with parent id's p1 and p2. | |
![]() | |
Array< Node > | nodes |
Array storing all nodes. | |
![]() | |
static const int | H2D_DEFAULT_HASH_SIZE = 0x8000 |
Represents a finite element mesh. Typical usage: Hermes::Hermes2D::Mesh mesh; Hermes::Hermes2D::MeshReaderH2DXML mloader; try { mloader.load("mesh.xml", &mesh); } catch(Exceptions::MeshLoadFailureException& e) { e.print_msg(); return -1; }.
int Hermes::Hermes2D::Mesh::get_num_base_elements | ( | ) | const |
Returns the number of base mesh elements.
Returns the number of coarse mesh elements.
Definition at line 394 of file mesh.cpp.
Referenced by Hermes::Hermes2D::MeshReaderH2DXML::save().
int Hermes::Hermes2D::Mesh::get_num_used_base_elements | ( | ) | const |
void Hermes::Hermes2D::Mesh::init | ( | int | size = H2D_DEFAULT_HASH_SIZE | ) |
Initializes the mesh.
size[in] | Hash table size; must be a power of two. |
Definition at line 1416 of file mesh.cpp.
Referenced by copy_base(), create(), Hermes::Hermes2D::MeshReaderH1DXML::load(), Hermes::Hermes2D::MeshReaderH2D::load(), and Hermes::Hermes2D::MeshReaderH2DXML::load().
void Hermes::Hermes2D::Mesh::refine_all_elements | ( | int | refinement = 0 , |
bool | mark_as_initial = false |
||
) |
Refines all elements.
refinement[in] | Same meaning as in refine_element_id(). |
Definition at line 970 of file mesh.cpp.
Referenced by Hermes::Hermes2D::Mesh::ReferenceMeshCreator::create_ref_mesh().
void Hermes::Hermes2D::Mesh::refine_by_criterion | ( | int(*)(Element *e) | criterion, |
int | depth = 1 , |
||
bool | mark_as_initial = false |
||
) |
Selects elements to refine according to a given criterion and performs 'depth' levels of refinements. The criterion function receives a pointer to an element to be considered. It must return -1 if the element is not to be refined, 0 if it should be refined uniformly, 1 if it is a quad and should be split horizontally, 2 if it is a quad and should be split vertically, and 3 if it is a triangle and should be split into three quads.
Definition at line 994 of file mesh.cpp.
Referenced by refine_towards_boundary(), and refine_towards_vertex().
void Hermes::Hermes2D::Mesh::refine_element_id | ( | int | id, |
int | refinement = 0 |
||
) |
Refines an element.
id[in] | Element id number. |
refinement[in] | Ignored for triangles. If the element is a quad, 0 means refine in both directions, 1 means refine horizontally (with respect to the reference domain), 2 means refine vertically. |
Definition at line 960 of file mesh.cpp.
Referenced by Hermes::Hermes2D::Adapt< Scalar >::apply_refinement(), Hermes::Hermes2D::MeshReaderH2D::load(), Hermes::Hermes2D::MeshReaderH2DXML::load(), refine_all_elements(), refine_by_criterion(), and regularize().
void Hermes::Hermes2D::Mesh::refine_quad | ( | Element * | e, |
int | refinement, | ||
Element ** | sons_out = NULL |
||
) |
Refines a quad element into four quads, or two quads (horizontally or vertically. If mesh != NULL, the new elements are incorporated into the mesh. The option mesh == NULL is used to perform adaptive numerical quadrature. If sons_out != NULL, pointers to the new elements will be saved there.
void Hermes::Hermes2D::Mesh::refine_towards_boundary | ( | Hermes::vector< std::string > | markers, |
int | depth = 1 , |
||
bool | aniso = true , |
||
bool | mark_as_initial = false |
||
) |
void Hermes::Hermes2D::Mesh::refine_towards_vertex | ( | int | vertex_id, |
int | depth = 1 , |
||
bool | mark_as_initial = false |
||
) |
int * Hermes::Hermes2D::Mesh::regularize | ( | int | n | ) |
Regularizes the mesh by refining elements with hanging nodes of degree more than 'n'. As a result, n-irregular mesh is obtained. If n = 0, completely regular mesh is created. In this case, however, due to incompatible refinements, the element refinement hierarchy is removed and all elements become top-level elements. Also, total regularization does not work on curved elements. Returns an array of new element parents which can be passed to Space::distribute_orders(). The array must be deallocated with ::free().
Definition at line 3205 of file mesh.cpp.
Referenced by Hermes::Hermes2D::Adapt< Scalar >::adapt().
void Hermes::Hermes2D::Mesh::unrefine_all_elements | ( | bool | keep_initial_refinements = true | ) |
Unrefines all elements with immediate active sons. In effect, this shaves off one layer of refinements from the mesh. If done immediately after refine_all_elements(), this function reverts the mesh to its original state. However, it is not exactly an inverse to refine_all_elements().
void Hermes::Hermes2D::Mesh::unrefine_element_id | ( | int | id | ) |
Recursively removes all son elements of the given element and makes it active.
Definition at line 1174 of file mesh.cpp.
Referenced by Hermes::Hermes2D::MeshReaderH2DXML::load(), and unrefine_all_elements().
Hermes::vector<std::pair<unsigned int, int> > Hermes::Hermes2D::Mesh::refinements |
Vector for storing refinements in order to be able to save/load meshes with identical element IDs. Refinement "-1" stands for unrefinement.
Definition at line 681 of file mesh.h.
Referenced by copy(), free(), and Hermes::Hermes2D::MeshReaderH2DXML::save().