MFEM v4.10.0
Finite element discretization library
Loading...
Searching...
No Matches
nurbs_ex10.cpp
Go to the documentation of this file.
1// MFEM Example 10 -- modified for NURBS FE
2//
3// Compile with: make nurbs_ex10
4//
5// Sample runs:
6// nurbs_ex10 -m ../../data/beam-quad-nurbs.mesh -s 23 -r 2 -o 2 -dt 0.1
7//
8// Description: This examples solves a time dependent nonlinear elasticity
9// problem of the form dv/dt = H(x) + S v, dx/dt = v, where H is a
10// hyperelastic model and S is a viscosity operator of Laplacian
11// type. The geometry of the domain is assumed to be as follows:
12//
13// +---------------------+
14// boundary --->| |
15// attribute 1 | |
16// (fixed) +---------------------+
17//
18// The example demonstrates the use of nonlinear operators (the
19// class HyperelasticOperator defining H(x)), as well as their
20// implicit time integration using a Newton method for solving an
21// associated reduced backward-Euler type nonlinear equation
22// (class ReducedSystemOperator). Each Newton step requires the
23// inversion of a Jacobian matrix, which is done through a
24// (preconditioned) inner solver. Note that implementing the
25// method HyperelasticOperator::ImplicitSolve is the only
26// requirement for high-order implicit (SDIRK) time integration.
27//
28// We recommend viewing examples 2 and 9 before viewing this
29// example.
30
31#include "mfem.hpp"
32#include <memory>
33#include <iostream>
34#include <fstream>
35
36using namespace std;
37using namespace mfem;
38
39class ReducedSystemOperator;
40
41/** After spatial discretization, the hyperelastic model can be written as a
42 * system of ODEs:
43 * dv/dt = -M^{-1}*(H(x) + S*v)
44 * dx/dt = v,
45 * where x is the vector representing the deformation, v is the velocity field,
46 * M is the mass matrix, S is the viscosity matrix, and H(x) is the nonlinear
47 * hyperelastic operator.
48 *
49 * Class HyperelasticOperator represents the right-hand side of the above
50 * system of ODEs. */
51class HyperelasticOperator : public TimeDependentOperator
52{
53protected:
54 FiniteElementSpace &fespace;
55
56 BilinearForm M, S;
58 real_t viscosity;
59 HyperelasticModel *model;
60
61 CGSolver M_solver; // Krylov solver for inverting the mass matrix M
62 DSmoother M_prec; // Preconditioner for the mass matrix M
63
64 /** Nonlinear operator defining the reduced backward Euler equation for the
65 velocity. Used in the implementation of method ImplicitSolve. */
66 ReducedSystemOperator *reduced_oper;
67
68 /// Newton solver for the reduced backward Euler equation
69 NewtonSolver newton_solver;
70
71 /// Solver for the Jacobian solve in the Newton method
72 Solver *J_solver;
73 /// Preconditioner for the Jacobian solve in the Newton method
74 Solver *J_prec;
75
76 mutable Vector z; // auxiliary vector
77
78public:
79 HyperelasticOperator(FiniteElementSpace &f, Array<int> &ess_bdr,
80 real_t visc, real_t mu, real_t K);
81
82 /// Compute the right-hand side of the ODE system.
83 void Mult(const Vector &vx, Vector &dvx_dt) const override;
84 /** Solve the Backward-Euler equation: k = f(x + dt*k, t), for the unknown k.
85 This is the only requirement for high-order SDIRK implicit integration.*/
86 void ImplicitSolve(const real_t dt, const Vector &x, Vector &k) override;
87
88 real_t ElasticEnergy(const Vector &x) const;
89 real_t KineticEnergy(const Vector &v) const;
90 void GetElasticEnergyDensity(const GridFunction &x,
91 GridFunction &w,
92 ProjectType proj_type) const;
93
94 ~HyperelasticOperator() override;
95};
96
97/** Nonlinear operator of the form:
98 k --> (M + dt*S)*k + H(x + dt*v + dt^2*k) + S*v,
99 where M and S are given BilinearForms, H is a given NonlinearForm, v and x
100 are given vectors, and dt is a scalar. */
101class ReducedSystemOperator : public Operator
102{
103private:
104 BilinearForm *M, *S;
105 NonlinearForm *H;
106 mutable SparseMatrix *Jacobian;
107 real_t dt;
108 const Vector *v, *x;
109 mutable Vector w, z;
110
111public:
112 ReducedSystemOperator(BilinearForm *M_, BilinearForm *S_, NonlinearForm *H_);
113
114 /// Set current dt, v, x values - needed to compute action and Jacobian.
115 void SetParameters(real_t dt_, const Vector *v_, const Vector *x_);
116
117 /// Compute y = H(x + dt (v + dt k)) + M k + S (v + dt k).
118 void Mult(const Vector &k, Vector &y) const override;
119
120 /// Compute J = M + dt S + dt^2 grad_H(x + dt (v + dt k)).
121 Operator &GetGradient(const Vector &k) const override;
122
123 ~ReducedSystemOperator() override;
124};
125
126
127/** Function representing the elastic energy density for the given hyperelastic
128 model+deformation. Used in HyperelasticOperator::GetElasticEnergyDensity. */
129class ElasticEnergyCoefficient : public Coefficient
130{
131private:
132 HyperelasticModel &model;
133 const GridFunction &x;
134 DenseMatrix J;
135
136public:
137 ElasticEnergyCoefficient(HyperelasticModel &m, const GridFunction &x_)
138 : model(m), x(x_) { }
139 real_t Eval(ElementTransformation &T, const IntegrationPoint &ip) override;
140 ~ElasticEnergyCoefficient() override { }
141};
142
143void InitialDeformation(const Vector &x, Vector &y);
144
145void InitialVelocity(const Vector &x, Vector &v);
146
147void visualize(ostream &os, Mesh *mesh, GridFunction *deformed_nodes,
148 GridFunction *field, const char *field_name = NULL,
149 bool init_vis = false);
150
151
152int main(int argc, char *argv[])
153{
154 // 1. Parse command-line options.
155 const char *mesh_file = "../../data/beam-quad-nurbs.mesh";
156 int ref_levels = 1;
157 int order = 2;
158 int ode_solver_type = 23;
159 real_t t_final = 0.5;
160 real_t dt = 0.1;
161 real_t visc = 1e-2;
162 real_t mu = 0.25;
163 real_t K = 5.0;
164 int proj_type_int = 0;
165 bool visualization = true;
166 int vis_steps = 1;
167
168 OptionsParser args(argc, argv);
169 args.AddOption(&mesh_file, "-m", "--mesh",
170 "Mesh file to use.");
171 args.AddOption(&ref_levels, "-r", "--refine",
172 "Number of times to refine the mesh uniformly.");
173 args.AddOption(&order, "-o", "--order",
174 "Order (degree) of the finite elements.");
175 args.AddOption(&ode_solver_type, "-s", "--ode-solver",
176 ODESolver::Types.c_str());
177 args.AddOption(&t_final, "-tf", "--t-final",
178 "Final time; start time is 0.");
179 args.AddOption(&dt, "-dt", "--time-step",
180 "Time step.");
181 args.AddOption(&visc, "-v", "--viscosity",
182 "Viscosity coefficient.");
183 args.AddOption(&mu, "-mu", "--shear-modulus",
184 "Shear modulus in the Neo-Hookean hyperelastic model.");
185 args.AddOption(&K, "-K", "--bulk-modulus",
186 "Bulk modulus in the Neo-Hookean hyperelastic model.");
187 args.AddOption(&proj_type_int, "-proj", "--projection",
188 "Projection type:\n."
189 " 0 = DEFAULT: ELEMENTL2 for NURBS elements, ELEMENT else.\n"
190 " 1 = ELEMENT: As defined in the respective element.\n"
191 " 2 = GLOBALL2: Global L2 projection.\n"
192 " 3 = ELEMENTL2: Element L2 projection.");
193 args.AddOption(&visualization, "-vis", "--visualization", "-no-vis",
194 "--no-visualization",
195 "Enable or disable GLVis visualization.");
196 args.AddOption(&vis_steps, "-vs", "--visualization-steps",
197 "Visualize every n-th timestep.");
198 args.Parse();
199 if (!args.Good())
200 {
201 args.PrintUsage(cout);
202 return 1;
203 }
204 args.PrintOptions(cout);
205
206 ProjectType proj_type = static_cast<ProjectType>(proj_type_int);
207
208 // 2. Read the mesh from the given mesh file. We can handle triangular,
209 // quadrilateral, tetrahedral and hexahedral meshes with the same code.
210 Mesh *mesh = new Mesh(mesh_file, 1, 1);
211 int dim = mesh->Dimension();
212
213 // 3. Define the ODE solver used for time integration. Several implicit
214 // singly diagonal implicit Runge-Kutta (SDIRK) methods, as well as
215 // explicit Runge-Kutta methods are available.
216 unique_ptr<ODESolver> ode_solver = ODESolver::Select(ode_solver_type);
217
218 // 4. Refine the mesh to increase the resolution. In this example we do
219 // 'ref_levels' of uniform refinement, where 'ref_levels' is a
220 // command-line parameter.
221 for (int lev = 0; lev < ref_levels; lev++)
222 {
223 mesh->UniformRefinement();
224 }
225
226 // 5. Define the vector finite element spaces representing the mesh
227 // deformation x, the velocity v, and the initial configuration, x_ref.
228 // Define also the elastic energy density, w, which is in a discontinuous
229 // higher-order space. Since x and v are integrated in time as a system,
230 // we group them together in block vector vx, with offsets given by the
231 // fe_offset array.
232 FiniteElementCollection *fec = nullptr;
233 NURBSExtension *NURBSext = nullptr;
234 if (mesh->NURBSext)
235 {
236 NURBSext = new NURBSExtension(mesh->NURBSext, order);
237 fec = new NURBSFECollection(order);
238 cout << "Using NURBS FEs: " << fec->Name() << endl;
239 }
240 else
241 {
242 fec = new H1_FECollection(order, dim);
243 cout << "Using H1 FEs: " << fec->Name() << endl;
244 }
245
246 FiniteElementSpace fespace(mesh, NURBSext, fec, dim);
247
248 int fe_size = fespace.GetTrueVSize();
249 cout << "Number of velocity/deformation unknowns: " << fe_size << endl;
250 Array<int> fe_offset(3);
251 fe_offset[0] = 0;
252 fe_offset[1] = fe_size;
253 fe_offset[2] = 2*fe_size;
254
255 BlockVector vx(fe_offset);
256 GridFunction v, x;
257 v.MakeTRef(&fespace, vx.GetBlock(0), 0);
258 x.MakeTRef(&fespace, vx.GetBlock(1), 0);
259
260 GridFunction x_ref(&fespace);
261 mesh->GetNodes(x_ref);
262
263 L2_FECollection w_fec(order + 1, dim);
264 FiniteElementSpace w_fespace(mesh, &w_fec);
265 GridFunction w(&w_fespace);
266
267 // 6. Set the initial conditions for v and x, and the boundary conditions on
268 // a beam-like mesh (see description above).
270 v.ProjectCoefficient(velo, proj_type);
271
272 v.SetTrueVector();
274 x.ProjectCoefficient(deform, proj_type);
275
276 x.SetTrueVector();
277
278 Array<int> ess_bdr(fespace.GetMesh()->bdr_attributes.Max());
279 ess_bdr = 0;
280 ess_bdr[0] = 1; // boundary attribute 1 (index 0) is fixed
281
282 // 7. Initialize the hyperelastic operator, the GLVis visualization and print
283 // the initial energies.
284 HyperelasticOperator oper(fespace, ess_bdr, visc, mu, K);
285
286 socketstream vis_v, vis_w;
287 if (visualization)
288 {
289 char vishost[] = "localhost";
290 int visport = 19916;
291 vis_v.open(vishost, visport);
292 vis_v.precision(8);
294 visualize(vis_v, mesh, &x, &v, "Velocity", true);
295 vis_w.open(vishost, visport);
296 if (vis_w)
297 {
298 oper.GetElasticEnergyDensity(x, w, proj_type);
299 vis_w.precision(8);
300 visualize(vis_w, mesh, &x, &w, "Elastic energy density", true);
301 }
302 cout << "GLVis visualization paused."
303 << " Press space (in the GLVis window) to resume it.\n";
304 }
305
306 real_t ee0 = oper.ElasticEnergy(x.GetTrueVector());
307 real_t ke0 = oper.KineticEnergy(v.GetTrueVector());
308 cout << "initial elastic energy (EE) = " << ee0 << endl;
309 cout << "initial kinetic energy (KE) = " << ke0 << endl;
310 cout << "initial total energy (TE) = " << (ee0 + ke0) << endl;
311
312 real_t t = 0.0;
313 oper.SetTime(t);
314 ode_solver->Init(oper);
315
316 // 8. Perform time-integration (looping over the time iterations, ti, with a
317 // time-step dt).
318 bool last_step = false;
319 for (int ti = 1; !last_step; ti++)
320 {
321 real_t dt_real = min(dt, t_final - t);
322
323 ode_solver->Step(vx, t, dt_real);
324
325 last_step = (t >= t_final - 1e-8*dt);
326
327 if (last_step || (ti % vis_steps) == 0)
328 {
329 real_t ee = oper.ElasticEnergy(x.GetTrueVector());
330 real_t ke = oper.KineticEnergy(v.GetTrueVector());
331
332 cout << "step " << ti << ", t = " << t << ", EE = " << ee << ", KE = "
333 << ke << ", ΔTE = " << (ee+ke)-(ee0+ke0) << endl;
334
335 if (visualization)
336 {
338 visualize(vis_v, mesh, &x, &v);
339 if (vis_w)
340 {
341 oper.GetElasticEnergyDensity(x, w, proj_type);
342 visualize(vis_w, mesh, &x, &w);
343 }
344 }
345 }
346 }
347
348 // 9. Save the displaced mesh, the velocity and elastic energy.
349 {
351 GridFunction *nodes = &x;
352 int owns_nodes = 0;
353 mesh->SwapNodes(nodes, owns_nodes);
354 ofstream mesh_ofs("deformed.mesh");
355 mesh_ofs.precision(8);
356 mesh->Print(mesh_ofs);
357 mesh->SwapNodes(nodes, owns_nodes);
358 ofstream velo_ofs("velocity.sol");
359 velo_ofs.precision(8);
360 v.Save(velo_ofs);
361 ofstream ee_ofs("elastic_energy.sol");
362 ee_ofs.precision(8);
363 oper.GetElasticEnergyDensity(x, w, proj_type);
364 w.Save(ee_ofs);
365 }
366
367 // 10. Free the used memory.
368 delete fec;
369 delete mesh;
370
371 return 0;
372}
373
374
375void visualize(ostream &os, Mesh *mesh, GridFunction *deformed_nodes,
376 GridFunction *field, const char *field_name, bool init_vis)
377{
378 if (!os)
379 {
380 return;
381 }
382
383 GridFunction *nodes = deformed_nodes;
384 int owns_nodes = 0;
385
386 mesh->SwapNodes(nodes, owns_nodes);
387
388 os << "solution\n" << *mesh << *field;
389
390 mesh->SwapNodes(nodes, owns_nodes);
391
392 if (init_vis)
393 {
394 os << "window_size 800 800\n";
395 os << "window_title '" << field_name << "'\n";
396 if (mesh->SpaceDimension() == 2)
397 {
398 os << "view 0 0\n"; // view from top
399 os << "keys jl\n"; // turn off perspective and light
400 }
401 os << "keys cm\n"; // show colorbar and mesh
402 // update value-range; keep mesh-extents fixed
403 os << "autoscale value\n";
404 os << "pause\n";
405 }
406 os << flush;
407}
408
409
410ReducedSystemOperator::ReducedSystemOperator(
412 : Operator(M_->Height()), M(M_), S(S_), H(H_), Jacobian(NULL),
413 dt(0.0), v(NULL), x(NULL), w(height), z(height)
414{ }
415
416void ReducedSystemOperator::SetParameters(real_t dt_, const Vector *v_,
417 const Vector *x_)
418{
419 dt = dt_; v = v_; x = x_;
420}
421
422void ReducedSystemOperator::Mult(const Vector &k, Vector &y) const
423{
424 // compute: y = H(x + dt*(v + dt*k)) + M*k + S*(v + dt*k)
425 add(*v, dt, k, w);
426 add(*x, dt, w, z);
427 H->Mult(z, y);
428 M->AddMult(k, y);
429 S->AddMult(w, y);
430}
431
432Operator &ReducedSystemOperator::GetGradient(const Vector &k) const
433{
434 delete Jacobian;
435 Jacobian = Add(1.0, M->SpMat(), dt, S->SpMat());
436 add(*v, dt, k, w);
437 add(*x, dt, w, z);
438 SparseMatrix *grad_H = dynamic_cast<SparseMatrix *>(&H->GetGradient(z));
439 Jacobian->Add(dt*dt, *grad_H);
440 return *Jacobian;
441}
442
443ReducedSystemOperator::~ReducedSystemOperator()
444{
445 delete Jacobian;
446}
447
448
449HyperelasticOperator::HyperelasticOperator(FiniteElementSpace &f,
450 Array<int> &ess_bdr, real_t visc,
451 real_t mu, real_t K)
452 : TimeDependentOperator(2*f.GetTrueVSize(), (real_t) 0.0), fespace(f),
453 M(&fespace), S(&fespace), H(&fespace),
454 viscosity(visc), z(height/2)
455{
456#if defined(MFEM_USE_DOUBLE)
457 const real_t rel_tol = 1e-8;
458 const real_t newton_abs_tol = 0.0;
459#elif defined(MFEM_USE_SINGLE)
460 const real_t rel_tol = 1e-3;
461 const real_t newton_abs_tol = 1e-4;
462#else
463#error "Only single and double precision are supported!"
464 const real_t rel_tol = real_t(1);
465 const real_t newton_abs_tol = real_t(0);
466#endif
467 const int skip_zero_entries = 0;
468
469 const real_t ref_density = 1.0; // density in the reference configuration
470 ConstantCoefficient rho0(ref_density);
471 M.AddDomainIntegrator(new VectorMassIntegrator(rho0));
472 M.Assemble(skip_zero_entries);
474 fespace.GetEssentialTrueDofs(ess_bdr, ess_tdof_list);
475 SparseMatrix tmp;
476 M.FormSystemMatrix(ess_tdof_list, tmp);
477
478 M_solver.iterative_mode = false;
479 M_solver.SetRelTol(rel_tol);
480 M_solver.SetAbsTol(0.0);
481 M_solver.SetMaxIter(30);
482 M_solver.SetPrintLevel(0);
483 M_solver.SetPreconditioner(M_prec);
484 M_solver.SetOperator(M.SpMat());
485
486 model = new NeoHookeanModel(mu, K);
487 H.AddDomainIntegrator(new HyperelasticNLFIntegrator(model));
488 H.SetEssentialTrueDofs(ess_tdof_list);
489
490 ConstantCoefficient visc_coeff(viscosity);
491 S.AddDomainIntegrator(new VectorDiffusionIntegrator(visc_coeff));
492 S.Assemble(skip_zero_entries);
493 S.FormSystemMatrix(ess_tdof_list, tmp);
494
495 reduced_oper = new ReducedSystemOperator(&M, &S, &H);
496
497#ifndef MFEM_USE_SUITESPARSE
498 J_prec = new DSmoother(1);
499 MINRESSolver *J_minres = new MINRESSolver;
500 J_minres->SetRelTol(rel_tol);
501 J_minres->SetAbsTol(0.0);
502 J_minres->SetMaxIter(300);
503 J_minres->SetPrintLevel(-1);
504 J_minres->SetPreconditioner(*J_prec);
505 J_solver = J_minres;
506#else
507 J_solver = new UMFPackSolver;
508 J_prec = NULL;
509#endif
510
511 newton_solver.iterative_mode = false;
512 newton_solver.SetSolver(*J_solver);
513 newton_solver.SetOperator(*reduced_oper);
514 newton_solver.SetPrintLevel(1); // print Newton iterations
515 newton_solver.SetRelTol(rel_tol);
516 newton_solver.SetAbsTol(newton_abs_tol);
517 newton_solver.SetMaxIter(10);
518}
519
520void HyperelasticOperator::Mult(const Vector &vx, Vector &dvx_dt) const
521{
522 // Create views to the sub-vectors v, x of vx, and dv_dt, dx_dt of dvx_dt
523 int sc = height/2;
524 Vector v(vx.GetData() + 0, sc);
525 Vector x(vx.GetData() + sc, sc);
526 Vector dv_dt(dvx_dt.GetData() + 0, sc);
527 Vector dx_dt(dvx_dt.GetData() + sc, sc);
528
529 H.Mult(x, z);
530 if (viscosity != 0.0)
531 {
532 S.AddMult(v, z);
533 }
534 z.Neg(); // z = -z
535 M_solver.Mult(z, dv_dt);
536
537 dx_dt = v;
538}
539
540void HyperelasticOperator::ImplicitSolve(const real_t dt,
541 const Vector &vx, Vector &dvx_dt)
542{
543 int sc = height/2;
544 Vector v(vx.GetData() + 0, sc);
545 Vector x(vx.GetData() + sc, sc);
546 Vector dv_dt(dvx_dt.GetData() + 0, sc);
547 Vector dx_dt(dvx_dt.GetData() + sc, sc);
548
549 // By eliminating kx from the coupled system:
550 // kv = -M^{-1}*[H(x + dt*kx) + S*(v + dt*kv)]
551 // kx = v + dt*kv
552 // we reduce it to a nonlinear equation for kv, represented by the
553 // reduced_oper. This equation is solved with the newton_solver
554 // object (using J_solver and J_prec internally).
555 reduced_oper->SetParameters(dt, &v, &x);
556 Vector zero; // empty vector is interpreted as zero r.h.s. by NewtonSolver
557 newton_solver.Mult(zero, dv_dt);
558 MFEM_VERIFY(newton_solver.GetConverged(), "Newton solver did not converge.");
559 add(v, dt, dv_dt, dx_dt);
560}
561
562real_t HyperelasticOperator::ElasticEnergy(const Vector &x) const
563{
564 return H.GetEnergy(x);
565}
566
567real_t HyperelasticOperator::KineticEnergy(const Vector &v) const
568{
569 return 0.5*M.InnerProduct(v, v);
570}
571
572void HyperelasticOperator::GetElasticEnergyDensity(
573 const GridFunction &x, GridFunction &w, ProjectType proj_type) const
574{
575 ElasticEnergyCoefficient w_coeff(*model, x);
576 w.ProjectCoefficient(w_coeff, proj_type);
577}
578
579HyperelasticOperator::~HyperelasticOperator()
580{
581 delete J_solver;
582 delete J_prec;
583 delete reduced_oper;
584 delete model;
585}
586
587
588real_t ElasticEnergyCoefficient::Eval(ElementTransformation &T,
589 const IntegrationPoint &ip)
590{
591 model.SetTransformation(T);
592 x.GetVectorGradient(T, J);
593 // return model.EvalW(J); // in reference configuration
594 return model.EvalW(J)/J.Det(); // in deformed configuration
595}
596
597
599{
600 // set the initial configuration to be the same as the reference, stress
601 // free, configuration
602 y = x;
603}
604
605void InitialVelocity(const Vector &x, Vector &v)
606{
607 const int dim = x.Size();
608 const real_t s = 0.1/64.;
609
610 v = 0.0;
611 v(dim-1) = s*x(0)*x(0)*(8.0-x(0));
612 v(0) = -s*x(0)*x(0);
613}
T Max() const
Find the maximal element in the array, using the comparison operator < for class T.
Definition array.cpp:69
A "square matrix" operator for the associated FE space and BLFIntegrators The sum of all the BLFInteg...
void AddMult(const Vector &x, Vector &y, const real_t a=1.0) const override
Add the matrix vector multiple to a vector: .
real_t InnerProduct(const Vector &x, const Vector &y) const
Compute .
const SparseMatrix & SpMat() const
Returns a const reference to the sparse matrix: .
A class to handle Vectors in a block fashion.
Vector & GetBlock(int i)
Get the i-th vector in the block.
Conjugate gradient method.
Definition solvers.hpp:627
void Mult(const Vector &b, Vector &x) const override
Iterative solution of the linear system using the Conjugate Gradient method.
Definition solvers.cpp:869
Base class Coefficients that optionally depend on space and time. These are used by the BilinearFormI...
A coefficient that is constant across space and time.
Jacobi-type diagonal smoother of a sparse matrix.
Data type dense matrix using column-major storage.
Definition densemat.hpp:24
real_t Det() const
Definition densemat.cpp:496
Collection of finite elements from the same family in multiple dimensions. This class is used to matc...
Definition fe_coll.hpp:27
virtual const char * Name() const
Definition fe_coll.hpp:79
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
Mesh * GetMesh() const
Returns the mesh.
Definition fespace.hpp:639
Class for grid function - Vector with associated FE space.
Definition gridfunc.hpp:53
void GetVectorGradient(ElementTransformation &tr, DenseMatrix &grad) const
Compute the vector gradient with respect to the physical element variable.
void SetTrueVector()
Shortcut for calling GetTrueDofs() with GetTrueVector() as argument.
Definition gridfunc.hpp:187
virtual void Save(std::ostream &out) const
Save the GridFunction to an output stream.
void MakeTRef(FiniteElementSpace *f, real_t *tv)
Associate a new FiniteElementSpace and new true-dof data with the GridFunction.
Definition gridfunc.cpp:253
void SetFromTrueVector()
Shortcut for calling SetFromTrueDofs() with GetTrueVector() as argument.
Definition gridfunc.hpp:193
const Vector & GetTrueVector() const
Read only access to the (optional) internal true-dof Vector.
Definition gridfunc.hpp:173
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
Abstract class for hyperelastic models.
virtual real_t EvalW(const DenseMatrix &Jpt) const =0
Evaluate the strain energy density function, W = W(Jpt).
void SetTransformation(ElementTransformation &Ttr_)
Class for integration point with weight.
Definition intrules.hpp:35
void SetRelTol(real_t rtol)
Definition solvers.hpp:238
virtual void SetPrintLevel(int print_lvl)
Legacy method to set the level of verbosity of the solver output.
Definition solvers.cpp:76
void SetMaxIter(int max_it)
Definition solvers.hpp:240
bool GetConverged() const
Returns true if the last call to Mult() converged successfully.
Definition solvers.hpp:291
void SetAbsTol(real_t atol)
Definition solvers.hpp:239
Arbitrary order "L2-conforming" discontinuous finite elements.
Definition fe_coll.hpp:369
MINRES method.
Definition solvers.hpp:742
void SetPreconditioner(Solver &pr) override
This should be called before SetOperator.
Definition solvers.hpp:754
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
NURBSExtension * NURBSext
Optional NURBS mesh extension.
Definition mesh.hpp:317
virtual void Print(std::ostream &os=mfem::out, const std::string &comments="") const
Print the mesh to the given stream using the default MFEM mesh format.
Definition mesh.hpp:2610
int Dimension() const
Dimension of the reference space used within the elements.
Definition mesh.hpp:1314
int SpaceDimension() const
Dimension of the physical space containing the mesh.
Definition mesh.hpp:1317
void GetNodes(Vector &node_coord) const
Definition mesh.cpp:10112
void UniformRefinement(int i, const DSTable &, int *, int *, int *)
Definition mesh.cpp:12125
void SwapNodes(GridFunction *&nodes, int &own_nodes_)
Swap the internal node GridFunction pointer and ownership flag members with the given ones.
Definition mesh.cpp:10161
NURBSExtension generally contains multiple NURBSPatch objects spanning an entire Mesh....
Definition nurbs.hpp:575
Arbitrary order non-uniform rational B-splines (NURBS) finite elements.
Definition fe_coll.hpp:749
Newton's method for solving F(x)=b for a given operator F.
Definition solvers.hpp:781
void Mult(const Vector &b, Vector &x) const override
Solve the nonlinear system with right-hand side b.
Definition solvers.cpp:2062
Operator & GetGradient(const Vector &x) const override
Compute the gradient Operator of the NonlinearForm corresponding to the state x.
virtual real_t GetEnergy(const Vector &x) const
Compute the energy corresponding to the state x.
void Mult(const Vector &x, Vector &y) const override
Evaluate the action of the NonlinearForm.
static MFEM_EXPORT std::string Types
Definition ode.hpp:235
static MFEM_EXPORT std::unique_ptr< ODESolver > Select(const int ode_solver_type)
Definition ode.cpp:41
Abstract operator.
Definition operator.hpp:27
int height
Dimension of the output / number of rows in the matrix.
Definition operator.hpp:29
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:855
bool iterative_mode
If true, use the second argument of Mult() as an initial guess.
Definition operator.hpp:858
Data type sparse matrix.
Definition sparsemat.hpp:51
void Add(const int i, const int j, const real_t val)
Base abstract class for first order time dependent operators.
Definition operator.hpp:367
virtual void SetTime(const real_t t_)
Set the current time.
Definition operator.hpp:442
Direct sparse solver using UMFPACK.
Definition solvers.hpp:1210
A general vector function coefficient.
Vector data type.
Definition vector.hpp:82
void Neg()
(*this) = -(*this)
Definition vector.cpp:376
int Size() const
Returns the size of the vector.
Definition vector.hpp:234
real_t * GetData() const
Return a pointer to the beginning of the Vector data.
Definition vector.hpp:243
int open(const char hostname[], int port)
Open the socket stream on 'port' at 'hostname'.
const int * ess_tdof_list
int dim
Definition ex24.cpp:53
real_t mu
Definition ex25.cpp:140
int main()
int GetTrueVSize(const FieldDescriptor &f)
Get the true dof size of a field descriptor.
Definition util.hpp:786
ProjectType
This enumerated type describes the main projection types used by GridFunction::ProjectCoefficient():
Definition gridfunc.hpp:49
void add(const Vector &v1, const Vector &v2, Vector &v)
Definition vector.cpp:414
float real_t
Definition config.hpp:46
std::function< real_t(const Vector &)> f(real_t mass_coeff)
Definition lor_mms.hpp:30
void Add(const DenseMatrix &A, const DenseMatrix &B, real_t alpha, DenseMatrix &C)
C = A + alpha*B.
const char vishost[]
STL namespace.
void visualize(ostream &os, Mesh *mesh, GridFunction *deformed_nodes, GridFunction *field, const char *field_name=NULL, bool init_vis=false)
void InitialDeformation(const Vector &x, Vector &y)
void InitialVelocity(const Vector &x, Vector &v)
std::array< int, NCMesh::MaxFaceNodes > nodes