From d8545b949a9c9a5f4bc4dfac8f8e1d03bf5b0f4e Mon Sep 17 00:00:00 2001 From: Alex Lindsay Date: Tue, 3 Dec 2024 13:58:53 -0800 Subject: [PATCH] update some const and pass-by-ref --- framework/include/mfem/materials/MFEMMaterial.h | 2 +- framework/include/mfem/utils/PropertyManager.h | 12 ++++++------ framework/include/mfem/utils/property_map.h | 2 +- framework/src/mfem/ics/MFEMScalarIC.C | 5 +++-- framework/src/mfem/materials/MFEMMaterial.C | 2 +- framework/src/mfem/utils/PropertyManager.C | 14 +++++++------- 6 files changed, 19 insertions(+), 18 deletions(-) diff --git a/framework/include/mfem/materials/MFEMMaterial.h b/framework/include/mfem/materials/MFEMMaterial.h index 260d2e1d0a29..74b521eb5a82 100644 --- a/framework/include/mfem/materials/MFEMMaterial.h +++ b/framework/include/mfem/materials/MFEMMaterial.h @@ -20,7 +20,7 @@ class MFEMMaterial : public MFEMGeneralUserObject const std::vector & getBlocks() const { return _block_ids; } protected: - std::vector subdomainsToStrings(std::vector blocks); + std::vector subdomainsToStrings(const std::vector & blocks); std::vector _block_ids; platypus::PropertyManager & _properties; diff --git a/framework/include/mfem/utils/PropertyManager.h b/framework/include/mfem/utils/PropertyManager.h index 52bb4c5af6d6..125217734f4a 100644 --- a/framework/include/mfem/utils/PropertyManager.h +++ b/framework/include/mfem/utils/PropertyManager.h @@ -98,12 +98,12 @@ class PropertyManager this->declareMatrix

(name, std::vector(), args...); } - mfem::Coefficient & getScalarProperty(const std::string name); - mfem::VectorCoefficient & getVectorProperty(const std::string name); - mfem::MatrixCoefficient & getMatrixProperty(const std::string name); - std::shared_ptr getScalarPropertyPtr(const std::string name); - std::shared_ptr getVectorPropertyPtr(const std::string name); - std::shared_ptr getMatrixPropertyPtr(const std::string name); + mfem::Coefficient & getScalarProperty(const std::string & name); + mfem::VectorCoefficient & getVectorProperty(const std::string & name); + mfem::MatrixCoefficient & getMatrixProperty(const std::string & name); + std::shared_ptr getScalarPropertyPtr(const std::string & name); + std::shared_ptr getVectorPropertyPtr(const std::string & name); + std::shared_ptr getMatrixPropertyPtr(const std::string & name); bool scalarIsDefined(const std::string & name, const std::string & block) const; bool vectorIsDefined(const std::string & name, const std::string & block) const; bool matrixIsDefined(const std::string & name, const std::string & block) const; diff --git a/framework/include/mfem/utils/property_map.h b/framework/include/mfem/utils/property_map.h index a1045c1f24f7..fa42ed9e52ba 100644 --- a/framework/include/mfem/utils/property_map.h +++ b/framework/include/mfem/utils/property_map.h @@ -129,7 +129,7 @@ class PropertyMap private: using PWData = std::tuple, std::map>>; - std::map, PWData>> _properties; + std::map, PWData>> _properties; ObjectManager & _manager; PWData emptyPWData(std::shared_ptr /*coeff*/) diff --git a/framework/src/mfem/ics/MFEMScalarIC.C b/framework/src/mfem/ics/MFEMScalarIC.C index 82ef294bcb64..4b94f82ababe 100644 --- a/framework/src/mfem/ics/MFEMScalarIC.C +++ b/framework/src/mfem/ics/MFEMScalarIC.C @@ -28,9 +28,10 @@ MFEMScalarIC::MFEMScalarIC(const InputParameters & params) : MFEMGeneralUserObje void MFEMScalarIC::execute() { - auto coeff = getMFEMProblem().getScalarFunctionCoefficient(getParam("coefficient")); + auto & coeff = + getMFEMProblem().getProperties().getScalarProperty(getParam("coefficient")); auto grid_function = getMFEMProblem().getGridFunction(getParam("variable")); - grid_function->ProjectCoefficient(*coeff); + grid_function->ProjectCoefficient(coeff); } #endif diff --git a/framework/src/mfem/materials/MFEMMaterial.C b/framework/src/mfem/materials/MFEMMaterial.C index 67420fbdc73e..e8a8d557b6b3 100644 --- a/framework/src/mfem/materials/MFEMMaterial.C +++ b/framework/src/mfem/materials/MFEMMaterial.C @@ -24,7 +24,7 @@ MFEMMaterial::validParams() } std::vector -MFEMMaterial::subdomainsToStrings(std::vector blocks) +MFEMMaterial::subdomainsToStrings(const std::vector & blocks) { std::vector result(blocks.size()); auto & mesh = getMFEMProblem().mesh().getMFEMParMesh(); diff --git a/framework/src/mfem/utils/PropertyManager.C b/framework/src/mfem/utils/PropertyManager.C index 00e3311f67ac..6cb2d1fed740 100644 --- a/framework/src/mfem/utils/PropertyManager.C +++ b/framework/src/mfem/utils/PropertyManager.C @@ -13,7 +13,7 @@ declareCoefficient(PropertyMap & map, const std::string & name, const std::vector & blocks, std::shared_ptr coef, - const ObjectManager & libmesh_dbg_var(manager)) + const ObjectManager &) { if (blocks.empty()) { @@ -94,37 +94,37 @@ PropertyManager::declareMatrix(const std::string & name, } mfem::Coefficient & -PropertyManager::getScalarProperty(const std::string name) +PropertyManager::getScalarProperty(const std::string & name) { return this->_scalar_coeffs.getCoefficient(name); } mfem::VectorCoefficient & -PropertyManager::getVectorProperty(const std::string name) +PropertyManager::getVectorProperty(const std::string & name) { return this->_vector_coeffs.getCoefficient(name); } mfem::MatrixCoefficient & -PropertyManager::getMatrixProperty(const std::string name) +PropertyManager::getMatrixProperty(const std::string & name) { return this->_matrix_coeffs.getCoefficient(name); } std::shared_ptr -PropertyManager::getScalarPropertyPtr(const std::string name) +PropertyManager::getScalarPropertyPtr(const std::string & name) { return this->_scalar_coeffs.getCoefficientPtr(name); } std::shared_ptr -PropertyManager::getVectorPropertyPtr(const std::string name) +PropertyManager::getVectorPropertyPtr(const std::string & name) { return this->_vector_coeffs.getCoefficientPtr(name); } std::shared_ptr -PropertyManager::getMatrixPropertyPtr(const std::string name) +PropertyManager::getMatrixPropertyPtr(const std::string & name) { return this->_matrix_coeffs.getCoefficientPtr(name); }