Mesh Oriented datABase  (version 5.5.1)
An array-based unstructured mesh library
moab::EvalSet Class Reference

#include <ElemEvaluator.hpp>

Public Member Functions

 EvalSet ()
 Bare constructor. More...
 
 EvalSet (EvalFcn eval, ReverseEvalFcn rev, NormalFcn normal, JacobianFcn jacob, IntegrateFcn integ, InitFcn initf, InsideFcn insidef)
 Constructor. More...
 
 EvalSet (EvalSet const &eval)
 Copy constructor. More...
 
EvalSetoperator= (const EvalSet &eval)
 Operator=. More...
 

Static Public Member Functions

static ErrorCode get_eval_set (Interface *mb, EntityHandle eh, EvalSet &eval_set)
 Given an entity handle, get an appropriate eval set, based on type & #vertices. More...
 
static ErrorCode get_eval_set (EntityType tp, unsigned int num_vertices, EvalSet &eval_set)
 Given type & #vertices, get an appropriate eval set. More...
 
static ErrorCode evaluate_reverse (EvalFcn eval, JacobianFcn jacob, InsideFcn inside_f, const double *posn, const double *verts, const int nverts, const int ndim, const double iter_tol, const double inside_tol, double *work, double *params, int *inside)
 Common function to do reverse evaluation based on evaluation and jacobian functions. More...
 
static int inside_function (const double *params, const int ndims, const double tol)
 Common function that returns true if params is in [-1,1]^ndims. More...
 

Public Attributes

EvalFcn evalFcn
 Forward-evaluation of field at parametric coordinates. More...
 
ReverseEvalFcn reverseEvalFcn
 Reverse-evaluation of parametric coordinates at physical space position. More...
 
NormalFcn normalFcn
 Evaluate the normal at a local facet (edge/face for 2D/3D) More...
 
JacobianFcn jacobianFcn
 Evaluate the jacobian at a specified parametric position. More...
 
IntegrateFcn integrateFcn
 Forward-evaluation of field at parametric coordinates. More...
 
InitFcn initFcn
 Initialization function for an element. More...
 
InsideFcn insideFcn
 Function that returns whether or not the parameters are inside the natural space of the element. More...
 

Detailed Description

Definition at line 56 of file ElemEvaluator.hpp.

Constructor & Destructor Documentation

◆ EvalSet() [1/3]

moab::EvalSet::EvalSet ( )
inline

Bare constructor.

Definition at line 82 of file ElemEvaluator.hpp.

83  : evalFcn( NULL ), reverseEvalFcn( NULL ), normalFcn( NULL ), jacobianFcn( NULL ), integrateFcn( NULL ),
84  initFcn( NULL ), insideFcn( NULL )
85  {
86  }

◆ EvalSet() [2/3]

moab::EvalSet::EvalSet ( EvalFcn  eval,
ReverseEvalFcn  rev,
NormalFcn  normal,
JacobianFcn  jacob,
IntegrateFcn  integ,
InitFcn  initf,
InsideFcn  insidef 
)
inline

Constructor.

Definition at line 89 of file ElemEvaluator.hpp.

96  : evalFcn( eval ), reverseEvalFcn( rev ), normalFcn( normal ), jacobianFcn( jacob ), integrateFcn( integ ),
97  initFcn( initf ), insideFcn( insidef )
98  {
99  }

◆ EvalSet() [3/3]

moab::EvalSet::EvalSet ( EvalSet const &  eval)
inline

Copy constructor.

Definition at line 102 of file ElemEvaluator.hpp.

103  : evalFcn( eval.evalFcn ), reverseEvalFcn( eval.reverseEvalFcn ), normalFcn( eval.normalFcn ),
104  jacobianFcn( eval.jacobianFcn ), integrateFcn( eval.integrateFcn ), initFcn( eval.initFcn ),
105  insideFcn( eval.insideFcn )
106  {
107  }

Member Function Documentation

◆ evaluate_reverse()

ErrorCode moab::EvalSet::evaluate_reverse ( EvalFcn  eval,
JacobianFcn  jacob,
InsideFcn  inside_f,
const double *  posn,
const double *  verts,
const int  nverts,
const int  ndim,
const double  iter_tol,
const double  inside_tol,
double *  work,
double *  params,
int *  inside 
)
static

Common function to do reverse evaluation based on evaluation and jacobian functions.

Definition at line 19 of file ElemEvaluator.cpp.

31 {
32  // TODO: should differentiate between epsilons used for
33  // Newton Raphson iteration, and epsilons used for curved boundary geometry errors
34  // right now, fix the tolerance used for NR
35  const double error_tol_sqr = iter_tol * iter_tol;
36  CartVect* cvparams = reinterpret_cast< CartVect* >( params );
37  const CartVect* cvposn = reinterpret_cast< const CartVect* >( posn );
38 
39  // initialize to center of element
40  *cvparams = CartVect( -.4 );
41 
42  CartVect new_pos;
43  // evaluate that first guess to get a new position
44  ErrorCode rval = ( *eval )( cvparams->array(), verts, ndim,
45  3, // hardwire to num_tuples to 3 since the field is coords
46  work, new_pos.array() );
47  if( MB_SUCCESS != rval ) return rval;
48 
49  // residual is diff between old and new pos; need to minimize that
50  CartVect res = new_pos - *cvposn;
51  Matrix3 J;
52  int dum, *tmp_inside = ( inside ? inside : &dum );
53 
54  int iters = 0;
55  // while |res| larger than tol
56  while( res % res > error_tol_sqr )
57  {
58  if( ++iters > 10 )
59  {
60  // if we haven't converged but we're outside, that's defined as success
61  *tmp_inside = ( *inside_f )( params, ndim, inside_tol );
62  if( !( *tmp_inside ) )
63  return MB_SUCCESS;
64  else
65  return MB_FAILURE;
66  }
67 
68  // get jacobian at current params
69  rval = ( *jacob )( cvparams->array(), verts, nverts, ndim, work, J.array() );
70  double det = J.determinant();
71  if( det < std::numeric_limits< double >::epsilon() )
72  {
73  *tmp_inside = ( *inside_f )( params, ndim, inside_tol );
74  if( !( *tmp_inside ) )
75  return MB_SUCCESS;
76  else
77  return MB_INDEX_OUT_OF_RANGE;
78  }
79 
80  // new params tries to eliminate residual
81  *cvparams -= J.inverse() * res;
82 
83  // get the new forward-evaluated position, and its difference from the target pt
84  rval = ( *eval )( params, verts, ndim,
85  3, // hardwire to num_tuples to 3 since the field is coords
86  work, new_pos.array() );
87  if( MB_SUCCESS != rval ) return rval;
88  res = new_pos - *cvposn;
89  }
90 
91  if( inside ) *inside = ( *inside_f )( params, ndim, inside_tol );
92 
93  return MB_SUCCESS;
94 } // Map::evaluate_reverse()

References moab::CartVect::array(), moab::Matrix3::array(), moab::Matrix3::determinant(), moab::dum, ErrorCode, moab::Matrix3::inverse(), MB_INDEX_OUT_OF_RANGE, and MB_SUCCESS.

Referenced by moab::LinearHex::reverseEvalFcn(), moab::LinearQuad::reverseEvalFcn(), and moab::QuadraticHex::reverseEvalFcn().

◆ get_eval_set() [1/2]

ErrorCode moab::EvalSet::get_eval_set ( EntityType  tp,
unsigned int  num_vertices,
EvalSet eval_set 
)
static

Given type & #vertices, get an appropriate eval set.

Definition at line 107 of file ElemEvaluator.cpp.

108 {
109  switch( tp )
110  {
111  case MBEDGE:
112  break;
113  case MBTRI:
114  if( LinearTri::compatible( tp, num_vertices, eval_set ) ) return MB_SUCCESS;
115  break;
116  case MBQUAD:
117  if( LinearQuad::compatible( tp, num_vertices, eval_set ) ) return MB_SUCCESS;
118  // if (SpectralQuad::compatible(tp, num_vertices, eval_set)) return
119  // MB_SUCCESS;
120  break;
121  case MBTET:
122  if( LinearTet::compatible( tp, num_vertices, eval_set ) ) return MB_SUCCESS;
123  break;
124  case MBHEX:
125  if( LinearHex::compatible( tp, num_vertices, eval_set ) ) return MB_SUCCESS;
126  if( QuadraticHex::compatible( tp, num_vertices, eval_set ) ) return MB_SUCCESS;
127  // if (SpectralHex::compatible(tp, num_vertices, eval_set)) return
128  // MB_SUCCESS;
129  break;
130  default:
131  break;
132  }
133 
134  return MB_NOT_IMPLEMENTED;
135 }

References moab::LinearHex::compatible(), moab::LinearQuad::compatible(), moab::LinearTet::compatible(), moab::LinearTri::compatible(), moab::QuadraticHex::compatible(), MB_NOT_IMPLEMENTED, MB_SUCCESS, MBEDGE, MBHEX, MBQUAD, MBTET, and MBTRI.

◆ get_eval_set() [2/2]

ErrorCode moab::EvalSet::get_eval_set ( Interface mb,
EntityHandle  eh,
EvalSet eval_set 
)
inlinestatic

Given an entity handle, get an appropriate eval set, based on type & #vertices.

Definition at line 147 of file ElemEvaluator.hpp.

148 {
149  int nv;
150  EntityType tp = mb->type_from_handle( eh );
151  const EntityHandle* connect;
152  std::vector< EntityHandle > dum_vec;
153  ErrorCode rval = mb->get_connectivity( eh, connect, nv, false, &dum_vec );
154  if( MB_SUCCESS != rval ) return rval;
155 
156  return get_eval_set( tp, nv, eval_set );
157 }

References ErrorCode, mb, and MB_SUCCESS.

Referenced by moab::ElemEvaluator::set_ent_handle(), and moab::ElemEvaluator::set_eval_set().

◆ inside_function()

int moab::EvalSet::inside_function ( const double *  params,
const int  ndims,
const double  tol 
)
static

Common function that returns true if params is in [-1,1]^ndims.

Definition at line 96 of file ElemEvaluator.cpp.

97 {
98  if( params[0] >= -1 - tol && params[0] <= 1 + tol &&
99  ( ndims < 2 || ( params[1] >= -1 - tol && params[1] <= 1 + tol ) ) &&
100  ( ndims < 3 || ( params[2] >= -1 - tol && params[2] <= 1 + tol ) ) )
101  return true;
102  else
103  return false;
104 }

Referenced by moab::LinearHex::insideFcn(), moab::LinearQuad::insideFcn(), and moab::QuadraticHex::insideFcn().

◆ operator=()

EvalSet& moab::EvalSet::operator= ( const EvalSet eval)
inline

Operator=.

Definition at line 116 of file ElemEvaluator.hpp.

117  {
118  evalFcn = eval.evalFcn;
119  reverseEvalFcn = eval.reverseEvalFcn;
120  normalFcn = eval.normalFcn;
121  jacobianFcn = eval.jacobianFcn;
122  integrateFcn = eval.integrateFcn;
123  initFcn = eval.initFcn;
124  insideFcn = eval.insideFcn;
125  return *this;
126  }

References evalFcn, initFcn, insideFcn, integrateFcn, jacobianFcn, normalFcn, and reverseEvalFcn.

Member Data Documentation

◆ evalFcn

EvalFcn moab::EvalSet::evalFcn

Forward-evaluation of field at parametric coordinates.

Definition at line 60 of file ElemEvaluator.hpp.

Referenced by operator=(), and moab::ElemEvaluator::reverse_eval().

◆ initFcn

InitFcn moab::EvalSet::initFcn

Initialization function for an element.

Definition at line 75 of file ElemEvaluator.hpp.

Referenced by operator=(), and moab::ElemEvaluator::set_eval_set().

◆ insideFcn

InsideFcn moab::EvalSet::insideFcn

Function that returns whether or not the parameters are inside the natural space of the element.

Definition at line 79 of file ElemEvaluator.hpp.

Referenced by operator=(), and moab::ElemEvaluator::reverse_eval().

◆ integrateFcn

IntegrateFcn moab::EvalSet::integrateFcn

Forward-evaluation of field at parametric coordinates.

Definition at line 72 of file ElemEvaluator.hpp.

Referenced by operator=().

◆ jacobianFcn

JacobianFcn moab::EvalSet::jacobianFcn

Evaluate the jacobian at a specified parametric position.

Definition at line 69 of file ElemEvaluator.hpp.

Referenced by operator=(), and moab::ElemEvaluator::reverse_eval().

◆ normalFcn

NormalFcn moab::EvalSet::normalFcn

Evaluate the normal at a local facet (edge/face for 2D/3D)

Definition at line 66 of file ElemEvaluator.hpp.

Referenced by operator=().

◆ reverseEvalFcn

ReverseEvalFcn moab::EvalSet::reverseEvalFcn

Reverse-evaluation of parametric coordinates at physical space position.

Definition at line 63 of file ElemEvaluator.hpp.

Referenced by operator=().


The documentation for this class was generated from the following files: