MOAB: Mesh Oriented datABase  (version 5.2.1)
moab::EntityRefiner Class Reference

#include <EntityRefiner.hpp>

Inheritance diagram for moab::EntityRefiner:
Collaboration diagram for moab::EntityRefiner:

## Public Member Functions

EntityRefiner ()
Construct an entity refiner.
virtual ~EntityRefiner ()
Destruction is virtual so subclasses may clean up after refinement.
virtual bool prepare (RefinerTagManager *tmgr, EntityRefinerOutputFunctor *ofunc)
Prepare to start refining entities on a given mesh. This is called once before refine_entity() is ever invoked. The tag manager specifies the input and output meshes upon which the refiner will act.
virtual bool refine_entity (EntityType typ, EntityHandle ent)=0
Method implemented by subclasses to create decompositions of entities using edge subdivisions.
virtual unsigned long get_heap_size_bound (int max_recursions) const =0
When an entity is refined, what is the maximum number of new vertices that will be created?
virtual bool set_edge_size_evaluator (EdgeSizeEvaluator *)
Set the object that specifies which edges of a given entity should be subdivided.
EdgeSizeEvaluatorget_edge_size_evaluator ()
Return a pointer to the object that specifies which edges of a given entity should be subdivided.
virtual bool set_output_functor (EntityRefinerOutputFunctor *func_obj)
Set the functor through which output entities are streamed.
EntityRefinerOutputFunctorget_output_functor ()
Return the functor used to stream output.
virtual bool set_minimum_number_of_subdivisions (int mn)
Set the minimum number of recursive subdivisions that should occur, regardless of the edge_size_evaluator's response.
int get_minimum_number_of_subdivisions () const
Return the minimum number of recursive edge subdivisions guaranteed to take place, regardless of the edge size evaluator.
virtual bool set_maximum_number_of_subdivisions (int mx)
Set the maximum number of recursive subdivisions that should occur, regardless of the edge_size_evaluator's response.
int get_maximum_number_of_subdivisions () const
Return the maximum number of recursive edge subdivisions guaranteed to take place, regardless of the edge size evaluator.

## Protected Member Functions

void update_heap_size ()
This is called when the edge size evaluator or maximum number of subdivisions is changed to make sure the heaps are properly sized.
void reset_heap_pointers ()
Subclasses should call this on entry to refine_entity().
double * heap_coord_storage ()
Return a pointer to temporary storage for edge midpoint vertex coordinates inside refine_entity().
void * heap_tag_storage ()
Return a pointer to temporary storage for edge midpoint vertex coordinates inside refine_entity().

## Protected Attributes

Interface * mesh_in
EdgeSizeEvaluatoredge_size_evaluator
EntityRefinerOutputFunctoroutput_functor
int minimum_number_of_subdivisions
int maximum_number_of_subdivisions
std::vector< double > coord_heap
std::vector< double >::iterator current_coord
std::vector< char > tag_heap
std::vector< char >::iterator current_tag

## Detailed Description

This is an abstract class that contains the method used for per-entity refinement. Subclasses must implement the pure virtual refine_entity() function and may implement the vertices_per_split() function. This class constructor requires a non-NULL pointer to a mesh so that, given an entity handle, it can look up vertex coordinates and tags to prepare arguments for the refine_entity() method.

Although the MeshRefiner class may not initially support it, entity refiners are required to support some level of recursion. The maximum number of recursive calls allowed may be set with EntityRefiner::set_maximum_number_of_subdivisions(). As a convenience, some of the framework for recursion is provided by the EntityRefiner class.

Specifically, EntityRefiner stores a pair of heap arrays to hold edge midpoint vertex coordinates and tag values pre-allocated to the maximum recursion depth so that no repeated allocation and deallocation needs to take place during refinement. To use these heaps, subclasses should call reset_heap_pointers() upon entry to EntityRefiner::refine_entity(). Then, when the edge size evaluator requires an edge to be split, subclasses should call heap_coord_storage() and heap_tag_storage() to obtain pointers as required.

Date:
24 December 2007

Definition at line 143 of file EntityRefiner.hpp.

## Constructor & Destructor Documentation

 moab::EntityRefiner::EntityRefiner ( )

Construct an entity refiner.

Definition at line 10 of file EntityRefiner.cpp.

{
this->mesh_in             = 0;
this->edge_size_evaluator = 0;
this->output_functor      = 0;
// By default, allow at most one subdivision per edge
this->minimum_number_of_subdivisions = 0;
this->maximum_number_of_subdivisions = 1;
}

 moab::EntityRefiner::~EntityRefiner ( )  [virtual]

Destruction is virtual so subclasses may clean up after refinement.

Definition at line 21 of file EntityRefiner.cpp.

References edge_size_evaluator.

{
if( this->edge_size_evaluator ) delete this->edge_size_evaluator;
}


## Member Function Documentation

 EdgeSizeEvaluator * moab::EntityRefiner::get_edge_size_evaluator ( )  [inline]

Return a pointer to the object that specifies which edges of a given entity should be subdivided.

This may return NULL if no value has been previously specified.

Return values:
 A pointer to an edge size evaluator object or NULL.

Definition at line 154 of file EntityRefiner.hpp.

References edge_size_evaluator.

    {
return this->edge_size_evaluator;
}

 int moab::EntityRefiner::get_heap_size_bound ( int max_recursions ) const [pure virtual]

When an entity is refined, what is the maximum number of new vertices that will be created?

This must be the maximum number of initial corner vertices for any entity type (hex, tet, etc.) to be processed plus the maximum number of new vertices that might be created at edge or face mid-points during the refinement of a single entity.

Implemented in moab::SimplexTemplateRefiner.

Referenced by update_heap_size().

 int moab::EntityRefiner::get_maximum_number_of_subdivisions ( ) const [inline]

Return the maximum number of recursive edge subdivisions guaranteed to take place, regardless of the edge size evaluator.

This may any non-negative integer.

Return values:
 The guaranteed maximum number of subdivisions that will take place on each and every edge of the mesh.

Definition at line 172 of file EntityRefiner.hpp.

References maximum_number_of_subdivisions.

    {
return this->maximum_number_of_subdivisions;
}

 int moab::EntityRefiner::get_minimum_number_of_subdivisions ( ) const [inline]

Return the minimum number of recursive edge subdivisions guaranteed to take place, regardless of the edge size evaluator.

This may any non-negative integer.

Return values:
 The guaranteed minimum number of subdivisions that will take place on each and every edge of the mesh.

Definition at line 166 of file EntityRefiner.hpp.

References minimum_number_of_subdivisions.

    {
return this->minimum_number_of_subdivisions;
}

 EntityRefinerOutputFunctor * moab::EntityRefiner::get_output_functor ( )  [inline]

Return the functor used to stream output.

Return values:
 A pointer to the functor. This may be NULL.

Definition at line 160 of file EntityRefiner.hpp.

References output_functor.

    {
return this->output_functor;
}

 double * moab::EntityRefiner::heap_coord_storage ( )  [protected]

Return a pointer to temporary storage for edge midpoint vertex coordinates inside refine_entity().

The returned pointer references 6 uninitialized double values to hold parametric coordinates and world coordinates.

Definition at line 194 of file EntityRefiner.cpp.

References coord_heap, and current_coord.

{
double* rval;
if( this->current_coord != this->coord_heap.end() )
{
rval = &( *this->current_coord );
this->current_coord += 6;
}
else
{
rval = 0;
}
return rval;
}

 void * moab::EntityRefiner::heap_tag_storage ( )  [protected]

Return a pointer to temporary storage for edge midpoint vertex coordinates inside refine_entity().

The returned pointer references enough bytes to store all the tags for a vertex as reported by the current edge size evaluator's EdgeSizeEvaluator::get_vertex_tag_size().

Definition at line 215 of file EntityRefiner.cpp.

{
void* rval;
if( this->edge_size_evaluator && this->current_tag != this->tag_heap.end() )
{
rval = (void*)&( *this->current_tag );
this->current_tag += this->edge_size_evaluator->get_tag_manager()->get_vertex_tag_size();
}
else
{
rval = 0;
}
return rval;
}

 bool moab::EntityRefiner::prepare ( RefinerTagManager * tmgr, EntityRefinerOutputFunctor * ofunc )  [virtual]

Prepare to start refining entities on a given mesh. This is called once before refine_entity() is ever invoked. The tag manager specifies the input and output meshes upon which the refiner will act.

This function returns false if calling refine_entity() immediately afterwards would cause a failure (due, for example, to a NULL edge_size_evaluator). Otherwise it returns true.

Reimplemented in moab::SimplexTemplateRefiner.

Definition at line 34 of file EntityRefiner.cpp.

Referenced by moab::MeshRefiner::refine().

{
bool rval = true;
if( this->edge_size_evaluator ) { this->edge_size_evaluator->set_tag_manager( tmgr ); }
else
{
rval = false;
}
this->set_output_functor( ofunc );
this->mesh_in = tmgr->get_input_mesh();
this->update_heap_size();
return rval;
}

 bool moab::EntityRefiner::refine_entity ( EntityType typ, EntityHandle ent )  [pure virtual]

Method implemented by subclasses to create decompositions of entities using edge subdivisions.

Implemented in moab::SimplexTemplateRefiner.

Referenced by moab::MeshRefiner::refine().

 void moab::EntityRefiner::reset_heap_pointers ( )  [protected]

Subclasses should call this on entry to refine_entity().

When called, future calls to heap_coord_storage() and heap_tag_storage() will re-use the allocated storage starting from the beginning.

Definition at line 182 of file EntityRefiner.cpp.

References coord_heap, current_coord, current_tag, and tag_heap.

Referenced by moab::SimplexTemplateRefiner::refine_entity().

{
this->current_coord = this->coord_heap.begin();
this->current_tag   = this->tag_heap.begin();
}

 bool moab::EntityRefiner::set_edge_size_evaluator ( EdgeSizeEvaluator * ese )  [virtual]

Set the object that specifies which edges of a given entity should be subdivided.

The entity refiner takes ownership of edge size evaluator and will delete it when a new value is set or when the entity refiner is destroyed.

Parameters:
 ese The new edge size evaluator object.
Return values:
 Returns true if the value was changed and false otherwise.

Definition at line 69 of file EntityRefiner.cpp.

References edge_size_evaluator.

Referenced by TestMeshRefiner().

{
if( !ese || ese == this->edge_size_evaluator ) return false;

if( this->edge_size_evaluator ) { delete this->edge_size_evaluator; }
this->edge_size_evaluator = ese;

return true;
}

 bool moab::EntityRefiner::set_maximum_number_of_subdivisions ( int mx )  [virtual]

Set the maximum number of recursive subdivisions that should occur, regardless of the edge_size_evaluator's response.

This is useful for preventing infinite recursion. A value of 0 is allowed although not terribly practical.

Return values:
 True if the number of subdivisions was changed; false otherwise.

Definition at line 142 of file EntityRefiner.cpp.

References maximum_number_of_subdivisions, and update_heap_size().

{
if( mx < 0 || mx == this->maximum_number_of_subdivisions ) { return false; }

this->maximum_number_of_subdivisions = mx;
this->update_heap_size();
return true;
}

 bool moab::EntityRefiner::set_minimum_number_of_subdivisions ( int mn )  [virtual]

Set the minimum number of recursive subdivisions that should occur, regardless of the edge_size_evaluator's response.

This is useful for forcing global refinement.

Return values:
 True if the number of subdivisions was changed; false otherwise.

Definition at line 116 of file EntityRefiner.cpp.

References minimum_number_of_subdivisions.

{
if( mn < 0 || mn == this->minimum_number_of_subdivisions ) { return false; }

this->minimum_number_of_subdivisions = mn;
return true;
}

 bool moab::EntityRefiner::set_output_functor ( EntityRefinerOutputFunctor * func_obj )  [virtual]

Set the functor through which output entities are streamed.

Any previously assigned functor will be deleted when a new functor is set.

true if the value was changed and false otherwise.

Definition at line 94 of file EntityRefiner.cpp.

References output_functor.

Referenced by prepare().

{
if( !func_obj || func_obj == this->output_functor ) return false;

if( this->output_functor ) { delete this->output_functor; }
this->output_functor = func_obj;
return true;
}

 void moab::EntityRefiner::update_heap_size ( )  [protected]

This is called when the edge size evaluator or maximum number of subdivisions is changed to make sure the heaps are properly sized.

Tag heap size cannot be computed if the edge_size_evaluator is NULL.

Definition at line 166 of file EntityRefiner.cpp.

Referenced by prepare(), and set_maximum_number_of_subdivisions().

{
unsigned long n = this->get_heap_size_bound( this->maximum_number_of_subdivisions );
this->coord_heap.resize( 6 * n );
if( this->edge_size_evaluator )
{
unsigned long m = this->edge_size_evaluator->get_tag_manager()->get_vertex_tag_size();
this->tag_heap.resize( m * n );
}
}


## Member Data Documentation

 std::vector< double > moab::EntityRefiner::coord_heap [protected]

Definition at line 183 of file EntityRefiner.hpp.

Referenced by heap_coord_storage(), reset_heap_pointers(), and update_heap_size().

 std::vector< double >::iterator moab::EntityRefiner::current_coord [protected]

Definition at line 184 of file EntityRefiner.hpp.

Referenced by heap_coord_storage(), and reset_heap_pointers().

 std::vector< char >::iterator moab::EntityRefiner::current_tag [protected]

Definition at line 186 of file EntityRefiner.hpp.

Referenced by heap_tag_storage(), and reset_heap_pointers().

 EdgeSizeEvaluator* moab::EntityRefiner::edge_size_evaluator [protected]
 int moab::EntityRefiner::maximum_number_of_subdivisions [protected]

Definition at line 182 of file EntityRefiner.hpp.

 Interface* moab::EntityRefiner::mesh_in [protected]

Definition at line 178 of file EntityRefiner.hpp.

Referenced by EntityRefiner(), and prepare().

 int moab::EntityRefiner::minimum_number_of_subdivisions [protected]

Definition at line 181 of file EntityRefiner.hpp.

 std::vector< char > moab::EntityRefiner::tag_heap [protected]

Definition at line 185 of file EntityRefiner.hpp.

Referenced by heap_tag_storage(), reset_heap_pointers(), and update_heap_size().

List of all members.

The documentation for this class was generated from the following files: