MFEM  v4.4.0
Finite element discretization library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
estimators.hpp
Go to the documentation of this file.
1 // Copyright (c) 2010-2022, Lawrence Livermore National Security, LLC. Produced
2 // at the Lawrence Livermore National Laboratory. All Rights reserved. See files
3 // LICENSE and NOTICE for details. LLNL-CODE-806117.
4 //
5 // This file is part of the MFEM library. For more information and source code
6 // availability visit https://mfem.org.
7 //
8 // MFEM is free software; you can redistribute it and/or modify it under the
9 // terms of the BSD-3 license. We welcome feedback and contributions, see file
10 // CONTRIBUTING.md for details.
11 
12 #ifndef MFEM_ERROR_ESTIMATORS
13 #define MFEM_ERROR_ESTIMATORS
14 
15 #include <functional>
16 
17 #include "../config/config.hpp"
18 #include "../linalg/vector.hpp"
19 #include "bilinearform.hpp"
20 #ifdef MFEM_USE_MPI
21 #include "pgridfunc.hpp"
22 #endif
23 
24 namespace mfem
25 {
26 
27 /** @brief Base class for all error estimators.
28  */
30 {
31 public:
33 };
34 
35 
36 /** @brief Base class for all element based error estimators.
37 
38  At a minimum, an ErrorEstimator must be able compute one non-negative real
39  (double) number for each element in the Mesh.
40  */
42 {
43 public:
44  /// Return the total error from the last error estimate.
45  /** @note This method is optional for derived classes to override and the
46  base class implementation simply returns 0. */
47  virtual double GetTotalError() const { return 0.0; }
48 
49  /// Get a Vector with all element errors.
50  virtual const Vector &GetLocalErrors() = 0;
51 
52  /// Force recomputation of the estimates on the next call to GetLocalErrors.
53  virtual void Reset() = 0;
54 
55  /// Destruct the error estimator
56  virtual ~ErrorEstimator() { }
57 };
58 
59 
60 /** @brief The AnisotropicErrorEstimator class is the base class for all error
61  estimators that compute one non-negative real (double) number and an
62  anisotropic flag for every element in the Mesh.
63  */
65 {
66 public:
67  /** @brief Get an Array<int> with anisotropic flags for all mesh elements.
68  @return An empty array when anisotropic estimates are not available or
69  enabled. */
70  virtual const Array<int> &GetAnisotropicFlags() = 0;
71 };
72 
73 
74 /** @brief The ZienkiewiczZhuEstimator class implements the Zienkiewicz-Zhu
75  error estimation procedure.
76 
77  Zienkiewicz, O.C. and Zhu, J.Z., The superconvergent patch recovery
78  and a posteriori error estimates. Part 1: The recovery technique.
79  Int. J. Num. Meth. Engng. 33, 1331-1364 (1992).
80 
81  Zienkiewicz, O.C. and Zhu, J.Z., The superconvergent patch recovery
82  and a posteriori error estimates. Part 2: Error estimates and adaptivity.
83  Int. J. Num. Meth. Engng. 33, 1365-1382 (1992).
84 
85  The required BilinearFormIntegrator must implement the methods
86  ComputeElementFlux() and ComputeFluxEnergy().
87  */
89 {
90 protected:
93  double total_error;
96  int flux_averaging; // see SetFluxAveraging()
97 
98  BilinearFormIntegrator *integ; ///< Not owned.
99  GridFunction *solution; ///< Not owned.
100 
101  FiniteElementSpace *flux_space; /**< @brief Ownership based on own_flux_fes.
102  Its Update() method is called automatically by this class when needed. */
104  bool own_flux_fes; ///< Ownership flag for flux_space.
105 
106  /// Check if the mesh of the solution was modified.
108  {
109  long mesh_sequence = solution->FESpace()->GetMesh()->GetSequence();
110  MFEM_ASSERT(mesh_sequence >= current_sequence, "");
111  return (mesh_sequence > current_sequence);
112  }
113 
114  /// Compute the element error estimates.
115  void ComputeEstimates();
116 
117 public:
118  /** @brief Construct a new ZienkiewiczZhuEstimator object.
119  @param integ This BilinearFormIntegrator must implement the methods
120  ComputeElementFlux() and ComputeFluxEnergy().
121  @param sol The solution field whose error is to be estimated.
122  @param flux_fes The ZienkiewiczZhuEstimator assumes ownership of this
123  FiniteElementSpace and will call its Update() method when
124  needed.*/
126  FiniteElementSpace *flux_fes)
127  : current_sequence(-1),
128  total_error(),
129  anisotropic(false),
130  flux_averaging(0),
131  integ(&integ),
132  solution(&sol),
133  flux_space(flux_fes),
134  with_coeff(false),
135  own_flux_fes(true)
136  { }
137 
138  /** @brief Construct a new ZienkiewiczZhuEstimator object.
139  @param integ This BilinearFormIntegrator must implement the methods
140  ComputeElementFlux() and ComputeFluxEnergy().
141  @param sol The solution field whose error is to be estimated.
142  @param flux_fes The ZienkiewiczZhuEstimator does NOT assume ownership of
143  this FiniteElementSpace; will call its Update() method
144  when needed. */
146  FiniteElementSpace &flux_fes)
147  : current_sequence(-1),
148  total_error(),
149  anisotropic(false),
150  flux_averaging(0),
151  integ(&integ),
152  solution(&sol),
153  flux_space(&flux_fes),
154  with_coeff(false),
155  own_flux_fes(false)
156  { }
157 
158  /** @brief Consider the coefficient in BilinearFormIntegrator to calculate
159  the fluxes for the error estimator.*/
160  void SetWithCoeff(bool w_coeff = true) { with_coeff = w_coeff; }
161 
162  /** @brief Enable/disable anisotropic estimates. To enable this option, the
163  BilinearFormIntegrator must support the 'd_energy' parameter in its
164  ComputeFluxEnergy() method. */
165  void SetAnisotropic(bool aniso = true) { anisotropic = aniso; }
166 
167  /** @brief Set the way the flux is averaged (smoothed) across elements.
168 
169  When @a fa is zero (default), averaging is performed globally. When @a fa
170  is non-zero, the flux averaging is performed locally for each mesh
171  attribute, i.e. the flux is not averaged across interfaces between
172  different mesh attributes. */
173  void SetFluxAveraging(int fa) { flux_averaging = fa; }
174 
175  /// Return the total error from the last error estimate.
176  virtual double GetTotalError() const override { return total_error; }
177 
178  /// Get a Vector with all element errors.
179  virtual const Vector &GetLocalErrors() override
180  {
181  if (MeshIsModified()) { ComputeEstimates(); }
182  return error_estimates;
183  }
184 
185  /** @brief Get an Array<int> with anisotropic flags for all mesh elements.
186  Return an empty array when anisotropic estimates are not available or
187  enabled. */
188  virtual const Array<int> &GetAnisotropicFlags() override
189  {
190  if (MeshIsModified()) { ComputeEstimates(); }
191  return aniso_flags;
192  }
193 
194  /// Reset the error estimator.
195  virtual void Reset() override { current_sequence = -1; }
196 
197  /** @brief Destroy a ZienkiewiczZhuEstimator object. Destroys, if owned, the
198  FiniteElementSpace, flux_space. */
200  {
201  if (own_flux_fes) { delete flux_space; }
202  }
203 };
204 
205 
206 #ifdef MFEM_USE_MPI
207 
208 /** @brief The L2ZienkiewiczZhuEstimator class implements the Zienkiewicz-Zhu
209  error estimation procedure where the flux averaging is replaced by a global
210  L2 projection (requiring a mass matrix solve).
211 
212  The required BilinearFormIntegrator must implement the methods
213  ComputeElementFlux() and ComputeFluxEnergy().
214 
215  Implemented for the parallel case only.
216  */
218 {
219 protected:
221  int local_norm_p; ///< Local L_p norm to use, default is 1.
223  double total_error;
224 
225  BilinearFormIntegrator *integ; ///< Not owned.
226  ParGridFunction *solution; ///< Not owned.
227 
228  ParFiniteElementSpace *flux_space; /**< @brief Ownership based on the flag
229  own_flux_fes. Its Update() method is called automatically by this class
230  when needed. */
231  ParFiniteElementSpace *smooth_flux_space; /**< @brief Ownership based on the
232  flag own_flux_fes. Its Update() method is called automatically by this
233  class when needed.*/
234  bool own_flux_fes; ///< Ownership flag for flux_space and smooth_flux_space.
235 
236  /// Initialize with the integrator, solution, and flux finite element spaces.
238  ParGridFunction &sol,
239  ParFiniteElementSpace *flux_fes,
240  ParFiniteElementSpace *smooth_flux_fes)
241  {
242  current_sequence = -1;
243  local_norm_p = 1;
244  total_error = 0.0;
245  integ = &integ_;
246  solution = &sol;
247  flux_space = flux_fes;
248  smooth_flux_space = smooth_flux_fes;
249  }
250 
251  /// Check if the mesh of the solution was modified.
253  {
254  long mesh_sequence = solution->FESpace()->GetMesh()->GetSequence();
255  MFEM_ASSERT(mesh_sequence >= current_sequence, "");
256  return (mesh_sequence > current_sequence);
257  }
258 
259  /// Compute the element error estimates.
260  void ComputeEstimates();
261 
262 public:
263  /** @brief Construct a new L2ZienkiewiczZhuEstimator object.
264  @param integ This BilinearFormIntegrator must implement the methods
265  ComputeElementFlux() and ComputeFluxEnergy().
266  @param sol The solution field whose error is to be estimated.
267  @param flux_fes The L2ZienkiewiczZhuEstimator assumes ownership of this
268  FiniteElementSpace and will call its Update() method when
269  needed.
270  @param smooth_flux_fes
271  The L2ZienkiewiczZhuEstimator assumes ownership of this
272  FiniteElementSpace and will call its Update() method when
273  needed. */
275  ParGridFunction &sol,
276  ParFiniteElementSpace *flux_fes,
277  ParFiniteElementSpace *smooth_flux_fes)
278  { Init(integ, sol, flux_fes, smooth_flux_fes); own_flux_fes = true; }
279 
280  /** @brief Construct a new L2ZienkiewiczZhuEstimator object.
281  @param integ This BilinearFormIntegrator must implement the methods
282  ComputeElementFlux() and ComputeFluxEnergy().
283  @param sol The solution field whose error is to be estimated.
284  @param flux_fes The L2ZienkiewiczZhuEstimator does NOT assume ownership
285  of this FiniteElementSpace; will call its Update() method
286  when needed.
287  @param smooth_flux_fes
288  The L2ZienkiewiczZhuEstimator does NOT assume ownership
289  of this FiniteElementSpace; will call its Update() method
290  when needed. */
292  ParGridFunction &sol,
293  ParFiniteElementSpace &flux_fes,
294  ParFiniteElementSpace &smooth_flux_fes)
295  { Init(integ, sol, &flux_fes, &smooth_flux_fes); own_flux_fes = false; }
296 
297  /** @brief Set the exponent, p, of the Lp norm used for computing the local
298  element errors. Default value is 1. */
300 
301  /// Return the total error from the last error estimate.
302  virtual double GetTotalError() const override { return total_error; }
303 
304  /// Get a Vector with all element errors.
305  virtual const Vector &GetLocalErrors() override
306  {
307  if (MeshIsModified()) { ComputeEstimates(); }
308  return error_estimates;
309  }
310 
311  /// Reset the error estimator.
312  virtual void Reset() override { current_sequence = -1; }
313 
314  /** @brief Destroy a L2ZienkiewiczZhuEstimator object. Destroys, if owned,
315  the FiniteElementSpace, flux_space. */
317  {
318  if (own_flux_fes) { delete flux_space; delete smooth_flux_space; }
319  }
320 };
321 
322 #endif // MFEM_USE_MPI
323 
324 
325 /** @brief The LpErrorEstimator class compares the solution to a known
326  coefficient.
327 
328  This class can be used, for example, to adapt a mesh to a non-trivial
329  initial condition in a time-dependent simulation. It can also be used to
330  force refinement in the neighborhood of small features before switching to a
331  more traditional error estimator.
332 
333  The LpErrorEstimator supports either scalar or vector coefficients and works
334  both in serial and in parallel.
335 */
337 {
338 protected:
342 
343  double total_error = 0.0;
344 
348 
349  /// Check if the mesh of the solution was modified.
351  {
352  long mesh_sequence = sol->FESpace()->GetMesh()->GetSequence();
353  MFEM_ASSERT(mesh_sequence >= current_sequence, "");
354  return (mesh_sequence > current_sequence);
355  }
356 
357  /// Compute the element error estimates.
358  void ComputeEstimates();
359 
360 public:
361  /** @brief Construct a new LpErrorEstimator object for a scalar field.
362  @param p Integer which selects which Lp norm to use.
363  @param sol The GridFunction representation of the scalar field.
364  Note: the coefficient must be set before use with the SetCoef method.
365  */
367  : current_sequence(-1), local_norm_p(p),
368  error_estimates(0), coef(NULL), vcoef(NULL), sol(&sol) { }
369 
370  /** @brief Construct a new LpErrorEstimator object for a scalar field.
371  @param p Integer which selects which Lp norm to use.
372  @param coef The scalar Coefficient to compare to the solution.
373  @param sol The GridFunction representation of the scalar field.
374  */
376  : current_sequence(-1), local_norm_p(p),
377  error_estimates(0), coef(&coef), vcoef(NULL), sol(&sol) { }
378 
379  /** @brief Construct a new LpErrorEstimator object for a vector field.
380  @param p Integer which selects which Lp norm to use.
381  @param coef The vector VectorCoefficient to compare to the solution.
382  @param sol The GridFunction representation of the vector field.
383  */
385  : current_sequence(-1), local_norm_p(p),
386  error_estimates(0), coef(NULL), vcoef(&coef), sol(&sol) { }
387 
388  /** @brief Set the exponent, p, of the Lp norm used for computing the local
389  element errors. */
391 
392  void SetCoef(Coefficient &A) { coef = &A; }
393  void SetCoef(VectorCoefficient &A) { vcoef = &A; }
394 
395  /// Reset the error estimator.
396  virtual void Reset() override { current_sequence = -1; }
397 
398  /// Get a Vector with all element errors.
399  virtual const Vector &GetLocalErrors() override
400  {
401  if (MeshIsModified()) { ComputeEstimates(); }
402  return error_estimates;
403  }
404 
405  /// Destructor
406  virtual ~LpErrorEstimator() {}
407 };
408 
409 
410 /** @brief The KellyErrorEstimator class provides a fast error indication
411  strategy for smooth scalar parallel problems.
412 
413  The Kelly error indicator is based on the following papers:
414 
415  [1] Kelly, D. W., et al. "A posteriori error analysis and adaptive processes
416  in the finite element method: Part I—Error analysis." International journal
417  for numerical methods in engineering 19.11 (1983): 1593-1619.
418 
419  [2] De SR Gago, J. P., et al. "A posteriori error analysis and adaptive
420  processes in the finite element method: Part II—Adaptive mesh refinement."
421  International journal for numerical methods in engineering 19.11 (1983):
422  1621-1656.
423 
424  It can be roughly described by:
425  ||∇(u-uₕ)||ₑ ≅ √( C hₑ ∑ₖ (hₖ ∫ |J[∇uₕ]|²) dS )
426  where "e" denotes an element, ||⋅||ₑ the corresponding local norm and k the
427  corresponding faces. u is the analytic solution and uₕ the discretized
428  solution. hₖ and hₑ are factors dependent on the face and element geometry.
429  J is the jump function, i.e. the difference between the limits at each point
430  for each side of the face. A custom method to compute hₖ can be provided. It
431  is also possible to estimate the error only on a subspace by feeding this
432  class an attribute array describing the subspace.
433 
434  @note This algorithm is appropriate only for problems with scalar diffusion
435  coefficients (e.g. Poisson problems), because it measures only the flux of
436  the gradient of the discrete solution. The current implementation also does
437  not include the volume term present in Equation 75 of Kelly et al [1].
438  Instead, it includes only the flux term recommended in Equation 82. The
439  current implementation also does not include the constant factor "C". It
440  furthermore assumes that the approximation error at the boundary is small
441  enough, as the implementation ignores boundary faces.
442 */
444 {
445 public:
446  /// Function type to compute the local coefficient hₑ of an element.
448  std::function<double(Mesh*, const int)>;
449  /** @brief Function type to compute the local coefficient hₖ of a face. The
450  third argument is true for shared faces and false for local faces. */
452  std::function<double(Mesh*, const int, const bool)>;
453 
454 private:
455  int current_sequence = -1;
456 
457  Vector error_estimates;
458 
459  double total_error = 0.0;
460 
461  Array<int> attributes;
462 
463  /** @brief A method to compute hₑ on per-element basis.
464 
465  This method weights the error approximation on the element level.
466 
467  Defaults to hₑ=1.0.
468  */
469  ElementCoefficientFunction compute_element_coefficient;
470 
471  /** @brief A method to compute hₖ on per-face basis.
472 
473  This method weights the error approximation on the face level. The
474  background here is that classical Kelly error estimator implementations
475  approximate the geometrical characteristic hₖ with the face diameter,
476  which should be also be a possibility in this implementation.
477 
478  Defaults to hₖ=diameter/2p.
479  */
480  FaceCoefficientFunction compute_face_coefficient;
481 
482  BilinearFormIntegrator* flux_integrator; ///< Not owned.
483  GridFunction* solution; ///< Not owned.
484 
486  flux_space; /**< @brief Ownership based on own_flux_fes. */
487  bool own_flux_fespace; ///< Ownership flag for flux_space.
488 
489 #ifdef MFEM_USE_MPI
490  const bool isParallel;
491 #endif
492 
493  /// Check if the mesh of the solution was modified.
494  bool MeshIsModified()
495  {
496  long mesh_sequence = solution->FESpace()->GetMesh()->GetSequence();
497  MFEM_ASSERT(mesh_sequence >= current_sequence,
498  "improper mesh update sequence");
499  return (mesh_sequence > current_sequence);
500  }
501 
502  /** @brief Compute the element error estimates.
503 
504  Algorithm outline:
505  1. Compute flux field for each element
506  2. Add error contribution from local interior faces
507  3. Add error contribution from shared interior faces
508  4. Finalize by computing hₖ and scale errors.
509  */
510  void ComputeEstimates();
511 
512 public:
513  /** @brief Construct a new KellyErrorEstimator object for a scalar field.
514  @param di_ The bilinearform to compute the interface flux.
515  @param sol_ The solution field whose error is to be estimated.
516  @param flux_fes_ The finite element space for the interface flux.
517  @param attributes_ The attributes of the subdomain(s) for which the
518  error should be estimated. An empty array results in
519  estimating the error over the complete domain.
520  */
522  FiniteElementSpace& flux_fes_,
523  const Array<int> &attributes_ = Array<int>());
524 
525  /** @brief Construct a new KellyErrorEstimator object for a scalar field.
526  @param di_ The bilinearform to compute the interface flux.
527  @param sol_ The solution field whose error is to be estimated.
528  @param flux_fes_ The finite element space for the interface flux.
529  @param attributes_ The attributes of the subdomain(s) for which the
530  error should be estimated. An empty array results in
531  estimating the error over the complete domain.
532  */
534  FiniteElementSpace* flux_fes_,
535  const Array<int> &attributes_ = Array<int>());
536 
538 
539  /// Get a Vector with all element errors.
540  const Vector& GetLocalErrors() override
541  {
542  if (MeshIsModified())
543  {
544  ComputeEstimates();
545  }
546  return error_estimates;
547  }
548 
549  /// Reset the error estimator.
550  void Reset() override { current_sequence = -1; };
551 
552  virtual double GetTotalError() const override { return total_error; }
553 
554  /** @brief Change the method to compute hₑ on a per-element basis.
555  @param compute_element_coefficient_
556  A function taking a mesh and an element index to
557  compute the local hₑ for the element.
558  */
560  compute_element_coefficient_)
561  {
562  compute_element_coefficient = compute_element_coefficient_;
563  }
564 
565  /** @brief Change the method to compute hₖ on a per-element basis.
566  @param compute_face_coefficient_
567  A function taking a mesh and a face index to
568  compute the local hₖ for the face.
569  */
572  compute_face_coefficient_)
573  {
574  compute_face_coefficient = compute_face_coefficient_;
575  }
576 
577  /// Change the coefficients back to default as described above.
579 };
580 
581 } // namespace mfem
582 
583 #endif // MFEM_ERROR_ESTIMATORS
virtual ~L2ZienkiewiczZhuEstimator()
Destroy a L2ZienkiewiczZhuEstimator object. Destroys, if owned, the FiniteElementSpace, flux_space.
Definition: estimators.hpp:316
void SetAnisotropic(bool aniso=true)
Enable/disable anisotropic estimates. To enable this option, the BilinearFormIntegrator must support ...
Definition: estimators.hpp:165
The LpErrorEstimator class compares the solution to a known coefficient.
Definition: estimators.hpp:336
Class for grid function - Vector with associated FE space.
Definition: gridfunc.hpp:30
std::function< double(Mesh *, const int)> ElementCoefficientFunction
Function type to compute the local coefficient hₑ of an element.
Definition: estimators.hpp:448
L2ZienkiewiczZhuEstimator(BilinearFormIntegrator &integ, ParGridFunction &sol, ParFiniteElementSpace *flux_fes, ParFiniteElementSpace *smooth_flux_fes)
Construct a new L2ZienkiewiczZhuEstimator object.
Definition: estimators.hpp:274
Base class for vector Coefficients that optionally depend on time and space.
void ComputeEstimates()
Compute the element error estimates.
Definition: estimators.cpp:36
The KellyErrorEstimator class provides a fast error indication strategy for smooth scalar parallel pr...
Definition: estimators.hpp:443
ParFiniteElementSpace * flux_space
Ownership based on the flag own_flux_fes. Its Update() method is called automatically by this class w...
Definition: estimators.hpp:228
virtual const Vector & GetLocalErrors() override
Get a Vector with all element errors.
Definition: estimators.hpp:399
void SetLocalErrorNormP(int p)
Set the exponent, p, of the Lp norm used for computing the local element errors.
Definition: estimators.hpp:390
virtual void Reset() override
Reset the error estimator.
Definition: estimators.hpp:312
VectorCoefficient * vcoef
Definition: estimators.hpp:346
LpErrorEstimator(int p, Coefficient &coef, GridFunction &sol)
Construct a new LpErrorEstimator object for a scalar field.
Definition: estimators.hpp:375
bool MeshIsModified()
Check if the mesh of the solution was modified.
Definition: estimators.hpp:252
void SetLocalErrorNormP(int p)
Set the exponent, p, of the Lp norm used for computing the local element errors. Default value is 1...
Definition: estimators.hpp:299
Abstract parallel finite element space.
Definition: pfespace.hpp:28
GridFunction * sol
Definition: estimators.hpp:347
void SetWithCoeff(bool w_coeff=true)
Consider the coefficient in BilinearFormIntegrator to calculate the fluxes for the error estimator...
Definition: estimators.hpp:160
bool MeshIsModified()
Check if the mesh of the solution was modified.
Definition: estimators.hpp:350
virtual double GetTotalError() const override
Return the total error from the last error estimate.
Definition: estimators.hpp:552
The L2ZienkiewiczZhuEstimator class implements the Zienkiewicz-Zhu error estimation procedure where t...
Definition: estimators.hpp:217
virtual ~ErrorEstimator()
Destruct the error estimator.
Definition: estimators.hpp:56
void ComputeEstimates()
Compute the element error estimates.
Definition: estimators.cpp:17
void Reset() override
Reset the error estimator.
Definition: estimators.hpp:550
ParGridFunction * solution
Not owned.
Definition: estimators.hpp:226
long GetSequence() const
Definition: mesh.hpp:1639
bool own_flux_fes
Ownership flag for flux_space and smooth_flux_space.
Definition: estimators.hpp:234
LpErrorEstimator(int p, GridFunction &sol)
Construct a new LpErrorEstimator object for a scalar field.
Definition: estimators.hpp:366
virtual const Vector & GetLocalErrors()=0
Get a Vector with all element errors.
Mesh * GetMesh() const
Returns the mesh.
Definition: fespace.hpp:433
void ResetCoefficientFunctions()
Change the coefficients back to default as described above.
Definition: estimators.cpp:93
Base class for all error estimators.
Definition: estimators.hpp:29
GridFunction * solution
Not owned.
Definition: estimators.hpp:99
virtual void Reset() override
Reset the error estimator.
Definition: estimators.hpp:396
int local_norm_p
Local L_p norm to use, default is 1.
Definition: estimators.hpp:221
void SetFluxAveraging(int fa)
Set the way the flux is averaged (smoothed) across elements.
Definition: estimators.hpp:173
virtual double GetTotalError() const
Return the total error from the last error estimate.
Definition: estimators.hpp:47
LpErrorEstimator(int p, VectorCoefficient &coef, GridFunction &sol)
Construct a new LpErrorEstimator object for a vector field.
Definition: estimators.hpp:384
virtual void Reset() override
Reset the error estimator.
Definition: estimators.hpp:195
Base class for all element based error estimators.
Definition: estimators.hpp:41
void SetCoef(Coefficient &A)
Definition: estimators.hpp:392
L2ZienkiewiczZhuEstimator(BilinearFormIntegrator &integ, ParGridFunction &sol, ParFiniteElementSpace &flux_fes, ParFiniteElementSpace &smooth_flux_fes)
Construct a new L2ZienkiewiczZhuEstimator object.
Definition: estimators.hpp:291
FiniteElementSpace * FESpace()
Definition: gridfunc.hpp:652
KellyErrorEstimator(BilinearFormIntegrator &di_, GridFunction &sol_, FiniteElementSpace &flux_fes_, const Array< int > &attributes_=Array< int >())
Construct a new KellyErrorEstimator object for a scalar field.
Definition: estimators.cpp:53
virtual const Array< int > & GetAnisotropicFlags()=0
Get an Array&lt;int&gt; with anisotropic flags for all mesh elements.
virtual void Reset()=0
Force recomputation of the estimates on the next call to GetLocalErrors.
void SetFaceCoefficientFunction(FaceCoefficientFunction compute_face_coefficient_)
Change the method to compute hₖ on a per-element basis.
Definition: estimators.hpp:570
virtual const Vector & GetLocalErrors() override
Get a Vector with all element errors.
Definition: estimators.hpp:305
Abstract base class BilinearFormIntegrator.
Definition: bilininteg.hpp:34
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
Definition: fespace.hpp:88
Base class Coefficients that optionally depend on space and time. These are used by the BilinearFormI...
Definition: coefficient.hpp:39
virtual double GetTotalError() const override
Return the total error from the last error estimate.
Definition: estimators.hpp:176
std::function< double(Mesh *, const int, const bool)> FaceCoefficientFunction
Function type to compute the local coefficient hₖ of a face. The third argument is true for shared fa...
Definition: estimators.hpp:452
ParFiniteElementSpace * smooth_flux_space
Ownership based on the flag own_flux_fes. Its Update() method is called automatically by this class w...
Definition: estimators.hpp:231
virtual const Vector & GetLocalErrors() override
Get a Vector with all element errors.
Definition: estimators.hpp:179
virtual double GetTotalError() const override
Return the total error from the last error estimate.
Definition: estimators.hpp:302
FiniteElementSpace * flux_space
Ownership based on own_flux_fes. Its Update() method is called automatically by this class when neede...
Definition: estimators.hpp:101
void SetElementCoefficientFunction(ElementCoefficientFunction compute_element_coefficient_)
Change the method to compute hₑ on a per-element basis.
Definition: estimators.hpp:559
The AnisotropicErrorEstimator class is the base class for all error estimators that compute one non-n...
Definition: estimators.hpp:64
BilinearFormIntegrator * integ
Not owned.
Definition: estimators.hpp:225
void ComputeEstimates()
Compute the element error estimates.
Definition: estimators.cpp:462
virtual ~LpErrorEstimator()
Destructor.
Definition: estimators.hpp:406
ZienkiewiczZhuEstimator(BilinearFormIntegrator &integ, GridFunction &sol, FiniteElementSpace *flux_fes)
Construct a new ZienkiewiczZhuEstimator object.
Definition: estimators.hpp:125
The ZienkiewiczZhuEstimator class implements the Zienkiewicz-Zhu error estimation procedure...
Definition: estimators.hpp:88
Vector data type.
Definition: vector.hpp:60
void Init(BilinearFormIntegrator &integ_, ParGridFunction &sol, ParFiniteElementSpace *flux_fes, ParFiniteElementSpace *smooth_flux_fes)
Initialize with the integrator, solution, and flux finite element spaces.
Definition: estimators.hpp:237
bool MeshIsModified()
Check if the mesh of the solution was modified.
Definition: estimators.hpp:107
virtual ~ZienkiewiczZhuEstimator()
Destroy a ZienkiewiczZhuEstimator object. Destroys, if owned, the FiniteElementSpace, flux_space.
Definition: estimators.hpp:199
ZienkiewiczZhuEstimator(BilinearFormIntegrator &integ, GridFunction &sol, FiniteElementSpace &flux_fes)
Construct a new ZienkiewiczZhuEstimator object.
Definition: estimators.hpp:145
Class for parallel grid function.
Definition: pgridfunc.hpp:32
virtual const Array< int > & GetAnisotropicFlags() override
Get an Array&lt;int&gt; with anisotropic flags for all mesh elements. Return an empty array when anisotropi...
Definition: estimators.hpp:188
BilinearFormIntegrator * integ
Not owned.
Definition: estimators.hpp:98
void SetCoef(VectorCoefficient &A)
Definition: estimators.hpp:393
bool own_flux_fes
Ownership flag for flux_space.
Definition: estimators.hpp:104
const Vector & GetLocalErrors() override
Get a Vector with all element errors.
Definition: estimators.hpp:540