115 #include "../common/mfem-common.hpp" 120 using namespace mfem;
123 int main (
int argc,
char *argv[])
131 const char *mesh_file =
"icf.mesh";
132 int mesh_poly_deg = 1;
138 double lim_const = 0.0;
139 double adapt_lim_const = 0.0;
140 double surface_fit_const = 0.0;
144 int solver_iter = 20;
145 double solver_rtol = 1e-10;
146 int solver_art_type = 0;
148 int max_lin_iter = 100;
149 bool move_bnd =
true;
151 bool bal_expl_combo =
false;
152 bool hradaptivity =
false;
153 int h_metric_id = -1;
154 bool normalization =
false;
155 bool visualization =
true;
156 int verbosity_level = 0;
157 bool fdscheme =
false;
159 bool exactaction =
false;
160 const char *devopt =
"cpu";
164 bool surface_fit_adapt =
false;
165 double surface_fit_threshold = -10;
166 int mesh_node_ordering = 0;
167 int barrier_type = 0;
168 int worst_case_type = 0;
172 args.
AddOption(&mesh_file,
"-m",
"--mesh",
173 "Mesh file to use.");
174 args.
AddOption(&mesh_poly_deg,
"-o",
"--order",
175 "Polynomial degree of mesh finite element space.");
176 args.
AddOption(&rs_levels,
"-rs",
"--refine-serial",
177 "Number of times to refine the mesh uniformly in serial.");
178 args.
AddOption(&rp_levels,
"-rp",
"--refine-parallel",
179 "Number of times to refine the mesh uniformly in parallel.");
180 args.
AddOption(&jitter,
"-ji",
"--jitter",
181 "Random perturbation scaling factor.");
182 args.
AddOption(&metric_id,
"-mid",
"--metric-id",
183 "Mesh optimization metric:\n\t" 185 "1 : |T|^2 -- 2D no type\n\t" 186 "2 : 0.5|T|^2/tau-1 -- 2D shape (condition number)\n\t" 187 "7 : |T-T^-t|^2 -- 2D shape+size\n\t" 188 "9 : tau*|T-T^-t|^2 -- 2D shape+size\n\t" 189 "14 : |T-I|^2 -- 2D shape+size+orientation\n\t" 190 "22 : 0.5(|T|^2-2*tau)/(tau-tau_0) -- 2D untangling\n\t" 191 "50 : 0.5|T^tT|^2/tau^2-1 -- 2D shape\n\t" 192 "55 : (tau-1)^2 -- 2D size\n\t" 193 "56 : 0.5(sqrt(tau)-1/sqrt(tau))^2 -- 2D size\n\t" 194 "58 : |T^tT|^2/(tau^2)-2*|T|^2/tau+2 -- 2D shape\n\t" 195 "77 : 0.5(tau-1/tau)^2 -- 2D size\n\t" 196 "80 : (1-gamma)mu_2 + gamma mu_77 -- 2D shape+size\n\t" 197 "85 : |T-|T|/sqrt(2)I|^2 -- 2D shape+orientation\n\t" 198 "98 : (1/tau)|T-I|^2 -- 2D shape+size+orientation\n\t" 201 "301: (|T||T^-1|)/3-1 -- 3D shape\n\t" 202 "302: (|T|^2|T^-1|^2)/9-1 -- 3D shape\n\t" 203 "303: (|T|^2)/3/tau^(2/3)-1 -- 3D shape\n\t" 204 "304: (|T|^3)/3^{3/2}/tau-1 -- 3D shape\n\t" 206 "313: (|T|^2)(tau-tau0)^(-2/3)/3 -- 3D untangling\n\t" 207 "315: (tau-1)^2 -- 3D no type\n\t" 208 "316: 0.5(sqrt(tau)-1/sqrt(tau))^2 -- 3D no type\n\t" 209 "321: |T-T^-t|^2 -- 3D shape+size\n\t" 210 "322: |T-adjT^-t|^2 -- 3D shape+size\n\t" 211 "323: |J|^3-3sqrt(3)ln(det(J))-3sqrt(3) -- 3D shape+size\n\t" 212 "328: (1-gamma) mu_301 + gamma mu_316 -- 3D shape+size\n\t" 213 "332: (1-gamma) mu_302 + gamma mu_315 -- 3D shape+size\n\t" 214 "333: (1-gamma) mu_302 + gamma mu_316 -- 3D shape+size\n\t" 215 "334: (1-gamma) mu_303 + gamma mu_316 -- 3D shape+size\n\t" 216 "347: (1-gamma) mu_304 + gamma mu_316 -- 3D shape+size\n\t" 218 "360: (|T|^3)/3^{3/2}-tau -- 3D shape\n\t" 220 "11 : (1/4*alpha)|A-(adjA)^T(W^TW)/omega|^2 -- 2D shape\n\t" 221 "36 : (1/alpha)|A-W|^2 -- 2D shape+size+orientation\n\t" 222 "107: (1/2*alpha)|A-|A|/|W|W|^2 -- 2D shape+orientation\n\t" 223 "126: (1-gamma)nu_11 + gamma*nu_14a -- 2D shape+size\n\t" 225 args.
AddOption(&target_id,
"-tid",
"--target-id",
226 "Target (ideal element) type:\n\t" 227 "1: Ideal shape, unit size\n\t" 228 "2: Ideal shape, equal size\n\t" 229 "3: Ideal shape, initial size\n\t" 230 "4: Given full analytic Jacobian (in physical space)\n\t" 231 "5: Ideal shape, given size (in physical space)");
232 args.
AddOption(&lim_const,
"-lc",
"--limit-const",
"Limiting constant.");
233 args.
AddOption(&adapt_lim_const,
"-alc",
"--adapt-limit-const",
234 "Adaptive limiting coefficient constant.");
235 args.
AddOption(&surface_fit_const,
"-sfc",
"--surface-fit-const",
236 "Surface preservation constant.");
237 args.
AddOption(&quad_type,
"-qt",
"--quad-type",
238 "Quadrature rule type:\n\t" 239 "1: Gauss-Lobatto\n\t" 240 "2: Gauss-Legendre\n\t" 241 "3: Closed uniform points");
242 args.
AddOption(&quad_order,
"-qo",
"--quad_order",
243 "Order of the quadrature rule.");
244 args.
AddOption(&solver_type,
"-st",
"--solver-type",
245 " Type of solver: (default) 0: Newton, 1: LBFGS");
246 args.
AddOption(&solver_iter,
"-ni",
"--newton-iters",
247 "Maximum number of Newton iterations.");
248 args.
AddOption(&solver_rtol,
"-rtol",
"--newton-rel-tolerance",
249 "Relative tolerance for the Newton solver.");
250 args.
AddOption(&solver_art_type,
"-art",
"--adaptive-rel-tol",
251 "Type of adaptive relative linear solver tolerance:\n\t" 252 "0: None (default)\n\t" 253 "1: Eisenstat-Walker type 1\n\t" 254 "2: Eisenstat-Walker type 2");
255 args.
AddOption(&lin_solver,
"-ls",
"--lin-solver",
260 "3: MINRES + Jacobi preconditioner\n\t" 261 "4: MINRES + l1-Jacobi preconditioner");
262 args.
AddOption(&max_lin_iter,
"-li",
"--lin-iter",
263 "Maximum number of iterations in the linear solve.");
264 args.
AddOption(&move_bnd,
"-bnd",
"--move-boundary",
"-fix-bnd",
266 "Enable motion along horizontal and vertical boundaries.");
267 args.
AddOption(&combomet,
"-cmb",
"--combo-type",
268 "Combination of metrics options:\n\t" 269 "0: Use single metric\n\t" 270 "1: Shape + space-dependent size given analytically\n\t" 271 "2: Shape + adapted size given discretely; shared target");
272 args.
AddOption(&bal_expl_combo,
"-bec",
"--balance-explicit-combo",
273 "-no-bec",
"--balance-explicit-combo",
274 "Automatic balancing of explicit combo metrics.");
275 args.
AddOption(&hradaptivity,
"-hr",
"--hr-adaptivity",
"-no-hr",
276 "--no-hr-adaptivity",
277 "Enable hr-adaptivity.");
278 args.
AddOption(&h_metric_id,
"-hmid",
"--h-metric",
279 "Same options as metric_id. Used to determine refinement" 280 " type for each element if h-adaptivity is enabled.");
281 args.
AddOption(&normalization,
"-nor",
"--normalization",
"-no-nor",
282 "--no-normalization",
283 "Make all terms in the optimization functional unitless.");
284 args.
AddOption(&fdscheme,
"-fd",
"--fd_approximation",
285 "-no-fd",
"--no-fd-approx",
286 "Enable finite difference based derivative computations.");
287 args.
AddOption(&exactaction,
"-ex",
"--exact_action",
288 "-no-ex",
"--no-exact-action",
289 "Enable exact action of TMOP_Integrator.");
290 args.
AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
291 "--no-visualization",
292 "Enable or disable GLVis visualization.");
293 args.
AddOption(&verbosity_level,
"-vl",
"--verbosity-level",
294 "Set the verbosity level - 0, 1, or 2.");
295 args.
AddOption(&adapt_eval,
"-ae",
"--adaptivity-evaluator",
296 "0 - Advection based (DEFAULT), 1 - GSLIB.");
297 args.
AddOption(&devopt,
"-d",
"--device",
298 "Device configuration string, see Device::Configure().");
299 args.
AddOption(&pa,
"-pa",
"--partial-assembly",
"-no-pa",
300 "--no-partial-assembly",
"Enable Partial Assembly.");
301 args.
AddOption(&n_hr_iter,
"-nhr",
"--n_hr_iter",
302 "Number of hr-adaptivity iterations.");
303 args.
AddOption(&n_h_iter,
"-nh",
"--n_h_iter",
304 "Number of h-adaptivity iterations per r-adaptivity" 306 args.
AddOption(&surface_fit_adapt,
"-sfa",
"--adaptive-surface-fit",
"-no-sfa",
307 "--no-adaptive-surface-fit",
308 "Enable or disable adaptive surface fitting.");
309 args.
AddOption(&surface_fit_threshold,
"-sft",
"--surf-fit-threshold",
310 "Set threshold for surface fitting. TMOP solver will" 311 "terminate when max surface fitting error is below this limit");
312 args.
AddOption(&mesh_node_ordering,
"-mno",
"--mesh_node_ordering",
313 "Ordering of mesh nodes." 314 "0 (default): byNodes, 1: byVDIM");
315 args.
AddOption(&barrier_type,
"-btype",
"--barrier-type",
317 "1 - Shifted Barrier," 318 "2 - Pseudo Barrier.");
319 args.
AddOption(&worst_case_type,
"-wctype",
"--worst-case-type",
331 if (h_metric_id < 0) { h_metric_id = metric_id; }
335 MFEM_VERIFY(strcmp(devopt,
"cpu")==0,
"HR-adaptivity is currently only" 336 " supported on cpus.");
339 if (myid == 0) { device.
Print();}
342 Mesh *mesh =
new Mesh(mesh_file, 1, 1,
false);
343 for (
int lev = 0; lev < rs_levels; lev++)
353 for (
int lev = 0; lev < rp_levels; lev++)
363 if (mesh_poly_deg <= 0)
390 double vol_loc = 0.0;
392 for (
int i = 0; i < pmesh->
GetNE(); i++)
398 for (
int j = 0; j < dofs.
Size(); j++)
400 h0(dofs[j]) = min(h0(dofs[j]), hi);
405 MPI_Allreduce(&vol_loc, &vol_glb, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD);
406 const double small_phys_size = pow(vol_glb, 1.0 /
dim) / 100.0;
419 for (
int i = 0; i < pfespace->
GetNDofs(); i++)
421 for (
int d = 0; d <
dim; d++)
427 for (
int i = 0; i < pfespace->
GetNBE(); i++)
432 for (
int j = 0; j < vdofs.
Size(); j++) { rdm(vdofs[j]) = 0.0; }
443 ostringstream mesh_name;
444 mesh_name <<
"perturbed.mesh";
445 ofstream mesh_ofs(mesh_name.str().c_str());
446 mesh_ofs.precision(8);
455 double min_detJ = -0.1;
502 if (myid == 0) { cout <<
"Unknown metric_id: " << metric_id << endl; }
521 default: cout <<
"Metric_id not supported for h-adaptivity: " << h_metric_id <<
528 switch (barrier_type)
536 default: cout <<
"barrier_type not supported: " << barrier_type << endl;
541 switch (worst_case_type)
549 default: cout <<
"worst_case_type not supported: " << worst_case_type << endl;
554 if (barrier_type > 0 || worst_case_type > 0)
556 if (barrier_type > 0)
558 MFEM_VERIFY(metric_id == 4 || metric_id == 14 || metric_id == 66,
559 "Metric not supported for shifted/pseudo barriers.");
570 if (metric_id < 300 || h_metric_id < 300)
572 MFEM_VERIFY(
dim == 2,
"Incompatible metric for 3D meshes");
574 if (metric_id >= 300 || h_metric_id >= 300)
576 MFEM_VERIFY(
dim == 3,
"Incompatible metric for 2D meshes");
616 #ifdef MFEM_USE_GSLIB 619 MFEM_ABORT(
"MFEM is not built with GSLIB.");
625 size.ProjectCoefficient(size_coeff);
630 size.ProjectCoefficient(size_coeff);
643 disc.ProjectCoefficient(mat_coeff);
650 #ifdef MFEM_USE_GSLIB 653 MFEM_ABORT(
"MFEM is not built with GSLIB.");
660 disc.GetDerivative(1,0,d_x);
661 disc.GetDerivative(1,1,d_y);
664 for (
int i = 0; i < size.Size(); i++)
666 size(i) = std::pow(d_x(i),2)+std::pow(d_y(i),2);
668 const double max = size.Max();
670 MPI_Allreduce(&max, &max_all, 1, MPI_DOUBLE, MPI_MAX, MPI_COMM_WORLD);
672 for (
int i = 0; i < d_x.Size(); i++)
674 d_x(i) = std::abs(d_x(i));
675 d_y(i) = std::abs(d_y(i));
677 const double eps = 0.01;
678 const double aspr_ratio = 20.0;
679 const double size_ratio = 40.0;
681 for (
int i = 0; i < size.Size(); i++)
683 size(i) = (size(i)/max_all);
684 aspr(i) = (d_x(i)+eps)/(d_y(i)+eps);
685 aspr(i) = 0.1 + 0.9*(1-size(i))*(1-size(i));
686 if (aspr(i) > aspr_ratio) {aspr(i) = aspr_ratio;}
687 if (aspr(i) < 1.0/aspr_ratio) {aspr(i) = 1.0/aspr_ratio;}
690 const int NE = pmesh->
GetNE();
691 double volume = 0.0, volume_ind = 0.0;
693 for (
int i = 0; i < NE; i++)
698 size.GetValues(i, ir, vals);
707 double volume_all, volume_ind_all;
708 MPI_Allreduce(&volume, &volume_all, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD);
709 MPI_Allreduce(&volume_ind, &volume_ind_all, 1, MPI_DOUBLE, MPI_SUM,
713 const double avg_zone_size = volume_all / NE_ALL;
715 const double small_avg_ratio =
716 (volume_ind_all + (volume_all - volume_ind_all) / size_ratio)
719 const double small_zone_size = small_avg_ratio * avg_zone_size;
720 const double big_zone_size = size_ratio * small_zone_size;
722 for (
int i = 0; i < size.Size(); i++)
724 const double val = size(i);
725 const double a = (big_zone_size - small_zone_size) / small_zone_size;
726 size(i) = big_zone_size / (1.0+
a*val);
747 #ifdef MFEM_USE_GSLIB 750 MFEM_ABORT(
"MFEM is not built with GSLIB.");
769 #ifdef MFEM_USE_GSLIB 772 MFEM_ABORT(
"MFEM is not built with GSLIB.");
777 size.ProjectCoefficient(size_coeff);
799 if (myid == 0) { cout <<
"Unknown target_id: " << target_id << endl; }
802 if (target_c == NULL)
810 if (metric_combo && bal_expl_combo)
813 metric_combo->ComputeBalancedWeights(x, *target_c, bal_weights);
814 metric_combo->SetWeights(bal_weights);
822 if (barrier_type > 0 || worst_case_type > 0)
830 MFEM_VERIFY(pa ==
false,
"PA for finite differences is not implemented.");
843 if (myid == 0) { cout <<
"Unknown quad_type: " << quad_type << endl; }
847 if (myid == 0 &&
dim == 2)
849 cout <<
"Triangle quadrature points: " 851 <<
"\nQuadrilateral quadrature points: " 854 if (myid == 0 &&
dim == 3)
856 cout <<
"Tetrahedron quadrature points: " 858 <<
"\nHexahedron quadrature points: " 860 <<
"\nPrism quadrature points: " 870 if (normalization) { dist = small_phys_size; }
872 if (lim_const != 0.0) { tmop_integ->
EnableLimiting(x0, dist, lim_coeff); }
878 if (adapt_lim_const > 0.0)
880 MFEM_VERIFY(pa ==
false,
"PA is not implemented for adaptive limiting");
885 if (adapt_eval == 0) { adapt_lim_eval =
new AdvectorCG(al); }
886 else if (adapt_eval == 1)
888 #ifdef MFEM_USE_GSLIB 891 MFEM_ABORT(
"MFEM is not built with GSLIB support!");
894 else { MFEM_ABORT(
"Bad interpolation option."); }
917 if (surface_fit_const > 0.0)
919 MFEM_VERIFY(hradaptivity ==
false,
920 "Surface fitting with HR is not implemented yet.");
921 MFEM_VERIFY(pa ==
false,
922 "Surface fitting with PA is not implemented yet.");
927 for (
int i = 0; i < pmesh->
GetNE(); i++)
935 for (
int j = 0; j < surf_fit_marker.Size(); j++)
937 if (surf_fit_mat_gf(j) > 0.1 && surf_fit_mat_gf(j) < 0.9)
939 surf_fit_marker[j] =
true;
940 surf_fit_mat_gf(j) = 1.0;
944 surf_fit_marker[j] =
false;
945 surf_fit_mat_gf(j) = 0.0;
949 if (adapt_eval == 0) { adapt_surface =
new AdvectorCG; }
950 else if (adapt_eval == 1)
952 #ifdef MFEM_USE_GSLIB 955 MFEM_ABORT(
"MFEM is not built with GSLIB support!");
958 else { MFEM_ABORT(
"Bad interpolation option."); }
1012 else { tmop_integ2 =
new TMOP_Integrator(metric2, target_c, h_metric); }
1021 if (lim_const != 0.0) { combo->
EnableLimiting(x0, dist, lim_coeff); }
1023 a.AddDomainIntegrator(combo);
1027 a.AddDomainIntegrator(tmop_integ);
1030 if (pa) {
a.Setup(); }
1034 const int NE = pmesh->
GetNE();
1035 for (
int i = 0; i < NE; i++)
1043 min_detJ = min(min_detJ, transf->
Jacobian().
Det());
1047 MPI_Allreduce(&min_detJ, &minJ0, 1, MPI_DOUBLE, MPI_MIN, MPI_COMM_WORLD);
1050 { cout <<
"Minimum det(J) of the original mesh is " << min_detJ << endl; }
1052 if (min_detJ < 0.0 && barrier_type == 0
1053 && metric_id != 22 && metric_id != 211 && metric_id != 252
1054 && metric_id != 311 && metric_id != 313 && metric_id != 352)
1056 MFEM_ABORT(
"The input mesh is inverted! Try an untangling metric.");
1061 "Untangling is supported only for ideal targets.");
1065 min_detJ /= Wideal.
Det();
1067 double h0min = h0.Min(), h0min_all;
1068 MPI_Allreduce(&h0min, &h0min_all, 1, MPI_DOUBLE, MPI_MIN, MPI_COMM_WORLD);
1070 min_detJ -= 0.01 * h0min_all;
1074 const double init_energy =
a.GetParGridFunctionEnergy(x) /
1076 double init_metric_energy = init_energy;
1077 if (lim_const > 0.0 || adapt_lim_const > 0.0 || surface_fit_const > 0.0)
1081 surf_fit_coeff.constant = 0.0;
1082 init_metric_energy =
a.GetParGridFunctionEnergy(x) /
1085 adapt_lim_coeff.
constant = adapt_lim_const;
1086 surf_fit_coeff.constant = surface_fit_const;
1093 char title[] =
"Initial metric values";
1101 if (move_bnd ==
false)
1105 a.SetEssentialBC(ess_bdr);
1110 for (
int i = 0; i < pmesh->
GetNBE(); i++)
1114 MFEM_VERIFY(!(
dim == 2 && attr == 3),
1115 "Boundary attribute 3 must be used only for 3D meshes. " 1116 "Adjust the attributes (1/2/3/4 for fixed x/y/z/all " 1117 "components, rest for free nodes), or use -fix-bnd.");
1118 if (attr == 1 || attr == 2 || attr == 3) { n += nd; }
1119 if (attr == 4) { n += nd *
dim; }
1123 for (
int i = 0; i < pmesh->
GetNBE(); i++)
1130 for (
int j = 0; j < nd; j++)
1131 { ess_vdofs[n++] = vdofs[j]; }
1135 for (
int j = 0; j < nd; j++)
1136 { ess_vdofs[n++] = vdofs[j+nd]; }
1140 for (
int j = 0; j < nd; j++)
1141 { ess_vdofs[n++] = vdofs[j+2*nd]; }
1145 for (
int j = 0; j < vdofs.
Size(); j++)
1146 { ess_vdofs[n++] = vdofs[j]; }
1149 a.SetEssentialVDofs(ess_vdofs);
1154 Solver *S = NULL, *S_prec = NULL;
1155 const double linsol_rtol = 1e-12;
1156 if (lin_solver == 0)
1158 S =
new DSmoother(1, 1.0, max_lin_iter);
1160 else if (lin_solver == 1)
1176 else { minres->
SetPrintLevel(verbosity_level == 2 ? 3 : -1); }
1177 if (lin_solver == 3 || lin_solver == 4)
1181 MFEM_VERIFY(lin_solver != 4,
"PA l1-Jacobi is not implemented");
1191 hs->SetPositiveDiagonal(
true);
1204 if (surface_fit_threshold > 0)
1206 solver.SetTerminationWithMaxSurfaceFittingError(surface_fit_threshold);
1209 solver.SetIntegrationRules(*irules, quad_order);
1210 if (solver_type == 0)
1213 solver.SetPreconditioner(*S);
1216 solver.SetMinDetPtr(&min_detJ);
1217 solver.SetMaxIter(solver_iter);
1218 solver.SetRelTol(solver_rtol);
1219 solver.SetAbsTol(0.0);
1220 if (solver_art_type > 0)
1222 solver.SetAdaptiveLinRtol(solver_art_type, 0.5, 0.9);
1224 solver.SetPrintLevel(verbosity_level >= 1 ? 1 : -1);
1234 x, move_bnd, hradaptivity,
1235 mesh_poly_deg, h_metric_id,
1236 n_hr_iter, n_h_iter);
1238 if (adapt_lim_const > 0.)
1248 ostringstream mesh_name;
1249 mesh_name <<
"optimized.mesh";
1250 ofstream mesh_ofs(mesh_name.str().c_str());
1251 mesh_ofs.precision(8);
1256 const double fin_energy =
a.GetParGridFunctionEnergy(x) /
1258 double fin_metric_energy = fin_energy;
1259 if (lim_const > 0.0 || adapt_lim_const > 0.0 || surface_fit_const > 0.0)
1263 surf_fit_coeff.constant = 0.0;
1264 fin_metric_energy =
a.GetParGridFunctionEnergy(x) /
1267 adapt_lim_coeff.
constant = adapt_lim_const;
1268 surf_fit_coeff.constant = surface_fit_const;
1272 std::cout << std::scientific << std::setprecision(4);
1273 cout <<
"Initial strain energy: " << init_energy
1274 <<
" = metrics: " << init_metric_energy
1275 <<
" + extra terms: " << init_energy - init_metric_energy << endl;
1276 cout <<
" Final strain energy: " << fin_energy
1277 <<
" = metrics: " << fin_metric_energy
1278 <<
" + extra terms: " << fin_energy - fin_metric_energy << endl;
1279 cout <<
"The strain energy decreased by: " 1280 << (init_energy - fin_energy) * 100.0 / init_energy <<
" %." << endl;
1286 char title[] =
"Final metric values";
1290 if (adapt_lim_const > 0.0 && visualization)
1294 600, 600, 300, 300);
1298 if (surface_fit_const > 0.0)
1304 "Materials", 600, 900, 300, 300);
1306 "Surface dof", 900, 900, 300, 300);
1308 double err_avg, err_max;
1312 std::cout <<
"Avg fitting error: " << err_avg << std::endl
1313 <<
"Max fitting error: " << err_max << std::endl;
1324 sock.
open(
"localhost", 19916);
1325 sock <<
"solution\n";
1331 sock <<
"window_title 'Displacements'\n" 1332 <<
"window_geometry " 1333 << 1200 <<
" " << 0 <<
" " << 600 <<
" " << 600 <<
"\n" 1334 <<
"keys jRmclA" << endl;
1342 delete metric_coeff1;
1343 delete adapt_lim_eval;
1344 delete adapt_surface;
1346 delete hr_adapt_coeff;
1350 delete untangler_metric;
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_)
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 GetNPoints() const
Returns the number of the points in the integration rule.
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.
double discrete_size_2d(const Vector &x)
3D barrier Shape+Size (VS) metric, well-posed (invex).
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.
void PrintOptions(std::ostream &out) const
Print the options.
Geometry::Type GetElementBaseGeometry(int i) const
void SaveAsOne(const char *fname, int precision=16) const
3D barrier Shape (S) metric, well-posed (polyconvex & invex).
void SetAdaptivityEvaluator(AdaptivityEvaluator *ae)
void PrintUsage(std::ostream &out) const
Print the usage message.
int GetAttribute() const
Return element's attribute.
double surface_level_set(const Vector &x)
int Size() const
Returns the size of the vector.
Coefficient defined by a GridFunction. This coefficient is mesh dependent.
T Max() const
Find the maximal element in the array, using the comparison operator < for class T.
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)
void SetVolumeScale(double vol_scale)
Used by target type IDEAL_SHAPE_EQUAL_SIZE. The default volume scale is 1.
int GetNDofs() const
Returns number of degrees of freedom.
void EnableAdaptiveLimiting(const GridFunction &z0, Coefficient &coeff, AdaptivityEvaluator &ae)
Restriction of the node positions to certain regions.
3D non-barrier metric without a type.
void SetIntegrationRules(IntegrationRules &irules, int order)
Prescribe a set of integration rules; relevant for mixed meshes.
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...
bool Good() const
Return true if the command line options were parsed successfully.
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).
3D barrier Shape+Size (VS) metric, well-posed (invex).
int GetNBE() const
Returns number of boundary elements.
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).
IntegrationRules IntRules(0, Quadrature1D::GaussLegendre)
A global object with all integration rules (defined in intrules.cpp)
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.
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.
long long GetGlobalNE() const
Return the total (global) number of elements.
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).
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.
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)
3D barrier Shape+Size (VS) metric, well-posed (polyconvex).
Version of QuadraticFECollection with positive basis functions.
int main(int argc, char *argv[])
virtual void SetParDiscreteTargetAspectRatio(const ParGridFunction &tspec_)
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 DiffuseField(ParGridFunction &field, int smooth_steps)
void EnableAdaptiveSurfaceFitting()
2D barrier Shape+Orientation (OS) metric (polyconvex).
virtual DofTransformation * GetElementDofs(int i, Array< int > &dofs) const
Returns indexes of degrees of freedom in array dofs for i'th element.
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)
virtual const FiniteElement * GetFE(int i) const
double weight_fun(const Vector &x)
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 PrintAsOne(std::ostream &out=mfem::out) const
int GetDof() const
Returns the number of degrees of freedom in the finite element.
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).
int GetNE() const
Returns number of elements.
double discrete_size_3d(const Vector &x)
Class for integration point with weight.
void GetElementTransformation(int i, IsoparametricTransformation *ElTr)
DofTransformation * GetBdrElementVDofs(int i, Array< int > &vdofs) const
Returns indexes of degrees of freedom for i'th boundary element.
2D barrier Shape+Size+Orientation (VOS) metric (polyconvex).
3D Shape (S) metric, untangling version of 303.
IntegrationRules IntRulesCU(0, Quadrature1D::ClosedUniform)
int GetNBE() const
Returns number of boundary elements in the mesh.
double infinity()
Define a shortcut for std::numeric_limits<double>::infinity()
const DenseMatrix & GetGeomToPerfGeomJac(int GeomType) const
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.
int Size() const
Return the logical size of the array.
A general function coefficient.
void SetAttribute(int i, int attr)
Set the attribute of element i.
int DofToVDof(int dof, int vd, int ndofs=-1) const
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 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.
const Element * GetBdrElement(int i) const
virtual void SetParDiscreteTargetOrientation(const ParGridFunction &tspec_)
Class for parallel grid function.
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.
const FiniteElement * GetBE(int i) const
Returns pointer to the FiniteElement in the FiniteElementCollection associated with i'th boundary fac...
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)
3D barrier Shape (S) metric, well-posed (polyconvex & invex).
2D non-barrier metric without a type.
Arbitrary order "L2-conforming" discontinuous finite elements.
A TMOP integrator class based on any given TMOP_QualityMetric and TargetConstructor.
2D non-barrier Shape+Size+Orientation (VOS) metric (polyconvex).