libMesh
miscellaneous_ex3.C
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2025 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License, or (at your option) any later version.
8 
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
13 
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 
18 
19 
20 // <h1>Miscellaneous Example 3 - 2D Laplace-Young Problem Using Nonlinear Solvers</h1>
21 // \author Derek Gaston
22 // \date 2008
23 //
24 // This example shows how to use the NonlinearImplicitSystem class to
25 // solve nonlinear problems in libMesh. The NonlinearImplicitSystem
26 // class employs the user's ComputeResidual and ComputeJacobian
27 // objects during the solve. In this particular example, the
28 // LaplaceYoung object provides this functionality.
29 //
30 // You can turn on preconditioning of the matrix-free system using the
31 // jacobian by passing "-pre" on the command line. Currently, this
32 // feature only works with Petsc, so this isn't used by "make run".
33 //
34 // This example also runs with the experimental Trilinos NOX solvers
35 // by specifying the --use-trilinos command line argument.
36 
37 
38 // C++ include files that we need
39 #include <iostream>
40 #include <algorithm>
41 #include <cmath>
42 
43 // Various include files needed for the mesh & solver functionality.
44 #include "libmesh/libmesh.h"
45 #include "libmesh/mesh.h"
46 #include "libmesh/mesh_refinement.h"
47 #include "libmesh/exodusII_io.h"
48 #include "libmesh/equation_systems.h"
49 #include "libmesh/fe.h"
50 #include "libmesh/quadrature_gauss.h"
51 #include "libmesh/dof_map.h"
52 #include "libmesh/sparse_matrix.h"
53 #include "libmesh/numeric_vector.h"
54 #include "libmesh/dense_matrix.h"
55 #include "libmesh/dense_vector.h"
56 #include "libmesh/elem.h"
57 #include "libmesh/string_to_enum.h"
58 #include "libmesh/getpot.h"
59 
60 // The nonlinear solver and system we will be using
61 #include "libmesh/nonlinear_solver.h"
62 #include "libmesh/nonlinear_implicit_system.h"
63 
64 // Necessary for programmatically setting petsc options
65 #ifdef LIBMESH_HAVE_PETSC
66 #include <petsc.h>
67 #include "libmesh/petsc_macro.h"
68 #include "libmesh/petsc_solver_exception.h"
69 #endif
70 
71 // Bring in everything from the libMesh namespace
72 using namespace libMesh;
73 
78 class LaplaceYoung :
82 {
83 public:
85  _kappa(1.),
86  _sigma(0.2),
87  _gamma(1.0)
88  {}
89 
93  virtual void residual (const NumericVector<Number> & X,
96 
100  virtual void jacobian (const NumericVector<Number> & X,
103 
117  virtual void postcheck (const NumericVector<Number> & old_soln,
118  NumericVector<Number> & search_direction,
119  NumericVector<Number> & new_soln,
120  bool & changed_search_direction,
121  bool & changed_new_soln,
123 
124 private:
127 
128  // Damping factor used for the solve postcheck
130 };
131 
132 
133 
134 // Begin the main program.
135 int main (int argc, char ** argv)
136 {
137  // Initialize libMesh and any dependent libraries, like in example 2.
138  LibMeshInit init (argc, argv);
139 
140  // This example requires a NonlinearSolver.
141 #if !defined(LIBMESH_HAVE_PETSC) && (!defined(LIBMESH_TRILINOS_HAVE_NOX) || !defined(LIBMESH_TRILINOS_HAVE_EPETRA))
142  libmesh_example_requires(false, "--enable-petsc or --enable-trilinos");
143 #endif
144 
145  if (libMesh::on_command_line ("--use-eigen"))
146  {
147  libMesh::err << "This example requires a NonlinearSolver, and therefore does not "
148  << "support --use-eigen on the command line."
149  << std::endl;
150  return 0;
151  }
152 
153 #ifndef LIBMESH_ENABLE_AMR
154  libmesh_example_requires(false, "--enable-amr");
155 #else
156 
157  // Create a GetPot object to parse the command line
158  GetPot command_line (argc, argv);
159 
160  // Check for proper calling arguments.
161  libmesh_error_msg_if(argc < 3, "Usage:\n" << "\t " << argv[0] << " -r 2");
162 
163  // Brief message to the user regarding the program name
164  // and command line arguments.
165  libMesh::out << "Running " << argv[0];
166 
167  for (int i=1; i<argc; i++)
168  libMesh::out << " " << argv[i];
169 
170  libMesh::out << std::endl << std::endl;
171 
172  // Read number of refinements
173  const int nr = libMesh::command_line_next("-r", 2);
174 
175  // Read FE order from command line
176  std::string order = "FIRST";
177  order = libMesh::command_line_next("-o", order);
178  order = libMesh::command_line_next("-Order", order);
179 
180  // Read FE Family from command line
181  std::string family = "LAGRANGE";
182  family = libMesh::command_line_next("-f", family);
183  family = libMesh::command_line_next("-FEFamily", family);
184 
185  // Cannot use discontinuous basis.
186  libmesh_error_msg_if((family == "MONOMIAL") || (family == "XYZ"),
187  "This example requires a C^0 (or higher) FE basis.");
188 
189  if (libMesh::on_command_line("-pre"))
190  {
191 #ifdef LIBMESH_HAVE_PETSC
192  //Use the jacobian for preconditioning.
193 # if PETSC_VERSION_LESS_THAN(3,7,0)
194  LibmeshPetscCall2(init.comm(), PetscOptionsSetValue("-snes_mf_operator",
195  LIBMESH_PETSC_NULLPTR));
196 # else
197  LibmeshPetscCall2(init.comm(), PetscOptionsSetValue(LIBMESH_PETSC_NULLPTR, "-snes_mf_operator",
198  LIBMESH_PETSC_NULLPTR));
199 # endif
200 #else
201  libMesh::err << "Must be using PETSc to use jacobian based preconditioning" << std::endl;
202 
203  //returning zero so that "make run" won't fail if we ever enable this capability there.
204  return 0;
205 #endif //LIBMESH_HAVE_PETSC
206  }
207 
208  // Skip this 2D example if libMesh was compiled as 1D-only.
209  libmesh_example_requires(2 <= LIBMESH_DIM, "2D support");
210 
211  // Create a mesh, with dimension to be overridden by the file,
212  // distributed across the default MPI communicator.
213  Mesh mesh(init.comm());
214 
215  mesh.read ("lshaped.xda");
216 
217  if (order != "FIRST")
219 
221 
222  // Print information about the mesh to the screen.
223  mesh.print_info();
224 
225  // Create an equation systems object.
226  EquationSystems equation_systems (mesh);
227 
228  // Declare the system and its variables.
229 
230  // Creates a system named "Laplace-Young"
231  NonlinearImplicitSystem & system =
232  equation_systems.add_system<NonlinearImplicitSystem> ("Laplace-Young");
233 
234  // Here we specify the tolerance for the nonlinear solver and
235  // the maximum of nonlinear iterations.
236  equation_systems.parameters.set<Real> ("nonlinear solver tolerance") = 1.e-12;
237  equation_systems.parameters.set<unsigned int> ("nonlinear solver maximum iterations") = 50;
238 
239 
240  // Adds the variable "u" to "Laplace-Young". "u"
241  // will be approximated using second-order approximation.
242  system.add_variable("u",
243  Utility::string_to_enum<Order> (order),
244  Utility::string_to_enum<FEFamily>(family));
245 
246  // Construct object which provides the residual and jacobian
247  // computations and tell the solver to use it.
248  LaplaceYoung laplace_young;
249  system.nonlinear_solver->residual_object = &laplace_young;
250  system.nonlinear_solver->jacobian_object = &laplace_young;
251  system.nonlinear_solver->postcheck_object = &laplace_young;
252 
253  // Initialize the data structures for the equation system.
254  equation_systems.init();
255 
256  // Prints information about the system to the screen.
257  equation_systems.print_info();
258 
259  // Solve the system "Laplace-Young", print the number of iterations
260  // and final residual
261  equation_systems.get_system("Laplace-Young").solve();
262 
263  // Print out final convergence information. This duplicates some
264  // output from during the solve itself, but demonstrates another way
265  // to get this information after the solve is complete.
266  libMesh::out << "Laplace-Young system solved at nonlinear iteration "
267  << system.n_nonlinear_iterations()
268  << " , final nonlinear residual norm: "
269  << system.final_nonlinear_residual()
270  << std::endl;
271 
272 #ifdef LIBMESH_HAVE_EXODUS_API
273  // After solving the system write the solution
275  equation_systems);
276 #endif // #ifdef LIBMESH_HAVE_EXODUS_API
277 #endif // #ifndef LIBMESH_ENABLE_AMR
278 
279  // All done.
280  return 0;
281 }
282 
283 
284 
285 // Residual assembly function for the Laplace-Young system
287  NumericVector<Number> & residual,
289 {
291 
292  // Get a constant reference to the mesh object.
293  const MeshBase & mesh = es.get_mesh();
294 
295  // The dimension that we are running
296  const unsigned int dim = mesh.mesh_dimension();
297  libmesh_assert_equal_to (dim, 2);
298 
299  // Get a reference to the NonlinearImplicitSystem we are solving
300  NonlinearImplicitSystem & system =
301  es.get_system<NonlinearImplicitSystem>("Laplace-Young");
302 
303  // A reference to the DofMap object for this system. The DofMap
304  // object handles the index translation from node and element numbers
305  // to degree of freedom numbers. We will talk more about the DofMap
306  // in future examples.
307  const DofMap & dof_map = system.get_dof_map();
308 
309  // Get a constant reference to the Finite Element type
310  // for the first (and only) variable in the system.
311  FEType fe_type = dof_map.variable_type(0);
312 
313  // Build a Finite Element object of the specified type. Since the
314  // FEBase::build() member dynamically creates memory we will
315  // store the object as a std::unique_ptr<FEBase>. This can be thought
316  // of as a pointer that will clean up after itself.
317  std::unique_ptr<FEBase> fe (FEBase::build(dim, fe_type));
318 
319  // A 5th order Gauss quadrature rule for numerical integration.
320  QGauss qrule (dim, FIFTH);
321 
322  // Tell the finite element object to use our quadrature rule.
323  fe->attach_quadrature_rule (&qrule);
324 
325  // Declare a special finite element object for
326  // boundary integration.
327  std::unique_ptr<FEBase> fe_face (FEBase::build(dim, fe_type));
328 
329  // Boundary integration requires one quadrature rule,
330  // with dimensionality one less than the dimensionality
331  // of the element.
332  QGauss qface(dim-1, FIFTH);
333 
334  // Tell the finite element object to use our
335  // quadrature rule.
336  fe_face->attach_quadrature_rule (&qface);
337 
338  // Here we define some references to cell-specific data that
339  // will be used to assemble the linear system.
340  // We begin with the element Jacobian * quadrature weight at each
341  // integration point.
342  const std::vector<Real> & JxW = fe->get_JxW();
343 
344  // The element shape functions evaluated at the quadrature points.
345  const std::vector<std::vector<Real>> & phi = fe->get_phi();
346 
347  // The element shape function gradients evaluated at the quadrature
348  // points.
349  const std::vector<std::vector<RealGradient>> & dphi = fe->get_dphi();
350 
351  // Define data structures to contain the residual contributions
353 
354  // This vector will hold the degree of freedom indices for
355  // the element. These define where in the global system
356  // the element degrees of freedom get mapped.
357  std::vector<dof_id_type> dof_indices;
358 
359  // Now we will loop over all the active elements in the mesh which
360  // are local to this processor.
361  // We will compute the element residual.
362  residual.zero();
363 
364  for (const auto & elem : mesh.active_local_element_ptr_range())
365  {
366  // Get the degree of freedom indices for the
367  // current element. These define where in the global
368  // matrix and right-hand-side this element will
369  // contribute to.
370  dof_map.dof_indices (elem, dof_indices);
371 
372  // Compute the element-specific data for the current
373  // element. This involves computing the location of the
374  // quadrature points (q_point) and the shape functions
375  // (phi, dphi) for the current element.
376  fe->reinit (elem);
377 
378  // We use the resize member here because
379  // the number of degrees of freedom might have changed from
380  // the last element. Note that this will be the case if the
381  // element type is different (i.e. the last element was a
382  // triangle, now we are on a quadrilateral).
383  const unsigned int n_dofs =
384  cast_int<unsigned int>(dof_indices.size());
385  Re.resize (n_dofs);
386 
387  // Now we will build the residual. This involves
388  // the construction of the matrix K and multiplication of it
389  // with the current solution x. We rearrange this into two loops:
390  // In the first, we calculate only the contribution of
391  // K_ij*x_j which is independent of the row i. In the second loops,
392  // we multiply with the row-dependent part and add it to the element
393  // residual.
394 
395  for (unsigned int qp=0; qp<qrule.n_points(); qp++)
396  {
397  Number u = 0;
398  Gradient grad_u;
399 
400  for (unsigned int j=0; j<n_dofs; j++)
401  {
402  u += phi[j][qp]*soln(dof_indices[j]);
403  grad_u += dphi[j][qp]*soln(dof_indices[j]);
404  }
405 
406  const Number K = 1./std::sqrt(1. + grad_u*grad_u);
407 
408  for (unsigned int i=0; i<n_dofs; i++)
409  Re(i) += JxW[qp]*(
410  K*(dphi[i][qp]*grad_u) +
411  _kappa*phi[i][qp]*u
412  );
413  }
414 
415  // At this point the interior element integration has
416  // been completed. However, we have not yet addressed
417  // boundary conditions.
418 
419  // The following loops over the sides of the element.
420  // If the element has no neighbor on a side then that
421  // side MUST live on a boundary of the domain.
422  for (auto side : elem->side_index_range())
423  if (elem->neighbor_ptr(side) == nullptr)
424  {
425  // The value of the shape functions at the quadrature
426  // points.
427  const std::vector<std::vector<Real>> & phi_face = fe_face->get_phi();
428 
429  // The Jacobian * Quadrature Weight at the quadrature
430  // points on the face.
431  const std::vector<Real> & JxW_face = fe_face->get_JxW();
432 
433  // Compute the shape function values on the element face.
434  fe_face->reinit(elem, side);
435 
436  // Loop over the face quadrature points for integration.
437  for (unsigned int qp=0; qp<qface.n_points(); qp++)
438  {
439  // This is the right-hand-side contribution (f),
440  // which has to be subtracted from the current residual
441  for (unsigned int i=0; i<n_dofs; i++)
442  Re(i) -= JxW_face[qp]*_sigma*phi_face[i][qp];
443  }
444  }
445 
446  dof_map.constrain_element_vector (Re, dof_indices);
447  residual.add_vector (Re, dof_indices);
448  }
449 
450  // That's it.
451 }
452 
453 
454 
455 // Jacobian assembly function for the Laplace-Young system
457  SparseMatrix<Number> & jacobian,
459 {
460  // Get a reference to the equation system.
462 
463  // Get a constant reference to the mesh object.
464  const MeshBase & mesh = es.get_mesh();
465 
466  // The dimension that we are running
467  const unsigned int dim = mesh.mesh_dimension();
468 
469  // Get a reference to the NonlinearImplicitSystem we are solving
470  NonlinearImplicitSystem & system =
471  es.get_system<NonlinearImplicitSystem>("Laplace-Young");
472 
473  // A reference to the DofMap object for this system. The DofMap
474  // object handles the index translation from node and element numbers
475  // to degree of freedom numbers. We will talk more about the DofMap
476  // in future examples.
477  const DofMap & dof_map = system.get_dof_map();
478 
479  // Get a constant reference to the Finite Element type
480  // for the first (and only) variable in the system.
481  FEType fe_type = dof_map.variable_type(0);
482 
483  // Build a Finite Element object of the specified type. Since the
484  // FEBase::build() member dynamically creates memory we will
485  // store the object as a std::unique_ptr<FEBase>. This can be thought
486  // of as a pointer that will clean up after itself.
487  std::unique_ptr<FEBase> fe (FEBase::build(dim, fe_type));
488 
489  // A 5th order Gauss quadrature rule for numerical integration.
490  QGauss qrule (dim, FIFTH);
491 
492  // Tell the finite element object to use our quadrature rule.
493  fe->attach_quadrature_rule (&qrule);
494 
495  // Here we define some references to cell-specific data that
496  // will be used to assemble the linear system.
497  // We begin with the element Jacobian * quadrature weight at each
498  // integration point.
499  const std::vector<Real> & JxW = fe->get_JxW();
500 
501  // The element shape functions evaluated at the quadrature points.
502  const std::vector<std::vector<Real>> & phi = fe->get_phi();
503 
504  // The element shape function gradients evaluated at the quadrature
505  // points.
506  const std::vector<std::vector<RealGradient>> & dphi = fe->get_dphi();
507 
508  // Define data structures to contain the Jacobian element matrix.
509  // Following basic finite element terminology we will denote these
510  // "Ke". More detail is in example 3.
512 
513  // This vector will hold the degree of freedom indices for
514  // the element. These define where in the global system
515  // the element degrees of freedom get mapped.
516  std::vector<dof_id_type> dof_indices;
517 
518  // Now we will loop over all the active elements in the mesh which
519  // are local to this processor.
520  // We will compute the element Jacobian contribution.
521  for (const auto & elem : mesh.active_local_element_ptr_range())
522  {
523  // Get the degree of freedom indices for the
524  // current element. These define where in the global
525  // matrix and right-hand-side this element will
526  // contribute to.
527  dof_map.dof_indices (elem, dof_indices);
528 
529  // Compute the element-specific data for the current
530  // element. This involves computing the location of the
531  // quadrature points (q_point) and the shape functions
532  // (phi, dphi) for the current element.
533  fe->reinit (elem);
534 
535  // Zero the element Jacobian before
536  // summing them. We use the resize member here because
537  // the number of degrees of freedom might have changed from
538  // the last element. Note that this will be the case if the
539  // element type is different (i.e. the last element was a
540  // triangle, now we are on a quadrilateral).
541  const unsigned int n_dofs =
542  cast_int<unsigned int>(dof_indices.size());
543  Ke.resize (n_dofs, n_dofs);
544 
545  // Now we will build the element Jacobian. This involves
546  // a double loop to integrate the test functions (i) against
547  // the trial functions (j). Note that the Jacobian depends
548  // on the current solution x, which we access using the soln
549  // vector.
550  //
551  for (unsigned int qp=0; qp<qrule.n_points(); qp++)
552  {
553  Gradient grad_u;
554 
555  for (unsigned int i=0; i<n_dofs; i++)
556  grad_u += dphi[i][qp]*soln(dof_indices[i]);
557 
558  const Number
559  sa = 1. + grad_u*grad_u,
560  K = 1. / std::sqrt(sa),
561  dK = -K / sa;
562 
563  for (unsigned int i=0; i<n_dofs; i++)
564  for (unsigned int j=0; j<n_dofs; j++)
565  Ke(i,j) += JxW[qp]*(
566  K * (dphi[i][qp]*dphi[j][qp]) +
567  dK * (grad_u*dphi[j][qp]) * (grad_u*dphi[i][qp]) +
568  _kappa * phi[i][qp] * phi[j][qp]
569  );
570  }
571 
572  dof_map.constrain_element_matrix (Ke, dof_indices);
573 
574  // Add the element matrix to the system Jacobian.
575  jacobian.add_matrix (Ke, dof_indices);
576  }
577 
578  // That's it.
579 }
580 
581 
582 
583 // Jacobian assembly function for the Laplace-Young system
585  NumericVector<Number> & search_direction,
586  NumericVector<Number> & new_soln,
587  bool & /*changed_search_direction*/,
588  bool & changed_new_soln,
589  NonlinearImplicitSystem & /*S*/)
590 {
591  // Back up along the search direction by some amount. Since Newton
592  // already works well for this problem, the only affect of this is
593  // to degrade the rate of convergence.
594  //
595  // The minus sign is due to the sign of the "search_direction"
596  // vector which comes in from the Newton solve. The RHS of the
597  // nonlinear system, i.e. the residual, is generally not multiplied
598  // by -1, so the solution vector, i.e. the search_direction, has a
599  // factor -1.
600  if (_gamma != 1.0)
601  {
602  new_soln = old_soln;
603  new_soln.add(-_gamma, search_direction);
604  changed_new_soln = true;
605  }
606  else
607  changed_new_soln = false;
608 }
class FEType hides (possibly multiple) FEFamily and approximation orders, thereby enabling specialize...
Definition: fe_type.h:196
OStreamProxy err
T command_line_next(std::string name, T default_value)
Use GetPot&#39;s search()/next() functions to get following arguments from the command line...
Definition: libmesh.C:1078
This is the EquationSystems class.
virtual void read(const std::string &name, void *mesh_data=nullptr, bool skip_renumber_nodes_and_elements=false, bool skip_find_neighbors=false)=0
Interfaces for reading/writing a mesh to/from a file.
std::unique_ptr< NonlinearSolver< Number > > nonlinear_solver
The NonlinearSolver defines the default interface used to solve the nonlinear_implicit system...
int main(int argc, char **argv)
unsigned int dim
The ExodusII_IO class implements reading meshes in the ExodusII file format from Sandia National Labs...
Definition: exodusII_io.h:52
void resize(const unsigned int n)
Resize the vector.
Definition: dense_vector.h:396
virtual void add_vector(const T *v, const std::vector< numeric_index_type > &dof_indices)
Computes , where v is a pointer and each dof_indices[i] specifies where to add value v[i]...
const EquationSystems & get_equation_systems() const
Definition: system.h:721
void print_info(std::ostream &os=libMesh::out) const
Prints information about the equation systems, by default to libMesh::out.
MeshBase & mesh
virtual void postcheck(const NumericVector< Number > &old_soln, NumericVector< Number > &search_direction, NumericVector< Number > &new_soln, bool &changed_search_direction, bool &changed_new_soln, NonlinearImplicitSystem &S)
Function which performs a postcheck on the solution.
This class defines a vector in LIBMESH_DIM dimensional Real or Complex space.
The LibMeshInit class, when constructed, initializes the dependent libraries (e.g.
Definition: libmesh.h:90
The libMesh namespace provides an interface to certain functionality in the library.
const T_sys & get_system(std::string_view name) const
This is the MeshBase class.
Definition: mesh_base.h:75
virtual void zero()=0
Set all entries to zero.
This class handles the numbering of degrees of freedom on a mesh.
Definition: dof_map.h:179
Abstract base class to be used to calculate the residual of a nonlinear system.
virtual void add_matrix(const DenseMatrix< T > &dm, const std::vector< numeric_index_type > &rows, const std::vector< numeric_index_type > &cols)=0
Add the full matrix dm to the SparseMatrix.
Implements (adaptive) mesh refinement algorithms for a MeshBase.
Abstract base class to be used to calculate the Jacobian of a nonlinear system.
virtual void write_equation_systems(const std::string &fname, const EquationSystems &es, const std::set< std::string > *system_names=nullptr) override
Writes out the solution for no specific time or timestep.
Definition: exodusII_io.C:2033
void print_info(std::ostream &os=libMesh::out, const unsigned int verbosity=0, const bool global=true) const
Prints relevant information about the mesh.
Definition: mesh_base.C:1562
void init(triangulateio &t)
Initializes the fields of t to nullptr/0 as necessary.
static std::unique_ptr< FEGenericBase > build(const unsigned int dim, const FEType &type)
Builds a specific finite element type.
Manages consistently variables, degrees of freedom, coefficient vectors, matrices and non-linear solv...
unsigned int add_variable(std::string_view var, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=nullptr)
Adds the variable var to the list of variables for this system.
Definition: system.C:1357
unsigned int n_points() const
Definition: quadrature.h:131
A class which provides the residual and jacobian assembly functions for the Laplace-Young system of e...
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual void jacobian(const NumericVector< Number > &X, SparseMatrix< Number > &J, NonlinearImplicitSystem &S)
Function which computes the jacobian.
T & set(const std::string &)
Definition: parameters.h:469
OStreamProxy out
const MeshBase & get_mesh() const
void resize(const unsigned int new_m, const unsigned int new_n)
Resizes the matrix to the specified size and calls zero().
Definition: dense_matrix.h:895
void all_second_order(const bool full_ordered=true)
Calls the range-based version of this function with a range consisting of all elements in the mesh...
Definition: mesh_base.C:1608
This class implements specific orders of Gauss quadrature.
unsigned int mesh_dimension() const
Definition: mesh_base.C:372
Parameters parameters
Data structure holding arbitrary parameters.
bool on_command_line(std::string arg)
Definition: libmesh.C:987
virtual void init()
Initialize all the systems.
virtual void add(const numeric_index_type i, const T value)=0
Adds value to the vector entry specified by i.
virtual System & add_system(std::string_view system_type, std::string_view name)
Add the system of type system_type named name to the systems array.
The Mesh class is a thin wrapper, around the ReplicatedMesh class by default.
Definition: mesh.h:50
virtual void residual(const NumericVector< Number > &X, NumericVector< Number > &R, NonlinearImplicitSystem &S)
Function which computes the residual.
const DofMap & get_dof_map() const
Definition: system.h:2374
Abstract base class to be used for applying user modifications to the solution vector and/or Newton u...
void uniformly_refine(unsigned int n=1)
Uniformly refines the mesh n times.