libMesh
smoothness_estimator.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2025 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_SMOOTHNESS_ESTIMATOR_H
21 #define LIBMESH_SMOOTHNESS_ESTIMATOR_H
22 
23 // Local Includes
24 #include "libmesh/point.h"
25 #include "libmesh/elem_range.h"
26 
27 // C++ includes
28 #include <cstddef>
29 #include <vector>
30 
31 namespace libMesh
32 {
33 
34 // Forward Declarations
35 class ErrorVector;
36 class System;
37 class Elem;
38 enum Order : int;
39 
49 {
50 public:
51 
56 
61  SmoothnessEstimator (const SmoothnessEstimator &) = default;
65  virtual ~SmoothnessEstimator() = default;
66 
75  virtual void estimate_smoothness (const System & system,
76  ErrorVector & smoothness_per_cell,
77  const NumericVector<Number> * solution_vector = nullptr);
78 
86  void extra_quadrature_order (const int extraorder)
87  { _extra_order = extraorder; }
88 
89 protected:
90 
94  static std::vector<Real> legepoly(const unsigned int dim,
95  const Order order,
96  const Point p,
97  const unsigned int matsize);
98 
103 
107  static Real compute_slope(int N, Real Sx, Real Sy, Real Sxx, Real Sxy);
108 
109  void reduce_smoothness (std::vector<ErrorVectorReal> & error_per_cell,
110  const Parallel::Communicator & comm);
111 
112 private:
113 
119  {
120  public:
122  const SmoothnessEstimator & ee,
123  ErrorVector & epc) :
124  system(sys),
127  {}
128 
129  void operator()(const ConstElemRange & range) const;
130 
131  private:
132  const System & system;
135  };
136 
137  friend class EstimateSmoothness;
138 };
139 
140 
141 } // namespace libMesh
142 
143 
144 #endif // LIBMESH_SMOOTHNESS_ESTIMATOR_H
Order
defines an enum for polynomial orders.
Definition: enum_order.h:40
virtual ~SmoothnessEstimator()=default
void extra_quadrature_order(const int extraorder)
Increases or decreases the order of the quadrature rule used for numerical integration.
SmoothnessEstimator & operator=(const SmoothnessEstimator &)=default
unsigned int dim
The ErrorVector is a specialization of the StatisticsVector for error data computed on a finite eleme...
Definition: error_vector.h:50
static std::vector< Real > legepoly(const unsigned int dim, const Order order, const Point p, const unsigned int matsize)
int _extra_order
Extra order to use for quadrature rule.
The StoredRange class defines a contiguous, divisible set of objects.
Definition: stored_range.h:54
The libMesh namespace provides an interface to certain functionality in the library.
void operator()(const ConstElemRange &range) const
This class implements the Smoothness estimate.
static Real compute_slope(int N, Real Sx, Real Sy, Real Sxx, Real Sxy)
Computes slop in a linear regression.
Manages consistently variables, degrees of freedom, and coefficient vectors.
Definition: system.h:96
virtual void estimate_smoothness(const System &system, ErrorVector &smoothness_per_cell, const NumericVector< Number > *solution_vector=nullptr)
This function uses the Legendre expansion of solution to estimate coefficient decay to quantify the s...
Class to compute the error contribution for a range of elements.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
EstimateSmoothness(const System &sys, const SmoothnessEstimator &ee, ErrorVector &epc)
void reduce_smoothness(std::vector< ErrorVectorReal > &error_per_cell, const Parallel::Communicator &comm)
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition: point.h:39
void ErrorVector unsigned int
Definition: adjoints_ex3.C:360