libMesh
|
This class handles the computation of the L2 and/or H1 error for the Systems in the EquationSystems object which is passed to it. More...
#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) |
Attach an arbitrary function which computes the exact value of the solution at any point. More... | |
typedef Gradient(* | 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. More... | |
typedef Tensor(* | 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. More... | |
Public Member Functions | |
ExactSolution (const EquationSystems &es) | |
Constructor. More... | |
ExactSolution (const ExactSolution &)=delete | |
The copy constructor and copy/move assignment operators are deleted. More... | |
ExactSolution & | operator= (const ExactSolution &)=delete |
ExactSolution & | operator= (ExactSolution &&)=delete |
ExactSolution (ExactSolution &&) | |
Move constructor and destructor are defaulted out-of-line (in the C file) to play nicely with our forward declarations. More... | |
~ExactSolution () | |
void | set_excluded_subdomains (const std::set< subdomain_id_type > &excluded) |
The user can indicate that elements in certain subdomains should be excluded from the error calculation by passing in a set of subdomain ids to ignore. More... | |
void | 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. More... | |
void | 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. More... | |
void | 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. More... | |
void | attach_exact_value (ValueFunctionPointer fptr) |
void | 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. More... | |
void | 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. More... | |
void | attach_exact_deriv (GradientFunctionPointer gptr) |
void | 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. More... | |
void | 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. More... | |
void | attach_exact_hessian (HessianFunctionPointer hptr) |
void | extra_quadrature_order (const int extraorder) |
Increases or decreases the order of the quadrature rule used for numerical integration. More... | |
void | 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)). More... | |
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 |
Data structure which stores the errors: ||e|| = ||u - u_h|| ||grad(e)|| = ||grad(u) - grad(u_h)|| for each unknown in a single system. More... | |
Private Member Functions | |
template<typename OutputShape > | |
void | _compute_error (const std::string &sys_name, const std::string &unknown_name, std::vector< Real > &error_vals) |
This function computes the error (in the solution and its first derivative) for a single unknown in a single system. More... | |
std::vector< Real > & | _check_inputs (const std::string &sys_name, const std::string &unknown_name) |
This function is responsible for checking the validity of the sys_name and unknown_name inputs. More... | |
Private Attributes | |
std::vector< std::unique_ptr< FunctionBase< Number > > > | _exact_values |
User-provided functors which compute the exact value of the solution for each system. More... | |
std::vector< std::unique_ptr< FunctionBase< Gradient > > > | _exact_derivs |
User-provided functors which compute the exact derivative of the solution for each system. More... | |
std::vector< std::unique_ptr< FunctionBase< Tensor > > > | _exact_hessians |
User-provided functors which compute the exact hessians of the solution for each system. More... | |
std::map< std::string, SystemErrorMap > | _errors |
A map of SystemErrorMaps, which contains entries for each system in the EquationSystems object. More... | |
const EquationSystems & | _equation_systems |
Constant reference to the EquationSystems object used for the simulation. More... | |
const EquationSystems * | _equation_systems_fine |
Constant pointer to the EquationSystems object containing the fine grid solution. More... | |
int | _extra_order |
Extra order to use for quadrature rule. More... | |
std::set< subdomain_id_type > | _excluded_subdomains |
Elements in a subdomain from this set are skipped during the error computation. More... | |
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 73 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 157 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 180 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 345 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 134 of file exact_solution.h.
|
explicit |
Constructor.
The ExactSolution object must be initialized with an EquationSystems object.
Definition at line 41 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 216 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 448 of file exact_solution.C.
References _equation_systems, _equation_systems_fine, _exact_derivs, _exact_hessians, _exact_values, _excluded_subdomains, _extra_order, 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(), dim, libMesh::TensorTools::div_from_grad(), libMesh::DofMap::dof_indices(), libMesh::err, exact_grad(), libMesh::FEInterface::field_type(), libMesh::ReferenceElem::get(), 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::libmesh_assert(), mesh, libMesh::QBase::n_points(), libMesh::FEInterface::n_vec_dim(), std::norm(), libMesh::TensorTools::norm_sq(), libMesh::TypeVector< T >::norm_sq(), libMesh::System::number(), libMesh::Real, libMesh::FEAbstract::reinit(), libMesh::SERIAL, libMesh::System::solution, std::sqrt(), 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 | ( | GradientFunctionPointer | gptr | ) |
Definition at line 134 of file exact_solution.C.
References _equation_systems, _equation_systems_fine, _exact_derivs, libMesh::EquationSystems::get_system(), gptr(), libMesh::libmesh_assert(), libMesh::EquationSystems::n_systems(), and libMesh::EquationSystems::parameters.
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 164 of file exact_solution.C.
References _exact_derivs, and libMesh::FunctionBase< Output >::clone().
Referenced by main().
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 153 of file exact_solution.C.
References _exact_derivs.
Referenced by main().
void libMesh::ExactSolution::attach_exact_hessian | ( | HessianFunctionPointer | hptr | ) |
Definition at line 175 of file exact_solution.C.
References _equation_systems, _equation_systems_fine, _exact_hessians, libMesh::EquationSystems::get_system(), libMesh::libmesh_assert(), libMesh::EquationSystems::n_systems(), and libMesh::EquationSystems::parameters.
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 205 of file exact_solution.C.
References _exact_hessians, and libMesh::FunctionBase< Output >::clone().
Referenced by main().
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 194 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 123 of file exact_solution.C.
References _exact_values, and libMesh::FunctionBase< Output >::clone().
Referenced by main().
void libMesh::ExactSolution::attach_exact_value | ( | ValueFunctionPointer | fptr | ) |
Definition at line 93 of file exact_solution.C.
References _equation_systems, _equation_systems_fine, _exact_values, fptr(), libMesh::EquationSystems::get_system(), libMesh::libmesh_assert(), 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 112 of file exact_solution.C.
References _exact_values.
Referenced by main().
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 81 of file exact_solution.C.
References _equation_systems_fine, _exact_derivs, _exact_hessians, _exact_values, and libMesh::libmesh_assert().
Referenced by main().
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 227 of file exact_solution.C.
References _check_inputs(), _equation_systems, libMesh::FEInterface::field_type(), libMesh::EquationSystems::get_system(), libMesh::EquationSystems::has_system(), libMesh::libmesh_assert(), libMesh::TYPE_SCALAR, and libMesh::TYPE_VECTOR.
Referenced by main().
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 264 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, libMesh::libmesh_assert(), std::norm(), std::sqrt(), and libMesh::TYPE_SCALAR.
Referenced by hcurl_error(), hdiv_error(), and main().
|
inline |
Increases or decreases the order of the quadrature rule used for numerical integration.
Definition at line 190 of file exact_solution.h.
References _extra_order.
Referenced by main().
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 393 of file exact_solution.C.
References _check_inputs(), and std::sqrt().
Referenced by main().
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 425 of file exact_solution.C.
References _check_inputs(), and std::sqrt().
Referenced by main().
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 410 of file exact_solution.C.
References error_norm(), and libMesh::HCURL.
Referenced by main().
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 417 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 353 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 333 of file exact_solution.C.
References _check_inputs(), and std::sqrt().
Referenced by main().
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 373 of file exact_solution.C.
References _check_inputs().
|
delete |
|
delete |
void libMesh::ExactSolution::set_excluded_subdomains | ( | const std::set< subdomain_id_type > & | excluded | ) |
The user can indicate that elements in certain subdomains should be excluded from the error calculation by passing in a set of subdomain ids to ignore.
By default, all subdomains are considered in the error calculation.
Definition at line 76 of file exact_solution.C.
References _excluded_subdomains.
|
private |
Constant reference to the EquationSystems
object used for the simulation.
Definition at line 359 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 365 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 353 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 329 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 335 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 323 of file exact_solution.h.
Referenced by _compute_error(), attach_exact_value(), attach_exact_values(), and attach_reference_solution().
|
private |
Elements in a subdomain from this set are skipped during the error computation.
Definition at line 376 of file exact_solution.h.
Referenced by _compute_error(), and set_excluded_subdomains().
|
private |
Extra order to use for quadrature rule.
Definition at line 370 of file exact_solution.h.
Referenced by _compute_error(), and extra_quadrature_order().