73{
74
76
77
79 "--enable-petsc");
80
81
82 GetPot infile("vector_fe_ex9.in");
83
84
85 infile.parse_command_line(argc, argv);
86
87
88 const unsigned int dimension = 2;
89 const unsigned int grid_size = infile("grid_size", 2);
90 const bool mms = infile("mms", true);
91 const Real nu = infile(
"nu", 1.);
92 const bool cavity = infile("cavity", false);
93
94
95 libmesh_example_requires(dimension <= LIBMESH_DIM, dimension << "D support");
96
97
98#if !defined(LIBMESH_HAVE_EIGEN_DENSE)
100 libmesh_example_requires(false, "--enable-eigen");
101#endif
102
103
104
106
107
108
109
110 const std::string elem_str = infile("element_type", std::string("TRI6"));
111
112 libmesh_error_msg_if(elem_str != "TRI6" && elem_str != "TRI7",
113 "You selected "
114 << elem_str
115 << " but this example must be run with TRI6, TRI7, QUAD8, or QUAD9 in 2d"
116 << " or with TET14, or HEX27 in 3d.");
117
118 if (mms && !cavity)
120 mesh, grid_size, grid_size, 0., 2., -1, 1., Utility::string_to_enum<ElemType>(elem_str));
121 else if (cavity)
123 mesh, grid_size, grid_size, -1, 1, -1, 1., Utility::string_to_enum<ElemType>(elem_str));
124 else
126 5 * grid_size,
127 grid_size,
128 0.,
129 10.,
130 -1,
131 1.,
132 Utility::string_to_enum<ElemType>(elem_str));
134
135
137
138
140
141
146
147
151 if (cavity)
153
157
159 if (system.has_static_condensation())
160 {
161 sc = &system.get_static_condensation();
163 }
164
167 hdg.system = &system;
168 hdg.dof_map = &system.get_dof_map();
174 hdg.scalar_fe_face =
FEBase::build(dimension, scalar_fe_type);
176 hdg.mms = mms;
177 hdg.sc = sc;
178
179 system.nonlinear_solver->residual_object = &hdg;
180 system.nonlinear_solver->jacobian_object = &hdg;
181
183
184
185 equation_systems.init();
186 equation_systems.print_info();
187
188
189 system.solve();
190
191 if (mms)
192 {
193
194
195
196
197 equation_systems.parameters.set<
const ExactSoln *>(
"vel_x_exact_sol") = &hdg.u_true_soln;
198 equation_systems.parameters.set<
const ExactSoln *>(
"vel_y_exact_sol") = &hdg.v_true_soln;
199 equation_systems.parameters.set<
const ExactSoln *>(
"pressure_exact_sol") = &hdg.p_true_soln;
202
203
204 exact_sol.compute_error("HDG", "vel_x");
205 exact_sol.compute_error("HDG", "vel_y");
206 exact_sol.compute_error("HDG", "pressure");
207
208
209 libMesh::out <<
"L2 error for u is: " << exact_sol.l2_error(
"HDG",
"vel_x") << std::endl;
210 libMesh::out <<
"L2 error for v is: " << exact_sol.l2_error(
"HDG",
"vel_y") << std::endl;
211 libMesh::out <<
"L2 error for pressure is: " << exact_sol.l2_error(
"HDG",
"pressure")
212 << std::endl;
213 }
214
215#ifdef LIBMESH_HAVE_EXODUS_API
216
217
219
220#endif
221
222
223 return 0;
224}
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.
static std::unique_ptr< FEGenericBase > build(const unsigned int dim, const FEType &type)
Builds a specific finite element type.
class FEType hides (possibly multiple) FEFamily and approximation orders, thereby enabling specialize...
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.
Manages consistently variables, degrees of freedom, coefficient vectors, matrices and non-linear solv...
static std::unique_ptr< QBase > build(std::string_view name, const unsigned int dim, const Order order=INVALID_ORDER)
Builds a specific quadrature rule based on the name string.
virtual void init(const numeric_index_type m, const numeric_index_type n, const numeric_index_type m_l, const numeric_index_type n_l, const numeric_index_type nnz=30, const numeric_index_type noz=10, const numeric_index_type blocksize=1) override
Initialize SparseMatrix with the specified sizes.
void dont_condense_vars(const std::unordered_set< unsigned int > &vars)
Add vars to the list of variables not to condense.
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.
void init(triangulateio &t)
Initializes the fields of t to nullptr/0 as necessary.
SolverPackage default_solver_package()
Number compute_error(const Point &p, const Parameters ¶ms, const std::string &, const std::string &unknown_name)
bool on_command_line(std::string arg)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real