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 : 12 : #pragma once 13 : 14 : #include "MFEMObject.h" 15 : #include "MFEMContainers.h" 16 : #include "MFEMVariable.h" 17 : 18 : /* 19 : * Wrapper class for mfem::ErrorEstimator objects. To keep the 20 : * naming consistent with MOOSE, we refer to it as an Indicator. 21 : */ 22 : class MFEMIndicator : public MFEMObject 23 : { 24 : public: 25 : static InputParameters validParams(); 26 : 27 : MFEMIndicator(const InputParameters & params); 28 : 29 26 : virtual ~MFEMIndicator() = default; 30 : 31 : /// Create the estimator internally. 32 : virtual void createEstimator() = 0; 33 : 34 : /// Get reference to FE space using the name we store when setting up this class 35 52 : mfem::ParFiniteElementSpace & getFESpace() const { return _fespace; } 36 : 37 : /// Get reference to the FE space's underlying mesh 38 143 : mfem::ParMesh & getParMesh() const { return *(_fespace.GetParMesh()); } 39 : 40 : /// Method to fetch the error estimator after creation 41 : std::shared_ptr<mfem::ErrorEstimator> getEstimator() const; 42 : 43 : protected: 44 : /// Name of the variable associated with the weak form that the kernel is applied to 45 : const VariableName & _var_name; 46 : 47 : /// Name of the kernel providing the error estimate 48 : const std::string & _kernel_name; 49 : 50 : /// Shared pointer to the MFEM estimator wrapped by this class 51 : std::shared_ptr<mfem::ErrorEstimator> _error_estimator; 52 : 53 : // FE space that the variable lives in 54 : mfem::ParFiniteElementSpace & _fespace; 55 : }; 56 : 57 : inline std::shared_ptr<mfem::ErrorEstimator> 58 26 : MFEMIndicator::getEstimator() const 59 : { 60 : mooseAssert(_error_estimator, 61 : "Attempting to retrieve error estimator before it's been constructed"); 62 26 : return _error_estimator; 63 : } 64 : 65 : #endif