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
mu4_ad(
const std::vector<type> &T,
const std::vector<type> &W)
149 return fnorm2 - 2*det;
153template <
typename type>
154type
mu14_ad(
const std::vector<type> &T,
const std::vector<type> &W)
157 Id(0,0) = 1; Id(1,1) = 1;
159 std::vector<type> Mat;
166template <
typename type>
167type
mu55_ad(
const std::vector<type> &T,
const std::vector<type> &W)
170 return pow(det-1.0, 2.0);
174template <
typename type>
175type
mu85_ad(
const std::vector<type> &T,
const std::vector<type> &W)
178 return T[1]*T[1] + T[2]*T[2] +
179 (T[0] - fnorm/sqrt(2))*(T[0] - fnorm/sqrt(2)) +
180 (T[3] - fnorm/sqrt(2))*(T[3] - fnorm/sqrt(2));
184template <
typename type>
185type
mu98_ad(
const std::vector<type> &T,
const std::vector<type> &W)
188 Id(0,0) = 1; Id(1,1) = 1;
190 std::vector<type> Mat;
196template <
typename type>
215template <
typename type>
217 const std::vector<type> &T,
const std::vector<type> &W,
228 auto val1 =
alpha*min_detT-detT_ep < 0.0 ?
229 (
alpha*min_detT-detT_ep)*one :
231 denom = 2.0*(
det_2D(T)-val1);
236 denom = detT + sqrt(detT*detT + detT_ep*detT_ep);
242 auto exp = exponent*one;
247 auto beta = (max_muT+muT_ep)*one;
254template <
typename type>
255type
mu342_ad(
const std::vector<type> &T,
const std::vector<type> &W)
258 Id(0,0) = 1; Id(1,1) = 1; Id(2,2) = 1;
260 std::vector<type> Mat;
267template <
typename type>
268type
nu11_ad(
const std::vector<type> &T,
const std::vector<type> &W)
271 std::vector<type> AdjA,AdjAt, WtW, WRK, WRK2;
286 return 0.25 / (
alpha) * fnorm;
290template <
typename type>
291type
nu14_ad(
const std::vector<type> &T,
const std::vector<type> &W)
296 auto sqalpha = sqrt(
det_2D(A));
297 auto sqomega = sqrt(
det_2D(W));
299 return 0.5*pow(sqalpha/sqomega - sqomega/sqalpha, 2.0);
303template <
typename type>
304type
nu36_ad(
const std::vector<type> &T,
const std::vector<type> &W)
307 std::vector<type> AminusW;
313 return 1.0 / (
det_2D(A)) * fnorm;
317template <
typename type>
318type
nu50_ad(
const std::vector<type> &T,
const std::vector<type> &W)
323 auto l1_A = sqrt(A[0]*A[0] + A[1]*A[1]);
324 auto l2_A = sqrt(A[2]*A[2] + A[3]*A[3]);
325 auto prod_A = l1_A*l2_A;
326 auto det_A = A[0]*A[3] - A[1]*A[2];
327 auto sin_A = det_A/prod_A;
328 auto cos_A = (A[0]*A[2] + A[1]*A[3])/prod_A;
330 auto l1_W = sqrt(W[0]*W[0] + W[1]*W[1]);
331 auto l2_W = sqrt(W[2]*W[2] + W[3]*W[3]);
332 auto prod_W = l1_W*l2_W;
333 auto det_W = W[0]*W[3] - W[1]*W[2];
334 auto sin_W = det_W/prod_W;
335 auto cos_W = (W[0]*W[2] + W[1]*W[3])/prod_W;
337 return (1.0 - cos_A*cos_W - sin_A*sin_W)/(sin_A*sin_W);
342template <
typename type>
343type
nu51_ad(
const std::vector<type> &T,
const std::vector<type> &W)
348 auto l1_A = sqrt(A[0]*A[0] + A[1]*A[1]);
349 auto l2_A = sqrt(A[2]*A[2] + A[3]*A[3]);
350 auto prod_A = l1_A*l2_A;
351 auto det_A = A[0]*A[3] - A[1]*A[2];
352 auto sin_A = det_A/prod_A;
353 auto cos_A = (A[0]*A[2] + A[1]*A[3])/prod_A;
354 auto ups_A = l1_A*l2_A*sin_A;
356 auto l1_W = sqrt(W[0]*W[0] + W[1]*W[1]);
357 auto l2_W = sqrt(W[2]*W[2] + W[3]*W[3]);
358 auto prod_W = l1_W*l2_W;
359 auto det_W = W[0]*W[3] - W[1]*W[2];
360 auto sin_W = det_W/prod_W;
361 auto cos_W = (W[0]*W[2] + W[1]*W[3])/prod_W;
362 auto ups_W = l1_W*l2_W*sin_W;
364 return (0.5 * (ups_A / ups_W + ups_W / ups_A) - cos_A*cos_W - sin_A*sin_W) /
369template <
typename type>
370type
nu107_ad(
const std::vector<type> &T,
const std::vector<type> &W)
373 std::vector<type> Mat;
384template <
typename type>
385type
skew2D_ad(
const std::vector<type> &T,
const std::vector<type> &W)
390 auto l1_A = sqrt(A[0]*A[0] + A[1]*A[1]);
391 auto l2_A = sqrt(A[2]*A[2] + A[3]*A[3]);
392 auto prod_A = l1_A*l2_A;
393 auto det_A = A[0]*A[3] - A[1]*A[2];
394 auto sin_A = det_A/prod_A;
395 auto cos_A = (A[0]*A[2] + A[1]*A[3])/prod_A;
397 auto l1_W = sqrt(W[0]*W[0] + W[1]*W[1]);
398 auto l2_W = sqrt(W[2]*W[2] + W[3]*W[3]);
399 auto prod_W = l1_W*l2_W;
400 auto det_W = W[0]*W[3] - W[1]*W[2];
401 auto sin_W = det_W/prod_W;
402 auto cos_W = (W[0]*W[2] + W[1]*W[3])/prod_W;
404 return 0.5*(1.0 - cos_A*cos_W - sin_A*sin_W);
410 std::vector<AD1Type>&)>mu_ad,
414 const bool dX =
true )
417 std::vector<AD1Type> adX(matsize), adY(matsize);
419 for (
int i=0; i<matsize; i++) { adX[i] =
AD1Type{X.
GetData()[i], 0.0}; }
422 for (
int i=0; i<matsize; i++) { adY[i] =
AD1Type{Y->GetData()[i], 0.0}; }
427 for (
int i=0; i<matsize; i++)
437 MFEM_VERIFY(Y,
"Y cannot be nullptr when dX = false.");
438 for (
int i=0; i<matsize; i++)
440 adY[i] =
AD1Type{Y->GetData()[i], 1.0};
443 adY[i] =
AD1Type{Y->GetData()[i], 0.0};
450 std::vector<AD2Type>&)> mu_ad,
458 std::vector<AD2Type> aduu(matsize), adY(matsize);
459 for (
int ii = 0; ii < matsize; ii++)
462 aduu[ii].gradient =
AD1Type{0.0, 0.0};
466 for (
int ii=0; ii<matsize; ii++)
468 adY[ii].value =
AD1Type{Y->GetData()[ii], 0.0};
469 adY[ii].gradient =
AD1Type{0.0, 0.0};
473 for (
int ii = 0; ii < matsize; ii++)
476 for (
int jj = 0; jj < (ii + 1); jj++)
478 aduu[jj].gradient =
AD1Type{1.0, 0.0};
479 AD2Type rez = mu_ad(aduu, adY);
482 aduu[jj].gradient =
AD1Type{0.0, 0.0};
500 for (
int r = 0; r <
dim; r++)
502 for (
int c = 0; c <
dim; c++)
507 for (
int rr = 0; rr <
dim; rr++)
509 for (
int cc = 0; cc <
dim; cc++)
511 const real_t entry_rr_cc = Hrc(rr, cc);
513 for (
int i = 0; i < dof; i++)
515 for (
int j = 0; j < dof; j++)
517 A(i+r*dof, j+rr*dof) +=
518 weight * DS(i, c) * DS(j, cc) * entry_rr_cc;
572 const std::vector<AD1Type> &W)
584 const std::vector<AD2Type> &W)
587 AD2Type metric = {{0., 0.},{0., 0.}};
622 Vector products_no_m(m_cnt); products_no_m = 1.0;
623 for (
int m_p = 0; m_p < m_cnt; m_p++)
625 for (
int m_a = 0; m_a < m_cnt; m_a++)
627 if (m_p != m_a) { products_no_m(m_p) *= averages(m_a); }
630 const real_t pnm_sum = products_no_m.
Sum();
632 if (pnm_sum == 0.0) { weights = 1.0 / m_cnt;
return; }
633 for (
int m = 0; m < m_cnt; m++) { weights(m) = products_no_m(m) / pnm_sum; }
635 MFEM_ASSERT(fabs(weights.
Sum() - 1.0) < 1e-14,
636 "Error: sum should be 1 always: " << weights.
Sum());
644 NE =
nodes.FESpace()->GetNE(),
645 dim =
nodes.FESpace()->GetMesh()->Dimension();
649 auto fe =
nodes.FESpace()->GetTypicalFE();
651 (IntRule) ? *IntRule :
IntRules.
Get(fe->GetGeomType(), 2*fe->GetOrder());
658 for (
int m = 0; m < m_cnt; m++)
673 for (
int e = 0; e < NE; e++)
683 nodes.FESpace()->GetElementVDofs(e, pos_dofs);
684 nodes.GetSubVector(pos_dofs, posV);
690 for (
int q = 0; q < nsp; q++)
701 for (
int m = 0; m < m_cnt; m++)
704 averages(m) +=
tmop_q_arr[m]->EvalW(T) * w_detA;
716 MPI_Allreduce(MPI_IN_PLACE, averages.
GetData(), m_cnt,
719 par_nodes->ParFESpace()->GetComm());
730 real_t metric = metric_tilde;
733 metric = std::pow(metric_tilde,
exponent);
738 metric = metric_tilde/(beta-metric_tilde);
760 const std::vector<AD1Type> &T,
761 const std::vector<AD1Type> &W)
const
768 const std::vector<AD2Type> &T,
769 const std::vector<AD2Type> &W)
const
778 auto mu_ad_fn = [
this](std::vector<AD1Type> &T, std::vector<AD1Type> &W)
788 MFEM_ABORT(
"EvalW_AD1 not implemented with this metric for "
789 "TMOP_WorstCaseUntangleOptimizer_Metric. "
790 "Please use metric 4/14/66.");
801 auto mu_ad_fn = [
this](std::vector<AD2Type> &T, std::vector<AD2Type> &W)
812 MFEM_ABORT(
"EvalW_AD1 not implemented with this metric for "
813 "TMOP_WorstCaseUntangleOptimizer_Metric. "
814 "Please use metric 4/14/66.");
841 MFEM_VERIFY(
Jtr != NULL,
842 "Requires a target Jacobian, use SetTargetJacobian().");
844 std::vector<AD1Type> T(matsize), W(matsize);
845 for (
int i=0; i<matsize; i++)
878 MFEM_VERIFY(
Jtr != NULL,
879 "Requires a target Jacobian, use SetTargetJacobian().");
891 real_t cos_Jpr_12 = (col1 * col2) / (norm_c1 * norm_c2),
892 cos_Jpr_13 = (col1 * col3) / (norm_c1 * norm_c3),
893 cos_Jpr_23 = (col2 * col3) / (norm_c2 * norm_c3);
894 real_t sin_Jpr_12 = std::sqrt(1.0 - cos_Jpr_12 * cos_Jpr_12),
895 sin_Jpr_13 = std::sqrt(1.0 - cos_Jpr_13 * cos_Jpr_13),
896 sin_Jpr_23 = std::sqrt(1.0 - cos_Jpr_23 * cos_Jpr_23);
904 real_t cos_Jtr_12 = (col1 * col2) / (norm_c1 * norm_c2),
905 cos_Jtr_13 = (col1 * col3) / (norm_c1 * norm_c3),
906 cos_Jtr_23 = (col2 * col3) / (norm_c2 * norm_c3);
907 real_t sin_Jtr_12 = std::sqrt(1.0 - cos_Jtr_12 * cos_Jtr_12),
908 sin_Jtr_13 = std::sqrt(1.0 - cos_Jtr_13 * cos_Jtr_13),
909 sin_Jtr_23 = std::sqrt(1.0 - cos_Jtr_23 * cos_Jtr_23);
911 return (3.0 - cos_Jpr_12 * cos_Jtr_12 - sin_Jpr_12 * sin_Jtr_12
912 - cos_Jpr_13 * cos_Jtr_13 - sin_Jpr_13 * sin_Jtr_13
913 - cos_Jpr_23 * cos_Jtr_23 - sin_Jpr_23 * sin_Jtr_23) / 6.0;
918 MFEM_VERIFY(
Jtr != NULL,
919 "Requires a target Jacobian, use SetTargetJacobian().");
933 return 0.5 * (ratio_Jpr / ratio_Jtr + ratio_Jtr / ratio_Jpr) - 1.0;
938 MFEM_VERIFY(
Jtr != NULL,
939 "Requires a target Jacobian, use SetTargetJacobian().");
951 real_t ratio_Jpr_1 = norm_c1 / std::sqrt(norm_c2 * norm_c3),
952 ratio_Jpr_2 = norm_c2 / std::sqrt(norm_c1 * norm_c3),
953 ratio_Jpr_3 = norm_c3 / std::sqrt(norm_c1 * norm_c2);
961 real_t ratio_Jtr_1 = norm_c1 / std::sqrt(norm_c2 * norm_c3),
962 ratio_Jtr_2 = norm_c2 / std::sqrt(norm_c1 * norm_c3),
963 ratio_Jtr_3 = norm_c3 / std::sqrt(norm_c1 * norm_c2);
965 return ( 0.5 * (ratio_Jpr_1 / ratio_Jtr_1 + ratio_Jtr_1 / ratio_Jpr_1) +
966 0.5 * (ratio_Jpr_2 / ratio_Jtr_2 + ratio_Jtr_2 / ratio_Jpr_2) +
967 0.5 * (ratio_Jpr_3 / ratio_Jtr_3 + ratio_Jtr_3 / ratio_Jpr_3) - 3.0
973 return 0.5 * Jpt.
FNorm2() / Jpt.
Det() - 1.0;
1022template <
typename type>
1024 const std::vector<type> &W)
const
1030 const std::vector<AD1Type> &W)
const
1036 const std::vector<AD2Type> &W)
const
1073 const real_t c2 = weight*c1*c1;
1120 return Mat.FNorm2();
1138 for (
int i = 0; i < Jpt.
Size(); i++)
1140 JptMinusId(i, i) -= 1.0;
1153 for (
int i = 0; i < Jpt.
Size(); i++)
1155 JptMinusId(i, i) -= 1.0;
1162template <
typename type>
1164 const std::vector<type> &W)
const
1170 const std::vector<AD1Type> &W)
const
1176 const std::vector<AD2Type> &W)
const
1198 return (0.5*
ie.
Get_I1() - I2b) / d;
1229 const real_t c2 = weight*c1/2;
1246 return 0.5 * JtJ.
FNorm2()/(det*det) - 1.0;
1257 return 0.5*I1b*I1b - 2.0;
1310template <
typename type>
1312 const std::vector<type> &W)
const
1318 const std::vector<AD1Type> &W)
const
1324 const std::vector<AD2Type> &W)
const
1333 return 0.5 * (d + 1.0 / d) - 1.0;
1341 return 0.5*(I2b + 1.0/I2b) - 1.0;
1374 return JtJ.
FNorm2()/(det*det) - 2*Jpt.
FNorm2()/det + 2.0;
1382 return I1b*(I1b - 2.0);
1410 return 0.5 * (d*d + 1.0/(d*d)) - 1.0;
1417 return 0.5*(I2 + 1.0/I2) - 1.0;
1445 std::vector<AD1Type> T(matsize), W(matsize);
1446 for (
int i=0; i<matsize; i++) { T[i] =
AD1Type{Jpt.
GetData()[i], 0.0}; }
1471 std::vector<AD1Type> T(matsize), W(matsize);
1472 for (
int i=0; i<matsize; i++) { T[i] =
AD1Type{Jpt.
GetData()[i], 0.0}; }
1499 return (I2b - 1.0)*(I2b - 1.0) - I2b + std::sqrt(I2b*I2b +
eps);
1504 MFEM_ABORT(
"Metric not implemented yet. Use metric mu_55 instead.");
1512 MFEM_ABORT(
"Metric not implemented yet. Use metric mu_55 instead.");
1520 return 0.5*(I2b - 1.0)*(I2b - 1.0)/(I2b -
tau0);
1548 const real_t c = c0*(I2b - 1.0);
1559 return Jpt.FNorm() * inv.FNorm() / 3.0 - 1.0;
1607 const real_t a = weight/(6*std::sqrt(I1b_I2b));
1619 return Jpt.
FNorm2() * inv.FNorm2() / 9.0 - 1.0;
1650 const real_t c1 = weight/9;
1660 return Jpt.
FNorm2() / 3.0 / pow(Jpt.
Det(), 2.0 / 3.0) - 1.0;
1693 const real_t fnorm = Jpt.FNorm();
1694 return fnorm * fnorm * fnorm / pow(3.0, 1.5) / Jpt.
Det() - 1.0;
1701 return pow(
ie.
Get_I1b()/3.0, 1.5) - 1.0;
1730 return (I3b - 1.0)*(I3b - 1.0) - I3b + std::sqrt(I3b*I3b +
eps);
1737 const real_t c = 2*I3b-3+(I3b)/(std::pow((I3b*I3b+
eps),0.5));
1750 const real_t c1 = 2 + 1/(pow(c0,0.5)) - I3b*I3b/(pow(c0,1.5));
1751 const real_t c2 = 2*I3b - 3 + I3b/(pow(c0,0.5));
1771 const real_t c = std::pow(d, -2.0/3.0);
1778 MFEM_ABORT(
"Metric not implemented yet.");
1786 MFEM_ABORT(
"Metric not implemented yet.");
1821 return 0.5 * (Jpt.
Det() + 1.0 / Jpt.
Det()) - 1.0;
1829 return 0.5*(I3b + 1.0/I3b) - 1.0;
1858 return 0.5 * (d*d + 1.0 / (d*d)) - 1.0;
1866 return 0.5*(I3 + 1.0/I3) - 1.0;
1897 invt.
Add(-1.0, Jpt);
1939 const real_t c1 = weight*c0*c0;
1940 const real_t c2 = -2*c0*c1;
1955 adj_J_t.
Add(1.0, Jpt);
1956 return 1.0 / 6.0 / Jpt.
Det() * adj_J_t.
FNorm2();
2002 m13 = weight * pow(
ie.
Get_I3b(), -1.0/3.0),
2003 m23 = weight * pow(
ie.
Get_I3b(), -2.0/3.0),
2004 m43 = weight * pow(
ie.
Get_I3b(), -4.0/3.0),
2005 m53 = weight * pow(
ie.
Get_I3b(), -5.0/3.0),
2006 m73 = weight * pow(
ie.
Get_I3b(), -7.0/3.0);
2026 real_t fnorm = Jpt.FNorm();
2027 return fnorm * fnorm * fnorm - 3.0 * sqrt(3.0) * (log(Jpt.
Det()) + 1.0);
2066 std::vector<AD1Type> T(matsize), W(matsize);
2067 for (
int i=0; i<matsize; i++) { T[i] =
AD1Type{Jpt.
GetData()[i], 0.0}; }
2093 return 0.5*(I3b - 1.0)*(I3b - 1.0)/(I3b -
tau0);
2126 const real_t c = c0*(I3b - 1.0);
2134 const real_t fnorm = Jpt.FNorm();
2135 return fnorm * fnorm * fnorm / pow(3.0, 1.5) - Jpt.
Det();
2169 MFEM_VERIFY(
Jtr != NULL,
2170 "Requires a target Jacobian, use SetTargetJacobian().");
2172 std::vector<AD1Type> T(matsize), W(matsize);
2173 for (
int i=0; i<matsize; i++)
2206 MFEM_VERIFY(
Jtr != NULL,
2207 "Requires a target Jacobian, use SetTargetJacobian().");
2209 std::vector<AD1Type> T(matsize), W(matsize);
2210 for (
int i=0; i<matsize; i++)
2243 MFEM_VERIFY(
Jtr != NULL,
2244 "Requires a target Jacobian, use SetTargetJacobian().");
2246 std::vector<AD1Type> T(matsize), W(matsize);
2247 for (
int i=0; i<matsize; i++)
2280 MFEM_VERIFY(
Jtr != NULL,
2281 "Requires a target Jacobian, use SetTargetJacobian().");
2283 std::vector<AD1Type> T(matsize), W(matsize);
2284 for (
int i=0; i<matsize; i++)
2317 MFEM_VERIFY(
Jtr != NULL,
2318 "Requires a target Jacobian, use SetTargetJacobian().");
2320 std::vector<AD1Type> T(matsize), W(matsize);
2321 for (
int i=0; i<matsize; i++)
2354 MFEM_VERIFY(
Jtr != NULL,
2355 "Requires a target Jacobian, use SetTargetJacobian().");
2357 std::vector<AD1Type> T(matsize), W(matsize);
2358 for (
int i=0; i<matsize; i++)
2391 MFEM_VERIFY(
nodes,
"Nodes are not given!");
2392 MFEM_ASSERT(
avg_volume == 0.0,
"The average volume is already computed!");
2395 const int NE = mesh->
GetNE();
2399 for (
int i = 0; i < NE; i++)
2423 area_NE[0] = volume; area_NE[1] = NE;
2444 const int NE = mesh->
GetNE();
2446 if (NE == 0) {
return; }
2449 "mixed meshes are not supported");
2450 MFEM_VERIFY(!fes.
IsVariableOrder(),
"variable orders are not supported");
2452 const int sdim = fes.
GetVDim();
2453 const int nvdofs = sdim*fe.
GetDof();
2455 xe.
Size() == NE*nvdofs,
"invalid input Vector 'xe'!");
2465 if (dof_map->
Size() == 0) { dof_map =
nullptr; }
2469 Vector elfun_lex, elfun_nat;
2477 for (
int e = 0; e < NE; e++)
2488 const int ndofs = fe.
GetDof();
2489 for (
int d = 0; d < sdim; d++)
2491 for (
int i_lex = 0; i_lex < ndofs; i_lex++)
2493 elfun_nat[(*dof_map)[i_lex]+d*ndofs] =
2494 elfun_lex[i_lex+d*ndofs];
2513 default: MFEM_ABORT(
"TargetType not added to ContainsVolumeInfo.");
2523 MFEM_CONTRACT_VAR(elfun);
2531 MFEM_ASSERT(Wideal.
Width() == Jtr.
SizeJ(),
"");
2537 for (
int i = 0; i < ir.
GetNPoints(); i++) { Jtr(i) = Wideal; }
2554 for (
int i = 0; i < ir.
GetNPoints(); i++) { Jtr(i) = W; }
2577 const real_t det = Jtr(i).Det();
2578 MFEM_VERIFY(det > 0.0,
"The given mesh is inverted!");
2579 Jtr(i).Set(std::pow(det / detW, 1./
dim), Wideal);
2585 MFEM_ABORT(
"invalid target type!");
2595 MFEM_CONTRACT_VAR(elfun);
2625 "Target type GIVEN_FULL requires a MatrixCoefficient.");
2642 MFEM_ABORT(
"Incompatible target type for analytic adaptation!");
2660 "Target type GIVEN_FULL requires a TMOPMatrixCoefficient.");
2662 for (
int d = 0; d < fe->
GetDim(); d++)
2675 MFEM_ABORT(
"Incompatible target type for analytic adaptation!");
2685static inline void device_copy(
real_t *d_dest,
const real_t *d_src,
int size)
2687 mfem::forall(size, [=] MFEM_HOST_DEVICE (
int i) { d_dest[i] = d_src[i]; });
2695 MFEM_VERIFY(
adapt_eval,
"SetAdaptivityEvaluator() has not been called!")
2696 MFEM_VERIFY(
ncomp > 0,
"No target specifications have been set!");
2740 MFEM_VERIFY(ndof ==
tspec.
Size()/
ncomp,
"Inconsistency in SetTspecAtIndex.");
2742 const auto tspec__d = tspec_.
Read();
2744 const int offset = idx*ndof;
2745 internal::device_copy(tspec_d + offset, tspec__d, ndof*vdim);
2752 "Discrete target size should be ordered byNodes.");
2762 "Discrete target skewness should be ordered byNodes.");
2772 "Discrete target aspect ratio should be ordered byNodes.");
2782 "Discrete target orientation should be ordered byNodes.");
2809 const auto tspec_temp_d = tspec_temp.
Read();
2811 internal::device_copy(tspec_d, tspec_temp_d, tspec_temp.
Size());
2813 const auto tspec__d = tspec_.
Read();
2814 const int offset = (
ncomp-vdim)*ndof;
2815 internal::device_copy(tspec_d + offset, tspec__d, ndof*vdim);
2822 MFEM_VERIFY(ndof ==
tspec.
Size()/
ncomp,
"Inconsistency in SetTspecAtIndex.");
2824 const auto tspec__d = tspec_.
Read();
2826 const int offset = idx*ndof;
2827 internal::device_copy(tspec_d + offset, tspec__d, ndof*vdim);
2834 "Discrete target size should be ordered byNodes.");
2844 "Discrete target skewness should be ordered byNodes.");
2854 "Discrete target aspect ratio should be ordered byNodes.");
2864 "Discrete target orientation should be ordered byNodes.");
2873 MFEM_VERIFY(
adapt_eval,
"SetAdaptivityEvaluator() has not been called!")
2874 MFEM_VERIFY(
ncomp > 0,
"No target specifications have been set!");
2894 if (idx < 0) {
return; }
2898 "Inconsistency in GetSerialDiscreteTargetSpec.");
2900 for (
int i = 0; i < ndof*vdim; i++)
2902 tspec_(i) =
tspec(i + idx*ndof);
2929 MFEM_VERIFY(
tspec.
Size() > 0,
"Target specification is not set!");
2945 int dofidx,
int dir,
2948 MFEM_VERIFY(
tspec.
Size() > 0,
"Target specification is not set!");
2954 for (
int i = 0; i <
ncomp; i++)
2956 tspec(dofs[dofidx]+i*cnt) = IntData(dofs[dofidx] + i*cnt + dir*cnt*
ncomp);
2963 MFEM_VERIFY(
tspec.
Size() > 0,
"Target specification is not set!");
2968 for (
int i = 0; i <
ncomp; i++)
2983 ntspec_dofs = ndofs*
ncomp;
2985 Vector tspec_vals(ntspec_dofs);
2996 MFEM_ABORT(
"Incompatible target type for discrete adaptation!");
3013 MFEM_VERIFY(
tspec_fesv,
"No target specifications have been set.");
3028 ntspec_dofs = ndofs*
ncomp;
3030 Vector shape(ndofs), tspec_vals(ntspec_dofs), par_vals,
3031 par_vals_c1, par_vals_c2, par_vals_c3;
3040 MFEM_VERIFY(
amr_el >= 0,
" Target being constructed for an AMR element.");
3041 for (
int i = 0; i <
ncomp; i++)
3043 for (
int j = 0; j < ndofs; j++)
3057 for (
int q = 0; q < nqp; q++)
3062 for (
int d = 0; d < 4; d++)
3073 MFEM_VERIFY(min_size > 0.0,
3074 "Non-positive size propagated in the target definition.");
3076 real_t size = std::max(shape * par_vals, min_size);
3082 Jtr(q).Set(std::pow(size, 1.0/
dim), Jtr(q));
3096 MFEM_VERIFY(min_size > 0.0,
3097 "Non-positive aspect-ratio propagated in the target definition.");
3099 const real_t aspectratio = shape * par_vals;
3101 D_rho(0,0) = 1./pow(aspectratio,0.5);
3102 D_rho(1,1) = pow(aspectratio,0.5);
3112 const real_t rho1 = shape * par_vals_c1;
3113 const real_t rho2 = shape * par_vals_c2;
3114 const real_t rho3 = shape * par_vals_c3;
3116 D_rho(0,0) = pow(rho1,2./3.);
3117 D_rho(1,1) = pow(rho2,2./3.);
3118 D_rho(2,2) = pow(rho3,2./3.);
3123 Mult(D_rho, Temp, Jtr(q));
3133 const real_t skew = shape * par_vals;
3137 Q_phi(0,1) = cos(skew);
3138 Q_phi(1,1) = sin(skew);
3148 const real_t phi12 = shape * par_vals_c1;
3149 const real_t phi13 = shape * par_vals_c2;
3150 const real_t chi = shape * par_vals_c3;
3154 Q_phi(0,1) = cos(phi12);
3155 Q_phi(0,2) = cos(phi13);
3157 Q_phi(1,1) = sin(phi12);
3158 Q_phi(1,2) = sin(phi13)*cos(chi);
3160 Q_phi(2,2) = sin(phi13)*sin(chi);
3165 Mult(Q_phi, Temp, Jtr(q));
3175 const real_t theta = shape * par_vals;
3176 R_theta(0,0) = cos(theta);
3177 R_theta(0,1) = -sin(theta);
3178 R_theta(1,0) = sin(theta);
3179 R_theta(1,1) = cos(theta);
3189 const real_t theta = shape * par_vals_c1;
3190 const real_t psi = shape * par_vals_c2;
3191 const real_t beta = shape * par_vals_c3;
3193 real_t ct = cos(theta), st = sin(theta),
3194 cp = cos(psi), sp = sin(psi),
3195 cb = cos(beta), sb = sin(beta);
3198 R_theta(0,0) = ct*sp;
3199 R_theta(1,0) = st*sp;
3202 R_theta(0,1) = -st*cb + ct*cp*sb;
3203 R_theta(1,1) = ct*cb + st*cp*sb;
3204 R_theta(2,1) = -sp*sb;
3206 R_theta(0,0) = -st*sb - ct*cp*cb;
3207 R_theta(1,0) = ct*sb - st*cp*cb;
3208 R_theta(2,0) = sp*cb;
3211 Jtrcomp_q = R_theta;
3213 Mult(R_theta, Temp, Jtr(q));
3219 MFEM_ABORT(
"Incompatible target type for discrete adaptation!");
3230 MFEM_VERIFY(
tspec_fesv,
"No target specifications have been set.");
3245 ntspec_dofs = ndofs*
ncomp;
3247 Vector shape(ndofs), tspec_vals(ntspec_dofs), par_vals,
3248 par_vals_c1(ndofs), par_vals_c2(ndofs), par_vals_c3(ndofs);
3258 grad_e_c2(ndofs,
dim),
3259 grad_e_c3(ndofs,
dim);
3260 Vector grad_ptr_c1(grad_e_c1.GetData(), ndofs*
dim),
3261 grad_ptr_c2(grad_e_c2.GetData(), ndofs*
dim),
3280 grad_phys.
Mult(par_vals, grad_ptr_c1);
3283 grad_e_c1.MultTranspose(shape, grad_q);
3286 MFEM_VERIFY(min_size > 0.0,
3287 "Non-positive size propagated in the target definition.");
3288 const real_t size = std::max(shape * par_vals, min_size);
3291 Mult(Jtrcomp_q, Jtrcomp_d, work1);
3292 Mult(Jtrcomp_r, work1, work2);
3294 for (
int d = 0; d <
dim; d++)
3298 work1.
Set(dz_dsize, work1);
3300 AddMult(work1, work2, dJtr_i);
3313 grad_phys.
Mult(par_vals, grad_ptr_c1);
3316 grad_e_c1.MultTranspose(shape, grad_q);
3318 const real_t aspectratio = shape * par_vals;
3320 dD_rho(0,0) = -0.5*pow(aspectratio,-1.5);
3321 dD_rho(1,1) = 0.5*pow(aspectratio,-0.5);
3323 Mult(Jtrcomp_s, Jtrcomp_r, work1);
3324 Mult(work1, Jtrcomp_q, work2);
3326 for (
int d = 0; d <
dim; d++)
3331 AddMult(work2, work1, dJtr_i);
3338 par_vals_c1.SetData(par_vals.
GetData());
3339 par_vals_c2.SetData(par_vals.
GetData()+ndofs);
3342 grad_phys.
Mult(par_vals_c1, grad_ptr_c1);
3343 grad_phys.
Mult(par_vals_c2, grad_ptr_c2);
3344 grad_phys.
Mult(par_vals_c3, grad_ptr_c3);
3347 grad_e_c1.MultTranspose(shape, grad_q1);
3348 grad_e_c2.MultTranspose(shape, grad_q2);
3351 const real_t rho1 = shape * par_vals_c1;
3352 const real_t rho2 = shape * par_vals_c2;
3353 const real_t rho3 = shape * par_vals_c3;
3355 dD_rho(0,0) = (2./3.)*pow(rho1,-1./3.);
3356 dD_rho(1,1) = (2./3.)*pow(rho2,-1./3.);
3357 dD_rho(2,2) = (2./3.)*pow(rho3,-1./3.);
3359 Mult(Jtrcomp_s, Jtrcomp_r, work1);
3360 Mult(work1, Jtrcomp_q, work2);
3363 for (
int d = 0; d <
dim; d++)
3367 work1(0,0) *= grad_q1(d);
3368 work1(1,2) *= grad_q2(d);
3369 work1(2,2) *= grad_q3(d);
3371 AddMult(work2, work1, dJtr_i);
3383 grad_phys.
Mult(par_vals, grad_ptr_c1);
3386 grad_e_c1.MultTranspose(shape, grad_q);
3388 const real_t skew = shape * par_vals;
3392 dQ_phi(0,1) = -sin(skew);
3393 dQ_phi(1,1) = cos(skew);
3395 Mult(Jtrcomp_s, Jtrcomp_r, work2);
3397 for (
int d = 0; d <
dim; d++)
3402 Mult(work1, Jtrcomp_d, work3);
3403 AddMult(work2, work3, dJtr_i);
3410 par_vals_c1.SetData(par_vals.
GetData());
3411 par_vals_c2.SetData(par_vals.
GetData()+ndofs);
3414 grad_phys.
Mult(par_vals_c1, grad_ptr_c1);
3415 grad_phys.
Mult(par_vals_c2, grad_ptr_c2);
3416 grad_phys.
Mult(par_vals_c3, grad_ptr_c3);
3419 grad_e_c1.MultTranspose(shape, grad_q1);
3420 grad_e_c2.MultTranspose(shape, grad_q2);
3423 const real_t phi12 = shape * par_vals_c1;
3424 const real_t phi13 = shape * par_vals_c2;
3425 const real_t chi = shape * par_vals_c3;
3429 dQ_phi(0,1) = -sin(phi12);
3430 dQ_phi(1,1) = cos(phi12);
3433 dQ_phi13(0,2) = -sin(phi13);
3434 dQ_phi13(1,2) = cos(phi13)*cos(chi);
3435 dQ_phi13(2,2) = cos(phi13)*sin(chi);
3438 dQ_phichi(1,2) = -sin(phi13)*sin(chi);
3439 dQ_phichi(2,2) = sin(phi13)*cos(chi);
3441 Mult(Jtrcomp_s, Jtrcomp_r, work2);
3443 for (
int d = 0; d <
dim; d++)
3447 work1 *= grad_q1(d);
3448 work1.Add(grad_q2(d), dQ_phi13);
3449 work1.Add(grad_q3(d), dQ_phichi);
3450 Mult(work1, Jtrcomp_d, work3);
3451 AddMult(work2, work3, dJtr_i);
3463 grad_phys.
Mult(par_vals, grad_ptr_c1);
3466 grad_e_c1.MultTranspose(shape, grad_q);
3468 const real_t theta = shape * par_vals;
3469 dR_theta(0,0) = -sin(theta);
3470 dR_theta(0,1) = -cos(theta);
3471 dR_theta(1,0) = cos(theta);
3472 dR_theta(1,1) = -sin(theta);
3474 Mult(Jtrcomp_q, Jtrcomp_d, work1);
3475 Mult(Jtrcomp_s, work1, work2);
3476 for (
int d = 0; d <
dim; d++)
3481 AddMult(work1, work2, dJtr_i);
3488 par_vals_c1.SetData(par_vals.
GetData());
3489 par_vals_c2.SetData(par_vals.
GetData()+ndofs);
3492 grad_phys.
Mult(par_vals_c1, grad_ptr_c1);
3493 grad_phys.
Mult(par_vals_c2, grad_ptr_c2);
3494 grad_phys.
Mult(par_vals_c3, grad_ptr_c3);
3497 grad_e_c1.MultTranspose(shape, grad_q1);
3498 grad_e_c2.MultTranspose(shape, grad_q2);
3501 const real_t theta = shape * par_vals_c1;
3502 const real_t psi = shape * par_vals_c2;
3503 const real_t beta = shape * par_vals_c3;
3505 const real_t ct = cos(theta), st = sin(theta),
3506 cp = cos(psi), sp = sin(psi),
3507 cb = cos(beta), sb = sin(beta);
3510 dR_theta(0,0) = -st*sp;
3511 dR_theta(1,0) = ct*sp;
3514 dR_theta(0,1) = -ct*cb - st*cp*sb;
3515 dR_theta(1,1) = -st*cb + ct*cp*sb;
3518 dR_theta(0,0) = -ct*sb + st*cp*cb;
3519 dR_theta(1,0) = -st*sb - ct*cp*cb;
3527 dR_beta(0,1) = st*sb + ct*cp*cb;
3528 dR_beta(1,1) = -ct*sb + st*cp*cb;
3529 dR_beta(2,1) = -sp*cb;
3531 dR_beta(0,0) = -st*cb + ct*cp*sb;
3532 dR_beta(1,0) = ct*cb + st*cp*sb;
3536 dR_psi(0,0) = ct*cp;
3537 dR_psi(1,0) = st*cp;
3540 dR_psi(0,1) = 0. - ct*sp*sb;
3541 dR_psi(1,1) = 0. + st*sp*sb;
3542 dR_psi(2,1) = -cp*sb;
3544 dR_psi(0,0) = 0. + ct*sp*cb;
3545 dR_psi(1,0) = 0. + st*sp*cb;
3546 dR_psi(2,0) = cp*cb;
3548 Mult(Jtrcomp_q, Jtrcomp_d, work1);
3549 Mult(Jtrcomp_s, work1, work2);
3550 for (
int d = 0; d <
dim; d++)
3554 work1 *= grad_q1(d);
3555 work1.Add(grad_q2(d), dR_psi);
3556 work1.Add(grad_q3(d), dR_beta);
3557 AddMult(work1, work2, dJtr_i);
3565 MFEM_ABORT(
"Incompatible target type for discrete adaptation!");
3572 bool reuse_flag,
int x_ordering)
3580 "FD with discrete adaptivity assume mesh_order = field_order.");
3586 for (
int j = 0; j <
dim; j++)
3588 for (
int i = 0; i < cnt; i++)
3597 for (
int i = 0; i < cnt; i++)
3609 bool reuse_flag,
int x_ordering)
3615 totmix = 1+2*(
dim-2);
3618 "FD with discrete adaptivity assume mesh_order = field_order.");
3627 for (
int j = 0; j <
dim; j++)
3629 for (
int i = 0; i < cnt; i++)
3638 for (
int i = 0; i < cnt; i++)
3647 for (
int k1 = 0; k1 <
dim; k1++)
3649 for (
int k2 = 0; (k1 != k2) && (k2 <
dim); k2++)
3651 for (
int i = 0; i < cnt; i++)
3662 for (
int i = 0; i < cnt; i++)
3693 f.GetVDim(),
f.GetOrdering());
3704 f.GetVDim(),
f.GetOrdering());
3731 PA.H.GetMemory().DeleteDevice(copy_to_host);
3732 PA.H0.GetMemory().DeleteDevice(copy_to_host);
3733 if (!copy_to_host && !
PA.Jtr.GetMemory().HostIsValid())
3735 PA.Jtr_needs_update =
true;
3737 PA.Jtr.GetMemory().DeleteDevice(copy_to_host);
3748 if (
PA.enabled &&
x_0 !=
nullptr)
3752 PA.X0.UseDevice(
true);
3766 for (
int i = 0; i <
ElemDer.Size(); i++)
3781 "'dist' must be a scalar GridFunction!");
3840 "Using both fitting approaches is not supported.");
3843 MFEM_VERIFY(per ==
false,
"Fitting is not supported for periodic meshes.");
3848 "Mesh and level-set polynomial order must be the same.");
3851 MFEM_VERIFY(fec,
"Only H1_FECollection is supported for the surface fitting "
3873 "Using both fitting approaches is not supported.");
3875 "Positions on a mesh without Nodes is not supported.");
3878 "Incompatible ordering of spaces!");
3881 MFEM_VERIFY(per ==
false,
"Fitting is not supported for periodic meshes.");
3901 "Using both fitting approaches is not supported.");
3904 MFEM_VERIFY(per ==
false,
"Fitting is not supported for periodic meshes.");
3909 "Mesh and level-set polynomial order must be the same.");
3912 MFEM_VERIFY(fec,
"Only H1_FECollection is supported for the surface fitting "
3927 if (!aegrad) {
return; }
3929 MFEM_VERIFY(aehess,
"AdaptivityEvaluator for Hessians must be provided too.");
3942 for (
int d = 0; d <
dim; d++)
3961 for (
int d = 0; d <
dim; d++)
3963 for (
int idir = 0; idir <
dim; idir++)
3969 surf_fit_grad_comp.
GetDerivative(1, idir, surf_fit_hess_comp);
3980#ifdef MFEM_USE_GSLIB
4007#ifndef MFEM_USE_GSLIB
4008 MFEM_ABORT(
"Surface fitting from source requires GSLIB!");
4012 MFEM_VERIFY(per ==
false,
"Fitting is not supported for periodic meshes.");
4032 "Nodal ordering for grid function on source mesh and current mesh"
4033 "should be the same.");
4047 "Nodal ordering for grid function on source mesh and current mesh"
4048 "should be the same.");
4078 "Fitting is not supported for periodic meshes.");
4082 else { pos = d_loc; }
4084 MFEM_VERIFY(
surf_fit_marker,
"Surface fitting has not been enabled.");
4090 bool parallel = (pfes) ?
true :
false;
4098 for (
int i = 0; i < node_cnt; i++)
4105 const int dof_i = pfes->DofToVDof(i, 0);
4106 if (parallel && pfes->GetLocalTDofNumber(dof_i) < 0) {
continue; }
4115 for (
int d = 0; d <
dim; d++)
4118 pos(d*node_cnt + i) : pos(i*
dim + d);
4121 : (*surf_fit_pos)(i*
dim + d);
4123 sigma_s = pos_s.DistanceTo(pos_s_target);
4126 err_max = std::max(err_max, sigma_s);
4133 MPI_Comm comm = pfes->GetComm();
4136 MPI_Allreduce(MPI_IN_PLACE, &dof_cnt, 1, MPI_INT, MPI_SUM, comm);
4142 err_avg = (dof_cnt > 0) ? err_sum / dof_cnt : 0.0;
4191 else { elfun = d_el; }
4261 Vector adapt_lim_gf_q, adapt_lim_gf0_q;
4262 if (adaptive_limiting)
4295 if (adaptive_limiting)
4297 const real_t diff = adapt_lim_gf_q(i) - adapt_lim_gf0_q(i);
4301 energy += weight * val;
4317 for (
int s = 0; s < dof; s++)
4320 const int scalar_dof_id = fes_fit->
VDofToDof(vdofs[s]);
4330 energy += w * sigma_e(s) * sigma_e(s);
4336 for (
int d = 0; d <
dim; d++)
4338 pos(d) =
PMatI(s, d);
4339 pos_target(d) = (*surf_fit_pos)(vdofs[d*dof + s]);
4365 for (
int e = 0; e < NEsplit; e++)
4372 for (
int i = 0; i < dof; i++)
4374 for (
int d = 0; d <
dim; d++)
4380 elfun_child(i + d*dof) = elfun(i + e*dof + d*dof*NEsplit);
4424 el_energy += weight * val;
4427 energy += el_energy;
4483 energy += weight * val;
4540 else { elfun = d_el; }
4563 Vector shape,
p, p0, d_vals, grad;
4585 d_vals.
SetSize(nqp); d_vals = 1.0;
4610 for (
int q = 0; q < nqp; q++)
4635 for (
int d = 0; d <
dim; d++)
4639 d_detW_dx(d) = dwdx.
Trace();
4646 for (
int d = 0; d <
dim; d++)
4651 Mult(Amat, work2, work1);
4653 d_Winv_dx(d) = work2.
Trace();
4655 d_Winv_dx *= -weight_m;
4656 d_detW_dx += d_Winv_dx;
4667 for (
int d = 0; d <
dim; d++)
4672 dmudxw(d) = Prod.
Trace();
4716 else { elfun = d_el; }
4757 d_vals.
SetSize(nqp); d_vals = 1.0;
4774 for (
int q = 0; q < nqp; q++)
4800 for (
int i = 0; i < dof; i++)
4802 const real_t w_shape_i = weight_m * shape(i);
4803 for (
int j = 0; j < dof; j++)
4805 const real_t w = w_shape_i * shape(j);
4806 for (
int d1 = 0; d1 <
dim; d1++)
4808 for (
int d2 = 0; d2 <
dim; d2++)
4810 elmat(d1*dof + i, d2*dof + j) += w * hess(d1, d2);
4831 Vector shape(dof), adapt_lim_gf_e, adapt_lim_gf_q, adapt_lim_gf0_q(nqp);
4845 grad_phys.
Mult(adapt_lim_gf_e, grad_ptr);
4849 for (
int q = 0; q < nqp; q++)
4853 adapt_lim_gf_grad_e.
MultTranspose(shape, adapt_lim_gf_grad_q);
4854 adapt_lim_gf_grad_q *= 2.0 * (adapt_lim_gf_q(q) - adapt_lim_gf0_q(q));
4867 Vector shape(dof), adapt_lim_gf_e, adapt_lim_gf_q, adapt_lim_gf0_q(nqp);
4881 grad_phys.
Mult(adapt_lim_gf_e, grad_ptr);
4886 Mult(grad_phys, adapt_lim_gf_grad_e, adapt_lim_gf_hess_e);
4893 for (
int q = 0; q < nqp; q++)
4898 adapt_lim_gf_grad_e.
MultTranspose(shape, adapt_lim_gf_grad_q);
4903 for (
int i = 0; i < dof *
dim; i++)
4905 const int idof = i % dof, idim = i / dof;
4906 for (
int j = 0; j <= i; j++)
4908 const int jdof = j % dof, jdim = j / dof;
4910 w * ( 2.0 * adapt_lim_gf_grad_q(idim) * shape(idof) *
4911 adapt_lim_gf_grad_q(jdim) * shape(jdof) +
4912 2.0 * (adapt_lim_gf_q(q) - adapt_lim_gf0_q(q)) *
4913 adapt_lim_gf_hess_q(idim, jdim) * shape(idof) * shape(jdof));
4915 if (i != j) { mat(j, i) += entry; }
4937 for (
int s = 0; s < dof_s; s++)
4940 const int scalar_dof_id = fes_fit->
VDofToDof(vdofs[s]);
4941 count += ((*surf_fit_marker)[scalar_dof_id]) ? 1 : 0;
4943 if (count == 0) {
return; }
4963 grad_phys.
Mult(sigma_e, grad_ptr);
4970 for (
int s = 0; s < dof_s; s++)
4973 const int scalar_dof_id = fes_fit->
VDofToDof(vdofs[s]);
4985 for (
int d = 0; d <
dim; d++)
4987 pos(d) =
PMatI(s, d);
4988 pos_target(d) = (*surf_fit_pos)(vdofs[d*dof_s + s]);
4992 for (
int d = 0; d <
dim; d++) { surf_fit_grad_e(s, d) = grad_s(d); }
4995 for (
int d = 0; d <
dim; d++)
4997 mat(s, d) += w * surf_fit_grad_e(s, d);
5018 for (
int s = 0; s < dof_s; s++)
5021 const int scalar_dof_id = fes_fit->
VDofToDof(vdofs[s]);
5022 count += ((*surf_fit_marker)[scalar_dof_id]) ? 1 : 0;
5024 if (count == 0) {
return; }
5045 grad_phys.
Mult(sigma_e, grad_ptr);
5059 Mult(grad_phys, surf_fit_grad_e, surf_fit_hess_e);
5068 for (
int s = 0; s < dof_s; s++)
5071 const int scalar_dof_id = fes_fit->
VDofToDof(vdofs[s]);
5081 surf_fit_hess_e.
GetRow(s, gg_ptr);
5087 for (
int d = 0; d <
dim; d++)
5089 pos(d) =
PMatI(s, d);
5090 pos_target(d) = (*surf_fit_pos)(vdofs[d*dof_s + s]);
5095 for (
int d = 0; d <
dim; d++) { surf_fit_grad_e(s, d) = 0.0; }
5100 for (
int idim = 0; idim <
dim; idim++)
5102 for (
int jdim = 0; jdim <= idim; jdim++)
5104 real_t entry = w * ( surf_fit_grad_e(s, idim) *
5105 surf_fit_grad_e(s, jdim) +
5106 sigma_e(s) * surf_fit_hess_s(idim, jdim));
5108 int idx = s + idim*dof_s;
5109 int jdx = s + jdim*dof_s;
5110 mat(idx, jdx) += entry;
5111 if (idx != jdx) { mat(jdx, idx) += entry; }
5119 Vector &d_el,
const int dofidx,
5120 const int dir,
const real_t e_fx,
5124 int idx = dir*dof+dofidx;
5152 else { elfun = d_el; }
5172 for (
int j = 0; j <
dim; j++)
5174 for (
int i = 0; i < dof; i++)
5204 for (
int q = 0; q < nqp; q++)
5230 else { elfun = d_el; }
5242 for (
int i = 0; i < dof; i++)
5244 for (
int j = 0; j < i+1; j++)
5246 for (
int k1 = 0; k1 <
dim; k1++)
5248 for (
int k2 = 0; k2 <
dim; k2++)
5250 d_el_mod(k2 * dof + j) +=
fd_h;
5277 real_t e_fx = ElemPertLoc(k2 * dof + j);
5280 d_el_mod(k2 * dof + j) -=
fd_h;
5281 real_t e_fpx = ElemDerLoc(k1*dof+i);
5283 elmat(k1*dof+i, k2*dof+j) = (e_fpxph - e_fpx) /
fd_h;
5284 elmat(k2*dof+j, k1*dof+i) = (e_fpxph - e_fpx) /
fd_h;
5314 for (
int q = 0; q < nqp; q++)
5333 MFEM_VERIFY(cf,
"Dynamic weight works only with a ConstantCoefficient.");
5334 cf->constant *= factor;
5343 MFEM_VERIFY(cf,
"Dynamic weight works only with a ConstantCoefficient.");
5344 return cf->constant;
5384 metric_energy = 0.0;
5388 MFEM_VERIFY(
PA.E.Size() > 0,
"Must be called after AssemblePA!");
5390 "Normalization + PA + Fitting is not implemented!");
5428 for (
int i = 0; i <
fes->
GetNE(); i++)
5434 const int dof = fe->
GetDof();
5443 for (
int q = 0; q < nqp; q++)
5456 lim_energy += weight;
5483 fd_h = std::numeric_limits<float>::max();
5486 real_t detv_avg_min = std::numeric_limits<float>::max();
5487 for (
int i = 0; i < NE; i++)
5492 for (
int j = 0; j < nsp; j++)
5496 detv_sum += std::fabs(
Jpr.
Det());
5498 real_t detv_avg = pow(detv_sum/nsp, 1./
dim);
5499 detv_avg_min = std::min(detv_avg, detv_avg_min);
5507 MFEM_VERIFY(
periodic ==
false,
"Periodic not implemented yet.");
5516 const int total_cnt = new_x.
Size()/
dim;
5518 if (new_x_ordering == 0)
5520 for (
int d = 0; d <
dim; d++)
5522 for (
int i = 0; i < cnt; i++)
5525 new_x_sorted(i + d*cnt) = new_x(dof_index + d*total_cnt);
5531 for (
int i = 0; i < cnt; i++)
5534 for (
int d = 0; d <
dim; d++)
5536 new_x_sorted(d + i*
dim) = new_x(d + dof_index*
dim);
5542 Vector surf_fit_gf_int, surf_fit_grad_int, surf_fit_hess_int;
5545 for (
int i = 0; i < cnt; i++)
5548 (*surf_fit_gf)[dof_index] = surf_fit_gf_int(i);
5560 for (
int d = 0; d < grad_dim; d++)
5562 for (
int i = 0; i < cnt; i++)
5565 (*surf_fit_grad)[dof_index + d*grad_cnt] =
5566 surf_fit_grad_int(i + d*cnt);
5572 for (
int i = 0; i < cnt; i++)
5575 for (
int d = 0; d < grad_dim; d++)
5577 (*surf_fit_grad)[dof_index*grad_dim + d] =
5578 surf_fit_grad_int(i*grad_dim + d);
5592 for (
int d = 0; d < hess_dim; d++)
5594 for (
int i = 0; i < cnt; i++)
5597 (*surf_fit_hess)[dof_index + d*hess_cnt] =
5598 surf_fit_hess_int(i + d*cnt);
5604 for (
int i = 0; i < cnt; i++)
5607 for (
int d = 0; d < hess_dim; d++)
5609 (*surf_fit_hess)[dof_index*hess_dim + d] =
5610 surf_fit_hess_int(i*hess_dim + d);
5635 if (
discr_tc) {
PA.Jtr_needs_update =
true; }
5661 if (
periodic) { MFEM_ABORT(
"Periodic not implemented yet."); }
5683 if (
periodic) { MFEM_ABORT(
"Periodic not implemented yet."); }
5709 MFEM_VERIFY(per ==
false,
"FD is not supported for periodic meshes.");
5713#ifdef MFEM_USE_GSLIB
5717 MFEM_ABORT(
"Using GSLIB-based interpolation with finite differences"
5718 "requires careful consideration. Contact TMOP team.");
5736 MFEM_VERIFY(per ==
false,
"FD is not supported for periodic meshes.");
5740#ifdef MFEM_USE_GSLIB
5744 MFEM_ABORT(
"Using GSLIB-based interpolation with finite differences"
5745 "requires careful consideration. Contact TMOP team.");
5760 real_t min_detT = std::numeric_limits<real_t>::infinity();
5768 for (
int i = 0; i < NE; i++)
5784 for (
int q = 0; q < nsp; q++)
5793 min_detT = std::min(min_detT, detT);
5802 real_t max_muT = -std::numeric_limits<real_t>::infinity();
5819 for (
int i = 0; i < NE; i++)
5838 for (
int q = 0; q < nsp; q++)
5855 max_muT = std::max(max_muT, metric_val);
5867 if (!wcuo) {
return; }
5869 if (
periodic) { MFEM_ABORT(
"Periodic not implemented yet."); }
5887 real_t min_detT_all = min_detT;
5891 MPI_Allreduce(&min_detT, &min_detT_all, 1,
5895 if (wcuo) { wcuo->
SetMinDetT(min_detT_all); }
5899 real_t max_muT_all = max_muT;
5915 MFEM_VERIFY(
tmopi.Size() > 0,
"No TMOP_Integrators were added.");
5917 tmopi[0]->EnableLimiting(n0, dist, w0, lfunc);
5918 for (
int i = 1; i <
tmopi.Size(); i++) {
tmopi[i]->DisableLimiting(); }
5925 MFEM_VERIFY(
tmopi.Size() > 0,
"No TMOP_Integrators were added.");
5927 tmopi[0]->EnableLimiting(n0, w0, lfunc);
5928 for (
int i = 1; i <
tmopi.Size(); i++) {
tmopi[i]->DisableLimiting(); }
5933 MFEM_VERIFY(
tmopi.Size() > 0,
"No TMOP_Integrators were added.");
5935 tmopi[0]->SetLimitingNodes(n0);
5936 for (
int i = 1; i <
tmopi.Size(); i++) {
tmopi[i]->DisableLimiting(); }
5944 for (
int i = 0; i <
tmopi.Size(); i++)
5946 energy +=
tmopi[i]->GetElementEnergy(el, T, elfun);
5956 MFEM_VERIFY(
tmopi.Size() > 0,
"No TMOP_Integrators were added.");
5958 tmopi[0]->AssembleElementVector(el, T, elfun, elvect);
5959 for (
int i = 1; i <
tmopi.Size(); i++)
5962 tmopi[i]->AssembleElementVector(el, T, elfun, elvect_i);
5972 MFEM_VERIFY(
tmopi.Size() > 0,
"No TMOP_Integrators were added.");
5974 tmopi[0]->AssembleElementGrad(el, T, elfun, elmat);
5975 for (
int i = 1; i <
tmopi.Size(); i++)
5978 tmopi[i]->AssembleElementGrad(el, T, elfun, elmat_i);
5989 for (
int i = 0; i <
tmopi.Size(); i++)
5991 energy +=
tmopi[i]->GetRefinementElementEnergy(el, T, elfun, irule);
6002 for (
int i = 0; i <
tmopi.Size(); i++)
6004 energy +=
tmopi[i]->GetDerefinementElementEnergy(el, T, elfun);
6012 real_t total_integral = 0.0;
6013 for (
int i = 0; i < cnt; i++)
6015 tmopi[i]->EnableNormalization(x);
6016 total_integral += 1.0 /
tmopi[i]->metric_normal;
6018 for (
int i = 0; i < cnt; i++)
6020 tmopi[i]->metric_normal = 1.0 / total_integral;
6027 const int cnt =
tmopi.Size();
6028 real_t total_integral = 0.0;
6029 for (
int i = 0; i < cnt; i++)
6031 tmopi[i]->ParEnableNormalization(x);
6032 total_integral += 1.0 /
tmopi[i]->metric_normal;
6034 for (
int i = 0; i < cnt; i++)
6036 tmopi[i]->metric_normal = 1.0 / total_integral;
6043 for (
int i = 0; i <
tmopi.Size(); i++)
6045 tmopi[i]->AssemblePA(fes);
6052 for (
int i = 0; i <
tmopi.Size(); i++)
6054 tmopi[i]->AssembleGradPA(xe,fes);
6060 for (
int i = 0; i <
tmopi.Size(); i++)
6062 tmopi[i]->AssembleGradDiagonalPA(de);
6068 for (
int i = 0; i <
tmopi.Size(); i++)
6070 tmopi[i]->AddMultPA(xe, ye);
6076 for (
int i = 0; i <
tmopi.Size(); i++)
6078 tmopi[i]->AddMultGradPA(re, ce);
6085 for (
int i = 0; i <
tmopi.Size(); i++)
6087 energy +=
tmopi[i]->GetLocalStateEnergyPA(xe);
6096 const int NE = mesh.
GetNE();
6104 for (
int i = 0; i < NE; i++)
6115 nodes.FESpace()->GetElementVDofs(i, pos_dofs);
6116 nodes.GetSubVector(pos_dofs, posV);
6121 for (
int j = 0; j < nsp; j++)
6132 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
int TotalSize() const
Total size = width*height.
real_t * Data() const
Returns the matrix data array. Warning: this method casts away constness.
real_t * GetData() const
Returns the matrix data array. Warning: this method casts away constness.
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.
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...
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 GetLocalEnergyPA_3D(const GridFunction &nodes, const TargetConstructor &tc, int m_index, real_t &energy, real_t &vol, const IntegrationRule &ir) const
void GetLocalEnergyPA_2D(const GridFunction &nodes, const TargetConstructor &tc, int m_index, real_t &energy, real_t &vol, const IntegrationRule &ir) const
void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const override
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
void ComputeAvgMetrics(const GridFunction &nodes, const TargetConstructor &tc, Vector &averages, bool use_pa=false, const IntegrationRule *IntRule=nullptr) const
AD2Type EvalW_AD2(const std::vector< AD2Type > &T, const std::vector< AD2Type > &W) const override
Second-derivative hook for AD-based computations.
void ComputeBalancedWeights(const GridFunction &nodes, const TargetConstructor &tc, Vector &weights, bool use_pa=false, const IntegrationRule *IntRule=nullptr) const
AD1Type EvalW_AD1(const std::vector< AD1Type > &T, const std::vector< AD1Type > &W) const override
First-derivative hook for AD-based computations.
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
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)
void GetNormalizationFactors(real_t &metric_normal, real_t &lim_normal, real_t &surf_fit_normal)
Get the normalization factors of the metric.
TMOP_LimiterFunction * lim_func
void ComputeAllElementTargets(const Vector &xe=Vector()) const
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
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
void GetLocalNormalizationEnergiesPA_3D(const Vector &x, real_t &met_energy, real_t &lim_energy) const
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 ComputeNormalizationEnergies(const GridFunction &x, real_t &metric_energy, real_t &lim_energy)
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).
void GetLocalNormalizationEnergiesPA_2D(const Vector &x, real_t &met_energy, real_t &lim_energy) const
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).
AD1Type EvalW_AD1(const std::vector< AD1Type > &T, const std::vector< AD1Type > &W) const override
First-derivative hook for AD-based computations.
AD2Type EvalW_AD2(const std::vector< AD2Type > &T, const std::vector< AD2Type > &W) const override
Second-derivative hook for AD-based computations.
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
type EvalW_AD_impl(const std::vector< type > &T, const std::vector< type > &W) const
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).
AD2Type EvalW_AD2(const std::vector< AD2Type > &T, const std::vector< AD2Type > &W) const override
Second-derivative hook for AD-based computations.
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
AD1Type EvalW_AD1(const std::vector< AD1Type > &T, const std::vector< AD1Type > &W) const override
First-derivative hook for AD-based computations.
real_t EvalWMatrixForm(const DenseMatrix &Jpt) const override
Evaluates the metric in matrix form (opposed to invariant form). Used for validating the invariant ev...
type EvalW_AD_impl(const std::vector< type > &T, const std::vector< type > &W) const
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...
AD2Type EvalW_AD2(const std::vector< AD2Type > &T, const std::vector< AD2Type > &W) const override
Second-derivative hook for AD-based computations.
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
type EvalW_AD_impl(const std::vector< type > &T, const std::vector< type > &W) const
AD1Type EvalW_AD1(const std::vector< AD1Type > &T, const std::vector< AD1Type > &W) const override
First-derivative hook for AD-based computations.
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 AD1Type EvalW_AD1(const std::vector< AD1Type > &T, const std::vector< AD1Type > &W) const
First-derivative hook for AD-based computations.
virtual AD2Type EvalW_AD2(const std::vector< AD2Type > &T, const std::vector< AD2Type > &W) const
Second-derivative hook for AD-based computations.
virtual int Id() const
Return the metric ID.
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,...
AD1Type EvalW_AD1(const std::vector< AD1Type > &T, const std::vector< AD1Type > &W) const override
First-derivative hook for AD-based computations.
void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const override
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
BarrierType GetBarrierType()
TMOP_QualityMetric & tmop_metric
void SetMinDetT(real_t min_detT_)
WorstCaseType GetWorstCaseType()
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 SetMaxMuT(real_t max_muT_)
real_t EvalWBarrier(const DenseMatrix &Jpt) const
AD2Type EvalW_AD2(const std::vector< AD2Type > &T, const std::vector< AD2Type > &W) const override
Second-derivative hook for AD-based computations.
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.
type mu14_ad(const std::vector< type > &T, const std::vector< type > &W)
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)
AD1Type make_one_type< AD1Type >()
future::dual< AD1Type, AD1Type > AD2Type
MFEM native AD-type for second derivatives.
void CalcAdjugateTranspose(const DenseMatrix &a, DenseMatrix &adjat)
Calculate the transposed adjugate of a matrix (for NxN matrices, N=1,2,3)
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)
future::dual< real_t, real_t > AD1Type
MFEM native AD-type for first derivatives.
void CalcInverse(const DenseMatrix &a, DenseMatrix &inva)
AD2Type make_one_type< AD2Type >()
type mu98_ad(const std::vector< type > &T, const std::vector< type > &W)
type wcuo_ad(type mu, const std::vector< type > &T, const std::vector< type > &W, real_t alpha, real_t min_detT, real_t detT_ep, int exponent, real_t max_muT, real_t muT_ep, TWCUO::BarrierType bt, TWCUO::WorstCaseType wct)
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)
type mu55_ad(const std::vector< type > &T, const std::vector< type > &W)
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)
type mu4_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)
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)
MFEM_HOST_DEVICE Complex exp(const Complex &q)
Helper struct to convert a C++ type to an MPI type.
Dual number struct (value plus gradient)
gradient_type gradient
the partial derivatives of value w.r.t. some other quantity
value_type value
the actual numerical value
std::array< int, NCMesh::MaxFaceNodes > nodes