moab
|
#include <EntityRefiner.hpp>
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. | |
EdgeSizeEvaluator * | get_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. | |
EntityRefinerOutputFunctor * | get_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 |
EdgeSizeEvaluator * | edge_size_evaluator |
EntityRefinerOutputFunctor * | output_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 |
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.
Definition at line 138 of file EntityRefiner.hpp.
Construct an entity refiner.
Definition at line 9 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 20 of file EntityRefiner.cpp.
{ if ( this->edge_size_evaluator ) delete this->edge_size_evaluator; }
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.
A | pointer to an edge size evaluator object or NULL. |
Definition at line 149 of file EntityRefiner.hpp.
{ 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.
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.
The | guaranteed maximum number of subdivisions that will take place on each and every edge of the mesh. |
Definition at line 158 of file EntityRefiner.hpp.
{ 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.
The | guaranteed minimum number of subdivisions that will take place on each and every edge of the mesh. |
Definition at line 155 of file EntityRefiner.hpp.
{ return this->minimum_number_of_subdivisions; }
Return the functor used to stream output.
A | pointer to the functor. This may be NULL. |
Definition at line 152 of file EntityRefiner.hpp.
{ 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 201 of file EntityRefiner.cpp.
{ 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 221 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.
{ 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.
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 191 of file EntityRefiner.cpp.
{ 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.
ese | The new edge size evaluator object. |
Returns | true if the value was changed and false otherwise. |
Definition at line 71 of file EntityRefiner.cpp.
{ 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.
True | if the number of subdivisions was changed; false otherwise. |
Definition at line 150 of file EntityRefiner.cpp.
{ 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.
True | if the number of subdivisions was changed; false otherwise. |
Definition at line 124 of file EntityRefiner.cpp.
{ 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 99 of file EntityRefiner.cpp.
{ 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 175 of file EntityRefiner.cpp.
{ 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 ); } }
std::vector<double> moab::EntityRefiner::coord_heap [protected] |
Definition at line 166 of file EntityRefiner.hpp.
std::vector<double>::iterator moab::EntityRefiner::current_coord [protected] |
Definition at line 167 of file EntityRefiner.hpp.
std::vector<char>::iterator moab::EntityRefiner::current_tag [protected] |
Definition at line 169 of file EntityRefiner.hpp.
Definition at line 162 of file EntityRefiner.hpp.
int moab::EntityRefiner::maximum_number_of_subdivisions [protected] |
Definition at line 165 of file EntityRefiner.hpp.
Interface* moab::EntityRefiner::mesh_in [protected] |
Definition at line 161 of file EntityRefiner.hpp.
int moab::EntityRefiner::minimum_number_of_subdivisions [protected] |
Definition at line 164 of file EntityRefiner.hpp.
Definition at line 163 of file EntityRefiner.hpp.
std::vector<char> moab::EntityRefiner::tag_heap [protected] |
Definition at line 168 of file EntityRefiner.hpp.