libMesh
error_estimator.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2019 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_ERROR_ESTIMATOR_H
21 #define LIBMESH_ERROR_ESTIMATOR_H
22 
23 // Local Includes
24 #include "libmesh/libmesh_common.h"
25 #include "libmesh/system_norm.h"
26 
27 #ifdef LIBMESH_FORWARD_DECLARE_ENUMS
28 namespace libMesh
29 {
30 enum ErrorEstimatorType : int;
31 }
32 #else
33 #include "libmesh/enum_error_estimator_type.h"
34 #endif
35 
36 // C++ includes
37 #include <cstddef>
38 #include <map>
39 #include <string>
40 #include <vector>
41 
42 namespace libMesh
43 {
44 
45 // Forward Declarations
46 class ErrorVector;
47 class EquationSystems;
48 class System;
49 template <typename T> class NumericVector;
50 
51 namespace Parallel {
52  class Communicator;
53 }
54 
68 {
69 public:
70 
75  ErrorEstimator() = default;
76 
81  ErrorEstimator (const ErrorEstimator &) = default;
82  ErrorEstimator (ErrorEstimator &&) = default;
83  ErrorEstimator & operator= (const ErrorEstimator &) = default;
85  virtual ~ErrorEstimator() = default;
86 
87 
101  virtual void estimate_error (const System & system,
102  ErrorVector & error_per_cell,
103  const NumericVector<Number> * solution_vector = nullptr,
104  bool estimate_parent_error = false) = 0;
105 
117  virtual void estimate_errors (const EquationSystems & equation_systems,
118  ErrorVector & error_per_cell,
119  const std::map<const System *, SystemNorm> & error_norms,
120  const std::map<const System *, const NumericVector<Number> *> * solution_vectors = nullptr,
121  bool estimate_parent_error = false);
122 
127  typedef std::map<std::pair<const System *, unsigned int>, ErrorVector *> ErrorMap;
128 
141  virtual void estimate_errors (const EquationSystems & equation_systems,
142  ErrorMap & errors_per_cell,
143  const std::map<const System *, const NumericVector<Number> *> * solution_vectors = nullptr,
144  bool estimate_parent_error = false);
145 
149  virtual ErrorEstimatorType type() const = 0;
150 
165 
166 protected:
167 
173  void reduce_error (std::vector<ErrorVectorReal> & error_per_cell,
174  const Parallel::Communicator & comm) const;
175 };
176 
177 
178 } // namespace libMesh
179 
180 #endif // LIBMESH_ERROR_ESTIMATOR_H
libMesh::System
Manages consistently variables, degrees of freedom, and coefficient vectors.
Definition: system.h:100
libMesh::ErrorEstimator::error_norm
SystemNorm error_norm
When estimating the error in a single system, the error_norm is used to control the scaling and norm ...
Definition: error_estimator.h:164
libMesh::ErrorEstimatorType
ErrorEstimatorType
Defines an enum for the different types of error estimators which are available.
Definition: enum_error_estimator_type.h:33
libMesh::ErrorEstimator
This class holds functions that will estimate the error in a finite element solution on a given mesh.
Definition: error_estimator.h:67
libMesh
The libMesh namespace provides an interface to certain functionality in the library.
Definition: factoryfunction.C:55
libMesh::ErrorEstimator::~ErrorEstimator
virtual ~ErrorEstimator()=default
libMesh::ErrorEstimator::type
virtual ErrorEstimatorType type() const =0
libMesh::NumericVector< Number >
libMesh::ErrorEstimator::estimate_error
virtual void estimate_error(const System &system, ErrorVector &error_per_cell, const NumericVector< Number > *solution_vector=nullptr, bool estimate_parent_error=false)=0
This pure virtual function must be redefined in derived classes to compute the error for each active ...
libMesh::ErrorVector
The ErrorVector is a specialization of the StatisticsVector for error data computed on a finite eleme...
Definition: error_vector.h:50
libMesh::ErrorEstimator::ErrorEstimator
ErrorEstimator()=default
Constructor.
libMesh::ErrorEstimator::estimate_errors
virtual void estimate_errors(const EquationSystems &equation_systems, ErrorVector &error_per_cell, const std::map< const System *, SystemNorm > &error_norms, const std::map< const System *, const NumericVector< Number > * > *solution_vectors=nullptr, bool estimate_parent_error=false)
This virtual function can be redefined in derived classes, but by default computes the sum of the err...
Definition: error_estimator.C:47
libMesh::EquationSystems
This is the EquationSystems class.
Definition: equation_systems.h:74
libMesh::ErrorEstimator::ErrorMap
std::map< std::pair< const System *, unsigned int >, ErrorVector * > ErrorMap
When calculating many error vectors at once, we need a data structure to hold them all.
Definition: error_estimator.h:127
libMesh::ErrorEstimator::reduce_error
void reduce_error(std::vector< ErrorVectorReal > &error_per_cell, const Parallel::Communicator &comm) const
This method takes the local error contributions in error_per_cell from each processor and combines th...
Definition: error_estimator.C:32
libMesh::ErrorEstimator::operator=
ErrorEstimator & operator=(const ErrorEstimator &)=default
libMesh::SystemNorm
This class defines a norm/seminorm to be applied to a NumericVector which contains coefficients in a ...
Definition: system_norm.h:51
int
void ErrorVector unsigned int
Definition: adjoints_ex3.C:360