Mesh Oriented datABase  (version 5.5.1)
An array-based unstructured mesh library
moab::element_utility::Spectral_hex_map< _Matrix > Class Template Reference

#include <spectral_hex_map.hpp>

+ Inheritance diagram for moab::element_utility::Spectral_hex_map< _Matrix >:
+ Collaboration diagram for moab::element_utility::Spectral_hex_map< _Matrix >:

Public Types

typedef _Matrix Matrix
 

Public Member Functions

 Spectral_hex_map ()
 
 Spectral_hex_map (int order)
 
 Spectral_hex_map (const Self &f)
 
template<typename Moab , typename Entity_handle , typename Points , typename Point >
std::pair< bool, Point > operator() (const Moab &, const Entity_handle &, const Points &v, const Point &p, const double tol=1.e-6)
 

Private Types

typedef Spectral_hex_map< MatrixSelf
 

Private Member Functions

void initialize_spectral_hex (int order)
 
void free_data ()
 
void set_gl_points (double *x, double *y, double *z)
 
template<typename Point >
bool is_contained (const Point &p, const double tol) const
 
template<typename Point , typename Points >
bool solve_inverse (const Point &x, Point &xi, const Points &points, const double tol=1.e-6)
 
template<typename Point , typename Points >
Point & evaluate (const Point &p, const Points &, Point &f)
 
template<typename Point , typename Field >
double evaluate_scalar_field (const Point &p, const Field &field) const
 
template<typename Points , typename Field >
double integrate_scalar_field (const Points &p, const Field &field) const
 
template<typename Point , typename Points >
Matrixjacobian (const Point &, const Points &, Matrix &J)
 

Private Attributes

bool _init
 
int _n
 
real_z [3]
 
lagrange_data _ld [3]
 
opt_data_3 _data
 
real_odwork
 
real_xyz [3]
 

Detailed Description

template<typename _Matrix>
class moab::element_utility::Spectral_hex_map< _Matrix >

Definition at line 22 of file spectral_hex_map.hpp.

Member Typedef Documentation

◆ Matrix

template<typename _Matrix >
typedef _Matrix moab::element_utility::Spectral_hex_map< _Matrix >::Matrix

Definition at line 25 of file spectral_hex_map.hpp.

◆ Self

template<typename _Matrix >
typedef Spectral_hex_map< Matrix > moab::element_utility::Spectral_hex_map< _Matrix >::Self
private

Definition at line 28 of file spectral_hex_map.hpp.

Constructor & Destructor Documentation

◆ Spectral_hex_map() [1/3]

template<typename _Matrix >
moab::element_utility::Spectral_hex_map< _Matrix >::Spectral_hex_map ( )
inline

Definition at line 32 of file spectral_hex_map.hpp.

32 {};

◆ Spectral_hex_map() [2/3]

template<typename _Matrix >
moab::element_utility::Spectral_hex_map< _Matrix >::Spectral_hex_map ( int  order)
inline

◆ Spectral_hex_map() [3/3]

template<typename _Matrix >
moab::element_utility::Spectral_hex_map< _Matrix >::Spectral_hex_map ( const Self f)
inline

Definition at line 38 of file spectral_hex_map.hpp.

38 {}

Member Function Documentation

◆ evaluate()

template<typename _Matrix >
template<typename Point , typename Points >
Point& moab::element_utility::Spectral_hex_map< _Matrix >::evaluate ( const Point &  p,
const Points ,
Point &  f 
)
inlineprivate

Definition at line 160 of file spectral_hex_map.hpp.

161  {
162  for( int d = 0; d < 3; ++d )
163  {
164  lagrange_0( &_ld[d], p[0] );
165  }
166  for( int d = 0; d < 3; ++d )
167  {
168  f[d] = tensor_i3( _ld[0].J, _ld[0].n, _ld[1].J, _ld[1].n, _ld[2].J, _ld[2].n, _xyz[d], _odwork );
169  }
170  return f;
171  }

References moab::element_utility::Spectral_hex_map< _Matrix >::_ld, moab::element_utility::Spectral_hex_map< _Matrix >::_odwork, moab::element_utility::Spectral_hex_map< _Matrix >::_xyz, lagrange_0(), and tensor_i3().

Referenced by moab::element_utility::Spectral_hex_map< _Matrix >::solve_inverse().

◆ evaluate_scalar_field()

template<typename _Matrix >
template<typename Point , typename Field >
double moab::element_utility::Spectral_hex_map< _Matrix >::evaluate_scalar_field ( const Point &  p,
const Field &  field 
) const
inlineprivate

Definition at line 174 of file spectral_hex_map.hpp.

175  {
176  int d;
177  for( d = 0; d < 3; d++ )
178  {
179  lagrange_0( &_ld[d], p[d] );
180  }
181  return tensor_i3( _ld[0].J, _ld[0].n, _ld[1].J, _ld[1].n, _ld[2].J, _ld[2].n, field, _odwork );
182  }

References moab::element_utility::Spectral_hex_map< _Matrix >::_ld, moab::element_utility::Spectral_hex_map< _Matrix >::_odwork, lagrange_0(), and tensor_i3().

◆ free_data()

◆ initialize_spectral_hex()

template<typename _Matrix >
void moab::element_utility::Spectral_hex_map< _Matrix >::initialize_spectral_hex ( int  order)
inlineprivate

◆ integrate_scalar_field()

template<typename _Matrix >
template<typename Points , typename Field >
double moab::element_utility::Spectral_hex_map< _Matrix >::integrate_scalar_field ( const Points p,
const Field &  field 
) const
inlineprivate

Definition at line 184 of file spectral_hex_map.hpp.

185  {
186  // set the position of GL points
187  // set the positions of GL nodes, before evaluations
188  _data.elx[0] = _xyz[0];
189  _data.elx[1] = _xyz[1];
190  _data.elx[2] = _xyz[2];
191  double xi[3];
192  // triple loop; the most inner loop is in r direction, then s, then t
193  double integral = 0.;
194  // double volume = 0;
195  int index = 0; // used fr the inner loop
196  for( int k = 0; k < _n; k++ )
197  {
198  xi[2] = _ld[2].z[k];
199  // double wk= _ld[2].w[k];
200  for( int j = 0; j < _n; j++ )
201  {
202  xi[1] = _ld[1].z[j];
203  // double wj= _ld[1].w[j];
204  for( int i = 0; i < _n; i++ )
205  {
206  xi[0] = _ld[0].z[i];
207  // double wi= _ld[0].w[i];
208  opt_vol_set_intp_3( (opt_data_3*)&_data, xi ); // cast away const-ness
209  double wk = _ld[2].J[k];
210  double wj = _ld[1].J[j];
211  double wi = _ld[0].J[i];
212  Matrix3 J( 0. );
213  for( int n = 0; n < 8; n++ )
214  J( n / 3, n % 3 ) = _data.jac[n];
215  double bm = wk * wj * wi * J.determinant();
216  integral += bm * field[index++];
217  // volume +=bm;
218  }
219  }
220  }
221  // std::cout << "volume: " << volume << "\n";
222  return integral;
223  }

References moab::element_utility::Spectral_hex_map< _Matrix >::_data, moab::element_utility::Spectral_hex_map< _Matrix >::_ld, moab::element_utility::Spectral_hex_map< _Matrix >::_n, moab::element_utility::Spectral_hex_map< _Matrix >::_xyz, moab::Matrix3::determinant(), opt_data_3::elx, lagrange_data::J, opt_data_3::jac, opt_vol_set_intp_3(), and lagrange_data::z.

◆ is_contained()

template<typename _Matrix >
template<typename Point >
bool moab::element_utility::Spectral_hex_map< _Matrix >::is_contained ( const Point &  p,
const double  tol 
) const
inlineprivate

Definition at line 101 of file spectral_hex_map.hpp.

102  {
103  // just look at the box+tol here
104  return ( p[0] >= -1. - tol ) && ( p[0] <= 1. + tol ) && ( p[1] >= -1. - tol ) && ( p[1] <= 1. + tol ) &&
105  ( p[2] >= -1. - tol ) && ( p[2] <= 1. + tol );
106  }

Referenced by moab::element_utility::Spectral_hex_map< _Matrix >::operator()().

◆ jacobian()

template<typename _Matrix >
template<typename Point , typename Points >
Matrix& moab::element_utility::Spectral_hex_map< _Matrix >::jacobian ( const Point &  ,
const Points ,
Matrix J 
)
inlineprivate

Definition at line 226 of file spectral_hex_map.hpp.

227  {
228  real x[3];
229  for( int i = 0; i < 3; ++i )
230  {
231  _data.elx[i] = _xyz[i];
232  }
233  opt_vol_set_intp_3( &_data, x );
234  for( int i = 0; i < 9; ++i )
235  {
236  J( i % 3, i / 3 ) = _data.jac[i];
237  }
238  return J;
239  }

References moab::element_utility::Spectral_hex_map< _Matrix >::_data, moab::element_utility::Spectral_hex_map< _Matrix >::_xyz, opt_data_3::elx, opt_data_3::jac, and opt_vol_set_intp_3().

Referenced by moab::element_utility::Spectral_hex_map< _Matrix >::solve_inverse().

◆ operator()()

template<typename _Matrix >
template<typename Moab , typename Entity_handle , typename Points , typename Point >
std::pair< bool, Point > moab::element_utility::Spectral_hex_map< _Matrix >::operator() ( const Moab &  ,
const Entity_handle &  ,
const Points v,
const Point &  p,
const double  tol = 1.e-6 
)
inline

Definition at line 77 of file spectral_hex_map.hpp.

82  {
83  Point result( 3, 0.0 );
84  /*
85  moab.tag_get_by_ptr(_xm1Tag, &eh, 1,(const void **) &_xyz[ 0] );
86  moab.tag_get_by_ptr(_ym1Tag, &eh, 1,(const void **) &_xyz[ 1] );
87  moab.tag_get_by_ptr(_zm1Tag, &eh, 1,(const void **) &_xyz[ 2] );
88  */
89  bool point_found = solve_inverse( p, result, v, tol ) && is_contained( result, tol );
90  return std::make_pair( point_found, result );
91  }

References moab::element_utility::Spectral_hex_map< _Matrix >::is_contained(), and moab::element_utility::Spectral_hex_map< _Matrix >::solve_inverse().

◆ set_gl_points()

template<typename _Matrix >
void moab::element_utility::Spectral_hex_map< _Matrix >::set_gl_points ( double *  x,
double *  y,
double *  z 
)
inlineprivate

Definition at line 94 of file spectral_hex_map.hpp.

95  {
96  _xyz[0] = x;
97  _xyz[1] = y;
98  _xyz[2] = z;
99  }

References moab::element_utility::Spectral_hex_map< _Matrix >::_xyz.

◆ solve_inverse()

template<typename _Matrix >
template<typename Point , typename Points >
bool moab::element_utility::Spectral_hex_map< _Matrix >::solve_inverse ( const Point &  x,
Point &  xi,
const Points points,
const double  tol = 1.e-6 
)
inlineprivate

Definition at line 109 of file spectral_hex_map.hpp.

110  {
111  const double error_tol_sqr = tol * tol;
112  Point delta( 3, 0.0 );
113  xi = delta;
114  evaluate( xi, points, delta );
115  vec_subtract( delta, x );
116  std::size_t num_iterations = 0;
117 #ifdef SPECTRAL_HEX_DEBUG
118  std::stringstream ss;
119  ss << "Point: ";
120  ss << x[0] << ", " << x[1] << ", " << x[2] << std::endl;
121  ss << "Hex: ";
122  for( int i = 0; i < 8; ++i )
123  {
124  ss << points[i][0] << ", " << points[i][1] << ", " << points[i][2] << std::endl;
125  }
126  ss << std::endl;
127 #endif
128  while( normsq( delta ) > error_tol_sqr )
129  {
130 #ifdef SPECTRAL_HEX_DEBUG
131  ss << "Iter #: " << num_iterations << " Err: " << sqrt( normsq( delta ) ) << " Iterate: ";
132  ss << xi[0] << ", " << xi[1] << ", " << xi[2] << std::endl;
133 #endif
134  if( ++num_iterations >= 5 )
135  {
136  return false;
137  }
138  Matrix J;
139  jacobian( xi, points, J );
140  double det = moab::Matrix::determinant3( J );
141  if( fabs( det ) < 1.e-10 )
142  {
143 #ifdef SPECTRAL_HEX_DEBUG
144  std::cerr << ss.str();
145 #endif
146 #ifndef SPECTRAL_HEX_DEBUG
147  std::cerr << x[0] << ", " << x[1] << ", " << x[2] << std::endl;
148 #endif
149  std::cerr << "inverse solve failure: det: " << det << std::endl;
150  exit( -1 );
151  }
152  vec_subtract( xi, moab::Matrix::inverse( J, 1.0 / det ) * delta );
153  evaluate( xi, points, delta );
154  vec_subtract( delta, x );
155  }
156  return true;
157  }

References moab::element_utility::Spectral_hex_map< _Matrix >::evaluate(), moab::Matrix::inverse(), and moab::element_utility::Spectral_hex_map< _Matrix >::jacobian().

Referenced by moab::element_utility::Spectral_hex_map< _Matrix >::operator()().

Member Data Documentation

◆ _data

◆ _init

template<typename _Matrix >
bool moab::element_utility::Spectral_hex_map< _Matrix >::_init
private

◆ _ld

◆ _n

◆ _odwork

◆ _xyz

◆ _z


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