Mesh Oriented datABase
(version 5.4.1)
Array-based unstructured mesh datastructure
|
#include <spectral_hex_map.hpp>
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) |
Static Public Member Functions | |
typedef _Matrix | Matrix |
Private Types | |
typedef Spectral_hex_map< Matrix > | Self |
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 > | |
Matrix & | jacobian (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] |
Definition at line 22 of file spectral_hex_map.hpp.
typedef _Matrix moab::element_utility::Spectral_hex_map< _Matrix >::Matrix [static] |
Definition at line 25 of file spectral_hex_map.hpp.
typedef Spectral_hex_map< Matrix > moab::element_utility::Spectral_hex_map< _Matrix >::Self [private] |
Definition at line 28 of file spectral_hex_map.hpp.
moab::element_utility::Spectral_hex_map< _Matrix >::Spectral_hex_map | ( | ) | [inline] |
Definition at line 32 of file spectral_hex_map.hpp.
{};
moab::element_utility::Spectral_hex_map< _Matrix >::Spectral_hex_map | ( | int | order | ) | [inline] |
Definition at line 33 of file spectral_hex_map.hpp.
{ initialize_spectral_hex( order ); }
moab::element_utility::Spectral_hex_map< _Matrix >::Spectral_hex_map | ( | const Self & | f | ) | [inline] |
Definition at line 38 of file spectral_hex_map.hpp.
{}
Point& moab::element_utility::Spectral_hex_map< _Matrix >::evaluate | ( | const Point & | p, |
const Points & | , | ||
Point & | f | ||
) | [inline, private] |
Definition at line 160 of file spectral_hex_map.hpp.
Referenced by moab::element_utility::Spectral_hex_map< moab::Matrix3 >::solve_inverse().
double moab::element_utility::Spectral_hex_map< _Matrix >::evaluate_scalar_field | ( | const Point & | p, |
const Field & | field | ||
) | const [inline, private] |
void moab::element_utility::Spectral_hex_map< _Matrix >::free_data | ( | ) | [inline, private] |
Definition at line 63 of file spectral_hex_map.hpp.
Referenced by moab::element_utility::Spectral_hex_map< moab::Matrix3 >::initialize_spectral_hex().
{ for( int d = 0; d < 3; d++ ) { free( _z[d] ); lagrange_free( &_ld[d] ); } opt_free_3( &_data ); free( _odwork ); }
void moab::element_utility::Spectral_hex_map< _Matrix >::initialize_spectral_hex | ( | int | order | ) | [inline, private] |
Definition at line 41 of file spectral_hex_map.hpp.
Referenced by moab::element_utility::Spectral_hex_map< moab::Matrix3 >::Spectral_hex_map().
{ if( _init && _n == order ) { return; } if( _init && _n != order ) { free_data(); } _init = true; _n = order; for( int d = 0; d < 3; d++ ) { lobatto_nodes( _z[d], _n ); lagrange_setup( &_ld[d], _z[d], _n ); } opt_alloc_3( &_data, _ld ); std::size_t nf = _n * _n, ne = _n, nw = 2 * _n * _n + 3 * _n; _odwork = tmalloc( real, 6 * nf + 9 * ne + nw ); }
double moab::element_utility::Spectral_hex_map< _Matrix >::integrate_scalar_field | ( | const Points & | p, |
const Field & | field | ||
) | const [inline, private] |
Definition at line 184 of file spectral_hex_map.hpp.
{ // set the position of GL points // set the positions of GL nodes, before evaluations _data.elx[0] = _xyz[0]; _data.elx[1] = _xyz[1]; _data.elx[2] = _xyz[2]; double xi[3]; // triple loop; the most inner loop is in r direction, then s, then t double integral = 0.; // double volume = 0; int index = 0; // used fr the inner loop for( int k = 0; k < _n; k++ ) { xi[2] = _ld[2].z[k]; // double wk= _ld[2].w[k]; for( int j = 0; j < _n; j++ ) { xi[1] = _ld[1].z[j]; // double wj= _ld[1].w[j]; for( int i = 0; i < _n; i++ ) { xi[0] = _ld[0].z[i]; // double wi= _ld[0].w[i]; opt_vol_set_intp_3( (opt_data_3*)&_data, xi ); // cast away const-ness double wk = _ld[2].J[k]; double wj = _ld[1].J[j]; double wi = _ld[0].J[i]; Matrix3 J( 0. ); for( int n = 0; n < 8; n++ ) J( n / 3, n % 3 ) = _data.jac[n]; double bm = wk * wj * wi * J.determinant(); integral += bm * field[index++]; // volume +=bm; } } } // std::cout << "volume: " << volume << "\n"; return integral; }
bool moab::element_utility::Spectral_hex_map< _Matrix >::is_contained | ( | const Point & | p, |
const double | tol | ||
) | const [inline, private] |
Definition at line 101 of file spectral_hex_map.hpp.
Referenced by moab::element_utility::Spectral_hex_map< moab::Matrix3 >::operator()().
{ // just look at the box+tol here return ( p[0] >= -1. - tol ) && ( p[0] <= 1. + tol ) && ( p[1] >= -1. - tol ) && ( p[1] <= 1. + tol ) && ( p[2] >= -1. - tol ) && ( p[2] <= 1. + tol ); }
Matrix& moab::element_utility::Spectral_hex_map< _Matrix >::jacobian | ( | const Point & | , |
const Points & | , | ||
Matrix & | J | ||
) | [inline, private] |
Definition at line 226 of file spectral_hex_map.hpp.
Referenced by moab::element_utility::Spectral_hex_map< moab::Matrix3 >::solve_inverse().
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.
{ Point result( 3, 0.0 ); /* moab.tag_get_by_ptr(_xm1Tag, &eh, 1,(const void **) &_xyz[ 0] ); moab.tag_get_by_ptr(_ym1Tag, &eh, 1,(const void **) &_xyz[ 1] ); moab.tag_get_by_ptr(_zm1Tag, &eh, 1,(const void **) &_xyz[ 2] ); */ bool point_found = solve_inverse( p, result, v, tol ) && is_contained( result, tol ); return std::make_pair( point_found, result ); }
void moab::element_utility::Spectral_hex_map< _Matrix >::set_gl_points | ( | double * | x, |
double * | y, | ||
double * | z | ||
) | [inline, private] |
Definition at line 94 of file spectral_hex_map.hpp.
bool moab::element_utility::Spectral_hex_map< _Matrix >::solve_inverse | ( | const Point & | x, |
Point & | xi, | ||
const Points & | points, | ||
const double | tol = 1.e-6 |
||
) | [inline, private] |
Definition at line 109 of file spectral_hex_map.hpp.
Referenced by moab::element_utility::Spectral_hex_map< moab::Matrix3 >::operator()().
{ const double error_tol_sqr = tol * tol; Point delta( 3, 0.0 ); xi = delta; evaluate( xi, points, delta ); vec_subtract( delta, x ); std::size_t num_iterations = 0; #ifdef SPECTRAL_HEX_DEBUG std::stringstream ss; ss << "Point: "; ss << x[0] << ", " << x[1] << ", " << x[2] << std::endl; ss << "Hex: "; for( int i = 0; i < 8; ++i ) { ss << points[i][0] << ", " << points[i][1] << ", " << points[i][2] << std::endl; } ss << std::endl; #endif while( normsq( delta ) > error_tol_sqr ) { #ifdef SPECTRAL_HEX_DEBUG ss << "Iter #: " << num_iterations << " Err: " << sqrt( normsq( delta ) ) << " Iterate: "; ss << xi[0] << ", " << xi[1] << ", " << xi[2] << std::endl; #endif if( ++num_iterations >= 5 ) { return false; } Matrix J; jacobian( xi, points, J ); double det = moab::Matrix::determinant3( J ); if( fabs( det ) < 1.e-10 ) { #ifdef SPECTRAL_HEX_DEBUG std::cerr << ss.str(); #endif #ifndef SPECTRAL_HEX_DEBUG std::cerr << x[0] << ", " << x[1] << ", " << x[2] << std::endl; #endif std::cerr << "inverse solve failure: det: " << det << std::endl; exit( -1 ); } vec_subtract( xi, moab::Matrix::inverse( J, 1.0 / det ) * delta ); evaluate( xi, points, delta ); vec_subtract( delta, x ); } return true; }
opt_data_3 moab::element_utility::Spectral_hex_map< _Matrix >::_data [private] |
Definition at line 246 of file spectral_hex_map.hpp.
Referenced by moab::element_utility::Spectral_hex_map< moab::Matrix3 >::free_data(), moab::element_utility::Spectral_hex_map< moab::Matrix3 >::initialize_spectral_hex(), moab::element_utility::Spectral_hex_map< moab::Matrix3 >::integrate_scalar_field(), and moab::element_utility::Spectral_hex_map< moab::Matrix3 >::jacobian().
bool moab::element_utility::Spectral_hex_map< _Matrix >::_init [private] |
Definition at line 242 of file spectral_hex_map.hpp.
Referenced by moab::element_utility::Spectral_hex_map< moab::Matrix3 >::initialize_spectral_hex().
lagrange_data moab::element_utility::Spectral_hex_map< _Matrix >::_ld[3] [private] |
Definition at line 245 of file spectral_hex_map.hpp.
Referenced by moab::element_utility::Spectral_hex_map< moab::Matrix3 >::evaluate(), moab::element_utility::Spectral_hex_map< moab::Matrix3 >::evaluate_scalar_field(), moab::element_utility::Spectral_hex_map< moab::Matrix3 >::free_data(), moab::element_utility::Spectral_hex_map< moab::Matrix3 >::initialize_spectral_hex(), and moab::element_utility::Spectral_hex_map< moab::Matrix3 >::integrate_scalar_field().
int moab::element_utility::Spectral_hex_map< _Matrix >::_n [private] |
Definition at line 243 of file spectral_hex_map.hpp.
Referenced by moab::element_utility::Spectral_hex_map< moab::Matrix3 >::initialize_spectral_hex(), and moab::element_utility::Spectral_hex_map< moab::Matrix3 >::integrate_scalar_field().
real* moab::element_utility::Spectral_hex_map< _Matrix >::_odwork [private] |
Definition at line 247 of file spectral_hex_map.hpp.
Referenced by moab::element_utility::Spectral_hex_map< moab::Matrix3 >::evaluate(), moab::element_utility::Spectral_hex_map< moab::Matrix3 >::evaluate_scalar_field(), moab::element_utility::Spectral_hex_map< moab::Matrix3 >::free_data(), and moab::element_utility::Spectral_hex_map< moab::Matrix3 >::initialize_spectral_hex().
real* moab::element_utility::Spectral_hex_map< _Matrix >::_xyz[3] [private] |
Definition at line 248 of file spectral_hex_map.hpp.
Referenced by moab::element_utility::Spectral_hex_map< moab::Matrix3 >::evaluate(), moab::element_utility::Spectral_hex_map< moab::Matrix3 >::integrate_scalar_field(), moab::element_utility::Spectral_hex_map< moab::Matrix3 >::jacobian(), and moab::element_utility::Spectral_hex_map< moab::Matrix3 >::set_gl_points().
real* moab::element_utility::Spectral_hex_map< _Matrix >::_z[3] [private] |
Definition at line 244 of file spectral_hex_map.hpp.
Referenced by moab::element_utility::Spectral_hex_map< moab::Matrix3 >::free_data(), and moab::element_utility::Spectral_hex_map< moab::Matrix3 >::initialize_spectral_hex().