1 #ifndef MOAB_QUADRATIC_HEX_HPP
2 #define MOAB_QUADRATIC_HEX_HPP
13 namespace element_utility
19 double SH(
const int i,
const double xi )
24 return ( xi * xi - xi ) / 2;
28 return ( xi * xi + xi ) / 2;
33 double DSH(
const int i,
const double xi )
50 template <
typename _Matrix >
67 template <
typename Moab,
typename Entity_handle,
typename Po
ints,
typename Po
int >
69 const Entity_handle& ,
72 const double tol = 1.e-6 )
const
74 Point result( 3, 0.0 );
76 return std::make_pair( point_found, result );
85 const double rpts[27][3] = { { -1, -1, -1 }, { 1, -1, -1 }, { 1, 1, -1 },
89 { 1, 1, 1 }, { -1, 1, 1 },
105 { -1, 0, 0 }, { 0, 0, -1 }, { 0, 0, 1 }, { 0, 0, 0 } };
109 template <
typename Po
int >
113 return ( p[0] >= -1. - tol ) && ( p[0] <= 1. + tol ) && ( p[1] >= -1. - tol ) && ( p[1] <= 1. + tol ) &&
114 ( p[2] >= -1. - tol ) && ( p[2] <= 1. + tol );
117 template <
typename Po
int,
typename Po
ints >
120 const double error_tol_sqr = tol * tol;
121 Point delta( 3, 0.0 );
124 vec_subtract( delta, x );
125 std::size_t num_iterations = 0;
126 #ifdef QUADRATIC_HEX_DEBUG
127 std::stringstream ss;
129 ss << x[0] <<
", " << x[1] <<
", " << x[2] << std::endl;
131 for(
int i = 0; i < 8; ++i )
133 ss << points[i][0] <<
", " << points[i][1] <<
", " << points[i][2] << std::endl;
137 while( normsq( delta ) > error_tol_sqr )
139 #ifdef QUADRATIC_HEX_DEBUG
140 ss <<
"Iter #: " << num_iterations <<
" Err: " << sqrt( normsq( delta ) ) <<
" Iterate: ";
141 ss << xi[0] <<
", " << xi[1] <<
", " << xi[2] << std::endl;
143 if( ++num_iterations >= 5 )
149 double det = moab::Matrix::determinant3( J );
150 if( fabs( det ) < 1.e-10 )
152 #ifdef QUADRATIC_HEX_DEBUG
153 std::cerr << ss.str();
155 #ifndef QUADRATIC_HEX_DEBUG
156 std::cerr << x[0] <<
", " << x[1] <<
", " << x[2] << std::endl;
158 std::cerr <<
"inverse solve failure: det: " << det << std::endl;
163 vec_subtract( delta, x );
168 template <
typename Po
int,
typename Po
ints >
171 typedef typename Points::value_type Vector;
173 for(
int i = 0; i < 3; ++i )
177 for(
unsigned i = 0; i < 27; ++i )
181 result += sh * points[i];
183 for(
int i = 0; i < 3; ++i )
189 template <
typename Po
int,
typename Field >
193 for(
int i = 0; i < 27; i++ )
201 template <
typename Field,
typename Po
ints >
208 template <
typename Po
int,
typename Po
ints >
212 for(
int i = 0; i < 27; i++ )
218 for(
int j = 0; j < 3; j++ )