Go to the documentation of this file.
13 #include "MooseObject.h"
21 InputParameters params = emptyInputParameters();
23 params.addClassDescription(
"This interface universalizes the communication standards for "
24 "array-based coefficient transfers.");
26 params.addParam<
bool>(
"print_when_set",
false,
"Print the array of coefficients when set");
32 const InputParameters & parameters)
33 : Restartable(moose_object->getMooseApp(),
34 moose_object->
name() +
"_coefs",
35 "MutableCoefficientsInterface",
36 moose_object->parameters().get<THREAD_ID>(
"_tid")),
37 _characteristics(declareRestartableData<std::vector<std::size_t>>(
"characteristics")),
38 _coefficients(declareRestartableData<std::vector<Real>>(
"coefficients")),
40 _print_coefficients(parameters.get<bool>(
"print_when_set")),
41 _console(moose_object->_console)
50 const std::vector<std::size_t> &
56 const std::vector<Real> &
71 std::stringbuf string;
72 std::ostream table(&
string);
120 mooseError(
"Cannot import coefficients from incompatible MutableCoefficientsInterface");
137 mooseError(
"Cannot resize coefficient array with size enforcement enabled.");
150 const std::vector<std::size_t> & new_characteristics)
159 mooseError(
"Cannon assigned a coefficient array with differing size when size enforcement is "
174 mooseError(
"Cannon assigned a coefficient array with differing size when size enforcement is "
188 const MooseObject * myself_again = dynamic_cast<const MooseObject *>(&me);
190 <<
"MutableCoefficientsInterface: " << (myself_again ? myself_again->name() :
"Unknown")
192 <<
" Number of Coefficients: " << me.
getSize() <<
"\n";
194 for (std::size_t i = 0; i < me.
getSize(); ++i)
195 stream << std::setw(4) << i <<
": " << std::setw(12) << me[i] << ((i % 6 == 5) ?
"\n" :
" ");
const std::vector< std::size_t > & getCharacteristics() const
Get a reference to the characteristics array.
const bool _print_coefficients
Boolean to flag if the coefficients should be printed when set.
void setCharacteristics(const std::vector< std::size_t > &new_characteristics)
Sets the characteristics array.
std::ostream & operator<<(std::ostream &stream, const MutableCoefficientsInterface &me)
void resize(std::size_t size, Real fill=0.0, bool fill_out_to_size=true)
Resize the array, using the value for fill if the new size is larger.
const ConsoleStream & _console
MooseObject instance of this to provide access to _console
void importCoefficients(const MutableCoefficientsInterface &other)
Import the coefficients from another instance.
InputParameters validParams< MutableCoefficientsInterface >()
const std::vector< Real > & getCoefficients() const
Get a read-only reference to the vector of coefficients.
std::vector< Real > & _coefficients
The coefficient array.
std::vector< std::size_t > & _characteristics
An array of integer characteristics that can be used to check compatibility.
std::string getCoefficientsTable() const
Get a formatted string of the coefficients.
std::size_t getSize() const
Get the size, aka number of coefficients.
void enforceSize(bool enforce)
Toggle whether the size of the coefficient array can be changed.
virtual void coefficientsChanged()
Called when the coefficients have been changed.
Real operator[](std::size_t index) const
Get the value of the coefficient at the corresponding index.
void setCoefficients(const std::vector< Real > &new_coefficients)
Set the coefficients using a copy operation.
MutableCoefficientsInterface(const MooseObject *moose_object, const InputParameters ¶meters)
This class is designed to provide a uniform interface for any class that uses an array of coefficient...
bool isCompatibleWith(const MutableCoefficientsInterface &other) const
Checks to see if another instance is compatible.
bool isSizeEnforced() const
Returns true if the size of the coefficient array is fixed and enforced.
bool _enforce_size
Boolean that locks or allows resizing of the coefficient array.