MOAB: Mesh Oriented datABase  (version 5.3.0)
ElemEvaluator.hpp
Go to the documentation of this file.
00001 #ifndef ELEM_EVALUATOR_HPP
00002 #define ELEM_EVALUATOR_HPP
00003 
00004 #include "moab/Interface.hpp"
00005 #include "moab/CartVect.hpp"
00006 #include "moab/Matrix3.hpp"
00007 #include "moab/CN.hpp"
00008 
00009 #include <vector>
00010 
00011 namespace moab
00012 {
00013 
00014 typedef ErrorCode ( *EvalFcn )( const double* params, const double* field, const int ndim, const int num_tuples,
00015                                 double* work, double* result );
00016 
00017 typedef ErrorCode ( *JacobianFcn )( const double* params, const double* verts, const int nverts, const int ndim,
00018                                     double* work, double* result );
00019 
00020 typedef ErrorCode ( *IntegrateFcn )( const double* field, const double* verts, const int nverts, const int ndim,
00021                                      const int num_tuples, double* work, double* result );
00022 
00023 typedef ErrorCode ( *InitFcn )( const double* verts, const int nverts, double*& work );
00024 
00025 typedef int ( *InsideFcn )( const double* verts, const int ndims, const double tol );
00026 
00027 typedef ErrorCode ( *ReverseEvalFcn )( EvalFcn eval, JacobianFcn jacob, InsideFcn ins, const double* posn,
00028                                        const double* verts, const int nverts, const int ndim, const double iter_tol,
00029                                        const double inside_tol, double* work, double* params, int* is_inside );
00030 
00031 typedef ErrorCode ( *NormalFcn )( const int ientDim, const int facet, const int nverts, const double* verts,
00032                                   double normal[3] );
00033 
00034 class EvalSet
00035 {
00036   public:
00037     /** \brief Forward-evaluation of field at parametric coordinates */
00038     EvalFcn evalFcn;
00039 
00040     /** \brief Reverse-evaluation of parametric coordinates at physical space position */
00041     ReverseEvalFcn reverseEvalFcn;
00042 
00043     /** \brief Evaluate the normal at a local facet (edge/face for 2D/3D) */
00044     NormalFcn normalFcn;
00045 
00046     /** \brief Evaluate the jacobian at a specified parametric position */
00047     JacobianFcn jacobianFcn;
00048 
00049     /** \brief Forward-evaluation of field at parametric coordinates */
00050     IntegrateFcn integrateFcn;
00051 
00052     /** \brief Initialization function for an element */
00053     InitFcn initFcn;
00054 
00055     /** \brief Function that returns whether or not the parameters are inside the natural space of
00056      * the element */
00057     InsideFcn insideFcn;
00058 
00059     /** \brief Bare constructor */
00060     EvalSet()
00061         : evalFcn( NULL ), reverseEvalFcn( NULL ), normalFcn( NULL ), jacobianFcn( NULL ), integrateFcn( NULL ),
00062           initFcn( NULL ), insideFcn( NULL )
00063     {
00064     }
00065 
00066     /** \brief Constructor */
00067     EvalSet( EvalFcn eval, ReverseEvalFcn rev, NormalFcn normal, JacobianFcn jacob, IntegrateFcn integ, InitFcn initf,
00068              InsideFcn insidef )
00069         : evalFcn( eval ), reverseEvalFcn( rev ), normalFcn( normal ), jacobianFcn( jacob ), integrateFcn( integ ),
00070           initFcn( initf ), insideFcn( insidef )
00071     {
00072     }
00073 
00074     /** \brief Given an entity handle, get an appropriate eval set, based on type & #vertices */
00075     static ErrorCode get_eval_set( Interface* mb, EntityHandle eh, EvalSet& eval_set );
00076 
00077     /** \brief Given type & #vertices, get an appropriate eval set */
00078     static ErrorCode get_eval_set( EntityType tp, unsigned int num_vertices, EvalSet& eval_set );
00079 
00080     /** \brief Operator= */
00081     EvalSet& operator=( const EvalSet& eval )
00082     {
00083         evalFcn        = eval.evalFcn;
00084         reverseEvalFcn = eval.reverseEvalFcn;
00085         normalFcn      = eval.normalFcn;
00086         jacobianFcn    = eval.jacobianFcn;
00087         integrateFcn   = eval.integrateFcn;
00088         initFcn        = eval.initFcn;
00089         insideFcn      = eval.insideFcn;
00090         return *this;
00091     }
00092 
00093     /** \brief Common function to do reverse evaluation based on evaluation and jacobian functions
00094      */
00095     static ErrorCode evaluate_reverse( EvalFcn eval, JacobianFcn jacob, InsideFcn inside_f, const double* posn,
00096                                        const double* verts, const int nverts, const int ndim, const double iter_tol,
00097                                        const double inside_tol, double* work, double* params, int* inside );
00098     /** \brief Common function that returns true if params is in [-1,1]^ndims */
00099     static int inside_function( const double* params, const int ndims, const double tol );
00100 };
00101 
00102 /** \brief Given an entity handle, get an appropriate eval set, based on type & #vertices */
00103 inline ErrorCode EvalSet::get_eval_set( Interface* mb, EntityHandle eh, EvalSet& eval_set )
00104 {
00105     int nv;
00106     EntityType tp = mb->type_from_handle( eh );
00107     const EntityHandle* connect;
00108     std::vector< EntityHandle > dum_vec;
00109     ErrorCode rval = mb->get_connectivity( eh, connect, nv, false, &dum_vec );
00110     if( MB_SUCCESS != rval ) return rval;
00111 
00112     return get_eval_set( tp, nv, eval_set );
00113 }
00114 
00115 /**\brief Class facilitating local discretization-related functions
00116  * \class ElemEvaluator
00117  * This class implements discretization-related functionality operating
00118  * on data in MOAB.  A member of this class caches certain data about the element
00119  * it's currently operating on, but is not meant to be instantiated one-per-element,
00120  * but rather one-per-search (or other operation on a collection of elements).
00121  *
00122  * Actual discretization functionality is accessed through function pointers,
00123  * allowing applications to specialize the implementation of specific functions
00124  * while still using this class.
00125  *
00126  * This class depends on MOAB functionality for gathering entity-based data; the functions
00127  * it calls through function pointers depend only on POD (plain old data, or intrinsic data types).
00128  * This allows the use of other packages for serving these functions, without having to modify
00129  * them to get data through MOAB.  This should also promote efficiency, since in many cases they
00130  * will be able to read data from its native storage locations.
00131  */
00132 
00133 class ElemEvaluator
00134 {
00135   public:
00136     /** \brief Constructor
00137      * \param impl MOAB instance
00138      * \param ent Entity handle to cache on the evaluator; if non-zero, calls set_ent_handle, which
00139      * does some other stuff. \param tag Tag to cache on the evaluator; if non-zero, calls
00140      * set_tag_handle, which does some other stuff too. \param tagged_ent_dim Dimension of entities
00141      * to be tagged to cache on the evaluator
00142      */
00143     ElemEvaluator( Interface* impl, EntityHandle ent = 0, Tag tag = 0, int tagged_ent_dim = -1 );
00144     ~ElemEvaluator();
00145 
00146     /** \brief Evaluate cached tag at a given parametric location within the cached entity
00147      * If evaluating coordinates, call set_tag(0, 0), which indicates coords instead of a tag.
00148      * \param params Parameters at which to evaluate field
00149      * \param result Result of evaluation
00150      * \param num_tuples Size of evaluated field, in number of values
00151      */
00152     ErrorCode eval( const double* params, double* result, int num_tuples = -1 ) const;
00153 
00154     /** \brief Reverse-evaluate the cached entity at a given physical position
00155      * \param posn Position at which to evaluate parameters
00156      * \param iter_tol Tolerance of reverse evaluation non-linear iteration, usually 10^-10 or so
00157      * \param inside_tol Tolerance of is_inside evaluation, usually 10^-6 or so
00158      * \param params Result of evaluation
00159      * \param is_inside If non-NULL, returns true of resulting parameters place the point inside the
00160      * element (in most cases, within [-1]*(dim)
00161      */
00162     ErrorCode reverse_eval( const double* posn, double iter_tol, double inside_tol, double* params,
00163                             int* is_inside = NULL ) const;
00164 
00165     /**
00166      * \brief Evaluate the normal to a facet of an entity
00167      * \param ientDim Dimension of the facet. Should be (d-1) for d-dimensional entities
00168      * \param facet Local id of the facet w.r.t the entity
00169      * \param normal Returns the normal.
00170      */
00171     ErrorCode get_normal( const int ientDim, const int facet, double normal[3] ) const;
00172 
00173     /** \brief Evaluate the jacobian of the cached entity at a given parametric location
00174      * \param params Parameters at which to evaluate jacobian
00175      * \param result Result of evaluation, in the form of a 3x3 matrix, stored in column-major order
00176      */
00177     ErrorCode jacobian( const double* params, double* result ) const;
00178 
00179     /** \brief Integrate the cached tag over the cached entity
00180      * \param result Result of the integration
00181      */
00182     ErrorCode integrate( double* result ) const;
00183 
00184     /** \brief Return whether a physical position is inside the cached entity to within a tolerance
00185      * \param params Parameters at which to query the element
00186      * \param tol Tolerance, usually 10^-6 or so
00187      */
00188     int inside( const double* params, const double tol ) const;
00189 
00190     /** \brief Given a list of entities, return the entity the point is in, or none
00191      * This function reverse-evaluates the entities, returning the first entity containing the
00192      * point. If no entity contains the point, containing_ent is returned as 0 and params are
00193      * unchanged. This function returns something other than MB_SUCCESS only when queries go wrong
00194      * for some reason. num_evals, if non-NULL, is always incremented for each call to reverse_eval.
00195      * This function calls set_ent_handle for each entity before calling reverse_eval, so the
00196      * ElemEvaluator object is changed. \param entities Entities tested \param point Point tested,
00197      * must have 3 dimensions, even for edge and face entities \param iter_tol Tolerance for
00198      * non-linear reverse evaluation \param inside_tol Tolerance for is_inside test \param
00199      * containing_ent Entity containing the point, returned 0 if no entity \param params Parameters
00200      * of point in containing entity, unchanged if no containing entity \param num_evals If
00201      * non-NULL, incremented each time reverse_eval is called \return Returns non-success only if
00202      * evaulation failed for some reason (point not in element is NOT a reason for failure)
00203      */
00204     ErrorCode find_containing_entity( Range& entities, const double* point, const double iter_tol,
00205                                       const double inside_tol, EntityHandle& containing_ent, double* params,
00206                                       unsigned int* num_evals = NULL );
00207 
00208     /** \brief Given an entity set, return the contained entity the point is in, or none
00209      * This function reverse-evaluates the entities, returning the first entity containing the
00210      * point. If no entity contains the point, containing_ent is returned as 0 and params are
00211      * unchanged. This function returns something other than MB_SUCCESS only when queries go wrong
00212      * for some reason. num_evals, if non-NULL, is always incremented for each call to reverse_eval.
00213      * This function calls set_ent_handle for each entity before calling reverse_eval, so the
00214      * ElemEvaluator object is changed. \param ent_set Entity set containing the entities to be
00215      * tested \param point Point tested, must have 3 dimensions, even for edge and face entities
00216      * \param iter_tol Tolerance for non-linear reverse evaluation
00217      * \param inside_tol Tolerance for is_inside test
00218      * \param containing_ent Entity containing the point, returned 0 if no entity
00219      * \param params Parameters of point in containing entity, unchanged if no containing entity
00220      * \param num_evals If non-NULL, incremented each time reverse_eval is called
00221      * \return Returns non-success only if evaulation failed for some reason (point not in element
00222      * is NOT a reason for failure)
00223      */
00224     ErrorCode find_containing_entity( EntityHandle ent_set, const double* point, const double iter_tol,
00225                                       const double inside_tol, EntityHandle& containing_ent, double* params,
00226                                       unsigned int* num_evals = NULL );
00227 
00228     /** \brief Set the eval set for a given type entity
00229      * \param tp Entity type for which to set the eval set
00230      * \param eval_set Eval set object to use
00231      */
00232     ErrorCode set_eval_set( EntityType tp, const EvalSet& eval_set );
00233 
00234     /** \brief Set the eval set using a given entity handle
00235      * This function queries the entity type and number of vertices on the entity to decide which
00236      * type of shape function to use. NOTE: this function should only be called after setting a
00237      * valid MOAB instance on the evaluator \param eh Entity handle whose type and #vertices are
00238      * queried
00239      */
00240     ErrorCode set_eval_set( const EntityHandle eh );
00241 
00242     /** \brief Get the eval set for a given type entity */
00243     inline EvalSet get_eval_set( EntityType tp )
00244     {
00245         return evalSets[tp];
00246     }
00247 
00248     /** \brief Set entity handle & cache connectivty & vertex positions */
00249     inline ErrorCode set_ent_handle( EntityHandle ent );
00250 
00251     /** \brief Get entity handle for this ElemEval */
00252     inline EntityHandle get_ent_handle() const
00253     {
00254         return entHandle;
00255     }
00256 
00257     /* \brief Get vertex positions cached on this EE
00258      */
00259     inline double* get_vert_pos()
00260     {
00261         return vertPos[0].array();
00262     }
00263 
00264     /* \brief Get the vertex handles cached here */
00265     inline const EntityHandle* get_vert_handles() const
00266     {
00267         return vertHandles;
00268     }
00269 
00270     /* \brief Get the number of vertices for the cached entity */
00271     inline int get_num_verts() const
00272     {
00273         return numVerts;
00274     }
00275 
00276     /* \brief Get the tag handle cached on this entity */
00277     inline Tag get_tag_handle() const
00278     {
00279         return tagHandle;
00280     };
00281 
00282     /* \brief Set the tag handle to cache on this evaluator
00283      * To designate that vertex coordinates are the desired tag, pass in a tag handle of 0
00284      * and a tag dimension of 0.
00285      * \param tag Tag handle to cache, or 0 to cache vertex positions
00286      * \param tagged_ent_dim Dimension of entities tagged with this tag
00287      */
00288     inline ErrorCode set_tag_handle( Tag tag, int tagged_ent_dim = -1 );
00289 
00290     /* \brief Set the name of the tag to cache on this evaluator
00291      * To designate that vertex coordinates are the desired tag, pass in "COORDS" as the name
00292      * and a tag dimension of 0.
00293      * \param tag_name Tag handle to cache, or 0 to cache vertex positions
00294      * \param tagged_ent_dim Dimension of entities tagged with this tag
00295      */
00296     inline ErrorCode set_tag( const char* tag_name, int tagged_ent_dim = -1 );
00297 
00298     /* \brief Get the dimension of the entities on which tag is set */
00299     inline int get_tagged_ent_dim() const
00300     {
00301         return taggedEntDim;
00302     };
00303 
00304     /* \brief Set the dimension of entities having the tag */
00305     inline ErrorCode set_tagged_ent_dim( int dim );
00306 
00307     /* \brief Get work space, sometimes this is useful for evaluating data you don't want to set as
00308      * tags on entities Can't be const because most of the functions (evaluate, integrate, etc.)
00309      * take non-const work space *'s
00310      */
00311     inline double* get_work_space()
00312     {
00313         return workSpace;
00314     }
00315 
00316     /* \brief MOAB interface cached on this evaluator */
00317     inline Interface* get_moab()
00318     {
00319         return mbImpl;
00320     }
00321 
00322   private:
00323     /** \brief Interface */
00324     Interface* mbImpl;
00325 
00326     /** \brief Entity handle being evaluated */
00327     EntityHandle entHandle;
00328 
00329     /** \brief Entity type */
00330     EntityType entType;
00331 
00332     /** \brief Entity dimension */
00333     int entDim;
00334 
00335     /** \brief Number of vertices cached here */
00336     int numVerts;
00337 
00338     /** \brief Cached copy of vertex handle ptr */
00339     const EntityHandle* vertHandles;
00340 
00341     /** \brief Cached copy of vertex positions */
00342     CartVect vertPos[CN::MAX_NODES_PER_ELEMENT];
00343 
00344     /** \brief Tag being evaluated */
00345     Tag tagHandle;
00346 
00347     /** \brief Whether tag is coordinates or something else */
00348     bool tagCoords;
00349 
00350     /** \brief Number of values in this tag */
00351     int numTuples;
00352 
00353     /** \brief Dimension of entities from which to grab tag */
00354     int taggedEntDim;
00355 
00356     /** \brief Tag space */
00357     std::vector< unsigned char > tagSpace;
00358 
00359     /** \brief Evaluation methods for elements of various topologies */
00360     EvalSet evalSets[MBMAXTYPE];
00361 
00362     /** \brief Work space for element-specific data */
00363     double* workSpace;
00364 
00365 };  // class ElemEvaluator
00366 
00367 inline ElemEvaluator::ElemEvaluator( Interface* impl, EntityHandle ent, Tag tag, int tagged_ent_dim )
00368     : mbImpl( impl ), entHandle( 0 ), entType( MBMAXTYPE ), entDim( -1 ), numVerts( 0 ), vertHandles( NULL ),
00369       tagHandle( 0 ), tagCoords( false ), numTuples( 0 ), taggedEntDim( 0 ), workSpace( NULL )
00370 {
00371     if( ent ) set_ent_handle( ent );
00372     if( tag ) set_tag_handle( tag, tagged_ent_dim );
00373 }
00374 
00375 inline ElemEvaluator::~ElemEvaluator()
00376 {
00377     if( workSpace ) delete[] workSpace;
00378 }
00379 
00380 inline ErrorCode ElemEvaluator::set_ent_handle( EntityHandle ent )
00381 {
00382     entHandle = ent;
00383     if( workSpace )
00384     {
00385         delete[] workSpace;
00386         workSpace = NULL;
00387     }
00388 
00389     entType = mbImpl->type_from_handle( ent );
00390     entDim  = mbImpl->dimension_from_handle( ent );
00391 
00392     std::vector< EntityHandle > dum_vec;
00393     ErrorCode rval = mbImpl->get_connectivity( ent, vertHandles, numVerts, false, &dum_vec );
00394     if( MB_SUCCESS != rval ) return rval;
00395 
00396     if( !evalSets[entType].evalFcn ) EvalSet::get_eval_set( entType, numVerts, evalSets[entType] );
00397 
00398     rval = mbImpl->get_coords( vertHandles, numVerts, vertPos[0].array() );
00399     if( MB_SUCCESS != rval ) return rval;
00400 
00401     if( tagHandle )
00402     {
00403         rval = set_tag_handle( tagHandle );
00404         if( MB_SUCCESS != rval ) return rval;
00405     }
00406     if( evalSets[entType].initFcn ) return ( *evalSets[entType].initFcn )( vertPos[0].array(), numVerts, workSpace );
00407     return MB_SUCCESS;
00408 }
00409 
00410 inline ErrorCode ElemEvaluator::set_tag_handle( Tag tag, int tagged_ent_dim )
00411 {
00412     ErrorCode rval = MB_SUCCESS;
00413     if( !tag && !tagged_ent_dim )
00414     {
00415         tagCoords    = true;
00416         numTuples    = 3;
00417         taggedEntDim = 0;
00418         tagHandle    = 0;
00419         return rval;
00420     }
00421     else if( tagHandle != tag )
00422     {
00423         tagHandle = tag;
00424         rval      = mbImpl->tag_get_length( tagHandle, numTuples );
00425         if( MB_SUCCESS != rval ) return rval;
00426         int sz;
00427         rval = mbImpl->tag_get_bytes( tag, sz );
00428         if( MB_SUCCESS != rval ) return rval;
00429         tagSpace.resize( CN::MAX_NODES_PER_ELEMENT * sz );
00430         tagCoords = false;
00431     }
00432 
00433     taggedEntDim = ( -1 == tagged_ent_dim ? 0 : tagged_ent_dim );
00434 
00435     if( entHandle )
00436     {
00437         if( 0 == taggedEntDim )
00438         {
00439             rval = mbImpl->tag_get_data( tagHandle, vertHandles, numVerts, &tagSpace[0] );
00440             if( MB_SUCCESS != rval ) return rval;
00441         }
00442         else if( taggedEntDim == entDim )
00443         {
00444             rval = mbImpl->tag_get_data( tagHandle, &entHandle, 1, &tagSpace[0] );
00445             if( MB_SUCCESS != rval ) return rval;
00446         }
00447     }
00448 
00449     return rval;
00450 }
00451 
00452 inline ErrorCode ElemEvaluator::set_tag( const char* tag_name, int tagged_ent_dim )
00453 {
00454     ErrorCode rval = MB_SUCCESS;
00455     if( !tag_name || strlen( tag_name ) == 0 ) return MB_FAILURE;
00456     Tag tag;
00457     if( !strcmp( tag_name, "COORDS" ) )
00458     {
00459         tagCoords    = true;
00460         taggedEntDim = 0;
00461         numTuples    = 3;
00462         tagHandle    = 0;
00463         // can return here, because vertex coords already cached when entity handle set
00464         return rval;
00465     }
00466     else
00467     {
00468         rval = mbImpl->tag_get_handle( tag_name, tag );
00469         if( MB_SUCCESS != rval ) return rval;
00470 
00471         if( tagHandle != tag )
00472         {
00473             tagHandle = tag;
00474             rval      = mbImpl->tag_get_length( tagHandle, numTuples );
00475             if( MB_SUCCESS != rval ) return rval;
00476             int sz;
00477             rval = mbImpl->tag_get_bytes( tag, sz );
00478             if( MB_SUCCESS != rval ) return rval;
00479             tagSpace.reserve( CN::MAX_NODES_PER_ELEMENT * sz );
00480             tagCoords = false;
00481         }
00482 
00483         taggedEntDim = ( -1 == tagged_ent_dim ? entDim : tagged_ent_dim );
00484     }
00485 
00486     if( entHandle )
00487     {
00488         if( 0 == taggedEntDim )
00489         {
00490             rval = mbImpl->tag_get_data( tagHandle, vertHandles, numVerts, &tagSpace[0] );
00491             if( MB_SUCCESS != rval ) return rval;
00492         }
00493         else if( taggedEntDim == entDim )
00494         {
00495             rval = mbImpl->tag_get_data( tagHandle, &entHandle, 1, &tagSpace[0] );
00496             if( MB_SUCCESS != rval ) return rval;
00497         }
00498     }
00499 
00500     return rval;
00501 }
00502 
00503 inline ErrorCode ElemEvaluator::set_eval_set( EntityType tp, const EvalSet& eval_set )
00504 {
00505     evalSets[tp] = eval_set;
00506     if( entHandle && evalSets[entType].initFcn )
00507     {
00508         ErrorCode rval = ( *evalSets[entType].initFcn )( vertPos[0].array(), numVerts, workSpace );
00509         if( MB_SUCCESS != rval ) return rval;
00510     }
00511     return MB_SUCCESS;
00512 }
00513 
00514 inline ErrorCode ElemEvaluator::eval( const double* params, double* result, int num_tuples ) const
00515 {
00516     assert( entHandle && MBMAXTYPE != entType );
00517     return ( *evalSets[entType].evalFcn )(
00518         params, ( tagCoords ? (const double*)vertPos[0].array() : (const double*)&tagSpace[0] ), entDim,
00519         ( -1 == num_tuples ? numTuples : num_tuples ), workSpace, result );
00520 }
00521 
00522 inline ErrorCode ElemEvaluator::reverse_eval( const double* posn, const double iter_tol, const double inside_tol,
00523                                               double* params, int* ins ) const
00524 {
00525     assert( entHandle && MBMAXTYPE != entType );
00526     return ( *evalSets[entType].reverseEvalFcn )( evalSets[entType].evalFcn, evalSets[entType].jacobianFcn,
00527                                                   evalSets[entType].insideFcn, posn, vertPos[0].array(), numVerts,
00528                                                   entDim, iter_tol, inside_tol, workSpace, params, ins );
00529 }
00530 
00531 /** \brief Evaluate the normal of the cached entity at a given facet */
00532 inline ErrorCode ElemEvaluator::get_normal( const int ientDim, const int facet, double normal[] ) const
00533 {
00534     assert( entHandle && MBMAXTYPE != entType );
00535     return ( *evalSets[entType].normalFcn )( ientDim, facet, numVerts, vertPos[0].array(), normal );
00536 }
00537 
00538 /** \brief Evaluate the jacobian of the cached entity at a given parametric location */
00539 inline ErrorCode ElemEvaluator::jacobian( const double* params, double* result ) const
00540 {
00541     assert( entHandle && MBMAXTYPE != entType );
00542     return ( *evalSets[entType].jacobianFcn )( params, vertPos[0].array(), numVerts, entDim, workSpace, result );
00543 }
00544 
00545 /** \brief Integrate the cached tag over the cached entity */
00546 inline ErrorCode ElemEvaluator::integrate( double* result ) const
00547 {
00548     assert( entHandle && MBMAXTYPE != entType && ( tagCoords || tagHandle ) );
00549     ErrorCode rval = MB_SUCCESS;
00550     if( !tagCoords )
00551     {
00552         if( 0 == taggedEntDim )
00553             rval = mbImpl->tag_get_data( tagHandle, vertHandles, numVerts, (void*)&tagSpace[0] );
00554         else
00555             rval = mbImpl->tag_get_data( tagHandle, &entHandle, 1, (void*)&tagSpace[0] );
00556         if( MB_SUCCESS != rval ) return rval;
00557     }
00558     return ( *evalSets[entType].integrateFcn )( ( tagCoords ? vertPos[0].array() : (const double*)&tagSpace[0] ),
00559                                                 vertPos[0].array(), numVerts, entDim, numTuples, workSpace, result );
00560 }
00561 
00562 inline ErrorCode ElemEvaluator::find_containing_entity( EntityHandle ent_set, const double* point,
00563                                                         const double iter_tol, const double inside_tol,
00564                                                         EntityHandle& containing_ent, double* params,
00565                                                         unsigned int* num_evals )
00566 {
00567     assert( mbImpl->type_from_handle( ent_set ) == MBENTITYSET );
00568     Range entities;
00569     ErrorCode rval = mbImpl->get_entities_by_handle( ent_set, entities );
00570     if( MB_SUCCESS != rval )
00571         return rval;
00572     else
00573         return find_containing_entity( entities, point, iter_tol, inside_tol, containing_ent, params, num_evals );
00574 }
00575 
00576 inline int ElemEvaluator::inside( const double* params, const double tol ) const
00577 {
00578     return ( *evalSets[entType].insideFcn )( params, entDim, tol );
00579 }
00580 
00581 inline ErrorCode ElemEvaluator::set_eval_set( const EntityHandle eh )
00582 {
00583     EvalSet eset;
00584     ErrorCode rval = EvalSet::get_eval_set( mbImpl, eh, evalSets[mbImpl->type_from_handle( eh )] );
00585     return rval;
00586 }
00587 
00588 }  // namespace moab
00589 
00590 #endif /*MOAB_ELEM_EVALUATOR_HPP*/
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines