LCOV - code coverage report
Current view: top level - include/error_estimation - uniform_refinement_estimator.h (source / functions) Hit Total Coverage
Test: libMesh/libmesh: #4229 (6a9aeb) with base 727f46 Lines: 0 1 0.0 %
Date: 2025-08-19 19:27:09 Functions: 0 2 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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_UNIFORM_REFINEMENT_ESTIMATOR_H
      21             : #define LIBMESH_UNIFORM_REFINEMENT_ESTIMATOR_H
      22             : 
      23             : // Local Includes
      24             : #include "libmesh/error_estimator.h"
      25             : #include "libmesh/libmesh.h"
      26             : 
      27             : // C++ includes
      28             : #include <cstddef>
      29             : #include <vector>
      30             : 
      31             : #ifdef LIBMESH_ENABLE_AMR
      32             : 
      33             : namespace libMesh
      34             : {
      35             : 
      36             : /**
      37             :  * This class implements a ``brute force'' error estimator
      38             :  * which integrates differences between the current solution
      39             :  * and the solution on a uniformly refined (in h and/or p,
      40             :  * for an arbitrary number of levels) grid.
      41             :  *
      42             :  * \author Roy H. Stogner
      43             :  * \date 2006
      44             :  */
      45             : class UniformRefinementEstimator : public ErrorEstimator
      46             : {
      47             : public:
      48             : 
      49             :   /**
      50             :    * Constructor.  Sets the most common default parameter values.
      51             :    */
      52             :   UniformRefinementEstimator();
      53             : 
      54             :   /**
      55             :    * Copy/move ctor, copy/move assignment operator, and destructor are
      56             :    * all explicitly defaulted for this simple class.
      57             :    */
      58             :   UniformRefinementEstimator (const UniformRefinementEstimator &) = default;
      59             :   UniformRefinementEstimator (UniformRefinementEstimator &&) = default;
      60             :   UniformRefinementEstimator & operator= (const UniformRefinementEstimator &) = default;
      61             :   UniformRefinementEstimator & operator= (UniformRefinementEstimator &&) = default;
      62           0 :   virtual ~UniformRefinementEstimator() = default;
      63             : 
      64             :   /**
      65             :    * This function does uniform refinements and a
      66             :    * solve to get an improved solution on each cell,
      67             :    * then estimates the error by integrating differences
      68             :    * between the coarse and fine solutions.
      69             :    *
      70             :    * system.solve() must be called, and so should
      71             :    * have no side effects.
      72             :    *
      73             :    * Only the provided system is solved on the refined mesh;
      74             :    * for problems decoupled into multiple systems, use of
      75             :    * estimate_errors() should be more reliable.
      76             :    *
      77             :    * The estimated error is output in the vector
      78             :    * \p error_per_cell
      79             :    */
      80             :   virtual void estimate_error (const System & system,
      81             :                                ErrorVector & error_per_cell,
      82             :                                const NumericVector<Number> * solution_vector = nullptr,
      83             :                                bool estimate_parent_error = false) override;
      84             : 
      85             :   /**
      86             :    * Currently this function ignores the error_norm member variable,
      87             :    * and uses the function argument error_norms instead.
      88             :    *
      89             :    * This function is named estimate_errors instead of estimate_error
      90             :    * because otherwise C++ can get confused.
      91             :    */
      92             :   virtual void estimate_errors (const EquationSystems & equation_systems,
      93             :                                 ErrorVector & error_per_cell,
      94             :                                 const std::map<const System *, SystemNorm> & error_norms,
      95             :                                 const std::map<const System *, const NumericVector<Number> *> * solution_vectors = nullptr,
      96             :                                 bool estimate_parent_error = false) override;
      97             : 
      98             :   /**
      99             :    * Currently this function ignores the component_scale member variable,
     100             :    * because it calculates each error individually, unscaled.
     101             :    *
     102             :    * The user selects which errors get computed by filling a map with error
     103             :    * vectors: If errors_per_cell[&system][v] exists, it will be filled with the
     104             :    * error values in variable \p v of \p system
     105             :    */
     106             :   virtual void estimate_errors (const EquationSystems & equation_systems,
     107             :                                 ErrorMap & errors_per_cell,
     108             :                                 const std::map<const System *, const NumericVector<Number> *> * solution_vectors = nullptr,
     109             :                                 bool estimate_parent_error = false) override;
     110             : 
     111             :   /**
     112             :    * Increases or decreases the order of the quadrature rule used for numerical
     113             :    * integration.  The default \p extraorder is 1, because properly
     114             :    * integrating L2 error requires integrating the squares of terms
     115             :    * with order p+1, and 2p+2 is 1 higher than what we default to
     116             :    * using for reasonable mass matrix integration.
     117             :    */
     118             :   void extra_quadrature_order (const int extraorder)
     119             :   { _extra_order = extraorder; }
     120             : 
     121             :   virtual ErrorEstimatorType type() const override;
     122             : 
     123             :   /**
     124             :    * How many h refinements to perform to get the fine grid
     125             :    */
     126             :   unsigned char number_h_refinements;
     127             : 
     128             :   /**
     129             :    * How many p refinements to perform to get the fine grid
     130             :    */
     131             :   unsigned char number_p_refinements;
     132             : 
     133             : protected:
     134             : 
     135             :   /**
     136             :    * Extra order to use for quadrature rule
     137             :    */
     138             :   int _extra_order;
     139             : 
     140             :   /**
     141             :    * The code for estimate_error and both estimate_errors versions is very
     142             :    * similar, so we use the same function for all three
     143             :    */
     144             :   virtual void _estimate_error (const EquationSystems * equation_systems,
     145             :                                 const System * system,
     146             :                                 ErrorVector * error_per_cell,
     147             :                                 ErrorMap * errors_per_cell,
     148             :                                 const std::map<const System *, SystemNorm > * error_norms,
     149             :                                 const std::map<const System *, const NumericVector<Number> *> * solution_vectors = nullptr,
     150             :                                 bool estimate_parent_error = false);
     151             : };
     152             : 
     153             : } // namespace libMesh
     154             : 
     155             : #endif // #ifdef LIBMESH_ENABLE_AMR
     156             : 
     157             : #endif // LIBMESH_UNIFORM_REFINEMENT_ESTIMATOR_H

Generated by: LCOV version 1.14