moab
|
00001 /* 00002 * MOAB, a Mesh-Oriented datABase, is a software component for creating, 00003 * storing and accessing finite element mesh data. 00004 * 00005 * Copyright 2007 Sandia Corporation. Under the terms of Contract 00006 * DE-AC04-94AL85000 with Sandia Coroporation, the U.S. Government 00007 * retains certain rights in this software. 00008 * 00009 * This library is free software; you can redistribute it and/or 00010 * modify it under the terms of the GNU Lesser General Public 00011 * License as published by the Free Software Foundation; either 00012 * version 2.1 of the License, or (at your option) any later version. 00013 * 00014 */ 00015 00064 #ifndef MOAB_ENTITY_REFINER_HPP 00065 #define MOAB_ENTITY_REFINER_HPP 00066 00067 #include "moab/Types.hpp" 00068 #include "moab/Compiler.hpp" // for MB_DLL_EXPORT 00069 00070 #include <vector> 00071 00072 namespace moab { 00073 00074 class Interface; 00075 class EdgeSizeEvaluator; 00076 class RefinerTagManager; 00077 00078 class MB_DLL_EXPORT EntityRefinerOutputFunctor 00079 { 00080 public: 00081 virtual ~EntityRefinerOutputFunctor() { } 00083 virtual EntityHandle map_vertex( EntityHandle vhash, const double* vcoords, const void* vtags ) = 0; 00092 EntityHandle operator () ( EntityHandle h0, EntityHandle h1, const double* vcoords, const void* vtags ) 00093 { 00094 EntityHandle harr[2]; 00095 harr[0] = h0; 00096 harr[1] = h1; 00097 return (*this)( 2, harr, vcoords, vtags ); 00098 } 00108 virtual EntityHandle operator () ( EntityHandle h0, EntityHandle h1, EntityHandle h2, const double* vcoords, const void* vtags ) 00109 { 00110 EntityHandle harr[3]; 00111 harr[0] = h0; 00112 harr[1] = h1; 00113 harr[2] = h2; 00114 return (*this)( 3, harr, vcoords, vtags ); 00115 } 00124 virtual EntityHandle operator () ( int nhash, EntityHandle* hash, const double* vcoords, const void* vtags ) = 0; 00129 virtual void operator () ( EntityHandle vhash ) = 0; 00135 virtual void operator () ( EntityType etyp ) = 0; 00136 }; 00137 00138 class MB_DLL_EXPORT EntityRefiner 00139 { 00140 public: 00141 EntityRefiner(); 00142 virtual ~EntityRefiner(); 00143 00144 virtual bool prepare( RefinerTagManager* tmgr, EntityRefinerOutputFunctor* ofunc ); 00145 virtual bool refine_entity( EntityType typ, EntityHandle ent ) = 0; 00146 virtual unsigned long get_heap_size_bound( int max_recursions ) const = 0; 00147 00148 virtual bool set_edge_size_evaluator( EdgeSizeEvaluator* ); 00149 EdgeSizeEvaluator* get_edge_size_evaluator() { return this->edge_size_evaluator; } 00150 00151 virtual bool set_output_functor( EntityRefinerOutputFunctor* func_obj ); 00152 EntityRefinerOutputFunctor* get_output_functor() { return this->output_functor; } 00153 00154 virtual bool set_minimum_number_of_subdivisions( int mn ); 00155 int get_minimum_number_of_subdivisions() const { return this->minimum_number_of_subdivisions; } 00156 00157 virtual bool set_maximum_number_of_subdivisions( int mx ); 00158 int get_maximum_number_of_subdivisions() const { return this->maximum_number_of_subdivisions; } 00159 00160 protected: 00161 Interface* mesh_in; 00162 EdgeSizeEvaluator* edge_size_evaluator; 00163 EntityRefinerOutputFunctor* output_functor; 00164 int minimum_number_of_subdivisions; 00165 int maximum_number_of_subdivisions; 00166 std::vector<double> coord_heap; 00167 std::vector<double>::iterator current_coord; 00168 std::vector<char> tag_heap; 00169 std::vector<char>::iterator current_tag; 00170 00171 void update_heap_size(); 00172 void reset_heap_pointers(); 00173 double* heap_coord_storage(); 00174 void* heap_tag_storage(); 00175 }; 00176 00177 } // namespace moab 00178 00179 #endif // MOAB_ENTITY_REFINER_HPP