MOAB: Mesh Oriented datABase  (version 5.4.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

Interfacemesh_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.

Author:
David Thompson
Philippe Pebay
Date:
24 December 2007

Definition at line 146 of file EntityRefiner.hpp.


Constructor & Destructor Documentation

Construct an entity refiner.

Definition at line 10 of file EntityRefiner.cpp.

References edge_size_evaluator, maximum_number_of_subdivisions, mesh_in, minimum_number_of_subdivisions, and output_functor.

{
    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;
}

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

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:
Apointer to an edge size evaluator object or NULL.

Definition at line 157 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().

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:
Theguaranteed maximum number of subdivisions that will take place on each and every edge of the mesh.

Definition at line 175 of file EntityRefiner.hpp.

References maximum_number_of_subdivisions.

    {
        return this->maximum_number_of_subdivisions;
    }

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:
Theguaranteed minimum number of subdivisions that will take place on each and every edge of the mesh.

Definition at line 169 of file EntityRefiner.hpp.

References minimum_number_of_subdivisions.

    {
        return this->minimum_number_of_subdivisions;
    }

Return the functor used to stream output.

Return values:
Apointer to the functor. This may be NULL.

Definition at line 163 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 209 of file EntityRefiner.cpp.

References coord_heap, and current_coord.

Referenced by moab::SimplexTemplateRefiner::refine_1_simplex(), moab::SimplexTemplateRefiner::refine_2_simplex(), and moab::SimplexTemplateRefiner::refine_3_simplex().

{
    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 230 of file EntityRefiner.cpp.

References current_tag, edge_size_evaluator, moab::EdgeSizeEvaluator::get_tag_manager(), moab::RefinerTagManager::get_vertex_tag_size(), and tag_heap.

Referenced by moab::SimplexTemplateRefiner::refine_1_simplex(), moab::SimplexTemplateRefiner::refine_2_simplex(), moab::SimplexTemplateRefiner::refine_3_simplex(), and moab::SimplexTemplateRefiner::refine_entity().

{
    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;
}

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.

References edge_size_evaluator, moab::RefinerTagManager::get_input_mesh(), mesh_in, set_output_functor(), moab::EdgeSizeEvaluator::set_tag_manager(), and update_heap_size().

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().

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 197 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();
}

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:
eseThe new edge size evaluator object.
Return values:
Returnstrue if the value was changed and false otherwise.

Definition at line 72 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;
}

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:
Trueif the number of subdivisions was changed; false otherwise.

Definition at line 154 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;
}

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:
Trueif the number of subdivisions was changed; false otherwise.

Definition at line 125 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;
}

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 100 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;
}

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 181 of file EntityRefiner.cpp.

References coord_heap, edge_size_evaluator, get_heap_size_bound(), moab::EdgeSizeEvaluator::get_tag_manager(), moab::RefinerTagManager::get_vertex_tag_size(), maximum_number_of_subdivisions, and tag_heap.

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 186 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 187 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 189 of file EntityRefiner.hpp.

Referenced by heap_tag_storage(), and reset_heap_pointers().

Definition at line 181 of file EntityRefiner.hpp.

Referenced by EntityRefiner(), and prepare().

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

Definition at line 188 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:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines