136{
137
139
140
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
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
158 GetPot command_line (argc, argv);
159
160
161 libmesh_error_msg_if(argc < 3, "Usage:\n" << "\t " << argv[0] << " -r 2");
162
163
164
166
167 for (int i=1; i<argc; i++)
169
171
172
174
175
176 std::string order = "FIRST";
179
180
181 std::string family = "LAGRANGE";
184
185
186 libmesh_error_msg_if((family == "MONOMIAL") || (family == "XYZ"),
187 "This example requires a C^0 (or higher) FE basis.");
188
190 {
191#ifdef LIBMESH_HAVE_PETSC
192
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
204 return 0;
205#endif
206 }
207
208
209 libmesh_example_requires(2 <= LIBMESH_DIM, "2D support");
210
211
212
214
216
217 if (order != "FIRST")
219
221
222
224
225
227
228
229
230
233
234
235
237 equation_systems.parameters.set<unsigned int> ("nonlinear solver maximum iterations") = 50;
238
239
240
241
243 Utility::string_to_enum<Order> (order),
244 Utility::string_to_enum<FEFamily>(family));
245
246
247
252
253
254 equation_systems.init();
255
256
257 equation_systems.print_info();
258
259
260
261 equation_systems.get_system("Laplace-Young").solve();
262
263
264
265
266 libMesh::out <<
"Laplace-Young system solved at nonlinear iteration "
268 << " , final nonlinear residual norm: "
270 << std::endl;
271
272#ifdef LIBMESH_HAVE_EXODUS_API
273
275 equation_systems);
276#endif
277#endif
278
279
280 return 0;
281}
A class which provides the residual and jacobian assembly functions for the Laplace-Young system of e...
This is the EquationSystems class.
The ExodusII_IO class implements reading meshes in the ExodusII file format from Sandia National Labs...
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.
The LibMeshInit class, when constructed, initializes the dependent libraries (e.g.
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.
virtual void read(const std::string &name, void *mesh_data=nullptr, bool skip_renumber_nodes_and_elements=false, bool skip_find_neighbors=false, bool skip_detect_interior_parents=false)=0
Interfaces for reading/writing a mesh to/from a file.
void print_info(std::ostream &os=libMesh::out, const unsigned int verbosity=0, const bool global=true) const
Prints relevant information about the mesh.
Implements (adaptive) mesh refinement algorithms for a MeshBase.
void uniformly_refine(unsigned int n=1)
Uniformly refines the mesh n times.
The Mesh class is a thin wrapper, around the ReplicatedMesh class by default.
Manages consistently variables, degrees of freedom, coefficient vectors, matrices and non-linear solv...
std::unique_ptr< NonlinearSolver< Number > > nonlinear_solver
The NonlinearSolver defines the default interface used to solve the nonlinear_implicit system.
Real final_nonlinear_residual() const
unsigned int n_nonlinear_iterations() const
T & set(const std::string &)
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.
Parameters parameters
Parameters for the system. If a parameter is not provided, it should be retrieved from the EquationSy...
void init(triangulateio &t)
Initializes the fields of t to nullptr/0 as necessary.
T command_line_next(std::string name, T default_value)
Use GetPot's search()/next() functions to get following arguments from the command line.
bool on_command_line(std::string arg)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real