Mesh Oriented datABase  (version 5.5.0)
An array-based unstructured mesh library
moab::Element::Map Class Referenceabstract

Class representing a map (diffeomorphism) F parameterizing a 3D element by its canonical preimage. More...

#include <ElemUtil.hpp>

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

Classes

class  ArgError
 
class  EvaluationError
 

Public Member Functions

 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 evaluate (const CartVect &xi) const =0
 Evaluate the map on \(x_i\) (calculate \(\vec x = F($\vec \xi)\) ) More...
 
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 bool inside_nat_space (const CartVect &xi, double &tol) const =0
 decide if within the natural param space, with a tolerance More...
 
virtual Matrix3 jacobian (const CartVect &xi) const =0
 Evaluate the map's Jacobi matrix. 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...
 
virtual double evaluate_scalar_field (const CartVect &xi, const double *field_vertex_values) const =0
 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 =0
 Integrate a scalar field over the element given field values at the vertices. 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
 

Protected Attributes

std::vector< CartVectvertex
 

Detailed Description

Class representing a map (diffeomorphism) F parameterizing a 3D element by its canonical preimage.

Definition at line 51 of file ElemUtil.hpp.

Constructor & Destructor Documentation

◆ Map() [1/2]

moab::Element::Map::Map ( const std::vector< CartVect > &  v)
inline

Construct a Map defined by the given std::vector of vertices.

Definition at line 55 of file ElemUtil.hpp.

56  {
57  this->vertex.resize( v.size() );
58  this->set_vertices( v );
59  };

References set_vertices().

◆ Map() [2/2]

moab::Element::Map::Map ( const unsigned int  n)
inline

Construct a Map defined by n vertices.

Definition at line 61 of file ElemUtil.hpp.

62  {
63  this->vertex = std::vector< CartVect >( n );
64  };

◆ ~Map()

moab::Element::Map::~Map ( )
virtual

Definition at line 396 of file ElemUtil.cpp.

396 {}

Member Function Documentation

◆ det_ijacobian()

virtual double moab::Element::Map::det_ijacobian ( const CartVect xi) const
inlinevirtual

Evaluate the determinate of the inverse Jacobi matrix.

Reimplemented in moab::Element::LinearTri, and moab::Element::LinearTet.

Definition at line 92 of file ElemUtil.hpp.

93  {
94  return this->jacobian( xi ).inverse().determinant();
95  };

References moab::Matrix3::determinant(), moab::Matrix3::inverse(), and jacobian().

◆ det_jacobian()

virtual double moab::Element::Map::det_jacobian ( const CartVect xi) const
inlinevirtual

Evaluate the determinate of the Jacobi matrix.

Reimplemented in moab::Element::LinearTri, and moab::Element::LinearTet.

Definition at line 85 of file ElemUtil.hpp.

86  {
87  return this->jacobian( xi ).determinant();
88  };

References moab::Matrix3::determinant(), and jacobian().

Referenced by moab::Element::LinearHex::integrate_scalar_field(), moab::Element::LinearQuad::integrate_scalar_field(), and moab::Element::LinearEdge::integrate_scalar_field().

◆ evaluate()

virtual CartVect moab::Element::Map::evaluate ( const CartVect xi) const
pure virtual

◆ evaluate_scalar_field()

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

◆ get_vertices()

const std::vector< CartVect > & moab::Element::Map::get_vertices ( )
inline

Retrieve vertices.

Definition at line 398 of file ElemUtil.cpp.

399  {
400  return this->vertex;
401  }

References vertex.

◆ ievaluate()

CartVect moab::Element::Map::ievaluate ( const CartVect x,
double  tol = 1e-6,
const CartVect x0 = CartVect( 0.0 ) 
) const
virtual

Evaluate the inverse map (calculate \(\vec \xi = F^-1($\vec x)\) to given tolerance)

Reimplemented in moab::Element::SpectralQuad, moab::Element::SphericalTri, moab::Element::LinearTri, moab::Element::SphericalQuad, moab::Element::SpectralHex, and moab::Element::LinearTet.

Definition at line 421 of file ElemUtil.cpp.

422  {
423  // TODO: should differentiate between epsilons used for
424  // Newton Raphson iteration, and epsilons used for curved boundary geometry errors
425  // right now, fix the tolerance used for NR
426  tol = 1.0e-10;
427  const double error_tol_sqr = tol * tol;
428  double det;
429  CartVect xi = x0;
430  CartVect delta = evaluate( xi ) - x;
431  Matrix3 J;
432 
433  int iters = 0;
434  while( delta % delta > error_tol_sqr )
435  {
436  if( ++iters > 10 ) throw Map::EvaluationError( x, vertex );
437 
438  J = jacobian( xi );
439  det = J.determinant();
440  if( det < std::numeric_limits< double >::epsilon() ) throw Map::EvaluationError( x, vertex );
441  xi -= J.inverse() * delta;
442  delta = evaluate( xi ) - x;
443  }
444  return xi;
445  } // Map::ievaluate()

References moab::Matrix3::determinant(), evaluate(), moab::Matrix3::inverse(), and jacobian().

Referenced by moab::Element::SphericalQuad::ievaluate(), moab::Coupler::nat_param(), test_hex(), and test_hex_nat_coords().

◆ ijacobian()

virtual Matrix3 moab::Element::Map::ijacobian ( const CartVect xi) const
inlinevirtual

Evaluate the inverse of the Jacobi matrix.

Reimplemented in moab::Element::LinearTri, and moab::Element::LinearTet.

Definition at line 79 of file ElemUtil.hpp.

80  {
81  return this->jacobian( xi ).inverse();
82  };

References moab::Matrix3::inverse(), and jacobian().

◆ inside_box()

bool moab::Element::Map::inside_box ( const CartVect xi,
double &  tol 
) const
virtual

Reimplemented in moab::Element::SphericalTri, and moab::Element::SphericalQuad.

Definition at line 412 of file ElemUtil.cpp.

413  {
414  // bail out early, before doing an expensive NR iteration
415  // compute box
416  BoundBox box( this->vertex );
417  return box.contains_point( xi.array(), tol );
418  }

References moab::CartVect::array(), and moab::BoundBox::contains_point().

Referenced by moab::Element::SphericalQuad::inside_box(), moab::Element::SphericalTri::inside_box(), moab::Coupler::nat_param(), test_hex(), and test_linear_tri().

◆ inside_nat_space()

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

◆ integrate_scalar_field()

virtual double moab::Element::Map::integrate_scalar_field ( const double *  field_vertex_values) const
pure virtual

◆ jacobian()

◆ set_vertices()

void moab::Element::Map::set_vertices ( const std::vector< CartVect > &  v)
virtual

Set vertices.

Reimplemented in moab::Element::LinearTri, and moab::Element::LinearTet.

Definition at line 403 of file ElemUtil.cpp.

404  {
405  if( v.size() != this->vertex.size() )
406  {
407  throw ArgError();
408  }
409  this->vertex = v;
410  }

Referenced by Map(), moab::Element::LinearTet::set_vertices(), moab::Element::LinearTri::set_vertices(), and test_spectral_quad().

◆ size()

unsigned int moab::Element::Map::size ( )
inline

Size of the vertices vector.

Definition at line 103 of file ElemUtil.hpp.

104  {
105  return this->vertex.size();
106  }

Referenced by moab::Element::SpectralQuad::get_gl_points().

Member Data Documentation

◆ vertex

std::vector< CartVect > moab::Element::Map::vertex
protected

Definition at line 141 of file ElemUtil.hpp.

Referenced by get_vertices().


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