Loading [MathJax]/jax/output/HTML-CSS/config.js
libMesh
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
exact_error_estimator.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2025 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 
165  void extra_quadrature_order (const int extraorder)
166  { _extra_order = extraorder; }
167 
168  // Bring the base class functionality into the name lookup
169  // procedure. This allows for alternative calling formats
170  // defined in the base class. Thanks Wolfgang.
171  // GCC 2.95.3 cannot compile such code. Since it was not really
172  // essential to the functioning of this class, it's been removed.
173  // using ErrorEstimator::estimate_error;
174 
181  virtual void estimate_error (const System & system,
182  ErrorVector & error_per_cell,
183  const NumericVector<Number> * solution_vector = nullptr,
184  bool estimate_parent_error = false) override;
185 
186  virtual ErrorEstimatorType type() const override;
187 
188 private:
189 
195 
201 
207 
212  std::vector<std::unique_ptr<FunctionBase<Number>>> _exact_values;
213 
218  std::vector<std::unique_ptr<FunctionBase<Gradient>>> _exact_derivs;
219 
224  std::vector<std::unique_ptr<FunctionBase<Tensor>>> _exact_hessians;
225 
231 
235  Real find_squared_element_error (const System & system,
236  const std::string & var_name,
237  const Elem * elem,
238  const DenseVector<Number> & Uelem,
239  FEBase * fe,
240  MeshFunction * fine_values) const;
241 
245  void clear_functors ();
246 
251 };
252 
253 
254 } // namespace libMesh
255 
256 #endif // LIBMESH_EXACT_ERROR_ESTIMATOR_H
HessianFunctionPointer _exact_hessian
Function pointer to user-provided function which computes the exact hessian of the solution...
This is the EquationSystems class.
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...
This class provides the ability to map between arbitrary, user-defined strings and several data types...
Definition: parameters.h:67
std::vector< std::unique_ptr< FunctionBase< Tensor > > > _exact_hessians
User-provided functors which compute the exact hessians of the solution for each system.
int _extra_order
Extra order to use for quadrature rule.
The ErrorVector is a specialization of the StatisticsVector for error data computed on a finite eleme...
Definition: error_vector.h:50
ErrorEstimatorType
Defines an enum for the different types of error estimators which are available.
void attach_exact_hessians(std::vector< FunctionBase< Tensor > *> h)
Clone and attach arbitrary functors which compute the exact second derivatives of the EquationSystems...
This is the base class from which all geometric element types are derived.
Definition: elem.h:94
void extra_quadrature_order(const int extraorder)
Increases or decreases the order of the quadrature rule used for numerical integration.
The libMesh namespace provides an interface to certain functionality in the library.
ValueFunctionPointer _exact_value
Function pointer to user-provided function which computes the exact value of the solution.
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...
std::vector< std::unique_ptr< FunctionBase< Gradient > > > _exact_derivs
User-provided functors which compute the exact derivative of the solution for each system...
Number fptr(const Point &p, const Parameters &, const std::string &libmesh_dbg_var(sys_name), const std::string &unknown_name)
Definition: projection.C:80
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.
virtual ErrorEstimatorType type() const override
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...
virtual ~ExactErrorEstimator()=default
Manages consistently variables, degrees of freedom, and coefficient vectors.
Definition: system.h:96
NumberVectorValue Gradient
This class holds functions that will estimate the error in a finite element solution on a given mesh...
void clear_functors()
Helper method for cleanup.
FEGenericBase< Real > FEBase
void attach_exact_derivs(std::vector< FunctionBase< Gradient > *> g)
Clone and attach arbitrary functors which compute the exact gradients of the EquationSystems&#39; solutio...
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...
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
GradientFunctionPointer _exact_deriv
Function pointer to user-provided function which computes the exact derivative of the solution...
EquationSystems * _equation_systems_fine
Constant pointer to the EquationSystems object containing a fine grid solution.
NumberTensorValue Tensor
This class implements an "error estimator" based on the difference between the approximate and exact ...
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...
Gradient gptr(const Point &p, const Parameters &, const std::string &libmesh_dbg_var(sys_name), const std::string &unknown_name)
Definition: projection.C:95
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.
void attach_exact_values(std::vector< FunctionBase< Number > *> f)
Clone and attach arbitrary functors which compute the exact values of the EquationSystems&#39; solutions ...
Defines a dense vector for use in Finite Element-type computations.
Definition: dof_map.h:73
This class provides function-like objects for data distributed over a mesh.
Definition: mesh_function.h:54
void attach_reference_solution(EquationSystems *es_fine)
Attach function similar to system.h which allows the user to attach a second EquationSystems object w...
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...
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition: point.h:39
ExactErrorEstimator & operator=(const ExactErrorEstimator &)=delete
std::vector< std::unique_ptr< FunctionBase< Number > > > _exact_values
User-provided functors which compute the exact value of the solution for each system.
This class forms the foundation from which generic finite elements may be derived.