10#ifdef MOOSE_MFEM_ENABLED
35 const std::vector<std::string> &
blocks,
36 std::shared_ptr<mfem::Coefficient> coef)
44 const std::vector<std::string> &
blocks,
45 const std::string & existing_or_literal)
48 if (std::dynamic_pointer_cast<mfem::PWCoefficient>(coef))
49 mooseError(
"Properties must not be defined out of other properties or piecewise coefficients.");
53mfem::VectorCoefficient &
55 std::shared_ptr<mfem::VectorCoefficient> coef)
61mfem::VectorCoefficient &
67mfem::VectorCoefficient &
69 const std::vector<std::string> &
blocks,
70 std::shared_ptr<mfem::VectorCoefficient> coef)
76mfem::VectorCoefficient &
78 const std::vector<std::string> &
blocks,
79 const std::string & existing_or_literal)
81 std::shared_ptr<mfem::VectorCoefficient> coef =
83 if (std::dynamic_pointer_cast<mfem::PWVectorCoefficient>(coef))
84 mooseError(
"Properties must not be defined out of other properties or piecewise coefficients.");
88mfem::MatrixCoefficient &
90 std::shared_ptr<mfem::MatrixCoefficient> coef)
96mfem::MatrixCoefficient &
102mfem::MatrixCoefficient &
104 const std::vector<std::string> &
blocks,
105 std::shared_ptr<mfem::MatrixCoefficient> coef)
111mfem::MatrixCoefficient &
113 const std::vector<std::string> &
blocks,
114 const std::string & existing_coef)
117 if (std::dynamic_pointer_cast<mfem::PWMatrixCoefficient>(coef))
118 mooseError(
"Properties must not be defined out of other properties or piecewise coefficients.");
122std::shared_ptr<mfem::Coefficient>
129 mfem::real_t real_value;
130 if (ss >> real_value && ss.eof())
132 this->declareScalar<mfem::ConstantCoefficient>(name, real_value);
135 mooseError(
"Scalar coefficient with name '" + name +
"' has not been declared.");
138std::shared_ptr<mfem::VectorCoefficient>
144 std::vector<mfem::real_t> vec_values;
147 this->declareVector<mfem::VectorConstantCoefficient>(
148 name, mfem::Vector(vec_values.data(), vec_values.size()));
151 mooseError(
"Vector coefficient with name '" + name +
"' has not been declared.");
154std::shared_ptr<mfem::MatrixCoefficient>
162 std::vector<std::string> row_strs;
164 std::vector<std::vector<mfem::real_t>> rows;
165 for (
const auto & row_str : row_strs)
167 std::vector<mfem::real_t> row_vals;
170 rows.push_back(row_vals);
171 if (rows.back().size() != rows.front().size())
172 mooseError(
"Matrix coefficient literal '" + name +
"' has rows of differing length.");
175 if (rows.size() ==
static_cast<std::size_t
>(std::count(name.begin(), name.end(),
';')) + 1)
177 const int nrows =
static_cast<int>(rows.size());
178 const int ncols =
static_cast<int>(rows.front().size());
179 mfem::DenseMatrix mat(nrows, ncols);
180 for (
int i = 0; i < nrows; ++i)
181 for (
int j = 0; j < ncols; ++j)
182 mat(i, j) = rows[i][j];
183 this->declareMatrix<mfem::MatrixConstantCoefficient>(name, mat);
186 mooseError(
"Matrix coefficient with name '" + name +
"' has not been declared.");
195mfem::VectorCoefficient &
201mfem::MatrixCoefficient &
209 const std::string & block)
const
216 const std::string & block)
const
223 const std::string & block)
const
239 auto mark_solution_changed = [](
auto & coef)
242 qf_coef->MarkSolutionChanged();
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Shared lazy-update state for quadrature function coefficients.
std::shared_ptr< mfem::Coefficient > getScalarCoefficientPtr(const std::string &name)
mfem::VectorCoefficient & declareVectorProperty(const std::string &name, const std::vector< std::string > &blocks, const std::string &existing_or_literal)
Use an existing vector coefficient for a property on some blocks of the mesh.
bool scalarPropertyIsDefined(const std::string &name, const std::string &block) const
std::shared_ptr< mfem::VectorCoefficient > getVectorCoefficientPtr(const std::string &name)
mfem::Coefficient & declareScalarProperty(const std::string &name, const std::vector< std::string > &blocks, const std::string &existing_or_literal)
Use an existing scalar coefficient for a property on some blocks of the mesh.
void setTime(const mfem::real_t time)
mfem::Coefficient & declareScalar(const std::string &name, const std::string &existing_or_literal)
Declare an alias to an existing scalar coefficient or, if it does not exist, try interpreting the nam...
mfem::MatrixCoefficient & declareMatrixProperty(const std::string &name, const std::vector< std::string > &blocks, const std::string &existing_coef)
Use an existing matrix coefficient for a property on some blocks of the mesh.
mfem::MatrixCoefficient & declareMatrix(const std::string &name, const std::string &existing_coef)
Declare an alias to an existing matrix coefficient.
mfem::MatrixCoefficient & getMatrixCoefficient(const std::string &name)
Return scalar coefficient with the given name.
mfem::VectorCoefficient & getVectorCoefficient(const std::string &name)
Return a vector coefficient with the given name or, if that doesn't exist, try interpreting the name ...
bool vectorPropertyIsDefined(const std::string &name, const std::string &block) const
mfem::Coefficient & getScalarCoefficient(const std::string &name)
Return a scalar coefficient with the given name or, if that doesn't exist, try interpreting the name ...
void markSolutionChanged()
Notify quadrature function coefficients that solution variables have changed, marking the stored valu...
mfem::VectorCoefficient & declareVector(const std::string &name, const std::string &existing_or_literal)
Declare an alias to an existing vector coefficientor or, if it does not exist, try interpreting the n...
std::shared_ptr< mfem::MatrixCoefficient > getMatrixCoefficientPtr(const std::string &name)
bool matrixPropertyIsDefined(const std::string &name, const std::string &block) const
bool propertyDefinedOnBlock(const std::string &name, const std::string &block) const
void addCoefficient(const std::string &name, std::shared_ptr< T > coeff)
Add a named global coefficient.
bool hasCoefficient(const std::string &name) const
void addPiecewiseBlocks(const std::string &name, std::shared_ptr< T > coeff, const std::vector< std::string > &blocks)
Add piecewise material property.
std::shared_ptr< T > getCoefficientPtr(const std::string &name)
void setTime(const mfem::real_t time)
void apply(F &&func)
Apply a function to every coefficient created by this map.
bool tokenizeAndConvert(const std::string &str, std::vector< T > &tokenized_vector, const std::string &delimiter=" \t\n\v\f\r")
tokenizeAndConvert splits a string using delimiter and then converts to type T.
void tokenize(const std::string &str, std::vector< T > &elements, unsigned int min_len=1, const std::string &delims="/")
This function will split the passed in string on a set of delimiters appending the substrings to the ...
std::string trim(const std::string &str, const std::string &white_space=" \t\n\v\f\r")
Standard scripting language trim function.
Utilities for converting between vector(s) of libMesh Points and MFEM Vector(s).