libMesh
exact_error_estimator.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2019 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License, or (at your option) any later version.
8 
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
13 
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 
18 
19 
20 #ifndef LIBMESH_EXACT_ERROR_ESTIMATOR_H
21 #define LIBMESH_EXACT_ERROR_ESTIMATOR_H
22 
23 // Local Includes
24 #include "libmesh/error_estimator.h"
25 #include "libmesh/function_base.h"
26 #include "libmesh/vector_value.h"
27 #include "libmesh/tensor_value.h"
28 
29 // C++ includes
30 #include <cstddef>
31 #include <string>
32 #include <vector>
33 
34 namespace libMesh
35 {
36 
37 // Forward Declarations
38 class Elem;
39 template <typename T> class FEGenericBase;
41 class MeshFunction;
42 class Point;
43 class Parameters;
44 template <typename T> class DenseVector;
45 
58 {
59 public:
60 
66 
72  ExactErrorEstimator (const ExactErrorEstimator &) = delete;
74 
80  virtual ~ExactErrorEstimator() = default;
81 
86  void attach_exact_values (std::vector<FunctionBase<Number> *> f);
87 
92  void attach_exact_value (unsigned int sys_num,
94 
99  typedef Number (*ValueFunctionPointer)(const Point & p,
100  const Parameters & Parameters,
101  const std::string & sys_name,
102  const std::string & unknown_name);
104 
109  void attach_exact_derivs (std::vector<FunctionBase<Gradient> *> g);
110 
115  void attach_exact_deriv (unsigned int sys_num,
117 
122  typedef Gradient (*GradientFunctionPointer)(const Point & p,
123  const Parameters & parameters,
124  const std::string & sys_name,
125  const std::string & unknown_name);
127 
132  void attach_exact_hessians (std::vector<FunctionBase<Tensor> *> h);
133 
138  void attach_exact_hessian (unsigned int sys_num,
140 
145  typedef Tensor (*HessianFunctionPointer)(const Point & p,
146  const Parameters & parameters,
147  const std::string & sys_name,
148  const std::string & unknown_name);
150 
157 
158 
163  void extra_quadrature_order (const int extraorder)
164  { _extra_order = extraorder; }
165 
166 
167  // Bring the base class functionality into the name lookup
168  // procedure. This allows for alternative calling formats
169  // defined in the base class. Thanks Wolfgang.
170  // GCC 2.95.3 cannot compile such code. Since it was not really
171  // essential to the functioning of this class, it's been removed.
172  // using ErrorEstimator::estimate_error;
173 
180  virtual void estimate_error (const System & system,
181  ErrorVector & error_per_cell,
182  const NumericVector<Number> * solution_vector = nullptr,
183  bool estimate_parent_error = false) override;
184 
185  virtual ErrorEstimatorType type() const override;
186 
187 private:
188 
194 
200 
206 
211  std::vector<std::unique_ptr<FunctionBase<Number>>> _exact_values;
212 
217  std::vector<std::unique_ptr<FunctionBase<Gradient>>> _exact_derivs;
218 
223  std::vector<std::unique_ptr<FunctionBase<Tensor>>> _exact_hessians;
224 
230 
234  Real find_squared_element_error (const System & system,
235  const std::string & var_name,
236  const Elem * elem,
237  const DenseVector<Number> & Uelem,
238  FEBase * fe,
239  MeshFunction * fine_values) const;
240 
244  void clear_functors ();
245 
250 };
251 
252 
253 } // namespace libMesh
254 
255 #endif // LIBMESH_EXACT_ERROR_ESTIMATOR_H
libMesh::ExactErrorEstimator::_exact_deriv
GradientFunctionPointer _exact_deriv
Function pointer to user-provided function which computes the exact derivative of the solution.
Definition: exact_error_estimator.h:199
libMesh::System
Manages consistently variables, degrees of freedom, and coefficient vectors.
Definition: system.h:100
libMesh::Number
Real Number
Definition: libmesh_common.h:195
libMesh::ExactErrorEstimator::attach_reference_solution
void attach_reference_solution(EquationSystems *es_fine)
Attach function similar to system.h which allows the user to attach a second EquationSystems object w...
Definition: exact_error_estimator.C:174
libMesh::FunctionBase< Number >
libMesh::ExactErrorEstimator::_exact_derivs
std::vector< std::unique_ptr< FunctionBase< Gradient > > > _exact_derivs
User-provided functors which compute the exact derivative of the solution for each system.
Definition: exact_error_estimator.h:217
libMesh::ExactErrorEstimator::GradientFunctionPointer
Gradient(* GradientFunctionPointer)(const Point &p, const Parameters &parameters, 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: exact_error_estimator.h:122
libMesh::ErrorEstimatorType
ErrorEstimatorType
Defines an enum for the different types of error estimators which are available.
Definition: enum_error_estimator_type.h:33
libMesh::ExactErrorEstimator::extra_quadrature_order
void extra_quadrature_order(const int extraorder)
Increases or decreases the order of the quadrature rule used for numerical integration.
Definition: exact_error_estimator.h:163
libMesh::MeshFunction
This class provides function-like objects for data distributed over a mesh.
Definition: mesh_function.h:53
libMesh::ExactErrorEstimator::ValueFunctionPointer
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.
Definition: exact_error_estimator.h:99
libMesh::ErrorEstimator
This class holds functions that will estimate the error in a finite element solution on a given mesh.
Definition: error_estimator.h:67
libMesh
The libMesh namespace provides an interface to certain functionality in the library.
Definition: factoryfunction.C:55
libMesh::ExactErrorEstimator::attach_exact_deriv
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 solutio...
Definition: exact_error_estimator.C:126
libMesh::FEGenericBase
This class forms the foundation from which generic finite elements may be derived.
Definition: exact_error_estimator.h:39
libMesh::ExactErrorEstimator::_exact_hessians
std::vector< std::unique_ptr< FunctionBase< Tensor > > > _exact_hessians
User-provided functors which compute the exact hessians of the solution for each system.
Definition: exact_error_estimator.h:223
libMesh::ExactErrorEstimator::_extra_order
int _extra_order
Extra order to use for quadrature rule.
Definition: exact_error_estimator.h:249
libMesh::ExactErrorEstimator::_exact_value
ValueFunctionPointer _exact_value
Function pointer to user-provided function which computes the exact value of the solution.
Definition: exact_error_estimator.h:193
libMesh::ExactErrorEstimator::ExactErrorEstimator
ExactErrorEstimator()
Constructor.
Definition: exact_error_estimator.C:49
libMesh::NumericVector< Number >
libMesh::ExactErrorEstimator::operator=
ExactErrorEstimator & operator=(const ExactErrorEstimator &)=delete
libMesh::ExactErrorEstimator::estimate_error
virtual void estimate_error(const System &system, ErrorVector &error_per_cell, const NumericVector< Number > *solution_vector=nullptr, bool estimate_parent_error=false) override
This function uses the exact solution function to estimate the error on each cell.
Definition: exact_error_estimator.C:188
libMesh::ExactErrorEstimator::find_squared_element_error
Real find_squared_element_error(const System &system, const std::string &var_name, const Elem *elem, const DenseVector< Number > &Uelem, FEBase *fe, MeshFunction *fine_values) const
Helper method for calculating on each element.
Definition: exact_error_estimator.C:402
libMesh::ExactErrorEstimator::type
virtual ErrorEstimatorType type() const override
Definition: exact_error_estimator.C:61
libMesh::FEBase
FEGenericBase< Real > FEBase
Definition: exact_error_estimator.h:39
libMesh::ExactErrorEstimator::~ExactErrorEstimator
virtual ~ExactErrorEstimator()=default
libMesh::Point
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition: point.h:38
libMesh::ErrorVector
The ErrorVector is a specialization of the StatisticsVector for error data computed on a finite eleme...
Definition: error_vector.h:50
libMesh::ExactErrorEstimator::_equation_systems_fine
EquationSystems * _equation_systems_fine
Constant pointer to the EquationSystems object containing a fine grid solution.
Definition: exact_error_estimator.h:229
libMesh::ExactErrorEstimator::attach_exact_hessians
void attach_exact_hessians(std::vector< FunctionBase< Tensor > * > h)
Clone and attach arbitrary functors which compute the exact second derivatives of the EquationSystems...
Definition: exact_error_estimator.C:152
gptr
Gradient gptr(const Point &p, const Parameters &, const std::string &libmesh_dbg_var(sys_name), const std::string &unknown_name)
Definition: projection.C:95
libMesh::ExactErrorEstimator::attach_exact_hessian
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_n...
Definition: exact_error_estimator.C:163
libMesh::EquationSystems
This is the EquationSystems class.
Definition: equation_systems.h:74
libMesh::ExactErrorEstimator::_exact_values
std::vector< std::unique_ptr< FunctionBase< Number > > > _exact_values
User-provided functors which compute the exact value of the solution for each system.
Definition: exact_error_estimator.h:211
libMesh::ExactErrorEstimator::_exact_hessian
HessianFunctionPointer _exact_hessian
Function pointer to user-provided function which computes the exact hessian of the solution.
Definition: exact_error_estimator.h:205
libMesh::Gradient
NumberVectorValue Gradient
Definition: exact_solution.h:58
libMesh::ExactErrorEstimator::clear_functors
void clear_functors()
Helper method for cleanup.
Definition: exact_error_estimator.C:535
libMesh::ExactErrorEstimator::attach_exact_value
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 a...
Definition: exact_error_estimator.C:91
libMesh::ExactErrorEstimator
This class implements an "error estimator" based on the difference between the approximate and exact ...
Definition: exact_error_estimator.h:57
libMesh::Elem
This is the base class from which all geometric element types are derived.
Definition: elem.h:100
libMesh::ExactErrorEstimator::attach_exact_values
void attach_exact_values(std::vector< FunctionBase< Number > * > f)
Clone and attach arbitrary functors which compute the exact values of the EquationSystems' solutions ...
Definition: exact_error_estimator.C:80
libMesh::ExactErrorEstimator::attach_exact_derivs
void attach_exact_derivs(std::vector< FunctionBase< Gradient > * > g)
Clone and attach arbitrary functors which compute the exact gradients of the EquationSystems' solutio...
Definition: exact_error_estimator.C:115
libMesh::Real
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Definition: libmesh_common.h:121
libMesh::Tensor
NumberTensorValue Tensor
Definition: exact_solution.h:56
fptr
Number fptr(const Point &p, const Parameters &, const std::string &libmesh_dbg_var(sys_name), const std::string &unknown_name)
Definition: projection.C:80
libMesh::ExactErrorEstimator::HessianFunctionPointer
Tensor(* HessianFunctionPointer)(const Point &p, const Parameters &parameters, 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: exact_error_estimator.h:145
libMesh::Parameters
This class provides the ability to map between arbitrary, user-defined strings and several data types...
Definition: parameters.h:59
libMesh::DenseVector
Defines a dense vector for use in Finite Element-type computations.
Definition: meshless_interpolation_function.h:39