moab
EntityRefiner.cpp
Go to the documentation of this file.
00001 #include "EntityRefiner.hpp"
00002 
00003 #include "EdgeSizeEvaluator.hpp"
00004 #include "moab/Interface.hpp"
00005 
00006 namespace moab {
00007 
00009 EntityRefiner::EntityRefiner()
00010 {  
00011   this->mesh_in = 0;
00012   this->edge_size_evaluator = 0;
00013   this->output_functor = 0;
00014   // By default, allow at most one subdivision per edge
00015   this->minimum_number_of_subdivisions = 0;
00016   this->maximum_number_of_subdivisions = 1;
00017 }
00018 
00020 EntityRefiner::~EntityRefiner()
00021 {
00022   if ( this->edge_size_evaluator )
00023     delete this->edge_size_evaluator;
00024 }
00025 
00034 bool EntityRefiner::prepare( RefinerTagManager* tmgr, EntityRefinerOutputFunctor* ofunc )
00035 {
00036   bool rval = true;
00037   if ( this->edge_size_evaluator )
00038     {
00039     this->edge_size_evaluator->set_tag_manager( tmgr );
00040     }
00041   else
00042     {
00043     rval = false;
00044     }
00045   this->set_output_functor( ofunc );
00046   this->mesh_in = tmgr->get_input_mesh();
00047   this->update_heap_size();
00048   return rval;
00049 }
00050 
00071 bool EntityRefiner::set_edge_size_evaluator( EdgeSizeEvaluator* ese )
00072 {
00073   if ( ! ese || ese == this->edge_size_evaluator )
00074     return false;
00075 
00076   if ( this->edge_size_evaluator )
00077     {
00078     delete this->edge_size_evaluator;
00079     }
00080   this->edge_size_evaluator = ese;
00081 
00082   return true;
00083 }
00084 
00099 bool EntityRefiner::set_output_functor( EntityRefinerOutputFunctor* func_obj )
00100 {
00101   if ( ! func_obj || func_obj == this->output_functor )
00102     return false;
00103 
00104   if ( this->output_functor )
00105     {
00106     delete this->output_functor;
00107     }
00108   this->output_functor = func_obj;
00109   return true;
00110 }
00111 
00124 bool EntityRefiner::set_minimum_number_of_subdivisions( int mn )
00125 {
00126   if ( mn < 0 || mn == this->minimum_number_of_subdivisions )
00127     {
00128     return false;
00129     }
00130 
00131   this->minimum_number_of_subdivisions = mn;
00132   return true;
00133 }
00134 
00150 bool EntityRefiner::set_maximum_number_of_subdivisions( int mx )
00151 {
00152   if ( mx < 0 || mx == this->maximum_number_of_subdivisions )
00153     {
00154     return false;
00155     }
00156 
00157   this->maximum_number_of_subdivisions = mx;
00158   this->update_heap_size();
00159   return true;
00160 }
00161 
00175 void EntityRefiner::update_heap_size()
00176 {
00177   unsigned long n = this->get_heap_size_bound( this->maximum_number_of_subdivisions );
00178   this->coord_heap.resize( 6 * n );
00179   if ( this->edge_size_evaluator )
00180     {
00181     unsigned long m = this->edge_size_evaluator->get_tag_manager()->get_vertex_tag_size();
00182     this->tag_heap.resize( m * n );
00183     }
00184 }
00185 
00191 void EntityRefiner::reset_heap_pointers()
00192 {
00193   this->current_coord = this->coord_heap.begin();
00194   this->current_tag = this->tag_heap.begin();
00195 }
00196 
00201 double* EntityRefiner::heap_coord_storage()
00202 {
00203   double* rval;
00204   if ( this->current_coord != this->coord_heap.end() )
00205     {
00206     rval = &(*this->current_coord);
00207     this->current_coord += 6;
00208     }
00209   else
00210     {
00211     rval = 0;
00212     }
00213   return rval;
00214 }
00215 
00221 void* EntityRefiner::heap_tag_storage()
00222 {
00223   void* rval;
00224   if ( this->edge_size_evaluator && this->current_tag != this->tag_heap.end() )
00225     {
00226     rval = (void*) &(*this->current_tag);
00227     this->current_tag += this->edge_size_evaluator->get_tag_manager()->get_vertex_tag_size();
00228     }
00229   else
00230     {
00231     rval = 0;
00232     }
00233   return rval;
00234 }
00235 
00236 } // namespace moab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines