$extrastylesheet
exact_error_estimator.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 
00019 
00020 #ifndef LIBMESH_EXACT_ERROR_ESTIMATOR_H
00021 #define LIBMESH_EXACT_ERROR_ESTIMATOR_H
00022 
00023 // Local Includes
00024 #include "libmesh/error_estimator.h"
00025 #include "libmesh/function_base.h"
00026 
00027 // C++ includes
00028 #include <cstddef>
00029 #include <string>
00030 #include <vector>
00031 
00032 namespace libMesh
00033 {
00034 
00035 // Forward Declarations
00036 class Elem;
00037 template <typename T> class FEGenericBase;
00038 typedef FEGenericBase<Real> FEBase;
00039 class MeshFunction;
00040 class Point;
00041 class Parameters;
00042 
00043 template <typename T> class DenseVector;
00044 
00045 // Is there any way to simplify this?
00046 // All we need are Tensor and Gradient. - RHS
00047 template <typename T> class TensorValue;
00048 template <typename T> class VectorValue;
00049 typedef TensorValue<Number> NumberTensorValue;
00050 typedef NumberTensorValue   Tensor;
00051 typedef VectorValue<Number> NumberVectorValue;
00052 typedef NumberVectorValue   Gradient;
00053 
00054 
00055 
00066 class ExactErrorEstimator : public ErrorEstimator
00067 {
00068 public:
00069 
00074   ExactErrorEstimator() :
00075     ErrorEstimator(),
00076     _exact_value(NULL),
00077     _exact_deriv(NULL),
00078     _exact_hessian(NULL),
00079     _equation_systems_fine(NULL),
00080     _extra_order(0)
00081   { error_norm = H1; }
00082 
00086   ~ExactErrorEstimator() {}
00087 
00092   void attach_exact_values (std::vector<FunctionBase<Number> *> f);
00093 
00098   void attach_exact_value (unsigned int sys_num,
00099                            FunctionBase<Number>* f);
00100 
00105   void attach_exact_value ( Number fptr(const Point& p,
00106                                         const Parameters& Parameters,
00107                                         const std::string& sys_name,
00108                                         const std::string& unknown_name));
00109 
00114   void attach_exact_derivs (std::vector<FunctionBase<Gradient> *> g);
00115 
00120   void attach_exact_deriv (unsigned int sys_num,
00121                            FunctionBase<Gradient>* g);
00122 
00127   void attach_exact_deriv ( Gradient gptr(const Point& p,
00128                                           const Parameters& parameters,
00129                                           const std::string& sys_name,
00130                                           const std::string& unknown_name));
00131 
00136   void attach_exact_hessians (std::vector<FunctionBase<Tensor> *> h);
00137 
00142   void attach_exact_hessian (unsigned int sys_num,
00143                              FunctionBase<Tensor>* h);
00144 
00149   void attach_exact_hessian ( Tensor hptr(const Point& p,
00150                                           const Parameters& parameters,
00151                                           const std::string& sys_name,
00152                                           const std::string& unknown_name));
00153 
00159   void attach_reference_solution (EquationSystems* es_fine);
00160 
00161 
00166   void extra_quadrature_order (const int extraorder)
00167   { _extra_order = extraorder; }
00168 
00169 
00170   // Bring the base class functionality into the name lookup
00171   // procedure.  This allows for alternative calling formats
00172   // defined in the base class.  Thanks Wolfgang.
00173   // GCC 2.95.3 cannot compile such code.  Since it was not really
00174   // essential to the functioning of this class, it's been removed.
00175   // using ErrorEstimator::estimate_error;
00176 
00183   virtual void estimate_error (const System& system,
00184                                ErrorVector& error_per_cell,
00185                                const NumericVector<Number>* solution_vector = NULL,
00186                                bool estimate_parent_error = false);
00187 
00188 private:
00189 
00194   Number (* _exact_value) (const Point& p,
00195                            const Parameters& parameters,
00196                            const std::string& sys_name,
00197                            const std::string& unknown_name);
00198 
00203   Gradient (* _exact_deriv) (const Point& p,
00204                              const Parameters& parameters,
00205                              const std::string& sys_name,
00206                              const std::string& unknown_name);
00207 
00212   Tensor (* _exact_hessian) (const Point& p,
00213                              const Parameters& parameters,
00214                              const std::string& sys_name,
00215                              const std::string& unknown_name);
00216 
00221   std::vector<FunctionBase<Number> *> _exact_values;
00222 
00227   std::vector<FunctionBase<Gradient> *> _exact_derivs;
00228 
00233   std::vector<FunctionBase<Tensor> *> _exact_hessians;
00234 
00239   EquationSystems* _equation_systems_fine;
00240 
00244   Real find_squared_element_error (const System& system,
00245                                    const std::string& var_name,
00246                                    const Elem *elem,
00247                                    const DenseVector<Number> &Uelem,
00248                                    FEBase *fe,
00249                                    MeshFunction *fine_values) const;
00250 
00254   void clear_functors ();
00255 
00259   int _extra_order;
00260 };
00261 
00262 
00263 } // namespace libMesh
00264 
00265 #endif // LIBMESH_EXACT_ERROR_ESTIMATOR_H