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