107 #include "../common/mfem-common.hpp"
112 using namespace mfem;
115 int main(
int argc,
char *argv[])
118 const char *mesh_file =
"icf.mesh";
119 int mesh_poly_deg = 1;
124 double lim_const = 0.0;
125 double adapt_lim_const = 0.0;
126 double surface_fit_const = 0.0;
130 int solver_iter = 20;
131 double solver_rtol = 1e-10;
132 int solver_art_type = 0;
134 int max_lin_iter = 100;
135 bool move_bnd =
true;
137 bool hradaptivity =
false;
138 int h_metric_id = -1;
139 bool normalization =
false;
140 bool visualization =
true;
141 int verbosity_level = 0;
142 bool fdscheme =
false;
144 bool exactaction =
false;
145 const char *devopt =
"cpu";
149 bool surface_fit_adapt =
false;
150 double surface_fit_threshold = -10;
154 args.
AddOption(&mesh_file,
"-m",
"--mesh",
155 "Mesh file to use.");
156 args.
AddOption(&mesh_poly_deg,
"-o",
"--order",
157 "Polynomial degree of mesh finite element space.");
158 args.
AddOption(&rs_levels,
"-rs",
"--refine-serial",
159 "Number of times to refine the mesh uniformly in serial.");
160 args.
AddOption(&jitter,
"-ji",
"--jitter",
161 "Random perturbation scaling factor.");
162 args.
AddOption(&metric_id,
"-mid",
"--metric-id",
163 "Mesh optimization metric:\n\t"
165 "1 : |T|^2 -- 2D shape\n\t"
166 "2 : 0.5|T|^2/tau-1 -- 2D shape (condition number)\n\t"
167 "7 : |T-T^-t|^2 -- 2D shape+size\n\t"
168 "9 : tau*|T-T^-t|^2 -- 2D shape+size\n\t"
169 "14 : |T-I|^2 -- 2D shape+size+orientation\n\t"
170 "22 : 0.5(|T|^2-2*tau)/(tau-tau_0) -- 2D untangling\n\t"
171 "50 : 0.5|T^tT|^2/tau^2-1 -- 2D shape\n\t"
172 "55 : (tau-1)^2 -- 2D size\n\t"
173 "56 : 0.5(sqrt(tau)-1/sqrt(tau))^2 -- 2D size\n\t"
174 "58 : |T^tT|^2/(tau^2)-2*|T|^2/tau+2 -- 2D shape\n\t"
175 "77 : 0.5(tau-1/tau)^2 -- 2D size\n\t"
176 "80 : (1-gamma)mu_2 + gamma mu_77 -- 2D shape+size\n\t"
177 "85 : |T-|T|/sqrt(2)I|^2 -- 2D shape+orientation\n\t"
178 "98 : (1/tau)|T-I|^2 -- 2D shape+size+orientation\n\t"
181 "301: (|T||T^-1|)/3-1 -- 3D shape\n\t"
182 "302: (|T|^2|T^-1|^2)/9-1 -- 3D shape\n\t"
183 "303: (|T|^2)/3*tau^(2/3)-1 -- 3D shape\n\t"
185 "313: (|T|^2)(tau-tau0)^(-2/3)/3 -- 3D untangling\n\t"
186 "315: (tau-1)^2 -- 3D size\n\t"
187 "316: 0.5(sqrt(tau)-1/sqrt(tau))^2 -- 3D size\n\t"
188 "321: |T-T^-t|^2 -- 3D shape+size\n\t"
191 "11 : (1/4*alpha)|A-(adjA)^T(W^TW)/omega|^2 -- 2D shape\n\t"
192 "36 : (1/alpha)|A-W|^2 -- 2D shape+size+orientation\n\t"
193 "107: (1/2*alpha)|A-|A|/|W|W|^2 -- 2D shape+orientation\n\t"
194 "126: (1-gamma)nu_11 + gamma*nu_14a -- 2D shape+size\n\t"
196 args.
AddOption(&target_id,
"-tid",
"--target-id",
197 "Target (ideal element) type:\n\t"
198 "1: Ideal shape, unit size\n\t"
199 "2: Ideal shape, equal size\n\t"
200 "3: Ideal shape, initial size\n\t"
201 "4: Given full analytic Jacobian (in physical space)\n\t"
202 "5: Ideal shape, given size (in physical space)");
203 args.
AddOption(&lim_const,
"-lc",
"--limit-const",
"Limiting constant.");
204 args.
AddOption(&adapt_lim_const,
"-alc",
"--adapt-limit-const",
205 "Adaptive limiting coefficient constant.");
206 args.
AddOption(&surface_fit_const,
"-sfc",
"--surface-fit-const",
207 "Surface preservation constant.");
208 args.
AddOption(&quad_type,
"-qt",
"--quad-type",
209 "Quadrature rule type:\n\t"
210 "1: Gauss-Lobatto\n\t"
211 "2: Gauss-Legendre\n\t"
212 "3: Closed uniform points");
213 args.
AddOption(&quad_order,
"-qo",
"--quad_order",
214 "Order of the quadrature rule.");
215 args.
AddOption(&solver_type,
"-st",
"--solver-type",
216 " Type of solver: (default) 0: Newton, 1: LBFGS");
217 args.
AddOption(&solver_iter,
"-ni",
"--newton-iters",
218 "Maximum number of Newton iterations.");
219 args.
AddOption(&solver_rtol,
"-rtol",
"--newton-rel-tolerance",
220 "Relative tolerance for the Newton solver.");
221 args.
AddOption(&solver_art_type,
"-art",
"--adaptive-rel-tol",
222 "Type of adaptive relative linear solver tolerance:\n\t"
223 "0: None (default)\n\t"
224 "1: Eisenstat-Walker type 1\n\t"
225 "2: Eisenstat-Walker type 2");
226 args.
AddOption(&lin_solver,
"-ls",
"--lin-solver",
231 "3: MINRES + Jacobi preconditioner\n\t"
232 "4: MINRES + l1-Jacobi preconditioner");
233 args.
AddOption(&max_lin_iter,
"-li",
"--lin-iter",
234 "Maximum number of iterations in the linear solve.");
235 args.
AddOption(&move_bnd,
"-bnd",
"--move-boundary",
"-fix-bnd",
237 "Enable motion along horizontal and vertical boundaries.");
238 args.
AddOption(&combomet,
"-cmb",
"--combo-type",
239 "Combination of metrics options:\n\t"
240 "0: Use single metric\n\t"
241 "1: Shape + space-dependent size given analytically\n\t"
242 "2: Shape + adapted size given discretely; shared target");
243 args.
AddOption(&hradaptivity,
"-hr",
"--hr-adaptivity",
"-no-hr",
244 "--no-hr-adaptivity",
245 "Enable hr-adaptivity.");
246 args.
AddOption(&h_metric_id,
"-hmid",
"--h-metric",
247 "Same options as metric_id. Used to determine refinement"
248 " type for each element if h-adaptivity is enabled.");
249 args.
AddOption(&normalization,
"-nor",
"--normalization",
"-no-nor",
250 "--no-normalization",
251 "Make all terms in the optimization functional unitless.");
252 args.
AddOption(&fdscheme,
"-fd",
"--fd_approximation",
253 "-no-fd",
"--no-fd-approx",
254 "Enable finite difference based derivative computations.");
255 args.
AddOption(&exactaction,
"-ex",
"--exact_action",
256 "-no-ex",
"--no-exact-action",
257 "Enable exact action of TMOP_Integrator.");
258 args.
AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
259 "--no-visualization",
260 "Enable or disable GLVis visualization.");
261 args.
AddOption(&verbosity_level,
"-vl",
"--verbosity-level",
262 "Set the verbosity level - 0, 1, or 2.");
263 args.
AddOption(&adapt_eval,
"-ae",
"--adaptivity-evaluator",
264 "0 - Advection based (DEFAULT), 1 - GSLIB.");
265 args.
AddOption(&devopt,
"-d",
"--device",
266 "Device configuration string, see Device::Configure().");
267 args.
AddOption(&pa,
"-pa",
"--partial-assembly",
"-no-pa",
268 "--no-partial-assembly",
"Enable Partial Assembly.");
269 args.
AddOption(&n_hr_iter,
"-nhr",
"--n_hr_iter",
270 "Number of hr-adaptivity iterations.");
271 args.
AddOption(&n_h_iter,
"-nh",
"--n_h_iter",
272 "Number of h-adaptivity iterations per r-adaptivity"
274 args.
AddOption(&surface_fit_adapt,
"-sfa",
"--adaptive-surface-fit",
"-no-sfa",
275 "--no-adaptive-surface-fit",
276 "Enable or disable adaptive surface fitting.");
277 args.
AddOption(&surface_fit_threshold,
"-sft",
"--surf-fit-threshold",
278 "Set threshold for surface fitting. TMOP solver will"
279 "terminate when max surface fitting error is below this limit");
288 if (h_metric_id < 0) { h_metric_id = metric_id; }
292 MFEM_VERIFY(strcmp(devopt,
"cpu")==0,
"HR-adaptivity is currently only"
293 " supported on cpus.");
299 Mesh *mesh =
new Mesh(mesh_file, 1, 1,
false);
310 if (mesh_poly_deg <= 0)
339 double mesh_volume = 0.0;
341 for (
int i = 0; i < mesh->
GetNE(); i++)
347 for (
int j = 0; j < dofs.
Size(); j++)
349 h0(dofs[j]) = min(h0(dofs[j]), hi);
353 const double small_phys_size =
pow(mesh_volume, 1.0 / dim) / 100.0;
366 for (
int i = 0; i < fespace->
GetNDofs(); i++)
368 for (
int d = 0; d <
dim; d++)
374 for (
int i = 0; i < fespace->
GetNBE(); i++)
379 for (
int j = 0; j < vdofs.
Size(); j++) { rdm(vdofs[j]) = 0.0; }
388 ofstream mesh_ofs(
"perturbed.mesh");
389 mesh->
Print(mesh_ofs);
397 double tauval = -0.1;
437 cout <<
"Unknown metric_id: " << metric_id << endl;
456 default: cout <<
"Metric_id not supported for h-adaptivity: " << h_metric_id <<
462 if (metric_id < 300 || h_metric_id < 300)
464 MFEM_VERIFY(dim == 2,
"Incompatible metric for 3D meshes");
466 if (metric_id >= 300 || h_metric_id >= 300)
468 MFEM_VERIFY(dim == 3,
"Incompatible metric for 2D meshes");
478 GridFunction size(&ind_fes), aspr(&ind_fes), ori(&ind_fes);
508 #ifdef MFEM_USE_GSLIB
511 MFEM_ABORT(
"MFEM is not built with GSLIB.");
517 size.ProjectCoefficient(size_coeff);
522 size.ProjectCoefficient(size_coeff);
542 #ifdef MFEM_USE_GSLIB
545 MFEM_ABORT(
"MFEM is not built with GSLIB.");
557 for (
int i = 0; i < size.Size(); i++)
561 const double max = size.Max();
563 for (
int i = 0; i < d_x.Size(); i++)
565 d_x(i) = std::abs(d_x(i));
566 d_y(i) = std::abs(d_y(i));
568 const double eps = 0.01;
569 const double aspr_ratio = 20.0;
570 const double size_ratio = 40.0;
572 for (
int i = 0; i < size.Size(); i++)
574 size(i) = (size(i)/max);
575 aspr(i) = (d_x(i)+eps)/(d_y(i)+eps);
576 aspr(i) = 0.1 + 0.9*(1-size(i))*(1-size(i));
577 if (aspr(i) > aspr_ratio) {aspr(i) = aspr_ratio;}
578 if (aspr(i) < 1.0/aspr_ratio) {aspr(i) = 1.0/aspr_ratio;}
581 const int NE = mesh->
GetNE();
582 double volume = 0.0, volume_ind = 0.0;
584 for (
int i = 0; i < NE; i++)
589 size.GetValues(i, ir, vals);
599 const double avg_zone_size = volume / NE;
601 const double small_avg_ratio = (volume_ind + (volume - volume_ind) /
605 const double small_zone_size = small_avg_ratio * avg_zone_size;
606 const double big_zone_size = size_ratio * small_zone_size;
608 for (
int i = 0; i < size.Size(); i++)
610 const double val = size(i);
611 const double a = (big_zone_size - small_zone_size) / small_zone_size;
612 size(i) = big_zone_size / (1.0+a*val);
633 #ifdef MFEM_USE_GSLIB
636 MFEM_ABORT(
"MFEM is not built with GSLIB.");
656 #ifdef MFEM_USE_GSLIB
659 MFEM_ABORT(
"MFEM is not built with GSLIB.");
663 if (metric_id == 14 || metric_id == 36)
666 size.ProjectCoefficient(size_coeff);
673 aspr.ProjectCoefficient(aspr_coeff);
696 default: cout <<
"Unknown target_id: " << target_id << endl;
return 3;
698 if (target_c == NULL)
709 MFEM_VERIFY(pa ==
false,
"PA for finite differences is not implemented.");
721 default: cout <<
"Unknown quad_type: " << quad_type << endl;
return 3;
726 cout <<
"Triangle quadrature points: "
728 <<
"\nQuadrilateral quadrature points: "
733 cout <<
"Tetrahedron quadrature points: "
735 <<
"\nHexahedron quadrature points: "
737 <<
"\nPrism quadrature points: "
747 if (normalization) { dist = small_phys_size; }
749 if (lim_const != 0.0) { tmop_integ->
EnableLimiting(x0, dist, lim_coeff); }
755 if (adapt_lim_const > 0.0)
757 MFEM_VERIFY(pa ==
false,
"PA is not implemented for adaptive limiting");
762 if (adapt_eval == 0) { adapt_lim_eval =
new AdvectorCG(al); }
763 else if (adapt_eval == 1)
765 #ifdef MFEM_USE_GSLIB
768 MFEM_ABORT(
"MFEM is not built with GSLIB support!");
771 else { MFEM_ABORT(
"Bad interpolation option."); }
794 if (surface_fit_const > 0.0)
796 MFEM_VERIFY(hradaptivity ==
false,
797 "Surface fitting with HR is not implemented yet.");
798 MFEM_VERIFY(pa ==
false,
799 "Surface fitting with PA is not implemented yet.");
804 for (
int i = 0; i < mesh->
GetNE(); i++)
812 for (
int j = 0; j < surf_fit_marker.Size(); j++)
814 if (surf_fit_mat_gf(j) > 0.1 && surf_fit_mat_gf(j) < 0.9)
816 surf_fit_marker[j] =
true;
817 surf_fit_mat_gf(j) = 1.0;
821 surf_fit_marker[j] =
false;
822 surf_fit_mat_gf(j) = 0.0;
826 if (adapt_eval == 0) { adapt_surface =
new AdvectorCG; }
827 else if (adapt_eval == 1)
829 #ifdef MFEM_USE_GSLIB
832 MFEM_ABORT(
"MFEM is not built with GSLIB support!");
835 else { MFEM_ABORT(
"Bad interpolation option."); }
838 surf_fit_coeff, *adapt_surface);
889 else { tmop_integ2 =
new TMOP_Integrator(metric2, target_c, h_metric); }
898 if (lim_const != 0.0) { combo->
EnableLimiting(x0, dist, lim_coeff); }
907 if (pa) { a.
Setup(); }
911 const int NE = mesh->
GetNE();
912 for (
int i = 0; i < NE; i++)
923 cout <<
"Minimum det(J) of the original mesh is " << tauval << endl;
925 if (tauval < 0.0 && metric_id != 22 && metric_id != 211 && metric_id != 252
926 && metric_id != 311 && metric_id != 313 && metric_id != 352)
928 MFEM_ABORT(
"The input mesh is inverted! Try an untangling metric.");
933 "Untangling is supported only for ideal targets.");
937 tauval /= Wideal.
Det();
940 tauval -= 0.01 * h0.Min();
945 (hradaptivity ? mesh->
GetNE() : 1);
946 double init_metric_energy = init_energy;
947 if (lim_const > 0.0 || adapt_lim_const > 0.0 || surface_fit_const > 0.0)
951 surf_fit_coeff.constant = 0.0;
953 (hradaptivity ? mesh->
GetNE() : 1);
955 adapt_lim_coeff.
constant = adapt_lim_const;
956 surf_fit_coeff.constant = surface_fit_const;
963 char title[] =
"Initial metric values";
972 if (move_bnd ==
false)
981 for (
int i = 0; i < mesh->
GetNBE(); i++)
985 MFEM_VERIFY(!(dim == 2 && attr == 3),
986 "Boundary attribute 3 must be used only for 3D meshes. "
987 "Adjust the attributes (1/2/3/4 for fixed x/y/z/all "
988 "components, rest for free nodes), or use -fix-bnd.");
989 if (attr == 1 || attr == 2 || attr == 3) { n += nd; }
990 if (attr == 4) { n += nd *
dim; }
994 for (
int i = 0; i < mesh->
GetNBE(); i++)
1001 for (
int j = 0; j < nd; j++)
1002 { ess_vdofs[n++] = vdofs[j]; }
1006 for (
int j = 0; j < nd; j++)
1007 { ess_vdofs[n++] = vdofs[j+nd]; }
1011 for (
int j = 0; j < nd; j++)
1012 { ess_vdofs[n++] = vdofs[j+2*nd]; }
1016 for (
int j = 0; j < vdofs.
Size(); j++)
1017 { ess_vdofs[n++] = vdofs[j]; }
1025 Solver *S = NULL, *S_prec = NULL;
1026 const double linsol_rtol = 1e-12;
1027 if (lin_solver == 0)
1029 S =
new DSmoother(1, 1.0, max_lin_iter);
1031 else if (lin_solver == 1)
1048 if (lin_solver == 3 || lin_solver == 4)
1052 MFEM_VERIFY(lin_solver != 4,
"PA l1-Jacobi is not implemented");
1059 auto ds =
new DSmoother((lin_solver == 3) ? 0 : 1, 1.0, 1);
1060 ds->SetPositiveDiagonal(
true);
1073 if (surface_fit_threshold > 0)
1079 if (solver_type == 0)
1089 if (solver_art_type > 0)
1103 x, move_bnd, hradaptivity,
1104 mesh_poly_deg, h_metric_id,
1105 n_hr_iter, n_h_iter);
1107 if (adapt_lim_const > 0.)
1117 ofstream mesh_ofs(
"optimized.mesh");
1118 mesh_ofs.precision(14);
1119 mesh->
Print(mesh_ofs);
1123 (hradaptivity ? mesh->
GetNE() : 1);
1124 double fin_metric_energy = fin_energy;
1125 if (lim_const > 0.0 || adapt_lim_const > 0.0)
1129 surf_fit_coeff.constant = 0.0;
1131 (hradaptivity ? mesh->
GetNE() : 1);
1133 adapt_lim_coeff.
constant = adapt_lim_const;
1134 surf_fit_coeff.constant = surface_fit_const;
1136 std::cout << std::scientific << std::setprecision(4);
1137 cout <<
"Initial strain energy: " << init_energy
1138 <<
" = metrics: " << init_metric_energy
1139 <<
" + extra terms: " << init_energy - init_metric_energy << endl;
1140 cout <<
" Final strain energy: " << fin_energy
1141 <<
" = metrics: " << fin_metric_energy
1142 <<
" + extra terms: " << fin_energy - fin_metric_energy << endl;
1143 cout <<
"The strain energy decreased by: "
1144 << (init_energy - fin_energy) * 100.0 / init_energy <<
" %." << endl;
1149 char title[] =
"Final metric values";
1153 if (adapt_lim_const > 0.0 && visualization)
1157 600, 600, 300, 300);
1160 if (surface_fit_const > 0.0)
1166 600, 900, 300, 300);
1168 900, 900, 300, 300);
1170 double err_avg, err_max;
1172 std::cout <<
"Avg fitting error: " << err_avg << std::endl
1173 <<
"Max fitting error: " << err_max << std::endl;
1180 sock <<
"solution\n";
1185 sock <<
"window_title 'Displacements'\n"
1186 <<
"window_geometry "
1187 << 1200 <<
" " << 0 <<
" " << 600 <<
" " << 600 <<
"\n"
1188 <<
"keys jRmclA" << endl;
1195 delete metric_coeff1;
1196 delete adapt_lim_eval;
1197 delete adapt_surface;
1199 delete hr_adapt_coeff;
int GetNPoints() const
Returns the number of the points in the integration rule.
void discrete_aspr_3d(const Vector &x, Vector &v)
int Size() const
Return the logical size of the array.
Conjugate gradient method.
int GetNDofs() const
Returns number of degrees of freedom.
AssemblyLevel
Enumeration defining the assembly level for bilinear and nonlinear form classes derived from Operator...
Class for an integration rule - an Array of IntegrationPoint.
void EnableFiniteDifferences(const GridFunction &x)
Enables FD-based approximation and computes dx.
Class for grid function - Vector with associated FE space.
int DofToVDof(int dof, int vd, int ndofs=-1) const
double discrete_size_2d(const Vector &x)
3D barrier Shape+Size (VS) metric.
Data type for scaled Jacobi-type smoother of sparse matrix.
const IntegrationRule & Get(int GeomType, int Order)
Returns an integration rule for given GeomType and Order.
IntegrationRules IntRulesLo(0, Quadrature1D::GaussLobatto)
void SetPositiveDiagonal(bool pos_diag=true)
Replace diagonal entries with their absolute values.
void SetIntegrationRules(IntegrationRules &irules, int order)
Prescribe a set of integration rules; relevant for mixed meshes.
void SetFromTrueVector()
Shortcut for calling SetFromTrueDofs() with GetTrueVector() as argument.
3D barrier Shape+Size (VS) metric (polyconvex).
A coefficient that is constant across space and time.
virtual void SetSerialDiscreteTargetOrientation(const GridFunction &tspec_)
void EnableNormalization(const GridFunction &x)
Computes the normalization factors of the metric and limiting integrals using the mesh position given...
int GetNBE() const
Returns number of boundary elements.
3D barrier Shape (S) metric.
void SetAdaptivityEvaluator(AdaptivityEvaluator *ae)
void ProjectDiscCoefficient(VectorCoefficient &coeff, Array< int > &dof_attr)
2D barrier Shape+Size (VS) metric (polyconvex).
double surface_level_set(const Vector &x)
Coefficient defined by a GridFunction. This coefficient is mesh dependent.
Container class for integration rules.
Data type dense matrix using column-major storage.
3D barrier Shape (S) metric.
void GetSurfaceFittingErrors(double &err_avg, double &err_max)
int Size() const
Returns the size of the vector.
void SetVolumeScale(double vol_scale)
Used by target type IDEAL_SHAPE_EQUAL_SIZE. The default volume scale is 1.
2D barrier shape (S) metric (polyconvex).
void EnableAdaptiveLimiting(const GridFunction &z0, Coefficient &coeff, AdaptivityEvaluator &ae)
Restriction of the node positions to certain regions.
3D non-barrier Size (V) metric.
2D barrier size (V) metric (polyconvex).
void SetIntegrationRules(IntegrationRules &irules, int order)
Prescribe a set of integration rules; relevant for mixed meshes.
int GetNE() const
Returns number of elements.
void EnableNormalization(const GridFunction &x)
Normalization factor that considers all integrators in the combination.
2D barrier Shape+Size (VS) metric (polyconvex).
void Print(std::ostream &out=mfem::out)
Print the configuration of the MFEM virtual device object.
void vis_tmop_metric_s(int order, TMOP_QualityMetric &qm, const TargetConstructor &tc, Mesh &mesh, char *title, int position)
void SetExactActionFlag(bool flag_)
Flag to control if exact action of Integration is effected.
void Randomize(int seed=0)
Set random values in the vector.
void SetMinDetPtr(double *md_ptr)
2D barrier Shape+Size (VS) metric (not polyconvex).
Geometry::Type GetElementBaseGeometry(int i) const
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.
2D Shifted barrier form of shape metric (mu_2).
virtual void SetSerialDiscreteTargetAspectRatio(const GridFunction &tspec_)
const DenseMatrix & GetGeomToPerfGeomJac(int GeomType) const
DofTransformation * GetBdrElementVDofs(int i, Array< int > &vdofs) const
Returns indexes of degrees of freedom for i'th boundary element.
2D barrier shape (S) metric (not polyconvex).
void SetTerminationWithMaxSurfaceFittingError(double max_error)
virtual void Save(std::ostream &out) const
Save the GridFunction to an output stream.
Geometry::Type GetGeomType() const
Returns the Geometry::Type of the reference element.
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 GetDerivative(int comp, int der_comp, GridFunction &der)
Compute a certain derivative of a function's component. Derivatives of the function are computed at t...
void SetTrueVector()
Shortcut for calling GetTrueDofs() with GetTrueVector() as argument.
virtual void SetPreconditioner(Solver &pr)
This should be called before SetOperator.
virtual void SetPrintLevel(int print_lvl)
Legacy method to set the level of verbosity of the solver output.
double GetElementSize(ElementTransformation *T, int type=0)
void EnableLimiting(const GridFunction &n0, const GridFunction &dist, Coefficient &w0, TMOP_LimiterFunction *lfunc=NULL)
Limiting of the mesh displacements (general version).
int GetNBE() const
Returns number of boundary elements in the mesh.
void Parse()
Parse the command-line options. Note that this function expects all the options provided through the ...
void SetCoefficient(Coefficient &w1)
Sets a scaling Coefficient for the quality metric term of the integrator.
2D non-barrier size (V) metric (not polyconvex).
void EnsureNCMesh(bool simplices_nonconforming=false)
3D barrier Size (V) metric.
Jacobi smoothing for a given bilinear form (no matrix necessary).
void UniformRefinement(int i, const DSTable &, int *, int *, int *)
void SetNodes(const GridFunction &n)
Set the nodes to be used in the target-matrix construction.
void SetMaxIter(int max_it)
T Max() const
Find the maximal element in the array, using the comparison operator < for class T.
Version of QuadraticFECollection with positive basis functions.
int GetAttribute() const
Return element's attribute.
double discrete_ori_2d(const Vector &x)
2D barrier Shape+Size+Orientation (VOS) metric (polyconvex).
void SetNodalFESpace(FiniteElementSpace *nfes)
void AddFESpaceForUpdate(FiniteElementSpace *fes)
void PrintUsage(std::ostream &out) const
Print the usage message.
void DiffuseField(ParGridFunction &field, int smooth_steps)
void EnableAdaptiveSurfaceFitting()
2D barrier Shape+Orientation (OS) metric (polyconvex).
virtual DofTransformation * GetElementDofs(int elem, Array< int > &dofs) const
Returns indices of degrees of freedom of element 'elem'.
FDualNumber< tbase > pow(const FDualNumber< tbase > &a, const FDualNumber< tbase > &b)
pow([dual number],[dual number])
A general vector function coefficient.
3D barrier Shape+Size (VS) metric (polyconvex).
void SetAbsTol(double atol)
Array< int > bdr_attributes
A list of all unique boundary attributes used by the Mesh.
void AddGridFunctionForUpdate(GridFunction *gf)
void SetRelTol(double rtol)
2D barrier (not a shape) metric (polyconvex).
virtual void SetPreconditioner(Solver &pr)
This should be called before SetOperator.
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.
double weight_fun(const Vector &x)
2D barrier size (V) metric (polyconvex).
Collection of finite elements from the same family in multiple dimensions. This class is used to matc...
void AddOption(bool *var, const char *enable_short_name, const char *enable_long_name, const char *disable_short_name, const char *disable_long_name, const char *description, bool required=false)
Add a boolean option and set 'var' to receive the value. Enable/disable tags are used to set the bool...
void SetAdaptiveLinRtol(const int type=2, const double rtol0=0.5, const double rtol_max=0.9, const double alpha=0.5 *(1.0+sqrt(5.0)), const double gamma=1.0)
Enable adaptive linear solver relative tolerance algorithm.
double adapt_lim_fun(const Vector &x)
void AddTMOPIntegrator(TMOP_Integrator *ti)
Adds a new TMOP_Integrator to the combination.
double material_indicator_2d(const Vector &x)
2D barrier Shape+Size (VS) metric (not polyconvex).
double discrete_size_3d(const Vector &x)
double discrete_aspr_2d(const Vector &x)
Class for integration point with weight.
void GetElementTransformation(int i, IsoparametricTransformation *ElTr)
virtual void Print(std::ostream &os=mfem::out) const
2D barrier Shape+Size+Orientation (VOS) metric (polyconvex).
3D Shape (S) metric, untangling version of 303.
IntegrationRules IntRulesCU(0, Quadrature1D::ClosedUniform)
virtual const FiniteElement * GetFE(int i) const
Returns pointer to the FiniteElement in the FiniteElementCollection associated with i'th element in t...
void PrintOptions(std::ostream &out) const
Print the options.
double infinity()
Define a shortcut for std::numeric_limits<double>::infinity()
virtual void ProjectCoefficient(Coefficient &coeff)
Project coeff Coefficient to this GridFunction. The projection computation depends on the choice of t...
A general function coefficient.
void SetAttribute(int i, int attr)
Set the attribute of element i.
void VisualizeField(socketstream &sock, const char *vishost, int visport, GridFunction &gf, const char *title, int x, int y, int w, int h, const char *keys, bool vec)
3D barrier Shape+Size (VS) metric (polyconvex).
Arbitrary order H1-conforming (continuous) finite elements.
TargetType
Target-matrix construction algorithms supported by this class.
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.
const FiniteElement * GetBE(int i) const
Returns pointer to the FiniteElement in the FiniteElementCollection associated with i'th boundary fac...
void SetNodalGridFunction(GridFunction *nodes, bool make_owner=false)
Base class representing target-matrix construction algorithms for mesh optimization via the target-ma...
The MFEM Device class abstracts hardware devices such as GPUs, as well as programming models such as ...
virtual void SetAnalyticTargetSpec(Coefficient *sspec, VectorCoefficient *vspec, TMOPMatrixCoefficient *mspec)
3D barrier Shape+Size (VS) metric (polyconvex).
int material_id(int el_id, const GridFunction &g)
virtual void SetSerialDiscreteTargetSize(const GridFunction &tspec_)
IntegrationRules IntRules(0, Quadrature1D::GaussLegendre)
A global object with all integration rules (defined in intrules.cpp)
2D barrier Shape+Orientation (OS) metric (polyconvex).
virtual double * HostReadWrite()
Shortcut for mfem::ReadWrite(vec.GetMemory(), vec.Size(), false).
double GetElementVolume(int i)
const Element * GetBdrElement(int i) const
3D barrier Shape (S) metric.
2D non-barrier metric without a type.
Arbitrary order "L2-conforming" discontinuous finite elements.
bool Good() const
Return true if the command line options were parsed successfully.
A TMOP integrator class based on any given TMOP_QualityMetric and TargetConstructor.
2D non-barrier Shape+Size+Orientation (VOS) metric (polyconvex).