#include <exact_solution.h>
Public Types | |
typedef Number(* | ValueFunctionPointer) (const Point &p, const Parameters &Parameters, const std::string &sys_name, const std::string &unknown_name) |
typedef Gradient(* | GradientFunctionPointer) (const Point &p, const Parameters ¶meters, const std::string &sys_name, const std::string &unknown_name) |
typedef Tensor(* | HessianFunctionPointer) (const Point &p, const Parameters ¶meters, const std::string &sys_name, const std::string &unknown_name) |
Public Member Functions | |
ExactSolution (const EquationSystems &es) | |
ExactSolution (const ExactSolution &)=delete | |
ExactSolution & | operator= (const ExactSolution &)=delete |
ExactSolution & | operator= (ExactSolution &&)=delete |
ExactSolution (ExactSolution &&) | |
~ExactSolution () | |
void | attach_reference_solution (const EquationSystems *es_fine) |
void | attach_exact_values (const std::vector< FunctionBase< Number > *> &f) |
void | attach_exact_value (unsigned int sys_num, FunctionBase< Number > *f) |
void | attach_exact_value (ValueFunctionPointer fptr) |
void | attach_exact_derivs (const std::vector< FunctionBase< Gradient > *> &g) |
void | attach_exact_deriv (unsigned int sys_num, FunctionBase< Gradient > *g) |
void | attach_exact_deriv (GradientFunctionPointer gptr) |
void | attach_exact_hessians (std::vector< FunctionBase< Tensor > *> h) |
void | attach_exact_hessian (unsigned int sys_num, FunctionBase< Tensor > *h) |
void | attach_exact_hessian (HessianFunctionPointer hptr) |
void | extra_quadrature_order (const int extraorder) |
void | compute_error (const std::string &sys_name, const std::string &unknown_name) |
Real | l2_error (const std::string &sys_name, const std::string &unknown_name) |
Real | l1_error (const std::string &sys_name, const std::string &unknown_name) |
Real | l_inf_error (const std::string &sys_name, const std::string &unknown_name) |
Real | h1_error (const std::string &sys_name, const std::string &unknown_name) |
Real | hcurl_error (const std::string &sys_name, const std::string &unknown_name) |
Real | hdiv_error (const std::string &sys_name, const std::string &unknown_name) |
Real | h2_error (const std::string &sys_name, const std::string &unknown_name) |
Real | error_norm (const std::string &sys_name, const std::string &unknown_name, const FEMNormType &norm) |
Private Types | |
typedef std::map< std::string, std::vector< Real > > | SystemErrorMap |
Private Member Functions | |
template<typename OutputShape > | |
void | _compute_error (const std::string &sys_name, const std::string &unknown_name, std::vector< Real > &error_vals) |
std::vector< Real > & | _check_inputs (const std::string &sys_name, const std::string &unknown_name) |
Private Attributes | |
std::vector< std::unique_ptr< FunctionBase< Number > > > | _exact_values |
std::vector< std::unique_ptr< FunctionBase< Gradient > > > | _exact_derivs |
std::vector< std::unique_ptr< FunctionBase< Tensor > > > | _exact_hessians |
std::map< std::string, SystemErrorMap > | _errors |
const EquationSystems & | _equation_systems |
const EquationSystems * | _equation_systems_fine |
int | _extra_order |
This class handles the computation of the L2 and/or H1 error for the Systems in the EquationSystems object which is passed to it.
exact_value
and exact_deriv
functions below.Definition at line 72 of file exact_solution.h.
typedef Gradient(* libMesh::ExactSolution::GradientFunctionPointer) (const Point &p, const Parameters ¶meters, const std::string &sys_name, const std::string &unknown_name) |
Attach an arbitrary function which computes the exact gradient of the solution at any point.
Definition at line 148 of file exact_solution.h.
typedef Tensor(* libMesh::ExactSolution::HessianFunctionPointer) (const Point &p, const Parameters ¶meters, const std::string &sys_name, const std::string &unknown_name) |
Attach an arbitrary function which computes the exact second derivatives of the solution at any point.
Definition at line 171 of file exact_solution.h.
|
private |
Data structure which stores the errors: ||e|| = ||u - u_h|| ||grad(e)|| = ||grad(u) - grad(u_h)|| for each unknown in a single system. The name of the unknown is the key for the map.
Definition at line 336 of file exact_solution.h.
typedef Number(* libMesh::ExactSolution::ValueFunctionPointer) (const Point &p, const Parameters &Parameters, const std::string &sys_name, const std::string &unknown_name) |
Attach an arbitrary function which computes the exact value of the solution at any point.
Definition at line 125 of file exact_solution.h.
|
explicit |
Constructor. The ExactSolution object must be initialized with an EquationSystems object.
Definition at line 39 of file exact_solution.C.
References _equation_systems, _errors, libMesh::EquationSystems::get_system(), libMesh::EquationSystems::n_systems(), libMesh::System::n_vars(), libMesh::System::name(), and libMesh::System::variable_name().
|
delete |
The copy constructor and copy/move assignment operators are deleted. This class has containers of unique_ptrs so it can't be default (shallow) copied, and it has a const reference so it can't be assigned to after creation.
|
default |
Move constructor and destructor are defaulted out-of-line (in the C file) to play nicely with our forward declarations.
|
default |
|
private |
This function is responsible for checking the validity of the sys_name
and unknown_name
inputs.
Definition at line 208 of file exact_solution.C.
References _errors.
Referenced by compute_error(), error_norm(), h1_error(), h2_error(), l1_error(), l2_error(), and l_inf_error().
|
private |
This function computes the error (in the solution and its first derivative) for a single unknown in a single system. It is a private function since it is used by the implementation when solving for several unknowns in several systems.
Definition at line 455 of file exact_solution.C.
References _equation_systems, _equation_systems_fine, _exact_derivs, _exact_hessians, _exact_values, _extra_order, libMesh::MeshBase::active_local_element_ptr_range(), libMesh::Variable::active_on_subdomain(), libMesh::FEGenericBase< OutputType >::build(), libMesh::NumericVector< T >::build(), libMesh::ParallelObject::comm(), libMesh::TensorTools::curl_from_grad(), libMesh::System::current_solution(), libMesh::FEType::default_quadrature_rule(), libMesh::TensorTools::div_from_grad(), libMesh::DofMap::dof_indices(), libMesh::MeshBase::elem_dimensions(), libMesh::err, libMesh::FEInterface::field_type(), libMesh::FEGenericBase< OutputType >::get_curl_phi(), libMesh::FEGenericBase< OutputType >::get_d2phi(), libMesh::FEGenericBase< OutputType >::get_div_phi(), libMesh::System::get_dof_map(), libMesh::FEGenericBase< OutputType >::get_dphi(), libMesh::FEAbstract::get_JxW(), libMesh::System::get_mesh(), libMesh::FEGenericBase< OutputType >::get_phi(), libMesh::EquationSystems::get_system(), libMesh::FEAbstract::get_xyz(), libMesh::QBase::n_points(), libMesh::FEInterface::n_vec_dim(), libMesh::TensorTools::norm_sq(), libMesh::TypeVector< T >::norm_sq(), libMesh::System::number(), libMesh::Real, libMesh::FEAbstract::reinit(), libMesh::SERIAL, libMesh::System::solution, libMesh::TYPE_VECTOR, libMesh::System::update_global_solution(), libMesh::System::variable(), libMesh::System::variable_number(), libMesh::System::variable_scalar_number(), and libMesh::DofMap::variable_type().
void libMesh::ExactSolution::attach_exact_deriv | ( | unsigned int | sys_num, |
FunctionBase< Gradient > * | g | ||
) |
Clone and attach an arbitrary functor which computes the exact gradient of the system sys_num
solution at any point.
Definition at line 156 of file exact_solution.C.
References _exact_derivs, and libMesh::FunctionBase< Output >::clone().
void libMesh::ExactSolution::attach_exact_deriv | ( | GradientFunctionPointer | gptr | ) |
Definition at line 126 of file exact_solution.C.
References _equation_systems, _equation_systems_fine, _exact_derivs, libMesh::EquationSystems::get_system(), libMesh::EquationSystems::n_systems(), and libMesh::EquationSystems::parameters.
void libMesh::ExactSolution::attach_exact_derivs | ( | const std::vector< FunctionBase< Gradient > *> & | g | ) |
Clone and attach arbitrary functors which compute the exact gradients of the EquationSystems' solutions at any point.
Definition at line 145 of file exact_solution.C.
References _exact_derivs.
void libMesh::ExactSolution::attach_exact_hessian | ( | unsigned int | sys_num, |
FunctionBase< Tensor > * | h | ||
) |
Clone and attach an arbitrary functor which computes the exact second derivatives of the system sys_num
solution at any point.
Definition at line 197 of file exact_solution.C.
References _exact_hessians, and libMesh::FunctionBase< Output >::clone().
void libMesh::ExactSolution::attach_exact_hessian | ( | HessianFunctionPointer | hptr | ) |
Definition at line 167 of file exact_solution.C.
References _equation_systems, _equation_systems_fine, _exact_hessians, libMesh::EquationSystems::get_system(), libMesh::EquationSystems::n_systems(), and libMesh::EquationSystems::parameters.
void libMesh::ExactSolution::attach_exact_hessians | ( | std::vector< FunctionBase< Tensor > *> | h | ) |
Clone and attach arbitrary functors which compute the exact second derivatives of the EquationSystems' solutions at any point.
Definition at line 186 of file exact_solution.C.
References _exact_hessians.
void libMesh::ExactSolution::attach_exact_value | ( | unsigned int | sys_num, |
FunctionBase< Number > * | f | ||
) |
Clone and attach an arbitrary functor which computes the exact value of the system sys_num
solution at any point.
Definition at line 115 of file exact_solution.C.
References _exact_values, and libMesh::FunctionBase< Output >::clone().
void libMesh::ExactSolution::attach_exact_value | ( | ValueFunctionPointer | fptr | ) |
Definition at line 85 of file exact_solution.C.
References _equation_systems, _equation_systems_fine, _exact_values, libMesh::EquationSystems::get_system(), libMesh::EquationSystems::n_systems(), and libMesh::EquationSystems::parameters.
void libMesh::ExactSolution::attach_exact_values | ( | const std::vector< FunctionBase< Number > *> & | f | ) |
Clone and attach arbitrary functors which compute the exact values of the EquationSystems' solutions at any point.
Definition at line 104 of file exact_solution.C.
References _exact_values.
void libMesh::ExactSolution::attach_reference_solution | ( | const EquationSystems * | es_fine | ) |
Attach function similar to system.h which allows the user to attach a second EquationSystems object with a reference fine grid solution.
Definition at line 73 of file exact_solution.C.
References _equation_systems_fine, _exact_derivs, _exact_hessians, and _exact_values.
void libMesh::ExactSolution::compute_error | ( | const std::string & | sys_name, |
const std::string & | unknown_name | ||
) |
Computes and stores the error in the solution value e = u-u_h, the gradient grad(e) = grad(u) - grad(u_h), and possibly the hessian grad(grad(e)) = grad(grad(u)) - grad(grad(u_h)). Does not return any value. For that you need to call the l2_error(), h1_error() or h2_error() functions respectively.
Definition at line 234 of file exact_solution.C.
References _check_inputs(), _equation_systems, libMesh::FEInterface::field_type(), libMesh::EquationSystems::get_system(), libMesh::EquationSystems::has_system(), libMesh::TYPE_SCALAR, and libMesh::TYPE_VECTOR.
Real libMesh::ExactSolution::error_norm | ( | const std::string & | sys_name, |
const std::string & | unknown_name, | ||
const FEMNormType & | norm | ||
) |
sys_name
for the unknown unknown_name
.compute_error()
for that.Definition at line 271 of file exact_solution.C.
References _check_inputs(), _equation_systems, libMesh::FEInterface::field_type(), libMesh::EquationSystems::get_system(), libMesh::H1, libMesh::H1_SEMINORM, libMesh::H2, libMesh::H2_SEMINORM, libMesh::EquationSystems::has_system(), libMesh::HCURL, libMesh::HCURL_SEMINORM, libMesh::HDIV, libMesh::HDIV_SEMINORM, libMesh::L1, libMesh::L2, libMesh::L_INF, and libMesh::TYPE_SCALAR.
Referenced by hcurl_error(), and hdiv_error().
|
inline |
Increases or decreases the order of the quadrature rule used for numerical integration.
Definition at line 181 of file exact_solution.h.
References _extra_order.
Real libMesh::ExactSolution::h1_error | ( | const std::string & | sys_name, |
const std::string & | unknown_name | ||
) |
sys_name
for the unknown unknown_name
.compute_error()
for that. Definition at line 400 of file exact_solution.C.
References _check_inputs().
Real libMesh::ExactSolution::h2_error | ( | const std::string & | sys_name, |
const std::string & | unknown_name | ||
) |
sys_name
for the unknown unknown_name
.compute_error()
for that. Definition at line 432 of file exact_solution.C.
References _check_inputs().
Real libMesh::ExactSolution::hcurl_error | ( | const std::string & | sys_name, |
const std::string & | unknown_name | ||
) |
sys_name
for the unknown unknown_name
.compute_error()
for that.Definition at line 417 of file exact_solution.C.
References error_norm(), and libMesh::HCURL.
Real libMesh::ExactSolution::hdiv_error | ( | const std::string & | sys_name, |
const std::string & | unknown_name | ||
) |
sys_name
for the unknown unknown_name
.compute_error()
for that.Definition at line 424 of file exact_solution.C.
References error_norm(), and libMesh::HDIV.
Real libMesh::ExactSolution::l1_error | ( | const std::string & | sys_name, |
const std::string & | unknown_name | ||
) |
sys_name
for the unknown unknown_name
.compute_error()
for that. Definition at line 360 of file exact_solution.C.
References _check_inputs().
Real libMesh::ExactSolution::l2_error | ( | const std::string & | sys_name, |
const std::string & | unknown_name | ||
) |
sys_name
for the unknown unknown_name
.compute_error()
for that. Definition at line 340 of file exact_solution.C.
References _check_inputs().
Real libMesh::ExactSolution::l_inf_error | ( | const std::string & | sys_name, |
const std::string & | unknown_name | ||
) |
sys_name
for the unknown unknown_name
.Definition at line 380 of file exact_solution.C.
References _check_inputs().
|
delete |
|
delete |
|
private |
Constant reference to the EquationSystems
object used for the simulation.
Definition at line 350 of file exact_solution.h.
Referenced by _compute_error(), attach_exact_deriv(), attach_exact_hessian(), attach_exact_value(), compute_error(), error_norm(), and ExactSolution().
|
private |
Constant pointer to the EquationSystems
object containing the fine grid solution.
Definition at line 356 of file exact_solution.h.
Referenced by _compute_error(), attach_exact_deriv(), attach_exact_hessian(), attach_exact_value(), and attach_reference_solution().
|
private |
A map of SystemErrorMaps, which contains entries for each system in the EquationSystems object. This is required, since it is possible for two systems to have unknowns with the same name.
Definition at line 344 of file exact_solution.h.
Referenced by _check_inputs(), and ExactSolution().
|
private |
User-provided functors which compute the exact derivative of the solution for each system.
Definition at line 320 of file exact_solution.h.
Referenced by _compute_error(), attach_exact_deriv(), attach_exact_derivs(), and attach_reference_solution().
|
private |
User-provided functors which compute the exact hessians of the solution for each system.
Definition at line 326 of file exact_solution.h.
Referenced by _compute_error(), attach_exact_hessian(), attach_exact_hessians(), and attach_reference_solution().
|
private |
User-provided functors which compute the exact value of the solution for each system.
Definition at line 314 of file exact_solution.h.
Referenced by _compute_error(), attach_exact_value(), attach_exact_values(), and attach_reference_solution().
|
private |
Extra order to use for quadrature rule
Definition at line 361 of file exact_solution.h.
Referenced by _compute_error(), and extra_quadrature_order().