exact_error_estimator.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2018 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
25 #include "libmesh/function_base.h"
26 
27 // C++ includes
28 #include <cstddef>
29 #include <string>
30 #include <vector>
31 
32 namespace libMesh
33 {
34 
35 // Forward Declarations
36 class Elem;
37 template <typename T> class FEGenericBase;
39 class MeshFunction;
40 class Point;
41 class Parameters;
42 
43 template <typename T> class DenseVector;
44 
45 // Is there any way to simplify this?
46 // All we need are Tensor and Gradient. - RHS
47 template <typename T> class TensorValue;
48 template <typename T> class VectorValue;
50 typedef NumberTensorValue Tensor;
52 typedef NumberVectorValue Gradient;
53 
54 
55 
68 {
69 public:
70 
81  _extra_order(0)
82  { error_norm = H1; }
83 
88 
93  void attach_exact_values (std::vector<FunctionBase<Number> *> f);
94 
99  void attach_exact_value (unsigned int sys_num,
101 
106  typedef Number (*ValueFunctionPointer)(const Point & p,
107  const Parameters & Parameters,
108  const std::string & sys_name,
109  const std::string & unknown_name);
111 
116  void attach_exact_derivs (std::vector<FunctionBase<Gradient> *> g);
117 
122  void attach_exact_deriv (unsigned int sys_num,
124 
129  typedef Gradient (*GradientFunctionPointer)(const Point & p,
130  const Parameters & parameters,
131  const std::string & sys_name,
132  const std::string & unknown_name);
134 
139  void attach_exact_hessians (std::vector<FunctionBase<Tensor> *> h);
140 
145  void attach_exact_hessian (unsigned int sys_num,
147 
152  typedef Tensor (*HessianFunctionPointer)(const Point & p,
153  const Parameters & parameters,
154  const std::string & sys_name,
155  const std::string & unknown_name);
157 
164 
165 
170  void extra_quadrature_order (const int extraorder)
171  { _extra_order = extraorder; }
172 
173 
174  // Bring the base class functionality into the name lookup
175  // procedure. This allows for alternative calling formats
176  // defined in the base class. Thanks Wolfgang.
177  // GCC 2.95.3 cannot compile such code. Since it was not really
178  // essential to the functioning of this class, it's been removed.
179  // using ErrorEstimator::estimate_error;
180 
187  virtual void estimate_error (const System & system,
188  ErrorVector & error_per_cell,
189  const NumericVector<Number> * solution_vector = libmesh_nullptr,
190  bool estimate_parent_error = false) libmesh_override;
191 
192  virtual ErrorEstimatorType type() const libmesh_override
193  { return EXACT;}
194 
195 private:
196 
201  Number (* _exact_value) (const Point & p,
202  const Parameters & parameters,
203  const std::string & sys_name,
204  const std::string & unknown_name);
205 
210  Gradient (* _exact_deriv) (const Point & p,
211  const Parameters & parameters,
212  const std::string & sys_name,
213  const std::string & unknown_name);
214 
219  Tensor (* _exact_hessian) (const Point & p,
220  const Parameters & parameters,
221  const std::string & sys_name,
222  const std::string & unknown_name);
223 
228  std::vector<std::unique_ptr<FunctionBase<Number>>> _exact_values;
229 
234  std::vector<std::unique_ptr<FunctionBase<Gradient>>> _exact_derivs;
235 
240  std::vector<std::unique_ptr<FunctionBase<Tensor>>> _exact_hessians;
241 
247 
251  Real find_squared_element_error (const System & system,
252  const std::string & var_name,
253  const Elem * elem,
254  const DenseVector<Number> & Uelem,
255  FEBase * fe,
256  MeshFunction * fine_values) const;
257 
261  void clear_functors ();
262 
267 };
268 
269 
270 } // namespace libMesh
271 
272 #endif // LIBMESH_EXACT_ERROR_ESTIMATOR_H
void attach_exact_derivs(std::vector< FunctionBase< Gradient > * > g)
Manages multiples systems of equations.
void attach_exact_hessian(unsigned int sys_num, FunctionBase< Tensor > *h)
Number(* _exact_value)(const Point &p, const Parameters &parameters, const std::string &sys_name, const std::string &unknown_name)
std::vector< std::unique_ptr< FunctionBase< Tensor > > > _exact_hessians
void attach_exact_hessians(std::vector< FunctionBase< Tensor > * > h)
The base class for all geometric element types.
Definition: elem.h:90
const class libmesh_nullptr_t libmesh_nullptr
void extra_quadrature_order(const int extraorder)
void attach_exact_value(unsigned int sys_num, FunctionBase< Number > *f)
std::vector< std::unique_ptr< FunctionBase< Gradient > > > _exact_derivs
TensorValue< Number > NumberTensorValue
Tensor(* HessianFunctionPointer)(const Point &p, const Parameters &parameters, const std::string &sys_name, const std::string &unknown_name)
NumberVectorValue Gradient
virtual ErrorEstimatorType type() const libmesh_override
FEGenericBase< Real > FEBase
Gradient(* GradientFunctionPointer)(const Point &p, const Parameters &parameters, const std::string &sys_name, const std::string &unknown_name)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Tensor(* _exact_hessian)(const Point &p, const Parameters &parameters, const std::string &sys_name, const std::string &unknown_name)
NumberTensorValue Tensor
Number(* ValueFunctionPointer)(const Point &p, const Parameters &Parameters, const std::string &sys_name, const std::string &unknown_name)
void attach_exact_values(std::vector< FunctionBase< Number > * > f)
virtual void estimate_error(const System &system, ErrorVector &error_per_cell, const NumericVector< Number > *solution_vector=libmesh_nullptr, bool estimate_parent_error=false) libmesh_override
void attach_reference_solution(EquationSystems *es_fine)
void attach_exact_deriv(unsigned int sys_num, FunctionBase< Gradient > *g)
VectorValue< Number > NumberVectorValue
Gradient(* _exact_deriv)(const Point &p, const Parameters &parameters, const std::string &sys_name, const std::string &unknown_name)
A geometric point in (x,y,z) space.
Definition: point.h:38
std::vector< std::unique_ptr< FunctionBase< Number > > > _exact_values
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