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

Shape function space for trilinear hexahedron, obtained by a pushforward of the canonical linear (affine) functions. More...

#include <ElemUtil.hpp>

+ Inheritance diagram for moab::Element::LinearHex:
+ Collaboration diagram for moab::Element::LinearHex:

Public Member Functions

 LinearHex (const std::vector< CartVect > &vertices)
 
 LinearHex ()
 
virtual ~LinearHex ()
 
virtual CartVect evaluate (const CartVect &xi) const
 Evaluate the map on \(x_i\) (calculate \(\vec x = F($\vec \xi)\) ) More...
 
virtual bool inside_nat_space (const CartVect &xi, double &tol) const
 decide if within the natural param space, with a tolerance More...
 
virtual Matrix3 jacobian (const CartVect &xi) const
 Evaluate the map's Jacobi matrix. More...
 
virtual double evaluate_scalar_field (const CartVect &xi, const double *field_vertex_values) const
 Evaluate a scalar field at a point given field values at the vertices. More...
 
virtual double integrate_scalar_field (const double *field_vertex_values) const
 Integrate a scalar field over the element given field values at the vertices. More...
 
- Public Member Functions inherited from moab::Element::Map
 Map (const std::vector< CartVect > &v)
 Construct a Map defined by the given std::vector of vertices. More...
 
 Map (const unsigned int n)
 Construct a Map defined by n vertices. More...
 
virtual ~Map ()
 
virtual CartVect ievaluate (const CartVect &x, double tol=1e-6, const CartVect &x0=CartVect(0.0)) const
 Evaluate the inverse map (calculate \(\vec \xi = F^-1($\vec x)\) to given tolerance) More...
 
virtual Matrix3 ijacobian (const CartVect &xi) const
 Evaluate the inverse of the Jacobi matrix. More...
 
virtual double det_jacobian (const CartVect &xi) const
 Evaluate the determinate of the Jacobi matrix. More...
 
virtual double det_ijacobian (const CartVect &xi) const
 Evaluate the determinate of the inverse Jacobi matrix. More...
 
unsigned int size ()
 Size of the vertices vector. More...
 
const std::vector< CartVect > & get_vertices ()
 Retrieve vertices. More...
 
virtual void set_vertices (const std::vector< CartVect > &v)
 Set vertices.
More...
 
virtual bool inside_box (const CartVect &xi, double &tol) const
 

Static Protected Attributes

static const double corner [8][3]
 
static const double gauss [2][2] = { { 1.0, -0.5773502691 }, { 1.0, 0.5773502691 } }
 
static const unsigned int corner_count = 8
 
static const unsigned int gauss_count = 2
 

Additional Inherited Members

- Protected Attributes inherited from moab::Element::Map
std::vector< CartVectvertex
 

Detailed Description

Shape function space for trilinear hexahedron, obtained by a pushforward of the canonical linear (affine) functions.

Definition at line 146 of file ElemUtil.hpp.

Constructor & Destructor Documentation

◆ LinearHex() [1/2]

moab::Element::LinearHex::LinearHex ( const std::vector< CartVect > &  vertices)
inline

Definition at line 149 of file ElemUtil.hpp.

149 : Map( vertices ){};

◆ LinearHex() [2/2]

moab::Element::LinearHex::LinearHex ( )

Definition at line 685 of file ElemUtil.cpp.

685 : Map( 0 ) {} // LinearHex::LinearHex()

◆ ~LinearHex()

moab::Element::LinearHex::~LinearHex ( )
virtual

Definition at line 687 of file ElemUtil.cpp.

687 {}

Member Function Documentation

◆ evaluate()

CartVect moab::Element::LinearHex::evaluate ( const CartVect xi) const
virtual

Evaluate the map on \(x_i\) (calculate \(\vec x = F($\vec \xi)\) )

Implements moab::Element::Map.

Definition at line 699 of file ElemUtil.cpp.

700  {
701  CartVect x( 0.0 );
702  for( unsigned i = 0; i < 8; ++i )
703  {
704  const double N_i =
705  ( 1 + xi[0] * corner[i][0] ) * ( 1 + xi[1] * corner[i][1] ) * ( 1 + xi[2] * corner[i][2] );
706  x += N_i * this->vertex[i];
707  }
708  x *= 0.125;
709  return x;
710  } // LinearHex::evaluate

References corner.

◆ evaluate_scalar_field()

double moab::Element::LinearHex::evaluate_scalar_field ( const CartVect xi,
const double *  field_vertex_values 
) const
virtual

Evaluate a scalar field at a point given field values at the vertices.

Implements moab::Element::Map.

Definition at line 736 of file ElemUtil.cpp.

737  {
738  double f( 0.0 );
739  for( unsigned i = 0; i < 8; ++i )
740  {
741  const double N_i =
742  ( 1 + xi[0] * corner[i][0] ) * ( 1 + xi[1] * corner[i][1] ) * ( 1 + xi[2] * corner[i][2] );
743  f += N_i * field_vertex_value[i];
744  }
745  f *= 0.125;
746  return f;
747  } // LinearHex::evaluate_scalar_field()

References corner.

Referenced by integrate_scalar_field().

◆ inside_nat_space()

bool moab::Element::LinearHex::inside_nat_space ( const CartVect xi,
double &  tol 
) const
virtual

decide if within the natural param space, with a tolerance

Implements moab::Element::Map.

Definition at line 772 of file ElemUtil.cpp.

773  {
774  // just look at the box+tol here
775  return ( xi[0] >= -1. - tol ) && ( xi[0] <= 1. + tol ) && ( xi[1] >= -1. - tol ) && ( xi[1] <= 1. + tol ) &&
776  ( xi[2] >= -1. - tol ) && ( xi[2] <= 1. + tol );
777  }

Referenced by moab::Coupler::nat_param(), and test_hex_nat_coords().

◆ integrate_scalar_field()

double moab::Element::LinearHex::integrate_scalar_field ( const double *  field_vertex_values) const
virtual

Integrate a scalar field over the element given field values at the vertices.

Implements moab::Element::Map.

Definition at line 749 of file ElemUtil.cpp.

750  {
751  double I( 0.0 );
752  for( unsigned int j1 = 0; j1 < this->gauss_count; ++j1 )
753  {
754  double x1 = this->gauss[j1][1];
755  double w1 = this->gauss[j1][0];
756  for( unsigned int j2 = 0; j2 < this->gauss_count; ++j2 )
757  {
758  double x2 = this->gauss[j2][1];
759  double w2 = this->gauss[j2][0];
760  for( unsigned int j3 = 0; j3 < this->gauss_count; ++j3 )
761  {
762  double x3 = this->gauss[j3][1];
763  double w3 = this->gauss[j3][0];
764  CartVect x( x1, x2, x3 );
765  I += this->evaluate_scalar_field( x, field_vertex_values ) * w1 * w2 * w3 * this->det_jacobian( x );
766  }
767  }
768  }
769  return I;
770  } // LinearHex::integrate_scalar_field()

References moab::Element::Map::det_jacobian(), evaluate_scalar_field(), gauss, and gauss_count.

Referenced by integrate_scalar_field_test().

◆ jacobian()

Matrix3 moab::Element::LinearHex::jacobian ( const CartVect xi) const
virtual

Evaluate the map's Jacobi matrix.

Implements moab::Element::Map.

Definition at line 712 of file ElemUtil.cpp.

713  {
714  Matrix3 J( 0.0 );
715  for( unsigned i = 0; i < 8; ++i )
716  {
717  const double xi_p = 1 + xi[0] * corner[i][0];
718  const double eta_p = 1 + xi[1] * corner[i][1];
719  const double zeta_p = 1 + xi[2] * corner[i][2];
720  const double dNi_dxi = corner[i][0] * eta_p * zeta_p;
721  const double dNi_deta = corner[i][1] * xi_p * zeta_p;
722  const double dNi_dzeta = corner[i][2] * xi_p * eta_p;
723  J( 0, 0 ) += dNi_dxi * vertex[i][0];
724  J( 1, 0 ) += dNi_dxi * vertex[i][1];
725  J( 2, 0 ) += dNi_dxi * vertex[i][2];
726  J( 0, 1 ) += dNi_deta * vertex[i][0];
727  J( 1, 1 ) += dNi_deta * vertex[i][1];
728  J( 2, 1 ) += dNi_deta * vertex[i][2];
729  J( 0, 2 ) += dNi_dzeta * vertex[i][0];
730  J( 1, 2 ) += dNi_dzeta * vertex[i][1];
731  J( 2, 2 ) += dNi_dzeta * vertex[i][2];
732  }
733  return J *= 0.125;
734  } // LinearHex::jacobian()

References corner.

Member Data Documentation

◆ corner

const double moab::Element::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 163 of file ElemUtil.hpp.

Referenced by evaluate(), evaluate_scalar_field(), and jacobian().

◆ corner_count

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

Definition at line 165 of file ElemUtil.hpp.

◆ gauss

const double moab::Element::LinearHex::gauss = { { 1.0, -0.5773502691 }, { 1.0, 0.5773502691 } }
staticprotected

Definition at line 164 of file ElemUtil.hpp.

Referenced by integrate_scalar_field().

◆ gauss_count

const unsigned int moab::Element::LinearHex::gauss_count = 2
staticprotected

Definition at line 166 of file ElemUtil.hpp.

Referenced by integrate_scalar_field().


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