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

#include <linear_hex_map.hpp>

+ Inheritance diagram for moab::element_utility::Linear_hex_map:

Public Member Functions

 Linear_hex_map ()
 
 Linear_hex_map (const Linear_hex_map &)
 
template<typename Moab , typename Entity_handle , typename Points , typename Point >
std::pair< bool, CartVectevaluate_reverse (const double *verts, const double *eval_point, const double tol=1.e-6) const
 

Private Member Functions

const CartVectreference_points (const std::size_t &i) const
 
bool is_contained (const CartVect &params, const double tol) const
 
bool solve_inverse (const CartVect &point, CartVect &params, const CartVect *verts, const double tol=1.e-6) const
 
void evaluate_forward (const CartVect &p, const CartVect *verts, CartVect &f) const
 
double integrate_scalar_field (const CartVect *points, const double *field_values) const
 
template<typename Point , typename Points >
Matrix3jacobian (const Point &p, const Points &points, Matrix3 &J) const
 

Detailed Description

Definition at line 16 of file linear_hex_map.hpp.

Constructor & Destructor Documentation

◆ Linear_hex_map() [1/2]

moab::element_utility::Linear_hex_map::Linear_hex_map ( )
inline

Definition at line 20 of file linear_hex_map.hpp.

20 {}

◆ Linear_hex_map() [2/2]

moab::element_utility::Linear_hex_map::Linear_hex_map ( const Linear_hex_map )
inline

Definition at line 22 of file linear_hex_map.hpp.

22 {}

Member Function Documentation

◆ evaluate_forward()

void moab::element_utility::Linear_hex_map::evaluate_forward ( const CartVect p,
const CartVect verts,
CartVect f 
) const
inlineprivate

Definition at line 107 of file linear_hex_map.hpp.

108  {
109  typedef typename Points::value_type Vector;
110  f.set( 0.0, 0.0, 0.0 );
111  for( unsigned i = 0; i < 8; ++i )
112  {
113  const double N_i = ( 1 + p[0] * reference_points( i )[0] ) * ( 1 + p[1] * reference_points( i )[1] ) *
114  ( 1 + p[2] * reference_points( i )[2] );
115  f += N_i * verts[i];
116  }
117  f *= 0.125;
118  return f;
119  }

References reference_points().

Referenced by solve_inverse().

◆ evaluate_reverse()

template<typename Moab , typename Entity_handle , typename Points , typename Point >
std::pair< bool, CartVect > moab::element_utility::Linear_hex_map::evaluate_reverse ( const double *  verts,
const double *  eval_point,
const double  tol = 1.e-6 
) const
inline

Definition at line 27 of file linear_hex_map.hpp.

30  {
31  CartVect params( 3, 0.0 );
32  solve_inverse( eval_point, params, verts );
33  bool point_found = solve_inverse( eval_point, params, verts, tol ) && is_contained( params, tol );
34  return std::make_pair( point_found, params );
35  }

References is_contained(), and solve_inverse().

◆ integrate_scalar_field()

double moab::element_utility::Linear_hex_map::integrate_scalar_field ( const CartVect points,
const double *  field_values 
) const
inlineprivate

Definition at line 121 of file linear_hex_map.hpp.

121 {}

◆ is_contained()

bool moab::element_utility::Linear_hex_map::is_contained ( const CartVect params,
const double  tol 
) const
inlineprivate

Definition at line 49 of file linear_hex_map.hpp.

50  {
51  // just look at the box+tol here
52  return ( params[0] >= -1. - tol ) && ( params[0] <= 1. + tol ) && ( params[1] >= -1. - tol ) &&
53  ( params[1] <= 1. + tol ) && ( params[2] >= -1. - tol ) && ( params[2] <= 1. + tol );
54  }

Referenced by evaluate_reverse().

◆ jacobian()

template<typename Point , typename Points >
Matrix3& moab::element_utility::Linear_hex_map::jacobian ( const Point &  p,
const Points points,
Matrix3 J 
) const
inlineprivate

Definition at line 124 of file linear_hex_map.hpp.

125  {
126  }

Referenced by solve_inverse().

◆ reference_points()

const CartVect& moab::element_utility::Linear_hex_map::reference_points ( const std::size_t &  i) const
inlineprivate

Definition at line 41 of file linear_hex_map.hpp.

42  {
43  const CartVect rpts[8] = { CartVect( -1, -1, -1 ), CartVect( 1, -1, -1 ), CartVect( 1, 1, -1 ),
44  CartVect( -1, 1, -1 ), CartVect( -1, -1, 1 ), CartVect( 1, -1, 1 ),
45  CartVect( 1, 1, 1 ), CartVect( -1, 1, 1 ) };
46  return rpts[i];
47  }

Referenced by evaluate_forward().

◆ solve_inverse()

bool moab::element_utility::Linear_hex_map::solve_inverse ( const CartVect point,
CartVect params,
const CartVect verts,
const double  tol = 1.e-6 
) const
inlineprivate

Definition at line 56 of file linear_hex_map.hpp.

60  {
61  const double error_tol_sqr = tol * tol;
62  CartVect delta( 0.0, 0.0, 0.0 );
63  params = delta;
64  evaluate_forward( params, verts, delta );
65  delta -= point;
66  std::size_t num_iterations = 0;
67 #ifdef LINEAR_HEX_DEBUG
68  std::stringstream ss;
69  ss << "CartVect: ";
70  ss << point[0] << ", " << point[1] << ", " << point[2] << std::endl;
71  ss << "Hex: ";
72  for( int i = 0; i < 8; ++i )
73  ss << points[i][0] << ", " << points[i][1] << ", " << points[i][2] << std::endl;
74  ss << std::endl;
75 #endif
76  while( delta.length_squared() > error_tol_sqr )
77  {
78 #ifdef LINEAR_HEX_DEBUG
79  ss << "Iter #: " << num_iterations << " Err: " << delta.length() << " Iterate: ";
80  ss << params[0] << ", " << params[1] << ", " << params[2] << std::endl;
81 #endif
82  if( ++num_iterations >= 5 )
83  {
84  return false;
85  }
86  Matrix3 J;
87  jacobian( params, verts, J );
88  double det = moab::Matrix3::determinant3( J );
89  if( fabs( det ) < 1.e-10 )
90  {
91 #ifdef LINEAR_HEX_DEBUG
92  std::cerr << ss.str();
93 #endif
94 #ifndef LINEAR_HEX_DEBUG
95  std::cerr << x[0] << ", " << x[1] << ", " << x[2] << std::endl;
96 #endif
97  std::cerr << "inverse solve failure: det: " << det << std::endl;
98  exit( -1 );
99  }
100  params -= moab::Matrix3::inverse( J, 1.0 / det ) * delta;
101  evaluate_forward( params, points, delta );
102  delta -= x;
103  }
104  return true;
105  }

References evaluate_forward(), moab::Matrix3::inverse(), jacobian(), moab::CartVect::length(), and moab::CartVect::length_squared().

Referenced by evaluate_reverse().


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