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

#include <LinearHex.hpp>

Static Public Member Functions

static ErrorCode evalFcn (const double *params, const double *field, const int ndim, const int num_tuples, double *work, double *result)
 Forward-evaluation of field at parametric coordinates. More...
 
static ErrorCode reverseEvalFcn (EvalFcn eval, JacobianFcn jacob, InsideFcn ins, 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 *is_inside)
 Reverse-evaluation of parametric coordinates at physical space position. More...
 
static ErrorCode normalFcn (const int ientDim, const int facet, const int nverts, const double *verts, double normal[3])
 Evaluate the normal at a specified facet. More...
 
static ErrorCode jacobianFcn (const double *params, const double *verts, const int nverts, const int ndim, double *work, double *result)
 Evaluate the jacobian at a specified parametric position. More...
 
static ErrorCode integrateFcn (const double *field, const double *verts, const int nverts, const int ndim, const int num_tuples, double *work, double *result)
 Forward-evaluation of field at parametric coordinates. More...
 
static int insideFcn (const double *params, const int ndim, const double tol)
 Function that returns whether or not the parameters are inside the natural space of the element. More...
 
static EvalSet eval_set ()
 
static bool compatible (EntityType tp, int numv, EvalSet &eset)
 

Static Protected Attributes

static const double corner [8][3]
 
static const double gauss [1][2] = { { 2.0, 0.0 } }
 
static const unsigned int corner_count = 8
 
static const unsigned int gauss_count = 1
 

Detailed Description

Definition at line 12 of file LinearHex.hpp.

Member Function Documentation

◆ compatible()

static bool moab::LinearHex::compatible ( EntityType  tp,
int  numv,
EvalSet eset 
)
inlinestatic

Definition at line 70 of file LinearHex.hpp.

71  {
72  if( tp == MBHEX && numv == 8 )
73  {
74  eset = eval_set();
75  return true;
76  }
77  else
78  return false;
79  }

References eval_set(), and MBHEX.

Referenced by moab::EvalSet::get_eval_set().

◆ eval_set()

static EvalSet moab::LinearHex::eval_set ( )
inlinestatic

Definition at line 65 of file LinearHex.hpp.

66  {
68  }

References evalFcn(), insideFcn(), integrateFcn(), jacobianFcn(), normalFcn(), and reverseEvalFcn().

Referenced by compatible().

◆ evalFcn()

ErrorCode moab::LinearHex::evalFcn ( const double *  params,
const double *  field,
const int  ndim,
const int  num_tuples,
double *  work,
double *  result 
)
static

Forward-evaluation of field at parametric coordinates.

Definition at line 51 of file LinearHex.cpp.

57 {
58  assert( params && field && num_tuples != -1 );
59  for( int i = 0; i < num_tuples; i++ )
60  result[i] = 0.0;
61  for( unsigned i = 0; i < 8; ++i )
62  {
63  const double N_i =
64  ( 1 + params[0] * corner[i][0] ) * ( 1 + params[1] * corner[i][1] ) * ( 1 + params[2] * corner[i][2] );
65  for( int j = 0; j < num_tuples; j++ )
66  result[j] += N_i * field[i * num_tuples + j];
67  }
68  for( int i = 0; i < num_tuples; i++ )
69  result[i] *= 0.125;
70 
71  return MB_SUCCESS;
72 }

References corner, and MB_SUCCESS.

Referenced by eval_set(), and integrateFcn().

◆ insideFcn()

int moab::LinearHex::insideFcn ( const double *  params,
const int  ndim,
const double  tol 
)
static

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

Definition at line 133 of file LinearHex.cpp.

134 {
135  return EvalSet::inside_function( params, ndim, tol );
136 }

References moab::EvalSet::inside_function().

Referenced by eval_set().

◆ integrateFcn()

ErrorCode moab::LinearHex::integrateFcn ( const double *  field,
const double *  verts,
const int  nverts,
const int  ndim,
const int  num_tuples,
double *  work,
double *  result 
)
static

Forward-evaluation of field at parametric coordinates.

Definition at line 74 of file LinearHex.cpp.

81 {
82  assert( field && verts && num_tuples != -1 );
83  double tmp_result[8];
84  ErrorCode rval = MB_SUCCESS;
85  for( int i = 0; i < num_tuples; i++ )
86  result[i] = 0.0;
87  CartVect x;
88  Matrix3 J;
89  for( unsigned int j1 = 0; j1 < LinearHex::gauss_count; ++j1 )
90  {
91  x[0] = LinearHex::gauss[j1][1];
92  double w1 = LinearHex::gauss[j1][0];
93  for( unsigned int j2 = 0; j2 < LinearHex::gauss_count; ++j2 )
94  {
95  x[1] = LinearHex::gauss[j2][1];
96  double w2 = LinearHex::gauss[j2][0];
97  for( unsigned int j3 = 0; j3 < LinearHex::gauss_count; ++j3 )
98  {
99  x[2] = LinearHex::gauss[j3][1];
100  double w3 = LinearHex::gauss[j3][0];
101  rval = evalFcn( x.array(), field, ndim, num_tuples, NULL, tmp_result );
102  if( MB_SUCCESS != rval ) return rval;
103  rval = jacobianFcn( x.array(), verts, nverts, ndim, work, J[0] );
104  if( MB_SUCCESS != rval ) return rval;
105  double tmp_det = w1 * w2 * w3 * J.determinant();
106  for( int i = 0; i < num_tuples; i++ )
107  result[i] += tmp_result[i] * tmp_det;
108  }
109  }
110  }
111 
112  return MB_SUCCESS;
113 } // LinearHex::integrate_vector()

References moab::CartVect::array(), moab::Matrix3::determinant(), ErrorCode, evalFcn(), gauss, gauss_count, jacobianFcn(), and MB_SUCCESS.

Referenced by eval_set().

◆ jacobianFcn()

ErrorCode moab::LinearHex::jacobianFcn ( const double *  params,
const double *  verts,
const int  nverts,
const int  ndim,
double *  work,
double *  result 
)
static

Evaluate the jacobian at a specified parametric position.

Definition at line 19 of file LinearHex.cpp.

25 {
26  assert( params && verts );
27  Matrix3* J = reinterpret_cast< Matrix3* >( result );
28  *J = Matrix3( 0.0 );
29  for( unsigned i = 0; i < 8; ++i )
30  {
31  const double params_p = 1 + params[0] * corner[i][0];
32  const double eta_p = 1 + params[1] * corner[i][1];
33  const double zeta_p = 1 + params[2] * corner[i][2];
34  const double dNi_dparams = corner[i][0] * eta_p * zeta_p;
35  const double dNi_deta = corner[i][1] * params_p * zeta_p;
36  const double dNi_dzeta = corner[i][2] * params_p * eta_p;
37  ( *J )( 0, 0 ) += dNi_dparams * verts[i * ndim + 0];
38  ( *J )( 1, 0 ) += dNi_dparams * verts[i * ndim + 1];
39  ( *J )( 2, 0 ) += dNi_dparams * verts[i * ndim + 2];
40  ( *J )( 0, 1 ) += dNi_deta * verts[i * ndim + 0];
41  ( *J )( 1, 1 ) += dNi_deta * verts[i * ndim + 1];
42  ( *J )( 2, 1 ) += dNi_deta * verts[i * ndim + 2];
43  ( *J )( 0, 2 ) += dNi_dzeta * verts[i * ndim + 0];
44  ( *J )( 1, 2 ) += dNi_dzeta * verts[i * ndim + 1];
45  ( *J )( 2, 2 ) += dNi_dzeta * verts[i * ndim + 2];
46  }
47  ( *J ) *= 0.125;
48  return MB_SUCCESS;
49 } // LinearHex::jacobian()

References corner, and MB_SUCCESS.

Referenced by eval_set(), and integrateFcn().

◆ normalFcn()

ErrorCode moab::LinearHex::normalFcn ( const int  ientDim,
const int  facet,
const int  nverts,
const double *  verts,
double  normal[3] 
)
static

Evaluate the normal at a specified facet.

Definition at line 138 of file LinearHex.cpp.

143 {
144  // assert(facet < 6 && ientDim == 2 && nverts == 8);
145  if( nverts != 8 ) MB_SET_ERR( MB_FAILURE, "Incorrect vertex count for passed hex :: expected value = 8 " );
146  if( ientDim != 2 ) MB_SET_ERR( MB_FAILURE, "Requesting normal for unsupported dimension :: expected value = 2 " );
147  if( facet > 6 || facet < 0 ) MB_SET_ERR( MB_FAILURE, "Incorrect local face id :: expected value = one of 0-5" );
148 
149  int id0 = CN::mConnectivityMap[MBHEX][ientDim - 1].conn[facet][0];
150  int id1 = CN::mConnectivityMap[MBHEX][ientDim - 1].conn[facet][1];
151  int id2 = CN::mConnectivityMap[MBHEX][ientDim - 1].conn[facet][3];
152 
153  double x0[3], x1[3];
154 
155  for( int i = 0; i < 3; i++ )
156  {
157  x0[i] = verts[3 * id1 + i] - verts[3 * id0 + i];
158  x1[i] = verts[3 * id2 + i] - verts[3 * id0 + i];
159  }
160 
161  double a = x0[1] * x1[2] - x1[1] * x0[2];
162  double b = x1[0] * x0[2] - x0[0] * x1[2];
163  double c = x0[0] * x1[1] - x1[0] * x0[1];
164  double nrm = sqrt( a * a + b * b + c * c );
165 
166  if( nrm > std::numeric_limits< double >::epsilon() )
167  {
168  normal[0] = a / nrm;
169  normal[1] = b / nrm;
170  normal[2] = c / nrm;
171  }
172  return MB_SUCCESS;
173 }

References moab::CN::ConnMap::conn, MB_SET_ERR, MB_SUCCESS, MBHEX, and moab::CN::mConnectivityMap.

Referenced by eval_set().

◆ reverseEvalFcn()

ErrorCode moab::LinearHex::reverseEvalFcn ( EvalFcn  eval,
JacobianFcn  jacob,
InsideFcn  ins,
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 *  is_inside 
)
static

Reverse-evaluation of parametric coordinates at physical space position.

Definition at line 115 of file LinearHex.cpp.

127 {
128  assert( posn && verts );
129  return EvalSet::evaluate_reverse( eval, jacob, ins, posn, verts, nverts, ndim, iter_tol, inside_tol, work, params,
130  is_inside );
131 }

References moab::EvalSet::evaluate_reverse().

Referenced by eval_set().

Member Data Documentation

◆ corner

const double moab::LinearHex::corner
staticprotected
Initial value:
= { { -1, -1, -1 }, { 1, -1, -1 }, { 1, 1, -1 }, { -1, 1, -1 },
{ -1, -1, 1 }, { 1, -1, 1 }, { 1, 1, 1 }, { -1, 1, 1 } }

Definition at line 83 of file LinearHex.hpp.

Referenced by evalFcn(), and jacobianFcn().

◆ corner_count

const unsigned int moab::LinearHex::corner_count = 8
staticprotected

Definition at line 85 of file LinearHex.hpp.

◆ gauss

const double moab::LinearHex::gauss = { { 2.0, 0.0 } }
staticprotected

Definition at line 84 of file LinearHex.hpp.

Referenced by integrateFcn().

◆ gauss_count

const unsigned int moab::LinearHex::gauss_count = 1
staticprotected

Definition at line 86 of file LinearHex.hpp.

Referenced by integrateFcn().


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