libMesh
Loading...
Searching...
No Matches
exact_error_estimator.h
Go to the documentation of this file.
1// The libMesh Finite Element Library.
2// Copyright (C) 2002-2026 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
34namespace libMesh
35{
36
37// Forward Declarations
38class Elem;
39template <typename T> class FEGenericBase;
41class MeshFunction;
42class Point;
43class Parameters;
44template <typename T> class DenseVector;
45
58{
59public:
60
66
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
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
188private:
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
Defines a dense vector for use in Finite Element-type computations.
This is the base class from which all geometric element types are derived.
Definition elem.h:96
This is the EquationSystems class.
This class holds functions that will estimate the error in a finite element solution on a given mesh.
The ErrorVector is a specialization of the StatisticsVector for error data computed on a finite eleme...
This class implements an "error estimator" based on the difference between the approximate and exact ...
void attach_exact_hessians(std::vector< FunctionBase< Tensor > * > h)
Clone and attach arbitrary functors which compute the exact second derivatives of the EquationSystems...
ExactErrorEstimator & operator=(const ExactErrorEstimator &)=delete
void extra_quadrature_order(const int extraorder)
Increases or decreases the order of the quadrature rule used for numerical integration.
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
void attach_exact_derivs(std::vector< FunctionBase< Gradient > * > g)
Clone and attach arbitrary functors which compute the exact gradients of the EquationSystems' solutio...
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.
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...
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...
EquationSystems * _equation_systems_fine
Constant pointer to the EquationSystems object containing a fine grid solution.
void attach_exact_values(std::vector< FunctionBase< Number > * > f)
Clone and attach arbitrary functors which compute the exact values of the EquationSystems' solutions ...
std::vector< std::unique_ptr< FunctionBase< Tensor > > > _exact_hessians
User-provided functors which compute the exact hessians of the solution for each system.
void clear_functors()
Helper method for cleanup.
std::vector< std::unique_ptr< FunctionBase< Number > > > _exact_values
User-provided functors which compute the exact value of the solution for each system.
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...
void attach_reference_solution(EquationSystems *es_fine)
Attach function similar to system.h which allows the user to attach a second EquationSystems object w...
virtual ~ExactErrorEstimator()=default
GradientFunctionPointer _exact_deriv
Function pointer to user-provided function which computes the exact derivative of the solution.
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...
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.
ExactErrorEstimator(const ExactErrorEstimator &)=delete
This class cannot be (default) copy constructed/assigned because it has containers of unique_ptrs.
std::vector< std::unique_ptr< FunctionBase< Gradient > > > _exact_derivs
User-provided functors which compute the exact derivative of the solution for each system.
int _extra_order
Extra order to use for quadrature rule.
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.
HessianFunctionPointer _exact_hessian
Function pointer to user-provided function which computes the exact hessian of the solution.
ExactErrorEstimator(ExactErrorEstimator &&)=default
Defaulted move ctor, move assignment operator, and destructor.
ValueFunctionPointer _exact_value
Function pointer to user-provided function which computes the exact value of the solution.
This class forms the foundation from which generic finite elements may be derived.
Definition fe_base.h:86
Base class for functors that can be evaluated at a point and (optionally) time.
This class provides function-like objects for data distributed over a mesh.
Provides a uniform interface to vector storage schemes for different linear algebra libraries.
This class provides the ability to map between arbitrary, user-defined strings and several data types...
Definition parameters.h:75
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition point.h:40
Manages consistently variables, degrees of freedom, and coefficient vectors.
Definition system.h:100
The libMesh namespace provides an interface to certain functionality in the library.
ErrorEstimatorType
Defines an enum for the different types of error estimators which are available.
NumberVectorValue Gradient
NumberTensorValue Tensor
FEGenericBase< Real > FEBase
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Gradient gptr(const Point &p, const Parameters &, const std::string &libmesh_dbg_var(sys_name), const std::string &unknown_name)
Definition projection.C:96
Number fptr(const Point &p, const Parameters &, const std::string &libmesh_dbg_var(sys_name), const std::string &unknown_name)
Definition projection.C:81