MFEM v4.8.0
Finite element discretization library
Loading...
Searching...
No Matches
mesh-optimizer.cpp
Go to the documentation of this file.
1// Copyright (c) 2010-2025, Lawrence Livermore National Security, LLC. Produced
2// at the Lawrence Livermore National Laboratory. All Rights reserved. See files
3// LICENSE and NOTICE for details. LLNL-CODE-806117.
4//
5// This file is part of the MFEM library. For more information and source code
6// availability visit https://mfem.org.
7//
8// MFEM is free software; you can redistribute it and/or modify it under the
9// terms of the BSD-3 license. We welcome feedback and contributions, see file
10// CONTRIBUTING.md for details.
11//
12// --------------------------------------------------
13// Mesh Optimizer Miniapp: Optimize high-order meshes
14// --------------------------------------------------
15//
16// This miniapp performs mesh optimization using the Target-Matrix Optimization
17// Paradigm (TMOP) by P.Knupp et al., and a global variational minimization
18// approach. It minimizes the quantity sum_T int_T mu(J(x)), where T are the
19// target (ideal) elements, J is the Jacobian of the transformation from the
20// target to the physical element, and mu is the mesh quality metric. This
21// metric can measure shape, size or alignment of the region around each
22// quadrature point. The combination of targets & quality metrics is used to
23// optimize the physical node positions, i.e., they must be as close as possible
24// to the shape / size / alignment of their targets. This code also demonstrates
25// a possible use of nonlinear operators (the class TMOP_QualityMetric, defining
26// mu(J), and the class TMOP_Integrator, defining int mu(J)), as well as their
27// coupling to Newton methods for solving minimization problems. Note that the
28// utilized Newton methods are oriented towards avoiding invalid meshes with
29// negative Jacobian determinants. Each Newton step requires the inversion of a
30// Jacobian matrix, which is done through an inner linear solver.
31//
32// Compile with: make mesh-optimizer
33//
34// Sample runs:
35// Adapted analytic shape:
36// mesh-optimizer -m square01.mesh -o 2 -rs 2 -mid 2 -tid 4 -ni 200 -bnd -qt 1 -qo 8
37// Adapted analytic size+orientation:
38// mesh-optimizer -m square01.mesh -o 2 -rs 2 -mid 14 -tid 4 -ni 100 -bnd -qt 1 -qo 8
39// Adapted analytic shape+orientation (AD):
40// mesh-optimizer -m square01.mesh -o 3 -rs 2 -mid 85 -tid 4 -ni 100 -bnd -qt 1 -qo 8 -rtol 1e-6
41//
42// Adapted analytic shape and/or size with hr-adaptivity:
43// mesh-optimizer -m square01.mesh -o 2 -tid 9 -ni 50 -li 20 -hmid 55 -mid 7 -hr
44// mesh-optimizer -m square01.mesh -o 2 -tid 10 -ni 50 -li 20 -hmid 55 -mid 7 -hr
45// mesh-optimizer -m square01.mesh -o 2 -tid 11 -ni 50 -li 20 -hmid 58 -mid 7 -hr
46//
47// Adapted discrete size:
48// mesh-optimizer -m square01.mesh -o 2 -rs 2 -mid 94 -tid 5 -ni 50 -qo 4 -nor
49// (requires GSLIB):
50// * mesh-optimizer -m square01.mesh -o 2 -rs 2 -mid 80 -tid 5 -ni 50 -qo 4 -nor -mno 1 -ae 1
51// Adapted discrete size NC mesh;
52// mesh-optimizer -m amr-quad-q2.mesh -o 2 -rs 2 -mid 94 -tid 5 -ni 50 -qo 4 -nor
53// Adapted discrete size 3D with PA:
54// mesh-optimizer -m cube.mesh -o 2 -rs 2 -mid 321 -tid 5 -ls 3 -nor -pa -rtol 1e-8
55// Adapted discrete size 3D with PA on device (requires CUDA):
56// * mesh-optimizer -m cube.mesh -o 3 -rs 3 -mid 321 -tid 5 -ls 3 -nor -lc 0.1 -pa -d cuda
57// Adapted discrete size; explicit combo of metrics; mixed tri/quad mesh:
58// mesh-optimizer -m ../../data/square-mixed.mesh -o 2 -rs 2 -mid 2 -tid 5 -ni 200 -bnd -qo 6 -cmb 2 -nor
59// Adapted discrete size+aspect_ratio:
60// mesh-optimizer -m square01.mesh -o 2 -rs 2 -mid 7 -tid 6 -ni 100
61// Adapted discrete size+orientation (AD):
62// mesh-optimizer -m square01.mesh -o 2 -rs 2 -mid 36 -tid 8 -qo 4 -nor -rtol 1e-6
63// Adapted discrete aspect ratio (3D):
64// mesh-optimizer -m cube.mesh -o 2 -rs 2 -mid 302 -tid 7 -ni 20 -bnd -qt 1 -qo 8
65//
66// Periodic 2D + adapted discrete size:
67// mesh-optimizer -m ../../data/periodic-square.mesh -o 2 -rs 4 -mid 94 -tid 5 -qo 4 -nor
68// mesh-optimizer -m periodic-tri.mesh -o 2 -rs 4 -mid 94 -tid 5 -qo 4 -nor
69// Periodic 3D + adapted discrete size + PA:
70// mesh-optimizer -m periodic-cube.mesh -o 2 -rs 2 -mid 338 -tid 5 -nor -rtol 1e-6 -qo 4 -pa
71// Periodic 2D NC mesh + adapted discrete size + PA:
72// (the mesh is in the mfem/data GitHub repository)
73// * mesh-optimizer -m ../../../data/periodic/per-amr-square.mesh -o 2 -mid 94 -tid 5 -ni 50 -qo 4 -nor -pa
74//
75// Adaptive limiting:
76// mesh-optimizer -m stretched2D.mesh -o 2 -mid 2 -tid 1 -ni 50 -qo 5 -nor -vl 1 -alc 0.5
77// Adaptive limiting through the L-BFGS solver:
78// mesh-optimizer -m stretched2D.mesh -o 2 -mid 2 -tid 1 -ni 400 -qo 5 -nor -vl 1 -alc 0.5 -st 1 -rtol 1e-8
79//
80// Blade shape:
81// mesh-optimizer -m blade.mesh -o 4 -mid 2 -tid 1 -ni 30 -ls 3 -art 1 -bnd -qt 1 -qo 8
82// Blade shape (AD):
83// mesh-optimizer -m blade.mesh -o 4 -mid 11 -tid 1 -ni 30 -ls 3 -art 1 -bnd -qt 1 -qo 8
84// (requires CUDA):
85// * mesh-optimizer -m blade.mesh -o 4 -mid 2 -tid 1 -ni 30 -ls 3 -art 1 -bnd -qt 1 -qo 8 -d cuda
86// Blade limited shape:
87// mesh-optimizer -m blade.mesh -o 4 -mid 2 -tid 1 -bnd -qt 1 -qo 8 -lc 5000
88// ICF shape and equal size:
89// mesh-optimizer -o 3 -mid 80 -bec -tid 2 -ni 25 -ls 3 -art 2 -qo 5
90// ICF shape and initial size:
91// mesh-optimizer -o 3 -mid 9 -tid 3 -ni 30 -ls 3 -bnd -qt 1 -qo 8
92// ICF shape:
93// mesh-optimizer -o 3 -mid 1 -tid 1 -ni 100 -bnd -qt 1 -qo 8
94// ICF limited shape:
95// mesh-optimizer -o 3 -mid 1 -tid 1 -ni 100 -bnd -qt 1 -qo 8 -lc 10
96// ICF combo shape + size (rings, slow convergence):
97// mesh-optimizer -o 3 -mid 1 -tid 1 -ni 1000 -bnd -qt 1 -qo 8 -cmb 1
98// Mixed tet / cube / hex mesh with limiting:
99// mesh-optimizer -m ../../data/fichera-mixed-p2.mesh -o 4 -rs 1 -mid 301 -tid 1 -fix-bnd -qo 6 -nor -lc 0.25
100// 3D pinched sphere shape (the mesh is in the mfem/data GitHub repository):
101// * mesh-optimizer -m ../../../mfem_data/ball-pert.mesh -o 4 -mid 303 -tid 1 -ni 20 -li 500 -fix-bnd
102// 2D non-conforming shape and equal size:
103// mesh-optimizer -m ./amr-quad-q2.mesh -o 2 -rs 1 -mid 9 -tid 2 -ni 200 -bnd -qt 1 -qo 8
104//
105// 2D untangling:
106// mesh-optimizer -m jagged.mesh -o 2 -mid 22 -tid 1 -ni 50 -li 50 -qo 4 -fd -vl 1
107// 2D untangling with shifted barrier metric:
108// mesh-optimizer -m jagged.mesh -o 2 -mid 4 -tid 1 -ni 50 -qo 4 -fd -vl 1 -btype 1
109// 3D untangling (the mesh is in the mfem/data GitHub repository):
110// * mesh-optimizer -m ../../../mfem_data/cube-holes-inv.mesh -o 3 -mid 313 -tid 1 -rtol 1e-5 -li 50 -qo 4 -fd -vl 1
111
112#include "mfem.hpp"
114#include <fstream>
115#include <iostream>
116#include "mesh-optimizer.hpp"
117
118using namespace mfem;
119using namespace std;
120
121int main(int argc, char *argv[])
122{
123 // Set the method's default parameters.
124 const char *mesh_file = "icf.mesh";
125 int mesh_poly_deg = 1;
126 int rs_levels = 0;
127 real_t jitter = 0.0;
128 int metric_id = 1;
129 int target_id = 1;
130 real_t lim_const = 0.0;
131 real_t adapt_lim_const = 0.0;
132 int quad_type = 1;
133 int quad_order = 8;
134 int solver_type = 0;
135 int solver_iter = 20;
136#ifdef MFEM_USE_SINGLE
137 real_t solver_rtol = 1e-4;
138#else
139 real_t solver_rtol = 1e-10;
140#endif
141 int solver_art_type = 0;
142 int lin_solver = 2;
143 int max_lin_iter = 100;
144 bool move_bnd = true;
145 int combomet = 0;
146 bool bal_expl_combo = false;
147 bool hradaptivity = false;
148 int h_metric_id = -1;
149 bool normalization = false;
150 bool visualization = true;
151 int verbosity_level = 0;
152 bool fdscheme = false;
153 int adapt_eval = 0;
154 bool exactaction = false;
155 bool integ_over_targ = true;
156 const char *devopt = "cpu";
157 bool pa = false;
158 int n_hr_iter = 5;
159 int n_h_iter = 1;
160 int mesh_node_order = 0;
161 int barrier_type = 0;
162 int worst_case_type = 0;
163
164 // Parse command-line options.
165 OptionsParser args(argc, argv);
166 args.AddOption(&mesh_file, "-m", "--mesh",
167 "Mesh file to use.");
168 args.AddOption(&mesh_poly_deg, "-o", "--order",
169 "Polynomial degree of mesh finite element space.");
170 args.AddOption(&rs_levels, "-rs", "--refine-serial",
171 "Number of times to refine the mesh uniformly in serial.");
172 args.AddOption(&jitter, "-ji", "--jitter",
173 "Random perturbation scaling factor.");
174 args.AddOption(&metric_id, "-mid", "--metric-id",
175 "Mesh optimization metric:\n\t"
176 "T-metrics\n\t"
177 "1 : |T|^2 -- 2D no type\n\t"
178 "2 : 0.5|T|^2/tau-1 -- 2D shape (condition number)\n\t"
179 "7 : |T-T^-t|^2 -- 2D shape+size\n\t"
180 "9 : tau*|T-T^-t|^2 -- 2D shape+size\n\t"
181 "14 : |T-I|^2 -- 2D shape+size+orientation\n\t"
182 "22 : 0.5(|T|^2-2*tau)/(tau-tau_0) -- 2D untangling\n\t"
183 "50 : 0.5|T^tT|^2/tau^2-1 -- 2D shape\n\t"
184 "55 : (tau-1)^2 -- 2D size\n\t"
185 "56 : 0.5(sqrt(tau)-1/sqrt(tau))^2 -- 2D size\n\t"
186 "58 : |T^tT|^2/(tau^2)-2*|T|^2/tau+2 -- 2D shape\n\t"
187 "77 : 0.5(tau-1/tau)^2 -- 2D size\n\t"
188 "80 : (1-gamma)mu_2 + gamma mu_77 -- 2D shape+size\n\t"
189 "85 : |T-|T|/sqrt(2)I|^2 -- 2D shape+orientation\n\t"
190 "90 : balanced combo mu_50 & mu_77 -- 2D shape+size\n\t"
191 "94 : balanced combo mu_2 & mu_56 -- 2D shape+size\n\t"
192 "98 : (1/tau)|T-I|^2 -- 2D shape+size+orientation\n\t"
193 // "211: (tau-1)^2-tau+sqrt(tau^2+eps) -- 2D untangling\n\t"
194 // "252: 0.5(tau-1)^2/(tau-tau_0) -- 2D untangling\n\t"
195 "301: (|T||T^-1|)/3-1 -- 3D shape\n\t"
196 "302: (|T|^2|T^-1|^2)/9-1 -- 3D shape\n\t"
197 "303: (|T|^2)/3/tau^(2/3)-1 -- 3D shape\n\t"
198 "304: (|T|^3)/3^{3/2}/tau-1 -- 3D shape\n\t"
199 //"311: (tau-1)^2-tau+sqrt(tau^2+eps)-- 3D untangling\n\t"
200 "313: (|T|^2)(tau-tau0)^(-2/3)/3 -- 3D untangling\n\t"
201 "315: (tau-1)^2 -- 3D no type\n\t"
202 "316: 0.5(sqrt(tau)-1/sqrt(tau))^2 -- 3D no type\n\t"
203 "321: |T-T^-t|^2 -- 3D shape+size\n\t"
204 "322: |T-adjT^-t|^2 -- 3D shape+size\n\t"
205 "323: |J|^3-3sqrt(3)ln(det(J))-3sqrt(3) -- 3D shape+size\n\t"
206 "328: balanced combo mu_301 & mu_316 -- 3D shape+size\n\t"
207 "332: (1-gamma) mu_302 + gamma mu_315 -- 3D shape+size\n\t"
208 "333: (1-gamma) mu_302 + gamma mu_316 -- 3D shape+size\n\t"
209 "334: (1-gamma) mu_303 + gamma mu_316 -- 3D shape+size\n\t"
210 "328: balanced combo mu_302 & mu_318 -- 3D shape+size\n\t"
211 "347: (1-gamma) mu_304 + gamma mu_316 -- 3D shape+size\n\t"
212 // "352: 0.5(tau-1)^2/(tau-tau_0) -- 3D untangling\n\t"
213 "360: (|T|^3)/3^{3/2}-tau -- 3D shape\n\t"
214 "A-metrics\n\t"
215 "11 : (1/4*alpha)|A-(adjA)^T(W^TW)/omega|^2 -- 2D shape\n\t"
216 "36 : (1/alpha)|A-W|^2 -- 2D shape+size+orientation\n\t"
217 "49 : (1-gamma) mu_2 + gamma nu_50 -- 2D shape+skew\n\t"
218 "51 : see fem/tmop.hpp -- 2D size+skew\n\t"
219 "107: (1/2*alpha)|A-|A|/|W|W|^2 -- 2D shape+orientation\n\t"
220 "126: (1-gamma)nu_11 + gamma*nu_14a -- 2D shape+size\n\t"
221 );
222 args.AddOption(&target_id, "-tid", "--target-id",
223 "Target (ideal element) type:\n\t"
224 "1: Ideal shape, unit size\n\t"
225 "2: Ideal shape, equal size\n\t"
226 "3: Ideal shape, initial size\n\t"
227 "4: Given full analytic Jacobian (in physical space)\n\t"
228 "5: Ideal shape, given size (in physical space)");
229 args.AddOption(&lim_const, "-lc", "--limit-const", "Limiting constant.");
230 args.AddOption(&adapt_lim_const, "-alc", "--adapt-limit-const",
231 "Adaptive limiting coefficient constant.");
232 args.AddOption(&quad_type, "-qt", "--quad-type",
233 "Quadrature rule type:\n\t"
234 "1: Gauss-Lobatto\n\t"
235 "2: Gauss-Legendre\n\t"
236 "3: Closed uniform points");
237 args.AddOption(&quad_order, "-qo", "--quad_order",
238 "Order of the quadrature rule.");
239 args.AddOption(&solver_type, "-st", "--solver-type",
240 " Type of solver: (default) 0: Newton, 1: LBFGS");
241 args.AddOption(&solver_iter, "-ni", "--newton-iters",
242 "Maximum number of Newton iterations.");
243 args.AddOption(&solver_rtol, "-rtol", "--newton-rel-tolerance",
244 "Relative tolerance for the Newton solver.");
245 args.AddOption(&solver_art_type, "-art", "--adaptive-rel-tol",
246 "Type of adaptive relative linear solver tolerance:\n\t"
247 "0: None (default)\n\t"
248 "1: Eisenstat-Walker type 1\n\t"
249 "2: Eisenstat-Walker type 2");
250 args.AddOption(&lin_solver, "-ls", "--lin-solver",
251 "Linear solver:\n\t"
252 "0: l1-Jacobi\n\t"
253 "1: CG\n\t"
254 "2: MINRES\n\t"
255 "3: MINRES + Jacobi preconditioner\n\t"
256 "4: MINRES + l1-Jacobi preconditioner");
257 args.AddOption(&max_lin_iter, "-li", "--lin-iter",
258 "Maximum number of iterations in the linear solve.");
259 args.AddOption(&move_bnd, "-bnd", "--move-boundary", "-fix-bnd",
260 "--fix-boundary",
261 "Enable motion along horizontal and vertical boundaries.");
262 args.AddOption(&combomet, "-cmb", "--combo-type",
263 "Combination of metrics options:\n\t"
264 "0: Use single metric\n\t"
265 "1: Shape + space-dependent size given analytically\n\t"
266 "2: Shape + adapted size given discretely; shared target");
267 args.AddOption(&bal_expl_combo, "-bec", "--balance-explicit-combo",
268 "-no-bec", "--balance-explicit-combo",
269 "Automatic balancing of explicit combo metrics.");
270 args.AddOption(&hradaptivity, "-hr", "--hr-adaptivity", "-no-hr",
271 "--no-hr-adaptivity",
272 "Enable hr-adaptivity.");
273 args.AddOption(&h_metric_id, "-hmid", "--h-metric",
274 "Same options as metric_id. Used to determine refinement"
275 " type for each element if h-adaptivity is enabled.");
276 args.AddOption(&normalization, "-nor", "--normalization", "-no-nor",
277 "--no-normalization",
278 "Make all terms in the optimization functional unitless.");
279 args.AddOption(&fdscheme, "-fd", "--fd_approximation",
280 "-no-fd", "--no-fd-approx",
281 "Enable finite difference based derivative computations.");
282 args.AddOption(&exactaction, "-ex", "--exact_action",
283 "-no-ex", "--no-exact-action",
284 "Enable exact action of TMOP_Integrator.");
285 args.AddOption(&integ_over_targ, "-it", "--integrate-target",
286 "-ir", "--integrate-reference",
287 "Integrate over target (-it) or reference (-ir) element.");
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 "Verbosity level for the involved iterative solvers:\n\t"
293 "0: no output\n\t"
294 "1: Newton iterations\n\t"
295 "2: Newton iterations + linear solver summaries\n\t"
296 "3: newton iterations + linear solver iterations");
297 args.AddOption(&adapt_eval, "-ae", "--adaptivity-evaluator",
298 "0 - Advection based (DEFAULT), 1 - GSLIB.");
299 args.AddOption(&devopt, "-d", "--device",
300 "Device configuration string, see Device::Configure().");
301 args.AddOption(&pa, "-pa", "--partial-assembly", "-no-pa",
302 "--no-partial-assembly", "Enable Partial Assembly.");
303 args.AddOption(&n_hr_iter, "-nhr", "--n_hr_iter",
304 "Number of hr-adaptivity iterations.");
305 args.AddOption(&n_h_iter, "-nh", "--n_h_iter",
306 "Number of h-adaptivity iterations per r-adaptivity"
307 "iteration.");
308 args.AddOption(&mesh_node_order, "-mno", "--mesh_node_ordering",
309 "Ordering of mesh nodes."
310 "0 (default): byNodes, 1: byVDIM");
311 args.AddOption(&barrier_type, "-btype", "--barrier-type",
312 "0 - None,"
313 "1 - Shifted Barrier,"
314 "2 - Pseudo Barrier.");
315 args.AddOption(&worst_case_type, "-wctype", "--worst-case-type",
316 "0 - None,"
317 "1 - Beta,"
318 "2 - PMean.");
319 args.Parse();
320 if (!args.Good())
321 {
322 args.PrintUsage(cout);
323 return 1;
324 }
325 args.PrintOptions(cout);
326
327 if (h_metric_id < 0) { h_metric_id = metric_id; }
328
329 if (hradaptivity)
330 {
331 MFEM_VERIFY(strcmp(devopt,"cpu")==0, "HR-adaptivity is currently only"
332 " supported on cpus.");
333 }
334 Device device(devopt);
335 device.Print();
336
337 // Initialize and refine the starting mesh.
338 Mesh *mesh = new Mesh(mesh_file, 1, 1, false);
339 for (int lev = 0; lev < rs_levels; lev++) { mesh->UniformRefinement(); }
340 const int dim = mesh->Dimension();
341
342 if (hradaptivity) { mesh->EnsureNCMesh(); }
343
344 auto s = mesh->GetNodalFESpace();
345 const bool periodic = (s && s->IsDGSpace()) ? true : false;
346
347 // Define a FE space on the mesh, based on the input order. This space will
348 // also be used to represent the nodal positions of the mesh. We use a vector
349 // FE space which is a tensor product of a scalar FE space. The number of
350 // components in the vector finite element space matches the dimension.
352 if (mesh_poly_deg <= 0) { mesh_poly_deg = 2; }
353 if (periodic)
354 {
355 fec = new L2_FECollection(mesh_poly_deg, dim, BasisType::GaussLobatto);
356 }
357 else { fec = new H1_FECollection(mesh_poly_deg, dim); }
358 auto fespace = new FiniteElementSpace(mesh, fec, dim, mesh_node_order);
359
360 // Make the starting mesh curved. This means we define the mesh elements
361 // through a FE-based transformation of the reference element.
362 mesh->SetNodalFESpace(fespace);
363
364 // Get the mesh nodes (vertices and other DOFs in the FE space) as a FE grid
365 // function in pfespace. Note that changing x automatically changes the
366 // shapes of the mesh elements.
367 GridFunction x(fespace);
368 mesh->SetNodalGridFunction(&x);
369
370 // We create an H1 space for the mesh displacement. The displacement is
371 // always in a continuous space, even if the mesh is periodic.
372 // The nonlinear problem will be solved for the continuous displacement.
373 H1_FECollection fec_h1(mesh_poly_deg, dim);
374 FiniteElementSpace fes_h1(mesh, &fec_h1, dim, mesh_node_order);
375 GridFunction dx(&fes_h1); dx = 0.0;
376
377 // Define a vector representing the minimal local mesh size in the mesh
378 // nodes. We index the nodes by the scalar version of the DOFs in pfespace.
379 // In addition, compute average mesh size and total volume.
380 Vector h0(fes_h1.GetNDofs());
381 h0 = infinity();
382 real_t mesh_volume = 0.0;
383 Array<int> dofs;
384 for (int i = 0; i < mesh->GetNE(); i++)
385 {
386 // Get the local scalar element degrees of freedom in dofs.
387 fes_h1.GetElementDofs(i, dofs);
388 // Adjust the value of h0 in dofs based on the local mesh size.
389 const real_t hi = mesh->GetElementSize(i);
390 for (int j = 0; j < dofs.Size(); j++)
391 {
392 h0(dofs[j]) = min(h0(dofs[j]), hi);
393 }
394 mesh_volume += mesh->GetElementVolume(i);
395 }
396 const real_t small_phys_size = pow(mesh_volume, 1.0 / dim) / 100.0;
397
398 // Add a random perturbation to the nodes in the interior of the domain.
399 // We define a random grid function of pfespace and make sure that it is
400 // zero on the boundary and its values are locally of the order of h0.
401 // The latter is based on the DofToVDof() method which maps the scalar to
402 // the vector degrees of freedom in pfespace.
403 if (jitter > 0)
404 {
405 GridFunction rdm(&fes_h1);
406 rdm.Randomize();
407 rdm -= 0.25; // Shift to random values in [-0.5,0.5].
408 rdm *= jitter;
409 rdm.HostReadWrite();
410 // Scale the random values to be of order of the local mesh size.
411 for (int i = 0; i < fes_h1.GetNDofs(); i++)
412 {
413 for (int d = 0; d < dim; d++)
414 {
415 rdm(fes_h1.DofToVDof(i,d)) *= h0(i);
416 }
417 }
418 // Set the boundary values to zero. Note that periodic periodic boundaries
419 // will be free to move.
420 Array<int> vdofs;
421 for (int i = 0; i < fes_h1.GetNBE(); i++)
422 {
423 fespace->GetBdrElementVDofs(i, vdofs);
424 for (int j = 0; j < vdofs.Size(); j++) { rdm(vdofs[j]) = 0.0; }
425 }
426
427 if (periodic)
428 {
429 // For H1 the perturbation is controlled by the true nodes.
430 rdm.SetFromTrueVector();
431 GridFunction rdm_l2(fespace);
432 rdm_l2.ProjectGridFunction(rdm);
433 x -= rdm_l2;
434 }
435 else
436 {
437 x -= rdm;
438 // For H1 the perturbation is controlled by the true nodes.
440 }
441
442 if (visualization)
443 {
444 socketstream vis1;
445 common::VisualizeMesh(vis1, "localhost", 19916, *mesh, "Perturbed",
446 300, 600, 300, 300);
447 }
448 }
449
450 // Save the starting (prior to the optimization) mesh to a file. This
451 // output can be viewed later using GLVis: "glvis -m perturbed.mesh".
452 {
453 ofstream mesh_ofs("perturbed.mesh");
454 mesh->Print(mesh_ofs);
455 }
456
457 // Store the starting (prior to the optimization) positions.
458 GridFunction x0(x);
459
460 // Form the integrator that uses the chosen metric and target.
461 real_t min_detJ = -0.1;
462 TMOP_QualityMetric *metric = NULL;
463 switch (metric_id)
464 {
465 // T-metrics
466 case 1: metric = new TMOP_Metric_001; break;
467 case 2: metric = new TMOP_Metric_002; break;
468 case 4: metric = new TMOP_Metric_004; break;
469 case 7: metric = new TMOP_Metric_007; break;
470 case 9: metric = new TMOP_Metric_009; break;
471 case 14: metric = new TMOP_Metric_014; break;
472 case 22: metric = new TMOP_Metric_022(min_detJ); break;
473 case 50: metric = new TMOP_Metric_050; break;
474 case 55: metric = new TMOP_Metric_055; break;
475 case 56: metric = new TMOP_Metric_056; break;
476 case 58: metric = new TMOP_Metric_058; break;
477 case 66: metric = new TMOP_Metric_066(0.5); break;
478 case 77: metric = new TMOP_Metric_077; break;
479 case 80: metric = new TMOP_Metric_080(0.5); break;
480 case 85: metric = new TMOP_Metric_085; break;
481 case 90: metric = new TMOP_Metric_090; break;
482 case 94: metric = new TMOP_Metric_094; break;
483 case 98: metric = new TMOP_Metric_098; break;
484 // case 211: metric = new TMOP_Metric_211; break;
485 // case 252: metric = new TMOP_Metric_252(min_detJ); break;
486 case 301: metric = new TMOP_Metric_301; break;
487 case 302: metric = new TMOP_Metric_302; break;
488 case 303: metric = new TMOP_Metric_303; break;
489 case 304: metric = new TMOP_Metric_304; break;
490 // case 311: metric = new TMOP_Metric_311; break;
491 case 313: metric = new TMOP_Metric_313(min_detJ); break;
492 case 315: metric = new TMOP_Metric_315; break;
493 case 316: metric = new TMOP_Metric_316; break;
494 case 321: metric = new TMOP_Metric_321; break;
495 case 322: metric = new TMOP_Metric_322; break;
496 case 323: metric = new TMOP_Metric_323; break;
497 case 328: metric = new TMOP_Metric_328; break;
498 case 332: metric = new TMOP_Metric_332(0.5); break;
499 case 333: metric = new TMOP_Metric_333(0.5); break;
500 case 334: metric = new TMOP_Metric_334(0.5); break;
501 case 338: metric = new TMOP_Metric_338; break;
502 case 347: metric = new TMOP_Metric_347(0.5); break;
503 // case 352: metric = new TMOP_Metric_352(min_detJ); break;
504 case 360: metric = new TMOP_Metric_360; break;
505 // A-metrics
506 case 11: metric = new TMOP_AMetric_011; break;
507 case 36: metric = new TMOP_AMetric_036; break;
508 case 49: metric = new TMOP_AMetric_049(0.9); break;
509 case 51: metric = new TMOP_AMetric_051; break;
510 case 107: metric = new TMOP_AMetric_107; break;
511 case 126: metric = new TMOP_AMetric_126(0.9); break;
512 default:
513 cout << "Unknown metric_id: " << metric_id << endl;
514 return 3;
515 }
516 TMOP_QualityMetric *h_metric = NULL;
517 if (hradaptivity)
518 {
519 switch (h_metric_id)
520 {
521 case 1: h_metric = new TMOP_Metric_001; break;
522 case 2: h_metric = new TMOP_Metric_002; break;
523 case 7: h_metric = new TMOP_Metric_007; break;
524 case 9: h_metric = new TMOP_Metric_009; break;
525 case 55: h_metric = new TMOP_Metric_055; break;
526 case 56: h_metric = new TMOP_Metric_056; break;
527 case 58: h_metric = new TMOP_Metric_058; break;
528 case 77: h_metric = new TMOP_Metric_077; break;
529 case 315: h_metric = new TMOP_Metric_315; break;
530 case 316: h_metric = new TMOP_Metric_316; break;
531 case 321: h_metric = new TMOP_Metric_321; break;
532 default: cout << "Metric_id not supported for h-adaptivity: " << h_metric_id <<
533 endl;
534 return 3;
535 }
536 }
537
539 switch (barrier_type)
540 {
541 case 0: btype = TMOP_WorstCaseUntangleOptimizer_Metric::BarrierType::None;
542 break;
543 case 1: btype = TMOP_WorstCaseUntangleOptimizer_Metric::BarrierType::Shifted;
544 break;
545 case 2: btype = TMOP_WorstCaseUntangleOptimizer_Metric::BarrierType::Pseudo;
546 break;
547 default: cout << "barrier_type not supported: " << barrier_type << endl;
548 return 3;
549 }
550
552 switch (worst_case_type)
553 {
554 case 0: wctype = TMOP_WorstCaseUntangleOptimizer_Metric::WorstCaseType::None;
555 break;
556 case 1: wctype = TMOP_WorstCaseUntangleOptimizer_Metric::WorstCaseType::Beta;
557 break;
558 case 2: wctype = TMOP_WorstCaseUntangleOptimizer_Metric::WorstCaseType::PMean;
559 break;
560 default: cout << "worst_case_type not supported: " << worst_case_type << endl;
561 return 3;
562 }
563
564 TMOP_QualityMetric *untangler_metric = NULL;
565 if (barrier_type > 0 || worst_case_type > 0)
566 {
567 if (barrier_type > 0)
568 {
569 MFEM_VERIFY(metric_id == 4 || metric_id == 14 || metric_id == 66,
570 "Metric not supported for shifted/pseudo barriers.");
571 }
572 untangler_metric = new TMOP_WorstCaseUntangleOptimizer_Metric(*metric,
573 2,
574 1.5,
575 0.001, //0.01 for pseudo barrier
576 0.001,
577 btype,
578 wctype);
579 }
580
581 if (metric_id < 300 || h_metric_id < 300)
582 {
583 MFEM_VERIFY(dim == 2, "Incompatible metric for 3D meshes");
584 }
585 if (metric_id >= 300 || h_metric_id >= 300)
586 {
587 MFEM_VERIFY(dim == 3, "Incompatible metric for 2D meshes");
588 }
589
591 TargetConstructor *target_c = NULL;
592 HessianCoefficient *adapt_coeff = NULL;
593 HRHessianCoefficient *hr_adapt_coeff = NULL;
594 int ind_fec_order = (target_id >= 5 && target_id <= 8 && !fdscheme) ?
595 1 : mesh_poly_deg;
596 H1_FECollection ind_fec(ind_fec_order, dim);
597 FiniteElementSpace ind_fes(mesh, &ind_fec);
598 FiniteElementSpace ind_fesv(mesh, &ind_fec, dim);
599 GridFunction size(&ind_fes), aspr(&ind_fes), ori(&ind_fes);
600 GridFunction aspr3d(&ind_fesv);
601
602 const AssemblyLevel al =
603 pa ? AssemblyLevel::PARTIAL : AssemblyLevel::LEGACY;
604
605 switch (target_id)
606 {
607 case 1: target_t = TargetConstructor::IDEAL_SHAPE_UNIT_SIZE; break;
608 case 2: target_t = TargetConstructor::IDEAL_SHAPE_EQUAL_SIZE; break;
609 case 3: target_t = TargetConstructor::IDEAL_SHAPE_GIVEN_SIZE; break;
610 case 4: // Analytic
611 {
613 AnalyticAdaptTC *tc = new AnalyticAdaptTC(target_t);
614 adapt_coeff = new HessianCoefficient(dim, metric_id);
615 tc->SetAnalyticTargetSpec(NULL, NULL, adapt_coeff);
616 target_c = tc;
617 break;
618 }
619 case 5: // Discrete size 2D or 3D
620 {
622 DiscreteAdaptTC *tc = new DiscreteAdaptTC(target_t);
623 if (adapt_eval == 0)
624 {
626 }
627 else
628 {
629#ifdef MFEM_USE_GSLIB
631#else
632 MFEM_ABORT("MFEM is not built with GSLIB.");
633#endif
634 }
635 ConstructSizeGF(size);
637 tc->SetMinSizeForTargets(size.Min());
638 target_c = tc;
639 break;
640 }
641 case 6: // Discrete size + aspect ratio - 2D
642 {
643 GridFunction d_x(&ind_fes), d_y(&ind_fes), disc(&ind_fes);
644
646 DiscreteAdaptTC *tc = new DiscreteAdaptTC(target_t);
648 disc.ProjectCoefficient(mat_coeff);
649 if (adapt_eval == 0)
650 {
652 }
653 else
654 {
655#ifdef MFEM_USE_GSLIB
657#else
658 MFEM_ABORT("MFEM is not built with GSLIB.");
659#endif
660 }
661
662 // Diffuse the interface
664
665 // Get partials with respect to x and y of the grid function
666 disc.GetDerivative(1,0,d_x);
667 disc.GetDerivative(1,1,d_y);
668
669 // Compute the squared magnitude of the gradient
670 for (int i = 0; i < size.Size(); i++)
671 {
672 size(i) = std::pow(d_x(i),2)+std::pow(d_y(i),2);
673 }
674 const real_t max = size.Max();
675
676 for (int i = 0; i < d_x.Size(); i++)
677 {
678 d_x(i) = std::abs(d_x(i));
679 d_y(i) = std::abs(d_y(i));
680 }
681 const real_t eps = 0.01;
682 const real_t aspr_ratio = 20.0;
683 const real_t size_ratio = 40.0;
684
685 for (int i = 0; i < size.Size(); i++)
686 {
687 size(i) = (size(i)/max);
688 aspr(i) = (d_x(i)+eps)/(d_y(i)+eps);
689 aspr(i) = 0.1 + 0.9*(1-size(i))*(1-size(i));
690 if (aspr(i) > aspr_ratio) {aspr(i) = aspr_ratio;}
691 if (aspr(i) < 1.0/aspr_ratio) {aspr(i) = 1.0/aspr_ratio;}
692 }
693 Vector vals;
694 const int NE = mesh->GetNE();
695 real_t volume = 0.0, volume_ind = 0.0;
696
697 for (int i = 0; i < NE; i++)
698 {
700 const IntegrationRule &ir =
701 IntRules.Get(mesh->GetElementBaseGeometry(i), Tr->OrderJ());
702 size.GetValues(i, ir, vals);
703 for (int j = 0; j < ir.GetNPoints(); j++)
704 {
705 const IntegrationPoint &ip = ir.IntPoint(j);
706 Tr->SetIntPoint(&ip);
707 volume += ip.weight * Tr->Weight();
708 volume_ind += vals(j) * ip.weight * Tr->Weight();
709 }
710 }
711
712 const real_t avg_zone_size = volume / NE;
713
714 const real_t small_avg_ratio = (volume_ind + (volume - volume_ind) /
715 size_ratio) /
716 volume;
717
718 const real_t small_zone_size = small_avg_ratio * avg_zone_size;
719 const real_t big_zone_size = size_ratio * small_zone_size;
720
721 for (int i = 0; i < size.Size(); i++)
722 {
723 const real_t val = size(i);
724 const real_t a = (big_zone_size - small_zone_size) / small_zone_size;
725 size(i) = big_zone_size / (1.0+a*val);
726 }
727
728 DiffuseField(size, 2);
729 DiffuseField(aspr, 2);
730
732 tc->SetMinSizeForTargets(size.Min());
734 target_c = tc;
735 break;
736 }
737 case 7: // Discrete aspect ratio 3D
738 {
740 DiscreteAdaptTC *tc = new DiscreteAdaptTC(target_t);
741 if (adapt_eval == 0)
742 {
744 }
745 else
746 {
747#ifdef MFEM_USE_GSLIB
749#else
750 MFEM_ABORT("MFEM is not built with GSLIB.");
751#endif
752 }
754 aspr3d.ProjectCoefficient(fd_aspr3d);
755
757 target_c = tc;
758 break;
759 }
760 case 8: // shape/size + orientation 2D
761 {
763 DiscreteAdaptTC *tc = new DiscreteAdaptTC(target_t);
764 if (adapt_eval == 0)
765 {
767 }
768 else
769 {
770#ifdef MFEM_USE_GSLIB
772#else
773 MFEM_ABORT("MFEM is not built with GSLIB.");
774#endif
775 }
776
777 ConstantCoefficient size_coeff(0.1*0.1);
778 size.ProjectCoefficient(size_coeff);
780 tc->SetMinSizeForTargets(size.Min());
781
783 ori.ProjectCoefficient(ori_coeff);
785 target_c = tc;
786 break;
787 }
788 // Targets used for hr-adaptivity tests.
789 case 9: // size target in an annular region.
790 case 10: // size+aspect-ratio in an annular region.
791 case 11: // size+aspect-ratio target for a rotate sine wave
792 {
794 AnalyticAdaptTC *tc = new AnalyticAdaptTC(target_t);
795 hr_adapt_coeff = new HRHessianCoefficient(dim, target_id - 9);
796 tc->SetAnalyticTargetSpec(NULL, NULL, hr_adapt_coeff);
797 target_c = tc;
798 break;
799 }
800 default: cout << "Unknown target_id: " << target_id << endl; return 3;
801 }
802 if (target_c == NULL)
803 {
804 target_c = new TargetConstructor(target_t);
805 }
806 target_c->SetNodes(x0);
807
808 // Automatically balanced gamma in composite metrics.
809 auto metric_combo = dynamic_cast<TMOP_Combo_QualityMetric *>(metric);
810 if (metric_combo && bal_expl_combo)
811 {
812 Vector bal_weights;
813 metric_combo->ComputeBalancedWeights(x, *target_c, bal_weights);
814 metric_combo->SetWeights(bal_weights);
815 }
816
817 TMOP_QualityMetric *metric_to_use = barrier_type > 0 || worst_case_type > 0
818 ? untangler_metric
819 : metric;
820 auto tmop_integ = new TMOP_Integrator(metric_to_use, target_c, h_metric);
821 tmop_integ->IntegrateOverTarget(integ_over_targ);
822 if (barrier_type > 0 || worst_case_type > 0)
823 {
824 tmop_integ->ComputeUntangleMetricQuantiles(x, *fespace);
825 }
826
827 // Finite differences for computations of derivatives.
828 if (fdscheme)
829 {
830 MFEM_VERIFY(pa == false, "PA for finite differences is not implemented.");
831 tmop_integ->EnableFiniteDifferences(x);
832 }
833 tmop_integ->SetExactActionFlag(exactaction);
834
835 // Setup the quadrature rules for the TMOP integrator.
836 IntegrationRules *irules = NULL;
837 switch (quad_type)
838 {
839 case 1: irules = &IntRulesLo; break;
840 case 2: irules = &IntRules; break;
841 case 3: irules = &IntRulesCU; break;
842 default: cout << "Unknown quad_type: " << quad_type << endl; return 3;
843 }
844 tmop_integ->SetIntegrationRules(*irules, quad_order);
845 if (dim == 2)
846 {
847 cout << "Triangle quadrature points: "
848 << irules->Get(Geometry::TRIANGLE, quad_order).GetNPoints()
849 << "\nQuadrilateral quadrature points: "
850 << irules->Get(Geometry::SQUARE, quad_order).GetNPoints() << endl;
851 }
852 if (dim == 3)
853 {
854 cout << "Tetrahedron quadrature points: "
855 << irules->Get(Geometry::TETRAHEDRON, quad_order).GetNPoints()
856 << "\nHexahedron quadrature points: "
857 << irules->Get(Geometry::CUBE, quad_order).GetNPoints()
858 << "\nPrism quadrature points: "
859 << irules->Get(Geometry::PRISM, quad_order).GetNPoints() << endl;
860 }
861
862 // Limit the node movement.
863 // The limiting distances can be given by a general function of space.
864 FiniteElementSpace dist_fespace(mesh, &fec_h1); // scalar space
865 GridFunction dist(&dist_fespace);
866 dist = 1.0;
867 // The small_phys_size is relevant only with proper normalization.
868 if (normalization) { dist = small_phys_size; }
869 ConstantCoefficient lim_coeff(lim_const);
870 if (lim_const != 0.0) { tmop_integ->EnableLimiting(x0, dist, lim_coeff); }
871
872 // Adaptive limiting.
873 GridFunction adapt_lim_gf0(&ind_fes);
874 ConstantCoefficient adapt_lim_coeff(adapt_lim_const);
875 AdaptivityEvaluator *adapt_lim_eval = NULL;
876 if (adapt_lim_const > 0.0)
877 {
878 MFEM_VERIFY(pa == false, "PA is not implemented for adaptive limiting");
879
880 FunctionCoefficient adapt_lim_gf0_coeff(adapt_lim_fun);
881 adapt_lim_gf0.ProjectCoefficient(adapt_lim_gf0_coeff);
882
883 if (adapt_eval == 0) { adapt_lim_eval = new AdvectorCG(al); }
884 else if (adapt_eval == 1)
885 {
886#ifdef MFEM_USE_GSLIB
887 adapt_lim_eval = new InterpolatorFP;
888#else
889 MFEM_ABORT("MFEM is not built with GSLIB support!");
890#endif
891 }
892 else { MFEM_ABORT("Bad interpolation option."); }
893
894 tmop_integ->EnableAdaptiveLimiting(adapt_lim_gf0, adapt_lim_coeff,
895 *adapt_lim_eval);
896 if (visualization)
897 {
898 socketstream vis1;
899 common::VisualizeField(vis1, "localhost", 19916, adapt_lim_gf0, "Zeta 0",
900 300, 600, 300, 300);
901 }
902 }
903
904 // Has to be after the enabling of the limiting / alignment, as it computes
905 // normalization factors for these terms as well.
906 if (normalization) { tmop_integ->EnableNormalization(x0); }
907
908 //
909 // Setup the NonlinearForm which defines the integral of interest, its
910 // first and second derivatives.
911 //
912 // Note that the TMOP optimization always operates on H1 spaces. For periodic
913 // meshes, TMOP solves for a continuous periodic displacement.
914 NonlinearForm a(&fes_h1);
915 if (pa) { a.SetAssemblyLevel(AssemblyLevel::PARTIAL); }
916 // We can use a combination of metrics, i.e., optimize the sum of two
917 // integrals, where both are scaled by used-defined space-dependent weights.
918 // Note that there are no command-line options for the weights and the type
919 // of the second metric; one should update those in the code.
920 ConstantCoefficient *metric_coeff1 = NULL;
921 TMOP_QualityMetric *metric2 = NULL;
922 TargetConstructor *target_c2 = NULL;
923 FunctionCoefficient metric_coeff2(weight_fun);
924 if (combomet > 0)
925 {
926 // First metric.
927 metric_coeff1 = new ConstantCoefficient(1.0);
928 tmop_integ->SetCoefficient(*metric_coeff1);
929
930 // Second metric.
931 if (dim == 2) { metric2 = new TMOP_Metric_077; }
932 else { metric2 = new TMOP_Metric_315; }
933 TMOP_Integrator *tmop_integ2 = NULL;
934 if (combomet == 1)
935 {
936 target_c2 = new TargetConstructor(
938 target_c2->SetVolumeScale(0.01);
939 target_c2->SetNodes(x0);
940 tmop_integ2 = new TMOP_Integrator(metric2, target_c2, h_metric);
941 tmop_integ2->SetCoefficient(metric_coeff2);
942 }
943 else { tmop_integ2 = new TMOP_Integrator(metric2, target_c, h_metric); }
944 tmop_integ2->IntegrateOverTarget(integ_over_targ);
945 tmop_integ2->SetIntegrationRules(*irules, quad_order);
946 if (fdscheme) { tmop_integ2->EnableFiniteDifferences(x); }
947 tmop_integ2->SetExactActionFlag(exactaction);
948
950 combo->AddTMOPIntegrator(tmop_integ);
951 combo->AddTMOPIntegrator(tmop_integ2);
952 if (normalization) { combo->EnableNormalization(x0); }
953 if (lim_const != 0.0) { combo->EnableLimiting(x0, dist, lim_coeff); }
954
955 a.AddDomainIntegrator(combo);
956 }
957 else { a.AddDomainIntegrator(tmop_integ); }
958 // The PA setup must be performed after all integrators have been added.
959 if (pa) { a.Setup(); }
960
961 // Compute the minimum det(J) of the starting mesh.
962 min_detJ = infinity();
963 const int NE = mesh->GetNE();
964 for (int i = 0; i < NE; i++)
965 {
966 const IntegrationRule &ir =
967 irules->Get(fespace->GetFE(i)->GetGeomType(), quad_order);
969 for (int j = 0; j < ir.GetNPoints(); j++)
970 {
971 transf->SetIntPoint(&ir.IntPoint(j));
972 min_detJ = min(min_detJ, transf->Jacobian().Det());
973 }
974 }
975 cout << "Minimum det(J) of the original mesh is " << min_detJ << endl;
976
977 if (min_detJ < 0.0 && barrier_type == 0
978 && metric_id != 22 && metric_id != 211 && metric_id != 252
979 && metric_id != 311 && metric_id != 313 && metric_id != 352)
980 {
981 MFEM_ABORT("The input mesh is inverted! Try an untangling metric.");
982 }
983 if (min_detJ < 0.0)
984 {
985 MFEM_VERIFY(target_t == TargetConstructor::IDEAL_SHAPE_UNIT_SIZE,
986 "Untangling is supported only for ideal targets.");
987
988 const DenseMatrix &Wideal =
990 min_detJ /= Wideal.Det();
991
992 // Slightly below minJ0 to avoid div by 0.
993 min_detJ -= 0.01 * h0.Min();
994 }
995
996 // For HR tests, the energy is normalized by the number of elements.
997 if (periodic) { tmop_integ->SetInitialMeshPos(&x0); }
998 const real_t init_energy = a.GetGridFunctionEnergy(periodic ? dx : x) /
999 (hradaptivity ? mesh->GetNE() : 1);
1000 real_t init_metric_energy = init_energy;
1001 if (lim_const > 0.0 || adapt_lim_const > 0.0)
1002 {
1003 lim_coeff.constant = 0.0;
1004 adapt_lim_coeff.constant = 0.0;
1005 init_metric_energy = a.GetGridFunctionEnergy(periodic ? dx : x) /
1006 (hradaptivity ? mesh->GetNE() : 1);
1007 lim_coeff.constant = lim_const;
1008 adapt_lim_coeff.constant = adapt_lim_const;
1009 }
1010
1011 // Visualize the starting mesh and metric values.
1012 // Note that for combinations of metrics, this only shows the first metric.
1013 if (visualization)
1014 {
1015 char title[] = "Initial metric values";
1016 vis_tmop_metric_s(mesh_poly_deg, *metric, *target_c, *mesh, title, 0);
1017 }
1018
1019 // Fix all boundary nodes, or fix only a given component depending on the
1020 // boundary attributes of the given mesh.
1021 // Attributes 1/2/3 correspond to fixed x/y/z components of the node.
1022 // Attribute 4 corresponds to an entirely fixed node.
1023 // All other attributes represent unconstrained boundary nodes.
1024 if (move_bnd == false)
1025 {
1026 Array<int> ess_bdr(mesh->bdr_attributes.Max());
1027 ess_bdr = 1;
1028 a.SetEssentialBC(ess_bdr);
1029 }
1030 else
1031 {
1032 int n = 0;
1033 for (int i = 0; i < mesh->GetNBE(); i++)
1034 {
1035 const int nd = fes_h1.GetBE(i)->GetDof();
1036 const int attr = mesh->GetBdrElement(i)->GetAttribute();
1037 MFEM_VERIFY(!(dim == 2 && attr == 3),
1038 "Boundary attribute 3 must be used only for 3D meshes. "
1039 "Adjust the attributes (1/2/3/4 for fixed x/y/z/all "
1040 "components, rest for free nodes), or use -fix-bnd.");
1041 if (attr == 1 || attr == 2 || attr == 3) { n += nd; }
1042 if (attr == 4) { n += nd * dim; }
1043 }
1044 Array<int> vdofs, ess_vdofs(n);
1045 n = 0;
1046 for (int i = 0; i < mesh->GetNBE(); i++)
1047 {
1048 const int nd = fes_h1.GetBE(i)->GetDof();
1049 const int attr = mesh->GetBdrElement(i)->GetAttribute();
1050 fes_h1.GetBdrElementVDofs(i, vdofs);
1051 if (attr == 1) // Fix x components.
1052 {
1053 for (int j = 0; j < nd; j++)
1054 { ess_vdofs[n++] = vdofs[j]; }
1055 }
1056 else if (attr == 2) // Fix y components.
1057 {
1058 for (int j = 0; j < nd; j++)
1059 { ess_vdofs[n++] = vdofs[j+nd]; }
1060 }
1061 else if (attr == 3) // Fix z components.
1062 {
1063 for (int j = 0; j < nd; j++)
1064 { ess_vdofs[n++] = vdofs[j+2*nd]; }
1065 }
1066 else if (attr == 4) // Fix all components.
1067 {
1068 for (int j = 0; j < vdofs.Size(); j++)
1069 { ess_vdofs[n++] = vdofs[j]; }
1070 }
1071 }
1072 a.SetEssentialVDofs(ess_vdofs);
1073 }
1074
1075 // As we use the inexact Newton method to solve the resulting nonlinear
1076 // system, here we setup the linear solver for the system's Jacobian.
1077 Solver *S = NULL, *S_prec = NULL;
1078#ifdef MFEM_USE_SINGLE
1079 const real_t linsol_rtol = 1e-5;
1080#else
1081 const real_t linsol_rtol = 1e-12;
1082#endif
1083 // Level of output.
1084 IterativeSolver::PrintLevel linsolver_print;
1085 if (verbosity_level == 2)
1086 { linsolver_print.Errors().Warnings().FirstAndLast(); }
1087 if (verbosity_level > 2)
1088 { linsolver_print.Errors().Warnings().Iterations(); }
1089 if (lin_solver == 0)
1090 {
1091 S = new DSmoother(1, 1.0, max_lin_iter);
1092 }
1093 else if (lin_solver == 1)
1094 {
1095 CGSolver *cg = new CGSolver;
1096 cg->SetMaxIter(max_lin_iter);
1097 cg->SetRelTol(linsol_rtol);
1098 cg->SetAbsTol(0.0);
1099 cg->SetPrintLevel(linsolver_print);
1100 S = cg;
1101 }
1102 else
1103 {
1104 MINRESSolver *minres = new MINRESSolver;
1105 minres->SetMaxIter(max_lin_iter);
1106 minres->SetRelTol(linsol_rtol);
1107 minres->SetAbsTol(0.0);
1108 minres->SetPrintLevel(linsolver_print);
1109 if (lin_solver == 3 || lin_solver == 4)
1110 {
1111 if (pa)
1112 {
1113 MFEM_VERIFY(lin_solver != 4, "PA l1-Jacobi is not implemented");
1114 auto js = new OperatorJacobiSmoother;
1115 js->SetPositiveDiagonal(true);
1116 S_prec = js;
1117 }
1118 else
1119 {
1120 auto ds = new DSmoother((lin_solver == 3) ? 0 : 1, 1.0, 1);
1121 ds->SetPositiveDiagonal(true);
1122 S_prec = ds;
1123 }
1124 minres->SetPreconditioner(*S_prec);
1125 }
1126 S = minres;
1127 }
1128
1129 //
1130 // Perform the nonlinear optimization.
1131 //
1132 const IntegrationRule &ir =
1133 irules->Get(mesh->GetTypicalElementGeometry(), quad_order);
1134 TMOPNewtonSolver solver(ir, solver_type);
1135 // Provide all integration rules in case of a mixed mesh.
1136 solver.SetIntegrationRules(*irules, quad_order);
1137 // Specify linear solver when we use a Newton-based solver.
1138 if (solver_type == 0) { solver.SetPreconditioner(*S); }
1139 // For untangling, the solver will update the min det(T) values.
1140 solver.SetMinDetPtr(&min_detJ);
1141 solver.SetMaxIter(solver_iter);
1142 solver.SetRelTol(solver_rtol);
1143 solver.SetAbsTol(0.0);
1144 if (solver_art_type > 0)
1145 {
1146 solver.SetAdaptiveLinRtol(solver_art_type, 0.5, 0.9);
1147 }
1148 // Level of output.
1149 IterativeSolver::PrintLevel newton_print;
1150 if (verbosity_level > 0) { newton_print.Errors().Warnings().Iterations(); }
1151 else { newton_print.Errors().Warnings(); }
1152 solver.SetPrintLevel(newton_print);
1153 // hr-adaptivity solver.
1154 // If hr-adaptivity is disabled, r-adaptivity is done once using the
1155 // TMOPNewtonSolver.
1156 // Otherwise, "hr_iter" iterations of r-adaptivity are done followed by
1157 // "h_per_r_iter" iterations of h-adaptivity after each r-adaptivity.
1158 // The solver terminates if an h-adaptivity iteration does not modify
1159 // any element in the mesh.
1160 TMOPHRSolver hr_solver(*mesh, a, solver,
1161 x, move_bnd, hradaptivity,
1162 mesh_poly_deg, h_metric_id,
1163 n_hr_iter, n_h_iter);
1164 hr_solver.AddGridFunctionForUpdate(&x0);
1165 hr_solver.AddFESpaceForUpdate(&fes_h1);
1166 if (adapt_lim_const > 0.)
1167 {
1168 hr_solver.AddGridFunctionForUpdate(&adapt_lim_gf0);
1169 hr_solver.AddFESpaceForUpdate(&ind_fes);
1170 }
1171 hr_solver.Mult();
1172
1173 // Save the optimized mesh to a file. This output can be viewed later
1174 // using GLVis: "glvis -m optimized.mesh".
1175 {
1176 ofstream mesh_ofs("optimized.mesh");
1177 mesh_ofs.precision(14);
1178 mesh->Print(mesh_ofs);
1179 }
1180
1181 // Report the final energy of the functional.
1182 if (periodic)
1183 {
1184 GridFunction dx_L2(x); dx_L2 -= x0;
1185 // Assumes Gauss-Lobatto and continuity in x and x_0 across faces.
1186 dx.ProjectGridFunction(dx_L2);
1187 }
1188 if (periodic) { tmop_integ->SetInitialMeshPos(&x0); }
1189 const real_t fin_energy = a.GetGridFunctionEnergy(periodic ? dx : x) /
1190 (hradaptivity ? mesh->GetNE() : 1);
1191 real_t fin_metric_energy = fin_energy;
1192 if (lim_const > 0.0 || adapt_lim_const > 0.0)
1193 {
1194 lim_coeff.constant = 0.0;
1195 adapt_lim_coeff.constant = 0.0;
1196 fin_metric_energy = a.GetGridFunctionEnergy(periodic ? dx : x) /
1197 (hradaptivity ? mesh->GetNE() : 1);
1198 lim_coeff.constant = lim_const;
1199 adapt_lim_coeff.constant = adapt_lim_const;
1200 }
1201 std::cout << std::scientific << std::setprecision(4);
1202 cout << "Initial strain energy: " << init_energy
1203 << " = metrics: " << init_metric_energy
1204 << " + extra terms: " << init_energy - init_metric_energy << endl;
1205 cout << " Final strain energy: " << fin_energy
1206 << " = metrics: " << fin_metric_energy
1207 << " + extra terms: " << fin_energy - fin_metric_energy << endl;
1208 cout << "The strain energy decreased by: "
1209 << (init_energy - fin_energy) * 100.0 / init_energy << " %." << endl;
1210
1211 // Visualize the final mesh and metric values.
1212 if (visualization)
1213 {
1214 char title[] = "Final metric values";
1215 vis_tmop_metric_s(mesh_poly_deg, *metric, *target_c, *mesh, title, 600);
1216 }
1217
1218 if (adapt_lim_const > 0.0 && visualization)
1219 {
1220 socketstream vis0;
1221 common::VisualizeField(vis0, "localhost", 19916, adapt_lim_gf0, "Xi 0",
1222 600, 600, 300, 300);
1223 }
1224
1225 // Visualize the mesh displacement.
1226 if (visualization)
1227 {
1228 osockstream sock(19916, "localhost");
1229 sock << "solution\n";
1230 mesh->Print(sock);
1231 x0 -= x;
1232 x0.Save(sock);
1233 sock.send();
1234 sock << "window_title 'Displacements'\n"
1235 << "window_geometry "
1236 << 1200 << " " << 0 << " " << 600 << " " << 600 << "\n"
1237 << "keys jRmclA" << endl;
1238 }
1239
1240 delete S;
1241 delete S_prec;
1242 delete target_c2;
1243 delete metric2;
1244 delete metric_coeff1;
1245 delete adapt_lim_eval;
1246 delete target_c;
1247 delete hr_adapt_coeff;
1248 delete adapt_coeff;
1249 delete h_metric;
1250 delete metric;
1251 delete untangler_metric;
1252 delete fespace;
1253 delete fec;
1254 delete mesh;
1255
1256 return 0;
1257}
virtual void SetAnalyticTargetSpec(Coefficient *sspec, VectorCoefficient *vspec, TMOPMatrixCoefficient *mspec)
Definition tmop.cpp:2358
T Max() const
Find the maximal element in the array, using the comparison operator < for class T.
Definition array.cpp:68
int Size() const
Return the logical size of the array.
Definition array.hpp:147
@ GaussLobatto
Closed type.
Definition fe_base.hpp:36
Conjugate gradient method.
Definition solvers.hpp:538
A coefficient that is constant across space and time.
Data type for scaled Jacobi-type smoother of sparse matrix.
void SetPositiveDiagonal(bool pos_diag=true)
Replace diag entries with their abs values. Relevant only when type = 0.
Data type dense matrix using column-major storage.
Definition densemat.hpp:24
real_t Det() const
Definition densemat.cpp:516
The MFEM Device class abstracts hardware devices such as GPUs, as well as programming models such as ...
Definition device.hpp:123
void Print(std::ostream &out=mfem::out)
Print the configuration of the MFEM virtual device object.
Definition device.cpp:297
virtual void SetSerialDiscreteTargetAspectRatio(const GridFunction &tspec_)
Definition tmop.cpp:2606
void SetMinSizeForTargets(real_t min_size_)
Definition tmop.hpp:1851
virtual void SetSerialDiscreteTargetSize(const GridFunction &tspec_)
Definition tmop.cpp:2586
void SetAdaptivityEvaluator(AdaptivityEvaluator *ae)
Definition tmop.hpp:1809
virtual void SetSerialDiscreteTargetOrientation(const GridFunction &tspec_)
Definition tmop.cpp:2616
real_t Weight()
Return the weight of the Jacobian matrix of the transformation at the currently set IntegrationPoint....
Definition eltrans.hpp:144
virtual int OrderJ() const =0
Return the order of the elements of the Jacobian of the transformation.
const DenseMatrix & Jacobian()
Return the Jacobian matrix of the transformation at the currently set IntegrationPoint,...
Definition eltrans.hpp:132
void SetIntPoint(const IntegrationPoint *ip)
Set the integration point ip that weights and Jacobians will be evaluated at.
Definition eltrans.hpp:106
int GetAttribute() const
Return element's attribute.
Definition element.hpp:58
Collection of finite elements from the same family in multiple dimensions. This class is used to matc...
Definition fe_coll.hpp:27
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
Definition fespace.hpp:244
const FiniteElement * GetBE(int i) const
Returns pointer to the FiniteElement in the FiniteElementCollection associated with i'th boundary fac...
Definition fespace.cpp:3881
DofTransformation * GetElementDofs(int elem, Array< int > &dofs) const
Returns indices of degrees of freedom of element 'elem'. The returned indices are offsets into an ldo...
Definition fespace.cpp:3513
int GetNDofs() const
Returns number of degrees of freedom. This is the number of Local Degrees of Freedom.
Definition fespace.hpp:845
int GetNBE() const
Returns number of boundary elements in the mesh.
Definition fespace.hpp:900
DofTransformation * GetBdrElementVDofs(int i, Array< int > &vdofs) const
Returns indices of degrees of freedom for i'th boundary element. The returned indices are offsets int...
Definition fespace.cpp:348
int DofToVDof(int dof, int vd, int ndofs=-1) const
Compute a single vdof corresponding to the index dof and the vector index vd.
Definition fespace.cpp:294
int GetDof() const
Returns the number of degrees of freedom in the finite element.
Definition fe_base.hpp:334
A general function coefficient.
const DenseMatrix & GetGeomToPerfGeomJac(int GeomType) const
Definition geom.hpp:102
Class for grid function - Vector with associated FE space.
Definition gridfunc.hpp:31
virtual void Save(std::ostream &out) const
Save the GridFunction to an output stream.
void SetFromTrueVector()
Shortcut for calling SetFromTrueDofs() with GetTrueVector() as argument.
Definition gridfunc.hpp:153
virtual void ProjectCoefficient(Coefficient &coeff)
Project coeff Coefficient to this GridFunction. The projection computation depends on the choice of t...
void ProjectGridFunction(const GridFunction &src)
Project the src GridFunction to this GridFunction, both of which must be on the same mesh.
Arbitrary order H1-conforming (continuous) finite elements.
Definition fe_coll.hpp:275
Class for integration point with weight.
Definition intrules.hpp:35
Class for an integration rule - an Array of IntegrationPoint.
Definition intrules.hpp:100
int GetNPoints() const
Returns the number of the points in the integration rule.
Definition intrules.hpp:256
IntegrationPoint & IntPoint(int i)
Returns a reference to the i-th integration point.
Definition intrules.hpp:259
Container class for integration rules.
Definition intrules.hpp:422
const IntegrationRule & Get(int GeomType, int Order)
Returns an integration rule for given GeomType and Order.
void SetRelTol(real_t rtol)
Definition solvers.hpp:229
virtual void SetPrintLevel(int print_lvl)
Legacy method to set the level of verbosity of the solver output.
Definition solvers.cpp:72
void SetMaxIter(int max_it)
Definition solvers.hpp:231
void SetAbsTol(real_t atol)
Definition solvers.hpp:230
Arbitrary order "L2-conforming" discontinuous finite elements.
Definition fe_coll.hpp:346
MINRES method.
Definition solvers.hpp:653
void SetPreconditioner(Solver &pr) override
This should be called before SetOperator.
Definition solvers.hpp:665
Mesh data type.
Definition mesh.hpp:64
Array< int > bdr_attributes
A list of all unique boundary attributes used by the Mesh.
Definition mesh.hpp:290
const FiniteElementSpace * GetNodalFESpace() const
Definition mesh.cpp:6479
Geometry::Type GetTypicalElementGeometry() const
If the local mesh is not empty, return GetElementGeometry(0); otherwise, return a typical Geometry pr...
Definition mesh.cpp:1528
virtual void Print(std::ostream &os=mfem::out, const std::string &comments="") const
Definition mesh.hpp:2433
int GetNE() const
Returns number of elements.
Definition mesh.hpp:1282
int Dimension() const
Dimension of the reference space used within the elements.
Definition mesh.hpp:1216
const Element * GetBdrElement(int i) const
Return pointer to the i'th boundary element object.
Definition mesh.hpp:1354
real_t GetElementSize(int i, int type=0)
Get the size of the i-th element relative to the perfect reference element.
Definition mesh.cpp:107
void GetElementTransformation(int i, IsoparametricTransformation *ElTr) const
Builds the transformation defining the i-th element in ElTr. ElTr must be allocated in advance and wi...
Definition mesh.cpp:357
void SetNodalGridFunction(GridFunction *nodes, bool make_owner=false)
Definition mesh.cpp:6473
real_t GetElementVolume(int i)
Definition mesh.cpp:121
virtual void SetNodalFESpace(FiniteElementSpace *nfes)
Definition mesh.cpp:6426
int GetNBE() const
Returns number of boundary elements.
Definition mesh.hpp:1285
void EnsureNCMesh(bool simplices_nonconforming=false)
Definition mesh.cpp:10951
void UniformRefinement(int i, const DSTable &, int *, int *, int *)
Definition mesh.cpp:11295
Geometry::Type GetElementBaseGeometry(int i) const
Definition mesh.hpp:1455
void SetAdaptiveLinRtol(const int type=2, const real_t rtol0=0.5, const real_t rtol_max=0.9, const real_t alpha=0.5 *(1.0+sqrt(5.0)), const real_t gamma=1.0)
Enable adaptive linear solver relative tolerance algorithm.
Definition solvers.cpp:2022
Jacobi smoothing for a given bilinear form (no matrix necessary).
Definition solvers.hpp:333
void SetPositiveDiagonal(bool pos_diag=true)
Replace diagonal entries with their absolute values.
Definition solvers.hpp:369
void Parse()
Parse the command-line options. Note that this function expects all the options provided through the ...
void PrintUsage(std::ostream &out) const
Print the usage message.
void PrintOptions(std::ostream &out) const
Print the options.
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...
Definition optparser.hpp:82
bool Good() const
Return true if the command line options were parsed successfully.
Base class for solvers.
Definition operator.hpp:780
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.
Definition tmop.cpp:5641
void EnableNormalization(const GridFunction &x)
Normalization factor that considers all integrators in the combination.
Definition tmop.cpp:5740
void AddTMOPIntegrator(TMOP_Integrator *ti)
Adds a new TMOP_Integrator to the combination.
Definition tmop.hpp:2453
void AddGridFunctionForUpdate(GridFunction *gf)
Definition tmop_amr.hpp:252
void AddFESpaceForUpdate(FiniteElementSpace *fes)
Definition tmop_amr.hpp:253
void SetPreconditioner(Solver &pr) override
This should be called before SetOperator.
void SetIntegrationRules(IntegrationRules &irules, int order)
Prescribe a set of integration rules; relevant for mixed meshes.
void SetMinDetPtr(real_t *md_ptr)
2D barrier Shape+Size+Orientation (VOS) metric (polyconvex).
Definition tmop.hpp:1169
2D barrier Size+Skew (VQ) metric.
Definition tmop.hpp:1209
2D barrier Shape+Orientation (OS) metric (polyconvex).
Definition tmop.hpp:1231
2D barrier Shape+Size (VS) metric (polyconvex).
Definition tmop.hpp:1251
A TMOP integrator class based on any given TMOP_QualityMetric and TargetConstructor.
Definition tmop.hpp:1885
void SetExactActionFlag(bool flag_)
Flag to control if exact action of Integration is effected.
Definition tmop.hpp:2415
void SetCoefficient(Coefficient &w1)
Sets a scaling Coefficient for the quality metric term of the integrator.
Definition tmop.hpp:2211
void EnableFiniteDifferences(const GridFunction &x)
Enables FD-based approximation and computes dx.
Definition tmop.cpp:5434
void SetIntegrationRules(IntegrationRules &irules, int order)
Prescribe a set of integration rules; relevant for mixed meshes.
Definition tmop.hpp:2180
void IntegrateOverTarget(bool integ_over_target_)
Definition tmop.hpp:2196
2D non-barrier metric without a type.
Definition tmop.hpp:249
2D barrier Shape+Size (VS) metric (not polyconvex).
Definition tmop.hpp:374
2D barrier Shape+Size (VS) metric (not polyconvex).
Definition tmop.hpp:392
2D non-barrier Shape+Size+Orientation (VOS) metric (polyconvex).
Definition tmop.hpp:408
2D Shifted barrier form of shape metric (mu_2).
Definition tmop.hpp:427
2D barrier shape (S) metric (not polyconvex).
Definition tmop.hpp:504
2D barrier Shape+Orientation (OS) metric (polyconvex).
Definition tmop.hpp:590
2D compound barrier Shape+Size (VS) metric (balanced).
Definition tmop.hpp:605
2D compound barrier Shape+Size (VS) metric (balanced).
Definition tmop.hpp:626
2D barrier Shape+Size+Orientation (VOS) metric (polyconvex).
Definition tmop.hpp:647
3D barrier Shape (S) metric, well-posed (polyconvex & invex).
Definition tmop.hpp:701
3D barrier Shape (S) metric, well-posed (polyconvex & invex).
Definition tmop.hpp:720
3D barrier Shape (S) metric, well-posed (polyconvex & invex).
Definition tmop.hpp:741
3D barrier Shape (S) metric, well-posed (polyconvex & invex).
Definition tmop.hpp:762
3D Shape (S) metric, untangling version of 303.
Definition tmop.hpp:802
3D Size (V) metric.
Definition tmop.hpp:823
3D Size (V) metric.
Definition tmop.hpp:841
3D barrier Shape+Size (VS) metric, well-posed (invex).
Definition tmop.hpp:881
3D barrier Shape+Size (VS) metric, well-posed (invex).
Definition tmop.hpp:902
3D barrier Shape+Size (VS) metric, well-posed (invex).
Definition tmop.hpp:923
3D compound barrier Shape+Size (VS) metric (polyconvex, balanced).
Definition tmop.hpp:944
3D compound barrier Shape+Size (VS) metric (polyconvex).
Definition tmop.hpp:965
3D barrier Shape+Size (VS) metric, well-posed (polyconvex).
Definition tmop.hpp:986
3D barrier Shape+Size (VS) metric, well-posed (polyconvex).
Definition tmop.hpp:1005
3D compound barrier Shape+Size (VS) metric (polyconvex, balanced).
Definition tmop.hpp:1027
3D barrier Shape+Size (VS) metric, well-posed (polyconvex).
Definition tmop.hpp:1066
3D non-barrier Shape (S) metric.
Definition tmop.hpp:1107
Abstract class for local mesh quality metrics in the target-matrix optimization paradigm (TMOP) by P....
Definition tmop.hpp:24
Base class representing target-matrix construction algorithms for mesh optimization via the target-ma...
Definition tmop.hpp:1481
void SetVolumeScale(real_t vol_scale)
Used by target type IDEAL_SHAPE_EQUAL_SIZE. The default volume scale is 1.
Definition tmop.hpp:1566
void SetNodes(const GridFunction &n)
Set the nodes to be used in the target-matrix construction.
Definition tmop.hpp:1560
TargetType
Target-matrix construction algorithms supported by this class.
Definition tmop.hpp:1485
A general vector function coefficient.
Vector data type.
Definition vector.hpp:82
void Randomize(int seed=0)
Set random values in the vector.
Definition vector.cpp:915
virtual real_t * HostReadWrite()
Shortcut for mfem::ReadWrite(vec.GetMemory(), vec.Size(), false).
Definition vector.hpp:514
real_t Min() const
Returns the minimal element of the vector.
Definition vector.cpp:1123
int dim
Definition ex24.cpp:53
@ disc
Definition ex25.cpp:151
int main()
real_t a
Definition lissajous.cpp:41
real_t adapt_lim_fun(const Vector &x)
IntegrationRules IntRulesCU(0, Quadrature1D::ClosedUniform)
real_t weight_fun(const Vector &x)
real_t material_indicator_2d(const Vector &x)
IntegrationRules IntRulesLo(0, Quadrature1D::GaussLobatto)
void ConstructSizeGF(GridFunction &size)
real_t discrete_ori_2d(const Vector &x)
void discrete_aspr_3d(const Vector &x, Vector &v)
void VisualizeMesh(socketstream &sock, const char *vishost, int visport, Mesh &mesh, const char *title, int x, int y, int w, int h, const char *keys)
void DiffuseField(ParGridFunction &field, int smooth_steps)
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)
real_t infinity()
Define a shortcut for std::numeric_limits<double>::infinity()
Definition vector.hpp:47
Geometry Geometries
Definition fe.cpp:49
AssemblyLevel
Enumeration defining the assembly level for bilinear and nonlinear form classes derived from Operator...
void vis_tmop_metric_s(int order, TMOP_QualityMetric &qm, const TargetConstructor &tc, Mesh &mesh, char *title, int position)
float real_t
Definition config.hpp:43
IntegrationRules IntRules(0, Quadrature1D::GaussLegendre)
A global object with all integration rules (defined in intrules.cpp)
Definition intrules.hpp:492
Settings for the output behavior of the IterativeSolver.
Definition solvers.hpp:98