exact_solution.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 #ifndef LIBMESH_EXACT_SOLUTION_H
19 #define LIBMESH_EXACT_SOLUTION_H
20 
21 
22 // Local Includes
23 #include "libmesh/libmesh_common.h" // for Number
24 
25 #ifdef LIBMESH_FORWARD_DECLARE_ENUMS
26 namespace libMesh
27 {
28 enum FEMNormType : int;
29 }
30 #else
31 #include "libmesh/enum_norm_type.h"
32 #endif
33 
34 // C++ includes
35 #include <map>
36 #include <vector>
37 #include <memory>
38 
39 namespace libMesh
40 {
41 
42 
43 // Forward Declarations
44 class Point;
45 class EquationSystems;
46 class Parameters;
47 class Mesh;
48 template <typename Output> class FunctionBase;
49 
50 // Is there any way to simplify this?
51 // All we need are Tensor and Gradient. - RHS
52 template <typename T> class TensorValue;
53 template <typename T> class VectorValue;
58 
73 {
74 
75 public:
81  explicit
82  ExactSolution (const EquationSystems & es);
83 
90  ExactSolution(const ExactSolution &) = delete;
91  ExactSolution & operator= (const ExactSolution &) = delete;
92  ExactSolution & operator= (ExactSolution &&) = delete;
93 
100 
106  void attach_reference_solution (const EquationSystems * es_fine);
107 
112  void attach_exact_values (const std::vector<FunctionBase<Number> *> & f);
113 
118  void attach_exact_value (unsigned int sys_num,
120 
125  typedef Number (*ValueFunctionPointer)(const Point & p,
126  const Parameters & Parameters,
127  const std::string & sys_name,
128  const std::string & unknown_name);
130 
135  void attach_exact_derivs (const std::vector<FunctionBase<Gradient> *> & g);
136 
141  void attach_exact_deriv (unsigned int sys_num,
143 
148  typedef Gradient (*GradientFunctionPointer)(const Point & p,
149  const Parameters & parameters,
150  const std::string & sys_name,
151  const std::string & unknown_name);
153 
158  void attach_exact_hessians (std::vector<FunctionBase<Tensor> *> h);
159 
164  void attach_exact_hessian (unsigned int sys_num,
166 
171  typedef Tensor (*HessianFunctionPointer)(const Point & p,
172  const Parameters & parameters,
173  const std::string & sys_name,
174  const std::string & unknown_name);
176 
181  void extra_quadrature_order (const int extraorder)
182  { _extra_order = extraorder; }
183 
191  void compute_error(const std::string & sys_name,
192  const std::string & unknown_name);
193 
201  Real l2_error(const std::string & sys_name,
202  const std::string & unknown_name);
203 
211  Real l1_error(const std::string & sys_name,
212  const std::string & unknown_name);
213 
226  Real l_inf_error(const std::string & sys_name,
227  const std::string & unknown_name);
228 
236  Real h1_error(const std::string & sys_name,
237  const std::string & unknown_name);
238 
249  Real hcurl_error(const std::string & sys_name,
250  const std::string & unknown_name);
251 
262  Real hdiv_error(const std::string & sys_name,
263  const std::string & unknown_name);
264 
272  Real h2_error(const std::string & sys_name,
273  const std::string & unknown_name);
274 
285  Real error_norm(const std::string & sys_name,
286  const std::string & unknown_name,
287  const FEMNormType & norm);
288 private:
289 
296  template<typename OutputShape>
297  void _compute_error(const std::string & sys_name,
298  const std::string & unknown_name,
299  std::vector<Real> & error_vals);
300 
307  std::vector<Real> & _check_inputs(const std::string & sys_name,
308  const std::string & unknown_name);
309 
314  std::vector<std::unique_ptr<FunctionBase<Number>>> _exact_values;
315 
320  std::vector<std::unique_ptr<FunctionBase<Gradient>>> _exact_derivs;
321 
326  std::vector<std::unique_ptr<FunctionBase<Tensor>>> _exact_hessians;
327 
336  typedef std::map<std::string, std::vector<Real>> SystemErrorMap;
337 
344  std::map<std::string, SystemErrorMap> _errors;
345 
351 
357 
362 };
363 
364 
365 
366 } // namespace libMesh
367 
368 
369 #endif // LIBMESH_EXACT_SOLUTION_H
Manages multiples systems of equations.
void _compute_error(const std::string &sys_name, const std::string &unknown_name, std::vector< Real > &error_vals)
const EquationSystems & _equation_systems
ExactSolution(const EquationSystems &es)
void attach_exact_values(const std::vector< FunctionBase< Number > *> &f)
Real h2_error(const std::string &sys_name, const std::string &unknown_name)
Real hdiv_error(const std::string &sys_name, const std::string &unknown_name)
void extra_quadrature_order(const int extraorder)
void attach_exact_derivs(const std::vector< FunctionBase< Gradient > *> &g)
Real error_norm(const std::string &sys_name, const std::string &unknown_name, const FEMNormType &norm)
void compute_error(const std::string &sys_name, const std::string &unknown_name)
const EquationSystems * _equation_systems_fine
Number(* ValueFunctionPointer)(const Point &p, const Parameters &Parameters, const std::string &sys_name, const std::string &unknown_name)
std::map< std::string, std::vector< Real > > SystemErrorMap
TensorValue< Number > NumberTensorValue
void attach_exact_hessians(std::vector< FunctionBase< Tensor > *> h)
ExactSolution & operator=(const ExactSolution &)=delete
NumberVectorValue Gradient
std::vector< std::unique_ptr< FunctionBase< Gradient > > > _exact_derivs
void attach_exact_hessian(unsigned int sys_num, FunctionBase< Tensor > *h)
Real l1_error(const std::string &sys_name, const std::string &unknown_name)
void attach_exact_deriv(unsigned int sys_num, FunctionBase< Gradient > *g)
std::vector< std::unique_ptr< FunctionBase< Tensor > > > _exact_hessians
Real hcurl_error(const std::string &sys_name, const std::string &unknown_name)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
std::map< std::string, SystemErrorMap > _errors
NumberTensorValue Tensor
Real h1_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)
Tensor(* HessianFunctionPointer)(const Point &p, const Parameters &parameters, const std::string &sys_name, const std::string &unknown_name)
void attach_exact_value(unsigned int sys_num, FunctionBase< Number > *f)
void attach_reference_solution(const EquationSystems *es_fine)
Real l2_error(const std::string &sys_name, const std::string &unknown_name)
VectorValue< Number > NumberVectorValue
Gradient(* GradientFunctionPointer)(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
std::vector< Real > & _check_inputs(const std::string &sys_name, const std::string &unknown_name)