28#include "libmesh/equation_systems.h"
29#include "libmesh/getpot.h"
30#include "libmesh/exodusII_io.h"
31#include "libmesh/mesh.h"
32#include "libmesh/mesh_generation.h"
33#include "libmesh/mesh_modification.h"
34#include "libmesh/mesh_refinement.h"
35#include "libmesh/exact_solution.h"
36#include "libmesh/string_to_enum.h"
37#include "libmesh/enum_solver_package.h"
38#include "libmesh/enum_norm_type.h"
39#include "libmesh/petsc_macro.h"
42#include "curl_curl_system.h"
43#include "libmesh/diff_solver.h"
44#include "libmesh/steady_solver.h"
45#include "solution_function.h"
54int main (
int argc,
char ** argv)
61 "--enable-petsc, --enable-trilinos, or --enable-eigen");
64 GetPot infile(
"vector_fe_ex3.in");
67 infile.parse_command_line(argc, argv);
70#if PETSC_VERSION_LESS_THAN(3, 12, 2) || !defined(LIBMESH_HAVE_PETSC_HYPRE)
71 libmesh_example_requires(!infile.search(
"ams"),
72 "PETSc 3.12.2 or above with hypre support enabled");
76 const unsigned int grid_size = infile(
"grid_size", 2);
79 libmesh_example_requires(2 <= LIBMESH_DIM,
"2D support");
88 const std::string elem_str = infile(
"element_type", std::string(
"TRI6"));
90 libmesh_error_msg_if(elem_str !=
"TRI6" && elem_str !=
"TRI7" && elem_str !=
"QUAD8" && elem_str !=
"QUAD9",
91 "You selected: " << elem_str <<
92 " but this example must be run with TRI6, TRI7, QUAD8, or QUAD9.");
99 Utility::string_to_enum<ElemType>(elem_str));
104#ifdef LIBMESH_ENABLE_AMR
113 const Real phi = infile(
"phi", 0.), theta = infile(
"theta", 0.), psi = infile(
"psi", 0.);
130 const Order order =
static_cast<Order>(infile(
"order", 1u));
132 libmesh_error_msg_if(order < FIRST || order >
FIFTH,
133 "You selected: " << order <<
134 " but this example must be run with 1 <= order <= 5.");
139 system.
time_solver = std::make_unique<SteadySolver>(system);
142 equation_systems.
init();
146 solver.
quiet = infile(
"solver_quiet",
true);
169 std::vector<FunctionBase<Number> *> sols(1, &soln_func);
170 std::vector<FunctionBase<Gradient> *> grads(1, &soln_grad);
176 int extra_error_quadrature = infile(
"extra_error_quadrature", 2);
184 << exact_sol.
l2_error(
"CurlCurl",
"u")
193#ifdef LIBMESH_HAVE_EXODUS_API
static void RM(RealTensor T)
FEMSystem, TimeSolver and NewtonSolver will handle most tasks, but we must specify element residuals.
void order(const Order &order)
This is a generic class that defines a solver to handle ImplicitSystem classes, including NonlinearIm...
Real absolute_residual_tolerance
The DiffSolver should exit after the residual is reduced to either less than absolute_residual_tolera...
unsigned int max_linear_iterations
Each linear solver step should exit after max_linear_iterations is exceeded.
double initial_linear_tolerance
Any required linear solves will at first be done with this tolerance; the DiffSolver may tighten the ...
Real relative_residual_tolerance
Real relative_step_tolerance
bool verbose
The DiffSolver may print a lot more to libMesh::out if verbose is set to true; default is false.
unsigned int max_nonlinear_iterations
The DiffSolver should exit in failure if max_nonlinear_iterations is exceeded and continue_after_max_...
bool quiet
The DiffSolver should not print anything to libMesh::out unless quiet is set to false; default is tru...
std::unique_ptr< TimeSolver > time_solver
A pointer to the solver object we're going to use.
This is the EquationSystems class.
void print_info(std::ostream &os=libMesh::out) const
Prints information about the equation systems, by default to libMesh::out.
virtual void init()
Initialize all the systems.
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.
This class handles the computation of the L2 and/or H1 error for the Systems in the EquationSystems o...
Real l2_error(std::string_view sys_name, std::string_view unknown_name)
Real hcurl_error(std::string_view sys_name, std::string_view unknown_name)
Real error_norm(std::string_view sys_name, std::string_view unknown_name, const FEMNormType &norm)
void attach_exact_values(const std::vector< FunctionBase< Number > * > &f)
Clone and attach arbitrary functors which compute the exact values of the EquationSystems' solutions ...
void compute_error(std::string_view sys_name, std::string_view unknown_name)
Computes and stores the error in the solution value e = u-u_h, the gradient grad(e) = grad(u) - grad(...
void extra_quadrature_order(const int extraorder)
Increases or decreases the order of the quadrature rule used for numerical integration.
void attach_exact_derivs(const std::vector< FunctionBase< Gradient > * > &g)
Clone and attach arbitrary functors which compute the exact gradients of the EquationSystems' solutio...
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.
virtual void solve() override
Invokes the solver associated with the system.
The LibMeshInit class, when constructed, initializes the dependent libraries (e.g.
void complete_preparation()
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.
unsigned int variable_number(std::string_view var) const
This class defines a tensor in LIBMESH_DIM dimensional Real or Complex space.
The libMesh namespace provides an interface to certain functionality in the library.
SolverPackage default_solver_package()
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real