https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
FXIntegralBaseUserObject< IntegralBaseVariableUserObject > Class Template Referenceabstract

This class interacts with a MooseApp through functional expansions. More...

#include <FXIntegralBaseUserObject.h>

Inheritance diagram for FXIntegralBaseUserObject< IntegralBaseVariableUserObject >:
[legend]

Public Member Functions

 FXIntegralBaseUserObject (const InputParameters &parameters)
 
const FunctionSeriesgetFunctionSeries () const
 Return a reference to the underlying function series.
 
virtual Real getValue () const final
 
virtual void finalize () final
 
virtual void initialize () final
 
virtual Real spatialValue (const Point &location) const final
 
virtual void threadJoin (const UserObject &sibling) final
 
Real operator[] (std::size_t index) const
 Get the value of the coefficient at the corresponding index.
 
const std::vector< std::size_t > & getCharacteristics () const
 Get a reference to the characteristics array.
 
const std::vector< Real > & getCoefficients () const
 Get a read-only reference to the vector of coefficients.
 
std::vector< Real > & getCoefficients ()
 Get a writeable reference to the vector of coefficients.
 
std::string getCoefficientsTable () const
 Get a formatted string of the coefficients.
 
std::size_t getSize () const
 Get the size, aka number of coefficients.
 
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.
 
void enforceSize (bool enforce)
 Toggle whether the size of the coefficient array can be changed.
 
void importCoefficients (const MutableCoefficientsInterface &other)
 Import the coefficients from another instance.
 
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.
 
void setCharacteristics (const std::vector< std::size_t > &new_characteristics)
 Sets the characteristics array.
 
void setCoefficients (const std::vector< Real > &new_coefficients)
 Set the coefficients using a copy operation.
 
void setCoefficients (std::vector< Real > &&dropin_coefficients)
 Set the coefficients using a move operation (only works with temp objects)
 

Static Public Member Functions

static InputParameters validParams ()
 

Protected Member Functions

virtual Real computeIntegral () final
 
virtual Point getCentroid () const =0
 Get the centroid of the evaluated unit.
 
virtual Real getVolume () const =0
 Get the volume of the evaluated unit.
 
virtual void coefficientsChanged ()
 Called when the coefficients have been changed.
 
TdeclareRestartableData (const std::string &data_name, Args &&... args)
 
ManagedValue< TdeclareManagedRestartableDataWithContext (const std::string &data_name, void *context, Args &&... args)
 
const TgetRestartableData (const std::string &data_name) const
 
TdeclareRestartableDataWithContext (const std::string &data_name, void *context, Args &&... args)
 
TdeclareRecoverableData (const std::string &data_name, Args &&... args)
 
TdeclareRestartableDataWithObjectName (const std::string &data_name, const std::string &object_name, Args &&... args)
 
TdeclareRestartableDataWithObjectNameWithContext (const std::string &data_name, const std::string &object_name, void *context, Args &&... args)
 
std::string restartableName (const std::string &data_name) const
 

Protected Attributes

std::vector< std::vector< Real > > _coefficient_history
 History of the expansion coefficients for each solve.
 
std::vector< Real > _coefficient_partials
 Current coefficient partial sums.
 
FunctionSeries_function_series
 Reference to the underlying function series.
 
const bool _keep_history
 Keep the expansion coefficients after each solve.
 
const bool _print_state
 Flag to prints the state of the zeroth instance in finalize()
 
const Real _standardized_function_volume
 Volume of the standardized functional space of integration.
 
Real _volume
 Moose volume of evaluation.
 
std::vector< std::size_t > & _characteristics
 An array of integer characteristics that can be used to check compatibility.
 
std::vector< Real > & _coefficients
 The coefficient array.
 
bool _enforce_size
 Boolean that locks or allows resizing of the coefficient array.
 
const bool _print_coefficients
 Boolean to flag if the coefficients should be printed when set.
 
MooseApp_restartable_app
 
const std::string _restartable_system_name
 
const THREAD_ID _restartable_tid
 
const bool _restartable_read_only
 

Private Member Functions

RestartableDataValueregisterRestartableDataOnApp (std::unique_ptr< RestartableDataValue > data, THREAD_ID tid) const
 
void registerRestartableNameWithFilterOnApp (const std::string &name, Moose::RESTARTABLE_FILTER filter)
 
RestartableData< T > & declareRestartableDataHelper (const std::string &data_name, void *context, Args &&... args) const
 

Private Attributes

const ConsoleStream_console
 MooseObject instance of this to provide access to _console
 
const RestartableDataMapName _metaname
 
std::string _restartable_name
 

Detailed Description

template<class IntegralBaseVariableUserObject>
class FXIntegralBaseUserObject< IntegralBaseVariableUserObject >

This class interacts with a MooseApp through functional expansions.

It is templated to allow the inheritance of two dual classes that operate in a volume (FXVolumeUserObject) or on a boundary (FXBoundaryFluxUserObject and FXBoundaryValueUserObject)

It uses an instance of FunctionSeries to generate the orthonormal function series required to generate the functional expansion coefficients.

Definition at line 32 of file FXIntegralBaseUserObject.h.

Constructor & Destructor Documentation

◆ FXIntegralBaseUserObject()

template<class IntegralBaseVariableUserObject >
FXIntegralBaseUserObject< IntegralBaseVariableUserObject >::FXIntegralBaseUserObject ( const InputParameters parameters)

Definition at line 127 of file FXIntegralBaseUserObject.h.

129 : IntegralBaseVariableUserObject(parameters),
130 MutableCoefficientsInterface(this, parameters),
132 FunctionSeries::checkAndConvertFunction(getFunction("function"), this->getBase(), name())),
133 _keep_history(UserObject::getParam<bool>("keep_history")),
134 _print_state(UserObject::getParam<bool>("print_state")),
136{
137 // Size the coefficient arrays
141
142 if (!_keep_history)
143 _coefficient_history.resize(0);
144}
const std::string name
Definition Setup.h:21
const bool _print_state
Flag to prints the state of the zeroth instance in finalize()
const Real _standardized_function_volume
Volume of the standardized functional space of integration.
std::vector< std::vector< Real > > _coefficient_history
History of the expansion coefficients for each solve.
FunctionSeries & _function_series
Reference to the underlying function series.
std::vector< Real > _coefficient_partials
Current coefficient partial sums.
const bool _keep_history
Keep the expansion coefficients after each solve.
std::size_t getNumberOfTerms() const
Returns the number of terms (coefficients) in the underlying function series.
const std::vector< std::size_t > & getOrders() const
Returns a vector of the functional orders in the underlying functional series.
static FunctionSeries & checkAndConvertFunction(const Function &function, const std::string &typeName, const std::string &objectName)
Static function to cast a Function to SeriesFunction.
Real getStandardizedFunctionVolume() const
Returns the volume of evaluation in the functional series standardized space.
This class is designed to provide a uniform interface for any class that uses an array of coefficient...
std::vector< std::size_t > & _characteristics
An array of integer characteristics that can be used to check compatibility.
std::vector< Real > & _coefficients
The coefficient array.
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.

Member Function Documentation

◆ coefficientsChanged()

virtual void MutableCoefficientsInterface::coefficientsChanged ( )
inlineprotectedvirtualinherited

◆ computeIntegral()

template<class IntegralBaseVariableUserObject >
Real FXIntegralBaseUserObject< IntegralBaseVariableUserObject >::computeIntegral ( )
finalprotectedvirtual

Definition at line 148 of file FXIntegralBaseUserObject.h.

149{
150 Real sum = 0.0;
151 const Point centroid = getCentroid();
152
153 // Check to see if this element/side is within the valid boundaries
155 return 0.0;
156
157 // Loop over the quadrature points
158 for (_qp = 0; _qp < _q_point.size(); ++_qp)
159 {
160 // Get the functional terms for a vectorized approach
161 _function_series.setLocation(_q_point[_qp]);
162 const std::vector<Real> & term_evaluations = _function_series.getGeneration();
163
164 // Evaluate the functional expansion coefficients at each quadrature point
165 const Real local_contribution = computeQpIntegral();
166 const Real common_evaluation = local_contribution * _JxW[_qp] * _coord[_qp];
167 for (std::size_t c = 0; c < _coefficient_partials.size(); ++c)
168 _coefficient_partials[c] += term_evaluations[c] * common_evaluation;
169
170 sum += local_contribution;
171 }
172
173 _volume += getVolume();
174
175 return sum;
176}
virtual Real getVolume() const =0
Get the volume of the evaluated unit.
Real _volume
Moose volume of evaluation.
virtual Point getCentroid() const =0
Get the centroid of the evaluated unit.
void setLocation(const Point &point)
Set the current evaluation location.
bool isInPhysicalBounds(const Point &point) const
Returns true if the provided point is within the set physical boundaries.
const std::vector< Real > & getGeneration()
Returns a vector of the generation-evaluated functional series at the current location.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real

◆ enforceSize()

void MutableCoefficientsInterface::enforceSize ( bool  enforce)
inherited

Toggle whether the size of the coefficient array can be changed.

Definition at line 111 of file MutableCoefficientsInterface.C.

112{
113 _enforce_size = enforce;
114}
bool _enforce_size
Boolean that locks or allows resizing of the coefficient array.

Referenced by FunctionSeries::FunctionSeries(), and MutableCoefficientsFunctionInterface::MutableCoefficientsFunctionInterface().

◆ finalize()

template<class IntegralBaseVariableUserObject >
void FXIntegralBaseUserObject< IntegralBaseVariableUserObject >::finalize ( )
finalvirtual

Definition at line 180 of file FXIntegralBaseUserObject.h.

181{
182 // Sum the coefficient arrays over all processes
183 _communicator.sum(_coefficient_partials);
184 _communicator.sum(_volume);
185
186 // Normalize the volume of the functional expansion to the FX standard space
187 const Real volume_normalization = _standardized_function_volume / _volume;
188 for (auto & partial : _coefficient_partials)
189 partial *= volume_normalization;
190
191 // We now have the completely evaluated coefficients
193
194 // The average value is the same as the zeroth coefficient
195 _integral_value = _coefficient_partials[0];
196
197 if (_keep_history)
199
200 if (_print_state)
201 {
203 _console << COLOR_YELLOW << _function_series << COLOR_DEFAULT << std::endl;
204 }
205}
void setCoefficients(const std::vector< Real > &new_coefficients)
Set the coefficients using a copy operation.
const ConsoleStream & _console
MooseObject instance of this to provide access to _console

◆ getCentroid()

template<class IntegralBaseVariableUserObject >
virtual Point FXIntegralBaseUserObject< IntegralBaseVariableUserObject >::getCentroid ( ) const
protectedpure virtual

Get the centroid of the evaluated unit.

Implemented in FXVolumeUserObject, and FXBoundaryBaseUserObject.

◆ getCharacteristics()

const std::vector< std::size_t > & MutableCoefficientsInterface::getCharacteristics ( ) const
inherited

Get a reference to the characteristics array.

Definition at line 51 of file MutableCoefficientsInterface.C.

52{
53 return _characteristics;
54}

◆ getCoefficients() [1/2]

std::vector< Real > & MutableCoefficientsInterface::getCoefficients ( )
inherited

Get a writeable reference to the vector of coefficients.

Definition at line 63 of file MutableCoefficientsInterface.C.

64{
65 return _coefficients;
66}

◆ getCoefficients() [2/2]

const std::vector< Real > & MutableCoefficientsInterface::getCoefficients ( ) const
inherited

Get a read-only reference to the vector of coefficients.

Definition at line 57 of file MutableCoefficientsInterface.C.

58{
59 return _coefficients;
60}

◆ getCoefficientsTable()

std::string MutableCoefficientsInterface::getCoefficientsTable ( ) const
inherited

Get a formatted string of the coefficients.

Definition at line 69 of file MutableCoefficientsInterface.C.

70{
71 std::stringbuf string;
72 std::ostream table(&string);
73
74 table << *this;
75
76 return string.str();
77}

◆ getFunctionSeries()

template<class IntegralBaseVariableUserObject >
const FunctionSeries & FXIntegralBaseUserObject< IntegralBaseVariableUserObject >::getFunctionSeries ( ) const

Return a reference to the underlying function series.

Definition at line 209 of file FXIntegralBaseUserObject.h.

210{
211 return _function_series;
212}

◆ getSize()

std::size_t MutableCoefficientsInterface::getSize ( ) const
inherited

Get the size, aka number of coefficients.

Definition at line 80 of file MutableCoefficientsInterface.C.

81{
82 return _coefficients.size();
83}

Referenced by MutableCoefficientsInterface::isCompatibleWith().

◆ getValue()

template<class IntegralBaseVariableUserObject >
Real FXIntegralBaseUserObject< IntegralBaseVariableUserObject >::getValue ( ) const
finalvirtual

Definition at line 216 of file FXIntegralBaseUserObject.h.

217{
218 return _integral_value;
219}

◆ getVolume()

template<class IntegralBaseVariableUserObject >
virtual Real FXIntegralBaseUserObject< IntegralBaseVariableUserObject >::getVolume ( ) const
protectedpure virtual

Get the volume of the evaluated unit.

Implemented in FXVolumeUserObject, and FXBoundaryBaseUserObject.

◆ importCoefficients()

void MutableCoefficientsInterface::importCoefficients ( const MutableCoefficientsInterface other)
inherited

Import the coefficients from another instance.

Definition at line 117 of file MutableCoefficientsInterface.C.

118{
119 if (!isCompatibleWith(other))
120 mooseError("Cannot import coefficients from incompatible MutableCoefficientsInterface");
121
123
125 _console << *this;
126
128}
void mooseError(Args &&... args)
virtual void coefficientsChanged()
Called when the coefficients have been changed.
const bool _print_coefficients
Boolean to flag if the coefficients should be printed when set.
bool isCompatibleWith(const MutableCoefficientsInterface &other) const
Checks to see if another instance is compatible.

Referenced by MultiAppFXTransfer::execute().

◆ initialize()

template<class IntegralBaseVariableUserObject >
void FXIntegralBaseUserObject< IntegralBaseVariableUserObject >::initialize ( )
finalvirtual

Definition at line 223 of file FXIntegralBaseUserObject.h.

224{
225 IntegralBaseVariableUserObject::initialize();
226
227 // Clear the partial sums
228 for (auto & partial : _coefficient_partials)
229 partial = 0;
230
231 _volume = 0;
232}

◆ isCompatibleWith()

bool MutableCoefficientsInterface::isCompatibleWith ( const MutableCoefficientsInterface other) const
inherited

Checks to see if another instance is compatible.

Definition at line 86 of file MutableCoefficientsInterface.C.

87{
88 // Check the coefficient sizes if requested
89 if ((_enforce_size && other._enforce_size) && getSize() != other.getSize())
90 return false;
91
92 // Check the size of the characteristics array
93 if (_characteristics.size() != other._characteristics.size())
94 return false;
95
96 // Check the values of the characteristics array
97 for (std::size_t i = 0; i < _characteristics.size(); ++i)
98 if (_characteristics[i] != other._characteristics[i])
99 return false;
100
101 return true;
102}
std::size_t getSize() const
Get the size, aka number of coefficients.

Referenced by MultiAppFXTransfer::execute(), and MutableCoefficientsInterface::importCoefficients().

◆ isSizeEnforced()

bool MutableCoefficientsInterface::isSizeEnforced ( ) const
inherited

Returns true if the size of the coefficient array is fixed and enforced.

Definition at line 105 of file MutableCoefficientsInterface.C.

106{
107 return _enforce_size;
108}

◆ operator[]()

Real MutableCoefficientsInterface::operator[] ( std::size_t  index) const
inherited

Get the value of the coefficient at the corresponding index.

Definition at line 45 of file MutableCoefficientsInterface.C.

46{
47 return _coefficients[index];
48}

◆ resize()

void MutableCoefficientsInterface::resize ( std::size_t  size,
Real  fill = 0.0,
bool  fill_out_to_size = true 
)
inherited

Resize the array, using the value for fill if the new size is larger.

Definition at line 131 of file MutableCoefficientsInterface.C.

132{
133 if (size != _coefficients.size())
134 {
135 if (_enforce_size &&
136 (size > _coefficients.size() || (size < _coefficients.size() && !fill_out_to_size)))
137 mooseError("Cannot resize coefficient array with size enforcement enabled.");
138
139 _coefficients.resize(size, fill);
140
142 _console << *this;
143
145 }
146}

Referenced by FunctionSeries::FunctionSeries(), and FXIntegralBaseUserObject< IntegralBaseVariableUserObject >::FXIntegralBaseUserObject().

◆ setCharacteristics()

void MutableCoefficientsInterface::setCharacteristics ( const std::vector< std::size_t > &  new_characteristics)
inherited

Sets the characteristics array.

Definition at line 149 of file MutableCoefficientsInterface.C.

151{
152 _characteristics = new_characteristics;
153}

Referenced by FunctionSeries::FunctionSeries().

◆ setCoefficients() [1/2]

void MutableCoefficientsInterface::setCoefficients ( const std::vector< Real > &  new_coefficients)
inherited

Set the coefficients using a copy operation.

Definition at line 156 of file MutableCoefficientsInterface.C.

157{
158 if (_enforce_size && new_coefficients.size() != _coefficients.size())
159 mooseError("Cannon assigned a coefficient array with differing size when size enforcement is "
160 "enabled.");
161
162 _coefficients = new_coefficients;
163
165 _console << *this;
166
168}

Referenced by MutableCoefficientsFunctionInterface::MutableCoefficientsFunctionInterface().

◆ setCoefficients() [2/2]

void MutableCoefficientsInterface::setCoefficients ( std::vector< Real > &&  dropin_coefficients)
inherited

Set the coefficients using a move operation (only works with temp objects)

Definition at line 171 of file MutableCoefficientsInterface.C.

172{
173 if (_enforce_size && dropin_coefficients.size() != _coefficients.size())
174 mooseError("Cannon assigned a coefficient array with differing size when size enforcement is "
175 "enabled.");
176
177 _coefficients = dropin_coefficients;
178
180 _console << *this;
181
183}

◆ spatialValue()

template<class IntegralBaseVariableUserObject >
Real FXIntegralBaseUserObject< IntegralBaseVariableUserObject >::spatialValue ( const Point &  location) const
finalvirtual

Definition at line 249 of file FXIntegralBaseUserObject.h.

250{
252
254}
Real expand()
Expand the function series at the current location and with the current coefficients.

◆ threadJoin()

template<class IntegralBaseVariableUserObject >
void FXIntegralBaseUserObject< IntegralBaseVariableUserObject >::threadJoin ( const UserObject sibling)
finalvirtual

Definition at line 236 of file FXIntegralBaseUserObject.h.

237{
240
241 for (std::size_t c = 0; c < _coefficient_partials.size(); ++c)
243
244 _volume += sibling._volume;
245}
This class interacts with a MooseApp through functional expansions.

◆ validParams()

template<class IntegralBaseVariableUserObject >
InputParameters FXIntegralBaseUserObject< IntegralBaseVariableUserObject >::validParams ( )
static

Definition at line 106 of file FXIntegralBaseUserObject.h.

107{
108 InputParameters params = IntegralBaseVariableUserObject::validParams();
110
111 params.addClassDescription(
112 "This UserObject interacts with a MooseApp through functional expansions.");
113
114 params.addRequiredParam<FunctionName>("function",
115 "The name of the FunctionSeries \"Function\" object with "
116 "which to generate this functional expansion.");
117
118 params.addParam<bool>(
119 "keep_history", false, "Keep the expansion coefficients from previous solves");
120
121 params.addParam<bool>("print_state", false, "Print the state of the zeroth instance each solve");
122
123 return params;
124}
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)

Referenced by FXBoundaryBaseUserObject::validParams(), and FXVolumeUserObject::validParams().

Member Data Documentation

◆ _characteristics

std::vector<std::size_t>& MutableCoefficientsInterface::_characteristics
protectedinherited

◆ _coefficient_history

template<class IntegralBaseVariableUserObject >
std::vector<std::vector<Real> > FXIntegralBaseUserObject< IntegralBaseVariableUserObject >::_coefficient_history
protected

History of the expansion coefficients for each solve.

Definition at line 83 of file FXIntegralBaseUserObject.h.

Referenced by FXIntegralBaseUserObject< IntegralBaseVariableUserObject >::FXIntegralBaseUserObject().

◆ _coefficient_partials

template<class IntegralBaseVariableUserObject >
std::vector<Real> FXIntegralBaseUserObject< IntegralBaseVariableUserObject >::_coefficient_partials
protected

◆ _coefficients

std::vector<Real>& MutableCoefficientsInterface::_coefficients
protectedinherited

◆ _console

const ConsoleStream& MutableCoefficientsInterface::_console
privateinherited

◆ _enforce_size

bool MutableCoefficientsInterface::_enforce_size
protectedinherited

◆ _function_series

template<class IntegralBaseVariableUserObject >
FunctionSeries& FXIntegralBaseUserObject< IntegralBaseVariableUserObject >::_function_series
protected

Reference to the underlying function series.

Definition at line 89 of file FXIntegralBaseUserObject.h.

Referenced by FXIntegralBaseUserObject< IntegralBaseVariableUserObject >::FXIntegralBaseUserObject().

◆ _keep_history

template<class IntegralBaseVariableUserObject >
const bool FXIntegralBaseUserObject< IntegralBaseVariableUserObject >::_keep_history
protected

Keep the expansion coefficients after each solve.

Definition at line 92 of file FXIntegralBaseUserObject.h.

Referenced by FXIntegralBaseUserObject< IntegralBaseVariableUserObject >::FXIntegralBaseUserObject().

◆ _print_coefficients

const bool MutableCoefficientsInterface::_print_coefficients
protectedinherited

◆ _print_state

template<class IntegralBaseVariableUserObject >
const bool FXIntegralBaseUserObject< IntegralBaseVariableUserObject >::_print_state
protected

Flag to prints the state of the zeroth instance in finalize()

Definition at line 95 of file FXIntegralBaseUserObject.h.

◆ _standardized_function_volume

template<class IntegralBaseVariableUserObject >
const Real FXIntegralBaseUserObject< IntegralBaseVariableUserObject >::_standardized_function_volume
protected

Volume of the standardized functional space of integration.

Definition at line 98 of file FXIntegralBaseUserObject.h.

◆ _volume

template<class IntegralBaseVariableUserObject >
Real FXIntegralBaseUserObject< IntegralBaseVariableUserObject >::_volume
protected

The documentation for this class was generated from the following file: