25using AD1Type = internal::dual<real_t, real_t>;
27using AD2Type = internal::dual<AD1Type, AD1Type>;
32template <
typename type>
35 return u[0]*
u[0] +
u[1]*
u[1] +
u[2]*
u[2] +
u[3]*
u[3];
38template <
typename type>
41 return u[0]*
u[0] +
u[1]*
u[1] +
u[2]*
u[2] +
u[3]*
u[3] +
u[4]*
u[4] +
42 u[5]*
u[5] +
u[6]*
u[6] +
u[7]*
u[7] +
u[8]*
u[8];
45template <
typename type>
48 return u[0]*
u[3] -
u[1]*
u[2];
51template <
typename type>
54 return u[0]*(
u[4]*
u[8] -
u[5]*
u[7]) -
55 u[1]*(
u[3]*
u[8] -
u[5]*
u[6]) +
56 u[2]*(
u[3]*
u[7] -
u[4]*
u[6]);
59template <
typename type>
60void mult_2D(
const std::vector<type> &
u,
const std::vector<type> &M,
61 std::vector<type> &mat)
65 mat[0] =
u[0]*M[0] +
u[2]*M[1];
66 mat[1] =
u[1]*M[0] +
u[3]*M[1];
67 mat[2] =
u[0]*M[2] +
u[2]*M[3];
68 mat[3] =
u[1]*M[2] +
u[3]*M[3];
71template <
typename type>
72void mult_aTa_2D(
const std::vector<type> &in, std::vector<type> &outm)
74 outm.resize(in.size());
75 outm[0] = in[0]*in[0];
76 outm[1] = in[0]*in[2] + in[1]*in[3];
77 outm[2] = in[0]*in[2] + in[1]*in[3];
78 outm[3] = in[3]*in[3];
81template <
typename scalartype,
typename type>
82void add_2D(
const scalartype &scalar,
const std::vector<type> &
u,
86 mat[0] =
u[0] + scalar * M->
Elem(0,0);
87 mat[1] =
u[1] + scalar * M->
Elem(1,0);
88 mat[2] =
u[2] + scalar * M->
Elem(0,1);
89 mat[3] =
u[3] + scalar * M->
Elem(1,1);
92template <
typename scalartype,
typename type>
93void add_2D(
const scalartype &scalar,
const std::vector<type> &
u,
94 const std::vector<type> &M, std::vector<type> &mat)
97 mat[0] =
u[0] + scalar * M[0];
98 mat[1] =
u[1] + scalar * M[1];
99 mat[2] =
u[2] + scalar * M[2];
100 mat[3] =
u[3] + scalar * M[3];
103template <
typename type>
104void adjoint_2D(
const std::vector<type> &in, std::vector<type> &outm)
106 outm.resize(in.size());
113template <
typename type>
116 outm.resize(in.size());
123template <
typename scalartype,
typename type>
124void add_3D(
const scalartype &scalar,
const std::vector<type> &
u,
127 mat.resize(
u.size());
128 mat[0] =
u[0] + scalar * M->
Elem(0,0);
129 mat[1] =
u[1] + scalar * M->
Elem(1,0);
130 mat[2] =
u[2] + scalar * M->
Elem(2,0);
132 mat[3] =
u[3] + scalar * M->
Elem(0,1);
133 mat[4] =
u[4] + scalar * M->
Elem(1,1);
134 mat[5] =
u[5] + scalar * M->
Elem(2,1);
136 mat[6] =
u[6] + scalar * M->
Elem(0,2);
137 mat[7] =
u[7] + scalar * M->
Elem(1,2);
138 mat[8] =
u[8] + scalar * M->
Elem(2,2);
144template <
typename type>
145type
mu85_ad(
const std::vector<type> &T,
const std::vector<type> &W)
148 return T[1]*T[1] + T[2]*T[2] +
149 (T[0] - fnorm/sqrt(2))*(T[0] - fnorm/sqrt(2)) +
150 (T[3] - fnorm/sqrt(2))*(T[3] - fnorm/sqrt(2));
154template <
typename type>
155type
mu98_ad(
const std::vector<type> &T,
const std::vector<type> &W)
158 Id(0,0) = 1; Id(1,1) = 1;
160 std::vector<type> Mat;
167template <
typename type>
168type
mu342_ad(
const std::vector<type> &T,
const std::vector<type> &W)
171 Id(0,0) = 1; Id(1,1) = 1; Id(2,2) = 1;
173 std::vector<type> Mat;
180template <
typename type>
181type
nu11_ad(
const std::vector<type> &T,
const std::vector<type> &W)
184 std::vector<type> AdjA,AdjAt, WtW, WRK, WRK2;
199 return 0.25 / (
alpha) * fnorm;
203template <
typename type>
204type
nu14_ad(
const std::vector<type> &T,
const std::vector<type> &W)
209 auto sqalpha = sqrt(
det_2D(A));
210 auto sqomega = sqrt(
det_2D(W));
212 return 0.5*pow(sqalpha/sqomega - sqomega/sqalpha, 2.0);
216template <
typename type>
217type
nu36_ad(
const std::vector<type> &T,
const std::vector<type> &W)
220 std::vector<type> AminusW;
226 return 1.0 / (
det_2D(A)) * fnorm;
230template <
typename type>
231type
nu50_ad(
const std::vector<type> &T,
const std::vector<type> &W)
236 auto l1_A = sqrt(A[0]*A[0] + A[1]*A[1]);
237 auto l2_A = sqrt(A[2]*A[2] + A[3]*A[3]);
238 auto prod_A = l1_A*l2_A;
239 auto det_A = A[0]*A[3] - A[1]*A[2];
240 auto sin_A = det_A/prod_A;
241 auto cos_A = (A[0]*A[2] + A[1]*A[3])/prod_A;
243 auto l1_W = sqrt(W[0]*W[0] + W[1]*W[1]);
244 auto l2_W = sqrt(W[2]*W[2] + W[3]*W[3]);
245 auto prod_W = l1_W*l2_W;
246 auto det_W = W[0]*W[3] - W[1]*W[2];
247 auto sin_W = det_W/prod_W;
248 auto cos_W = (W[0]*W[2] + W[1]*W[3])/prod_W;
250 return (1.0 - cos_A*cos_W - sin_A*sin_W)/(sin_A*sin_W);
255template <
typename type>
256type
nu51_ad(
const std::vector<type> &T,
const std::vector<type> &W)
261 auto l1_A = sqrt(A[0]*A[0] + A[1]*A[1]);
262 auto l2_A = sqrt(A[2]*A[2] + A[3]*A[3]);
263 auto prod_A = l1_A*l2_A;
264 auto det_A = A[0]*A[3] - A[1]*A[2];
265 auto sin_A = det_A/prod_A;
266 auto cos_A = (A[0]*A[2] + A[1]*A[3])/prod_A;
267 auto ups_A = l1_A*l2_A*sin_A;
269 auto l1_W = sqrt(W[0]*W[0] + W[1]*W[1]);
270 auto l2_W = sqrt(W[2]*W[2] + W[3]*W[3]);
271 auto prod_W = l1_W*l2_W;
272 auto det_W = W[0]*W[3] - W[1]*W[2];
273 auto sin_W = det_W/prod_W;
274 auto cos_W = (W[0]*W[2] + W[1]*W[3])/prod_W;
275 auto ups_W = l1_W*l2_W*sin_W;
277 return (0.5 * (ups_A / ups_W + ups_W / ups_A) - cos_A*cos_W - sin_A*sin_W) /
282template <
typename type>
283type
nu107_ad(
const std::vector<type> &T,
const std::vector<type> &W)
286 std::vector<type> Mat;
297template <
typename type>
298type
skew2D_ad(
const std::vector<type> &T,
const std::vector<type> &W)
303 auto l1_A = sqrt(A[0]*A[0] + A[1]*A[1]);
304 auto l2_A = sqrt(A[2]*A[2] + A[3]*A[3]);
305 auto prod_A = l1_A*l2_A;
306 auto det_A = A[0]*A[3] - A[1]*A[2];
307 auto sin_A = det_A/prod_A;
308 auto cos_A = (A[0]*A[2] + A[1]*A[3])/prod_A;
310 auto l1_W = sqrt(W[0]*W[0] + W[1]*W[1]);
311 auto l2_W = sqrt(W[2]*W[2] + W[3]*W[3]);
312 auto prod_W = l1_W*l2_W;
313 auto det_W = W[0]*W[3] - W[1]*W[2];
314 auto sin_W = det_W/prod_W;
315 auto cos_W = (W[0]*W[2] + W[1]*W[3])/prod_W;
317 return 0.5*(1.0 - cos_A*cos_W - sin_A*sin_W);
323 std::vector<AD1Type>&)>mu_ad,
327 const bool dX =
true )
330 std::vector<AD1Type> adX(matsize), adY(matsize);
332 for (
int i=0; i<matsize; i++) { adX[i] =
AD1Type{X.
GetData()[i], 0.0}; }
335 for (
int i=0; i<matsize; i++) { adY[i] =
AD1Type{Y->GetData()[i], 0.0}; }
340 for (
int i=0; i<matsize; i++)
344 dmu.
GetData()[i] = rez.gradient;
350 MFEM_VERIFY(Y,
"Y cannot be nullptr when dX = false.");
351 for (
int i=0; i<matsize; i++)
353 adY[i] =
AD1Type{Y->GetData()[i], 1.0};
355 dmu.
GetData()[i] = rez.gradient;
356 adY[i] =
AD1Type{Y->GetData()[i], 0.0};
363 std::vector<AD2Type>&)> mu_ad,
371 std::vector<AD2Type> aduu(matsize), adY(matsize);
372 for (
int ii = 0; ii < matsize; ii++)
375 aduu[ii].gradient =
AD1Type{0.0, 0.0};
379 for (
int ii=0; ii<matsize; ii++)
381 adY[ii].value =
AD1Type{Y->GetData()[ii], 0.0};
382 adY[ii].gradient =
AD1Type{0.0, 0.0};
386 for (
int ii = 0; ii < matsize; ii++)
389 for (
int jj = 0; jj < (ii + 1); jj++)
391 aduu[jj].gradient =
AD1Type{1.0, 0.0};
392 AD2Type rez = mu_ad(aduu, adY);
393 d2mu_dX2(ii).
GetData()[jj] = rez.gradient.gradient;
394 d2mu_dX2(jj).
GetData()[ii] = rez.gradient.gradient;
395 aduu[jj].gradient =
AD1Type{0.0, 0.0};
413 for (
int r = 0; r <
dim; r++)
415 for (
int c = 0; c <
dim; c++)
420 for (
int rr = 0; rr <
dim; rr++)
422 for (
int cc = 0; cc <
dim; cc++)
424 const double entry_rr_cc = Hrc(rr, cc);
426 for (
int i = 0; i < dof; i++)
428 for (
int j = 0; j < dof; j++)
430 A(i+r*dof, j+rr*dof) +=
431 weight * DS(i, c) * DS(j, cc) * entry_rr_cc;
511 Vector products_no_m(m_cnt); products_no_m = 1.0;
512 for (
int m_p = 0; m_p < m_cnt; m_p++)
514 for (
int m_a = 0; m_a < m_cnt; m_a++)
516 if (m_p != m_a) { products_no_m(m_p) *= averages(m_a); }
519 const real_t pnm_sum = products_no_m.
Sum();
521 if (pnm_sum == 0.0) { weights = 1.0 / m_cnt;
return; }
522 for (
int m = 0; m < m_cnt; m++) { weights(m) = products_no_m(m) / pnm_sum; }
524 MFEM_ASSERT(fabs(weights.
Sum() - 1.0) < 1e-14,
525 "Error: sum should be 1 always: " << weights.
Sum());
533 NE =
nodes.FESpace()->GetNE(),
534 dim =
nodes.FESpace()->GetMesh()->Dimension();
542 for (
int e = 0; e < NE; e++)
554 nodes.FESpace()->GetElementVDofs(e, pos_dofs);
555 nodes.GetSubVector(pos_dofs, posV);
561 for (
int q = 0; q < nsp; q++)
572 for (
int m = 0; m < m_cnt; m++)
575 averages(m) +=
tmop_q_arr[m]->EvalW(T) * w_detA;
586 MPI_Allreduce(MPI_IN_PLACE, averages.
GetData(), m_cnt,
589 par_nodes->ParFESpace()->GetComm());
600 real_t metric = metric_tilde;
603 metric = std::pow(metric_tilde,
exponent);
608 metric = metric_tilde/(
beta-metric_tilde);
653 MFEM_VERIFY(
Jtr != NULL,
654 "Requires a target Jacobian, use SetTargetJacobian().");
656 std::vector<AD1Type> T(matsize), W(matsize);
657 for (
int i=0; i<matsize; i++)
690 MFEM_VERIFY(
Jtr != NULL,
691 "Requires a target Jacobian, use SetTargetJacobian().");
703 real_t cos_Jpr_12 = (col1 * col2) / (norm_c1 * norm_c2),
704 cos_Jpr_13 = (col1 * col3) / (norm_c1 * norm_c3),
705 cos_Jpr_23 = (col2 * col3) / (norm_c2 * norm_c3);
706 real_t sin_Jpr_12 = std::sqrt(1.0 - cos_Jpr_12 * cos_Jpr_12),
707 sin_Jpr_13 = std::sqrt(1.0 - cos_Jpr_13 * cos_Jpr_13),
708 sin_Jpr_23 = std::sqrt(1.0 - cos_Jpr_23 * cos_Jpr_23);
716 real_t cos_Jtr_12 = (col1 * col2) / (norm_c1 * norm_c2),
717 cos_Jtr_13 = (col1 * col3) / (norm_c1 * norm_c3),
718 cos_Jtr_23 = (col2 * col3) / (norm_c2 * norm_c3);
719 real_t sin_Jtr_12 = std::sqrt(1.0 - cos_Jtr_12 * cos_Jtr_12),
720 sin_Jtr_13 = std::sqrt(1.0 - cos_Jtr_13 * cos_Jtr_13),
721 sin_Jtr_23 = std::sqrt(1.0 - cos_Jtr_23 * cos_Jtr_23);
723 return (3.0 - cos_Jpr_12 * cos_Jtr_12 - sin_Jpr_12 * sin_Jtr_12
724 - cos_Jpr_13 * cos_Jtr_13 - sin_Jpr_13 * sin_Jtr_13
725 - cos_Jpr_23 * cos_Jtr_23 - sin_Jpr_23 * sin_Jtr_23) / 6.0;
730 MFEM_VERIFY(
Jtr != NULL,
731 "Requires a target Jacobian, use SetTargetJacobian().");
745 return 0.5 * (ratio_Jpr / ratio_Jtr + ratio_Jtr / ratio_Jpr) - 1.0;
750 MFEM_VERIFY(
Jtr != NULL,
751 "Requires a target Jacobian, use SetTargetJacobian().");
763 real_t ratio_Jpr_1 = norm_c1 / std::sqrt(norm_c2 * norm_c3),
764 ratio_Jpr_2 = norm_c2 / std::sqrt(norm_c1 * norm_c3),
765 ratio_Jpr_3 = norm_c3 / std::sqrt(norm_c1 * norm_c2);
773 real_t ratio_Jtr_1 = norm_c1 / std::sqrt(norm_c2 * norm_c3),
774 ratio_Jtr_2 = norm_c2 / std::sqrt(norm_c1 * norm_c3),
775 ratio_Jtr_3 = norm_c3 / std::sqrt(norm_c1 * norm_c2);
777 return ( 0.5 * (ratio_Jpr_1 / ratio_Jtr_1 + ratio_Jtr_1 / ratio_Jpr_1) +
778 0.5 * (ratio_Jpr_2 / ratio_Jtr_2 + ratio_Jtr_2 / ratio_Jpr_2) +
779 0.5 * (ratio_Jpr_3 / ratio_Jtr_3 + ratio_Jtr_3 / ratio_Jpr_3) - 3.0
785 return 0.5 * Jpt.
FNorm2() / Jpt.
Det() - 1.0;
866 const real_t c2 = weight*c1*c1;
931 for (
int i = 0; i < Jpt.
Size(); i++)
933 JptMinusId(i, i) -= 1.0;
946 for (
int i = 0; i < Jpt.
Size(); i++)
948 JptMinusId(i, i) -= 1.0;
1003 const real_t c2 = weight*c1/2;
1020 return 0.5 * JtJ.
FNorm2()/(det*det) - 1.0;
1031 return 0.5*I1b*I1b - 2.0;
1088 return 0.5 * (d + 1.0 / d) - 1.0;
1096 return 0.5*(I2b + 1.0/I2b) - 1.0;
1129 return JtJ.
FNorm2()/(det*det) - 2*Jpt.
FNorm2()/det + 2.0;
1137 return I1b*(I1b - 2.0);
1165 return 0.5 * (d*d + 1.0/(d*d)) - 1.0;
1172 return 0.5*(I2 + 1.0/I2) - 1.0;
1200 std::vector<AD1Type> T(matsize), W(matsize);
1201 for (
int i=0; i<matsize; i++) { T[i] =
AD1Type{Jpt.
GetData()[i], 0.0}; }
1226 std::vector<AD1Type> T(matsize), W(matsize);
1227 for (
int i=0; i<matsize; i++) { T[i] =
AD1Type{Jpt.
GetData()[i], 0.0}; }
1254 return (I2b - 1.0)*(I2b - 1.0) - I2b + std::sqrt(I2b*I2b +
eps);
1259 MFEM_ABORT(
"Metric not implemented yet. Use metric mu_55 instead.");
1267 MFEM_ABORT(
"Metric not implemented yet. Use metric mu_55 instead.");
1275 return 0.5*(I2b - 1.0)*(I2b - 1.0)/(I2b -
tau0);
1303 const real_t c = c0*(I2b - 1.0);
1314 return Jpt.FNorm() * inv.FNorm() / 3.0 - 1.0;
1362 const real_t a = weight/(6*std::sqrt(I1b_I2b));
1374 return Jpt.
FNorm2() * inv.FNorm2() / 9.0 - 1.0;
1405 const real_t c1 = weight/9;
1415 return Jpt.
FNorm2() / 3.0 / pow(Jpt.
Det(), 2.0 / 3.0) - 1.0;
1448 const real_t fnorm = Jpt.FNorm();
1449 return fnorm * fnorm * fnorm / pow(3.0, 1.5) / Jpt.
Det() - 1.0;
1456 return pow(
ie.
Get_I1b()/3.0, 1.5) - 1.0;
1485 return (I3b - 1.0)*(I3b - 1.0) - I3b + std::sqrt(I3b*I3b +
eps);
1492 const real_t c = 2*I3b-3+(I3b)/(std::pow((I3b*I3b+
eps),0.5));
1505 const real_t c1 = 2 + 1/(pow(c0,0.5)) - I3b*I3b/(pow(c0,1.5));
1506 const real_t c2 = 2*I3b - 3 + I3b/(pow(c0,0.5));
1526 const real_t c = std::pow(d, -2.0/3.0);
1533 MFEM_ABORT(
"Metric not implemented yet.");
1541 MFEM_ABORT(
"Metric not implemented yet.");
1576 return 0.5 * (Jpt.
Det() + 1.0 / Jpt.
Det()) - 1.0;
1584 return 0.5*(I3b + 1.0/I3b) - 1.0;
1613 return 0.5 * (d*d + 1.0 / (d*d)) - 1.0;
1621 return 0.5*(I3 + 1.0/I3) - 1.0;
1652 invt.
Add(-1.0, Jpt);
1694 const real_t c1 = weight*c0*c0;
1695 const real_t c2 = -2*c0*c1;
1710 adj_J_t.
Add(1.0, Jpt);
1711 return 1.0 / 6.0 / Jpt.
Det() * adj_J_t.
FNorm2();
1757 m13 = weight * pow(
ie.
Get_I3b(), -1.0/3.0),
1758 m23 = weight * pow(
ie.
Get_I3b(), -2.0/3.0),
1759 m43 = weight * pow(
ie.
Get_I3b(), -4.0/3.0),
1760 m53 = weight * pow(
ie.
Get_I3b(), -5.0/3.0),
1761 m73 = weight * pow(
ie.
Get_I3b(), -7.0/3.0);
1781 real_t fnorm = Jpt.FNorm();
1782 return fnorm * fnorm * fnorm - 3.0 * sqrt(3.0) * (log(Jpt.
Det()) + 1.0);
1821 std::vector<AD1Type> T(matsize), W(matsize);
1822 for (
int i=0; i<matsize; i++) { T[i] =
AD1Type{Jpt.
GetData()[i], 0.0}; }
1848 return 0.5*(I3b - 1.0)*(I3b - 1.0)/(I3b -
tau0);
1881 const real_t c = c0*(I3b - 1.0);
1889 const real_t fnorm = Jpt.FNorm();
1890 return fnorm * fnorm * fnorm / pow(3.0, 1.5) - Jpt.
Det();
1924 MFEM_VERIFY(
Jtr != NULL,
1925 "Requires a target Jacobian, use SetTargetJacobian().");
1927 std::vector<AD1Type> T(matsize), W(matsize);
1928 for (
int i=0; i<matsize; i++)
1961 MFEM_VERIFY(
Jtr != NULL,
1962 "Requires a target Jacobian, use SetTargetJacobian().");
1964 std::vector<AD1Type> T(matsize), W(matsize);
1965 for (
int i=0; i<matsize; i++)
1998 MFEM_VERIFY(
Jtr != NULL,
1999 "Requires a target Jacobian, use SetTargetJacobian().");
2001 std::vector<AD1Type> T(matsize), W(matsize);
2002 for (
int i=0; i<matsize; i++)
2035 MFEM_VERIFY(
Jtr != NULL,
2036 "Requires a target Jacobian, use SetTargetJacobian().");
2038 std::vector<AD1Type> T(matsize), W(matsize);
2039 for (
int i=0; i<matsize; i++)
2072 MFEM_VERIFY(
Jtr != NULL,
2073 "Requires a target Jacobian, use SetTargetJacobian().");
2075 std::vector<AD1Type> T(matsize), W(matsize);
2076 for (
int i=0; i<matsize; i++)
2109 MFEM_VERIFY(
Jtr != NULL,
2110 "Requires a target Jacobian, use SetTargetJacobian().");
2112 std::vector<AD1Type> T(matsize), W(matsize);
2113 for (
int i=0; i<matsize; i++)
2146 MFEM_VERIFY(
nodes,
"Nodes are not given!");
2147 MFEM_ASSERT(
avg_volume == 0.0,
"The average volume is already computed!");
2150 const int NE = mesh->
GetNE();
2154 for (
int i = 0; i < NE; i++)
2178 area_NE[0] = volume; area_NE[1] = NE;
2199 const int NE = mesh->
GetNE();
2201 if (NE == 0) {
return; }
2204 "mixed meshes are not supported");
2205 MFEM_VERIFY(!fes.
IsVariableOrder(),
"variable orders are not supported");
2207 const int sdim = fes.
GetVDim();
2208 const int nvdofs = sdim*fe.
GetDof();
2210 xe.
Size() == NE*nvdofs,
"invalid input Vector 'xe'!");
2220 if (dof_map->
Size() == 0) { dof_map =
nullptr; }
2224 Vector elfun_lex, elfun_nat;
2232 for (
int e = 0; e < NE; e++)
2243 const int ndofs = fe.
GetDof();
2244 for (
int d = 0; d < sdim; d++)
2246 for (
int i_lex = 0; i_lex < ndofs; i_lex++)
2248 elfun_nat[(*dof_map)[i_lex]+d*ndofs] =
2249 elfun_lex[i_lex+d*ndofs];
2268 default: MFEM_ABORT(
"TargetType not added to ContainsVolumeInfo.");
2278 MFEM_CONTRACT_VAR(elfun);
2286 MFEM_ASSERT(Wideal.
Width() == Jtr.
SizeJ(),
"");
2292 for (
int i = 0; i < ir.
GetNPoints(); i++) { Jtr(i) = Wideal; }
2309 for (
int i = 0; i < ir.
GetNPoints(); i++) { Jtr(i) = W; }
2332 const real_t det = Jtr(i).Det();
2333 MFEM_VERIFY(det > 0.0,
"The given mesh is inverted!");
2334 Jtr(i).Set(std::pow(det / detW, 1./
dim), Wideal);
2340 MFEM_ABORT(
"invalid target type!");
2350 MFEM_CONTRACT_VAR(elfun);
2380 "Target type GIVEN_FULL requires a MatrixCoefficient.");
2397 MFEM_ABORT(
"Incompatible target type for analytic adaptation!");
2415 "Target type GIVEN_FULL requires a TMOPMatrixCoefficient.");
2417 for (
int d = 0; d < fe->
GetDim(); d++)
2430 MFEM_ABORT(
"Incompatible target type for analytic adaptation!");
2440static inline void device_copy(
real_t *d_dest,
const real_t *d_src,
int size)
2442 mfem::forall(size, [=] MFEM_HOST_DEVICE (
int i) { d_dest[i] = d_src[i]; });
2450 MFEM_VERIFY(
adapt_eval,
"SetAdaptivityEvaluator() has not been called!")
2451 MFEM_VERIFY(
ncomp > 0,
"No target specifications have been set!");
2495 MFEM_VERIFY(ndof ==
tspec.
Size()/
ncomp,
"Inconsistency in SetTspecAtIndex.");
2497 const auto tspec__d = tspec_.
Read();
2499 const int offset = idx*ndof;
2500 internal::device_copy(tspec_d + offset, tspec__d, ndof*vdim);
2507 "Discrete target size should be ordered byNodes.");
2517 "Discrete target skewness should be ordered byNodes.");
2527 "Discrete target aspect ratio should be ordered byNodes.");
2537 "Discrete target orientation should be ordered byNodes.");
2564 const auto tspec_temp_d = tspec_temp.
Read();
2566 internal::device_copy(tspec_d, tspec_temp_d, tspec_temp.
Size());
2568 const auto tspec__d = tspec_.
Read();
2569 const int offset = (
ncomp-vdim)*ndof;
2570 internal::device_copy(tspec_d + offset, tspec__d, ndof*vdim);
2577 MFEM_VERIFY(ndof ==
tspec.
Size()/
ncomp,
"Inconsistency in SetTspecAtIndex.");
2579 const auto tspec__d = tspec_.
Read();
2581 const int offset = idx*ndof;
2582 internal::device_copy(tspec_d + offset, tspec__d, ndof*vdim);
2589 "Discrete target size should be ordered byNodes.");
2599 "Discrete target skewness should be ordered byNodes.");
2609 "Discrete target aspect ratio should be ordered byNodes.");
2619 "Discrete target orientation should be ordered byNodes.");
2628 MFEM_VERIFY(
adapt_eval,
"SetAdaptivityEvaluator() has not been called!")
2629 MFEM_VERIFY(
ncomp > 0,
"No target specifications have been set!");
2649 if (idx < 0) {
return; }
2653 "Inconsistency in GetSerialDiscreteTargetSpec.");
2655 for (
int i = 0; i < ndof*vdim; i++)
2657 tspec_(i) =
tspec(i + idx*ndof);
2684 MFEM_VERIFY(
tspec.
Size() > 0,
"Target specification is not set!");
2700 int dofidx,
int dir,
2703 MFEM_VERIFY(
tspec.
Size() > 0,
"Target specification is not set!");
2709 for (
int i = 0; i <
ncomp; i++)
2711 tspec(dofs[dofidx]+i*cnt) = IntData(dofs[dofidx] + i*cnt + dir*cnt*
ncomp);
2718 MFEM_VERIFY(
tspec.
Size() > 0,
"Target specification is not set!");
2723 for (
int i = 0; i <
ncomp; i++)
2738 ntspec_dofs = ndofs*
ncomp;
2740 Vector tspec_vals(ntspec_dofs);
2751 MFEM_ABORT(
"Incompatible target type for discrete adaptation!");
2768 MFEM_VERIFY(
tspec_fesv,
"No target specifications have been set.");
2783 ntspec_dofs = ndofs*
ncomp;
2785 Vector shape(ndofs), tspec_vals(ntspec_dofs), par_vals,
2786 par_vals_c1, par_vals_c2, par_vals_c3;
2795 MFEM_VERIFY(
amr_el >= 0,
" Target being constructed for an AMR element.");
2796 for (
int i = 0; i <
ncomp; i++)
2798 for (
int j = 0; j < ndofs; j++)
2812 for (
int q = 0; q < nqp; q++)
2817 for (
int d = 0; d < 4; d++)
2828 MFEM_VERIFY(min_size > 0.0,
2829 "Non-positive size propagated in the target definition.");
2831 real_t size = std::max(shape * par_vals, min_size);
2837 Jtr(q).Set(std::pow(size, 1.0/
dim), Jtr(q));
2851 MFEM_VERIFY(min_size > 0.0,
2852 "Non-positive aspect-ratio propagated in the target definition.");
2854 const real_t aspectratio = shape * par_vals;
2856 D_rho(0,0) = 1./pow(aspectratio,0.5);
2857 D_rho(1,1) = pow(aspectratio,0.5);
2867 const real_t rho1 = shape * par_vals_c1;
2868 const real_t rho2 = shape * par_vals_c2;
2869 const real_t rho3 = shape * par_vals_c3;
2871 D_rho(0,0) = pow(rho1,2./3.);
2872 D_rho(1,1) = pow(rho2,2./3.);
2873 D_rho(2,2) = pow(rho3,2./3.);
2878 Mult(D_rho, Temp, Jtr(q));
2888 const real_t skew = shape * par_vals;
2892 Q_phi(0,1) = cos(skew);
2893 Q_phi(1,1) = sin(skew);
2903 const real_t phi12 = shape * par_vals_c1;
2904 const real_t phi13 = shape * par_vals_c2;
2905 const real_t chi = shape * par_vals_c3;
2909 Q_phi(0,1) = cos(phi12);
2910 Q_phi(0,2) = cos(phi13);
2912 Q_phi(1,1) = sin(phi12);
2913 Q_phi(1,2) = sin(phi13)*cos(chi);
2915 Q_phi(2,2) = sin(phi13)*sin(chi);
2920 Mult(Q_phi, Temp, Jtr(q));
2930 const real_t theta = shape * par_vals;
2931 R_theta(0,0) = cos(theta);
2932 R_theta(0,1) = -sin(theta);
2933 R_theta(1,0) = sin(theta);
2934 R_theta(1,1) = cos(theta);
2944 const real_t theta = shape * par_vals_c1;
2945 const real_t psi = shape * par_vals_c2;
2948 real_t ct = cos(theta), st = sin(theta),
2949 cp = cos(psi), sp = sin(psi),
2953 R_theta(0,0) = ct*sp;
2954 R_theta(1,0) = st*sp;
2957 R_theta(0,1) = -st*cb + ct*cp*sb;
2958 R_theta(1,1) = ct*cb + st*cp*sb;
2959 R_theta(2,1) = -sp*sb;
2961 R_theta(0,0) = -st*sb - ct*cp*cb;
2962 R_theta(1,0) = ct*sb - st*cp*cb;
2963 R_theta(2,0) = sp*cb;
2966 Jtrcomp_q = R_theta;
2968 Mult(R_theta, Temp, Jtr(q));
2974 MFEM_ABORT(
"Incompatible target type for discrete adaptation!");
2985 MFEM_VERIFY(
tspec_fesv,
"No target specifications have been set.");
3000 ntspec_dofs = ndofs*
ncomp;
3002 Vector shape(ndofs), tspec_vals(ntspec_dofs), par_vals,
3003 par_vals_c1(ndofs), par_vals_c2(ndofs), par_vals_c3(ndofs);
3013 grad_e_c2(ndofs,
dim),
3014 grad_e_c3(ndofs,
dim);
3015 Vector grad_ptr_c1(grad_e_c1.GetData(), ndofs*
dim),
3016 grad_ptr_c2(grad_e_c2.GetData(), ndofs*
dim),
3035 grad_phys.
Mult(par_vals, grad_ptr_c1);
3038 grad_e_c1.MultTranspose(shape, grad_q);
3041 MFEM_VERIFY(min_size > 0.0,
3042 "Non-positive size propagated in the target definition.");
3043 const real_t size = std::max(shape * par_vals, min_size);
3046 Mult(Jtrcomp_q, Jtrcomp_d, work1);
3047 Mult(Jtrcomp_r, work1, work2);
3049 for (
int d = 0; d <
dim; d++)
3053 work1.
Set(dz_dsize, work1);
3055 AddMult(work1, work2, dJtr_i);
3068 grad_phys.
Mult(par_vals, grad_ptr_c1);
3071 grad_e_c1.MultTranspose(shape, grad_q);
3073 const real_t aspectratio = shape * par_vals;
3075 dD_rho(0,0) = -0.5*pow(aspectratio,-1.5);
3076 dD_rho(1,1) = 0.5*pow(aspectratio,-0.5);
3078 Mult(Jtrcomp_s, Jtrcomp_r, work1);
3079 Mult(work1, Jtrcomp_q, work2);
3081 for (
int d = 0; d <
dim; d++)
3086 AddMult(work2, work1, dJtr_i);
3093 par_vals_c1.SetData(par_vals.
GetData());
3094 par_vals_c2.SetData(par_vals.
GetData()+ndofs);
3097 grad_phys.
Mult(par_vals_c1, grad_ptr_c1);
3098 grad_phys.
Mult(par_vals_c2, grad_ptr_c2);
3099 grad_phys.
Mult(par_vals_c3, grad_ptr_c3);
3102 grad_e_c1.MultTranspose(shape, grad_q1);
3103 grad_e_c2.MultTranspose(shape, grad_q2);
3106 const real_t rho1 = shape * par_vals_c1;
3107 const real_t rho2 = shape * par_vals_c2;
3108 const real_t rho3 = shape * par_vals_c3;
3110 dD_rho(0,0) = (2./3.)*pow(rho1,-1./3.);
3111 dD_rho(1,1) = (2./3.)*pow(rho2,-1./3.);
3112 dD_rho(2,2) = (2./3.)*pow(rho3,-1./3.);
3114 Mult(Jtrcomp_s, Jtrcomp_r, work1);
3115 Mult(work1, Jtrcomp_q, work2);
3118 for (
int d = 0; d <
dim; d++)
3122 work1(0,0) *= grad_q1(d);
3123 work1(1,2) *= grad_q2(d);
3124 work1(2,2) *= grad_q3(d);
3126 AddMult(work2, work1, dJtr_i);
3138 grad_phys.
Mult(par_vals, grad_ptr_c1);
3141 grad_e_c1.MultTranspose(shape, grad_q);
3143 const real_t skew = shape * par_vals;
3147 dQ_phi(0,1) = -sin(skew);
3148 dQ_phi(1,1) = cos(skew);
3150 Mult(Jtrcomp_s, Jtrcomp_r, work2);
3152 for (
int d = 0; d <
dim; d++)
3157 Mult(work1, Jtrcomp_d, work3);
3158 AddMult(work2, work3, dJtr_i);
3165 par_vals_c1.SetData(par_vals.
GetData());
3166 par_vals_c2.SetData(par_vals.
GetData()+ndofs);
3169 grad_phys.
Mult(par_vals_c1, grad_ptr_c1);
3170 grad_phys.
Mult(par_vals_c2, grad_ptr_c2);
3171 grad_phys.
Mult(par_vals_c3, grad_ptr_c3);
3174 grad_e_c1.MultTranspose(shape, grad_q1);
3175 grad_e_c2.MultTranspose(shape, grad_q2);
3178 const real_t phi12 = shape * par_vals_c1;
3179 const real_t phi13 = shape * par_vals_c2;
3180 const real_t chi = shape * par_vals_c3;
3184 dQ_phi(0,1) = -sin(phi12);
3185 dQ_phi(1,1) = cos(phi12);
3188 dQ_phi13(0,2) = -sin(phi13);
3189 dQ_phi13(1,2) = cos(phi13)*cos(chi);
3190 dQ_phi13(2,2) = cos(phi13)*sin(chi);
3193 dQ_phichi(1,2) = -sin(phi13)*sin(chi);
3194 dQ_phichi(2,2) = sin(phi13)*cos(chi);
3196 Mult(Jtrcomp_s, Jtrcomp_r, work2);
3198 for (
int d = 0; d <
dim; d++)
3202 work1 *= grad_q1(d);
3203 work1.Add(grad_q2(d), dQ_phi13);
3204 work1.Add(grad_q3(d), dQ_phichi);
3205 Mult(work1, Jtrcomp_d, work3);
3206 AddMult(work2, work3, dJtr_i);
3218 grad_phys.
Mult(par_vals, grad_ptr_c1);
3221 grad_e_c1.MultTranspose(shape, grad_q);
3223 const real_t theta = shape * par_vals;
3224 dR_theta(0,0) = -sin(theta);
3225 dR_theta(0,1) = -cos(theta);
3226 dR_theta(1,0) = cos(theta);
3227 dR_theta(1,1) = -sin(theta);
3229 Mult(Jtrcomp_q, Jtrcomp_d, work1);
3230 Mult(Jtrcomp_s, work1, work2);
3231 for (
int d = 0; d <
dim; d++)
3236 AddMult(work1, work2, dJtr_i);
3243 par_vals_c1.SetData(par_vals.
GetData());
3244 par_vals_c2.SetData(par_vals.
GetData()+ndofs);
3247 grad_phys.
Mult(par_vals_c1, grad_ptr_c1);
3248 grad_phys.
Mult(par_vals_c2, grad_ptr_c2);
3249 grad_phys.
Mult(par_vals_c3, grad_ptr_c3);
3252 grad_e_c1.MultTranspose(shape, grad_q1);
3253 grad_e_c2.MultTranspose(shape, grad_q2);
3256 const real_t theta = shape * par_vals_c1;
3257 const real_t psi = shape * par_vals_c2;
3260 const real_t ct = cos(theta), st = sin(theta),
3261 cp = cos(psi), sp = sin(psi),
3265 dR_theta(0,0) = -st*sp;
3266 dR_theta(1,0) = ct*sp;
3269 dR_theta(0,1) = -ct*cb - st*cp*sb;
3270 dR_theta(1,1) = -st*cb + ct*cp*sb;
3273 dR_theta(0,0) = -ct*sb + st*cp*cb;
3274 dR_theta(1,0) = -st*sb - ct*cp*cb;
3282 dR_beta(0,1) = st*sb + ct*cp*cb;
3283 dR_beta(1,1) = -ct*sb + st*cp*cb;
3284 dR_beta(2,1) = -sp*cb;
3286 dR_beta(0,0) = -st*cb + ct*cp*sb;
3287 dR_beta(1,0) = ct*cb + st*cp*sb;
3291 dR_psi(0,0) = ct*cp;
3292 dR_psi(1,0) = st*cp;
3295 dR_psi(0,1) = 0. - ct*sp*sb;
3296 dR_psi(1,1) = 0. + st*sp*sb;
3297 dR_psi(2,1) = -cp*sb;
3299 dR_psi(0,0) = 0. + ct*sp*cb;
3300 dR_psi(1,0) = 0. + st*sp*cb;
3301 dR_psi(2,0) = cp*cb;
3303 Mult(Jtrcomp_q, Jtrcomp_d, work1);
3304 Mult(Jtrcomp_s, work1, work2);
3305 for (
int d = 0; d <
dim; d++)
3309 work1 *= grad_q1(d);
3310 work1.Add(grad_q2(d), dR_psi);
3311 work1.Add(grad_q3(d), dR_beta);
3312 AddMult(work1, work2, dJtr_i);
3320 MFEM_ABORT(
"Incompatible target type for discrete adaptation!");
3327 bool reuse_flag,
int x_ordering)
3335 "FD with discrete adaptivity assume mesh_order = field_order.");
3341 for (
int j = 0; j <
dim; j++)
3343 for (
int i = 0; i < cnt; i++)
3352 for (
int i = 0; i < cnt; i++)
3364 bool reuse_flag,
int x_ordering)
3370 totmix = 1+2*(
dim-2);
3373 "FD with discrete adaptivity assume mesh_order = field_order.");
3382 for (
int j = 0; j <
dim; j++)
3384 for (
int i = 0; i < cnt; i++)
3393 for (
int i = 0; i < cnt; i++)
3402 for (
int k1 = 0; k1 <
dim; k1++)
3404 for (
int k2 = 0; (k1 != k2) && (k2 <
dim); k2++)
3406 for (
int i = 0; i < cnt; i++)
3417 for (
int i = 0; i < cnt; i++)
3448 f.GetVDim(),
f.GetOrdering());
3459 f.GetVDim(),
f.GetOrdering());
3486 PA.H.GetMemory().DeleteDevice(copy_to_host);
3487 PA.H0.GetMemory().DeleteDevice(copy_to_host);
3488 if (!copy_to_host && !
PA.Jtr.GetMemory().HostIsValid())
3490 PA.Jtr_needs_update =
true;
3492 PA.Jtr.GetMemory().DeleteDevice(copy_to_host);
3503 if (
PA.enabled &&
x_0 !=
nullptr)
3507 PA.X0.UseDevice(
true);
3521 for (
int i = 0; i <
ElemDer.Size(); i++)
3536 "'dist' must be a scalar GridFunction!");
3595 "Using both fitting approaches is not supported.");
3598 MFEM_VERIFY(per ==
false,
"Fitting is not supported for periodic meshes.");
3603 "Mesh and level-set polynomial order must be the same.");
3606 MFEM_VERIFY(fec,
"Only H1_FECollection is supported for the surface fitting "
3628 "Using both fitting approaches is not supported.");
3630 "Positions on a mesh without Nodes is not supported.");
3633 "Incompatible ordering of spaces!");
3636 MFEM_VERIFY(per ==
false,
"Fitting is not supported for periodic meshes.");
3656 "Using both fitting approaches is not supported.");
3659 MFEM_VERIFY(per ==
false,
"Fitting is not supported for periodic meshes.");
3664 "Mesh and level-set polynomial order must be the same.");
3667 MFEM_VERIFY(fec,
"Only H1_FECollection is supported for the surface fitting "
3682 if (!aegrad) {
return; }
3684 MFEM_VERIFY(aehess,
"AdaptivityEvaluator for Hessians must be provided too.");
3697 for (
int d = 0; d <
dim; d++)
3716 for (
int d = 0; d <
dim; d++)
3718 for (
int idir = 0; idir <
dim; idir++)
3724 surf_fit_grad_comp.
GetDerivative(1, idir, surf_fit_hess_comp);
3735#ifdef MFEM_USE_GSLIB
3762#ifndef MFEM_USE_GSLIB
3763 MFEM_ABORT(
"Surface fitting from source requires GSLIB!");
3767 MFEM_VERIFY(per ==
false,
"Fitting is not supported for periodic meshes.");
3787 "Nodal ordering for grid function on source mesh and current mesh"
3788 "should be the same.");
3802 "Nodal ordering for grid function on source mesh and current mesh"
3803 "should be the same.");
3833 "Fitting is not supported for periodic meshes.");
3837 else { pos = d_loc; }
3839 MFEM_VERIFY(
surf_fit_marker,
"Surface fitting has not been enabled.");
3845 bool parallel = (pfes) ?
true :
false;
3853 for (
int i = 0; i < node_cnt; i++)
3860 const int dof_i = pfes->DofToVDof(i, 0);
3861 if (parallel && pfes->GetLocalTDofNumber(dof_i) < 0) {
continue; }
3870 for (
int d = 0; d <
dim; d++)
3873 pos(d*node_cnt + i) : pos(i*
dim + d);
3876 : (*surf_fit_pos)(i*
dim + d);
3878 sigma_s = pos_s.DistanceTo(pos_s_target);
3881 err_max = std::max(err_max, sigma_s);
3888 MPI_Comm comm = pfes->GetComm();
3891 MPI_Allreduce(MPI_IN_PLACE, &dof_cnt, 1, MPI_INT, MPI_SUM, comm);
3897 err_avg = (dof_cnt > 0) ? err_sum / dof_cnt : 0.0;
3946 else { elfun = d_el; }
4016 Vector adapt_lim_gf_q, adapt_lim_gf0_q;
4017 if (adaptive_limiting)
4050 if (adaptive_limiting)
4052 const real_t diff = adapt_lim_gf_q(i) - adapt_lim_gf0_q(i);
4056 energy += weight * val;
4072 for (
int s = 0; s < dof; s++)
4075 const int scalar_dof_id = fes_fit->
VDofToDof(vdofs[s]);
4085 energy += w * sigma_e(s) * sigma_e(s);
4091 for (
int d = 0; d <
dim; d++)
4093 pos(d) =
PMatI(s, d);
4094 pos_target(d) = (*surf_fit_pos)(vdofs[d*dof + s]);
4120 for (
int e = 0; e < NEsplit; e++)
4127 for (
int i = 0; i < dof; i++)
4129 for (
int d = 0; d <
dim; d++)
4135 elfun_child(i + d*dof) = elfun(i + e*dof + d*dof*NEsplit);
4179 el_energy += weight * val;
4182 energy += el_energy;
4238 energy += weight * val;
4295 else { elfun = d_el; }
4318 Vector shape,
p, p0, d_vals, grad;
4340 d_vals.
SetSize(nqp); d_vals = 1.0;
4365 for (
int q = 0; q < nqp; q++)
4390 for (
int d = 0; d <
dim; d++)
4394 d_detW_dx(d) = dwdx.
Trace();
4401 for (
int d = 0; d <
dim; d++)
4406 Mult(Amat, work2, work1);
4408 d_Winv_dx(d) = work2.
Trace();
4410 d_Winv_dx *= -weight_m;
4411 d_detW_dx += d_Winv_dx;
4422 for (
int d = 0; d <
dim; d++)
4427 dmudxw(d) = Prod.
Trace();
4471 else { elfun = d_el; }
4512 d_vals.
SetSize(nqp); d_vals = 1.0;
4529 for (
int q = 0; q < nqp; q++)
4555 for (
int i = 0; i < dof; i++)
4557 const real_t w_shape_i = weight_m * shape(i);
4558 for (
int j = 0; j < dof; j++)
4560 const real_t w = w_shape_i * shape(j);
4561 for (
int d1 = 0; d1 <
dim; d1++)
4563 for (
int d2 = 0; d2 <
dim; d2++)
4565 elmat(d1*dof + i, d2*dof + j) += w * hess(d1, d2);
4586 Vector shape(dof), adapt_lim_gf_e, adapt_lim_gf_q, adapt_lim_gf0_q(nqp);
4600 grad_phys.
Mult(adapt_lim_gf_e, grad_ptr);
4604 for (
int q = 0; q < nqp; q++)
4608 adapt_lim_gf_grad_e.
MultTranspose(shape, adapt_lim_gf_grad_q);
4609 adapt_lim_gf_grad_q *= 2.0 * (adapt_lim_gf_q(q) - adapt_lim_gf0_q(q));
4622 Vector shape(dof), adapt_lim_gf_e, adapt_lim_gf_q, adapt_lim_gf0_q(nqp);
4636 grad_phys.
Mult(adapt_lim_gf_e, grad_ptr);
4641 Mult(grad_phys, adapt_lim_gf_grad_e, adapt_lim_gf_hess_e);
4648 for (
int q = 0; q < nqp; q++)
4653 adapt_lim_gf_grad_e.
MultTranspose(shape, adapt_lim_gf_grad_q);
4658 for (
int i = 0; i < dof *
dim; i++)
4660 const int idof = i % dof, idim = i / dof;
4661 for (
int j = 0; j <= i; j++)
4663 const int jdof = j % dof, jdim = j / dof;
4665 w * ( 2.0 * adapt_lim_gf_grad_q(idim) * shape(idof) *
4666 adapt_lim_gf_grad_q(jdim) * shape(jdof) +
4667 2.0 * (adapt_lim_gf_q(q) - adapt_lim_gf0_q(q)) *
4668 adapt_lim_gf_hess_q(idim, jdim) * shape(idof) * shape(jdof));
4670 if (i != j) { mat(j, i) += entry; }
4692 for (
int s = 0; s < dof_s; s++)
4695 const int scalar_dof_id = fes_fit->
VDofToDof(vdofs[s]);
4696 count += ((*surf_fit_marker)[scalar_dof_id]) ? 1 : 0;
4698 if (count == 0) {
return; }
4718 grad_phys.
Mult(sigma_e, grad_ptr);
4725 for (
int s = 0; s < dof_s; s++)
4728 const int scalar_dof_id = fes_fit->
VDofToDof(vdofs[s]);
4740 for (
int d = 0; d <
dim; d++)
4742 pos(d) =
PMatI(s, d);
4743 pos_target(d) = (*surf_fit_pos)(vdofs[d*dof_s + s]);
4747 for (
int d = 0; d <
dim; d++) { surf_fit_grad_e(s, d) = grad_s(d); }
4750 for (
int d = 0; d <
dim; d++)
4752 mat(s, d) += w * surf_fit_grad_e(s, d);
4773 for (
int s = 0; s < dof_s; s++)
4776 const int scalar_dof_id = fes_fit->
VDofToDof(vdofs[s]);
4777 count += ((*surf_fit_marker)[scalar_dof_id]) ? 1 : 0;
4779 if (count == 0) {
return; }
4800 grad_phys.
Mult(sigma_e, grad_ptr);
4814 Mult(grad_phys, surf_fit_grad_e, surf_fit_hess_e);
4823 for (
int s = 0; s < dof_s; s++)
4826 const int scalar_dof_id = fes_fit->
VDofToDof(vdofs[s]);
4836 surf_fit_hess_e.
GetRow(s, gg_ptr);
4842 for (
int d = 0; d <
dim; d++)
4844 pos(d) =
PMatI(s, d);
4845 pos_target(d) = (*surf_fit_pos)(vdofs[d*dof_s + s]);
4850 for (
int d = 0; d <
dim; d++) { surf_fit_grad_e(s, d) = 0.0; }
4855 for (
int idim = 0; idim <
dim; idim++)
4857 for (
int jdim = 0; jdim <= idim; jdim++)
4859 real_t entry = w * ( surf_fit_grad_e(s, idim) *
4860 surf_fit_grad_e(s, jdim) +
4861 sigma_e(s) * surf_fit_hess_s(idim, jdim));
4863 int idx = s + idim*dof_s;
4864 int jdx = s + jdim*dof_s;
4865 mat(idx, jdx) += entry;
4866 if (idx != jdx) { mat(jdx, idx) += entry; }
4874 Vector &d_el,
const int dofidx,
4875 const int dir,
const real_t e_fx,
4879 int idx = dir*dof+dofidx;
4907 else { elfun = d_el; }
4927 for (
int j = 0; j <
dim; j++)
4929 for (
int i = 0; i < dof; i++)
4959 for (
int q = 0; q < nqp; q++)
4985 else { elfun = d_el; }
4997 for (
int i = 0; i < dof; i++)
4999 for (
int j = 0; j < i+1; j++)
5001 for (
int k1 = 0; k1 <
dim; k1++)
5003 for (
int k2 = 0; k2 <
dim; k2++)
5005 d_el_mod(k2 * dof + j) +=
fd_h;
5032 real_t e_fx = ElemPertLoc(k2 * dof + j);
5035 d_el_mod(k2 * dof + j) -=
fd_h;
5036 real_t e_fpx = ElemDerLoc(k1*dof+i);
5038 elmat(k1*dof+i, k2*dof+j) = (e_fpxph - e_fpx) /
fd_h;
5039 elmat(k2*dof+j, k1*dof+i) = (e_fpxph - e_fpx) /
fd_h;
5069 for (
int q = 0; q < nqp; q++)
5088 MFEM_VERIFY(cf,
"Dynamic weight works only with a ConstantCoefficient.");
5089 cf->constant *= factor;
5098 MFEM_VERIFY(cf,
"Dynamic weight works only with a ConstantCoefficient.");
5099 return cf->constant;
5131 real_t &surf_fit_gf_energy)
5142 metric_energy = 0.0;
5144 surf_fit_gf_energy = 0.0;
5145 for (
int i = 0; i <
fes->
GetNE(); i++)
5151 const int dof = fe->
GetDof();
5160 for (
int q = 0; q < nqp; q++)
5173 lim_energy += weight;
5183 for (
int s = 0; s < dofs.
Size(); s++)
5187 surf_fit_gf_energy += sigma_e(s) * sigma_e(s);
5214 fd_h = std::numeric_limits<float>::max();
5217 real_t detv_avg_min = std::numeric_limits<float>::max();
5218 for (
int i = 0; i < NE; i++)
5223 for (
int j = 0; j < nsp; j++)
5227 detv_sum += std::fabs(
Jpr.
Det());
5229 real_t detv_avg = pow(detv_sum/nsp, 1./
dim);
5230 detv_avg_min = std::min(detv_avg, detv_avg_min);
5238 MFEM_VERIFY(
periodic ==
false,
"Periodic not implemented yet.");
5247 const int total_cnt = new_x.
Size()/
dim;
5249 if (new_x_ordering == 0)
5251 for (
int d = 0; d <
dim; d++)
5253 for (
int i = 0; i < cnt; i++)
5256 new_x_sorted(i + d*cnt) = new_x(dof_index + d*total_cnt);
5262 for (
int i = 0; i < cnt; i++)
5265 for (
int d = 0; d <
dim; d++)
5267 new_x_sorted(d + i*
dim) = new_x(d + dof_index*
dim);
5273 Vector surf_fit_gf_int, surf_fit_grad_int, surf_fit_hess_int;
5276 for (
int i = 0; i < cnt; i++)
5279 (*surf_fit_gf)[dof_index] = surf_fit_gf_int(i);
5291 for (
int d = 0; d < grad_dim; d++)
5293 for (
int i = 0; i < cnt; i++)
5296 (*surf_fit_grad)[dof_index + d*grad_cnt] =
5297 surf_fit_grad_int(i + d*cnt);
5303 for (
int i = 0; i < cnt; i++)
5306 for (
int d = 0; d < grad_dim; d++)
5308 (*surf_fit_grad)[dof_index*grad_dim + d] =
5309 surf_fit_grad_int(i*grad_dim + d);
5323 for (
int d = 0; d < hess_dim; d++)
5325 for (
int i = 0; i < cnt; i++)
5328 (*surf_fit_hess)[dof_index + d*hess_cnt] =
5329 surf_fit_hess_int(i + d*cnt);
5335 for (
int i = 0; i < cnt; i++)
5338 for (
int d = 0; d < hess_dim; d++)
5340 (*surf_fit_hess)[dof_index*hess_dim + d] =
5341 surf_fit_hess_int(i*hess_dim + d);
5366 if (
discr_tc) {
PA.Jtr_needs_update =
true; }
5392 if (
periodic) { MFEM_ABORT(
"Periodic not implemented yet."); }
5414 if (
periodic) { MFEM_ABORT(
"Periodic not implemented yet."); }
5440 MFEM_VERIFY(per ==
false,
"FD is not supported for periodic meshes.");
5444#ifdef MFEM_USE_GSLIB
5448 MFEM_ABORT(
"Using GSLIB-based interpolation with finite differences"
5449 "requires careful consideration. Contact TMOP team.");
5467 MFEM_VERIFY(per ==
false,
"FD is not supported for periodic meshes.");
5471#ifdef MFEM_USE_GSLIB
5475 MFEM_ABORT(
"Using GSLIB-based interpolation with finite differences"
5476 "requires careful consideration. Contact TMOP team.");
5491 real_t min_detT = std::numeric_limits<real_t>::infinity();
5499 for (
int i = 0; i < NE; i++)
5515 for (
int q = 0; q < nsp; q++)
5524 min_detT = std::min(min_detT, detT);
5533 real_t max_muT = -std::numeric_limits<real_t>::infinity();
5550 for (
int i = 0; i < NE; i++)
5569 for (
int q = 0; q < nsp; q++)
5586 max_muT = std::max(max_muT, metric_val);
5598 if (!wcuo) {
return; }
5600 if (
periodic) { MFEM_ABORT(
"Periodic not implemented yet."); }
5618 real_t min_detT_all = min_detT;
5622 MPI_Allreduce(&min_detT, &min_detT_all, 1,
5626 if (wcuo) { wcuo->
SetMinDetT(min_detT_all); }
5630 real_t max_muT_all = max_muT;
5646 MFEM_VERIFY(
tmopi.Size() > 0,
"No TMOP_Integrators were added.");
5648 tmopi[0]->EnableLimiting(n0, dist, w0, lfunc);
5649 for (
int i = 1; i <
tmopi.Size(); i++) {
tmopi[i]->DisableLimiting(); }
5656 MFEM_VERIFY(
tmopi.Size() > 0,
"No TMOP_Integrators were added.");
5658 tmopi[0]->EnableLimiting(n0, w0, lfunc);
5659 for (
int i = 1; i <
tmopi.Size(); i++) {
tmopi[i]->DisableLimiting(); }
5664 MFEM_VERIFY(
tmopi.Size() > 0,
"No TMOP_Integrators were added.");
5666 tmopi[0]->SetLimitingNodes(n0);
5667 for (
int i = 1; i <
tmopi.Size(); i++) {
tmopi[i]->DisableLimiting(); }
5675 for (
int i = 0; i <
tmopi.Size(); i++)
5677 energy +=
tmopi[i]->GetElementEnergy(el, T, elfun);
5687 MFEM_VERIFY(
tmopi.Size() > 0,
"No TMOP_Integrators were added.");
5689 tmopi[0]->AssembleElementVector(el, T, elfun, elvect);
5690 for (
int i = 1; i <
tmopi.Size(); i++)
5693 tmopi[i]->AssembleElementVector(el, T, elfun, elvect_i);
5703 MFEM_VERIFY(
tmopi.Size() > 0,
"No TMOP_Integrators were added.");
5705 tmopi[0]->AssembleElementGrad(el, T, elfun, elmat);
5706 for (
int i = 1; i <
tmopi.Size(); i++)
5709 tmopi[i]->AssembleElementGrad(el, T, elfun, elmat_i);
5720 for (
int i = 0; i <
tmopi.Size(); i++)
5722 energy +=
tmopi[i]->GetRefinementElementEnergy(el, T, elfun, irule);
5733 for (
int i = 0; i <
tmopi.Size(); i++)
5735 energy +=
tmopi[i]->GetDerefinementElementEnergy(el, T, elfun);
5743 real_t total_integral = 0.0;
5744 for (
int i = 0; i < cnt; i++)
5746 tmopi[i]->EnableNormalization(x);
5747 total_integral += 1.0 /
tmopi[i]->metric_normal;
5749 for (
int i = 0; i < cnt; i++)
5751 tmopi[i]->metric_normal = 1.0 / total_integral;
5758 const int cnt =
tmopi.Size();
5759 real_t total_integral = 0.0;
5760 for (
int i = 0; i < cnt; i++)
5762 tmopi[i]->ParEnableNormalization(x);
5763 total_integral += 1.0 /
tmopi[i]->metric_normal;
5765 for (
int i = 0; i < cnt; i++)
5767 tmopi[i]->metric_normal = 1.0 / total_integral;
5774 for (
int i = 0; i <
tmopi.Size(); i++)
5776 tmopi[i]->AssemblePA(fes);
5783 for (
int i = 0; i <
tmopi.Size(); i++)
5785 tmopi[i]->AssembleGradPA(xe,fes);
5791 for (
int i = 0; i <
tmopi.Size(); i++)
5793 tmopi[i]->AssembleGradDiagonalPA(de);
5799 for (
int i = 0; i <
tmopi.Size(); i++)
5801 tmopi[i]->AddMultPA(xe, ye);
5807 for (
int i = 0; i <
tmopi.Size(); i++)
5809 tmopi[i]->AddMultGradPA(re, ce);
5816 for (
int i = 0; i <
tmopi.Size(); i++)
5818 energy +=
tmopi[i]->GetLocalStateEnergyPA(xe);
5827 const int NE = mesh.
GetNE();
5835 for (
int i = 0; i < NE; i++)
5846 nodes.FESpace()->GetElementVDofs(i, pos_dofs);
5847 nodes.GetSubVector(pos_dofs, posV);
5852 for (
int j = 0; j < nsp; j++)
5863 metric_gf(gf_dofs[j]) = metric.
EvalW(T);
virtual ~AdaptivityEvaluator()
virtual void SetNewFieldFESpace(const FiniteElementSpace &fes)=0
virtual void SetInitialField(const Vector &init_nodes, const Vector &init_field)=0
virtual void ComputeAtGivenPositions(const Vector &positions, Vector &values, int p_ordering=Ordering::byNODES)=0
Using the source mesh and field given by SetInitialField(), compute corresponding values at specified...
void SetSerialMetaInfo(const Mesh &m, const FiniteElementSpace &f)
void SetParMetaInfo(const ParMesh &m, const ParFiniteElementSpace &f)
Parallel version of SetSerialMetaInfo.
void ClearGeometricFactors()
virtual void ComputeAtNewPosition(const Vector &new_mesh_nodes, Vector &new_field, int nodes_ordering=Ordering::byNODES)=0
Perform field transfer between the original and a new mesh. The source mesh and field are given by Se...
ParFiniteElementSpace * pfes
Coefficient * scalar_tspec
virtual void SetAnalyticTargetSpec(Coefficient *sspec, VectorCoefficient *vspec, TMOPMatrixCoefficient *mspec)
TMOPMatrixCoefficient * matrix_tspec
VectorCoefficient * vector_tspec
void ComputeElementTargets(int e_id, const FiniteElement &fe, const IntegrationRule &ir, const Vector &elfun, DenseTensor &Jtr) const override
Given an element and quadrature rule, computes ref->target transformation Jacobians for each quadratu...
void ComputeElementTargetsGradient(const IntegrationRule &ir, const Vector &elfun, IsoparametricTransformation &Tpr, DenseTensor &dJtr) const override
void SetSize(int nsize)
Change the logical size of the array, keep existing entries.
int Size() const
Return the logical size of the array.
int Append(const T &el)
Append element 'el' to array, resize if necessary.
Base class Coefficients that optionally depend on space and time. These are used by the BilinearFormI...
virtual real_t Eval(ElementTransformation &T, const IntegrationPoint &ip)=0
Evaluate the coefficient in the element described by T at the point ip.
A coefficient that is constant across space and time.
Data type dense matrix using column-major storage.
void Mult(const real_t *x, real_t *y) const
Matrix vector multiplication.
void Set(real_t alpha, const real_t *A)
Set the matrix to alpha * A, assuming that A has the same dimensions as the matrix and uses column-ma...
void MultTranspose(const real_t *x, real_t *y) const
Multiply a vector with the transpose matrix.
void Transpose()
(*this) = (*this)^t
real_t * Data() const
Returns the matrix data array.
real_t * GetData() const
Returns the matrix data array.
void SetSize(int s)
Change the size of the DenseMatrix to s x s.
real_t Trace() const
Trace of a square matrix.
real_t & Elem(int i, int j) override
Returns reference to a_{ij}.
void UseExternalData(real_t *d, int h, int w)
Change the data array and the size of the DenseMatrix.
void Add(const real_t c, const DenseMatrix &A)
Adds the matrix A multiplied by the number c to the matrix.
void GetColumn(int c, Vector &col) const
int Size() const
For backward compatibility define Size to be synonym of Width()
real_t FNorm2() const
Compute the square of the Frobenius norm of the matrix.
void GetRow(int r, Vector &row) const
Rank 3 tensor (array of matrices)
real_t * HostWrite()
Shortcut for mfem::Write(GetMemory(), TotalSize(), false).
void SetSize(int i, int j, int k, MemoryType mt_=MemoryType::PRESERVE)
void UseExternalData(real_t *ext_data, int i, int j, int k)
static MemoryType GetMemoryType()
(DEPRECATED) Equivalent to GetDeviceMemoryType().
const Vector & GetTspecPert1H()
void UpdateTargetSpecification(const Vector &new_x, bool reuse_flag=false, int new_x_ordering=Ordering::byNODES)
virtual void SetSerialDiscreteTargetSkew(const GridFunction &tspec_)
virtual void SetParDiscreteTargetAspectRatio(const ParGridFunction &tspec_)
ParGridFunction * tspec_pgf
virtual void SetSerialDiscreteTargetAspectRatio(const GridFunction &tspec_)
const AdaptivityEvaluator * GetAdaptivityEvaluator() const
void SetTspecDataForDerefinement(FiniteElementSpace *fes)
Computes target specification data with respect to the coarse FE space.
const Vector & GetTspecPertMixH()
void ComputeElementTargetsGradient(const IntegrationRule &ir, const Vector &elfun, IsoparametricTransformation &Tpr, DenseTensor &dJtr) const override
virtual void SetParDiscreteTargetSpec(const ParGridFunction &tspec_)
AdaptivityEvaluator * adapt_eval
void FinalizeSerialDiscreteTargetSpec(const GridFunction &tspec_)
void FinalizeParDiscreteTargetSpec(const ParGridFunction &tspec_)
ParFiniteElementSpace * ptspec_fesv
FiniteElementSpace * coarse_tspec_fesv
virtual ~DiscreteAdaptTC()
virtual void SetSerialDiscreteTargetSize(const GridFunction &tspec_)
virtual void SetParDiscreteTargetSize(const ParGridFunction &tspec_)
const Vector & GetTspecPert2H()
void ComputeElementTargets(int e_id, const FiniteElement &fe, const IntegrationRule &ir, const Vector &elfun, DenseTensor &Jtr) const override
Given an element and quadrature rule, computes ref->target transformation Jacobians for each quadratu...
void UpdateAfterMeshTopologyChange()
Update all discrete fields based on tspec and update for AMR.
virtual void SetSerialDiscreteTargetSpec(const GridFunction &tspec_)
virtual void SetParDiscreteTargetOrientation(const ParGridFunction &tspec_)
void ResetRefinementTspecData()
virtual void SetParDiscreteTargetSkew(const ParGridFunction &tspec_)
void ParUpdateAfterMeshTopologyChange()
void UpdateTargetSpecificationAtNode(const FiniteElement &el, ElementTransformation &T, int nodenum, int idir, const Vector &IntData)
void RestoreTargetSpecificationAtNode(ElementTransformation &T, int nodenum)
FiniteElementSpace * tspec_fesv
virtual void SetSerialDiscreteTargetOrientation(const GridFunction &tspec_)
void SetTspecAtIndex(int idx, const GridFunction &tspec_)
void SetRefinementSubElement(int amr_el_)
void GetDiscreteTargetSpec(GridFunction &tspec_, int idx)
Get one of the discrete fields from tspec.
void UpdateHessianTargetSpecification(const Vector &x, real_t dx, bool reuse_flag=false, int x_ordering=Ordering::byNODES)
void SetDiscreteTargetBase(const GridFunction &tspec_)
void UpdateGradientTargetSpecification(const Vector &x, real_t dx, bool reuse_flag=false, int x_ordering=Ordering::byNODES)
void SetTspecFromIntRule(int e_id, const IntegrationRule &intrule)
int GetOrder() const
Return the order (polynomial degree) of the FE collection, corresponding to the order/degree returned...
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
bool IsVariableOrder() const
Returns true if the space contains elements of varying polynomial orders.
DofTransformation * GetElementDofs(int elem, Array< int > &dofs) const
Returns indices of degrees of freedom of element 'elem'. The returned indices are offsets into an ldo...
int GetNDofs() const
Returns number of degrees of freedom. This is the number of Local Degrees of Freedom.
int VDofToDof(int vdof) const
Compute the inverse of the Dof to VDof mapping for a single index vdof.
DofTransformation * GetElementVDofs(int i, Array< int > &vdofs) const
Returns indices of degrees of freedom for the i'th element. The returned indices are offsets into an ...
virtual const FiniteElement * GetFE(int i) const
Returns pointer to the FiniteElement in the FiniteElementCollection associated with i'th element in t...
Ordering::Type GetOrdering() const
Return the ordering method.
int GetNE() const
Returns number of elements in the mesh.
const ElementRestrictionOperator * GetElementRestriction(ElementDofOrdering e_ordering) const
Return an Operator that converts L-vectors to E-vectors.
virtual void Update(bool want_transform=true)
Reflect changes in the mesh: update number of DOFs, etc. Also, calculate GridFunction transformation ...
const FiniteElementCollection * FEColl() const
Mesh * GetMesh() const
Returns the mesh.
int GetVSize() const
Return the number of vector dofs, i.e. GetNDofs() x GetVDim().
int GetVDim() const
Returns the vector dimension of the finite element space.
bool IsDGSpace() const
Return whether or not the space is discontinuous (L2)
const FiniteElement * GetTypicalFE() const
Return GetFE(0) if the local mesh is not empty; otherwise return a typical FE based on the Geometry t...
const Operator * GetUpdateOperator()
Get the GridFunction update operator.
Abstract class for all finite elements.
int GetOrder() const
Returns the order of the finite element. In the case of anisotropic orders, returns the maximum order...
virtual void ProjectGrad(const FiniteElement &fe, ElementTransformation &Trans, DenseMatrix &grad) const
Compute the discrete gradient matrix from the given FiniteElement onto 'this' FiniteElement....
int GetDim() const
Returns the reference space dimension for the finite element.
const IntegrationRule & GetNodes() const
Get a const reference to the nodes of the element.
virtual void CalcDShape(const IntegrationPoint &ip, DenseMatrix &dshape) const =0
Evaluate the gradients of all shape functions of a scalar finite element in reference space at the gi...
Geometry::Type GetGeomType() const
Returns the Geometry::Type of the reference element.
virtual void CalcShape(const IntegrationPoint &ip, Vector &shape) const =0
Evaluate the values of all shape functions of a scalar finite element in reference space at the given...
int GetDof() const
Returns the number of degrees of freedom in the finite element.
const DenseMatrix & GetGeomToPerfGeomJac(int GeomType) const
Class for grid function - Vector with associated FE space.
virtual void CountElementsPerVDof(Array< int > &elem_per_vdof) const
For each vdof, counts how many elements contain the vdof, as containment is determined by FiniteEleme...
void GetValues(int i, const IntegrationRule &ir, Vector &vals, int vdim=1) const
virtual void Update()
Transform by the Space UpdateMatrix (e.g., on Mesh change).
void MakeOwner(FiniteElementCollection *fec_)
Make the GridFunction the owner of fec_owned and fes.
virtual void GetElementDofValues(int el, Vector &dof_vals) const
FiniteElementSpace * FESpace()
int VectorDim() const
Shortcut for calling FiniteElementSpace::GetVectorDim() on the underlying fes.
void GetVectorValues(int i, const IntegrationRule &ir, DenseMatrix &vals, DenseMatrix &tr) const
Arbitrary order H1-conforming (continuous) finite elements.
Class for integration point with weight.
Class for an integration rule - an Array of IntegrationPoint.
int GetNPoints() const
Returns the number of the points in the integration rule.
IntegrationPoint & IntPoint(int i)
Returns a reference to the i-th integration point.
const IntegrationRule & Get(int GeomType, int Order)
Returns an integration rule for given GeomType and Order.
const scalar_t * Get_dI1b()
void Assemble_ddI1(scalar_t w, scalar_t *A)
void SetJacobian(const scalar_t *Jac)
The Jacobian should use column-major storage.
void Assemble_ddI1b(scalar_t w, scalar_t *A)
const scalar_t * Get_dI2()
void SetDerivativeMatrix(int height, const scalar_t *Deriv)
The Deriv matrix is dof x 2, using column-major storage.
void Assemble_ddI2b(scalar_t w, scalar_t *A)
const scalar_t * Get_dI2b()
void Assemble_TProd(scalar_t w, const scalar_t *X, const scalar_t *Y, scalar_t *A)
void Assemble_ddI2(scalar_t w, scalar_t *A)
const scalar_t * Get_dI1()
void SetJacobian(const scalar_t *Jac)
The Jacobian should use column-major storage.
const scalar_t * Get_dI2()
const scalar_t * Get_dI2b()
const scalar_t * Get_dI3()
void Assemble_TProd(scalar_t w, const scalar_t *X, const scalar_t *Y, scalar_t *A)
const scalar_t * Get_dI1()
void SetDerivativeMatrix(int height, const scalar_t *Deriv)
The Deriv matrix is dof x 3, using column-major storage.
const scalar_t * Get_dI3b()
void Assemble_ddI1(scalar_t w, scalar_t *A)
void Assemble_ddI2(scalar_t w, scalar_t *A)
const scalar_t * Get_dI1b()
void Assemble_ddI3(scalar_t w, scalar_t *A)
void Assemble_ddI2b(scalar_t w, scalar_t *A)
void Assemble_ddI3b(scalar_t w, scalar_t *A)
void Assemble_ddI1b(scalar_t w, scalar_t *A)
virtual void Eval(DenseMatrix &K, ElementTransformation &T, const IntegrationPoint &ip)=0
Evaluate the matrix coefficient in the element described by T at the point ip, storing the result in ...
int GetNE() const
Returns number of elements.
int Dimension() const
Dimension of the reference space used within the elements.
void GetElementTransformation(int i, IsoparametricTransformation *ElTr) const
Builds the transformation defining the i-th element in ElTr. ElTr must be allocated in advance and wi...
void GetNodes(Vector &node_coord) const
NCMesh * ncmesh
Optional nonconforming mesh extension.
int GetNumGeometries(int dim) const
Return the number of geometries of the given dimension present in the mesh.
Geometry::Type GetElementBaseGeometry(int i) const
void DeleteGeometricFactors()
Destroy all GeometricFactors stored by the Mesh.
A class for non-conforming AMR. The class is not used directly by the user, rather it is an extension...
int GetElementSizeReduction(int i) const
int GetNumRootElements()
Return the number of root elements.
Class for standard nodal finite elements.
void ReorderLexToNative(int ncomp, Vector &dofs) const
int Height() const
Get the height (size of output) of the Operator. Synonym with NumRows().
virtual void Mult(const Vector &x, Vector &y) const =0
Operator application: y=A(x).
int NumCols() const
Get the number of columns (size of input) of the Operator. Synonym with Width().
int Width() const
Get the width (size of input) of the Operator. Synonym with NumCols().
Abstract parallel finite element space.
ParMesh * GetParMesh() const
void Update(bool want_transform=true) override
Class for parallel grid function.
void CountElementsPerVDof(Array< int > &elem_per_vdof) const override
For each vdof, counts how many elements contain the vdof, as containment is determined by FiniteEleme...
void GetDerivative(int comp, int der_comp, ParGridFunction &der) const
Parallel version of GridFunction::GetDerivative(); see its documentation.
ParFiniteElementSpace * ParFESpace() const
void Update() override
Transform by the Space UpdateMatrix (e.g., on Mesh change).
Class for parallel meshes.
virtual real_t GetDerefinementElementEnergy(const FiniteElement &el, ElementTransformation &T, const Vector &elfun)
void AssembleGradPA(const Vector &, const FiniteElementSpace &) override
Prepare the integrator for partial assembly (PA) gradient evaluations on the given FE space fes at th...
void AssembleGradDiagonalPA(Vector &) const override
Method for computing the diagonal of the gradient with partial assembly.
real_t GetLocalStateEnergyPA(const Vector &) const override
Compute the local (to the MPI rank) energy with partial assembly.
void AddMultPA(const Vector &, Vector &) const override
Method for partially assembled action.
void ParEnableNormalization(const ParGridFunction &x)
void EnableLimiting(const GridFunction &n0, const GridFunction &dist, Coefficient &w0, TMOP_LimiterFunction *lfunc=NULL)
Adds the limiting term to the first integrator. Disables it for the rest.
void AssembleElementGrad(const FiniteElement &el, ElementTransformation &T, const Vector &elfun, DenseMatrix &elmat) override
Assemble the local gradient matrix.
real_t GetElementEnergy(const FiniteElement &el, ElementTransformation &T, const Vector &elfun) override
Compute the local energy.
void AddMultGradPA(const Vector &, Vector &) const override
Method for partially assembled gradient action.
virtual real_t GetRefinementElementEnergy(const FiniteElement &el, ElementTransformation &T, const Vector &elfun, const IntegrationRule &irule)
void AssemblePA(const FiniteElementSpace &) override
Method defining partial assembly.
Array< TMOP_Integrator * > tmopi
void AssembleElementVector(const FiniteElement &el, ElementTransformation &T, const Vector &elfun, Vector &elvect) override
Perform the local action of the NonlinearFormIntegrator.
void EnableNormalization(const GridFunction &x)
Normalization factor that considers all integrators in the combination.
void SetLimitingNodes(const GridFunction &n0)
Update the original/reference nodes used for limiting.
virtual void EvalGrad(DenseMatrix &K, ElementTransformation &T, const IntegrationPoint &ip, int comp)=0
Evaluate the derivative of the matrix coefficient with respect to comp in the element described by T ...
real_t EvalWMatrixForm(const DenseMatrix &Jpt) const override
Evaluates the metric in matrix form (opposed to invariant form). Used for validating the invariant ev...
void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const real_t weight, DenseMatrix &A) const override
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
void EvalPW(const DenseMatrix &Jpt, DenseMatrix &PW) const override
void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const override
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const override
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const real_t weight, DenseMatrix &A) const override
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
void EvalPW(const DenseMatrix &Jpt, DenseMatrix &PW) const override
real_t EvalWMatrixForm(const DenseMatrix &Jpt) const override
Evaluates the metric in matrix form (opposed to invariant form). Used for validating the invariant ev...
real_t EvalWMatrixForm(const DenseMatrix &Jpt) const override
Evaluates the metric in matrix form (opposed to invariant form). Used for validating the invariant ev...
void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const real_t weight, DenseMatrix &A) const override
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const override
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
void EvalPW(const DenseMatrix &Jpt, DenseMatrix &PW) const override
void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const override
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const real_t weight, DenseMatrix &A) const override
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
real_t EvalWMatrixForm(const DenseMatrix &Jpt) const override
Evaluates the metric in matrix form (opposed to invariant form). Used for validating the invariant ev...
void EvalPW(const DenseMatrix &Jpt, DenseMatrix &PW) const override
void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const override
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
real_t EvalWMatrixForm(const DenseMatrix &Jpt) const override
Evaluates the metric in matrix form (opposed to invariant form). Used for validating the invariant ev...
void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const real_t weight, DenseMatrix &A) const override
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
void EvalPW(const DenseMatrix &Jpt, DenseMatrix &PW) const override
real_t EvalWMatrixForm(const DenseMatrix &Jpt) const override
Evaluates the metric in matrix form (opposed to invariant form). Used for validating the invariant ev...
void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const override
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const real_t weight, DenseMatrix &A) const override
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
void EvalPW(const DenseMatrix &Jpt, DenseMatrix &PW) const override
void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const real_t weight, DenseMatrix &A) const override
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
void ComputeAvgMetrics(const GridFunction &nodes, const TargetConstructor &tc, Vector &averages) const
real_t EvalW(const DenseMatrix &Jpt) const override
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants,...
void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const override
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
Array< TMOP_QualityMetric * > tmop_q_arr
real_t EvalWMatrixForm(const DenseMatrix &Jpt) const override
Evaluates the metric in matrix form (opposed to invariant form). Used for validating the invariant ev...
void EvalPW(const DenseMatrix &Jpt, DenseMatrix &P) const override
void ComputeBalancedWeights(const GridFunction &nodes, const TargetConstructor &tc, Vector &weights) const
real_t ComputeUntanglerMaxMuBarrier(const Vector &x, const FiniteElementSpace &fes)
void UpdateAfterMeshPositionChange(const Vector &d, const FiniteElementSpace &d_fes)
void AssembleElemVecAdaptLim(const FiniteElement &el, IsoparametricTransformation &Tpr, const IntegrationRule &ir, const Vector &weights, DenseMatrix &mat)
void AssembleElemGradAdaptLim(const FiniteElement &el, IsoparametricTransformation &Tpr, const IntegrationRule &ir, const Vector &weights, DenseMatrix &m)
TMOP_LimiterFunction * lim_func
void ParUpdateAfterMeshTopologyChange()
TMOP_QualityMetric * metric
const ParGridFunction * adapt_lim_pgf0
void GetSurfaceFittingErrors(const Vector &d_loc, real_t &err_avg, real_t &err_max)
real_t ComputeMinDetT(const Vector &x, const FiniteElementSpace &fes)
AdaptivityEvaluator * surf_fit_eval
void EnableNormalization(const GridFunction &x)
Computes the normalization factors of the metric and limiting integrals using the mesh position given...
void ComputeMinJac(const Vector &x, const FiniteElementSpace &fes)
void AssembleElementVectorExact(const FiniteElement &el, ElementTransformation &T, const Vector &d_el, Vector &elvect)
TMOP_QualityMetric * h_metric
void AssembleElementGradFD(const FiniteElement &el, ElementTransformation &T, const Vector &d_el, DenseMatrix &elmat)
DiscreteAdaptTC * discr_tc
GridFunction * surf_fit_gf
const GridFunction * lim_dist
Array< Vector * > ElemPertEnergy
const GridFunction * adapt_lim_gf0
void ComputeUntangleMetricQuantiles(const Vector &d, const FiniteElementSpace &fes)
void EnableSurfaceFittingFromSource(const ParGridFunction &s_bg, ParGridFunction &s0, const Array< bool > &smarker, Coefficient &coeff, AdaptivityEvaluator &ae, const ParGridFunction &s_bg_grad, ParGridFunction &s0_grad, AdaptivityEvaluator &age, const ParGridFunction &s_bg_hess, ParGridFunction &s0_hess, AdaptivityEvaluator &ahe)
Fitting of certain DOFs in the current mesh to the zero level set of a function defined on another (f...
const TargetConstructor * targetC
void ComputeNormalizationEnergies(const GridFunction &x, real_t &metric_energy, real_t &lim_energy, real_t &surf_fit_gf_energy)
AdaptivityEvaluator * surf_fit_eval_grad
const GridFunction * lim_nodes0
const IntegrationRule * ir
TMOP_QuadraticLimiter * surf_fit_limiter
void EnableFiniteDifferences(const GridFunction &x)
Enables FD-based approximation and computes dx.
virtual real_t GetRefinementElementEnergy(const FiniteElement &el, ElementTransformation &T, const Vector &elfun, const IntegrationRule &irule)
Computes the mean of the energies of the given element's children.
real_t GetSurfaceFittingWeight()
Get the surface fitting weight.
void SetInitialMeshPos(const GridFunction *x0)
const GridFunction * surf_fit_pos
Array< int > surf_fit_marker_dof_index
void ParEnableNormalization(const ParGridFunction &x)
real_t GetElementEnergy(const FiniteElement &el, ElementTransformation &T, const Vector &d_el) override
Computes the integral of W(Jacobian(Trt)) over a target zone.
Coefficient * adapt_lim_coeff
const FiniteElementSpace * fes
const IntegrationRule & EnergyIntegrationRule(const FiniteElement &el) const
GridFunction * surf_fit_grad
GridFunction * surf_fit_hess
void ReleasePADeviceMemory(bool copy_to_host=true)
virtual real_t GetDerefinementElementEnergy(const FiniteElement &el, ElementTransformation &T, const Vector &elfun)
void AssembleElementGrad(const FiniteElement &el, ElementTransformation &T, const Vector &d_el, DenseMatrix &elmat) override
Second derivative of GetElementEnergy() w.r.t. each local H1 DOF.
void AssembleElementVectorFD(const FiniteElement &el, ElementTransformation &T, const Vector &d_el, Vector &elvect)
const IntegrationRule & GradientIntegrationRule(const FiniteElement &el) const
void EnableAdaptiveLimiting(const GridFunction &z0, Coefficient &coeff, AdaptivityEvaluator &ae)
Restriction of the node positions to certain regions.
struct mfem::TMOP_Integrator::@26 PA
AdaptivityEvaluator * surf_fit_eval_hess
Coefficient * metric_coeff
GridFunction * adapt_lim_gf
real_t GetFDDerivative(const FiniteElement &el, ElementTransformation &T, Vector &d_el, const int nodenum, const int idir, const real_t baseenergy, bool update_stored)
void UpdateAfterMeshTopologyChange()
void RemapSurfaceFittingLevelSetAtNodes(const Vector &new_x, int new_x_ordering)
void UpdateCoefficientsPA(const Vector &d_loc)
Coefficient * surf_fit_coeff
Array< int > surf_fit_dof_count
void AssembleElementGradExact(const FiniteElement &el, ElementTransformation &T, const Vector &d_el, DenseMatrix &elmat)
void EnableSurfaceFitting(const GridFunction &s0, const Array< bool > &smarker, Coefficient &coeff, AdaptivityEvaluator &ae)
Fitting of certain DOFs to the zero level set of a function.
void AssembleElemGradSurfFit(const FiniteElement &el_x, IsoparametricTransformation &Tpr, DenseMatrix &mat)
void AssembleElementVector(const FiniteElement &el, ElementTransformation &T, const Vector &d_el, Vector &elvect) override
First defivative of GetElementEnergy() w.r.t. each local H1 DOF.
void UpdateSurfaceFittingWeight(real_t factor)
Update the surface fitting weight as surf_fit_coeff *= factor;.
Array< Vector * > ElemDer
const Array< bool > * surf_fit_marker
const IntegrationRule & ActionIntegrationRule(const FiniteElement &el) const
AdaptivityEvaluator * adapt_lim_eval
void ComputeFDh(const Vector &d, const FiniteElementSpace &fes)
Determines the perturbation, h, for FD-based approximation.
void AssembleElemVecSurfFit(const FiniteElement &el_x, IsoparametricTransformation &Tpr, DenseMatrix &mat)
void EnableLimiting(const GridFunction &n0, const GridFunction &dist, Coefficient &w0, TMOP_LimiterFunction *lfunc=NULL)
Limiting of the mesh displacements (general version).
Base class for limiting functions to be used in class TMOP_Integrator.
virtual real_t Eval(const Vector &x, const Vector &x0, real_t d) const =0
Returns the limiting function, f(x, x0, d).
virtual void Eval_d1(const Vector &x, const Vector &x0, real_t dist, Vector &d1) const =0
Returns the gradient of the limiting function f(x, x0, d) with respect to x.
virtual void Eval_d2(const Vector &x, const Vector &x0, real_t dist, DenseMatrix &d2) const =0
Returns the Hessian of the limiting function f(x, x0, d) with respect to x.
void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const real_t weight, DenseMatrix &A) const override
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
InvariantsEvaluator2D< real_t > ie
void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const override
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
real_t EvalW(const DenseMatrix &Jpt) const override
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants,...
void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const real_t weight, DenseMatrix &A) const override
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
InvariantsEvaluator2D< real_t > ie
real_t EvalW(const DenseMatrix &Jpt) const override
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants,...
real_t EvalWMatrixForm(const DenseMatrix &Jpt) const override
Evaluates the metric in matrix form (opposed to invariant form). Used for validating the invariant ev...
void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const override
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
real_t EvalW(const DenseMatrix &Jpt) const override
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants,...
void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const override
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
InvariantsEvaluator2D< real_t > ie
void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const real_t weight, DenseMatrix &A) const override
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const real_t weight, DenseMatrix &A) const override
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
real_t EvalW(const DenseMatrix &Jpt) const override
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants,...
void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const override
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
InvariantsEvaluator2D< real_t > ie
void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const real_t weight, DenseMatrix &A) const override
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
real_t EvalW(const DenseMatrix &Jpt) const override
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants,...
InvariantsEvaluator2D< real_t > ie
void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const override
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
real_t EvalW(const DenseMatrix &Jpt) const override
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants,...
InvariantsEvaluator2D< real_t > ie
real_t EvalWMatrixForm(const DenseMatrix &Jpt) const override
Evaluates the metric in matrix form (opposed to invariant form). Used for validating the invariant ev...
void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const real_t weight, DenseMatrix &A) const override
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const override
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const override
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
InvariantsEvaluator2D< real_t > ie
void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const real_t weight, DenseMatrix &A) const override
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
real_t EvalW(const DenseMatrix &Jpt) const override
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants,...
InvariantsEvaluator2D< real_t > ie
void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const override
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
real_t EvalW(const DenseMatrix &Jpt) const override
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants,...
real_t EvalWMatrixForm(const DenseMatrix &Jpt) const override
Evaluates the metric in matrix form (opposed to invariant form). Used for validating the invariant ev...
void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const real_t weight, DenseMatrix &A) const override
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
real_t EvalW(const DenseMatrix &Jpt) const override
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants,...
InvariantsEvaluator2D< real_t > ie
void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const real_t weight, DenseMatrix &A) const override
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const override
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const real_t weight, DenseMatrix &A) const override
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
real_t EvalWMatrixForm(const DenseMatrix &Jpt) const override
Evaluates the metric in matrix form (opposed to invariant form). Used for validating the invariant ev...
InvariantsEvaluator2D< real_t > ie
void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const override
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
real_t EvalW(const DenseMatrix &Jpt) const override
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants,...
real_t EvalW(const DenseMatrix &Jpt) const override
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants,...
void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const override
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
InvariantsEvaluator2D< real_t > ie
void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const real_t weight, DenseMatrix &A) const override
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
real_t EvalWMatrixForm(const DenseMatrix &Jpt) const override
Evaluates the metric in matrix form (opposed to invariant form). Used for validating the invariant ev...
InvariantsEvaluator2D< real_t > ie
void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const real_t weight, DenseMatrix &A) const override
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
real_t EvalWMatrixForm(const DenseMatrix &Jpt) const override
Evaluates the metric in matrix form (opposed to invariant form). Used for validating the invariant ev...
void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const override
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
real_t EvalW(const DenseMatrix &Jpt) const override
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants,...
real_t EvalWMatrixForm(const DenseMatrix &Jpt) const override
Evaluates the metric in matrix form (opposed to invariant form). Used for validating the invariant ev...
void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const real_t weight, DenseMatrix &A) const override
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const override
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const real_t weight, DenseMatrix &A) const override
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const override
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
real_t EvalWMatrixForm(const DenseMatrix &Jpt) const override
Evaluates the metric in matrix form (opposed to invariant form). Used for validating the invariant ev...
void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const real_t weight, DenseMatrix &A) const override
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
InvariantsEvaluator2D< real_t > ie
void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const override
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
real_t EvalW(const DenseMatrix &Jpt) const override
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants,...
void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const override
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
InvariantsEvaluator2D< real_t > ie
void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const real_t weight, DenseMatrix &A) const override
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
real_t EvalW(const DenseMatrix &Jpt) const override
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants,...
InvariantsEvaluator3D< real_t > ie
void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const real_t weight, DenseMatrix &A) const override
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const override
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
real_t EvalW(const DenseMatrix &Jpt) const override
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants,...
real_t EvalWMatrixForm(const DenseMatrix &Jpt) const override
Evaluates the metric in matrix form (opposed to invariant form). Used for validating the invariant ev...
real_t EvalWMatrixForm(const DenseMatrix &Jpt) const override
Evaluates the metric in matrix form (opposed to invariant form). Used for validating the invariant ev...
void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const real_t weight, DenseMatrix &A) const override
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
InvariantsEvaluator3D< real_t > ie
real_t EvalW(const DenseMatrix &Jpt) const override
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants,...
void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const override
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const real_t weight, DenseMatrix &A) const override
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
InvariantsEvaluator3D< real_t > ie
real_t EvalWMatrixForm(const DenseMatrix &Jpt) const override
Evaluates the metric in matrix form (opposed to invariant form). Used for validating the invariant ev...
void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const override
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
real_t EvalW(const DenseMatrix &Jpt) const override
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants,...
real_t EvalWMatrixForm(const DenseMatrix &Jpt) const override
Evaluates the metric in matrix form (opposed to invariant form). Used for validating the invariant ev...
real_t EvalW(const DenseMatrix &Jpt) const override
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants,...
InvariantsEvaluator3D< real_t > ie
void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const override
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const real_t weight, DenseMatrix &A) const override
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const override
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
real_t EvalW(const DenseMatrix &Jpt) const override
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants,...
void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const real_t weight, DenseMatrix &A) const override
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
InvariantsEvaluator3D< real_t > ie
void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const override
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
InvariantsEvaluator3D< real_t > ie
void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const real_t weight, DenseMatrix &A) const override
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
real_t EvalW(const DenseMatrix &Jpt) const override
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants,...
real_t EvalW(const DenseMatrix &Jpt) const override
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants,...
void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const real_t weight, DenseMatrix &A) const override
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
InvariantsEvaluator3D< real_t > ie
void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const override
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
real_t EvalW(const DenseMatrix &Jpt) const override
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants,...
void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const override
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
real_t EvalWMatrixForm(const DenseMatrix &Jpt) const override
Evaluates the metric in matrix form (opposed to invariant form). Used for validating the invariant ev...
InvariantsEvaluator3D< real_t > ie
void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const real_t weight, DenseMatrix &A) const override
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const real_t weight, DenseMatrix &A) const override
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const override
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
InvariantsEvaluator3D< real_t > ie
real_t EvalW(const DenseMatrix &Jpt) const override
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants,...
real_t EvalWMatrixForm(const DenseMatrix &Jpt) const override
Evaluates the metric in matrix form (opposed to invariant form). Used for validating the invariant ev...
real_t EvalW(const DenseMatrix &Jpt) const override
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants,...
real_t EvalWMatrixForm(const DenseMatrix &Jpt) const override
Evaluates the metric in matrix form (opposed to invariant form). Used for validating the invariant ev...
InvariantsEvaluator3D< real_t > ie
void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const override
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const real_t weight, DenseMatrix &A) const override
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const real_t weight, DenseMatrix &A) const override
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const override
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
InvariantsEvaluator3D< real_t > ie
real_t EvalWMatrixForm(const DenseMatrix &Jpt) const override
Evaluates the metric in matrix form (opposed to invariant form). Used for validating the invariant ev...
real_t EvalW(const DenseMatrix &Jpt) const override
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants,...
real_t EvalWMatrixForm(const DenseMatrix &Jpt) const override
Evaluates the metric in matrix form (opposed to invariant form). Used for validating the invariant ev...
void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const override
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
real_t EvalW(const DenseMatrix &Jpt) const override
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants,...
InvariantsEvaluator3D< real_t > ie
void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const real_t weight, DenseMatrix &A) const override
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
real_t EvalWMatrixForm(const DenseMatrix &Jpt) const override
Evaluates the metric in matrix form (opposed to invariant form). Used for validating the invariant ev...
void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const override
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const real_t weight, DenseMatrix &A) const override
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const real_t weight, DenseMatrix &A) const override
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
real_t EvalW(const DenseMatrix &Jpt) const override
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants,...
void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const override
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
InvariantsEvaluator3D< real_t > ie
real_t EvalWMatrixForm(const DenseMatrix &Jpt) const override
Evaluates the metric in matrix form (opposed to invariant form). Used for validating the invariant ev...
void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const override
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
InvariantsEvaluator3D< real_t > ie
real_t EvalW(const DenseMatrix &Jpt) const override
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants,...
void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const real_t weight, DenseMatrix &A) const override
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
real_t EvalW(const DenseMatrix &Jpt) const override
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants,...
real_t EvalW(const DenseMatrix &Jpt) const override
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants,...
void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const override
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
void EvalPW(const DenseMatrix &Jpt, DenseMatrix &PW) const override
real_t EvalWMatrixForm(const DenseMatrix &Jpt) const override
Evaluates the metric in matrix form (opposed to invariant form). Used for validating the invariant ev...
void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const real_t weight, DenseMatrix &A) const override
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
real_t EvalW(const DenseMatrix &Jpt) const override
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants,...
Default limiter function in TMOP_Integrator.
void Eval_d1(const Vector &x, const Vector &x0, real_t dist, Vector &d1) const override
Returns the gradient of the limiting function f(x, x0, d) with respect to x.
void Eval_d2(const Vector &x, const Vector &x0, real_t dist, DenseMatrix &d2) const override
Returns the Hessian of the limiting function f(x, x0, d) with respect to x.
real_t Eval(const Vector &x, const Vector &x0, real_t dist) const override
Returns the limiting function, f(x, x0, d).
Abstract class for local mesh quality metrics in the target-matrix optimization paradigm (TMOP) by P....
void DefaultAssembleH(const DenseTensor &H, const DenseMatrix &DS, const real_t weight, DenseMatrix &A) const
See AssembleH(). This is a default implementation for the case when the 2nd derivatives of the metric...
virtual void SetTargetJacobian(const DenseMatrix &Jtr_)
Specify the reference-element -> target-element Jacobian matrix for the point of interest.
virtual void EvalPW(const DenseMatrix &Jpt, DenseMatrix &PW) const
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const =0
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const real_t weight, DenseMatrix &A) const =0
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
virtual real_t EvalW(const DenseMatrix &Jpt) const =0
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants,...
real_t EvalW(const DenseMatrix &Jpt) const override
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants,...
BarrierType GetBarrierType()
TMOP_QualityMetric & tmop_metric
void SetMinDetT(real_t min_detT_)
WorstCaseType GetWorstCaseType()
void SetMaxMuT(real_t max_muT_)
real_t EvalWBarrier(const DenseMatrix &Jpt) const
Base class representing target-matrix construction algorithms for mesh optimization via the target-ma...
const TargetType target_type
void ComputeAvgVolume() const
virtual void ComputeElementTargetsGradient(const IntegrationRule &ir, const Vector &elfun, IsoparametricTransformation &Tpr, DenseTensor &dJtr) const
virtual void ComputeElementTargets(int e_id, const FiniteElement &fe, const IntegrationRule &ir, const Vector &elfun, DenseTensor &Jtr) const
Given an element and quadrature rule, computes ref->target transformation Jacobians for each quadratu...
bool UsesPhysicalCoordinates() const
Return true if the methods ComputeElementTargets(), ComputeAllElementTargets(), and ComputeElementTar...
const GridFunction * nodes
virtual bool ContainsVolumeInfo() const
Checks if the target matrices contain non-trivial size specification.
void ComputeAllElementTargets_Fallback(const FiniteElementSpace &fes, const IntegrationRule &ir, const Vector &xe, DenseTensor &Jtr) const
const Array< int > & GetDofMap() const
Get an Array<int> that maps lexicographically ordered indices to the indices of the respective nodes/...
Base class for vector Coefficients that optionally depend on time and space.
virtual const real_t * HostRead() const
Shortcut for mfem::Read(vec.GetMemory(), vec.Size(), false).
virtual const real_t * Read(bool on_dev=true) const
Shortcut for mfem::Read(vec.GetMemory(), vec.Size(), on_dev).
virtual real_t * ReadWrite(bool on_dev=true)
Shortcut for mfem::ReadWrite(vec.GetMemory(), vec.Size(), on_dev).
void SetDataAndSize(real_t *d, int s)
Set the Vector data and size.
real_t Norml2() const
Returns the l2 norm of the vector.
int Size() const
Returns the size of the vector.
virtual void UseDevice(bool use_dev) const
Enable execution of Vector operations using the mfem::Device.
real_t Sum() const
Return the sum of the vector entries.
void SetSize(int s)
Resize the vector to size s.
void NewDataAndSize(real_t *d, int s)
Set the Vector data and size, deleting the old data, if owned.
real_t * GetData() const
Return a pointer to the beginning of the Vector data.
real_t Min() const
Returns the minimal element of the vector.
void GetSubVector(const Array< int > &dofs, Vector &elemvect) const
Extract entries listed in dofs to the output Vector elemvect.
This file contains the declaration of a dual number class.
void mult_aTa_2D(const std::vector< type > &in, std::vector< type > &outm)
type nu51_ad(const std::vector< type > &T, const std::vector< type > &W)
real_t u(const Vector &xvec)
void Mult(const Table &A, const Table &B, Table &C)
C = A * B (as boolean matrices)
void CalcAdjugateTranspose(const DenseMatrix &a, DenseMatrix &adjat)
Calculate the transposed adjugate of a matrix (for NxN matrices, N=1,2,3)
internal::dual< AD1Type, AD1Type > AD2Type
MFEM native AD-type for second derivatives.
void add_3D(const scalartype &scalar, const std::vector< type > &u, const DenseMatrix *M, std::vector< type > &mat)
void ADGrad(std::function< AD1Type(std::vector< AD1Type > &, std::vector< AD1Type > &)>mu_ad, DenseMatrix &dmu, const DenseMatrix &X, const DenseMatrix *Y=nullptr, const bool dX=true)
void add(const Vector &v1, const Vector &v2, Vector &v)
void CalcInverse(const DenseMatrix &a, DenseMatrix &inva)
type mu98_ad(const std::vector< type > &T, const std::vector< type > &W)
type nu14_ad(const std::vector< type > &T, const std::vector< type > &W)
void adjoint_2D(const std::vector< type > &in, std::vector< type > &outm)
void InterpolateTMOP_QualityMetric(TMOP_QualityMetric &metric, const TargetConstructor &tc, const Mesh &mesh, GridFunction &metric_gf)
Interpolates the metric's values at the nodes of metric_gf.
void AddMultVWt(const Vector &v, const Vector &w, DenseMatrix &VWt)
VWt += v w^t.
type nu50_ad(const std::vector< type > &T, const std::vector< type > &W)
void GetPeriodicPositions(const Vector &x_0, const Vector &dx, const FiniteElementSpace &fesL2, const FiniteElementSpace &fesH1, Vector &x)
type fnorm2_3D(const std::vector< type > &u)
void AddMultABt(const DenseMatrix &A, const DenseMatrix &B, DenseMatrix &ABt)
ABt += A * B^t.
type det_2D(const std::vector< type > &u)
void MultAAt(const DenseMatrix &a, DenseMatrix &aat)
Calculate the matrix A.At.
void CalcInverseTranspose(const DenseMatrix &a, DenseMatrix &inva)
Calculate the inverse transpose of a matrix (for NxN matrices, N=1,2,3)
type fnorm2_2D(const std::vector< type > &u)
void ADHessian(std::function< AD2Type(std::vector< AD2Type > &, std::vector< AD2Type > &)> mu_ad, DenseTensor &d2mu_dX2, const DenseMatrix &X, const DenseMatrix *Y=nullptr)
type nu11_ad(const std::vector< type > &T, const std::vector< type > &W)
type skew2D_ad(const std::vector< type > &T, const std::vector< type > &W)
type mu85_ad(const std::vector< type > &T, const std::vector< type > &W)
ComplexDenseMatrix * MultAtB(const ComplexDenseMatrix &A, const ComplexDenseMatrix &B)
Multiply the complex conjugate transpose of a matrix A with a matrix B. A^H*B.
type mu342_ad(const std::vector< type > &T, const std::vector< type > &W)
void AddMult(const DenseMatrix &b, const DenseMatrix &c, DenseMatrix &a)
Matrix matrix multiplication. A += B * C.
void transpose_2D(const std::vector< type > &in, std::vector< type > &outm)
void mult_2D(const std::vector< type > &u, const std::vector< type > &M, std::vector< type > &mat)
type det_3D(const std::vector< type > &u)
internal::dual< real_t, real_t > AD1Type
MFEM native AD-type for first derivatives.
ElementDofOrdering
Constants describing the possible orderings of the DOFs in one element.
std::function< real_t(const Vector &)> f(real_t mass_coeff)
void forall(int N, lambda &&body)
void add_2D(const scalartype &scalar, const std::vector< type > &u, const DenseMatrix *M, std::vector< type > &mat)
type nu107_ad(const std::vector< type > &T, const std::vector< type > &W)
void Add(const DenseMatrix &A, const DenseMatrix &B, real_t alpha, DenseMatrix &C)
C = A + alpha*B.
IntegrationRules IntRules(0, Quadrature1D::GaussLegendre)
A global object with all integration rules (defined in intrules.cpp)
type nu36_ad(const std::vector< type > &T, const std::vector< type > &W)
real_t p(const Vector &x, real_t t)
Helper struct to convert a C++ type to an MPI type.
std::array< int, NCMesh::MaxFaceNodes > nodes