31 const double error_tol_sqr = tol * tol;
36 while( delta % delta > error_tol_sqr )
40 if( det < std::numeric_limits< double >::epsilon() )
return false;
62 const double LinearHexMap::corner_xi[8][3] = { { -1, -1, -1 }, { 1, -1, -1 }, { 1, 1, -1 }, { -1, 1, -1 },
63 { -1, -1, 1 }, { 1, -1, 1 }, { 1, 1, 1 }, { -1, 1, 1 } };
72 for(
unsigned i = 0; i < 8; ++i )
85 for(
unsigned i = 0; i < 8; ++i )
98 for(
unsigned i = 0; i < 8; ++i )
100 const double xi_p = 1 + xi[0] *
corner_xi[i][0];
101 const double eta_p = 1 + xi[1] *
corner_xi[i][1];
102 const double zeta_p = 1 + xi[2] *
corner_xi[i][2];
103 const double dNi_dxi =
corner_xi[i][0] * eta_p * zeta_p;
104 const double dNi_deta =
corner_xi[i][1] * xi_p * zeta_p;
105 const double dNi_dzeta =
corner_xi[i][2] * xi_p * eta_p;
106 J( 0, 0 ) += dNi_dxi *
corners[i][0];
107 J( 1, 0 ) += dNi_dxi *
corners[i][1];
108 J( 2, 0 ) += dNi_dxi *
corners[i][2];
109 J( 0, 1 ) += dNi_deta *
corners[i][0];
110 J( 1, 1 ) += dNi_deta *
corners[i][1];
111 J( 2, 1 ) += dNi_deta *
corners[i][2];
112 J( 0, 2 ) += dNi_dzeta *
corners[i][0];
113 J( 1, 2 ) += dNi_dzeta *
corners[i][1];
114 J( 2, 2 ) += dNi_dzeta *
corners[i][2];
131 const int nverts = 8;
132 const int vertMap[nverts] = { 0, 1, 3, 2, 4, 5, 7, 6 };
138 for(
int i = 0; i < ndim; i++ )
139 xm[i] = coords + i * nverts;
142 for(
int i = 0; i < nverts; i++ )
145 hex[i].
get( vcoord );
147 for(
int d = 0; d < ndim; d++ )
148 coords[d * nverts + vertMap[i]] = vcoord[d];
156 for(
int j = 0; j < 3; j++ )
158 if( ncoords[j] < ( -1.0 - etol ) || ncoords[j] > ( 1.0 + etol ) ) ncoords[j] *= 10;
166 ( fabs( xi[1] - 1.0 ) < etol ) && ( fabs( xi[2] - 1.0 ) < etol );
179 return ( fabs( pt[0] -
dim[0] ) < etol ) && ( fabs( pt[1] -
dim[1] ) < etol ) &&
210 for(
int d = 0; d < 3; d++ )
233 for(
int d = 0; d < 3; ++d )
235 for(
int d = 0; d < 3; ++d )
250 rstCartVec.
get( rst );
255 for( d = 0; d < 3; ++d )
263 const unsigned nf = n * n, ne = n, nw = 2 * n * n + 3 * n;
267 for( d = 0; d < 3; d++ )
272 value =
tensor_i3( ld[0].J, ld[0].n, ld[1].J, ld[1].n, ld[2].J, ld[2].n, field, od_work );
275 for( d = 0; d < 3; d++ )
290 const double gauss_1[1][2] = { { 2.0, 0.0 } };
292 const double gauss_2[2][2] = { { 1.0, -0.5773502691 }, { 1.0, 0.5773502691 } };
294 const double gauss_3[3][2] = { { 0.5555555555, -0.7745966692 },
295 { 0.8888888888, 0.0 },
296 { 0.5555555555, 0.7745966692 } };
298 const double gauss_4[4][2] = { { 0.3478548451, -0.8611363116 },
299 { 0.6521451549, -0.3399810436 },
300 { 0.6521451549, 0.3399810436 },
301 { 0.3478548451, 0.8611363116 } };
303 const double gauss_5[5][2] = { { 0.2369268851, -0.9061798459 },
304 { 0.4786286705, -0.5384693101 },
305 { 0.5688888889, 0.0 },
306 { 0.4786286705, 0.5384693101 },
307 { 0.2369268851, 0.9061798459 } };
318 const double( *g_pts )[2] = 0;
348 for(
int r = 0; r < num_pts; r++ )
349 for(
int c = 0; c < 2; c++ )
350 std::cout <<
"g_pts[" << r <<
"][" << c <<
"]=" << g_pts[r][c] << std::endl;
356 for(
int i = 0; i < num_pts; i++ )
358 double w_i = g_pts[i][0];
359 double xi_i = g_pts[i][1];
360 for(
int j = 0; j < num_pts; j++ )
362 double w_j = g_pts[j][0];
363 double eta_j = g_pts[j][1];
364 for(
int k = 0; k < num_pts; k++ )
366 double w_k = g_pts[k][0];
367 double zeta_k = g_pts[k][1];
370 CartVect normal_pt( xi_i, eta_j, zeta_k );
380 soln = soln + ( w_i * w_j * w_k * field * det );
405 if( v.size() != this->vertex.size() )
427 const double error_tol_sqr = tol * tol;
434 while( delta % delta > error_tol_sqr )
451 double v1v1 =
v1 %
v1;
452 for(
int j = 1; j < 4; j++ )
477 transf =
Matrix3( vx[0], vx[1], vx[2], vy[0], vy[1], vy[2], vz[0], vz[1], vz[2] );
479 for(
int j = 1; j < 4; j++ )
486 double v1v1 =
v1 %
v1;
497 double v1v1 =
v1 %
v1;
503 const double LinearTri::corner[3][3] = { { 0, 0, 0 }, { 1, 0, 0 }, { 0, 1, 0 } };
512 this->
T =
Matrix3( v[1][0] - v[0][0], v[2][0] - v[0][0], 0, v[1][1] - v[0][1], v[2][1] - v[0][1], 0,
513 v[1][2] - v[0][2], v[2][2] - v[0][2], 1 );
523 return ( xi[0] >= -tol ) && ( xi[1] >= -tol ) && ( xi[2] >= -tol ) && ( xi[2] <= tol ) &&
524 ( xi[0] + xi[1] < 1.0 + tol );
533 double f0 = field_vertex_value[0];
535 for(
unsigned i = 1; i < 3; ++i )
537 f += ( field_vertex_value[i] - f0 ) * xi[i - 1];
545 for(
unsigned int i = 0; i < 3; ++i )
547 I += field_vertex_values[i];
549 I *= this->
det_T / 6.0;
555 vertex.resize( vertices.size() );
559 double v1v1 =
v1 %
v1;
560 for(
int j = 1; j < 3; j++ )
585 transf =
Matrix3( vx[0], vx[1], vx[2], vy[0], vy[1], vy[2], vz[0], vz[1], vz[2] );
587 for(
int j = 1; j < 3; j++ )
596 double v1v1 =
v1 %
v1;
607 double v1v1 =
v1 %
v1;
629 const double N_i = ( 1.0 + xi[0] *
corner[i][0] );
630 x += N_i * this->
vertex[i];
641 const double xi_p = 1.0 + xi[0] *
corner[i][0];
642 const double dNi_dxi =
corner[i][0] * xi_p;
643 J( 0, 0 ) += dNi_dxi *
vertex[i][0];
656 const double N_i = ( 1 + xi[0] *
corner[i][0] ) * ( 1.0 + xi[1] *
corner[i][1] );
657 f += N_i * field_vertex_value[i];
666 for(
unsigned int j1 = 0; j1 < this->
gauss_count; ++j1 )
668 double x1 = this->
gauss[j1][1];
669 double w1 = this->
gauss[j1][0];
679 return ( xi[0] >= -1. - tol ) && ( xi[0] <= 1. + tol );
682 const double LinearHex::corner[8][3] = { { -1, -1, -1 }, { 1, -1, -1 }, { 1, 1, -1 }, { -1, 1, -1 },
683 { -1, -1, 1 }, { 1, -1, 1 }, { 1, 1, 1 }, { -1, 1, 1 } };
693 const double LinearHex::gauss[2][2] = { { 1.0, -0.5773502691 }, { 1.0, 0.5773502691 } };
702 for(
unsigned i = 0; i < 8; ++i )
705 ( 1 + xi[0] *
corner[i][0] ) * ( 1 + xi[1] *
corner[i][1] ) * ( 1 + xi[2] *
corner[i][2] );
706 x += N_i * this->
vertex[i];
715 for(
unsigned i = 0; i < 8; ++i )
717 const double xi_p = 1 + xi[0] *
corner[i][0];
718 const double eta_p = 1 + xi[1] *
corner[i][1];
719 const double zeta_p = 1 + xi[2] *
corner[i][2];
720 const double dNi_dxi =
corner[i][0] * eta_p * zeta_p;
721 const double dNi_deta =
corner[i][1] * xi_p * zeta_p;
722 const double dNi_dzeta =
corner[i][2] * xi_p * eta_p;
723 J( 0, 0 ) += dNi_dxi *
vertex[i][0];
724 J( 1, 0 ) += dNi_dxi *
vertex[i][1];
725 J( 2, 0 ) += dNi_dxi *
vertex[i][2];
726 J( 0, 1 ) += dNi_deta *
vertex[i][0];
727 J( 1, 1 ) += dNi_deta *
vertex[i][1];
728 J( 2, 1 ) += dNi_deta *
vertex[i][2];
729 J( 0, 2 ) += dNi_dzeta *
vertex[i][0];
730 J( 1, 2 ) += dNi_dzeta *
vertex[i][1];
731 J( 2, 2 ) += dNi_dzeta *
vertex[i][2];
739 for(
unsigned i = 0; i < 8; ++i )
742 ( 1 + xi[0] *
corner[i][0] ) * ( 1 + xi[1] *
corner[i][1] ) * ( 1 + xi[2] *
corner[i][2] );
743 f += N_i * field_vertex_value[i];
752 for(
unsigned int j1 = 0; j1 < this->
gauss_count; ++j1 )
754 double x1 = this->
gauss[j1][1];
755 double w1 = this->
gauss[j1][0];
756 for(
unsigned int j2 = 0; j2 < this->
gauss_count; ++j2 )
758 double x2 = this->
gauss[j2][1];
759 double w2 = this->
gauss[j2][0];
760 for(
unsigned int j3 = 0; j3 < this->
gauss_count; ++j3 )
762 double x3 = this->
gauss[j3][1];
763 double w3 = this->
gauss[j3][0];
775 return ( xi[0] >= -1. - tol ) && ( xi[0] <= 1. + tol ) && ( xi[1] >= -1. - tol ) && ( xi[1] <= 1. + tol ) &&
776 ( xi[2] >= -1. - tol ) && ( xi[2] <= 1. + tol );
782 { -1, -1, -1 }, { 1, -1, -1 }, { 1, 1, -1 },
786 { 1, 1, 1 }, { -1, 1, 1 },
802 { -1, 0, 0 }, { 0, 0, -1 }, { 0, 0, 1 }, { 0, 0, 0 } };
807 double SH(
const int i,
const double xi )
812 return ( xi * xi - xi ) / 2;
816 return ( xi * xi + xi ) / 2;
821 double DSH(
const int i,
const double xi )
840 for(
int i = 0; i < 27; i++ )
851 return ( xi[0] >= -1. - tol ) && ( xi[0] <= 1. + tol ) && ( xi[1] >= -1. - tol ) && ( xi[1] <= 1. + tol ) &&
852 ( xi[2] >= -1. - tol ) && ( xi[2] <= 1. + tol );
858 for(
int i = 0; i < 27; i++ )
864 for(
int j = 0; j < 3; j++ )
866 J( j, 0 ) += dsh[0] * sh[1] * sh[2] *
vertex[i][j];
867 J( j, 1 ) += sh[0] * dsh[1] * sh[2] *
vertex[i][j];
868 J( j, 2 ) += sh[0] * sh[1] * dsh[2] *
vertex[i][j];
877 for(
int i = 0; i < 27; i++ )
880 x += sh * field_vertex_values[i];
890 const double LinearTet::corner[4][3] = { { 0, 0, 0 }, { 1, 0, 0 }, { 0, 1, 0 }, { 0, 0, 1 } };
900 Matrix3( v[1][0] - v[0][0], v[2][0] - v[0][0], v[3][0] - v[0][0], v[1][1] - v[0][1], v[2][1] - v[0][1],
901 v[3][1] - v[0][1], v[1][2] - v[0][2], v[2][2] - v[0][2], v[3][2] - v[0][2] );
909 double f0 = field_vertex_value[0];
911 for(
unsigned i = 1; i < 4; ++i )
913 f += ( field_vertex_value[i] - f0 ) * xi[i - 1];
926 for(
unsigned int i = 0; i < 4; ++i )
928 I += field_vertex_values[i];
930 I *= this->
det_T / 24.0;
937 return ( xi[0] >= -tol ) && ( xi[1] >= -tol ) && ( xi[2] >= -tol ) && ( xi[0] + xi[1] + xi[2] < 1.0 + tol );
974 if(
_init &&
_n == order )
return;
984 for(
int d = 0; d < 3; d++ )
992 unsigned int nf =
_n *
_n, ne =
_n, nw = 2 *
_n *
_n + 3 *
_n;
997 for(
int d = 0; d < 3; d++ )
1016 for( d = 0; d < 3; d++ )
1021 for( d = 0; d < 3; d++ )
1041 if( dist > 10 * tol )
1043 std::vector< CartVect > dummy;
1077 for( d = 0; d < 3; d++ )
1094 double integral = 0.;
1097 for(
int k = 0; k <
_n; k++ )
1099 xi[2] =
_ld[2].
z[k];
1101 for(
int j = 0; j <
_n; j++ )
1103 xi[1] =
_ld[1].
z[j];
1105 for(
int i = 0; i <
_n; i++ )
1107 xi[0] =
_ld[0].
z[i];
1110 double wk =
_ld[2].
J[k];
1111 double wj =
_ld[1].
J[j];
1112 double wi =
_ld[0].
J[i];
1125 integral += bm * field_vertex_values[index++];
1137 return ( xi[0] >= -1. - tol ) && ( xi[0] <= 1. + tol ) && ( xi[1] >= -1. - tol ) && ( xi[1] <= 1. + tol ) &&
1138 ( xi[2] >= -1. - tol ) && ( xi[2] <= 1. + tol );
1144 const double LinearQuad::corner[4][3] = { { -1, -1, 0 }, { 1, -1, 0 }, { 1, 1, 0 }, { -1, 1, 0 } };
1161 const double N_i = ( 1 + xi[0] *
corner[i][0] ) * ( 1 + xi[1] *
corner[i][1] );
1162 x += N_i * this->
vertex[i];
1174 const double xi_p = 1 + xi[0] *
corner[i][0];
1175 const double eta_p = 1 + xi[1] *
corner[i][1];
1176 const double dNi_dxi =
corner[i][0] * eta_p;
1177 const double dNi_deta =
corner[i][1] * xi_p;
1178 J( 0, 0 ) += dNi_dxi *
vertex[i][0];
1179 J( 1, 0 ) += dNi_dxi *
vertex[i][1];
1180 J( 0, 1 ) += dNi_deta *
vertex[i][0];
1181 J( 1, 1 ) += dNi_deta *
vertex[i][1];
1193 const double N_i = ( 1 + xi[0] *
corner[i][0] ) * ( 1 + xi[1] *
corner[i][1] );
1194 f += N_i * field_vertex_value[i];
1203 for(
unsigned int j1 = 0; j1 < this->
gauss_count; ++j1 )
1205 double x1 = this->
gauss[j1][1];
1206 double w1 = this->
gauss[j1][0];
1207 for(
unsigned int j2 = 0; j2 < this->
gauss_count; ++j2 )
1209 double x2 = this->
gauss[j2][1];
1210 double w2 = this->
gauss[j2][0];
1221 return ( xi[0] >= -1. - tol ) && ( xi[0] <= 1. + tol ) && ( xi[1] >= -1. - tol ) && ( xi[1] <= 1. + tol );
1235 _xyz[0] = _xyz[1] = _xyz[2] = NULL;
1248 _xyz[0] = _xyz[1] = _xyz[2] = NULL;
1257 if(
_init &&
_n == order )
return;
1267 for(
int d = 0; d < 2; d++ )
1275 unsigned int nf =
_n *
_n, ne =
_n, nw = 2 *
_n *
_n + 3 *
_n;
1282 for(
int d = 0; d < 2; d++ )
1302 for( d = 0; d < 2; d++ )
1307 for( d = 0; d < 3; d++ )
1324 if( dist > 0.9e+30 )
1326 std::vector< CartVect > dummy;
1347 for( d = 0; d < 2; d++ )
1363 return ( xi[0] >= -1. - tol ) && ( xi[0] <= 1. + tol ) && ( xi[1] >= -1. - tol ) && ( xi[1] <= 1. + tol );
1372 assert( this->
vertex.size() == 4 );
1373 static double corner_xi[4][2] = { { -1., -1. }, { 1., -1. }, { 1., 1. }, { -1., 1. } };
1378 for(
int i = 0; i <
_n; i++ )
1380 double eta =
_z[0][i];
1381 for(
int j = 0; j <
_n; j++ )
1383 double csi =
_z[1][j];
1384 CartVect pos( 0.0 );
1385 for(
int k = 0; k < 4; k++ )
1387 const double N_k = ( 1 + csi * corner_xi[k][0] ) * ( 1 + eta * corner_xi[k][1] );
1404 x = (
double*)
_xyz[0];
1405 y = (
double*)
_xyz[1];
1406 z = (
double*)
_xyz[2];