117 #include "../common/mfem-common.hpp"
122 using namespace mfem;
125 int main (
int argc,
char *argv[])
133 const char *mesh_file =
"icf.mesh";
134 int mesh_poly_deg = 1;
140 double lim_const = 0.0;
141 double adapt_lim_const = 0.0;
142 double surface_fit_const = 0.0;
146 int solver_iter = 20;
147 double solver_rtol = 1e-10;
148 int solver_art_type = 0;
150 int max_lin_iter = 100;
151 bool move_bnd =
true;
153 bool hradaptivity =
false;
154 int h_metric_id = -1;
155 bool normalization =
false;
156 bool visualization =
true;
157 int verbosity_level = 0;
158 bool fdscheme =
false;
160 bool exactaction =
false;
161 const char *devopt =
"cpu";
165 bool surface_fit_adapt =
false;
166 double surface_fit_threshold = -10;
167 int mesh_node_ordering = 0;
168 int barrier_type = 0;
169 int worst_case_type = 0;
173 args.
AddOption(&mesh_file,
"-m",
"--mesh",
174 "Mesh file to use.");
175 args.
AddOption(&mesh_poly_deg,
"-o",
"--order",
176 "Polynomial degree of mesh finite element space.");
177 args.
AddOption(&rs_levels,
"-rs",
"--refine-serial",
178 "Number of times to refine the mesh uniformly in serial.");
179 args.
AddOption(&rp_levels,
"-rp",
"--refine-parallel",
180 "Number of times to refine the mesh uniformly in parallel.");
181 args.
AddOption(&jitter,
"-ji",
"--jitter",
182 "Random perturbation scaling factor.");
183 args.
AddOption(&metric_id,
"-mid",
"--metric-id",
184 "Mesh optimization metric:\n\t"
186 "1 : |T|^2 -- 2D no type\n\t"
187 "2 : 0.5|T|^2/tau-1 -- 2D shape (condition number)\n\t"
188 "7 : |T-T^-t|^2 -- 2D shape+size\n\t"
189 "9 : tau*|T-T^-t|^2 -- 2D shape+size\n\t"
190 "14 : |T-I|^2 -- 2D shape+size+orientation\n\t"
191 "22 : 0.5(|T|^2-2*tau)/(tau-tau_0) -- 2D untangling\n\t"
192 "50 : 0.5|T^tT|^2/tau^2-1 -- 2D shape\n\t"
193 "55 : (tau-1)^2 -- 2D size\n\t"
194 "56 : 0.5(sqrt(tau)-1/sqrt(tau))^2 -- 2D size\n\t"
195 "58 : |T^tT|^2/(tau^2)-2*|T|^2/tau+2 -- 2D shape\n\t"
196 "77 : 0.5(tau-1/tau)^2 -- 2D size\n\t"
197 "80 : (1-gamma)mu_2 + gamma mu_77 -- 2D shape+size\n\t"
198 "85 : |T-|T|/sqrt(2)I|^2 -- 2D shape+orientation\n\t"
199 "98 : (1/tau)|T-I|^2 -- 2D shape+size+orientation\n\t"
202 "301: (|T||T^-1|)/3-1 -- 3D shape\n\t"
203 "302: (|T|^2|T^-1|^2)/9-1 -- 3D shape\n\t"
204 "303: (|T|^2)/3/tau^(2/3)-1 -- 3D shape\n\t"
205 "304: (|T|^3)/3^{3/2}/tau-1 -- 3D shape\n\t"
207 "313: (|T|^2)(tau-tau0)^(-2/3)/3 -- 3D untangling\n\t"
208 "315: (tau-1)^2 -- 3D no type\n\t"
209 "316: 0.5(sqrt(tau)-1/sqrt(tau))^2 -- 3D no type\n\t"
210 "321: |T-T^-t|^2 -- 3D shape+size\n\t"
211 "322: |T-adjT^-t|^2 -- 3D shape+size\n\t"
212 "323: |J|^3-3sqrt(3)ln(det(J))-3sqrt(3) -- 3D shape+size\n\t"
213 "328: (1-gamma) mu_301 + gamma mu_316 -- 3D shape+size\n\t"
214 "332: (1-gamma) mu_302 + gamma mu_315 -- 3D shape+size\n\t"
215 "333: (1-gamma) mu_302 + gamma mu_316 -- 3D shape+size\n\t"
216 "334: (1-gamma) mu_303 + gamma mu_316 -- 3D shape+size\n\t"
217 "347: (1-gamma) mu_304 + gamma mu_316 -- 3D shape+size\n\t"
219 "360: (|T|^3)/3^{3/2}-tau -- 3D shape\n\t"
221 "11 : (1/4*alpha)|A-(adjA)^T(W^TW)/omega|^2 -- 2D shape\n\t"
222 "36 : (1/alpha)|A-W|^2 -- 2D shape+size+orientation\n\t"
223 "107: (1/2*alpha)|A-|A|/|W|W|^2 -- 2D shape+orientation\n\t"
224 "126: (1-gamma)nu_11 + gamma*nu_14a -- 2D shape+size\n\t"
226 args.
AddOption(&target_id,
"-tid",
"--target-id",
227 "Target (ideal element) type:\n\t"
228 "1: Ideal shape, unit size\n\t"
229 "2: Ideal shape, equal size\n\t"
230 "3: Ideal shape, initial size\n\t"
231 "4: Given full analytic Jacobian (in physical space)\n\t"
232 "5: Ideal shape, given size (in physical space)");
233 args.
AddOption(&lim_const,
"-lc",
"--limit-const",
"Limiting constant.");
234 args.
AddOption(&adapt_lim_const,
"-alc",
"--adapt-limit-const",
235 "Adaptive limiting coefficient constant.");
236 args.
AddOption(&surface_fit_const,
"-sfc",
"--surface-fit-const",
237 "Surface preservation constant.");
238 args.
AddOption(&quad_type,
"-qt",
"--quad-type",
239 "Quadrature rule type:\n\t"
240 "1: Gauss-Lobatto\n\t"
241 "2: Gauss-Legendre\n\t"
242 "3: Closed uniform points");
243 args.
AddOption(&quad_order,
"-qo",
"--quad_order",
244 "Order of the quadrature rule.");
245 args.
AddOption(&solver_type,
"-st",
"--solver-type",
246 " Type of solver: (default) 0: Newton, 1: LBFGS");
247 args.
AddOption(&solver_iter,
"-ni",
"--newton-iters",
248 "Maximum number of Newton iterations.");
249 args.
AddOption(&solver_rtol,
"-rtol",
"--newton-rel-tolerance",
250 "Relative tolerance for the Newton solver.");
251 args.
AddOption(&solver_art_type,
"-art",
"--adaptive-rel-tol",
252 "Type of adaptive relative linear solver tolerance:\n\t"
253 "0: None (default)\n\t"
254 "1: Eisenstat-Walker type 1\n\t"
255 "2: Eisenstat-Walker type 2");
256 args.
AddOption(&lin_solver,
"-ls",
"--lin-solver",
261 "3: MINRES + Jacobi preconditioner\n\t"
262 "4: MINRES + l1-Jacobi preconditioner");
263 args.
AddOption(&max_lin_iter,
"-li",
"--lin-iter",
264 "Maximum number of iterations in the linear solve.");
265 args.
AddOption(&move_bnd,
"-bnd",
"--move-boundary",
"-fix-bnd",
267 "Enable motion along horizontal and vertical boundaries.");
268 args.
AddOption(&combomet,
"-cmb",
"--combo-type",
269 "Combination of metrics options:\n\t"
270 "0: Use single metric\n\t"
271 "1: Shape + space-dependent size given analytically\n\t"
272 "2: Shape + adapted size given discretely; shared target");
273 args.
AddOption(&hradaptivity,
"-hr",
"--hr-adaptivity",
"-no-hr",
274 "--no-hr-adaptivity",
275 "Enable hr-adaptivity.");
276 args.
AddOption(&h_metric_id,
"-hmid",
"--h-metric",
277 "Same options as metric_id. Used to determine refinement"
278 " type for each element if h-adaptivity is enabled.");
279 args.
AddOption(&normalization,
"-nor",
"--normalization",
"-no-nor",
280 "--no-normalization",
281 "Make all terms in the optimization functional unitless.");
282 args.
AddOption(&fdscheme,
"-fd",
"--fd_approximation",
283 "-no-fd",
"--no-fd-approx",
284 "Enable finite difference based derivative computations.");
285 args.
AddOption(&exactaction,
"-ex",
"--exact_action",
286 "-no-ex",
"--no-exact-action",
287 "Enable exact action of TMOP_Integrator.");
288 args.
AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
289 "--no-visualization",
290 "Enable or disable GLVis visualization.");
291 args.
AddOption(&verbosity_level,
"-vl",
"--verbosity-level",
292 "Set the verbosity level - 0, 1, or 2.");
293 args.
AddOption(&adapt_eval,
"-ae",
"--adaptivity-evaluator",
294 "0 - Advection based (DEFAULT), 1 - GSLIB.");
295 args.
AddOption(&devopt,
"-d",
"--device",
296 "Device configuration string, see Device::Configure().");
297 args.
AddOption(&pa,
"-pa",
"--partial-assembly",
"-no-pa",
298 "--no-partial-assembly",
"Enable Partial Assembly.");
299 args.
AddOption(&n_hr_iter,
"-nhr",
"--n_hr_iter",
300 "Number of hr-adaptivity iterations.");
301 args.
AddOption(&n_h_iter,
"-nh",
"--n_h_iter",
302 "Number of h-adaptivity iterations per r-adaptivity"
304 args.
AddOption(&surface_fit_adapt,
"-sfa",
"--adaptive-surface-fit",
"-no-sfa",
305 "--no-adaptive-surface-fit",
306 "Enable or disable adaptive surface fitting.");
307 args.
AddOption(&surface_fit_threshold,
"-sft",
"--surf-fit-threshold",
308 "Set threshold for surface fitting. TMOP solver will"
309 "terminate when max surface fitting error is below this limit");
310 args.
AddOption(&mesh_node_ordering,
"-mno",
"--mesh_node_ordering",
311 "Ordering of mesh nodes."
312 "0 (default): byNodes, 1: byVDIM");
313 args.
AddOption(&barrier_type,
"-btype",
"--barrier-type",
315 "1 - Shifted Barrier,"
316 "2 - Pseudo Barrier.");
317 args.
AddOption(&worst_case_type,
"-wctype",
"--worst-case-type",
329 if (h_metric_id < 0) { h_metric_id = metric_id; }
333 MFEM_VERIFY(strcmp(devopt,
"cpu")==0,
"HR-adaptivity is currently only"
334 " supported on cpus.");
337 if (myid == 0) { device.
Print();}
340 Mesh *mesh =
new Mesh(mesh_file, 1, 1,
false);
341 for (
int lev = 0; lev < rs_levels; lev++)
351 for (
int lev = 0; lev < rp_levels; lev++)
361 if (mesh_poly_deg <= 0)
391 double vol_loc = 0.0;
393 for (
int i = 0; i < pmesh->
GetNE(); i++)
399 for (
int j = 0; j < dofs.
Size(); j++)
401 h0(dofs[j]) = min(h0(dofs[j]), hi);
406 MPI_Allreduce(&vol_loc, &vol_glb, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD);
407 const double small_phys_size = pow(vol_glb, 1.0 / dim) / 100.0;
420 for (
int i = 0; i < pfespace->
GetNDofs(); i++)
422 for (
int d = 0; d <
dim; d++)
428 for (
int i = 0; i < pfespace->
GetNBE(); i++)
433 for (
int j = 0; j < vdofs.
Size(); j++) { rdm(vdofs[j]) = 0.0; }
444 ostringstream mesh_name;
445 mesh_name <<
"perturbed.mesh";
446 ofstream mesh_ofs(mesh_name.str().c_str());
447 mesh_ofs.precision(8);
456 double min_detJ = -0.1;
503 if (myid == 0) { cout <<
"Unknown metric_id: " << metric_id << endl; }
522 default: cout <<
"Metric_id not supported for h-adaptivity: " << h_metric_id <<
529 switch (barrier_type)
537 default: cout <<
"barrier_type not supported: " << barrier_type << endl;
542 switch (worst_case_type)
550 default: cout <<
"worst_case_type not supported: " << worst_case_type << endl;
555 if (barrier_type > 0 || worst_case_type > 0)
557 if (barrier_type > 0)
559 MFEM_VERIFY(metric_id == 4 || metric_id == 14 || metric_id == 66,
560 "Metric not supported for shifted/pseudo barriers.");
571 if (metric_id < 300 || h_metric_id < 300)
573 MFEM_VERIFY(dim == 2,
"Incompatible metric for 3D meshes");
575 if (metric_id >= 300 || h_metric_id >= 300)
577 MFEM_VERIFY(dim == 3,
"Incompatible metric for 2D meshes");
617 #ifdef MFEM_USE_GSLIB
620 MFEM_ABORT(
"MFEM is not built with GSLIB.");
626 size.ProjectCoefficient(size_coeff);
631 size.ProjectCoefficient(size_coeff);
651 #ifdef MFEM_USE_GSLIB
654 MFEM_ABORT(
"MFEM is not built with GSLIB.");
665 for (
int i = 0; i < size.Size(); i++)
667 size(i) = std::pow(d_x(i),2)+std::pow(d_y(i),2);
669 const double max = size.Max();
671 MPI_Allreduce(&max, &max_all, 1, MPI_DOUBLE, MPI_MAX, MPI_COMM_WORLD);
673 for (
int i = 0; i < d_x.Size(); i++)
675 d_x(i) = std::abs(d_x(i));
676 d_y(i) = std::abs(d_y(i));
678 const double eps = 0.01;
679 const double aspr_ratio = 20.0;
680 const double size_ratio = 40.0;
682 for (
int i = 0; i < size.Size(); i++)
684 size(i) = (size(i)/max_all);
685 aspr(i) = (d_x(i)+eps)/(d_y(i)+eps);
686 aspr(i) = 0.1 + 0.9*(1-size(i))*(1-size(i));
687 if (aspr(i) > aspr_ratio) {aspr(i) = aspr_ratio;}
688 if (aspr(i) < 1.0/aspr_ratio) {aspr(i) = 1.0/aspr_ratio;}
691 const int NE = pmesh->
GetNE();
692 double volume = 0.0, volume_ind = 0.0;
694 for (
int i = 0; i < NE; i++)
699 size.GetValues(i, ir, vals);
708 double volume_all, volume_ind_all;
709 MPI_Allreduce(&volume, &volume_all, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD);
710 MPI_Allreduce(&volume_ind, &volume_ind_all, 1, MPI_DOUBLE, MPI_SUM,
714 const double avg_zone_size = volume_all / NE_ALL;
716 const double small_avg_ratio =
717 (volume_ind_all + (volume_all - volume_ind_all) / size_ratio)
720 const double small_zone_size = small_avg_ratio * avg_zone_size;
721 const double big_zone_size = size_ratio * small_zone_size;
723 for (
int i = 0; i < size.Size(); i++)
725 const double val = size(i);
726 const double a = (big_zone_size - small_zone_size) / small_zone_size;
727 size(i) = big_zone_size / (1.0+a*val);
748 #ifdef MFEM_USE_GSLIB
751 MFEM_ABORT(
"MFEM is not built with GSLIB.");
770 #ifdef MFEM_USE_GSLIB
773 MFEM_ABORT(
"MFEM is not built with GSLIB.");
777 if (metric_id == 14 || metric_id == 36)
780 size.ProjectCoefficient(size_coeff);
787 aspr.ProjectCoefficient(aspr_coeff);
811 if (myid == 0) { cout <<
"Unknown target_id: " << target_id << endl; }
815 if (target_c == NULL)
825 if (barrier_type > 0 || worst_case_type > 0)
834 MFEM_VERIFY(pa ==
false,
"PA for finite differences is not implemented.");
847 if (myid == 0) { cout <<
"Unknown quad_type: " << quad_type << endl; }
851 if (myid == 0 && dim == 2)
853 cout <<
"Triangle quadrature points: "
855 <<
"\nQuadrilateral quadrature points: "
858 if (myid == 0 && dim == 3)
860 cout <<
"Tetrahedron quadrature points: "
862 <<
"\nHexahedron quadrature points: "
864 <<
"\nPrism quadrature points: "
874 if (normalization) { dist = small_phys_size; }
876 if (lim_const != 0.0) { tmop_integ->
EnableLimiting(x0, dist, lim_coeff); }
882 if (adapt_lim_const > 0.0)
884 MFEM_VERIFY(pa ==
false,
"PA is not implemented for adaptive limiting");
889 if (adapt_eval == 0) { adapt_lim_eval =
new AdvectorCG(al); }
890 else if (adapt_eval == 1)
892 #ifdef MFEM_USE_GSLIB
895 MFEM_ABORT(
"MFEM is not built with GSLIB support!");
898 else { MFEM_ABORT(
"Bad interpolation option."); }
921 if (surface_fit_const > 0.0)
923 MFEM_VERIFY(hradaptivity ==
false,
924 "Surface fitting with HR is not implemented yet.");
925 MFEM_VERIFY(pa ==
false,
926 "Surface fitting with PA is not implemented yet.");
931 for (
int i = 0; i < pmesh->
GetNE(); i++)
939 for (
int j = 0; j < surf_fit_marker.Size(); j++)
941 if (surf_fit_mat_gf(j) > 0.1 && surf_fit_mat_gf(j) < 0.9)
943 surf_fit_marker[j] =
true;
944 surf_fit_mat_gf(j) = 1.0;
948 surf_fit_marker[j] =
false;
949 surf_fit_mat_gf(j) = 0.0;
953 if (adapt_eval == 0) { adapt_surface =
new AdvectorCG; }
954 else if (adapt_eval == 1)
956 #ifdef MFEM_USE_GSLIB
959 MFEM_ABORT(
"MFEM is not built with GSLIB support!");
962 else { MFEM_ABORT(
"Bad interpolation option."); }
1016 else { tmop_integ2 =
new TMOP_Integrator(metric2, target_c, h_metric); }
1025 if (lim_const != 0.0) { combo->
EnableLimiting(x0, dist, lim_coeff); }
1034 if (pa) { a.
Setup(); }
1038 const int NE = pmesh->
GetNE();
1039 for (
int i = 0; i < NE; i++)
1047 min_detJ = min(min_detJ, transf->
Jacobian().
Det());
1051 MPI_Allreduce(&min_detJ, &minJ0, 1, MPI_DOUBLE, MPI_MIN, MPI_COMM_WORLD);
1054 { cout <<
"Minimum det(J) of the original mesh is " << min_detJ << endl; }
1056 if (min_detJ < 0.0 && barrier_type == 0
1057 && metric_id != 22 && metric_id != 211 && metric_id != 252
1058 && metric_id != 311 && metric_id != 313 && metric_id != 352)
1060 MFEM_ABORT(
"The input mesh is inverted! Try an untangling metric.");
1065 "Untangling is supported only for ideal targets.");
1069 min_detJ /= Wideal.
Det();
1071 double h0min = h0.Min(), h0min_all;
1072 MPI_Allreduce(&h0min, &h0min_all, 1, MPI_DOUBLE, MPI_MIN, MPI_COMM_WORLD);
1074 min_detJ -= 0.01 * h0min_all;
1080 double init_metric_energy = init_energy;
1081 if (lim_const > 0.0 || adapt_lim_const > 0.0 || surface_fit_const > 0.0)
1085 surf_fit_coeff.constant = 0.0;
1089 adapt_lim_coeff.
constant = adapt_lim_const;
1090 surf_fit_coeff.constant = surface_fit_const;
1097 char title[] =
"Initial metric values";
1105 if (move_bnd ==
false)
1114 for (
int i = 0; i < pmesh->
GetNBE(); i++)
1118 MFEM_VERIFY(!(dim == 2 && attr == 3),
1119 "Boundary attribute 3 must be used only for 3D meshes. "
1120 "Adjust the attributes (1/2/3/4 for fixed x/y/z/all "
1121 "components, rest for free nodes), or use -fix-bnd.");
1122 if (attr == 1 || attr == 2 || attr == 3) { n += nd; }
1123 if (attr == 4) { n += nd *
dim; }
1127 for (
int i = 0; i < pmesh->
GetNBE(); i++)
1134 for (
int j = 0; j < nd; j++)
1135 { ess_vdofs[n++] = vdofs[j]; }
1139 for (
int j = 0; j < nd; j++)
1140 { ess_vdofs[n++] = vdofs[j+nd]; }
1144 for (
int j = 0; j < nd; j++)
1145 { ess_vdofs[n++] = vdofs[j+2*nd]; }
1149 for (
int j = 0; j < vdofs.
Size(); j++)
1150 { ess_vdofs[n++] = vdofs[j]; }
1158 Solver *S = NULL, *S_prec = NULL;
1159 const double linsol_rtol = 1e-12;
1160 if (lin_solver == 0)
1162 S =
new DSmoother(1, 1.0, max_lin_iter);
1164 else if (lin_solver == 1)
1180 else { minres->
SetPrintLevel(verbosity_level == 2 ? 3 : -1); }
1181 if (lin_solver == 3 || lin_solver == 4)
1185 MFEM_VERIFY(lin_solver != 4,
"PA l1-Jacobi is not implemented");
1195 hs->SetPositiveDiagonal(
true);
1208 if (surface_fit_threshold > 0)
1210 solver.SetTerminationWithMaxSurfaceFittingError(surface_fit_threshold);
1213 solver.SetIntegrationRules(*irules, quad_order);
1214 if (solver_type == 0)
1217 solver.SetPreconditioner(*S);
1220 solver.SetMinDetPtr(&min_detJ);
1221 solver.SetMaxIter(solver_iter);
1222 solver.SetRelTol(solver_rtol);
1223 solver.SetAbsTol(0.0);
1224 if (solver_art_type > 0)
1226 solver.SetAdaptiveLinRtol(solver_art_type, 0.5, 0.9);
1228 solver.SetPrintLevel(verbosity_level >= 1 ? 1 : -1);
1238 x, move_bnd, hradaptivity,
1239 mesh_poly_deg, h_metric_id,
1240 n_hr_iter, n_h_iter);
1242 if (adapt_lim_const > 0.)
1252 ostringstream mesh_name;
1253 mesh_name <<
"optimized.mesh";
1254 ofstream mesh_ofs(mesh_name.str().c_str());
1255 mesh_ofs.precision(8);
1262 double fin_metric_energy = fin_energy;
1263 if (lim_const > 0.0 || adapt_lim_const > 0.0 || surface_fit_const > 0.0)
1267 surf_fit_coeff.constant = 0.0;
1271 adapt_lim_coeff.
constant = adapt_lim_const;
1272 surf_fit_coeff.constant = surface_fit_const;
1276 std::cout << std::scientific << std::setprecision(4);
1277 cout <<
"Initial strain energy: " << init_energy
1278 <<
" = metrics: " << init_metric_energy
1279 <<
" + extra terms: " << init_energy - init_metric_energy << endl;
1280 cout <<
" Final strain energy: " << fin_energy
1281 <<
" = metrics: " << fin_metric_energy
1282 <<
" + extra terms: " << fin_energy - fin_metric_energy << endl;
1283 cout <<
"The strain energy decreased by: "
1284 << (init_energy - fin_energy) * 100.0 / init_energy <<
" %." << endl;
1290 char title[] =
"Final metric values";
1294 if (adapt_lim_const > 0.0 && visualization)
1298 600, 600, 300, 300);
1301 if (surface_fit_const > 0.0)
1307 "Materials", 600, 900, 300, 300);
1309 "Surface dof", 900, 900, 300, 300);
1311 double err_avg, err_max;
1315 std::cout <<
"Avg fitting error: " << err_avg << std::endl
1316 <<
"Max fitting error: " << err_max << std::endl;
1327 sock.
open(
"localhost", 19916);
1328 sock <<
"solution\n";
1334 sock <<
"window_title 'Displacements'\n"
1335 <<
"window_geometry "
1336 << 1200 <<
" " << 0 <<
" " << 600 <<
" " << 600 <<
"\n"
1337 <<
"keys jRmclA" << endl;
1346 delete metric_coeff1;
1347 delete adapt_lim_eval;
1348 delete adapt_surface;
1350 delete hr_adapt_coeff;
1354 delete untangler_metric;
int GetNPoints() const
Returns the number of the points in the integration rule.
void vis_tmop_metric_p(int order, TMOP_QualityMetric &qm, const TargetConstructor &tc, ParMesh &pmesh, char *title, int position)
void ComputeUntangleMetricQuantiles(const Vector &x, const FiniteElementSpace &fes)
void discrete_aspr_3d(const Vector &x, Vector &v)
virtual void SetParDiscreteTargetSize(const ParGridFunction &tspec_)
int Size() const
Return the logical size of the array.
static void Init()
Initialize hypre by calling HYPRE_Init() and set default options. After calling Hypre::Init(), hypre will be finalized automatically at program exit.
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.
3D non-barrier Shape (S) metric.
void EnableFiniteDifferences(const GridFunction &x)
Enables FD-based approximation and computes dx.
int DofToVDof(int dof, int vd, int ndofs=-1) const
void GetDerivative(int comp, int der_comp, ParGridFunction &der)
Parallel version of GridFunction::GetDerivative(); see its documentation.
double discrete_size_2d(const Vector &x)
3D barrier Shape+Size (VS) metric, well-posed (invex).
2D non-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 SetFromTrueVector()
Shortcut for calling SetFromTrueDofs() with GetTrueVector() as argument.
3D barrier Shape+Size (VS) metric, well-posed (polyconvex).
A coefficient that is constant across space and time.
int GetNBE() const
Returns number of boundary elements.
3D barrier Shape (S) metric, well-posed (polyconvex & invex).
void SetAdaptivityEvaluator(AdaptivityEvaluator *ae)
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, well-posed (polyconvex & invex).
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 metric without a type.
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.
2D barrier Shape+Size (VS) metric (polyconvex).
void Print(std::ostream &out=mfem::out)
Print the configuration of the MFEM virtual device object.
3D barrier Shape+Size (VS) metric, well-posed (invex).
virtual void ProjectDiscCoefficient(VectorCoefficient &coeff)
Project a discontinuous vector coefficient as a grid function on a continuous finite element space...
Abstract parallel finite element space.
virtual void ProjectCoefficient(Coefficient &coeff)
Project coeff Coefficient to this GridFunction. The projection computation depends on the choice of t...
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.
2D barrier Shape+Size (VS) metric (not polyconvex).
Geometry::Type GetElementBaseGeometry(int i) const
3D barrier Shape+Size (VS) metric, well-posed (invex).
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).
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).
3D barrier Shape (S) metric, well-posed (polyconvex & invex).
Geometry::Type GetGeomType() const
Returns the Geometry::Type of the reference element.
2D non-barrier shape (S) metric.
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 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)
virtual const FiniteElement * GetFE(int i) const
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 metric without a type.
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.
3D barrier Shape+Size (VS) metric, well-posed (polyconvex).
Version of QuadraticFECollection with positive basis functions.
virtual void SetParDiscreteTargetAspectRatio(const ParGridFunction &tspec_)
int GetAttribute() const
Return element's attribute.
double discrete_ori_2d(const Vector &x)
Parallel smoothers in hypre.
static void Init()
Singleton creation with Mpi::Init();.
void ParEnableNormalization(const ParGridFunction &x)
2D barrier Shape+Size+Orientation (VOS) metric (polyconvex).
void AddFESpaceForUpdate(FiniteElementSpace *fes)
void PrintUsage(std::ostream &out) const
Print the usage message.
void DiffuseField(ParGridFunction &field, int smooth_steps)
void EnableAdaptiveSurfaceFitting()
virtual DofTransformation * GetElementDofs(int i, Array< int > &dofs) const
Returns indexes of degrees of freedom in array dofs for i'th element.
2D barrier Shape+Orientation (OS) metric (polyconvex).
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).
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...
double adapt_lim_fun(const Vector &x)
void AddTMOPIntegrator(TMOP_Integrator *ti)
Adds a new TMOP_Integrator to the combination.
void SaveAsOne(const char *fname, int precision=16) const
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)
2D barrier Shape+Size+Orientation (VOS) metric (polyconvex).
long long GetGlobalNE() const
Return the total (global) number of elements.
3D Shape (S) metric, untangling version of 303.
IntegrationRules IntRulesCU(0, Quadrature1D::ClosedUniform)
void PrintOptions(std::ostream &out) const
Print the options.
double infinity()
Define a shortcut for std::numeric_limits<double>::infinity()
int open(const char hostname[], int port)
Open the socket stream on 'port' at 'hostname'.
static int WorldRank()
Return the MPI rank in MPI_COMM_WORLD.
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, well-posed (polyconvex).
void PrintAsOne(std::ostream &out=mfem::out) const
void SetNodalFESpace(FiniteElementSpace *nfes) override
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.
virtual void SetParDiscreteTargetOrientation(const ParGridFunction &tspec_)
Class for parallel grid 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)
Class for parallel meshes.
IntegrationRules IntRules(0, Quadrature1D::GaussLegendre)
A global object with all integration rules (defined in intrules.cpp)
void SetType(HypreSmoother::Type type, int relax_times=1)
Set the relaxation type and number of sweeps.
2D barrier Shape+Orientation (OS) metric (polyconvex).
virtual double * HostReadWrite()
Shortcut for mfem::ReadWrite(vec.GetMemory(), vec.Size(), false).
void ParEnableNormalization(const ParGridFunction &x)
double GetElementVolume(int i)
const Element * GetBdrElement(int i) const
3D barrier Shape (S) metric, well-posed (polyconvex & invex).
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).