16 #include "../general/forall.hpp"
85 MFEM_VERIFY(
Jtr != NULL,
86 "Requires a target Jacobian, use SetTargetJacobian().");
95 const double cos_Jpr = (col1 * col2) / norm_prod,
96 sin_Jpr = fabs(Jpr.
Det()) / norm_prod;
101 const double cos_Jtr = (col1 * col2) / norm_prod,
102 sin_Jtr = fabs(
Jtr->
Det()) / norm_prod;
104 return 0.5 * (1.0 - cos_Jpr * cos_Jtr - sin_Jpr * sin_Jtr);
109 MFEM_VERIFY(
Jtr != NULL,
110 "Requires a target Jacobian, use SetTargetJacobian().");
119 double norm_c1 = col1.
Norml2(),
122 double cos_Jpr_12 = (col1 * col2) / (norm_c1 * norm_c2),
123 cos_Jpr_13 = (col1 * col3) / (norm_c1 * norm_c3),
124 cos_Jpr_23 = (col2 * col3) / (norm_c2 * norm_c3);
125 double sin_Jpr_12 = std::sqrt(1.0 - cos_Jpr_12 * cos_Jpr_12),
126 sin_Jpr_13 = std::sqrt(1.0 - cos_Jpr_13 * cos_Jpr_13),
127 sin_Jpr_23 = std::sqrt(1.0 - cos_Jpr_23 * cos_Jpr_23);
135 double cos_Jtr_12 = (col1 * col2) / (norm_c1 * norm_c2),
136 cos_Jtr_13 = (col1 * col3) / (norm_c1 * norm_c3),
137 cos_Jtr_23 = (col2 * col3) / (norm_c2 * norm_c3);
138 double sin_Jtr_12 = std::sqrt(1.0 - cos_Jtr_12 * cos_Jtr_12),
139 sin_Jtr_13 = std::sqrt(1.0 - cos_Jtr_13 * cos_Jtr_13),
140 sin_Jtr_23 = std::sqrt(1.0 - cos_Jtr_23 * cos_Jtr_23);
142 return (3.0 - cos_Jpr_12 * cos_Jtr_12 - sin_Jpr_12 * sin_Jtr_12
143 - cos_Jpr_13 * cos_Jtr_13 - sin_Jpr_13 * sin_Jtr_13
144 - cos_Jpr_23 * cos_Jtr_23 - sin_Jpr_23 * sin_Jtr_23) / 6.0;
149 MFEM_VERIFY(
Jtr != NULL,
150 "Requires a target Jacobian, use SetTargetJacobian().");
164 return 0.5 * (ratio_Jpr / ratio_Jtr + ratio_Jtr / ratio_Jpr) - 1.0;
169 MFEM_VERIFY(
Jtr != NULL,
170 "Requires a target Jacobian, use SetTargetJacobian().");
179 double norm_c1 = col1.
Norml2(),
182 double ratio_Jpr_1 = norm_c1 / std::sqrt(norm_c2 * norm_c3),
183 ratio_Jpr_2 = norm_c2 / std::sqrt(norm_c1 * norm_c3),
184 ratio_Jpr_3 = norm_c3 / std::sqrt(norm_c1 * norm_c2);
192 double ratio_Jtr_1 = norm_c1 / std::sqrt(norm_c2 * norm_c3),
193 ratio_Jtr_2 = norm_c2 / std::sqrt(norm_c1 * norm_c3),
194 ratio_Jtr_3 = norm_c3 / std::sqrt(norm_c1 * norm_c2);
196 return ( 0.5 * (ratio_Jpr_1 / ratio_Jtr_1 + ratio_Jtr_1 / ratio_Jpr_1) +
197 0.5 * (ratio_Jpr_2 / ratio_Jtr_2 + ratio_Jtr_2 / ratio_Jpr_2) +
198 0.5 * (ratio_Jpr_3 / ratio_Jtr_3 + ratio_Jtr_3 / ratio_Jpr_3) - 3.0
256 const double c2 = weight*c1*c1;
300 MFEM_VERIFY(
Jtr != NULL,
301 "Requires a target Jacobian, use SetTargetJacobian().");
305 Id(0,0) = 1;
Id(0,1) = 0;
306 Id(1,0) = 0;
Id(1,1) = 1;
322 if (d < 0.0 && min_detT == 0.0)
362 const double c2 = weight*c1/2;
363 const double c3 = c1*c2;
379 return 0.5*I1b*I1b - 2.0;
437 return 0.5*(I2b + 1.0/I2b) - 1.0;
467 return I1b*(I1b - 1.0);
495 return 0.5*(I2b*I2b + 1./(I2b*I2b) - 2.);
514 const double I2 =
ie.
Get_I2(), I2inv_sq = 1.0 / (I2 * I2);
522 MFEM_VERIFY(
Jtr != NULL,
523 "Requires a target Jacobian, use SetTargetJacobian().");
529 Id(0,0) = 1;
Id(0,1) = 0;
530 Id(1,0) = 0;
Id(1,1) = 1;
531 Id *= Mat.FNorm()/pow(2,0.5);
540 MFEM_VERIFY(
Jtr != NULL,
541 "Requires a target Jacobian, use SetTargetJacobian().");
545 Id(0,0) = 1;
Id(0,1) = 0;
546 Id(1,0) = 0;
Id(1,1) = 1;
560 return (I2b - 1.0)*(I2b - 1.0) - I2b + std::sqrt(I2b*I2b +
eps);
565 MFEM_ABORT(
"Metric not implemented yet. Use metric mu_55 instead.");
573 MFEM_ABORT(
"Metric not implemented yet. Use metric mu_55 instead.");
581 return 0.5*(I2b - 1.0)*(I2b - 1.0)/(I2b -
tau0);
592 const double c = (I2b - 1.0)/(I2b -
tau0);
608 const double c0 = 1.0/(I2b -
tau0);
609 const double c = c0*(I2b - 1.0);
654 double d_I1b_I2b_data[9];
658 const double a = weight/(6*std::sqrt(I1b_I2b));
692 const double c1 = weight/9;
726 return (I3b - 1.0)*(I3b - 1.0) - I3b + std::sqrt(I3b*I3b +
eps);
733 const double c = 2*I3b-3+(I3b)/(std::pow((I3b*I3b+
eps),0.5));
745 const double c0 = I3b*I3b+
eps;
746 const double c1 = 2 + 1/(pow(c0,0.5)) - I3b*I3b/(pow(c0,1.5));
747 const double c2 = 2*I3b - 3 + I3b/(pow(c0,0.5));
758 if (d < 0.0 && min_detT == 0.0)
767 const double c = std::pow(d, -2.0/3.0);
774 MFEM_ABORT(
"Metric not implemented yet.");
782 MFEM_ABORT(
"Metric not implemented yet.");
819 return 0.5*(I3b + 1.0/I3b) - 1.0;
882 const double c1 = weight*c0*c0;
883 const double c2 = -2*c0*c1;
897 return 0.5*(I3b - 1.0)*(I3b - 1.0)/(I3b -
tau0);
908 const double c = (I3b - 1.0)/(I3b -
tau0);
929 const double c0 = 1.0/(I3b -
tau0);
930 const double c = c0*(I3b - 1.0);
937 MFEM_VERIFY(
Jtr != NULL,
938 "Requires a target Jacobian, use SetTargetJacobian().");
948 DenseMatrix AdjAt(dim), WtW(dim), WRK(dim), Jtrt(dim);
953 Mult(AdjAt, WtW, WRK);
958 return (0.25/alpha)*WRK.
FNorm2();
963 MFEM_VERIFY(
Jtr != NULL,
964 "Requires a target Jacobian, use SetTargetJacobian().");
971 double sqalpha = pow(Jpr.
Det(), 0.5),
972 sqomega = pow(
Jtr->
Det(), 0.5);
974 return 0.5*pow(sqalpha/sqomega - sqomega/sqalpha, 2.);
979 MFEM_VERIFY(
Jtr != NULL,
980 "Requires a target Jacobian, use SetTargetJacobian().");
990 return (1./alpha)*(Jpr.
FNorm2());
995 MFEM_VERIFY(
Jtr != NULL,
996 "Requires a target Jacobian, use SetTargetJacobian().");
1004 aw = Jpr.FNorm()/
Jtr->FNorm();
1010 return (0.5/alpha)*Jpr.
FNorm2();
1016 MFEM_VERIFY(
nodes,
"Nodes are not given!");
1017 MFEM_ASSERT(
avg_volume == 0.0,
"The average volume is already computed!");
1020 const int NE = mesh->
GetNE();
1022 double volume = 0.0;
1024 for (
int i = 0; i < NE; i++)
1048 area_NE[0] = volume; area_NE[1] = NE;
1049 MPI_Allreduce(area_NE, area_NE + 2, 2, MPI_DOUBLE, MPI_SUM,
comm);
1068 const int NE = mesh->
GetNE();
1070 if (NE == 0) {
return; }
1073 "mixed meshes are not supported");
1074 MFEM_VERIFY(!fes.
IsVariableOrder(),
"variable orders are not supported");
1076 const int sdim = fes.
GetVDim();
1077 const int nvdofs = sdim*fe.GetDof();
1079 xe.
Size() == NE*nvdofs,
"invalid input Vector 'xe'!");
1089 if (dof_map->
Size() == 0) { dof_map =
nullptr; }
1093 Vector elfun_lex, elfun_nat;
1101 for (
int e = 0; e < NE; e++)
1112 const int ndofs = fe.GetDof();
1113 for (
int d = 0; d < sdim; d++)
1115 for (
int i_lex = 0; i_lex < ndofs; i_lex++)
1117 elfun_nat[(*dof_map)[i_lex]+d*ndofs] =
1118 elfun_lex[i_lex+d*ndofs];
1137 default: MFEM_ABORT(
"TargetType not added to ContainsVolumeInfo.");
1147 MFEM_CONTRACT_VAR(elfun);
1155 MFEM_ASSERT(Wideal.
Width() == Jtr.
SizeJ(),
"");
1161 for (
int i = 0; i < ir.
GetNPoints(); i++) { Jtr(i) = Wideal; }
1173 el_volume =
avg_volume / ncmesh->GetElementSizeReduction(e_id);
1177 1./W.Height()), Wideal);
1178 for (
int i = 0; i < ir.
GetNPoints(); i++) { Jtr(i) = W; }
1201 const double det = Jtr(i).Det();
1202 MFEM_VERIFY(det > 0.0,
"The given mesh is inverted!");
1203 Jtr(i).Set(std::pow(det / detW, 1./dim), Wideal);
1209 MFEM_ABORT(
"invalid target type!");
1219 MFEM_CONTRACT_VAR(elfun);
1249 "Target type GIVEN_FULL requires a MatrixCoefficient.");
1266 MFEM_ABORT(
"Incompatible target type for analytic adaptation!");
1284 "Target type GIVEN_FULL requires a TMOPMatrixCoefficient.");
1286 for (
int d = 0; d < fe->
GetDim(); d++)
1299 MFEM_ABORT(
"Incompatible target type for analytic adaptation!");
1309 static inline void device_copy(
double *d_dest,
const double *d_src,
int size)
1311 MFEM_FORALL(i, size, d_dest[i] = d_src[i];);
1320 MFEM_VERIFY(
adapt_eval,
"SetAdaptivityEvaluator() has not been called!")
1321 MFEM_VERIFY(
ncomp > 0,
"No target specifications have been set!");
1339 dof_cnt = tspec_.
Size()/vdim;
1340 const auto tspec__d = tspec_.
Read();
1342 const int offset = idx*dof_cnt;
1343 internal::device_copy(tspec_d + offset, tspec__d, dof_cnt*vdim);
1386 #endif // MFEM_USE_MPI
1391 dof_cnt = tspec_.
Size()/vdim;
1407 const auto tspec_temp_d = tspec_temp.Read();
1409 internal::device_copy(tspec_d, tspec_temp_d, tspec_temp.Size());
1411 const auto tspec__d = tspec_.
Read();
1412 const int offset = (
ncomp-vdim)*dof_cnt;
1413 internal::device_copy(tspec_d + offset, tspec__d, dof_cnt*vdim);
1419 dof_cnt = tspec_.
Size()/vdim;
1421 const auto tspec__d = tspec_.
Read();
1423 const int offset = idx*dof_cnt;
1424 internal::device_copy(tspec_d + offset, tspec__d, dof_cnt*vdim);
1465 MFEM_VERIFY(
adapt_eval,
"SetAdaptivityEvaluator() has not been called!")
1466 MFEM_VERIFY(
ncomp > 0,
"No target specifications have been set!");
1491 MFEM_VERIFY(
tspec.
Size() > 0,
"Target specification is not set!");
1506 int dofidx,
int dir,
1509 MFEM_VERIFY(
tspec.
Size() > 0,
"Target specification is not set!");
1515 for (
int i = 0; i <
ncomp; i++)
1517 tspec(dofs[dofidx]+i*cnt) = IntData(dofs[dofidx] + i*cnt + dir*cnt*ncomp);
1524 MFEM_VERIFY(
tspec.
Size() > 0,
"Target specification is not set!");
1529 for (
int i = 0; i <
ncomp; i++)
1540 MFEM_VERIFY(
tspec_fesv,
"No target specifications have been set.");
1552 const int dim = Wideal.
Height(),
1554 ntspec_dofs = ndofs*
ncomp;
1556 Vector shape(ndofs), tspec_vals(ntspec_dofs), par_vals,
1557 par_vals_c1, par_vals_c2, par_vals_c3;
1565 for (
int q = 0; q < nqp; q++)
1570 for (
int d = 0; d < 4; d++)
1579 const double min_size = par_vals.
Min();
1580 MFEM_VERIFY(min_size > 0.0,
1581 "Non-positive size propagated in the target definition.");
1582 const double size = std::max(shape * par_vals, min_size);
1583 Jtr(q).Set(std::pow(size, 1.0/dim), Jtr(q));
1597 const double aspectratio = shape * par_vals;
1599 D_rho(0,0) = 1./pow(aspectratio,0.5);
1600 D_rho(1,1) = pow(aspectratio,0.5);
1610 const double rho1 = shape * par_vals_c1;
1611 const double rho2 = shape * par_vals_c2;
1612 const double rho3 = shape * par_vals_c3;
1614 D_rho(0,0) = pow(rho1,2./3.);
1615 D_rho(1,1) = pow(rho2,2./3.);
1616 D_rho(2,2) = pow(rho3,2./3.);
1621 Mult(D_rho, Temp, Jtr(q));
1631 const double skew = shape * par_vals;
1635 Q_phi(0,1) = cos(skew);
1636 Q_phi(1,1) = sin(skew);
1646 const double phi12 = shape * par_vals_c1;
1647 const double phi13 = shape * par_vals_c2;
1648 const double chi = shape * par_vals_c3;
1652 Q_phi(0,1) = cos(phi12);
1653 Q_phi(0,2) = cos(phi13);
1655 Q_phi(1,1) = sin(phi12);
1656 Q_phi(1,2) = sin(phi13)*cos(chi);
1658 Q_phi(2,2) = sin(phi13)*sin(chi);
1663 Mult(Q_phi, Temp, Jtr(q));
1673 const double theta = shape * par_vals;
1674 R_theta(0,0) = cos(theta);
1675 R_theta(0,1) = -sin(theta);
1676 R_theta(1,0) = sin(theta);
1677 R_theta(1,1) = cos(theta);
1687 const double theta = shape * par_vals_c1;
1688 const double psi = shape * par_vals_c2;
1689 const double beta = shape * par_vals_c3;
1691 double ct = cos(theta), st = sin(theta),
1692 cp = cos(psi), sp = sin(psi),
1693 cb = cos(beta), sb = sin(beta);
1696 R_theta(0,0) = ct*sp;
1697 R_theta(1,0) = st*sp;
1700 R_theta(0,1) = -st*cb + ct*cp*sb;
1701 R_theta(1,1) = ct*cb + st*cp*sb;
1702 R_theta(2,1) = -sp*sb;
1704 R_theta(0,0) = -st*sb - ct*cp*cb;
1705 R_theta(1,0) = ct*sb - st*cp*cb;
1706 R_theta(2,0) = sp*cb;
1709 Jtrcomp_q = R_theta;
1711 Mult(R_theta, Temp, Jtr(q));
1717 MFEM_ABORT(
"Incompatible target type for discrete adaptation!");
1728 MFEM_VERIFY(
tspec_fesv,
"No target specifications have been set.");
1743 ntspec_dofs = ndofs*
ncomp;
1745 Vector shape(ndofs), tspec_vals(ntspec_dofs), par_vals,
1746 par_vals_c1(ndofs), par_vals_c2(ndofs), par_vals_c3(ndofs);
1749 DenseMatrix dD_rho(dim), dQ_phi(dim), dR_theta(dim);
1756 grad_e_c2(ndofs, dim),
1757 grad_e_c3(ndofs, dim);
1758 Vector grad_ptr_c1(grad_e_c1.GetData(), ndofs*
dim),
1759 grad_ptr_c2(grad_e_c2.GetData(), ndofs*
dim),
1778 grad_phys.Mult(par_vals, grad_ptr_c1);
1781 grad_e_c1.MultTranspose(shape, grad_q);
1783 const double min_size = par_vals.
Min();
1784 MFEM_VERIFY(min_size > 0.0,
1785 "Non-positive size propagated in the target definition.");
1786 const double size = std::max(shape * par_vals, min_size);
1787 double dz_dsize = (1./
dim)*pow(size, 1./dim - 1.);
1789 Mult(Jtrcomp_q, Jtrcomp_d, work1);
1790 Mult(Jtrcomp_r, work1, work2);
1792 for (
int d = 0; d <
dim; d++)
1796 work1.
Set(dz_dsize, work1);
1798 AddMult(work1, work2, dJtr_i);
1811 grad_phys.Mult(par_vals, grad_ptr_c1);
1814 grad_e_c1.MultTranspose(shape, grad_q);
1816 const double aspectratio = shape * par_vals;
1818 dD_rho(0,0) = -0.5*pow(aspectratio,-1.5);
1819 dD_rho(1,1) = 0.5*pow(aspectratio,-0.5);
1821 Mult(Jtrcomp_s, Jtrcomp_r, work1);
1822 Mult(work1, Jtrcomp_q, work2);
1824 for (
int d = 0; d <
dim; d++)
1829 AddMult(work2, work1, dJtr_i);
1836 par_vals_c1.SetData(par_vals.
GetData());
1837 par_vals_c2.SetData(par_vals.
GetData()+ndofs);
1840 grad_phys.Mult(par_vals_c1, grad_ptr_c1);
1841 grad_phys.Mult(par_vals_c2, grad_ptr_c2);
1842 grad_phys.Mult(par_vals_c3, grad_ptr_c3);
1843 Vector grad_q1(dim), grad_q2(dim), grad_q3(dim);
1845 grad_e_c1.MultTranspose(shape, grad_q1);
1846 grad_e_c2.MultTranspose(shape, grad_q2);
1849 const double rho1 = shape * par_vals_c1;
1850 const double rho2 = shape * par_vals_c2;
1851 const double rho3 = shape * par_vals_c3;
1853 dD_rho(0,0) = (2./3.)*pow(rho1,-1./3.);
1854 dD_rho(1,1) = (2./3.)*pow(rho2,-1./3.);
1855 dD_rho(2,2) = (2./3.)*pow(rho3,-1./3.);
1857 Mult(Jtrcomp_s, Jtrcomp_r, work1);
1858 Mult(work1, Jtrcomp_q, work2);
1861 for (
int d = 0; d <
dim; d++)
1865 work1(0,0) *= grad_q1(d);
1866 work1(1,2) *= grad_q2(d);
1867 work1(2,2) *= grad_q3(d);
1869 AddMult(work2, work1, dJtr_i);
1881 grad_phys.Mult(par_vals, grad_ptr_c1);
1884 grad_e_c1.MultTranspose(shape, grad_q);
1886 const double skew = shape * par_vals;
1890 dQ_phi(0,1) = -sin(skew);
1891 dQ_phi(1,1) = cos(skew);
1893 Mult(Jtrcomp_s, Jtrcomp_r, work2);
1895 for (
int d = 0; d <
dim; d++)
1900 Mult(work1, Jtrcomp_d, work3);
1901 AddMult(work2, work3, dJtr_i);
1908 par_vals_c1.SetData(par_vals.
GetData());
1909 par_vals_c2.SetData(par_vals.
GetData()+ndofs);
1912 grad_phys.Mult(par_vals_c1, grad_ptr_c1);
1913 grad_phys.Mult(par_vals_c2, grad_ptr_c2);
1914 grad_phys.Mult(par_vals_c3, grad_ptr_c3);
1915 Vector grad_q1(dim), grad_q2(dim), grad_q3(dim);
1917 grad_e_c1.MultTranspose(shape, grad_q1);
1918 grad_e_c2.MultTranspose(shape, grad_q2);
1921 const double phi12 = shape * par_vals_c1;
1922 const double phi13 = shape * par_vals_c2;
1923 const double chi = shape * par_vals_c3;
1927 dQ_phi(0,1) = -sin(phi12);
1928 dQ_phi(1,1) = cos(phi12);
1931 dQ_phi13(0,2) = -sin(phi13);
1932 dQ_phi13(1,2) = cos(phi13)*cos(chi);
1933 dQ_phi13(2,2) = cos(phi13)*sin(chi);
1936 dQ_phichi(1,2) = -sin(phi13)*sin(chi);
1937 dQ_phichi(2,2) = sin(phi13)*cos(chi);
1939 Mult(Jtrcomp_s, Jtrcomp_r, work2);
1941 for (
int d = 0; d <
dim; d++)
1945 work1 *= grad_q1(d);
1946 work1.Add(grad_q2(d), dQ_phi13);
1947 work1.Add(grad_q3(d), dQ_phichi);
1948 Mult(work1, Jtrcomp_d, work3);
1949 AddMult(work2, work3, dJtr_i);
1961 grad_phys.Mult(par_vals, grad_ptr_c1);
1964 grad_e_c1.MultTranspose(shape, grad_q);
1966 const double theta = shape * par_vals;
1967 dR_theta(0,0) = -sin(theta);
1968 dR_theta(0,1) = -cos(theta);
1969 dR_theta(1,0) = cos(theta);
1970 dR_theta(1,1) = -sin(theta);
1972 Mult(Jtrcomp_q, Jtrcomp_d, work1);
1973 Mult(Jtrcomp_s, work1, work2);
1974 for (
int d = 0; d <
dim; d++)
1979 AddMult(work1, work2, dJtr_i);
1986 par_vals_c1.SetData(par_vals.
GetData());
1987 par_vals_c2.SetData(par_vals.
GetData()+ndofs);
1990 grad_phys.Mult(par_vals_c1, grad_ptr_c1);
1991 grad_phys.Mult(par_vals_c2, grad_ptr_c2);
1992 grad_phys.Mult(par_vals_c3, grad_ptr_c3);
1993 Vector grad_q1(dim), grad_q2(dim), grad_q3(dim);
1995 grad_e_c1.MultTranspose(shape, grad_q1);
1996 grad_e_c2.MultTranspose(shape, grad_q2);
1999 const double theta = shape * par_vals_c1;
2000 const double psi = shape * par_vals_c2;
2001 const double beta = shape * par_vals_c3;
2003 const double ct = cos(theta), st = sin(theta),
2004 cp = cos(psi), sp = sin(psi),
2005 cb = cos(beta), sb = sin(beta);
2008 dR_theta(0,0) = -st*sp;
2009 dR_theta(1,0) = ct*sp;
2012 dR_theta(0,1) = -ct*cb - st*cp*sb;
2013 dR_theta(1,1) = -st*cb + ct*cp*sb;
2016 dR_theta(0,0) = -ct*sb + st*cp*cb;
2017 dR_theta(1,0) = -st*sb - ct*cp*cb;
2025 dR_beta(0,1) = st*sb + ct*cp*cb;
2026 dR_beta(1,1) = -ct*sb + st*cp*cb;
2027 dR_beta(2,1) = -sp*cb;
2029 dR_beta(0,0) = -st*cb + ct*cp*sb;
2030 dR_beta(1,0) = ct*cb + st*cp*sb;
2034 dR_psi(0,0) = ct*cp;
2035 dR_psi(1,0) = st*cp;
2038 dR_psi(0,1) = 0. - ct*sp*sb;
2039 dR_psi(1,1) = 0. + st*sp*sb;
2040 dR_psi(2,1) = -cp*sb;
2042 dR_psi(0,0) = 0. + ct*sp*cb;
2043 dR_psi(1,0) = 0. + st*sp*cb;
2044 dR_psi(2,0) = cp*cb;
2046 Mult(Jtrcomp_q, Jtrcomp_d, work1);
2047 Mult(Jtrcomp_s, work1, work2);
2048 for (
int d = 0; d <
dim; d++)
2052 work1 *= grad_q1(d);
2053 work1.Add(grad_q2(d), dR_psi);
2054 work1.Add(grad_q3(d), dR_beta);
2055 AddMult(work1, work2, dJtr_i);
2063 MFEM_ABORT(
"Incompatible target type for discrete adaptation!");
2081 for (
int j = 0; j <
dim; j++)
2083 for (
int i = 0; i < cnt; i++) { xtemp(j*cnt+i) += dx; }
2088 for (
int i = 0; i < cnt; i++) { xtemp(j*cnt+i) -= dx; }
2095 double dx,
bool use_flag)
2102 totmix = 1+2*(dim-2);
2111 for (
int j = 0; j <
dim; j++)
2113 for (
int i = 0; i < cnt; i++) { xtemp(j*cnt+i) += 2*dx; }
2118 for (
int i = 0; i < cnt; i++) { xtemp(j*cnt+i) -= 2*dx; }
2123 for (
int k1 = 0; k1 <
dim; k1++)
2125 for (
int k2 = 0; (k1 != k2) && (k2 < dim); k2++)
2127 for (
int i = 0; i < cnt; i++)
2129 xtemp(k1*cnt+i) += dx;
2130 xtemp(k2*cnt+i) += dx;
2136 for (
int i = 0; i < cnt; i++)
2138 xtemp(k1*cnt+i) -= dx;
2139 xtemp(k2*cnt+i) -= dx;
2197 PA.H.GetMemory().DeleteDevice();
2198 PA.H0.GetMemory().DeleteDevice();
2199 PA.Jtr.GetMemory().DeleteDevice();
2207 for (
int i = 0; i <
ElemDer.Size(); i++)
2222 "'dist' must be a scalar GridFunction!");
2338 if (adaptive_limiting)
2350 const double weight = ip.
weight * Jtr_i.
Det();
2369 if (adaptive_limiting)
2371 const double diff = zeta_q(i) - zeta0_q(i);
2375 energy += weight * val;
2438 Vector shape,
p, p0, d_vals, grad;
2455 d_vals.
SetSize(nqp); d_vals = 1.0;
2479 for (
int q = 0; q < nqp; q++)
2506 for (
int d = 0; d <
dim; d++)
2510 d_detW_dx(d) = dwdx.
Trace();
2517 for (
int d = 0; d <
dim; d++)
2522 Mult(Amat, work2, work1);
2524 d_Winv_dx(d) = work2.
Trace();
2526 d_Winv_dx *= -weight_m;
2528 d_detW_dx += d_Winv_dx;
2589 d_vals.
SetSize(nqp); d_vals = 1.0;
2605 for (
int q = 0; q < nqp; q++)
2631 for (
int i = 0; i < dof; i++)
2633 const double w_shape_i = weight_m * shape(i);
2634 for (
int j = 0; j < dof; j++)
2636 const double w = w_shape_i * shape(j);
2637 for (
int d1 = 0; d1 <
dim; d1++)
2639 for (
int d2 = 0; d2 <
dim; d2++)
2641 elmat(d1*dof + i, d2*dof + j) += w * grad_grad(d1, d2);
2660 if (
zeta == NULL) {
return; }
2663 Vector shape(dof), zeta_e, zeta_q, zeta0_q;
2677 grad_phys.
Mult(zeta_e, grad_ptr);
2681 const int nqp = weights.
Size();
2682 for (
int q = 0; q < nqp; q++)
2687 zeta_grad_q *= 2.0 * (zeta_q(q) - zeta0_q(q));
2699 if (
zeta == NULL) {
return; }
2702 Vector shape(dof), zeta_e, zeta_q, zeta0_q;
2716 grad_phys.
Mult(zeta_e, grad_ptr);
2721 Mult(grad_phys, zeta_grad_e, zeta_grad_grad_e);
2723 zeta_grad_grad_e.
SetSize(dof, dim*dim);
2728 const int nqp = weights.
Size();
2729 for (
int q = 0; q < nqp; q++)
2739 for (
int i = 0; i < dof *
dim; i++)
2741 const int idof = i % dof, idim = i / dof;
2742 for (
int j = 0; j <= i; j++)
2744 const int jdof = j % dof, jdim = j / dof;
2745 const double entry =
2746 w * ( 2.0 * zeta_grad_q(idim) * shape(idof) *
2747 zeta_grad_q(jdim) * shape(jdof) +
2748 2.0 * (zeta_q(q) - zeta0_q(q)) *
2749 zeta_grad_grad_q(idim, jdim) * shape(idof) * shape(jdof));
2751 if (i != j) { mat(j, i) += entry; }
2759 Vector &elfun,
const int dofidx,
2760 const int dir,
const double e_fx,
2764 int idx = dir*dof+dofidx;
2768 double dfdx = (e_fxph-e_fx)/
dx;
2802 for (
int j = 0; j <
dim; j++)
2804 for (
int i = 0; i < dof; i++)
2833 for (
int q = 0; q < nqp; q++)
2858 for (
int i = 0; i < dof; i++)
2860 for (
int j = 0; j < i+1; j++)
2862 for (
int k1 = 0; k1 <
dim; k1++)
2864 for (
int k2 = 0; k2 <
dim; k2++)
2866 elfunmod(k2*dof+j) +=
dx;
2893 double e_fx = ElemPertLoc(k2*dof+j);
2896 elfunmod(k2*dof+j) -=
dx;
2897 double e_fpx = ElemDerLoc(k1*dof+i);
2899 elmat(k1*dof+i, k2*dof+j) = (e_fpxph - e_fpx) /
dx;
2900 elmat(k2*dof+j, k1*dof+i) = (e_fpxph - e_fpx) /
dx;
2929 for (
int q = 0; q < nqp; q++)
2958 double &metric_energy,
2970 metric_energy = 0.0;
2972 for (
int i = 0; i < fes->
GetNE(); i++)
2978 const int dof = fe->
GetDof();
2987 for (
int q = 0; q < nqp; q++)
2992 const double weight = ip.
weight *
Jtr(q).Det();
2999 lim_energy += weight;
3005 lim_energy = fes->
GetNE();
3021 dx = std::numeric_limits<float>::max();
3024 double detv_avg_min = std::numeric_limits<float>::max();
3025 for (
int i = 0; i < NE; i++)
3030 for (
int j = 0; j < nsp; j++)
3034 detv_sum += std::fabs(
Jpr.
Det());
3036 double detv_avg = pow(detv_sum/nsp, 1./dim);
3037 detv_avg_min = std::min(detv_avg, detv_avg_min);
3046 PA.Jtr_needs_update =
true;
3065 MPI_Allreduce(&
dx, &min_jac_all, 1, MPI_DOUBLE, MPI_MIN, pfes.
GetComm());
3103 MFEM_VERIFY(
tmopi.Size() > 0,
"No TMOP_Integrators were added.");
3105 tmopi[0]->EnableLimiting(n0, dist, w0, lfunc);
3106 for (
int i = 1; i <
tmopi.Size(); i++) {
tmopi[i]->DisableLimiting(); }
3113 MFEM_VERIFY(
tmopi.Size() > 0,
"No TMOP_Integrators were added.");
3115 tmopi[0]->EnableLimiting(n0, w0, lfunc);
3116 for (
int i = 1; i <
tmopi.Size(); i++) {
tmopi[i]->DisableLimiting(); }
3121 MFEM_VERIFY(
tmopi.Size() > 0,
"No TMOP_Integrators were added.");
3123 tmopi[0]->SetLimitingNodes(n0);
3124 for (
int i = 1; i <
tmopi.Size(); i++) {
tmopi[i]->DisableLimiting(); }
3132 for (
int i = 0; i <
tmopi.Size(); i++)
3134 energy +=
tmopi[i]->GetElementEnergy(el, T, elfun);
3144 MFEM_VERIFY(
tmopi.Size() > 0,
"No TMOP_Integrators were added.");
3146 tmopi[0]->AssembleElementVector(el, T, elfun, elvect);
3147 for (
int i = 1; i <
tmopi.Size(); i++)
3150 tmopi[i]->AssembleElementVector(el, T, elfun, elvect_i);
3160 MFEM_VERIFY(
tmopi.Size() > 0,
"No TMOP_Integrators were added.");
3162 tmopi[0]->AssembleElementGrad(el, T, elfun, elmat);
3163 for (
int i = 1; i <
tmopi.Size(); i++)
3166 tmopi[i]->AssembleElementGrad(el, T, elfun, elmat_i);
3173 const int cnt =
tmopi.Size();
3174 double total_integral = 0.0;
3175 for (
int i = 0; i < cnt; i++)
3177 tmopi[i]->EnableNormalization(x);
3178 total_integral += 1.0 /
tmopi[i]->metric_normal;
3180 for (
int i = 0; i < cnt; i++)
3182 tmopi[i]->metric_normal = 1.0 / total_integral;
3189 const int cnt =
tmopi.Size();
3190 double total_integral = 0.0;
3191 for (
int i = 0; i < cnt; i++)
3193 tmopi[i]->ParEnableNormalization(x);
3194 total_integral += 1.0 /
tmopi[i]->metric_normal;
3196 for (
int i = 0; i < cnt; i++)
3198 tmopi[i]->metric_normal = 1.0 / total_integral;
3205 for (
int i = 0; i <
tmopi.Size(); i++)
3207 tmopi[i]->AssemblePA(fes);
3214 for (
int i = 0; i <
tmopi.Size(); i++)
3216 tmopi[i]->AssembleGradPA(xe,fes);
3222 for (
int i = 0; i <
tmopi.Size(); i++)
3224 tmopi[i]->AssembleGradDiagonalPA(de);
3230 for (
int i = 0; i <
tmopi.Size(); i++)
3232 tmopi[i]->AddMultPA(xe, ye);
3238 for (
int i = 0; i <
tmopi.Size(); i++)
3240 tmopi[i]->AddMultGradPA(re, ce);
3246 double energy = 0.0;
3247 for (
int i = 0; i <
tmopi.Size(); i++)
3249 energy +=
tmopi[i]->GetLocalStateEnergyPA(xe);
3258 const int NE = mesh.
GetNE();
3261 DenseMatrix Winv(dim), T(dim), A(dim), dshape, pos;
3266 for (
int i = 0; i < NE; i++)
3283 for (
int j = 0; j < nsp; j++)
3294 metric_gf(gf_dofs[j]) = metric.
EvalW(T);
int GetNPoints() const
Returns the number of the points in the integration rule.
Abstract class for all finite elements.
InvariantsEvaluator2D< double > ie
int Size() const
For backward compatibility define Size to be synonym of Width()
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 int Id() const
Return the metric ID.
virtual void SetParDiscreteTargetSize(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...
int Size() const
Return the logical size of the array.
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt).
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt).
InvariantsEvaluator3D< double > ie
virtual void SetInitialField(const Vector &init_nodes, const Vector &init_field)=0
int GetDim() const
Returns the reference space dimension for the finite element.
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.
void SetSerialMetaInfo(const Mesh &m, const FiniteElementCollection &fec, int num_comp)
Class for an integration rule - an Array of IntegrationPoint.
VectorCoefficient * vector_tspec
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.
void UpdateAfterMeshChange(const Vector &new_x)
virtual void AddMultPA(const Vector &, Vector &) const
Method for partially assembled action.
void UseExternalData(double *ext_data, int i, int j, int k)
InvariantsEvaluator3D< double > ie
InvariantsEvaluator3D< double > ie
bool IsVariableOrder() const
Returns true if the space contains elements of varying polynomial orders.
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.
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
ParMesh * GetParMesh() const
Base class for vector Coefficients that optionally depend on time and space.
void Assemble_ddI2b(scalar_t w, scalar_t *A)
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.
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 ...
int GetNumGeometries(int dim) const
Return the number of geometries of the given dimension present in the mesh.
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()
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.
void GetElementVDofs(int i, Array< int > &vdofs) const
Returns indexes of degrees of freedom in array dofs for i'th element.
TMOP_QualityMetric * metric
InvariantsEvaluator2D< double > ie
Base class for limiting functions to be used in class TMOP_Integrator.
virtual double EvalW(const DenseMatrix &Jpt) const =0
Evaluate the strain energy density function, W = W(Jpt).
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt).
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 void ComputeElementTargetsGradient(const IntegrationRule &ir, const Vector &elfun, IsoparametricTransformation &Tpr, DenseTensor &dJtr) const
void Mult(const Table &A, const Table &B, Table &C)
C = A * B (as boolean matrices)
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 Width() const
Get the width (size of input) of the Operator. Synonym with NumCols().
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
double Norml2() const
Returns the l2 norm of the vector.
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt).
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 ...
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
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).
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const =0
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
InvariantsEvaluator2D< double > ie
virtual void ComputeElementTargetsGradient(const IntegrationRule &ir, const Vector &elfun, IsoparametricTransformation &Tpr, DenseTensor &dJtr) const
ParFiniteElementSpace * pfes
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt).
Data type dense matrix using column-major storage.
int Size() const
Returns the size of the vector.
void AssembleElemGradAdaptLim(const FiniteElement &el, const Vector &weights, IsoparametricTransformation &Tpr, const IntegrationRule &ir, DenseMatrix &m)
void FinalizeSerialDiscreteTargetSpec()
void EnableAdaptiveLimiting(const GridFunction &z0, Coefficient &coeff, AdaptivityEvaluator &ae)
Restriction of the node positions to certain regions.
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 GetNE() const
Returns number of elements.
void EnableNormalization(const GridFunction &x)
Normalization factor that considers all integrators in the combination.
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).
Abstract parallel finite element space.
virtual void AssemblePA(const FiniteElementSpace &)
Method defining partial assembly.
InvariantsEvaluator2D< double > ie
const IntegrationRule * ir
InvariantsEvaluator2D< double > ie
virtual void GetElementDofs(int elem, Array< int > &dofs) const
Returns indices of degrees of freedom of element 'elem'.
void AssembleElementVectorFD(const FiniteElement &el, ElementTransformation &T, const Vector &elfun, Vector &elvect)
const GridFunction * nodes
virtual void SetSerialDiscreteTargetSkew(const GridFunction &tspec_)
struct mfem::TMOP_Integrator::@13 PA
void UpdateGradientTargetSpecification(const Vector &x, double dx, bool use_flag=false)
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)
double * GetData() const
Returns the matrix data array.
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.
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).
Default limiter function in TMOP_Integrator.
Geometry::Type GetElementBaseGeometry(int i) const
virtual void UseDevice(bool use_dev) const
Enable execution of Vector operations using the mfem::Device.
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 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 quadratur...
void AssembleElementGradExact(const FiniteElement &el, ElementTransformation &T, const Vector &elfun, DenseMatrix &elmat)
Array< Vector * > ElemDer
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)
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt).
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 quadratur...
AdaptivityEvaluator * adapt_eval
Coefficient * scalar_tspec
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
virtual void SetSerialDiscreteTargetAspectRatio(const GridFunction &tspec_)
void ReleasePADeviceMemory()
const DenseMatrix & GetGeomToPerfGeomJac(int GeomType) const
void UpdateTargetSpecification(const Vector &new_x, bool use_flag=false)
const FiniteElementSpace * tspec_fesv
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt).
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(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...
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
virtual void AddMultGradPA(const Vector &, Vector &) const
Method for partially assembled gradient action.
virtual void ComputeElementTargetsGradient(const IntegrationRule &ir, const Vector &elfun, IsoparametricTransformation &Tpr, DenseTensor &dJtr) const
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.
int GetNE() const
Returns number of elements in the mesh.
Abstract class for local mesh quality metrics in the target-matrix optimization paradigm (TMOP) by P...
IntegrationPoint & IntPoint(int i)
Returns a reference to the i-th integration point.
void MultTranspose(const double *x, double *y) const
Multiply a vector with the transpose matrix.
virtual ~AdaptivityEvaluator()
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)
void Assemble_ddI3b(scalar_t w, scalar_t *A)
InvariantsEvaluator3D< double > ie
void SetLimitingNodes(const GridFunction &n0)
Update the original/reference nodes used for limiting.
void SetDiscreteTargetBase(const GridFunction &tspec_)
virtual const FiniteElement * GetFE(int i) const
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
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 EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt).
void UpdateTargetSpecificationAtNode(const FiniteElement &el, ElementTransformation &T, int nodenum, int idir, const Vector &IntData)
int Height() const
Get the height (size of output) of the Operator. Synonym with NumRows().
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...
Mesh * GetMesh() const
Returns the mesh.
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).
void Add(const double c, const DenseMatrix &A)
Adds the matrix A multiplied by the number c to the matrix.
InvariantsEvaluator2D< double > ie
void ClearGeometricFactors()
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt).
void AssembleElementVectorExact(const FiniteElement &el, ElementTransformation &T, const Vector &elfun, Vector &elvect)
virtual void AssembleGradDiagonalPA(Vector &) const
Method for computing the diagonal of the gradient with partial assembly.
const TargetConstructor * targetC
Array< Vector * > ElemPertEnergy
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
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 scalar_t * Get_dI2b()
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...
InvariantsEvaluator2D< double > ie
const IntegrationRule & GetNodes() const
Get a const reference to the nodes of the element.
void SetDerivativeMatrix(int height, const scalar_t *Deriv)
The Deriv matrix is dof x 3, using column-major storage.
virtual void AssembleGradPA(const Vector &, const FiniteElementSpace &)
Prepare the integrator for partial assembly (PA) gradient evaluations on the given FE space fes at th...
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt).
virtual void SetParDiscreteTargetAspectRatio(const ParGridFunction &tspec_)
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt).
void SetSize(int i, int j, int k, MemoryType mt_=MemoryType::PRESERVE)
void ParEnableNormalization(const ParGridFunction &x)
InvariantsEvaluator2D< double > ie
int GetNumRootElements()
Return the number of root elements.
void GetValues(int i, const IntegrationRule &ir, Vector &vals, int vdim=1) const
virtual void AssembleElementVector(const FiniteElement &el, ElementTransformation &T, const Vector &elfun, Vector &elvect)
Perform the local action of the NonlinearFormIntegrator.
virtual double GetLocalStateEnergyPA(const Vector &) const
Compute the local (to the MPI rank) energy with partial assembly.
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.
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...
A class for non-conforming AMR. The class is not used directly by the user, rather it is an extension...
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
FiniteElementSpace * FESpace()
virtual bool ContainsVolumeInfo() const
Checks if the target matrices contain non-trivial size specification.
Array< TMOP_QualityMetric * > tmop_q_arr
void GetColumn(int c, Vector &col) const
void Assemble_ddI1b(scalar_t w, scalar_t *A)
virtual const double * HostRead() const
Shortcut for mfem::Read(vec.GetMemory(), vec.Size(), false).
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_)
void ComputeAvgVolume() const
void CalcInverse(const DenseMatrix &a, DenseMatrix &inva)
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt).
double Min() const
Returns the minimal element of the vector.
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt).
double * Data() const
Returns the matrix data array.
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 UpdateHessianTargetSpecification(const Vector &x, double dx, bool use_flag=false)
void Transpose()
(*this) = (*this)^t
double Trace() const
Trace of a square matrix.
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.
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
int GetDof() const
Returns the number of degrees of freedom in the finite element.
void Assemble_ddI2(scalar_t w, scalar_t *A)
const scalar_t * Get_dI1()
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
Base class Coefficients that optionally depend on space and time. These are used by the BilinearFormI...
InvariantsEvaluator3D< double > ie
Collection of finite elements from the same family in multiple dimensions. This class is used to matc...
TMOPMatrixCoefficient * matrix_tspec
const scalar_t * Get_dI1()
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 quadratur...
const IntegrationRule & ActionIntegrationRule(const FiniteElement &el) const
InvariantsEvaluator2D< double > ie
void MultAAt(const DenseMatrix &a, DenseMatrix &aat)
Calculate the matrix A.At.
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt).
void AssembleElemVecAdaptLim(const FiniteElement &el, const Vector &weights, IsoparametricTransformation &Tpr, const IntegrationRule &ir, DenseMatrix &m)
bool UsesPhysicalCoordinates() const
Return true if the methods ComputeElementTargets(), ComputeAllElementTargets(), and ComputeElementTar...
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 * 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.
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt).
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt).
const scalar_t * Get_dI1b()
void SetDataAndSize(double *d, int s)
Set the Vector data and size.
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt).
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt).
const scalar_t * Get_dI1b()
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt).
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt).
const Array< int > & GetDofMap() const
Get an Array<int> that maps lexicographically ordered indices to the indices of the respective nodes/...
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(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...
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
InvariantsEvaluator3D< double > ie
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
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 Eval(const Vector &x, const Vector &x0, double d) const =0
Returns the limiting function, f(x, x0, d).
Class for integration point with weight.
AdaptivityEvaluator * adapt_eval
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)
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 GetElementTransformation(int i, IsoparametricTransformation *ElTr)
void ComputeNormalizationEnergies(const GridFunction &x, double &metric_energy, double &lim_energy)
const IntegrationRule & EnergyIntegrationRule(const FiniteElement &el) const
const IntegrationRule & GradientIntegrationRule(const FiniteElement &el) const
double GetFDDerivative(const FiniteElement &el, ElementTransformation &T, Vector &elfun, const int nodenum, const int idir, const double baseenergy, bool update_stored)
void SetParMetaInfo(const ParMesh &m, const FiniteElementCollection &fec, int num_comp)
Parallel version of SetSerialMetaInfo.
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.
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt).
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.
virtual const FiniteElement * GetFE(int i) const
Returns pointer to the FiniteElement in the FiniteElementCollection associated with i'th element in t...
const GridFunction * zeta_0
void ComputeAllElementTargets_Fallback(const FiniteElementSpace &fes, const IntegrationRule &ir, const Vector &xe, DenseTensor &Jtr) const
const Vector & GetTspecPert2H()
const Vector & GetTspecPert1H()
void AssembleElementGradFD(const FiniteElement &el, ElementTransformation &T, const Vector &elfun, DenseMatrix &elmat)
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt).
InvariantsEvaluator2D< 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...
virtual void SetParDiscreteTargetSpec(const ParGridFunction &tspec_)
InvariantsEvaluator2D< double > ie
NCMesh * ncmesh
Optional non-conforming mesh extension.
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt).
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
virtual double Eval(ElementTransformation &T, const IntegrationPoint &ip)=0
Evaluate the coefficient in the element described by T at the point ip.
const scalar_t * Get_dI2()
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).
void FinalizeParDiscreteTargetSpec(const ParGridFunction &tspec_)
void MultAtB(const DenseMatrix &A, const DenseMatrix &B, DenseMatrix &AtB)
Multiply the transpose of a matrix A with a matrix B: At*B.
const FiniteElementCollection * FEColl() const
void Mult(const double *x, double *y) const
Matrix vector multiplication.
void GetNodes(Vector &node_coord) const
InvariantsEvaluator3D< double > ie
const GridFunction * nodes0
const FiniteElementSpace * tspec_fes
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt).
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
void DeleteGeometricFactors()
Destroy all GeometricFactors stored by the Mesh.
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 void SetSerialDiscreteTargetSpec(const GridFunction &tspec_)
virtual void SetParDiscreteTargetSkew(const ParGridFunction &tspec_)
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
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...
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt).
void SetSize(int s)
Change the size of the DenseMatrix to s x s.
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
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)
Class for parallel meshes.
virtual void SetSerialDiscreteTargetSize(const GridFunction &tspec_)
double FNorm2() const
Compute the square of the Frobenius norm of the matrix.
IntegrationRules IntRules(0, Quadrature1D::GaussLegendre)
A global object with all integration rules (defined in intrules.cpp)
TMOP_LimiterFunction * lim_func
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt).
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
InvariantsEvaluator3D< double > ie
virtual void AssembleElementVector(const FiniteElement &el, ElementTransformation &T, const Vector &elfun, Vector &elvect)
Perform the local action of the NonlinearFormIntegrator.
virtual const double * Read(bool on_dev=true) const
Shortcut for mfem::Read(vec.GetMemory(), vec.Size(), on_dev).
void ParEnableNormalization(const ParGridFunction &x)
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 ComputeAtNewPosition(const Vector &new_nodes, Vector &new_field)=0
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).
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 * ParFESpace() const
void SetJacobian(const scalar_t *Jac)
The Jacobian should use column-major storage.