$extrastylesheet
exact_solution.h
Go to the documentation of this file.
00001 // The libMesh Finite Element Library.
00002 // Copyright (C) 2002-2014 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
00003 
00004 // This library is free software; you can redistribute it and/or
00005 // modify it under the terms of the GNU Lesser General Public
00006 // License as published by the Free Software Foundation; either
00007 // version 2.1 of the License, or (at your option) any later version.
00008 
00009 // This library is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012 // Lesser General Public License for more details.
00013 
00014 // You should have received a copy of the GNU Lesser General Public
00015 // License along with this library; if not, write to the Free Software
00016 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017 
00018 #ifndef LIBMESH_EXACT_SOLUTION_H
00019 #define LIBMESH_EXACT_SOLUTION_H
00020 
00021 
00022 // Local Includes
00023 #include "libmesh/libmesh_common.h" // for Number
00024 #include "libmesh/enum_norm_type.h"
00025 
00026 // C++ includes
00027 #include <map>
00028 #include <vector>
00029 
00030 namespace libMesh
00031 {
00032 
00033 
00034 // Forward Declarations
00035 class Point;
00036 class EquationSystems;
00037 class Parameters;
00038 class Mesh;
00039 template <typename Output> class FunctionBase;
00040 
00041 // Is there any way to simplify this?
00042 // All we need are Tensor and Gradient. - RHS
00043 template <typename T> class TensorValue;
00044 template <typename T> class VectorValue;
00045 typedef TensorValue<Number> NumberTensorValue;
00046 typedef NumberTensorValue   Tensor;
00047 typedef VectorValue<Number> NumberVectorValue;
00048 typedef NumberVectorValue   Gradient;
00049 
00064 class ExactSolution
00065 {
00066 
00067 public:
00073   explicit
00074   ExactSolution (const EquationSystems& es);
00075 
00079   ~ExactSolution();
00080 
00081 
00087   void attach_reference_solution (const EquationSystems* es_fine);
00088 
00093   void attach_exact_values (std::vector<FunctionBase<Number> *> f);
00094 
00099   void attach_exact_value (unsigned int sys_num,
00100                            FunctionBase<Number>* f);
00101 
00106   void attach_exact_value (Number fptr(const Point& p,
00107                                        const Parameters& Parameters,
00108                                        const std::string& sys_name,
00109                                        const std::string& unknown_name));
00110 
00115   void attach_exact_derivs (std::vector<FunctionBase<Gradient> *> g);
00116 
00121   void attach_exact_deriv (unsigned int sys_num,
00122                            FunctionBase<Gradient>* g);
00123 
00128   void attach_exact_deriv (Gradient gptr(const Point& p,
00129                                          const Parameters& parameters,
00130                                          const std::string& sys_name,
00131                                          const std::string& unknown_name));
00132 
00137   void attach_exact_hessians (std::vector<FunctionBase<Tensor> *> h);
00138 
00143   void attach_exact_hessian (unsigned int sys_num,
00144                              FunctionBase<Tensor>* h);
00145 
00150   void attach_exact_hessian (Tensor hptr(const Point& p,
00151                                          const Parameters& parameters,
00152                                          const std::string& sys_name,
00153                                          const std::string& unknown_name));
00154 
00159   void extra_quadrature_order (const int extraorder)
00160   { _extra_order = extraorder; }
00161 
00169   void compute_error(const std::string& sys_name,
00170                      const std::string& unknown_name);
00171 
00177   Real l2_error(const std::string& sys_name,
00178                 const std::string& unknown_name);
00179 
00185   Real l1_error(const std::string& sys_name,
00186                 const std::string& unknown_name);
00187 
00197   Real l_inf_error(const std::string& sys_name,
00198                    const std::string& unknown_name);
00199 
00205   Real h1_error(const std::string& sys_name,
00206                 const std::string& unknown_name);
00207 
00215   Real hcurl_error(const std::string& sys_name,
00216                    const std::string& unknown_name);
00217 
00225   Real hdiv_error(const std::string& sys_name,
00226                   const std::string& unknown_name);
00227 
00233   Real h2_error(const std::string& sys_name,
00234                 const std::string& unknown_name);
00235 
00243   Real error_norm(const std::string& sys_name,
00244                   const std::string& unknown_name,
00245                   const FEMNormType& norm);
00246 private:
00247 
00254   template<typename OutputShape>
00255   void _compute_error(const std::string& sys_name,
00256                       const std::string& unknown_name,
00257                       std::vector<Real>& error_vals);
00258 
00264   std::vector<Real>& _check_inputs(const std::string& sys_name,
00265                                    const std::string& unknown_name);
00266 
00271   std::vector<FunctionBase<Number> *> _exact_values;
00272 
00277   std::vector<FunctionBase<Gradient> *> _exact_derivs;
00278 
00283   std::vector<FunctionBase<Tensor> *> _exact_hessians;
00284 
00293   typedef std::map<std::string, std::vector<Real> > SystemErrorMap;
00294 
00301   std::map<std::string, SystemErrorMap> _errors;
00302 
00307   const EquationSystems& _equation_systems;
00308 
00313   const EquationSystems* _equation_systems_fine;
00314 
00318   int _extra_order;
00319 };
00320 
00321 
00322 
00323 } // namespace libMesh
00324 
00325 
00326 #endif // LIBMESH_EXACT_SOLUTION_H