1 #ifndef MOAB_SPECTRAL_HEX_HPP
2 #define MOAB_SPECTRAL_HEX_HPP
14 namespace element_utility
21 template <
typename _Matrix >
53 for(
int d = 0; d < 3; d++ )
59 std::size_t nf =
_n *
_n, ne =
_n, nw = 2 *
_n *
_n + 3 *
_n;
65 for(
int d = 0; d < 3; d++ )
76 template <
typename Moab,
typename Entity_handle,
typename Po
ints,
typename Po
int >
78 const Entity_handle& ,
81 const double tol = 1.e-6 )
83 Point result( 3, 0.0 );
90 return std::make_pair( point_found, result );
100 template <
typename Po
int >
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 );
108 template <
typename Po
int,
typename Po
ints >
111 const double error_tol_sqr = tol * tol;
112 Point delta( 3, 0.0 );
115 vec_subtract( delta, x );
116 std::size_t num_iterations = 0;
117 #ifdef SPECTRAL_HEX_DEBUG
118 std::stringstream ss;
120 ss << x[0] <<
", " << x[1] <<
", " << x[2] << std::endl;
122 for(
int i = 0; i < 8; ++i )
124 ss << points[i][0] <<
", " << points[i][1] <<
", " << points[i][2] << std::endl;
128 while( normsq( delta ) > error_tol_sqr )
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;
134 if( ++num_iterations >= 5 )
140 double det = moab::Matrix::determinant3( J );
141 if( fabs( det ) < 1.e-10 )
143 #ifdef SPECTRAL_HEX_DEBUG
144 std::cerr << ss.str();
146 #ifndef SPECTRAL_HEX_DEBUG
147 std::cerr << x[0] <<
", " << x[1] <<
", " << x[2] << std::endl;
149 std::cerr <<
"inverse solve failure: det: " << det << std::endl;
154 vec_subtract( delta, x );
159 template <
typename Po
int,
typename Po
ints >
162 for(
int d = 0; d < 3; ++d )
166 for(
int d = 0; d < 3; ++d )
173 template <
typename Po
int,
typename Field >
177 for( d = 0; d < 3; d++ )
183 template <
typename Po
ints,
typename Field >
193 double integral = 0.;
196 for(
int k = 0; k <
_n; k++ )
200 for(
int j = 0; j <
_n; j++ )
204 for(
int i = 0; i <
_n; i++ )
209 double wk =
_ld[2].
J[k];
210 double wj =
_ld[1].
J[j];
211 double wi =
_ld[0].
J[i];
213 for(
int n = 0; n < 8; n++ )
216 integral += bm * field[index++];
225 template <
typename Po
int,
typename Po
ints >
229 for(
int i = 0; i < 3; ++i )
234 for(
int i = 0; i < 9; ++i )