MFEM v4.10.0
Finite element discretization library
Loading...
Searching...
No Matches
ex37.cpp
Go to the documentation of this file.
1// MFEM Example 37
2//
3// Compile with: make ex37
4//
5// Sample runs:
6// ex37 -alpha 10
7// ex37 -alpha 10 -pv
8// ex37 -lambda 0.1 -mu 0.1 -growth 1
9// ex37 -o 2 -alpha 10.0 -mi 50 -vf 0.4 -ntol 1e-5 -growth 1.5
10// ex37 -r 6 -o 1 -alpha 25.0 -epsilon 0.02 -mi 50 -ntol 1e-5
11//
12// Description: This example code demonstrates the use of MFEM to solve a
13// density-filtered [3] topology optimization problem. The
14// objective is to minimize the compliance
15//
16// minimize ∫_Ω f⋅u dx over u ∈ [H¹(Ω)]² and ρ ∈ L¹(Ω)
17//
18// subject to
19//
20// -Div(r(ρ̃)Cε(u)) = f in Ω + BCs
21// -ϵ²Δρ̃ + ρ̃ = ρ in Ω + Neumann BCs
22// 0 ≤ ρ ≤ 1 in Ω
23// ∫_Ω ρ dx = θ vol(Ω)
24//
25// Here, r(ρ̃) = ρ₀ + ρ̃³ (1-ρ₀) is the solid isotropic material
26// penalization (SIMP) law, C is the elasticity tensor for an
27// isotropic linearly elastic material, ϵ > 0 is the design
28// length scale, and 0 < θ < 1 is the volume fraction.
29//
30// The problem is discretized and gradients are computing using
31// finite elements [1]. The design is optimized using an entropic
32// mirror descent algorithm introduced by Keith and Surowiec [2]
33// that is tailored to the bound constraint 0 ≤ ρ ≤ 1.
34//
35// This example highlights the ability of MFEM to deliver high-
36// order solutions to inverse design problems and showcases how
37// to set up and solve PDE-constrained optimization problems
38// using the so-called reduced space approach.
39//
40// [1] Andreassen, E., Clausen, A., Schevenels, M., Lazarov, B. S., & Sigmund, O.
41// (2011). Efficient topology optimization in MATLAB using 88 lines of
42// code. Structural and Multidisciplinary Optimization, 43(1), 1-16.
43// [2] Keith, B. and Surowiec, T. (2023) Proximal Galerkin: A structure-
44// preserving finite element method for pointwise bound constraints.
45// arXiv:2307.12444 [math.NA]
46// [3] Lazarov, B. S., & Sigmund, O. (2011). Filters in topology optimization
47// based on Helmholtz‐type differential equations. International Journal
48// for Numerical Methods in Engineering, 86(6), 765-781.
49
50#include "mfem.hpp"
51#include <iostream>
52#include <fstream>
53#include "ex37.hpp"
54
55using namespace std;
56using namespace mfem;
57
58/*
59 * ---------------------------------------------------------------
60 * ALGORITHM PREAMBLE
61 * ---------------------------------------------------------------
62 *
63 * The Lagrangian for this problem is
64 *
65 * L(u,ρ,ρ̃,w,w̃) = (f,u) - (r(ρ̃) C ε(u),ε(w)) + (f,w)
66 * - (ϵ² ∇ρ̃,∇w̃) - (ρ̃,w̃) + (ρ,w̃)
67 *
68 * where
69 *
70 * r(ρ̃) = ρ₀ + ρ̃³ (1 - ρ₀) (SIMP rule)
71 *
72 * ε(u) = (∇u + ∇uᵀ)/2 (symmetric gradient)
73 *
74 * C e = λtr(e)I + 2μe (isotropic material)
75 *
76 * NOTE: The Lame parameters can be computed from Young's modulus E
77 * and Poisson's ratio ν as follows:
78 *
79 * λ = E ν/((1+ν)(1-2ν)), μ = E/(2(1+ν))
80 *
81 * ---------------------------------------------------------------
82 *
83 * Discretization choices:
84 *
85 * u ∈ V ⊂ (H¹)ᵈ (order p)
86 * ψ ∈ L² (order p - 1), ρ = sigmoid(ψ)
87 * ρ̃ ∈ H¹ (order p)
88 * w ∈ V (order p)
89 * w̃ ∈ H¹ (order p)
90 *
91 * ---------------------------------------------------------------
92 * ALGORITHM
93 * ---------------------------------------------------------------
94 *
95 * Update ρ with projected mirror descent via the following algorithm.
96 *
97 * 1. Initialize ψ = inv_sigmoid(vol_fraction) so that ∫ sigmoid(ψ) = θ vol(Ω)
98 *
99 * While not converged:
100 *
101 * 2. Solve filter equation ∂_w̃ L = 0; i.e.,
102 *
103 * (ϵ² ∇ ρ̃, ∇ v ) + (ρ̃,v) = (ρ,v) ∀ v ∈ H¹.
104 *
105 * 3. Solve primal problem ∂_w L = 0; i.e.,
106 *
107 * (λ r(ρ̃) ∇⋅u, ∇⋅v) + (2 μ r(ρ̃) ε(u), ε(v)) = (f,v) ∀ v ∈ V.
108 *
109 * NB. The dual problem ∂_u L = 0 is the negative of the primal problem due to symmetry.
110 *
111 * 4. Solve for filtered gradient ∂_ρ̃ L = 0; i.e.,
112 *
113 * (ϵ² ∇ w̃ , ∇ v ) + (w̃ ,v) = (-r'(ρ̃) ( λ |∇⋅u|² + 2 μ |ε(u)|²),v) ∀ v ∈ H¹.
114 *
115 * 5. Project the gradient onto the discrete latent space; i.e., solve
116 *
117 * (G,v) = (w̃,v) ∀ v ∈ L².
118 *
119 * 6. Bregman proximal gradient update; i.e.,
120 *
121 * ψ ← ψ - αG + c,
122 *
123 * where α > 0 is a step size parameter and c ∈ R is a constant ensuring
124 *
125 * ∫_Ω sigmoid(ψ - αG + c) dx = θ vol(Ω).
126 *
127 * end
128 */
129
130int main(int argc, char *argv[])
131{
132 // 1. Parse command-line options.
133 int ref_levels = 5;
134 int order = 2;
135 real_t alpha = 1.0;
136 real_t growth = 2;
137 real_t epsilon = 0.01;
138 real_t vol_fraction = 0.5;
139 int max_it = 1e3;
140 real_t itol = 1e-2;
141 real_t ntol = 1e-4;
142 real_t rho_min = 1e-6;
143 real_t lambda = 1.0;
144 real_t mu = 1.0;
145 bool glvis_visualization = true;
146 bool paraview_output = false;
147
148 OptionsParser args(argc, argv);
149 args.AddOption(&ref_levels, "-r", "--refine",
150 "Number of times to refine the mesh uniformly.");
151 args.AddOption(&order, "-o", "--order",
152 "Order (degree) of the finite elements.");
153 args.AddOption(&alpha, "-alpha", "--alpha-step-length",
154 "Step length for gradient descent.");
155 args.AddOption(&growth, "-growth", "--alpha-growth-rate",
156 "Growth rate of step length for gradient descent.");
157 args.AddOption(&epsilon, "-epsilon", "--epsilon-thickness",
158 "Length scale for ρ.");
159 args.AddOption(&max_it, "-mi", "--max-it",
160 "Maximum number of gradient descent iterations.");
161 args.AddOption(&ntol, "-ntol", "--rel-tol",
162 "Normalized exit tolerance.");
163 args.AddOption(&itol, "-itol", "--abs-tol",
164 "Increment exit tolerance.");
165 args.AddOption(&vol_fraction, "-vf", "--volume-fraction",
166 "Volume fraction for the material density.");
167 args.AddOption(&lambda, "-lambda", "--lambda",
168 "Lamé constant λ.");
169 args.AddOption(&mu, "-mu", "--mu",
170 "Lamé constant μ.");
171 args.AddOption(&rho_min, "-rmin", "--psi-min",
172 "Minimum of density coefficient.");
173 args.AddOption(&glvis_visualization, "-vis", "--visualization", "-no-vis",
174 "--no-visualization",
175 "Enable or disable GLVis visualization.");
176 args.AddOption(&paraview_output, "-pv", "--paraview", "-no-pv",
177 "--no-paraview",
178 "Enable or disable ParaView output.");
179 args.Parse();
180 if (!args.Good())
181 {
182 args.PrintUsage(mfem::out);
183 return 1;
184 }
186
188 true, 3.0, 1.0);
189 int dim = mesh.Dimension();
190
191 // 2. Set BCs.
192 for (int i = 0; i<mesh.GetNBE(); i++)
193 {
194 Element * be = mesh.GetBdrElement(i);
195 Array<int> vertices;
196 be->GetVertices(vertices);
197
198 real_t * coords1 = mesh.GetVertex(vertices[0]);
199 real_t * coords2 = mesh.GetVertex(vertices[1]);
200
201 Vector center(2);
202 center(0) = 0.5*(coords1[0] + coords2[0]);
203 center(1) = 0.5*(coords1[1] + coords2[1]);
204
205 if (abs(center(0) - 0.0) < 1e-10)
206 {
207 // the left edge
208 be->SetAttribute(1);
209 }
210 else
211 {
212 // all other boundaries
213 be->SetAttribute(2);
214 }
215 }
216 mesh.SetAttributes();
217
218 // 3. Refine the mesh.
219 for (int lev = 0; lev < ref_levels; lev++)
220 {
221 mesh.UniformRefinement();
222 }
223
224 // 4. Define the necessary finite element spaces on the mesh.
225 H1_FECollection state_fec(order, dim); // space for u
226 H1_FECollection filter_fec(order, dim); // space for ρ̃
227 L2_FECollection control_fec(order-1, dim,
228 BasisType::GaussLobatto); // space for ψ
229 FiniteElementSpace state_fes(&mesh, &state_fec,dim);
230 FiniteElementSpace filter_fes(&mesh, &filter_fec);
231 FiniteElementSpace control_fes(&mesh, &control_fec);
232
233 int state_size = state_fes.GetTrueVSize();
234 int control_size = control_fes.GetTrueVSize();
235 int filter_size = filter_fes.GetTrueVSize();
236 mfem::out << "Number of state unknowns: " << state_size << std::endl;
237 mfem::out << "Number of filter unknowns: " << filter_size << std::endl;
238 mfem::out << "Number of control unknowns: " << control_size << std::endl;
239
240 // 5. Set the initial guess for ρ.
241 GridFunction u(&state_fes);
242 GridFunction psi(&control_fes);
243 GridFunction psi_old(&control_fes);
244 GridFunction rho_filter(&filter_fes);
245 u = 0.0;
246 rho_filter = vol_fraction;
247 psi = inv_sigmoid(vol_fraction);
248 psi_old = inv_sigmoid(vol_fraction);
249
250 // ρ = sigmoid(ψ)
252 // Interpolation of ρ = sigmoid(ψ) in control fes (for ParaView output)
253 GridFunction rho_gf(&control_fes);
254 // ρ - ρ_old = sigmoid(ψ) - sigmoid(ψ_old)
255 DiffMappedGridFunctionCoefficient succ_diff_rho(&psi, &psi_old, sigmoid);
256
257 // 6. Set-up the physics solver.
258 int maxat = mesh.bdr_attributes.Max();
259 Array<int> ess_bdr(maxat);
260 ess_bdr = 0;
261 ess_bdr[0] = 1;
262 ConstantCoefficient one(1.0);
263 ConstantCoefficient lambda_cf(lambda);
264 ConstantCoefficient mu_cf(mu);
265 LinearElasticitySolver * ElasticitySolver = new LinearElasticitySolver();
266 ElasticitySolver->SetMesh(&mesh);
267 ElasticitySolver->SetOrder(state_fec.GetOrder());
268 ElasticitySolver->SetupFEM();
269 Vector center(2); center(0) = 2.9; center(1) = 0.5;
270 Vector force(2); force(0) = 0.0; force(1) = -1.0;
271 real_t r = 0.05;
272 VolumeForceCoefficient vforce_cf(r,center,force);
273 ElasticitySolver->SetRHSCoefficient(&vforce_cf);
274 ElasticitySolver->SetEssentialBoundary(ess_bdr);
275
276 // 7. Set-up the filter solver.
278 DiffusionSolver * FilterSolver = new DiffusionSolver();
279 FilterSolver->SetMesh(&mesh);
280 FilterSolver->SetOrder(filter_fec.GetOrder());
281 FilterSolver->SetDiffusionCoefficient(&eps2_cf);
282 FilterSolver->SetMassCoefficient(&one);
283 Array<int> ess_bdr_filter;
284 if (mesh.bdr_attributes.Size())
285 {
286 ess_bdr_filter.SetSize(mesh.bdr_attributes.Max());
287 ess_bdr_filter = 0;
288 }
289 FilterSolver->SetEssentialBoundary(ess_bdr_filter);
290 FilterSolver->SetupFEM();
291 FilterSolver->AssembleDiffusionBilinear();
292
293 BilinearForm mass(&control_fes);
294 mass.AddDomainIntegrator(new InverseIntegrator(new MassIntegrator(one)));
295 mass.Assemble();
296 SparseMatrix M;
297 Array<int> empty;
298 mass.FormSystemMatrix(empty,M);
299
300 // 8. Define the Lagrange multiplier and gradient functions.
301 GridFunction grad(&control_fes);
302 GridFunction w_filter(&filter_fes);
303
304 // 9. Define some tools for later.
305 ConstantCoefficient zero(0.0);
306 GridFunction onegf(&control_fes);
307 onegf = 1.0;
308 GridFunction zerogf(&control_fes);
309 zerogf = 0.0;
310 LinearForm vol_form(&control_fes);
311 vol_form.AddDomainIntegrator(new DomainLFIntegrator(one));
312 vol_form.Assemble();
313 real_t domain_volume = vol_form(onegf);
314 const real_t target_volume = domain_volume * vol_fraction;
315
316 // 10. Connect to GLVis. Prepare for VisIt output.
317 char vishost[] = "localhost";
318 int visport = 19916;
319 socketstream sout_r;
320 if (glvis_visualization)
321 {
322 sout_r.open(vishost, visport);
323 sout_r.precision(8);
324 }
325
326 mfem::ParaViewDataCollection paraview_dc("ex37", &mesh);
327 if (paraview_output)
328 {
329 rho_gf.ProjectCoefficient(rho);
330 paraview_dc.SetPrefixPath("ParaView");
331 paraview_dc.SetLevelsOfDetail(order);
332 paraview_dc.SetDataFormat(VTKFormat::BINARY);
333 paraview_dc.SetHighOrderOutput(true);
334 paraview_dc.SetCycle(0);
335 paraview_dc.SetTime(0.0);
336 paraview_dc.RegisterField("displacement",&u);
337 paraview_dc.RegisterField("density",&rho_gf);
338 paraview_dc.RegisterField("filtered_density",&rho_filter);
339 paraview_dc.Save();
340 }
341
342 // 11. Iterate:
343 for (int k = 1; k <= max_it; k++)
344 {
345 if (k > 1) { alpha = std::pow((real_t) k,growth); }
346
347 mfem::out << "\nStep = " << k << std::endl;
348
349 // Step 1 - Filter solve
350 // Solve (ϵ^2 ∇ ρ̃, ∇ v ) + (ρ̃,v) = (ρ,v)
351 FilterSolver->SetRHSCoefficient(&rho);
352 FilterSolver->Solve();
353 rho_filter = *FilterSolver->GetFEMSolution();
354
355 // Step 2 - State solve
356 // Solve (λ r(ρ̃) ∇⋅u, ∇⋅v) + (2 μ r(ρ̃) ε(u), ε(v)) = (f,v)
357 SIMPInterpolationCoefficient SIMP_cf(&rho_filter,rho_min, 1.0);
358 ProductCoefficient lambda_SIMP_cf(lambda_cf,SIMP_cf);
359 ProductCoefficient mu_SIMP_cf(mu_cf,SIMP_cf);
360 ElasticitySolver->SetLameCoefficients(&lambda_SIMP_cf,&mu_SIMP_cf);
361 ElasticitySolver->Solve();
362 u = *ElasticitySolver->GetFEMSolution();
363
364 // Step 3 - Adjoint filter solve
365 // Solve (ϵ² ∇ w̃, ∇ v) + (w̃ ,v) = (-r'(ρ̃) ( λ |∇⋅u|² + 2 μ |ε(u)|²),v)
366 StrainEnergyDensityCoefficient rhs_cf(&lambda_cf,&mu_cf,&u, &rho_filter,
367 rho_min);
368 FilterSolver->SetRHSCoefficient(&rhs_cf);
369 FilterSolver->Solve();
370 w_filter = *FilterSolver->GetFEMSolution();
371
372 // Step 4 - Compute gradient
373 // Solve G = M⁻¹w̃
374 GridFunctionCoefficient w_cf(&w_filter);
375 LinearForm w_rhs(&control_fes);
377 w_rhs.Assemble();
378 M.Mult(w_rhs,grad);
379
380 // Step 5 - Update design variable ψ ← proj(ψ - αG)
381 psi.Add(-alpha, grad);
382 GridFunction alpha_grad(grad);
383 alpha_grad *= alpha;
384 const real_t material_volume = proj(psi, alpha_grad, target_volume);
385
386 // Compute ||ρ - ρ_old|| in control fes.
387 real_t norm_increment = zerogf.ComputeL1Error(succ_diff_rho);
388 real_t norm_reduced_gradient = norm_increment/alpha;
389 psi_old = psi;
390
391 real_t compliance = (*(ElasticitySolver->GetLinearForm()))(u);
392 mfem::out << "norm of the reduced gradient = " << norm_reduced_gradient <<
393 std::endl;
394 mfem::out << "norm of the increment = " << norm_increment << endl;
395 mfem::out << "compliance = " << compliance << std::endl;
396 mfem::out << "volume fraction = " << material_volume / domain_volume <<
397 std::endl;
398
399 if (glvis_visualization)
400 {
401 GridFunction r_gf(&filter_fes);
402 r_gf.ProjectCoefficient(SIMP_cf);
403 sout_r << "solution\n" << mesh << r_gf
404 << "window_title 'Design density r(ρ̃)'" << flush;
405 }
406
407 if (paraview_output)
408 {
409 rho_gf.ProjectCoefficient(rho);
410 paraview_dc.SetCycle(k);
411 paraview_dc.SetTime((real_t)k);
412 paraview_dc.Save();
413 }
414
415 if (norm_reduced_gradient < ntol && norm_increment < itol)
416 {
417 break;
418 }
419 }
420
421 delete ElasticitySolver;
422 delete FilterSolver;
423
424 return 0;
425}
T Max() const
Find the maximal element in the array, using the comparison operator < for class T.
Definition array.cpp:69
void SetSize(int nsize)
Change the logical size of the array, keep existing entries.
Definition array.hpp:869
int Size() const
Return the logical size of the array.
Definition array.hpp:192
@ GaussLobatto
Closed type.
Definition fe_base.hpp:36
A "square matrix" operator for the associated FE space and BLFIntegrators The sum of all the BLFInteg...
A coefficient that is constant across space and time.
virtual void RegisterField(const std::string &field_name, GridFunction *gf)
Add a grid function to the collection.
void SetCycle(int c)
Set time cycle (for time-dependent simulations)
void SetTime(real_t t)
Set physical time (for time-dependent simulations)
void SetPrefixPath(const std::string &prefix)
Set the path where the DataCollection will be saved.
Returns f(u(x)) - f(v(x)) where u, v are scalar GridFunctions and f:R → R.
Definition ex37.hpp:66
Class for solving Poisson's equation:
Definition ex37.hpp:216
void AssembleDiffusionBilinear(bool update_ess_tdofs=true)
Definition ex37.hpp:570
void SetDiffusionCoefficient(Coefficient *diffcf_)
Definition ex37.hpp:261
void SetRHSCoefficient(Coefficient *rhscf_)
Definition ex37.hpp:263
void SetOrder(int order_)
Definition ex37.hpp:260
void SetMesh(Mesh *mesh_)
Definition ex37.hpp:251
void SetMassCoefficient(Coefficient *masscf_)
Definition ex37.hpp:262
GridFunction * GetFEMSolution()
Definition ex37.hpp:692
void SetEssentialBoundary(const Array< int > &ess_bdr_)
Definition ex37.hpp:264
Class for domain integration .
Definition lininteg.hpp:108
Abstract data type element.
Definition element.hpp:29
virtual void GetVertices(Array< int > &v) const =0
Get the indices defining the vertices.
void SetAttribute(const int attr)
Set element's attribute.
Definition element.hpp:61
int GetOrder() const
Return the order (polynomial degree) of the FE collection, corresponding to the order/degree returned...
Definition fe_coll.hpp:248
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
Definition fespace.hpp:210
virtual int GetTrueVSize() const
Return the number of vector true (conforming) dofs.
Definition fespace.hpp:827
Coefficient defined by a GridFunction. This coefficient is mesh dependent.
Class for grid function - Vector with associated FE space.
Definition gridfunc.hpp:53
virtual real_t ComputeL1Error(Coefficient &exsol, const IntegrationRule *irs[]=NULL) const
Returns ||u_ex - u_h||_L1 for H1 or L2 elements.
virtual void ProjectCoefficient(Coefficient &coeff, ProjectType type=ProjectType::DEFAULT)
Project coeff Coefficient to this GridFunction. The projection computation depends on the choice of t...
Arbitrary order H1-conforming (continuous) finite elements.
Definition fe_coll.hpp:291
Integrator that inverts the matrix assembled by another integrator.
Arbitrary order "L2-conforming" discontinuous finite elements.
Definition fe_coll.hpp:369
Class for solving linear elasticity:
Definition ex37.hpp:309
GridFunction * GetFEMSolution()
Definition ex37.hpp:876
void SetEssentialBoundary(const Array< int > &ess_bdr_)
Definition ex37.hpp:349
void SetRHSCoefficient(VectorCoefficient *rhs_cf_)
Definition ex37.hpp:348
void SetMesh(Mesh *mesh_)
Definition ex37.hpp:337
LinearForm * GetLinearForm()
Definition ex37.hpp:358
void SetOrder(int order_)
Definition ex37.hpp:346
void SetLameCoefficients(Coefficient *lambda_cf_, Coefficient *mu_cf_)
Definition ex37.hpp:347
Vector with associated FE space and LinearFormIntegrators.
void AddDomainIntegrator(LinearFormIntegrator *lfi)
Adds new Domain Integrator. Assumes ownership of lfi.
void Assemble()
Assembles the linear form i.e. sums over all domain/bdr integrators.
Returns f(u(x)) where u is a scalar GridFunction and f:R → R.
Definition ex37.hpp:41
Mesh data type.
Definition mesh.hpp:67
Array< int > bdr_attributes
A list of all unique boundary attributes used by the Mesh.
Definition mesh.hpp:309
int Dimension() const
Dimension of the reference space used within the elements.
Definition mesh.hpp:1314
const Element * GetBdrElement(int i) const
Return pointer to the i'th boundary element object.
Definition mesh.hpp:1462
virtual void SetAttributes(bool elem_attrs_changed=true, bool bdr_face_attrs_changed=true)
Determine the sets of unique attribute values in domain if elem_attrs_changed and boundary elements i...
Definition mesh.cpp:2016
int GetNBE() const
Returns number of boundary elements.
Definition mesh.hpp:1393
static Mesh MakeCartesian2D(int nx, int ny, Element::Type type, bool generate_edges=false, real_t sx=1.0, real_t sy=1.0, bool sfc_ordering=true)
Creates mesh for the rectangle [0,sx]x[0,sy], divided into nx*ny quadrilaterals if type = QUADRILATER...
Definition mesh.cpp:4776
void UniformRefinement(int i, const DSTable &, int *, int *, int *)
Definition mesh.cpp:12125
const real_t * GetVertex(int i) const
Return pointer to vertex i's coordinates.
Definition mesh.hpp:1429
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.
void SetLevelsOfDetail(int levels_of_detail_)
Set the refinement level.
void SetHighOrderOutput(bool high_order_output_)
Sets whether or not to output the data as high-order elements (false by default).
void SetDataFormat(VTKFormat fmt)
Set the data format for the ParaView output files.
Writer for ParaView visualization (PVD and VTU format)
Scalar coefficient defined as the product of two scalar coefficients or a scalar and a scalar coeffic...
Solid isotropic material penalization (SIMP) coefficient.
Definition ex37.hpp:98
Data type sparse matrix.
Definition sparsemat.hpp:51
void Mult(const Vector &x, Vector &y) const override
Matrix vector multiplication.
Strain energy density coefficient.
Definition ex37.hpp:122
Vector data type.
Definition vector.hpp:82
Vector & Add(const real_t a, const Vector &Va)
(*this) += a * Va
Definition vector.cpp:326
Volumetric force for linear elasticity.
Definition ex37.hpp:168
int open(const char hostname[], int port)
Open the socket stream on 'port' at 'hostname'.
const real_t alpha
Definition ex15.cpp:369
int dim
Definition ex24.cpp:53
real_t mu
Definition ex25.cpp:140
real_t epsilon
Definition ex25.cpp:141
int main()
real_t sigmoid(real_t x)
Sigmoid function.
Definition ex37.hpp:20
real_t proj(GridFunction &psi, GridFunction &alpha_grad, real_t target_volume, real_t tol=1e-12, int max_its=100)
Bregman projection of ρ = sigmoid(ψ) onto the subspace ∫_Ω ρ dx = θ vol(Ω) as follows:
Definition ex37.hpp:395
real_t u(const Vector &xvec)
Definition lor_mms.hpp:22
OutStream out(std::cout)
Global stream used by the library for standard output. Initially it uses the same std::streambuf as s...
Definition globals.hpp:66
real_t inv_sigmoid(real_t x)
Inverse sigmoid function.
Definition ex37.hpp:12
float real_t
Definition config.hpp:46
const char vishost[]
STL namespace.
MFEM_HOST_DEVICE real_t abs(const Complex &z)