Skip to content

Commit

Permalink
update some const and pass-by-ref
Browse files Browse the repository at this point in the history
  • Loading branch information
lindsayad committed Jan 9, 2025
1 parent fe8f147 commit d8545b9
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 18 deletions.
2 changes: 1 addition & 1 deletion framework/include/mfem/materials/MFEMMaterial.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class MFEMMaterial : public MFEMGeneralUserObject
const std::vector<SubdomainName> & getBlocks() const { return _block_ids; }

protected:
std::vector<std::string> subdomainsToStrings(std::vector<SubdomainName> blocks);
std::vector<std::string> subdomainsToStrings(const std::vector<SubdomainName> & blocks);

std::vector<SubdomainName> _block_ids;
platypus::PropertyManager & _properties;
Expand Down
12 changes: 6 additions & 6 deletions framework/include/mfem/utils/PropertyManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,12 @@ class PropertyManager
this->declareMatrix<P>(name, std::vector<std::string>(), 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<mfem::Coefficient> getScalarPropertyPtr(const std::string name);
std::shared_ptr<mfem::VectorCoefficient> getVectorPropertyPtr(const std::string name);
std::shared_ptr<mfem::MatrixCoefficient> 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<mfem::Coefficient> getScalarPropertyPtr(const std::string & name);
std::shared_ptr<mfem::VectorCoefficient> getVectorPropertyPtr(const std::string & name);
std::shared_ptr<mfem::MatrixCoefficient> 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;
Expand Down
2 changes: 1 addition & 1 deletion framework/include/mfem/utils/property_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class PropertyMap

private:
using PWData = std::tuple<std::shared_ptr<Tpw>, std::map<const std::string, std::shared_ptr<T>>>;
std::map<const std::string, std::variant<std::shared_ptr<T>, PWData>> _properties;
std::map<std::string, std::variant<std::shared_ptr<T>, PWData>> _properties;
ObjectManager<T> & _manager;

PWData emptyPWData(std::shared_ptr<T> /*coeff*/)
Expand Down
5 changes: 3 additions & 2 deletions framework/src/mfem/ics/MFEMScalarIC.C
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ MFEMScalarIC::MFEMScalarIC(const InputParameters & params) : MFEMGeneralUserObje
void
MFEMScalarIC::execute()
{
auto coeff = getMFEMProblem().getScalarFunctionCoefficient(getParam<FunctionName>("coefficient"));
auto & coeff =
getMFEMProblem().getProperties().getScalarProperty(getParam<FunctionName>("coefficient"));
auto grid_function = getMFEMProblem().getGridFunction(getParam<std::string>("variable"));
grid_function->ProjectCoefficient(*coeff);
grid_function->ProjectCoefficient(coeff);
}

#endif
2 changes: 1 addition & 1 deletion framework/src/mfem/materials/MFEMMaterial.C
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ MFEMMaterial::validParams()
}

std::vector<std::string>
MFEMMaterial::subdomainsToStrings(std::vector<SubdomainName> blocks)
MFEMMaterial::subdomainsToStrings(const std::vector<SubdomainName> & blocks)
{
std::vector<std::string> result(blocks.size());
auto & mesh = getMFEMProblem().mesh().getMFEMParMesh();
Expand Down
14 changes: 7 additions & 7 deletions framework/src/mfem/utils/PropertyManager.C
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ declareCoefficient(PropertyMap<T, Tpw> & map,
const std::string & name,
const std::vector<std::string> & blocks,
std::shared_ptr<T> coef,
const ObjectManager<T> & libmesh_dbg_var(manager))
const ObjectManager<T> &)
{
if (blocks.empty())
{
Expand Down Expand Up @@ -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<mfem::Coefficient>
PropertyManager::getScalarPropertyPtr(const std::string name)
PropertyManager::getScalarPropertyPtr(const std::string & name)
{
return this->_scalar_coeffs.getCoefficientPtr(name);
}

std::shared_ptr<mfem::VectorCoefficient>
PropertyManager::getVectorPropertyPtr(const std::string name)
PropertyManager::getVectorPropertyPtr(const std::string & name)
{
return this->_vector_coeffs.getCoefficientPtr(name);
}

std::shared_ptr<mfem::MatrixCoefficient>
PropertyManager::getMatrixPropertyPtr(const std::string name)
PropertyManager::getMatrixPropertyPtr(const std::string & name)
{
return this->_matrix_coeffs.getCoefficientPtr(name);
}
Expand Down

0 comments on commit d8545b9

Please sign in to comment.