Mesh Class Reference

Represents the geometry of a mesh. More...

#include <mesh.h>

List of all members.

Public Member Functions

 Mesh ()
virtual ~Mesh ()
void free ()
 Frees all data associated with the mesh.
void copy (const Mesh &mesh)
 Creates a copy of another mesh.
void copy_base (const Mesh &mesh)
 Copies the coarsest elements of another mesh.
Word_t get_num_elements () const
 Returns the total number of elements stored.
Word_t get_num_base_elements () const
 Returns the number of coarse mesh elements.
Word_t get_num_active_elements () const
 Returns the current number of active elements in the mesh.
Word_t get_max_element_id () const
 Returns the maximum node id number plus one.
bool can_refine_element (Word_t eid, int reft) const
 Checks wether it is possible to refine an element.
bool refine_element (Word_t id, int refinement)
 Refines an element.
void refine_all_elements (int refinement)
 Refines all elements.
void refine_by_criterion (int(*criterion)(Element *e), int depth)
 Keeps refining all elements of the mesh until the given criterion is met for all elements of the mesh. 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. Exactly 'depth' levels of refinements are performed.
void refine_towards_boundary (int marker, int depth)
 Performs repeated refinements of elements touching a part of the boundary marked by 'marker'.
void unrefine_element (Word_t id)
 Recursively removes all son elements of the given element and makes it active.
void unrefine_all_elements ()
 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 regularize ()
 Regularize mesh (only 1-irregularity rule implemented).
Word_t get_facet_id (Element *e, int face_num) const
Word_t get_facet_id (int nv,...) const
Word_t get_edge_id (Element *e, int edge_num) const
 Get ID of the edge.
Word_t get_edge_id (Word_t a, Word_t b) const
 Get ID of the edge between a and b.
void dump ()
 Get state of an edge.
Word_t peek_midpoint (Word_t a, Word_t b) const
 Gets an index of a midpoint between a and b.
Word_t add_vertex (double x, double y, double z)
 Adds an vertex.
Tetraadd_tetra (Word_t vtcs[])
 Adds an element.
Hexadd_hex (Word_t vtcs[])
Prismadd_prism (Word_t vtcs[])
Word_t get_facing_facet (Word_t fid, Word_t elem_id)
 Get the facing facet.
Boundaryadd_tri_boundary (Word_t vtcs[], int marker)
Boundaryadd_quad_boundary (Word_t vtcs[], int marker)
void ugh ()

Public Attributes

Array< Vertex * > vertices
MapOrd< Edgeedges
Array< Element * > elements
Array< Boundary * > boundaries
MapOrd< Facet * > facets

Protected Member Functions

Tetracreate_tetra (Word_t vtcs[])
 number of active elements
Hexcreate_hex (Word_t vtcs[])
Prismcreate_prism (Word_t vtcs[])
bool can_refine_hex (Hex *elem, int refinement) const
bool refine_hex (Hex *elem, int refinement)
 Apply a refinement to a hex.
bool refine_hex_2 (Hex *parent, int refinement)
bool refine_hex_4 (Hex *parent, int refinement)
bool refine_hex_8 (Hex *parent, int refinement)
bool refine_quad_facet (Hex *parent, int iface, unsigned int face_refinement, Word_t eid)
 Refine quad facet.
bool refine_quad_facet (Hex *parent, int iface, unsigned int face_refinement, Word_t eid0, Word_t eid1)
bool refine_quad_facet (Hex *parent, int iface, unsigned int face_refinement, Word_t eid0, Word_t eid1, Word_t eid2, Word_t eid3)
bool is_compatible_quad_refinement (Facet *facet, int reft) const
Facetadd_quad_facet (Facet::Type type, Word_t left_elem, int left_iface, Word_t right_elem, int right_iface)
 Add a quadrilateral-shaped facet.
Word_t create_midpoint (Word_t a, Word_t b)
 Adds a midpoint as a vertex.
Word_t get_midpoint (Word_t a, Word_t b)
 Gets an index of a midpoint between a and b. If midpoint does not exists, it is created.
void set_midpoint (Word_t a, Word_t b, Word_t idx)
 Sets the midpoints index for a midpoint.
void ref_edges (Element *e)
 referencing edges
void unref_edges (Element *e)
void check_elem_oris ()
 Check element orientations.
int get_seq () const
 For internal use.
void set_seq (unsigned seq)
 For internal use.

Protected Attributes

Word_t nbase
Word_t nactive
 number of base elements
MapHSOrd midpoints
int seq

Friends

class Space
class WeakForm

Detailed Description

Represents the geometry of a mesh.


Constructor & Destructor Documentation

Mesh::Mesh (  ) 
Mesh::~Mesh (  )  [virtual]

Member Function Documentation

Hex * Mesh::add_hex ( Word_t  vtcs[]  ) 
Prism * Mesh::add_prism ( Word_t  vtcs[]  ) 
Boundary * Mesh::add_quad_boundary ( Word_t  vtcs[],
int  marker 
)
Facet * Mesh::add_quad_facet ( Facet::Type  type,
Word_t  left_elem,
int  left_iface,
Word_t  right_elem,
int  right_iface 
) [protected]

Add a quadrilateral-shaped facet.

Parameters:
[in] left_elem ID of the element on the right
[in] left_iface Local face number on the element on the left
[in] right_elem ID of the element on the right
[in] right_iface Local face number on the element on the right
Returns:
Pointer to the newly created facet
Tetra * Mesh::add_tetra ( Word_t  vtcs[]  ) 

Adds an element.

Parameters:
[in] e An element to add
Boundary * Mesh::add_tri_boundary ( Word_t  vtcs[],
int  marker 
)
Word_t Mesh::add_vertex ( double  x,
double  y,
double  z 
)

Adds an vertex.

bool Mesh::can_refine_element ( Word_t  eid,
int  reft 
) const

Checks wether it is possible to refine an element.

Returns:
true if it posible to apply the refinement, otherwise false
Parameters:
[in] eid Element id number.
[in] refinement The refinement that is going to be applied
bool Mesh::can_refine_hex ( Hex elem,
int  refinement 
) const [protected]
void Mesh::check_elem_oris (  )  [protected]

Check element orientations.

void Mesh::copy ( const Mesh mesh  ) 

Creates a copy of another mesh.

void Mesh::copy_base ( const Mesh mesh  ) 

Copies the coarsest elements of another mesh.

Hex * Mesh::create_hex ( Word_t  vtcs[]  )  [protected]
Word_t Mesh::create_midpoint ( Word_t  a,
Word_t  b 
) [protected]

Adds a midpoint as a vertex.

Parameters:
[in] a index of the first vertex
[in] b index of the second vertex
Returns:
index of the newly created vertex
Prism * Mesh::create_prism ( Word_t  vtcs[]  )  [protected]
Tetra * Mesh::create_tetra ( Word_t  vtcs[]  )  [protected]

number of active elements

void Mesh::dump (  ) 

Get state of an edge.

Parameters:
eidx ID of an edge
Returns:
true is edge is active, otherwise false
void Mesh::free (  ) 

Frees all data associated with the mesh.

Word_t Mesh::get_edge_id ( Word_t  a,
Word_t  b 
) const

Get ID of the edge between a and b.

Parameters:
[in] a Index (ID) of the first vertex
[in] b Index (ID) of the second vertex
Returns:
ID of the edge, INVALID_IDX is edge does not exist
Word_t Mesh::get_edge_id ( Element e,
int  edge_num 
) const

Get ID of the edge.

Parameters:
e Element
edge_num Local number of an edge on element e
Returns:
ID of the edge on the element
Word_t Mesh::get_facet_id ( int  nv,
  ... 
) const
Word_t Mesh::get_facet_id ( Element e,
int  face_num 
) const
Word_t Mesh::get_facing_facet ( Word_t  fid,
Word_t  elem_id 
)

Get the facing facet.

Parameters:
[in] fid ID of the facet
[in] elem_id ID of the element
Word_t Mesh::get_max_element_id (  )  const [inline]

Returns the maximum node id number plus one.

Word_t Mesh::get_midpoint ( Word_t  a,
Word_t  b 
) [protected]

Gets an index of a midpoint between a and b. If midpoint does not exists, it is created.

Parameters:
[in] a index of the first vertex
[in] b index of the second vertex
Returns:
index of the midpoint FIXME: better name
Word_t Mesh::get_num_active_elements (  )  const [inline]

Returns the current number of active elements in the mesh.

Word_t Mesh::get_num_base_elements (  )  const [inline]

Returns the number of coarse mesh elements.

Word_t Mesh::get_num_elements (  )  const [inline]

Returns the total number of elements stored.

int Mesh::get_seq (  )  const [inline, protected]

For internal use.

bool Mesh::is_compatible_quad_refinement ( Facet facet,
int  reft 
) const [protected]
Returns:
true if we can refine the face, otherwise false
Parameters:
[in] facet - facet to refine
[in] reft - the refinement that is going to be applied
Word_t Mesh::peek_midpoint ( Word_t  a,
Word_t  b 
) const

Gets an index of a midpoint between a and b.

Parameters:
[in] a index of the first vertex
[in] b index of the second vertex
Returns:
index of the midpoint
void Mesh::ref_edges ( Element e  )  [protected]

referencing edges

void Mesh::refine_all_elements ( int  refinement  ) 

Refines all elements.

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

Keeps refining all elements of the mesh until the given criterion is met for all elements of the mesh. 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. Exactly 'depth' levels of refinements are performed.

bool Mesh::refine_element ( Word_t  id,
int  refinement 
)

Refines an element.

Parameters:
[in] id Element id number.
[in] refinement Refinement to apply
bool Mesh::refine_hex ( Hex elem,
int  refinement 
) [protected]

Apply a refinement to a hex.

Parameters:
[in] elem An element to refine
[in] refinement Type of refinement
bool Mesh::refine_hex_2 ( Hex parent,
int  refinement 
) [protected]
bool Mesh::refine_hex_4 ( Hex parent,
int  refinement 
) [protected]
bool Mesh::refine_hex_8 ( Hex parent,
int  refinement 
) [protected]
bool Mesh::refine_quad_facet ( Hex parent,
int  iface,
unsigned int  face_refinement,
Word_t  eid0,
Word_t  eid1,
Word_t  eid2,
Word_t  eid3 
) [protected]
bool Mesh::refine_quad_facet ( Hex parent,
int  iface,
unsigned int  face_refinement,
Word_t  eid0,
Word_t  eid1 
) [protected]
bool Mesh::refine_quad_facet ( Hex parent,
int  iface,
unsigned int  face_refinement,
Word_t  eid 
) [protected]

Refine quad facet.

Parameters:
[in] parent Parent element
[in] iface Local number of a face whose facet will be refined
[in] face_refinement How to refine the face (see REFT_QUAD_XXX for possible values)
[in] eid ID of son element
void Mesh::refine_towards_boundary ( int  marker,
int  depth 
)

Performs repeated refinements of elements touching a part of the boundary marked by 'marker'.

void Mesh::regularize (  ) 

Regularize mesh (only 1-irregularity rule implemented).

void Mesh::set_midpoint ( Word_t  a,
Word_t  b,
Word_t  idx 
) [protected]

Sets the midpoints index for a midpoint.

Parameters:
[in] a index of the first vertex
[in] b index of the second vertex
void Mesh::set_seq ( unsigned  seq  )  [inline, protected]

For internal use.

void Mesh::ugh (  ) 
void Mesh::unref_edges ( Element e  )  [protected]
void Mesh::unrefine_all_elements (  ) 

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 ( Word_t  id  ) 

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


Friends And Related Function Documentation

friend class Space [friend]
friend class WeakForm [friend]

Member Data Documentation

MapOrd<Edge> Mesh::edges
MapOrd<Facet *> Mesh::facets
MapHSOrd Mesh::midpoints [protected]
Word_t Mesh::nactive [protected]

number of base elements

Word_t Mesh::nbase [protected]
int Mesh::seq [protected]

The documentation for this class was generated from the following files:
Generated on Fri Sep 3 09:22:20 2010 for Hermes3D Library: Real Version by  doxygen 1.6.3