Mesh Class Reference

Represents a finite element mesh. More...

#include <mesh.h>

Inherits HashTable.

List of all members.

Public Member Functions

 Mesh ()
 ~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 free ()
 Frees all data associated with the mesh.
void load_old (const char *filename)
 Loads the mesh from a file. Aborts the program on error.
void load_stream (FILE *f)
void load_str (char *mesh)
void load (const char *filename, bool debug=false)
 DEPRECATED.
void save (const char *filename)
 Saves the mesh, including all refinements, to a file. Caution: never overwrite hand-created meshes with this function -- all comments in the original file will be lost. DEPRECATED.
void create (int nv, double2 *verts, int nt, int4 *tris, int nq, int5 *quads, int nm, int3 *mark)
 Creates the mesh from the given vertex, triangle, quad and marker arrays.
Elementget_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 coarse mesh elements.
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.
void refine_element (int id, int refinement=0)
 Refines an element.
void refine_all_elements (int refinement=0)
 Refines all elements.
void refine_by_criterion (int(*criterion)(Element *e), int depth)
 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 or 2 if it is a quad and should be split vertically.
void refine_towards_vertex (int vertex_id, int depth)
 Performs repeated refinements of elements containing the given vertex. A mesh graded towards the vertex is created.
void refine_towards_boundary (int marker, int depth, bool aniso=true)
 Performs repeated refinements of elements touching a part of the boundary marked by 'marker'. Elements touching both by an edge or by a vertex are refined. 'aniso' allows or disables anisotropic splits of quads.
int * 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().
void unrefine_element (int id)
 Recursively removes all son elements of the given element and makes it active.
void 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 transform (double2x2 m, double2 t)
void transform (void(*fn)(double *x, double *y))
void load_raw (FILE *f)
 Loads the entire internal state from a (binary) file. DEPRECATED.
void save_raw (FILE *f)
 Saves the entire internal state to a (binary) file. DEPRECATED.
int get_edge_sons (Element *e, int edge, int &son1, int &son2)
 For internal use.
unsigned get_seq () const
 For internal use.
void set_seq (unsigned seq)
 For internal use.
Elementget_element_fast (int id) const
 For internal use.
void convert_triangles_to_quads ()
 Refines all triangle elements to quads. It can refine a triangle element into three quadrilaterals. Note: this function creates a base mesh -- it can only be used before any other mesh refinement function is called.
void convert_quads_to_triangles ()
 Refines all quad elements to triangles. It refines a quadrilateral element into two triangles. Note: this function creates a base mesh -- it can only be used before any other mesh refinement function is called.

Protected Member Functions

 H2D_API_USED_TEMPLATE (Array< Element >)
Elementcreate_triangle (int marker, Node *v0, Node *v1, Node *v2, CurvMap *cm)
Elementcreate_quad (int marker, Node *v0, Node *v1, Node *v2, Node *v3, CurvMap *cm)
void refine_triangle (Element *e)
void refine_quad (Element *e, int refinement)
void unrefine_element_internal (Element *e)
Nurbsreverse_nurbs (Nurbs *nurbs)
 Returns a NURBS curve with reversed control points and inverted knot vector. Used for curved edges inside a mesh, where two mirror Nurbs have to be created for the adjacent elements.
Nodeget_base_edge_node (Element *base, int edge)
int get_edge_degree (Node *v1, Node *v2)
void assign_parent (Element *e, int i)
void regularize_triangle (Element *e)
void regularize_quad (Element *e)
void flatten ()
void refine_triangle_to_quads (Element *e)
void refine_element_to_quads (int id)
void refine_quad_to_triangles (Element *e)
void refine_element_to_triangles (int id)

Protected Attributes

Array< Elementelements
int nbase
int ntopvert
int nactive
int ninitial
unsigned seq
int * parents
int parents_size

Friends

class H2DReader

Detailed Description

Represents a finite element mesh.


Constructor & Destructor Documentation

Mesh::Mesh (  ) 
Mesh::~Mesh (  )  [inline]

Member Function Documentation

void Mesh::assign_parent ( Element e,
int  i 
) [protected]
void Mesh::convert_quads_to_triangles (  ) 

Refines all quad elements to triangles. It refines a quadrilateral element into two triangles. Note: this function creates a base mesh -- it can only be used before any other mesh refinement function is called.

void Mesh::convert_triangles_to_quads (  ) 

Refines all triangle elements to quads. It can refine a triangle element into three quadrilaterals. Note: this function creates a base mesh -- it can only be used before any other mesh refinement function is called.

void Mesh::copy ( const Mesh mesh  ) 

Creates a copy of another mesh.

void Mesh::copy_base ( Mesh mesh  ) 

Copies the coarsest elements of another mesh.

void Mesh::copy_converted ( Mesh mesh  ) 

Copies the active elements of a converted mesh.

void Mesh::create ( int  nv,
double2 verts,
int  nt,
int4 tris,
int  nq,
int5 quads,
int  nm,
int3 mark 
)

Creates the mesh from the given vertex, triangle, quad and marker arrays.

Element * Mesh::create_quad ( int  marker,
Node v0,
Node v1,
Node v2,
Node v3,
CurvMap cm 
) [protected]
Element * Mesh::create_triangle ( int  marker,
Node v0,
Node v1,
Node v2,
CurvMap cm 
) [protected]
void Mesh::flatten (  )  [protected]
void Mesh::free (  ) 

Frees all data associated with the mesh.

Reimplemented from HashTable.

Node * Mesh::get_base_edge_node ( Element base,
int  edge 
) [protected]
int Mesh::get_edge_degree ( Node v1,
Node v2 
) [protected]
int Mesh::get_edge_sons ( Element e,
int  edge,
int &  son1,
int &  son2 
)

For internal use.

Element * Mesh::get_element ( int  id  )  const

Retrieves an element by its id number.

Element* Mesh::get_element_fast ( int  id  )  const [inline]

For internal use.

int Mesh::get_max_element_id (  )  const [inline]

Returns the maximum node id number plus one.

int Mesh::get_num_active_elements (  )  const [inline]

Returns the current number of active elements in the mesh.

int Mesh::get_num_base_elements (  )  const [inline]

Returns the number of coarse mesh elements.

int Mesh::get_num_elements (  )  const [inline]

Returns the total number of elements stored.

unsigned Mesh::get_seq (  )  const [inline]

For internal use.

Mesh::H2D_API_USED_TEMPLATE ( Array< Element  )  [protected]
void Mesh::load ( const char *  filename,
bool  debug = false 
)

DEPRECATED.

void Mesh::load_old ( const char *  filename  ) 

Loads the mesh from a file. Aborts the program on error.

Parameters:
filename [in] The name of the file. DEPRECATED
void Mesh::load_raw ( FILE *  f  ) 

Loads the entire internal state from a (binary) file. DEPRECATED.

void Mesh::load_str ( char *  mesh  ) 
void Mesh::load_stream ( FILE *  f  ) 
void Mesh::refine_all_elements ( int  refinement = 0  ) 

Refines all elements.

Parameters:
refinement [in] Same meaning as in refine_element().
void Mesh::refine_by_criterion ( int(*)(Element *e)  criterion,
int  depth 
)

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 or 2 if it is a quad and should be split vertically.

void Mesh::refine_element ( int  id,
int  refinement = 0 
)

Refines an element.

Parameters:
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.
void Mesh::refine_element_to_quads ( int  id  )  [protected]
void Mesh::refine_element_to_triangles ( int  id  )  [protected]
void Mesh::refine_quad ( Element e,
int  refinement 
) [protected]
void Mesh::refine_quad_to_triangles ( Element e  )  [protected]

< if bcheck is true, it is default add a new edge between < vn[0] and vn[2]

void Mesh::refine_towards_boundary ( int  marker,
int  depth,
bool  aniso = true 
)

Performs repeated refinements of elements touching a part of the boundary marked by 'marker'. Elements touching both by an edge or by a vertex are refined. 'aniso' allows or disables anisotropic splits of quads.

void Mesh::refine_towards_vertex ( int  vertex_id,
int  depth 
)

Performs repeated refinements of elements containing the given vertex. A mesh graded towards the vertex is created.

void Mesh::refine_triangle ( Element e  )  [protected]
void Mesh::refine_triangle_to_quads ( Element e  )  [protected]
int * 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().

void Mesh::regularize_quad ( Element e  )  [protected]
void Mesh::regularize_triangle ( Element e  )  [protected]
Nurbs * Mesh::reverse_nurbs ( Nurbs nurbs  )  [protected]

Returns a NURBS curve with reversed control points and inverted knot vector. Used for curved edges inside a mesh, where two mirror Nurbs have to be created for the adjacent elements.

void Mesh::save ( const char *  filename  ) 

Saves the mesh, including all refinements, to a file. Caution: never overwrite hand-created meshes with this function -- all comments in the original file will be lost. DEPRECATED.

Parameters:
filename [in] The name of the file.
void Mesh::save_raw ( FILE *  f  ) 

Saves the entire internal state to a (binary) file. DEPRECATED.

void Mesh::set_seq ( unsigned  seq  )  [inline]

For internal use.

void Mesh::transform ( void(*)(double *x, double *y)  fn  ) 
void Mesh::transform ( double2x2  m,
double2  t 
)
void 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 Mesh::unrefine_element ( int  id  ) 

Recursively removes all son elements of the given element and makes it active.

void Mesh::unrefine_element_internal ( Element e  )  [protected]

Friends And Related Function Documentation

friend class H2DReader [friend]

Reimplemented from HashTable.


Member Data Documentation

int Mesh::nactive [protected]
int Mesh::nbase [protected]
int Mesh::ninitial [protected]
int Mesh::ntopvert [protected]
int* Mesh::parents [protected]
int Mesh::parents_size [protected]
unsigned Mesh::seq [protected]

The documentation for this class was generated from the following files:
Generated on Sat Jun 5 15:17:43 2010 for Hermes2D Library: Real Version by  doxygen 1.6.3