Line data Source code
1 : //* This file is part of the MOOSE framework 2 : //* https://mooseframework.inl.gov 3 : //* 4 : //* All rights reserved, see COPYRIGHT for full restrictions 5 : //* https://github.com/idaholab/moose/blob/master/COPYRIGHT 6 : //* 7 : //* Licensed under LGPL 2.1, please see LICENSE for details 8 : //* https://www.gnu.org/licenses/lgpl-2.1.html 9 : 10 : #ifdef MOOSE_MFEM_ENABLED 11 : #pragma once 12 : 13 : #include "MFEMObject.h" 14 : #include "MFEMIndicator.h" 15 : 16 : /** 17 : * Class to construct threshold refiner. 18 : * The underlying mfem::ThresholdRefiner needs to be initialised with a reference to the estimator. 19 : */ 20 : class MFEMRefinementMarker : public MFEMObject 21 : { 22 : public: 23 : static InputParameters validParams(); 24 : 25 : MFEMRefinementMarker(const InputParameters & params); 26 : 27 26 : virtual ~MFEMRefinementMarker() = default; 28 : 29 : /// Constructs associated mfem::ThresholdRefiner once mfem::ErrorEstimator is guaranteed to exist 30 : void initialSetup(); 31 : 32 : /// Applies p-refinement wherever the refiner sees fit 33 : bool pRefine(); 34 : 35 : /// Applies h-refinement wherever the refiner sees fit 36 : bool hRefine(); 37 : 38 : protected: 39 : /// Unique pointer to underlying mfem::ThresholdRefiner object 40 : std::unique_ptr<mfem::ThresholdRefiner> _threshold_refiner; 41 : 42 : /// The estimator/indicator's name 43 : const std::string & _estimator_name; 44 : 45 : /// The error threshold determining which elements to refine 46 : const mfem::real_t _error_threshold; 47 : 48 : /// Whether to rebalance the mesh after h-refinement 49 : bool _rebalance; 50 : 51 : /// The max no. of times h-refinement can be performed 52 : const unsigned _max_h_level; 53 : 54 : /// The max no. of times h-refinement can be performed 55 : const unsigned _max_p_level; 56 : 57 : /// The no. of times h-refinement has been performed 58 : unsigned _h_ref_counter{0}; 59 : 60 : /// The no. of times p-refinement has been performed 61 : unsigned _p_ref_counter{0}; 62 : 63 : /// Pointer to the estimator/indicator 64 : const MFEMIndicator * _estimator{nullptr}; 65 : }; 66 : 67 : #endif