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

#include <LinearQuad.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[])
 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 [4][2] = { { -1, -1 }, { 1, -1 }, { 1, 1 }, { -1, 1 } }
 
static const double gauss [1][2] = { { 2.0, 0.0 } }
 
static const unsigned int corner_count = 4
 
static const unsigned int gauss_count = 1
 

Detailed Description

Definition at line 12 of file LinearQuad.hpp.

Member Function Documentation

◆ compatible()

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

Definition at line 70 of file LinearQuad.hpp.

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

References eval_set(), and MBQUAD.

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

◆ eval_set()

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

Definition at line 65 of file LinearQuad.hpp.

66  {
68  }

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

Referenced by compatible().

◆ evalFcn()

ErrorCode moab::LinearQuad::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 43 of file LinearQuad.cpp.

49 {
50  for( int i = 0; i < num_tuples; i++ )
51  result[i] = 0.0;
52  for( unsigned i = 0; i < 4; ++i )
53  {
54  const double N_i = ( 1 + params[0] * corner[i][0] ) * ( 1 + params[1] * corner[i][1] );
55  for( int j = 0; j < num_tuples; j++ )
56  result[j] += N_i * field[i * num_tuples + j];
57  }
58  for( int i = 0; i < num_tuples; i++ )
59  result[i] *= 0.25;
60 
61  return MB_SUCCESS;
62 }

References corner, and MB_SUCCESS.

Referenced by eval_set(), and integrateFcn().

◆ insideFcn()

int moab::LinearQuad::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 115 of file LinearQuad.cpp.

116 {
117  return EvalSet::inside_function( params, ndim, tol );
118 }

References moab::EvalSet::inside_function().

Referenced by eval_set().

◆ integrateFcn()

ErrorCode moab::LinearQuad::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 64 of file LinearQuad.cpp.

71 {
72  double tmp_result[4];
73  ErrorCode rval = MB_SUCCESS;
74  for( int i = 0; i < num_tuples; i++ )
75  result[i] = 0.0;
76  CartVect x;
77  Matrix3 J;
78  for( unsigned int j1 = 0; j1 < LinearQuad::gauss_count; ++j1 )
79  {
80  x[0] = LinearQuad::gauss[j1][1];
81  double w1 = LinearQuad::gauss[j1][0];
82  for( unsigned int j2 = 0; j2 < LinearQuad::gauss_count; ++j2 )
83  {
84  x[1] = LinearQuad::gauss[j2][1];
85  double w2 = LinearQuad::gauss[j2][0];
86  rval = evalFcn( x.array(), field, ndim, num_tuples, NULL, tmp_result );
87  if( MB_SUCCESS != rval ) return rval;
88  rval = jacobianFcn( x.array(), verts, nverts, ndim, work, J[0] );
89  if( MB_SUCCESS != rval ) return rval;
90  double tmp_det = w1 * w2 * J.determinant();
91  for( int i = 0; i < num_tuples; i++ )
92  result[i] += tmp_result[i] * tmp_det;
93  }
94  }
95  return MB_SUCCESS;
96 } // 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::LinearQuad::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 18 of file LinearQuad.cpp.

24 {
25  Matrix3* J = reinterpret_cast< Matrix3* >( result );
26  *J = Matrix3( 0.0 );
27  for( unsigned i = 0; i < 4; ++i )
28  {
29  const double xi_p = 1 + params[0] * corner[i][0];
30  const double eta_p = 1 + params[1] * corner[i][1];
31  const double dNi_dxi = corner[i][0] * eta_p;
32  const double dNi_deta = corner[i][1] * xi_p;
33  ( *J )( 0, 0 ) += dNi_dxi * verts[i * 3 + 0];
34  ( *J )( 1, 0 ) += dNi_dxi * verts[i * 3 + 1];
35  ( *J )( 0, 1 ) += dNi_deta * verts[i * 3 + 0];
36  ( *J )( 1, 1 ) += dNi_deta * verts[i * 3 + 1];
37  }
38  ( *J ) *= 0.25;
39  ( *J )( 2, 2 ) = 1.0; /* to make sure the Jacobian determinant is non-zero */
40  return MB_SUCCESS;
41 } // LinearQuad::jacobian()

References corner, and MB_SUCCESS.

Referenced by eval_set(), and integrateFcn().

◆ normalFcn()

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

Evaluate the normal at a specified facet.

Definition at line 120 of file LinearQuad.cpp.

125 {
126  // assert(facet <4 && ientDim == 1 && nverts==4);
127  if( nverts != 4 ) MB_SET_ERR( MB_FAILURE, "Incorrect vertex count for passed quad :: expected value = 4" );
128  if( ientDim != 1 ) MB_SET_ERR( MB_FAILURE, "Requesting normal for unsupported dimension :: expected value = 1 " );
129  if( facet > 4 || facet < 0 ) MB_SET_ERR( MB_FAILURE, "Incorrect local edge id :: expected value = one of 0-3" );
130 
131  // Get the local vertex ids of local edge
132  int id0 = CN::mConnectivityMap[MBQUAD][ientDim - 1].conn[facet][0];
133  int id1 = CN::mConnectivityMap[MBQUAD][ientDim - 1].conn[facet][1];
134 
135  // Find a vector along the edge
136  double edge[3];
137  for( int i = 0; i < 3; i++ )
138  {
139  edge[i] = verts[3 * id1 + i] - verts[3 * id0 + i];
140  }
141  // Find the normal of the face
142  double x0[3], x1[3], fnrm[3];
143  for( int i = 0; i < 3; i++ )
144  {
145  x0[i] = verts[3 * 1 + i] - verts[3 * 0 + i];
146  x1[i] = verts[3 * 3 + i] - verts[3 * 0 + i];
147  }
148  fnrm[0] = x0[1] * x1[2] - x1[1] * x0[2];
149  fnrm[1] = x1[0] * x0[2] - x0[0] * x1[2];
150  fnrm[2] = x0[0] * x1[1] - x1[0] * x0[1];
151 
152  // Find the normal of the edge as the cross product of edge and face normal
153 
154  double a = edge[1] * fnrm[2] - fnrm[1] * edge[2];
155  double b = edge[2] * fnrm[0] - fnrm[2] * edge[0];
156  double c = edge[0] * fnrm[1] - fnrm[0] * edge[1];
157  double nrm = sqrt( a * a + b * b + c * c );
158 
159  if( nrm > std::numeric_limits< double >::epsilon() )
160  {
161  normal[0] = a / nrm;
162  normal[1] = b / nrm;
163  normal[2] = c / nrm;
164  }
165  return MB_SUCCESS;
166 }

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

Referenced by eval_set().

◆ reverseEvalFcn()

ErrorCode moab::LinearQuad::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 98 of file LinearQuad.cpp.

110 {
111  return EvalSet::evaluate_reverse( eval, jacob, ins, posn, verts, nverts, ndim, iter_tol, inside_tol, work, params,
112  is_inside );
113 }

References moab::EvalSet::evaluate_reverse().

Referenced by eval_set().

Member Data Documentation

◆ corner

const double moab::LinearQuad::corner = { { -1, -1 }, { 1, -1 }, { 1, 1 }, { -1, 1 } }
staticprotected

Definition at line 83 of file LinearQuad.hpp.

Referenced by evalFcn(), and jacobianFcn().

◆ corner_count

const unsigned int moab::LinearQuad::corner_count = 4
staticprotected

Definition at line 85 of file LinearQuad.hpp.

◆ gauss

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

Definition at line 84 of file LinearQuad.hpp.

Referenced by integrateFcn().

◆ gauss_count

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

Definition at line 86 of file LinearQuad.hpp.

Referenced by integrateFcn().


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