50{
51
53
54
56 "--enable-petsc, --enable-trilinos, or --enable-eigen");
57
58
59 GetPot infile("vector_fe_ex4.in");
60
61
62 infile.parse_command_line(argc, argv);
63
64
65#if PETSC_VERSION_LESS_THAN(3, 12, 2) || !defined(LIBMESH_HAVE_PETSC_HYPRE)
66 libmesh_example_requires(!infile.search("ams"),
67 "PETSc 3.12.2 or above with hypre support enabled");
68#endif
69
70
71 const unsigned int grid_size = infile("grid_size", 2);
72
73
74 libmesh_example_requires(3 <= LIBMESH_DIM, "3D support");
75
76
77
79
80
81
82
83 std::string elem_str =
85 std::string("HEX27"));
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101 libmesh_error_msg_if(elem_str != "TET10" && elem_str != "TET14" && elem_str != "HEX20" && elem_str != "HEX27",
102 "You entered: " << elem_str <<
103 " but this example must be run with TET10, TET14, HEX20 or HEX27.");
104
106 grid_size,
107 grid_size,
108 grid_size,
109 -1., 1.,
110 -1., 1.,
111 -1., 1.,
112 Utility::string_to_enum<ElemType>(elem_str));
113
114
115
117
118
120
121
124
125
126 system.
time_solver = std::make_unique<SteadySolver>(system);
127
128
129 equation_systems.init();
130
131
133 solver.
quiet = infile(
"solver_quiet",
true);
139
140
143
144
145 equation_systems.print_info();
146
147
149
151
154
155
156 std::vector<FunctionBase<Number> *> sols(1, &soln_func);
157 std::vector<FunctionBase<Gradient> *> grads(1, &soln_grad);
158
159 exact_sol.attach_exact_values(sols);
160 exact_sol.attach_exact_derivs(grads);
161
162
163 int extra_error_quadrature = infile("extra_error_quadrature", 2);
164 exact_sol.extra_quadrature_order(extra_error_quadrature);
165
166
167 exact_sol.compute_error("CurlCurl", "u");
168
169
171 << exact_sol.l2_error("CurlCurl", "u")
172 << std::endl;
175 << std::endl;
177 << exact_sol.hcurl_error("CurlCurl", "u")
178 << std::endl;
179
180#ifdef LIBMESH_HAVE_EXODUS_API
181
182
184
185#endif
186
187
188 return 0;
189}
FEMSystem, TimeSolver and NewtonSolver will handle most tasks, but we must specify element residuals.
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.
This class handles the computation of the L2 and/or H1 error for the Systems in the EquationSystems o...
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 print_info(std::ostream &os=libMesh::out, const unsigned int verbosity=0, const bool global=true) const
Prints relevant information about the mesh.
The Mesh class is a thin wrapper, around the ReplicatedMesh class by default.
unsigned int variable_number(std::string_view var) const
void init(triangulateio &t)
Initializes the fields of t to nullptr/0 as necessary.
SolverPackage default_solver_package()
T command_line_value(const std::string &, T)