MOAB: Mesh Oriented datABase  (version 5.4.1)
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.
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.
static ErrorCode normalFcn (const int ientDim, const int facet, const int nverts, const double *verts, double normal[])
 Evaluate the normal at a specified facet.
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.
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.
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.
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

static bool moab::LinearHex::compatible ( EntityType  tp,
int  numv,
EvalSet eset 
) [inline, static]

Definition at line 70 of file LinearHex.hpp.

References eval_set(), and MBHEX.

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

    {
        if( tp == MBHEX && numv == 8 )
        {
            eset = eval_set();
            return true;
        }
        else
            return false;
    }
static EvalSet moab::LinearHex::eval_set ( ) [inline, static]

Definition at line 65 of file LinearHex.hpp.

Referenced by compatible(), test_linear_hex(), and test_normal_linear_hex().

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.

References corner, and MB_SUCCESS.

Referenced by integrateFcn().

{
    assert( params && field && num_tuples != -1 );
    for( int i = 0; i < num_tuples; i++ )
        result[i] = 0.0;
    for( unsigned i = 0; i < 8; ++i )
    {
        const double N_i =
            ( 1 + params[0] * corner[i][0] ) * ( 1 + params[1] * corner[i][1] ) * ( 1 + params[2] * corner[i][2] );
        for( int j = 0; j < num_tuples; j++ )
            result[j] += N_i * field[i * num_tuples + j];
    }
    for( int i = 0; i < num_tuples; i++ )
        result[i] *= 0.125;

    return MB_SUCCESS;
}
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.

References moab::EvalSet::inside_function().

{
    return EvalSet::inside_function( params, ndim, tol );
}
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.

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

{
    assert( field && verts && num_tuples != -1 );
    double tmp_result[8];
    ErrorCode rval = MB_SUCCESS;
    for( int i = 0; i < num_tuples; i++ )
        result[i] = 0.0;
    CartVect x;
    Matrix3 J;
    for( unsigned int j1 = 0; j1 < LinearHex::gauss_count; ++j1 )
    {
        x[0]      = LinearHex::gauss[j1][1];
        double w1 = LinearHex::gauss[j1][0];
        for( unsigned int j2 = 0; j2 < LinearHex::gauss_count; ++j2 )
        {
            x[1]      = LinearHex::gauss[j2][1];
            double w2 = LinearHex::gauss[j2][0];
            for( unsigned int j3 = 0; j3 < LinearHex::gauss_count; ++j3 )
            {
                x[2]      = LinearHex::gauss[j3][1];
                double w3 = LinearHex::gauss[j3][0];
                rval      = evalFcn( x.array(), field, ndim, num_tuples, NULL, tmp_result );
                if( MB_SUCCESS != rval ) return rval;
                rval = jacobianFcn( x.array(), verts, nverts, ndim, work, J[0] );
                if( MB_SUCCESS != rval ) return rval;
                double tmp_det = w1 * w2 * w3 * J.determinant();
                for( int i = 0; i < num_tuples; i++ )
                    result[i] += tmp_result[i] * tmp_det;
            }
        }
    }

    return MB_SUCCESS;
}  // LinearHex::integrate_vector()
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.

References corner, and MB_SUCCESS.

Referenced by integrateFcn().

{
    assert( params && verts );
    Matrix3* J = reinterpret_cast< Matrix3* >( result );
    *J         = Matrix3( 0.0 );
    for( unsigned i = 0; i < 8; ++i )
    {
        const double params_p    = 1 + params[0] * corner[i][0];
        const double eta_p       = 1 + params[1] * corner[i][1];
        const double zeta_p      = 1 + params[2] * corner[i][2];
        const double dNi_dparams = corner[i][0] * eta_p * zeta_p;
        const double dNi_deta    = corner[i][1] * params_p * zeta_p;
        const double dNi_dzeta   = corner[i][2] * params_p * eta_p;
        ( *J )( 0, 0 ) += dNi_dparams * verts[i * ndim + 0];
        ( *J )( 1, 0 ) += dNi_dparams * verts[i * ndim + 1];
        ( *J )( 2, 0 ) += dNi_dparams * verts[i * ndim + 2];
        ( *J )( 0, 1 ) += dNi_deta * verts[i * ndim + 0];
        ( *J )( 1, 1 ) += dNi_deta * verts[i * ndim + 1];
        ( *J )( 2, 1 ) += dNi_deta * verts[i * ndim + 2];
        ( *J )( 0, 2 ) += dNi_dzeta * verts[i * ndim + 0];
        ( *J )( 1, 2 ) += dNi_dzeta * verts[i * ndim + 1];
        ( *J )( 2, 2 ) += dNi_dzeta * verts[i * ndim + 2];
    }
    ( *J ) *= 0.125;
    return MB_SUCCESS;
}  // LinearHex::jacobian()
ErrorCode moab::LinearHex::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 138 of file LinearHex.cpp.

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

{
    // assert(facet < 6 && ientDim == 2 && nverts == 8);
    if( nverts != 8 ) MB_SET_ERR( MB_FAILURE, "Incorrect vertex count for passed hex :: expected value = 8 " );
    if( ientDim != 2 ) MB_SET_ERR( MB_FAILURE, "Requesting normal for unsupported dimension :: expected value = 2 " );
    if( facet > 6 || facet < 0 ) MB_SET_ERR( MB_FAILURE, "Incorrect local face id :: expected value = one of 0-5" );

    int id0 = CN::mConnectivityMap[MBHEX][ientDim - 1].conn[facet][0];
    int id1 = CN::mConnectivityMap[MBHEX][ientDim - 1].conn[facet][1];
    int id2 = CN::mConnectivityMap[MBHEX][ientDim - 1].conn[facet][3];

    double x0[3], x1[3];

    for( int i = 0; i < 3; i++ )
    {
        x0[i] = verts[3 * id1 + i] - verts[3 * id0 + i];
        x1[i] = verts[3 * id2 + i] - verts[3 * id0 + i];
    }

    double a   = x0[1] * x1[2] - x1[1] * x0[2];
    double b   = x1[0] * x0[2] - x0[0] * x1[2];
    double c   = x0[0] * x1[1] - x1[0] * x0[1];
    double nrm = sqrt( a * a + b * b + c * c );

    if( nrm > std::numeric_limits< double >::epsilon() )
    {
        normal[0] = a / nrm;
        normal[1] = b / nrm;
        normal[2] = c / nrm;
    }
    return MB_SUCCESS;
}
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.

References moab::EvalSet::evaluate_reverse().

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

Member Data Documentation

const double moab::LinearHex::corner [static, protected]
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().

const unsigned int moab::LinearHex::corner_count = 8 [static, protected]

Definition at line 85 of file LinearHex.hpp.

const double moab::LinearHex::gauss = { { 2.0, 0.0 } } [static, protected]

Definition at line 84 of file LinearHex.hpp.

Referenced by integrateFcn().

const unsigned int moab::LinearHex::gauss_count = 1 [static, protected]

Definition at line 86 of file LinearHex.hpp.

Referenced by integrateFcn().

List of all members.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines