1 #ifndef EQUIVALENT_POYNOMIALS_UTILS
2 #define EQUIVALENT_POYNOMIALS_UTILS
11 const unsigned int nSpace(1);
12 level_set_normal[0] = 1.0;
18 const unsigned int nSpace(2);
19 double level_set_tangent[2];
20 for(
unsigned int I=0; I < nSpace; I++)
22 level_set_tangent[I] = phys_nodes_cut[3+I] - phys_nodes_cut[I];
24 level_set_normal[0] = level_set_tangent[1];
25 level_set_normal[1] = - level_set_tangent[0];
26 double norm = std::sqrt(level_set_normal[0]*level_set_normal[0] +
27 level_set_normal[1]*level_set_normal[1]);
29 for(
unsigned int I=0; I < nSpace; I++)
30 level_set_normal[I] /= norm;
33 for(
unsigned int I=0; I < nSpace; I++)
34 level_set_normal[I] =0.0;
35 level_set_normal[1] = 1.0;
42 const unsigned int nSpace(3);
43 double level_set_tangent_a[3], level_set_tangent_b[3];
44 for(
unsigned int I=0; I < nSpace; I++)
46 level_set_tangent_a[I] = phys_nodes_cut[3+I] - phys_nodes_cut[I];
47 level_set_tangent_b[I] = phys_nodes_cut[6+I] - phys_nodes_cut[I];
49 level_set_normal[0] = level_set_tangent_a[1]*level_set_tangent_b[2]
50 - level_set_tangent_a[2]*level_set_tangent_b[1];
51 level_set_normal[1] = - level_set_tangent_a[0]*level_set_tangent_b[2]
52 + level_set_tangent_a[2]*level_set_tangent_b[0];
53 level_set_normal[2] = level_set_tangent_a[0]*level_set_tangent_b[1]
54 - level_set_tangent_a[1]*level_set_tangent_b[0];
55 double norm = std::sqrt(level_set_normal[0]*level_set_normal[0] +
56 level_set_normal[1]*level_set_normal[1] +
57 level_set_normal[2]*level_set_normal[2]);
59 for(
unsigned int I=0; I < nSpace; I++)
60 level_set_normal[I] /= norm;
63 for(
unsigned int I=0; I < nSpace; I++)
64 level_set_normal[I] =0.0;
65 level_set_normal[2] =1.0;
67 assert(std::fabs(1.0-level_set_normal[0]*level_set_normal[0] - level_set_normal[1]*level_set_normal[1] - level_set_normal[2]*level_set_normal[2]) < 1.0e-8);
71 double* phys_nodes_cut_quad_02,
72 double* phys_nodes_cut_quad_31,
73 double* phys_nodes_cut_quad_32,
74 double* level_set_normal)
76 const unsigned int nSpace(3);
77 double level_set_tangent_a[3], level_set_tangent_b[3], level_set_tangent_c[3], level_set_normal_2[3];
78 for(
unsigned int I=0; I < nSpace; I++)
80 level_set_tangent_a[I] = phys_nodes_cut_quad_02[I] - phys_nodes_cut_quad_01[I];
81 level_set_tangent_b[I] = phys_nodes_cut_quad_32[I] - phys_nodes_cut_quad_01[I];
82 level_set_tangent_c[I] = phys_nodes_cut_quad_31[I] - phys_nodes_cut_quad_01[I];
84 level_set_normal[0] = level_set_tangent_a[1]*level_set_tangent_b[2] - level_set_tangent_a[2]*level_set_tangent_b[1];
85 level_set_normal[1] = - level_set_tangent_a[0]*level_set_tangent_b[2] + level_set_tangent_a[2]*level_set_tangent_b[0];
86 level_set_normal[2] = level_set_tangent_a[0]*level_set_tangent_b[1] - level_set_tangent_a[1]*level_set_tangent_b[0];
87 double norm = std::sqrt(level_set_normal[0]*level_set_normal[0] +
88 level_set_normal[1]*level_set_normal[1] +
89 level_set_normal[2]*level_set_normal[2]);
92 for(
unsigned int I=0; I < nSpace; I++)
93 level_set_normal[I] = level_set_normal[I] / norm;
97 for(
unsigned int I=0; I < nSpace; I++)
98 level_set_normal[I] =0.0;
99 level_set_normal[2] = 1.0;
101 assert(std::fabs(1.0-level_set_normal[0]*level_set_normal[0] - level_set_normal[1]*level_set_normal[1] - level_set_normal[2]*level_set_normal[2]) < 1.0e-8);
110 unsigned int iDOF = 0;
111 register double x_pow_i=1.0;
112 for(
unsigned int i=0; i < nP+1; i++, iDOF++)
114 register double psi=x_pow_i;
116 _ImH += C_ImH[iDOF]*
psi;
128 unsigned int iDOF = 0;
129 register double x_pow_i=1.0;
130 for(
unsigned int i=0; i < nP+1; i++)
132 register double y_pow_j=1.0;
133 for(
unsigned int j=0; j < nP+1-i; j++, iDOF++)
135 register double psi=x_pow_i*y_pow_j;
137 _ImH += C_ImH[iDOF]*
psi;
151 unsigned int iDOF = 0;
152 register double x_pow_i=1.0;
153 for(
unsigned int i=0; i < nP+1; i++)
155 register double y_pow_j=1.0;
156 for(
unsigned int j=0; j < nP+1-i; j++)
158 register double x_pow_i_y_pow_j=x_pow_i*y_pow_j, z_pow_k=1.0;
159 for(
unsigned int k=0; k < nP+1-i-j; k++, iDOF++)
161 register double psi=x_pow_i_y_pow_j*z_pow_k;
163 _ImH += C_ImH[iDOF]*
psi;
176 inline double det(
const double* A);
187 return A[0]*A[3] - A[1]*A[2];
199 inline void inv(
const double* A,
double* Ainv);
202 inline void inv<1>(
const double* A,
double* Ainv)
208 inline void inv<2>(
const double* A,
double* Ainv)
210 double oneOverDet = 1.0/
det<2>(A);
211 Ainv[0] = oneOverDet*A[3];
212 Ainv[1] = -oneOverDet*A[1];
213 Ainv[2] = -oneOverDet*A[2];
214 Ainv[3] = oneOverDet*A[0];
218 inline void inv<3>(
const double* A,
double* Ainv)
220 double oneOverDet = 1.0/
det<3>(A);
221 Ainv[
XX] = oneOverDet*(A[
YY]*A[
ZZ] - A[
YZ]*A[
ZY]);
222 Ainv[
YX] = oneOverDet*(A[
YZ]*A[
ZX] - A[
YX]*A[
ZZ]);
223 Ainv[
ZX] = oneOverDet*(A[
YX]*A[
ZY] - A[
YY]*A[
ZX]);
224 Ainv[
XY] = oneOverDet*(A[
ZY]*A[
XZ] - A[
ZZ]*A[
XY]);
225 Ainv[
YY] = oneOverDet*(A[
ZZ]*A[
XX] - A[
ZX]*A[
XZ]);
226 Ainv[
ZY] = oneOverDet*(A[
ZX]*A[
XY] - A[
ZY]*A[
XX]);
227 Ainv[
XZ] = oneOverDet*(A[
XY]*A[
YZ] - A[
XZ]*A[
YY]);
228 Ainv[
YZ] = oneOverDet*(A[
XZ]*A[
YX] - A[
XX]*A[
YZ]);
229 Ainv[
ZZ] = oneOverDet*(A[
XX]*A[
YY] - A[
XY]*A[
YX]);