16 #include "../general/forall.hpp" 82 Vector products_no_m(m_cnt); products_no_m = 1.0;
83 for (
int m_p = 0; m_p < m_cnt; m_p++)
85 for (
int m_a = 0; m_a < m_cnt; m_a++)
87 if (m_p != m_a) { products_no_m(m_p) *= averages(m_a); }
90 const double pnm_sum = products_no_m.
Sum();
92 if (pnm_sum == 0.0) { weights = 1.0 / m_cnt;
return; }
93 for (
int m = 0; m < m_cnt; m++) { weights(m) = products_no_m(m) / pnm_sum; }
95 MFEM_ASSERT(fabs(weights.
Sum() - 1.0) < 1e-14,
96 "Error: sum should be 1 always: " << weights.
Sum());
113 for (
int e = 0; e < NE; e++)
132 for (
int q = 0; q < nsp; q++)
142 const double w_detA = ip.
weight * A.
Det();
143 for (
int m = 0; m < m_cnt; m++)
146 averages(m) +=
tmop_q_arr[m]->EvalW(T) * w_detA;
157 MPI_Allreduce(MPI_IN_PLACE, averages.
GetData(), m_cnt,
158 MPI_DOUBLE, MPI_SUM, par_nodes->ParFESpace()->GetComm());
159 MPI_Allreduce(MPI_IN_PLACE, &volume, 1, MPI_DOUBLE, MPI_SUM,
160 par_nodes->ParFESpace()->GetComm());
171 double metric = metric_tilde;
174 metric = std::pow(metric_tilde,
exponent);
179 metric = metric_tilde/(beta-metric_tilde);
187 double denominator = 1.0;
194 double detT = Jpt.
Det();
224 MFEM_VERIFY(
Jtr != NULL,
225 "Requires a target Jacobian, use SetTargetJacobian().");
234 const double cos_Jpr = (col1 * col2) / norm_prod,
235 sin_Jpr = fabs(Jpr.
Det()) / norm_prod;
240 const double cos_Jtr = (col1 * col2) / norm_prod,
241 sin_Jtr = fabs(
Jtr->
Det()) / norm_prod;
243 return 0.5 * (1.0 - cos_Jpr * cos_Jtr - sin_Jpr * sin_Jtr);
248 MFEM_VERIFY(
Jtr != NULL,
249 "Requires a target Jacobian, use SetTargetJacobian().");
258 double norm_c1 = col1.
Norml2(),
261 double cos_Jpr_12 = (col1 * col2) / (norm_c1 * norm_c2),
262 cos_Jpr_13 = (col1 * col3) / (norm_c1 * norm_c3),
263 cos_Jpr_23 = (col2 * col3) / (norm_c2 * norm_c3);
264 double sin_Jpr_12 = std::sqrt(1.0 - cos_Jpr_12 * cos_Jpr_12),
265 sin_Jpr_13 = std::sqrt(1.0 - cos_Jpr_13 * cos_Jpr_13),
266 sin_Jpr_23 = std::sqrt(1.0 - cos_Jpr_23 * cos_Jpr_23);
274 double cos_Jtr_12 = (col1 * col2) / (norm_c1 * norm_c2),
275 cos_Jtr_13 = (col1 * col3) / (norm_c1 * norm_c3),
276 cos_Jtr_23 = (col2 * col3) / (norm_c2 * norm_c3);
277 double sin_Jtr_12 = std::sqrt(1.0 - cos_Jtr_12 * cos_Jtr_12),
278 sin_Jtr_13 = std::sqrt(1.0 - cos_Jtr_13 * cos_Jtr_13),
279 sin_Jtr_23 = std::sqrt(1.0 - cos_Jtr_23 * cos_Jtr_23);
281 return (3.0 - cos_Jpr_12 * cos_Jtr_12 - sin_Jpr_12 * sin_Jtr_12
282 - cos_Jpr_13 * cos_Jtr_13 - sin_Jpr_13 * sin_Jtr_13
283 - cos_Jpr_23 * cos_Jtr_23 - sin_Jpr_23 * sin_Jtr_23) / 6.0;
288 MFEM_VERIFY(
Jtr != NULL,
289 "Requires a target Jacobian, use SetTargetJacobian().");
303 return 0.5 * (ratio_Jpr / ratio_Jtr + ratio_Jtr / ratio_Jpr) - 1.0;
308 MFEM_VERIFY(
Jtr != NULL,
309 "Requires a target Jacobian, use SetTargetJacobian().");
318 double norm_c1 = col1.
Norml2(),
321 double ratio_Jpr_1 = norm_c1 / std::sqrt(norm_c2 * norm_c3),
322 ratio_Jpr_2 = norm_c2 / std::sqrt(norm_c1 * norm_c3),
323 ratio_Jpr_3 = norm_c3 / std::sqrt(norm_c1 * norm_c2);
331 double ratio_Jtr_1 = norm_c1 / std::sqrt(norm_c2 * norm_c3),
332 ratio_Jtr_2 = norm_c2 / std::sqrt(norm_c1 * norm_c3),
333 ratio_Jtr_3 = norm_c3 / std::sqrt(norm_c1 * norm_c2);
335 return ( 0.5 * (ratio_Jpr_1 / ratio_Jtr_1 + ratio_Jtr_1 / ratio_Jpr_1) +
336 0.5 * (ratio_Jpr_2 / ratio_Jtr_2 + ratio_Jtr_2 / ratio_Jpr_2) +
337 0.5 * (ratio_Jpr_3 / ratio_Jtr_3 + ratio_Jtr_3 / ratio_Jpr_3) - 3.0
343 return 0.5 * Jpt.
FNorm2() / Jpt.
Det() - 1.0;
424 const double c2 = weight*c1*c1;
468 MFEM_VERIFY(
Jtr != NULL,
469 "Requires a target Jacobian, use SetTargetJacobian().");
473 Id(0,0) = 1;
Id(0,1) = 0;
474 Id(1,0) = 0;
Id(1,1) = 1;
530 const double c2 = weight*c1/2;
531 const double c3 = c1*c2;
547 return 0.5*I1b*I1b - 2.0;
605 return 0.5*(I2b + 1.0/I2b) - 1.0;
636 double det = Jpt.
Det();
638 return JtJ.
FNorm2()/(det*det) - 2*Jpt.
FNorm2()/det + 2.0;
646 return I1b*(I1b - 2.0);
674 return 0.5*(I2b*I2b + 1./(I2b*I2b) - 2.);
693 const double I2 =
ie.
Get_I2(), I2inv_sq = 1.0 / (I2 * I2);
701 MFEM_VERIFY(
Jtr != NULL,
702 "Requires a target Jacobian, use SetTargetJacobian().");
708 Id(0,0) = 1;
Id(0,1) = 0;
709 Id(1,0) = 0;
Id(1,1) = 1;
710 Id *=
Mat.FNorm()/pow(2,0.5);
719 MFEM_VERIFY(
Jtr != NULL,
720 "Requires a target Jacobian, use SetTargetJacobian().");
724 Id(0,0) = 1;
Id(0,1) = 0;
725 Id(1,0) = 0;
Id(1,1) = 1;
739 return (I2b - 1.0)*(I2b - 1.0) - I2b + std::sqrt(I2b*I2b +
eps);
744 MFEM_ABORT(
"Metric not implemented yet. Use metric mu_55 instead.");
752 MFEM_ABORT(
"Metric not implemented yet. Use metric mu_55 instead.");
760 return 0.5*(I2b - 1.0)*(I2b - 1.0)/(I2b -
tau0);
771 const double c = (I2b - 1.0)/(I2b -
tau0);
787 const double c0 = 1.0/(I2b -
tau0);
788 const double c = c0*(I2b - 1.0);
799 return Jpt.FNorm() * inv.FNorm() / 3.0 - 1.0;
847 const double a = weight/(6*std::sqrt(I1b_I2b));
890 const double c1 = weight/9;
900 return Jpt.
FNorm2() / 3.0 / pow(Jpt.
Det(), 2.0 / 3.0) - 1.0;
933 const double fnorm = Jpt.FNorm();
934 return fnorm * fnorm * fnorm / pow(3.0, 1.5) / Jpt.
Det() - 1.0;
970 return (I3b - 1.0)*(I3b - 1.0) - I3b + std::sqrt(I3b*I3b +
eps);
977 const double c = 2*I3b-3+(I3b)/(std::pow((I3b*I3b+
eps),0.5));
989 const double c0 = I3b*I3b+
eps;
990 const double c1 = 2 + 1/(pow(c0,0.5)) - I3b*I3b/(pow(c0,1.5));
991 const double c2 = 2*I3b - 3 + I3b/(pow(c0,0.5));
1011 const double c = std::pow(d, -2.0/3.0);
1018 MFEM_ABORT(
"Metric not implemented yet.");
1023 const double weight,
1026 MFEM_ABORT(
"Metric not implemented yet.");
1047 const double weight,
1061 return 0.5 * (Jpt.
Det() + 1.0 / Jpt.
Det()) - 1.0;
1069 return 0.5*(I3b + 1.0/I3b) - 1.0;
1082 const double weight,
1100 invt.
Add(-1.0, Jpt);
1128 const double weight,
1142 const double c1 = weight*c0*c0;
1143 const double c2 = -2*c0*c1;
1158 adj_J_t.
Add(1.0, Jpt);
1159 return 1.0 / 6.0 / Jpt.
Det() * adj_J_t.
FNorm2();
1204 const double p13 = weight * pow(
ie.
Get_I3b(), 1.0/3.0),
1205 m13 = weight * pow(
ie.
Get_I3b(), -1.0/3.0),
1206 m23 = weight * pow(
ie.
Get_I3b(), -2.0/3.0),
1207 m43 = weight * pow(
ie.
Get_I3b(), -4.0/3.0),
1208 m53 = weight * pow(
ie.
Get_I3b(), -5.0/3.0),
1209 m73 = weight * pow(
ie.
Get_I3b(), -7.0/3.0);
1229 double fnorm = Jpt.FNorm();
1230 return fnorm * fnorm * fnorm - 3.0 * sqrt(3.0) * (log(Jpt.
Det()) + 1.0);
1270 return 0.5*(I3b - 1.0)*(I3b - 1.0)/(I3b -
tau0);
1281 const double c = (I3b - 1.0)/(I3b -
tau0);
1287 const double weight,
1302 const double c0 = 1.0/(I3b -
tau0);
1303 const double c = c0*(I3b - 1.0);
1314 const double fnorm = Jpt.FNorm();
1315 return fnorm * fnorm * fnorm / pow(3.0, 1.5) - Jpt.
Det();
1349 MFEM_VERIFY(
Jtr != NULL,
1350 "Requires a target Jacobian, use SetTargetJacobian().");
1365 Mult(AdjAt, WtW, WRK);
1375 MFEM_VERIFY(
Jtr != NULL,
1376 "Requires a target Jacobian, use SetTargetJacobian().");
1383 double sqalpha = pow(Jpr.
Det(), 0.5),
1384 sqomega = pow(
Jtr->
Det(), 0.5);
1386 return 0.5*pow(sqalpha/sqomega - sqomega/sqalpha, 2.);
1391 MFEM_VERIFY(
Jtr != NULL,
1392 "Requires a target Jacobian, use SetTargetJacobian().");
1407 MFEM_VERIFY(
Jtr != NULL,
1408 "Requires a target Jacobian, use SetTargetJacobian().");
1416 aw = Jpr.FNorm()/
Jtr->FNorm();
1428 MFEM_VERIFY(
nodes,
"Nodes are not given!");
1429 MFEM_ASSERT(
avg_volume == 0.0,
"The average volume is already computed!");
1432 const int NE = mesh->
GetNE();
1434 double volume = 0.0;
1436 for (
int i = 0; i < NE; i++)
1460 area_NE[0] = volume; area_NE[1] = NE;
1461 MPI_Allreduce(area_NE, area_NE + 2, 2, MPI_DOUBLE, MPI_SUM,
comm);
1480 const int NE = mesh->
GetNE();
1482 if (NE == 0) {
return; }
1485 "mixed meshes are not supported");
1486 MFEM_VERIFY(!fes.
IsVariableOrder(),
"variable orders are not supported");
1488 const int sdim = fes.
GetVDim();
1489 const int nvdofs = sdim*fe.GetDof();
1491 xe.
Size() == NE*nvdofs,
"invalid input Vector 'xe'!");
1501 if (dof_map->
Size() == 0) { dof_map =
nullptr; }
1505 Vector elfun_lex, elfun_nat;
1513 for (
int e = 0; e < NE; e++)
1524 const int ndofs = fe.GetDof();
1525 for (
int d = 0; d < sdim; d++)
1527 for (
int i_lex = 0; i_lex < ndofs; i_lex++)
1529 elfun_nat[(*dof_map)[i_lex]+d*ndofs] =
1530 elfun_lex[i_lex+d*ndofs];
1549 default: MFEM_ABORT(
"TargetType not added to ContainsVolumeInfo.");
1559 MFEM_CONTRACT_VAR(elfun);
1567 MFEM_ASSERT(Wideal.
Width() == Jtr.
SizeJ(),
"");
1573 for (
int i = 0; i < ir.
GetNPoints(); i++) { Jtr(i) = Wideal; }
1585 el_volume =
avg_volume / ncmesh->GetElementSizeReduction(e_id);
1589 1./W.Height()), Wideal);
1590 for (
int i = 0; i < ir.
GetNPoints(); i++) { Jtr(i) = W; }
1613 const double det = Jtr(i).Det();
1614 MFEM_VERIFY(det > 0.0,
"The given mesh is inverted!");
1615 Jtr(i).Set(std::pow(det / detW, 1./
dim), Wideal);
1621 MFEM_ABORT(
"invalid target type!");
1631 MFEM_CONTRACT_VAR(elfun);
1661 "Target type GIVEN_FULL requires a MatrixCoefficient.");
1678 MFEM_ABORT(
"Incompatible target type for analytic adaptation!");
1696 "Target type GIVEN_FULL requires a TMOPMatrixCoefficient.");
1698 for (
int d = 0; d < fe->
GetDim(); d++)
1711 MFEM_ABORT(
"Incompatible target type for analytic adaptation!");
1721 static inline void device_copy(
double *d_dest,
const double *d_src,
int size)
1723 MFEM_FORALL(i, size, d_dest[i] = d_src[i];);
1731 MFEM_VERIFY(
adapt_eval,
"SetAdaptivityEvaluator() has not been called!")
1732 MFEM_VERIFY(
ncomp > 0,
"No target specifications have been set!");
1776 MFEM_VERIFY(ndof ==
tspec.
Size()/
ncomp,
"Inconsistency in SetTspecAtIndex.");
1778 const auto tspec__d = tspec_.
Read();
1780 const int offset = idx*ndof;
1781 internal::device_copy(tspec_d + offset, tspec__d, ndof*vdim);
1788 "Discrete target size should be ordered byNodes.");
1798 "Discrete target skewness should be ordered byNodes.");
1808 "Discrete target aspect ratio should be ordered byNodes.");
1818 "Discrete target orientation should be ordered byNodes.");
1829 #endif // MFEM_USE_MPI 1846 const auto tspec_temp_d = tspec_temp.
Read();
1848 internal::device_copy(tspec_d, tspec_temp_d, tspec_temp.
Size());
1850 const auto tspec__d = tspec_.
Read();
1851 const int offset = (
ncomp-vdim)*ndof;
1852 internal::device_copy(tspec_d + offset, tspec__d, ndof*vdim);
1859 MFEM_VERIFY(ndof ==
tspec.
Size()/
ncomp,
"Inconsistency in SetTargetSpec.");
1861 const auto tspec__d = tspec_.
Read();
1863 const int offset = idx*ndof;
1864 internal::device_copy(tspec_d + offset, tspec__d, ndof*vdim);
1871 "Discrete target size should be ordered byNodes.");
1881 "Discrete target skewness should be ordered byNodes.");
1891 "Discrete target aspect ratio should be ordered byNodes.");
1901 "Discrete target orientation should be ordered byNodes.");
1910 MFEM_VERIFY(
adapt_eval,
"SetAdaptivityEvaluator() has not been called!")
1911 MFEM_VERIFY(
ncomp > 0,
"No target specifications have been set!");
1931 if (idx < 0) {
return; }
1935 "Inconsistency in GetSerialDiscreteTargetSpec.");
1937 for (
int i = 0; i < ndof*vdim; i++)
1939 tspec_(i) =
tspec(i + idx*ndof);
1966 MFEM_VERIFY(
tspec.
Size() > 0,
"Target specification is not set!");
1982 int dofidx,
int dir,
1985 MFEM_VERIFY(
tspec.
Size() > 0,
"Target specification is not set!");
1991 for (
int i = 0; i <
ncomp; i++)
1993 tspec(dofs[dofidx]+i*cnt) = IntData(dofs[dofidx] + i*cnt + dir*cnt*
ncomp);
2000 MFEM_VERIFY(
tspec.
Size() > 0,
"Target specification is not set!");
2005 for (
int i = 0; i <
ncomp; i++)
2020 ntspec_dofs = ndofs*
ncomp;
2022 Vector tspec_vals(ntspec_dofs);
2033 MFEM_ABORT(
"Incompatible target type for discrete adaptation!");
2050 MFEM_VERIFY(
tspec_fesv,
"No target specifications have been set.");
2065 ntspec_dofs = ndofs*
ncomp;
2067 Vector shape(ndofs), tspec_vals(ntspec_dofs), par_vals,
2068 par_vals_c1, par_vals_c2, par_vals_c3;
2077 MFEM_VERIFY(
amr_el >= 0,
" Target being constructed for an AMR element.");
2078 for (
int i = 0; i <
ncomp; i++)
2080 for (
int j = 0; j < ndofs; j++)
2094 for (
int q = 0; q < nqp; q++)
2099 for (
int d = 0; d < 4; d++)
2108 double min_size = par_vals.
Min();
2115 MFEM_VERIFY(min_size > 0.0,
2116 "Non-positive size propagated in the target definition.");
2118 const double size = std::max(shape * par_vals, min_size);
2119 Jtr(q).Set(std::pow(size, 1.0/
dim), Jtr(q));
2132 const double min_size = par_vals.
Min();
2133 MFEM_VERIFY(min_size > 0.0,
2134 "Non-positive aspect-ratio propagated in the target definition.");
2136 const double aspectratio = shape * par_vals;
2138 D_rho(0,0) = 1./pow(aspectratio,0.5);
2139 D_rho(1,1) = pow(aspectratio,0.5);
2149 const double rho1 = shape * par_vals_c1;
2150 const double rho2 = shape * par_vals_c2;
2151 const double rho3 = shape * par_vals_c3;
2153 D_rho(0,0) = pow(rho1,2./3.);
2154 D_rho(1,1) = pow(rho2,2./3.);
2155 D_rho(2,2) = pow(rho3,2./3.);
2160 Mult(D_rho, Temp, Jtr(q));
2170 const double skew = shape * par_vals;
2174 Q_phi(0,1) = cos(skew);
2175 Q_phi(1,1) = sin(skew);
2185 const double phi12 = shape * par_vals_c1;
2186 const double phi13 = shape * par_vals_c2;
2187 const double chi = shape * par_vals_c3;
2191 Q_phi(0,1) = cos(phi12);
2192 Q_phi(0,2) = cos(phi13);
2194 Q_phi(1,1) = sin(phi12);
2195 Q_phi(1,2) = sin(phi13)*cos(chi);
2197 Q_phi(2,2) = sin(phi13)*sin(chi);
2202 Mult(Q_phi, Temp, Jtr(q));
2212 const double theta = shape * par_vals;
2213 R_theta(0,0) = cos(theta);
2214 R_theta(0,1) = -sin(theta);
2215 R_theta(1,0) = sin(theta);
2216 R_theta(1,1) = cos(theta);
2226 const double theta = shape * par_vals_c1;
2227 const double psi = shape * par_vals_c2;
2228 const double beta = shape * par_vals_c3;
2230 double ct = cos(theta), st = sin(theta),
2231 cp = cos(psi), sp = sin(psi),
2232 cb = cos(beta), sb = sin(beta);
2235 R_theta(0,0) = ct*sp;
2236 R_theta(1,0) = st*sp;
2239 R_theta(0,1) = -st*cb + ct*cp*sb;
2240 R_theta(1,1) = ct*cb + st*cp*sb;
2241 R_theta(2,1) = -sp*sb;
2243 R_theta(0,0) = -st*sb - ct*cp*cb;
2244 R_theta(1,0) = ct*sb - st*cp*cb;
2245 R_theta(2,0) = sp*cb;
2248 Jtrcomp_q = R_theta;
2250 Mult(R_theta, Temp, Jtr(q));
2256 MFEM_ABORT(
"Incompatible target type for discrete adaptation!");
2267 MFEM_VERIFY(
tspec_fesv,
"No target specifications have been set.");
2282 ntspec_dofs = ndofs*
ncomp;
2284 Vector shape(ndofs), tspec_vals(ntspec_dofs), par_vals,
2285 par_vals_c1(ndofs), par_vals_c2(ndofs), par_vals_c3(ndofs);
2295 grad_e_c2(ndofs,
dim),
2296 grad_e_c3(ndofs,
dim);
2297 Vector grad_ptr_c1(grad_e_c1.GetData(), ndofs*
dim),
2298 grad_ptr_c2(grad_e_c2.GetData(), ndofs*
dim),
2317 grad_phys.Mult(par_vals, grad_ptr_c1);
2320 grad_e_c1.MultTranspose(shape, grad_q);
2322 const double min_size = par_vals.
Min();
2323 MFEM_VERIFY(min_size > 0.0,
2324 "Non-positive size propagated in the target definition.");
2325 const double size = std::max(shape * par_vals, min_size);
2326 double dz_dsize = (1./
dim)*pow(size, 1./
dim - 1.);
2328 Mult(Jtrcomp_q, Jtrcomp_d, work1);
2329 Mult(Jtrcomp_r, work1, work2);
2331 for (
int d = 0; d <
dim; d++)
2335 work1.
Set(dz_dsize, work1);
2337 AddMult(work1, work2, dJtr_i);
2350 grad_phys.Mult(par_vals, grad_ptr_c1);
2353 grad_e_c1.MultTranspose(shape, grad_q);
2355 const double aspectratio = shape * par_vals;
2357 dD_rho(0,0) = -0.5*pow(aspectratio,-1.5);
2358 dD_rho(1,1) = 0.5*pow(aspectratio,-0.5);
2360 Mult(Jtrcomp_s, Jtrcomp_r, work1);
2361 Mult(work1, Jtrcomp_q, work2);
2363 for (
int d = 0; d <
dim; d++)
2368 AddMult(work2, work1, dJtr_i);
2375 par_vals_c1.SetData(par_vals.
GetData());
2376 par_vals_c2.SetData(par_vals.
GetData()+ndofs);
2379 grad_phys.Mult(par_vals_c1, grad_ptr_c1);
2380 grad_phys.Mult(par_vals_c2, grad_ptr_c2);
2381 grad_phys.Mult(par_vals_c3, grad_ptr_c3);
2384 grad_e_c1.MultTranspose(shape, grad_q1);
2385 grad_e_c2.MultTranspose(shape, grad_q2);
2388 const double rho1 = shape * par_vals_c1;
2389 const double rho2 = shape * par_vals_c2;
2390 const double rho3 = shape * par_vals_c3;
2392 dD_rho(0,0) = (2./3.)*pow(rho1,-1./3.);
2393 dD_rho(1,1) = (2./3.)*pow(rho2,-1./3.);
2394 dD_rho(2,2) = (2./3.)*pow(rho3,-1./3.);
2396 Mult(Jtrcomp_s, Jtrcomp_r, work1);
2397 Mult(work1, Jtrcomp_q, work2);
2400 for (
int d = 0; d <
dim; d++)
2404 work1(0,0) *= grad_q1(d);
2405 work1(1,2) *= grad_q2(d);
2406 work1(2,2) *= grad_q3(d);
2408 AddMult(work2, work1, dJtr_i);
2420 grad_phys.Mult(par_vals, grad_ptr_c1);
2423 grad_e_c1.MultTranspose(shape, grad_q);
2425 const double skew = shape * par_vals;
2429 dQ_phi(0,1) = -sin(skew);
2430 dQ_phi(1,1) = cos(skew);
2432 Mult(Jtrcomp_s, Jtrcomp_r, work2);
2434 for (
int d = 0; d <
dim; d++)
2439 Mult(work1, Jtrcomp_d, work3);
2440 AddMult(work2, work3, dJtr_i);
2447 par_vals_c1.SetData(par_vals.
GetData());
2448 par_vals_c2.SetData(par_vals.
GetData()+ndofs);
2451 grad_phys.Mult(par_vals_c1, grad_ptr_c1);
2452 grad_phys.Mult(par_vals_c2, grad_ptr_c2);
2453 grad_phys.Mult(par_vals_c3, grad_ptr_c3);
2456 grad_e_c1.MultTranspose(shape, grad_q1);
2457 grad_e_c2.MultTranspose(shape, grad_q2);
2460 const double phi12 = shape * par_vals_c1;
2461 const double phi13 = shape * par_vals_c2;
2462 const double chi = shape * par_vals_c3;
2466 dQ_phi(0,1) = -sin(phi12);
2467 dQ_phi(1,1) = cos(phi12);
2470 dQ_phi13(0,2) = -sin(phi13);
2471 dQ_phi13(1,2) = cos(phi13)*cos(chi);
2472 dQ_phi13(2,2) = cos(phi13)*sin(chi);
2475 dQ_phichi(1,2) = -sin(phi13)*sin(chi);
2476 dQ_phichi(2,2) = sin(phi13)*cos(chi);
2478 Mult(Jtrcomp_s, Jtrcomp_r, work2);
2480 for (
int d = 0; d <
dim; d++)
2484 work1 *= grad_q1(d);
2485 work1.Add(grad_q2(d), dQ_phi13);
2486 work1.Add(grad_q3(d), dQ_phichi);
2487 Mult(work1, Jtrcomp_d, work3);
2488 AddMult(work2, work3, dJtr_i);
2500 grad_phys.Mult(par_vals, grad_ptr_c1);
2503 grad_e_c1.MultTranspose(shape, grad_q);
2505 const double theta = shape * par_vals;
2506 dR_theta(0,0) = -sin(theta);
2507 dR_theta(0,1) = -cos(theta);
2508 dR_theta(1,0) = cos(theta);
2509 dR_theta(1,1) = -sin(theta);
2511 Mult(Jtrcomp_q, Jtrcomp_d, work1);
2512 Mult(Jtrcomp_s, work1, work2);
2513 for (
int d = 0; d <
dim; d++)
2518 AddMult(work1, work2, dJtr_i);
2525 par_vals_c1.SetData(par_vals.
GetData());
2526 par_vals_c2.SetData(par_vals.
GetData()+ndofs);
2529 grad_phys.Mult(par_vals_c1, grad_ptr_c1);
2530 grad_phys.Mult(par_vals_c2, grad_ptr_c2);
2531 grad_phys.Mult(par_vals_c3, grad_ptr_c3);
2534 grad_e_c1.MultTranspose(shape, grad_q1);
2535 grad_e_c2.MultTranspose(shape, grad_q2);
2538 const double theta = shape * par_vals_c1;
2539 const double psi = shape * par_vals_c2;
2540 const double beta = shape * par_vals_c3;
2542 const double ct = cos(theta), st = sin(theta),
2543 cp = cos(psi), sp = sin(psi),
2544 cb = cos(beta), sb = sin(beta);
2547 dR_theta(0,0) = -st*sp;
2548 dR_theta(1,0) = ct*sp;
2551 dR_theta(0,1) = -ct*cb - st*cp*sb;
2552 dR_theta(1,1) = -st*cb + ct*cp*sb;
2555 dR_theta(0,0) = -ct*sb + st*cp*cb;
2556 dR_theta(1,0) = -st*sb - ct*cp*cb;
2564 dR_beta(0,1) = st*sb + ct*cp*cb;
2565 dR_beta(1,1) = -ct*sb + st*cp*cb;
2566 dR_beta(2,1) = -sp*cb;
2568 dR_beta(0,0) = -st*cb + ct*cp*sb;
2569 dR_beta(1,0) = ct*cb + st*cp*sb;
2573 dR_psi(0,0) = ct*cp;
2574 dR_psi(1,0) = st*cp;
2577 dR_psi(0,1) = 0. - ct*sp*sb;
2578 dR_psi(1,1) = 0. + st*sp*sb;
2579 dR_psi(2,1) = -cp*sb;
2581 dR_psi(0,0) = 0. + ct*sp*cb;
2582 dR_psi(1,0) = 0. + st*sp*cb;
2583 dR_psi(2,0) = cp*cb;
2585 Mult(Jtrcomp_q, Jtrcomp_d, work1);
2586 Mult(Jtrcomp_s, work1, work2);
2587 for (
int d = 0; d <
dim; d++)
2591 work1 *= grad_q1(d);
2592 work1.Add(grad_q2(d), dR_psi);
2593 work1.Add(grad_q3(d), dR_beta);
2594 AddMult(work1, work2, dJtr_i);
2602 MFEM_ABORT(
"Incompatible target type for discrete adaptation!");
2621 for (
int j = 0; j <
dim; j++)
2623 for (
int i = 0; i < cnt; i++)
2632 for (
int i = 0; i < cnt; i++)
2643 double dx,
bool use_flag,
2651 totmix = 1+2*(
dim-2);
2660 for (
int j = 0; j <
dim; j++)
2662 for (
int i = 0; i < cnt; i++)
2671 for (
int i = 0; i < cnt; i++)
2680 for (
int k1 = 0; k1 <
dim; k1++)
2682 for (
int k2 = 0; (k1 != k2) && (k2 <
dim); k2++)
2684 for (
int i = 0; i < cnt; i++)
2695 for (
int i = 0; i < cnt; i++)
2726 f.GetVDim(),
f.GetOrdering());
2737 f.GetVDim(),
f.GetOrdering());
2764 PA.H.GetMemory().DeleteDevice(copy_to_host);
2765 PA.H0.GetMemory().DeleteDevice(copy_to_host);
2766 if (!copy_to_host && !
PA.Jtr.GetMemory().HostIsValid())
2768 PA.Jtr_needs_update =
true;
2770 PA.Jtr.GetMemory().DeleteDevice(copy_to_host);
2779 for (
int i = 0; i <
ElemDer.Size(); i++)
2794 "'dist' must be a scalar GridFunction!");
2884 MFEM_VERIFY(
surf_fit_gf,
"Surface fitting has not been enabled.");
2887 double loc_max = 0.0, loc_sum = 0.0;
2893 loc_max = std::max(loc_max, std::abs((*
surf_fit_gf)(i)));
2902 MPI_Allreduce(&loc_max, &err_max, 1, MPI_DOUBLE, MPI_MAX, comm);
2903 MPI_Allreduce(&loc_cnt, &glob_cnt, 1, MPI_INT, MPI_SUM, comm);
2904 MPI_Allreduce(&loc_sum, &err_avg, 1, MPI_DOUBLE, MPI_SUM, comm);
2905 err_avg = err_avg / glob_cnt;
2907 err_avg = loc_sum / loc_cnt;
2943 const int el_id = T.ElementNo;
3007 Vector adapt_lim_gf_q, adapt_lim_gf0_q;
3008 if (adaptive_limiting)
3021 const double weight = ip.
weight * Jtr_i.
Det();
3041 if (adaptive_limiting)
3043 const double diff = adapt_lim_gf_q(i) - adapt_lim_gf0_q(i);
3047 energy += weight * val;
3059 for (
int s = 0;
s < dofs.
Size();
s++)
3066 sigma_e(
s) * sigma_e(
s);
3081 NEsplit = elfun.
Size() / (dof*
dim), el_id = T.ElementNo;
3090 for (
int e = 0; e < NEsplit; e++)
3097 for (
int i = 0; i < dof; i++)
3099 for (
int d = 0; d <
dim; d++)
3105 elfun_child(i + d*dof) = elfun(i + e*dof + d*dof*NEsplit);
3112 double el_energy = 0;
3140 const double weight = ip.
weight * Jtr_i.
Det();
3149 el_energy += weight * val;
3152 energy += el_energy;
3199 const double weight = ip.
weight * Jtr_i.
Det();
3208 energy += weight * val;
3272 Vector shape,
p, p0, d_vals, grad;
3289 d_vals.
SetSize(nqp); d_vals = 1.0;
3313 for (
int q = 0; q < nqp; q++)
3340 for (
int d = 0; d <
dim; d++)
3344 d_detW_dx(d) = dwdx.
Trace();
3351 for (
int d = 0; d <
dim; d++)
3356 Mult(Amat, work2, work1);
3358 d_Winv_dx(d) = work2.
Trace();
3360 d_Winv_dx *= -weight_m;
3362 d_detW_dx += d_Winv_dx;
3424 d_vals.
SetSize(nqp); d_vals = 1.0;
3441 for (
int q = 0; q < nqp; q++)
3467 for (
int i = 0; i < dof; i++)
3469 const double w_shape_i = weight_m * shape(i);
3470 for (
int j = 0; j < dof; j++)
3472 const double w = w_shape_i * shape(j);
3473 for (
int d1 = 0; d1 <
dim; d1++)
3475 for (
int d2 = 0; d2 <
dim; d2++)
3477 elmat(d1*dof + i, d2*dof + j) += w * hess(d1, d2);
3498 Vector shape(dof), adapt_lim_gf_e, adapt_lim_gf_q, adapt_lim_gf0_q(nqp);
3512 grad_phys.
Mult(adapt_lim_gf_e, grad_ptr);
3516 for (
int q = 0; q < nqp; q++)
3520 adapt_lim_gf_grad_e.
MultTranspose(shape, adapt_lim_gf_grad_q);
3521 adapt_lim_gf_grad_q *= 2.0 * (adapt_lim_gf_q(q) - adapt_lim_gf0_q(q));
3534 Vector shape(dof), adapt_lim_gf_e, adapt_lim_gf_q, adapt_lim_gf0_q(nqp);
3548 grad_phys.
Mult(adapt_lim_gf_e, grad_ptr);
3553 Mult(grad_phys, adapt_lim_gf_grad_e, adapt_lim_gf_hess_e);
3560 for (
int q = 0; q < nqp; q++)
3565 adapt_lim_gf_grad_e.
MultTranspose(shape, adapt_lim_gf_grad_q);
3570 for (
int i = 0; i < dof *
dim; i++)
3572 const int idof = i % dof, idim = i / dof;
3573 for (
int j = 0; j <= i; j++)
3575 const int jdof = j % dof, jdim = j / dof;
3576 const double entry =
3577 w * ( 2.0 * adapt_lim_gf_grad_q(idim) * shape(idof) *
3578 adapt_lim_gf_grad_q(jdim) * shape(jdof) +
3579 2.0 * (adapt_lim_gf_q(q) - adapt_lim_gf0_q(q)) *
3580 adapt_lim_gf_hess_q(idim, jdim) * shape(idof) * shape(jdof));
3582 if (i != j) { mat(j, i) += entry; }
3597 for (
int s = 0;
s < dofs.
Size();
s++)
3599 count += ((*surf_fit_marker)[dofs[
s]]) ? 1 : 0;
3601 if (count == 0) {
return; }
3617 grad_phys.Mult(sigma_e, grad_ptr);
3619 Vector shape_x(dof_x), shape_s(dof_s);
3622 surf_fit_grad_s = 0.0;
3624 for (
int s = 0;
s < dof_s;
s++)
3651 for (
int s = 0;
s < dofs.
Size();
s++)
3653 count += ((*surf_fit_marker)[dofs[
s]]) ? 1 : 0;
3655 if (count == 0) {
return; }
3669 grad_phys.Mult(sigma_e, grad_ptr);
3674 Mult(grad_phys, surf_fit_grad_e, surf_fit_hess_e);
3678 Vector shape_x(dof_x), shape_s(dof_s);
3684 for (
int s = 0;
s < dof_s;
s++)
3700 for (
int i = 0; i < dof_x *
dim; i++)
3702 const int idof = i % dof_x, idim = i / dof_x;
3703 for (
int j = 0; j <= i; j++)
3705 const int jdof = j % dof_x, jdim = j / dof_x;
3706 const double entry =
3707 w * ( 2.0 * surf_fit_grad_s(idim) * shape_x(idof) *
3708 surf_fit_grad_s(jdim) * shape_x(jdof) +
3709 2.0 * sigma_e(
s) * surf_fit_hess_s(idim, jdim) *
3710 shape_x(idof) * shape_x(jdof));
3712 if (i != j) { mat(j, i) += entry; }
3720 Vector &elfun,
const int dofidx,
3721 const int dir,
const double e_fx,
3725 int idx = dir*dof+dofidx;
3729 double dfdx = (e_fxph-e_fx)/
dx;
3734 (*(
ElemDer[T.ElementNo]))(idx) = dfdx;
3763 for (
int j = 0; j <
dim; j++)
3765 for (
int i = 0; i < dof; i++)
3795 for (
int q = 0; q < nqp; q++)
3821 for (
int i = 0; i < dof; i++)
3823 for (
int j = 0; j < i+1; j++)
3825 for (
int k1 = 0; k1 <
dim; k1++)
3827 for (
int k2 = 0; k2 <
dim; k2++)
3829 elfunmod(k2*dof+j) +=
dx;
3856 double e_fx = ElemPertLoc(k2*dof+j);
3859 elfunmod(k2*dof+j) -=
dx;
3860 double e_fpx = ElemDerLoc(k1*dof+i);
3862 elmat(k1*dof+i, k2*dof+j) = (e_fpxph - e_fpx) /
dx;
3863 elmat(k2*dof+j, k1*dof+i) = (e_fpxph - e_fpx) /
dx;
3893 for (
int q = 0; q < nqp; q++)
3910 MFEM_VERIFY(cf,
"Dynamic weight works only with a ConstantCoefficient.");
3911 cf->constant *= factor;
3920 MFEM_VERIFY(cf,
"Dynamic weight works only with a ConstantCoefficient.");
3921 return cf->constant;
3950 double &metric_energy,
3952 double &surf_fit_gf_energy)
3963 metric_energy = 0.0;
3965 surf_fit_gf_energy = 0.0;
3966 for (
int i = 0; i <
fes->
GetNE(); i++)
3972 const int dof = fe->
GetDof();
3981 for (
int q = 0; q < nqp; q++)
3986 const double weight = ip.
weight *
Jtr(q).Det();
3993 lim_energy += weight;
4003 for (
int s = 0;
s < dofs.
Size();
s++)
4007 surf_fit_gf_energy += sigma_e(
s) * sigma_e(
s);
4033 dx = std::numeric_limits<float>::max();
4036 double detv_avg_min = std::numeric_limits<float>::max();
4037 for (
int i = 0; i < NE; i++)
4042 for (
int j = 0; j < nsp; j++)
4046 detv_sum += std::fabs(
Jpr.
Det());
4048 double detv_avg = pow(detv_sum/nsp, 1./
dim);
4049 detv_avg_min = std::min(detv_avg, detv_avg_min);
4059 PA.Jtr_needs_update =
true;
4084 MPI_Allreduce(&
dx, &min_jac_all, 1, MPI_DOUBLE, MPI_MIN, pfes->
GetComm());
4097 #ifdef MFEM_USE_GSLIB 4099 if (dynamic_cast<const InterpolatorFP *>(ae))
4101 MFEM_ABORT(
"Using GSLIB-based interpolation with finite differences" 4102 "requires careful consideration. Contact TMOP team.");
4119 #ifdef MFEM_USE_GSLIB 4121 if (dynamic_cast<const InterpolatorFP *>(ae))
4123 MFEM_ABORT(
"Using GSLIB-based interpolation with finite differences" 4124 "requires careful consideration. Contact TMOP team.");
4145 for (
int i = 0; i < NE; i++)
4161 for (
int q = 0; q < nsp; q++)
4170 min_detT = std::min(min_detT, detT);
4196 for (
int i = 0; i < NE; i++)
4215 for (
int q = 0; q < nsp; q++)
4225 double metric_val = 0.0;
4232 max_muT = std::max(max_muT, metric_val);
4244 if (!wcuo) {
return; }
4255 double min_detT_all = min_detT;
4259 MPI_Allreduce(&min_detT, &min_detT_all, 1, MPI_DOUBLE, MPI_MIN,
4263 if (wcuo) { wcuo->
SetMinDetT(min_detT_all); }
4267 double max_muT_all = max_muT;
4271 MPI_Allreduce(&max_muT, &max_muT_all, 1, MPI_DOUBLE, MPI_MAX,
4283 MFEM_VERIFY(
tmopi.Size() > 0,
"No TMOP_Integrators were added.");
4285 tmopi[0]->EnableLimiting(n0, dist, w0, lfunc);
4286 for (
int i = 1; i <
tmopi.Size(); i++) {
tmopi[i]->DisableLimiting(); }
4293 MFEM_VERIFY(
tmopi.Size() > 0,
"No TMOP_Integrators were added.");
4295 tmopi[0]->EnableLimiting(n0, w0, lfunc);
4296 for (
int i = 1; i <
tmopi.Size(); i++) {
tmopi[i]->DisableLimiting(); }
4301 MFEM_VERIFY(
tmopi.Size() > 0,
"No TMOP_Integrators were added.");
4303 tmopi[0]->SetLimitingNodes(n0);
4304 for (
int i = 1; i <
tmopi.Size(); i++) {
tmopi[i]->DisableLimiting(); }
4312 for (
int i = 0; i <
tmopi.Size(); i++)
4314 energy +=
tmopi[i]->GetElementEnergy(el, T, elfun);
4324 MFEM_VERIFY(
tmopi.Size() > 0,
"No TMOP_Integrators were added.");
4326 tmopi[0]->AssembleElementVector(el, T, elfun, elvect);
4327 for (
int i = 1; i <
tmopi.Size(); i++)
4330 tmopi[i]->AssembleElementVector(el, T, elfun, elvect_i);
4340 MFEM_VERIFY(
tmopi.Size() > 0,
"No TMOP_Integrators were added.");
4342 tmopi[0]->AssembleElementGrad(el, T, elfun, elmat);
4343 for (
int i = 1; i <
tmopi.Size(); i++)
4346 tmopi[i]->AssembleElementGrad(el, T, elfun, elmat_i);
4357 for (
int i = 0; i <
tmopi.Size(); i++)
4359 energy +=
tmopi[i]->GetRefinementElementEnergy(el, T, elfun, irule);
4370 for (
int i = 0; i <
tmopi.Size(); i++)
4372 energy +=
tmopi[i]->GetDerefinementElementEnergy(el, T, elfun);
4379 const int cnt =
tmopi.Size();
4380 double total_integral = 0.0;
4381 for (
int i = 0; i < cnt; i++)
4383 tmopi[i]->EnableNormalization(x);
4384 total_integral += 1.0 /
tmopi[i]->metric_normal;
4386 for (
int i = 0; i < cnt; i++)
4388 tmopi[i]->metric_normal = 1.0 / total_integral;
4395 const int cnt =
tmopi.Size();
4396 double total_integral = 0.0;
4397 for (
int i = 0; i < cnt; i++)
4399 tmopi[i]->ParEnableNormalization(x);
4400 total_integral += 1.0 /
tmopi[i]->metric_normal;
4402 for (
int i = 0; i < cnt; i++)
4404 tmopi[i]->metric_normal = 1.0 / total_integral;
4411 for (
int i = 0; i <
tmopi.Size(); i++)
4413 tmopi[i]->AssemblePA(fes);
4420 for (
int i = 0; i <
tmopi.Size(); i++)
4422 tmopi[i]->AssembleGradPA(xe,fes);
4428 for (
int i = 0; i <
tmopi.Size(); i++)
4430 tmopi[i]->AssembleGradDiagonalPA(de);
4436 for (
int i = 0; i <
tmopi.Size(); i++)
4438 tmopi[i]->AddMultPA(xe, ye);
4444 for (
int i = 0; i <
tmopi.Size(); i++)
4446 tmopi[i]->AddMultGradPA(re, ce);
4452 double energy = 0.0;
4453 for (
int i = 0; i <
tmopi.Size(); i++)
4455 energy +=
tmopi[i]->GetLocalStateEnergyPA(xe);
4464 const int NE = mesh.
GetNE();
4472 for (
int i = 0; i < NE; i++)
4489 for (
int j = 0; j < nsp; j++)
4500 metric_gf(gf_dofs[j]) = metric.
EvalW(T);
Abstract class for all finite elements.
void ComputeUntangleMetricQuantiles(const Vector &x, const FiniteElementSpace &fes)
InvariantsEvaluator2D< double > ie
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...
virtual double GetDerefinementElementEnergy(const FiniteElement &el, ElementTransformation &T, const Vector &elfun)
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
virtual double EvalWMatrixForm(const DenseMatrix &Jpt) const
Evaluates the metric in matrix form (opposed to invariant form). Used for validating the invariant ev...
virtual void SetParDiscreteTargetSize(const ParGridFunction &tspec_)
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...
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const double weight, DenseMatrix &A) const
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
InvariantsEvaluator3D< double > ie
virtual void SetInitialField(const Vector &init_nodes, const Vector &init_field)=0
int GetNPoints() const
Returns the number of the points in the integration rule.
virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const double weight, DenseMatrix &A) const
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const double weight, DenseMatrix &A) const =0
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
void AddMultVWt(const Vector &v, const Vector &w, DenseMatrix &VWt)
VWt += v w^t.
InvariantsEvaluator3D< double > ie
void AssembleElemVecSurfFit(const FiniteElement &el_x, IsoparametricTransformation &Tpr, DenseMatrix &mat)
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
Class for an integration rule - an Array of IntegrationPoint.
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
VectorCoefficient * vector_tspec
bool IsVariableOrder() const
Returns true if the space contains elements of varying polynomial orders.
void EnableFiniteDifferences(const GridFunction &x)
Enables FD-based approximation and computes dx.
void NewDataAndSize(double *d, int s)
Set the Vector data and size, deleting the old data, if owned.
const TargetType target_type
Class for grid function - Vector with associated FE space.
virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const double weight, DenseMatrix &A) const
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
void ComputeAvgMetrics(const GridFunction &nodes, const TargetConstructor &tc, Vector &averages) const
void UseExternalData(double *ext_data, int i, int j, int k)
virtual void Update(bool want_transform=true)
Reflect changes in the mesh: update number of DOFs, etc. Also, calculate GridFunction transformation ...
InvariantsEvaluator3D< double > ie
InvariantsEvaluator3D< double > ie
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
void Assemble_ddI2b(scalar_t w, scalar_t *A)
const IntegrationRule & Get(int GeomType, int Order)
Returns an integration rule for given GeomType and Order.
double GetSurfaceFittingWeight()
Get the surface fitting weight.
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
Base class for vector Coefficients that optionally depend on time and space.
A coefficient that is constant across space and time.
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const double weight, DenseMatrix &A) const
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
void Assemble_ddI2b(scalar_t w, scalar_t *A)
void ComputeBalancedWeights(const GridFunction &nodes, const TargetConstructor &tc, Vector &weights) const
Geometry::Type GetElementBaseGeometry(int i) const
void SetDerivativeMatrix(int height, const scalar_t *Deriv)
The Deriv matrix is dof x 2, using column-major storage.
const GridFunction * lim_dist
virtual void SetSerialDiscreteTargetOrientation(const GridFunction &tspec_)
virtual double GetElementEnergy(const FiniteElement &el, ElementTransformation &T, const Vector &elfun)
Compute the local energy.
bool UsesPhysicalCoordinates() const
Return true if the methods ComputeElementTargets(), ComputeAllElementTargets(), and ComputeElementTar...
struct mfem::TMOP_Integrator::@23 PA
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
virtual void ComputeAtNewPosition(const Vector &new_nodes, Vector &new_field, int new_nodes_ordering=Ordering::byNODES)=0
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 ...
InvariantsEvaluator2D< double > ie
void EnableNormalization(const GridFunction &x)
Computes the normalization factors of the metric and limiting integrals using the mesh position given...
const scalar_t * Get_dI3b()
const IntegrationRule & GradientIntegrationRule(const FiniteElement &el) const
void SetSize(int s)
Resize the vector to size s.
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.
TMOP_QualityMetric * metric
InvariantsEvaluator2D< double > ie
Base class for limiting functions to be used in class TMOP_Integrator.
virtual const double * HostRead() const
Shortcut for mfem::Read(vec.GetMemory(), vec.Size(), false).
virtual void ComputeElementTargetsGradient(const IntegrationRule &ir, const Vector &elfun, IsoparametricTransformation &Tpr, DenseTensor &dJtr) const
virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const double weight, DenseMatrix &A) const
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
virtual double EvalW(const DenseMatrix &Jpt) const =0
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
virtual void UseDevice(bool use_dev) const
Enable execution of Vector operations using the mfem::Device.
virtual void Eval_d2(const Vector &x, const Vector &x0, double dist, DenseMatrix &d2) const =0
Returns the Hessian of the limiting function f(x, x0, d) with respect to x.
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
void Mult(const Table &A, const Table &B, Table &C)
C = A * B (as boolean matrices)
virtual void Update(bool want_transform=true)
void ParUpdateAfterMeshTopologyChange()
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 Width() const
Get the width (size of input) of the Operator. Synonym with NumCols().
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const =0
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
InvariantsEvaluator2D< double > ie
int Size() const
Returns the size of the vector.
virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const double weight, DenseMatrix &A) const
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
ParFiniteElementSpace * pfes
Data type dense matrix using column-major storage.
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
void GetSurfaceFittingErrors(double &err_avg, double &err_max)
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
double * Data() const
Returns the matrix data array.
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
int GetNDofs() const
Returns number of degrees of freedom.
void EnableAdaptiveLimiting(const GridFunction &z0, Coefficient &coeff, AdaptivityEvaluator &ae)
Restriction of the node positions to certain regions.
virtual const double * Read(bool on_dev=true) const
Shortcut for mfem::Read(vec.GetMemory(), vec.Size(), on_dev).
virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const double weight, DenseMatrix &A) const
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const double weight, DenseMatrix &A) const
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
void EnableNormalization(const GridFunction &x)
Normalization factor that considers all integrators in the combination.
virtual double EvalWMatrixForm(const DenseMatrix &Jpt) const
Evaluates the metric in matrix form (opposed to invariant form). Used for validating the invariant ev...
TMOP_QualityMetric & tmop_metric
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
virtual void Mult(const Vector &x, Vector &y) const =0
Operator application: y=A(x).
const AdaptivityEvaluator * GetAdaptivityEvaluator() const
Abstract parallel finite element space.
virtual void AssemblePA(const FiniteElementSpace &)
Method defining partial assembly.
InvariantsEvaluator2D< double > ie
void SetSerialMetaInfo(const Mesh &m, const FiniteElementSpace &f)
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
void UpdateGradientTargetSpecification(const Vector &x, double dx, bool use_flag=false, int x_ordering=Ordering::byNODES)
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
const IntegrationRule * ir
InvariantsEvaluator2D< double > ie
void AssembleElementVectorFD(const FiniteElement &el, ElementTransformation &T, const Vector &elfun, Vector &elvect)
const GridFunction * nodes
virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const double weight, DenseMatrix &A) const
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
virtual void SetSerialDiscreteTargetSkew(const GridFunction &tspec_)
void GetSubVector(const Array< int > &dofs, Vector &elemvect) const
Extract entries listed in dofs to the output Vector elemvect.
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
void UpdateSurfaceFittingWeight(double factor)
Update the surface fitting weight as surf_fit_coeff *= factor;.
void SetRefinementSubElement(int amr_el_)
void Assemble_TProd(scalar_t w, const scalar_t *X, const scalar_t *Y, scalar_t *A)
void Assemble_ddI1(scalar_t w, scalar_t *A)
virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const double weight, DenseMatrix &A) const
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
Default limiter function in TMOP_Integrator.
virtual double GetLocalStateEnergyPA(const Vector &) const
Compute the local (to the MPI rank) energy with partial assembly.
void Set(double alpha, const double *A)
Set the matrix to alpha * A, assuming that A has the same dimensions as the matrix and uses column-ma...
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
void AssembleElementGradExact(const FiniteElement &el, ElementTransformation &T, const Vector &elfun, DenseMatrix &elmat)
virtual void AddMultGradPA(const Vector &, Vector &) const
Method for partially assembled gradient action.
Array< Vector * > ElemDer
double Trace() const
Trace of a square matrix.
const Vector & GetTspecPertMixH()
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 Assemble_ddI2(scalar_t w, scalar_t *A)
Coefficient * scalar_tspec
virtual const FiniteElement * GetFE(int i) const
Returns pointer to the FiniteElement in the FiniteElementCollection associated with i'th element in t...
virtual void SetSerialDiscreteTargetAspectRatio(const GridFunction &tspec_)
int GetNumGeometries(int dim) const
Return the number of geometries of the given dimension present in the mesh.
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
IntegrationRules IntRules(0, Quadrature1D::GaussLegendre)
A global object with all integration rules (defined in intrules.cpp)
const Array< int > & GetDofMap() const
Get an Array<int> that maps lexicographically ordered indices to the indices of the respective nodes/...
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
const IntegrationRule & EnergyIntegrationRule(const FiniteElement &el) const
double ComputeUntanglerMaxMuBarrier(const Vector &x, const FiniteElementSpace &fes)
Geometry::Type GetGeomType() const
Returns the Geometry::Type of the reference element.
void Add(const DenseMatrix &A, const DenseMatrix &B, double alpha, DenseMatrix &C)
C = A + alpha*B.
Abstract class for local mesh quality metrics in the target-matrix optimization paradigm (TMOP) by P...
virtual double EvalWMatrixForm(const DenseMatrix &Jpt) const
Evaluates the metric in matrix form (opposed to invariant form). Used for validating the invariant ev...
void FinalizeSerialDiscreteTargetSpec(const GridFunction &tspec_)
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
IntegrationPoint & IntPoint(int i)
Returns a reference to the i-th integration point.
virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const double weight, DenseMatrix &A) const
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
Coefficient * adapt_lim_coeff
virtual ~AdaptivityEvaluator()
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
void SetJacobian(const scalar_t *Jac)
The Jacobian should use column-major storage.
void CalcAdjugateTranspose(const DenseMatrix &a, DenseMatrix &adjat)
Calculate the transposed adjugate of a matrix (for NxN matrices, N=1,2,3)
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
void Assemble_ddI3b(scalar_t w, scalar_t *A)
InvariantsEvaluator3D< double > ie
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
void SetLimitingNodes(const GridFunction &n0)
Update the original/reference nodes used for limiting.
void SetDiscreteTargetBase(const GridFunction &tspec_)
AdaptivityEvaluator * adapt_lim_eval
void GetValues(int i, const IntegrationRule &ir, Vector &vals, int vdim=1) const
double f(const Vector &xvec)
double * GetData() const
Returns the matrix data array.
virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const double weight, DenseMatrix &A) const
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
virtual double EvalWBarrier(const DenseMatrix &Jpt) const
void AddMult(const DenseMatrix &b, const DenseMatrix &c, DenseMatrix &a)
Matrix matrix multiplication. A += B * C.
DiscreteAdaptTC * discr_tc
void EnableLimiting(const GridFunction &n0, const GridFunction &dist, Coefficient &w0, TMOP_LimiterFunction *lfunc=NULL)
Limiting of the mesh displacements (general version).
virtual double EvalWMatrixForm(const DenseMatrix &Jpt) const
Evaluates the metric in matrix form (opposed to invariant form). Used for validating the invariant ev...
virtual WorstCaseType GetWorstCaseType()
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
void UpdateTargetSpecificationAtNode(const FiniteElement &el, ElementTransformation &T, int nodenum, int idir, const Vector &IntData)
int Size() const
For backward compatibility define Size to be synonym of Width()
void SetTspecFromIntRule(int e_id, const IntegrationRule &intrule)
virtual int Id() const
Return the metric ID.
virtual void Update()
Transform by the Space UpdateMatrix (e.g., on Mesh change).
const FiniteElementCollection * FEColl() const
void UpdateAfterMeshPositionChange(const Vector &new_x, int new_x_ordering=Ordering::byNODES)
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
void Add(const double c, const DenseMatrix &A)
Adds the matrix A multiplied by the number c to the matrix.
void MultTranspose(const double *x, double *y) const
Multiply a vector with the transpose matrix.
void ResetRefinementTspecData()
InvariantsEvaluator2D< double > ie
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
virtual double EvalWMatrixForm(const DenseMatrix &Jpt) const
Evaluates the metric in matrix form (opposed to invariant form). Used for validating the invariant ev...
void ClearGeometricFactors()
void AssembleElementVectorExact(const FiniteElement &el, ElementTransformation &T, const Vector &elfun, Vector &elvect)
const TargetConstructor * targetC
ParMesh * GetParMesh() const
Array< Vector * > ElemPertEnergy
const GridFunction * lim_nodes0
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...
const ParGridFunction * adapt_lim_pgf0
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
double Sum() const
Return the sum of the vector entries.
const scalar_t * Get_dI2b()
InvariantsEvaluator2D< double > ie
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
void SetDerivativeMatrix(int height, const scalar_t *Deriv)
The Deriv matrix is dof x 3, using column-major storage.
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
virtual void AssembleGradPA(const Vector &, const FiniteElementSpace &)
Prepare the integrator for partial assembly (PA) gradient evaluations on the given FE space fes at th...
InvariantsEvaluator3D< double > ie
virtual void SetParDiscreteTargetAspectRatio(const ParGridFunction &tspec_)
virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const double weight, DenseMatrix &A) const
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
virtual void ComputeElementTargetsGradient(const IntegrationRule &ir, const Vector &elfun, IsoparametricTransformation &Tpr, DenseTensor &dJtr) const
void GetColumn(int c, Vector &col) const
void SetSize(int i, int j, int k, MemoryType mt_=MemoryType::PRESERVE)
void ParEnableNormalization(const ParGridFunction &x)
InvariantsEvaluator2D< double > ie
virtual void ProjectGrad(const FiniteElement &fe, ElementTransformation &Trans, DenseMatrix &grad) const
Compute the discrete gradient matrix from the given FiniteElement onto 'this' FiniteElement. The ElementTransformation is included to support cases when the matrix depends on it.
int GetNumRootElements()
Return the number of root elements.
double FNorm2() const
Compute the square of the Frobenius norm of the matrix.
virtual void AssembleElementVector(const FiniteElement &el, ElementTransformation &T, const Vector &elfun, Vector &elvect)
Perform the local action of the NonlinearFormIntegrator.
InvariantsEvaluator2D< double > ie
FiniteElementSpace * tspec_fesv
A class for non-conforming AMR. The class is not used directly by the user, rather it is an extension...
Coefficient * metric_coeff
void AssembleElemGradSurfFit(const FiniteElement &el_x, IsoparametricTransformation &Tpr, DenseMatrix &mat)
FiniteElementSpace * FESpace()
TMOP_QualityMetric * h_metric
Array< TMOP_QualityMetric * > tmop_q_arr
void Mult(const double *x, double *y) const
Matrix vector multiplication.
int GetNE() const
Returns number of elements in the mesh.
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
virtual BarrierType GetBarrierType()
void Assemble_ddI1b(scalar_t w, scalar_t *A)
void RestoreTargetSpecificationAtNode(ElementTransformation &T, int nodenum)
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
void SetTspecAtIndex(int idx, const GridFunction &tspec_)
virtual double GetRefinementElementEnergy(const FiniteElement &el, ElementTransformation &T, const Vector &elfun, const IntegrationRule &irule)
Computes the mean of the energies of the given element's children.
double * GetData() const
Return a pointer to the beginning of the Vector data.
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
void CalcInverse(const DenseMatrix &a, DenseMatrix &inva)
virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const double weight, DenseMatrix &A) const
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
int GetVDim() const
Returns vector dimension.
DofTransformation * GetElementVDofs(int i, Array< int > &vdofs) const
Returns indexes of degrees of freedom in array dofs for i'th element.
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
AdaptivityEvaluator * surf_fit_eval
virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const double weight, DenseMatrix &A) const
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
Mesh * GetMesh() const
Returns the mesh.
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const double weight, DenseMatrix &A) const
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const double weight, DenseMatrix &A) const
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
double p(const Vector &x, double t)
virtual void SetTargetJacobian(const DenseMatrix &Jtr_)
Specify the reference-element -> target-element Jacobian matrix for the point of interest.
void Transpose()
(*this) = (*this)^t
int GetDim() const
Returns the reference space dimension for the finite element.
ComplexDenseMatrix * MultAtB(const ComplexDenseMatrix &A, const ComplexDenseMatrix &B)
Multiply the complex conjugate transpose of a matrix A with a matrix B. A^H*B.
void AssembleElemGradAdaptLim(const FiniteElement &el, IsoparametricTransformation &Tpr, const IntegrationRule &ir, const Vector &weights, DenseMatrix &m)
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
void AddMultABt(const DenseMatrix &A, const DenseMatrix &B, DenseMatrix &ABt)
ABt += A * B^t.
virtual void AssembleElementGrad(const FiniteElement &el, ElementTransformation &T, const Vector &elfun, DenseMatrix &elmat)
Assemble the local gradient matrix.
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const double weight, DenseMatrix &A) const
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const double weight, DenseMatrix &A) const
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
void Assemble_ddI2(scalar_t w, scalar_t *A)
const scalar_t * Get_dI1()
virtual double EvalWMatrixForm(const DenseMatrix &Jpt) const
Evaluates the metric in matrix form (opposed to invariant form). Used for validating the invariant ev...
Base class Coefficients that optionally depend on space and time. These are used by the BilinearFormI...
InvariantsEvaluator3D< double > ie
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
TMOPMatrixCoefficient * matrix_tspec
virtual double EvalWMatrixForm(const DenseMatrix &Jpt) const
Evaluates the metric in matrix form (opposed to invariant form). Used for validating the invariant ev...
double Min() const
Returns the minimal element of the vector.
ParFiniteElementSpace * ParFESpace() const
const scalar_t * Get_dI1()
void SetSize(int nsize)
Change the logical size of the array, keep existing entries.
virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const double weight, DenseMatrix &A) const
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
virtual bool ContainsVolumeInfo() const
Checks if the target matrices contain non-trivial size specification.
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
InvariantsEvaluator2D< double > ie
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
void MultAAt(const DenseMatrix &a, DenseMatrix &aat)
Calculate the matrix A.At.
void ReleasePADeviceMemory(bool copy_to_host=true)
double * HostWrite()
Shortcut for mfem::Write(GetMemory(), TotalSize(), false).
virtual void AssembleElementGrad(const FiniteElement &el, ElementTransformation &T, const Vector &elfun, DenseMatrix &elmat)
Assemble the local gradient matrix.
int GetDof() const
Returns the number of degrees of freedom in the finite element.
void CalcInverseTranspose(const DenseMatrix &a, DenseMatrix &inva)
Calculate the inverse transpose of a matrix (for NxN matrices, N=1,2,3)
int Height() const
Get the height (size of output) of the Operator. Synonym with NumRows().
const scalar_t * Get_dI1b()
int NumCols() const
Get the number of columns (size of input) of the Operator. Synonym with Width().
void SetDataAndSize(double *d, int s)
Set the Vector data and size.
void SetParMetaInfo(const ParMesh &m, const ParFiniteElementSpace &f)
Parallel version of SetSerialMetaInfo.
virtual DofTransformation * GetElementDofs(int elem, Array< int > &dofs) const
Returns indices of degrees of freedom of element 'elem'.
virtual void Update()
Transform by the Space UpdateMatrix (e.g., on Mesh change).
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
const scalar_t * Get_dI1b()
virtual double EvalWMatrixForm(const DenseMatrix &Jpt) const
Evaluates the metric in matrix form (opposed to invariant form). Used for validating the invariant ev...
void UpdateAfterMeshTopologyChange()
virtual void SetMaxMuT(double max_muT_)
virtual void SetMinDetT(double min_detT_)
InvariantsEvaluator3D< double > ie
int GetNE() const
Returns number of elements.
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...
void ComputeFDh(const Vector &x, const FiniteElementSpace &fes)
Determines the perturbation, h, for FD-based approximation.
const scalar_t * Get_dI2b()
virtual double * ReadWrite(bool on_dev=true)
Shortcut for mfem::ReadWrite(vec.GetMemory(), vec.Size(), on_dev).
virtual double EvalWMatrixForm(const DenseMatrix &Jpt) const
Evaluates the metric in matrix form (opposed to invariant form). Used for validating the invariant ev...
void ComputeNormalizationEnergies(const GridFunction &x, double &metric_energy, double &lim_energy, double &surf_fit_gf_energy)
virtual double Eval(const Vector &x, const Vector &x0, double d) const =0
Returns the limiting function, f(x, x0, d).
Coefficient * surf_fit_coeff
Class for integration point with weight.
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
void UpdateHessianTargetSpecification(const Vector &x, double dx, bool use_flag=false, int x_ordering=Ordering::byNODES)
AdaptivityEvaluator * adapt_eval
virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const double weight, DenseMatrix &A) const
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
ParFiniteElementSpace * ptspec_fesv
InvariantsEvaluator3D< double > ie
void Assemble_TProd(scalar_t w, const scalar_t *X, const scalar_t *Y, scalar_t *A)
const FiniteElementSpace * fes
Array< TMOP_Integrator * > tmopi
const scalar_t * Get_dI2()
void ComputeMinJac(const Vector &x, const FiniteElementSpace &fes)
void GetElementTransformation(int i, IsoparametricTransformation *ElTr)
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
const IntegrationRule & ActionIntegrationRule(const FiniteElement &el) const
Ordering::Type GetOrdering() const
Return the ordering method.
double GetFDDerivative(const FiniteElement &el, ElementTransformation &T, Vector &elfun, const int nodenum, const int idir, const double baseenergy, bool update_stored)
virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const double weight, DenseMatrix &A) const
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
virtual double GetElementEnergy(const FiniteElement &el, ElementTransformation &T, const Vector &elfun)
Computes the integral of W(Jacobian(Trt)) over a target zone.
void AssembleElemVecAdaptLim(const FiniteElement &el, IsoparametricTransformation &Tpr, const IntegrationRule &ir, const Vector &weights, DenseMatrix &mat)
void ParUpdateAfterMeshTopologyChange()
virtual double GetDerefinementElementEnergy(const FiniteElement &el, ElementTransformation &T, const Vector &elfun)
void ComputeAvgVolume() const
void Assemble_ddI1(scalar_t w, scalar_t *A)
virtual void Eval_d1(const Vector &x, const Vector &x0, double dist, Vector &d1) const =0
Returns the gradient of the limiting function f(x, x0, d) with respect to x.
const Operator * GetUpdateOperator()
Get the GridFunction update operator.
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
const Vector & GetTspecPert2H()
virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const double weight, DenseMatrix &A) const
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
const Vector & GetTspecPert1H()
void AssembleElementGradFD(const FiniteElement &el, ElementTransformation &T, const Vector &elfun, DenseMatrix &elmat)
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
InvariantsEvaluator2D< double > ie
double infinity()
Define a shortcut for std::numeric_limits<double>::infinity()
const DenseMatrix & GetGeomToPerfGeomJac(int GeomType) const
virtual void SetParDiscreteTargetSpec(const ParGridFunction &tspec_)
InvariantsEvaluator2D< double > ie
double Norml2() const
Returns the l2 norm of the vector.
NCMesh * ncmesh
Optional nonconforming mesh extension.
void GetVectorValues(int i, const IntegrationRule &ir, DenseMatrix &vals, DenseMatrix &tr) const
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
int Size() const
Return the logical size of the array.
virtual double Eval(ElementTransformation &T, const IntegrationPoint &ip)=0
Evaluate the coefficient in the element described by T at the point ip.
GridFunction * adapt_lim_gf
const scalar_t * Get_dI2()
GridFunction * surf_fit_gf
void FinalizeParDiscreteTargetSpec(const ParGridFunction &tspec_)
ParGridFunction * tspec_pgf
void GetDiscreteTargetSpec(GridFunction &tspec_, int idx)
Get one of the discrete fields from tspec.
const Array< bool > * surf_fit_marker
virtual double EvalWMatrixForm(const DenseMatrix &Jpt) const
Evaluates the metric in matrix form (opposed to invariant form). Used for validating the invariant ev...
InvariantsEvaluator3D< double > ie
virtual void AssembleGradDiagonalPA(Vector &) const
Method for computing the diagonal of the gradient with partial assembly.
void SetTspecDataForDerefinement(FiniteElementSpace *fes)
Computes target specification data with respect to the coarse FE space.
void UpdateTargetSpecification(const Vector &new_x, bool use_flag=false, int new_x_ordering=Ordering::byNODES)
void GetNodes(Vector &node_coord) const
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 DeleteGeometricFactors()
Destroy all GeometricFactors stored by the Mesh.
InvariantsEvaluator3D< double > ie
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
virtual void SetSerialDiscreteTargetSpec(const GridFunction &tspec_)
virtual void SetParDiscreteTargetSkew(const ParGridFunction &tspec_)
virtual double EvalWMatrixForm(const DenseMatrix &Jpt) const
Evaluates the metric in matrix form (opposed to invariant form). Used for validating the invariant ev...
virtual void ComputeElementTargetsGradient(const IntegrationRule &ir, const Vector &elfun, IsoparametricTransformation &Tpr, DenseTensor &dJtr) const
virtual double GetRefinementElementEnergy(const FiniteElement &el, ElementTransformation &T, const Vector &elfun, const IntegrationRule &irule)
virtual void SetParDiscreteTargetOrientation(const ParGridFunction &tspec_)
void UseExternalData(double *d, int h, int w)
Change the data array and the size of the DenseMatrix.
Class for parallel grid function.
void Assemble_ddI1b(scalar_t w, scalar_t *A)
Base class representing target-matrix construction algorithms for mesh optimization via the target-ma...
void SetSize(int s)
Change the size of the DenseMatrix to s x s.
virtual ~DiscreteAdaptTC()
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...
virtual void SetAnalyticTargetSpec(Coefficient *sspec, VectorCoefficient *vspec, TMOPMatrixCoefficient *mspec)
Rank 3 tensor (array of matrices)
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
virtual double EvalWMatrixForm(const DenseMatrix &Jpt) const
Evaluates the metric in matrix form (opposed to invariant form). Used for validating the invariant ev...
Class for parallel meshes.
virtual void SetSerialDiscreteTargetSize(const GridFunction &tspec_)
virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const double weight, DenseMatrix &A) const
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
TMOP_LimiterFunction * lim_func
InvariantsEvaluator3D< double > ie
const GridFunction * adapt_lim_gf0
virtual void AssembleElementVector(const FiniteElement &el, ElementTransformation &T, const Vector &elfun, Vector &elvect)
Perform the local action of the NonlinearFormIntegrator.
double ComputeMinDetT(const Vector &x, const FiniteElementSpace &fes)
virtual void AddMultPA(const Vector &, Vector &) const
Method for partially assembled action.
int GetOrder() const
Returns the order of the finite element. In the case of anisotropic orders, returns the maximum order...
void ParEnableNormalization(const ParGridFunction &x)
void ComputeAllElementTargets_Fallback(const FiniteElementSpace &fes, const IntegrationRule &ir, const Vector &xe, DenseTensor &Jtr) const
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
void UpdateAfterMeshTopologyChange()
Update all discrete fields based on tspec and update for AMR.
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const double weight, DenseMatrix &A) const
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const double weight, DenseMatrix &A) const
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
InvariantsEvaluator3D< double > ie
virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const double weight, DenseMatrix &A) const
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
FiniteElementSpace * coarse_tspec_fesv
void SetJacobian(const scalar_t *Jac)
The Jacobian should use column-major storage.