www.mooseframework.org
Public Member Functions | Protected Member Functions | Protected Attributes | 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. More...
 
virtual Real getValue () 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. More...
 
const std::vector< std::size_t > & getCharacteristics () const
 Get a reference to the characteristics array. More...
 
const std::vector< Real > & getCoefficients () const
 Get a read-only reference to the vector of coefficients. More...
 
std::vector< Real > & getCoefficients ()
 Get a writeable reference to the vector of coefficients. More...
 
std::string getCoefficientsTable () const
 Get a formatted string of the coefficients. More...
 
std::size_t getSize () const
 Get the size, aka number of coefficients. More...
 
bool isCompatibleWith (const MutableCoefficientsInterface &other) const
 Checks to see if another instance is compatible. More...
 
bool isSizeEnforced () const
 Returns true if the size of the coefficient array is fixed and enforced. More...
 
void enforceSize (bool enforce)
 Toggle whether the size of the coefficient array can be changed. More...
 
void importCoefficients (const MutableCoefficientsInterface &other)
 Import the coefficients from another instance. More...
 
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. More...
 
void setCharacteristics (const std::vector< std::size_t > &new_characteristics)
 Sets the characteristics array. More...
 
void setCoefficients (const std::vector< Real > &new_coefficients)
 Set the coefficients using a copy operation. More...
 
void setCoefficients (std::vector< Real > &&dropin_coefficients)
 Set the coefficients using a move operation (only works with temp objects) More...
 

Protected Member Functions

virtual Real computeIntegral () final
 
virtual Point getCentroid () const =0
 Get the centroid of the evaluated unit. More...
 
virtual Real getVolume () const =0
 Get the volume of the evaluated unit. More...
 
virtual void coefficientsChanged ()
 Called when the coefficients have been changed. More...
 

Protected Attributes

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

Private Attributes

const ConsoleStream & _console
 MooseObject instance of this to provide access to _console More...
 

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 43 of file FXIntegralBaseUserObject.h.

Constructor & Destructor Documentation

◆ FXIntegralBaseUserObject()

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

Definition at line 114 of file FXIntegralBaseUserObject.h.

116  : IntegralBaseVariableUserObject(parameters),
117  MutableCoefficientsInterface(this, parameters),
119  getFunction("function"), UserObject::getParamTempl<std::string>("_moose_base"), name())),
120  _keep_history(UserObject::getParamTempl<bool>("keep_history")),
121  _print_state(UserObject::getParamTempl<bool>("print_state")),
123 {
124  // Size the coefficient arrays
128 
129  if (!_keep_history)
130  _coefficient_history.resize(0);
131 }

Member Function Documentation

◆ coefficientsChanged()

virtual void MutableCoefficientsInterface::coefficientsChanged ( )
inlineprotectedvirtualinherited

◆ computeIntegral()

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

Definition at line 135 of file FXIntegralBaseUserObject.h.

136 {
137  Real sum = 0.0;
138  const Point centroid = getCentroid();
139 
140  // Check to see if this element/side is within the valid boundaries
141  if (!_function_series.isInPhysicalBounds(centroid))
142  return 0.0;
143 
144  // Loop over the quadrature points
145  for (_qp = 0; _qp < _q_point.size(); ++_qp)
146  {
147  // Get the functional terms for a vectorized approach
148  _function_series.setLocation(_q_point[_qp]);
149  const std::vector<Real> & term_evaluations = _function_series.getGeneration();
150 
151  // Evaluate the functional expansion coefficients at each quadrature point
152  const Real local_contribution = computeQpIntegral();
153  const Real common_evaluation = local_contribution * _JxW[_qp] * _coord[_qp];
154  for (std::size_t c = 0; c < _coefficient_partials.size(); ++c)
155  _coefficient_partials[c] += term_evaluations[c] * common_evaluation;
156 
157  sum += local_contribution;
158  }
159 
160  _volume += getVolume();
161 
162  return sum;
163 }

◆ 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 }

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

◆ finalize()

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

Definition at line 167 of file FXIntegralBaseUserObject.h.

168 {
169  // Sum the coefficient arrays over all processes
170  _communicator.sum(_coefficient_partials);
171  _communicator.sum(_volume);
172 
173  // Normalize the volume of the functional expansion to the FX standard space
174  const Real volume_normalization = _standardized_function_volume / _volume;
175  for (auto & partial : _coefficient_partials)
176  partial *= volume_normalization;
177 
178  // We now have the completely evaluated coefficients
180 
181  // The average value is the same as the zeroth coefficient
182  _integral_value = _coefficient_partials[0];
183 
184  if (_keep_history)
186 
187  if (_print_state)
188  {
190  _console << COLOR_YELLOW << _function_series << COLOR_DEFAULT << std::endl;
191  }
192 }

◆ getCentroid()

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

Get the centroid of the evaluated unit.

Implemented in FXBoundaryBaseUserObject, and FXVolumeUserObject.

◆ 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 196 of file FXIntegralBaseUserObject.h.

197 {
198  return _function_series;
199 }

◆ 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(), and operator<<().

◆ getValue()

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

Definition at line 203 of file FXIntegralBaseUserObject.h.

204 {
205  return _integral_value;
206 }

◆ getVolume()

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

Get the volume of the evaluated unit.

Implemented in FXBoundaryBaseUserObject, and FXVolumeUserObject.

◆ 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 }

Referenced by MultiAppFXTransfer::execute().

◆ initialize()

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

Definition at line 210 of file FXIntegralBaseUserObject.h.

211 {
212  IntegralBaseVariableUserObject::initialize();
213 
214  // Clear the partial sums
215  for (auto & partial : _coefficient_partials)
216  partial = 0;
217 
218  _volume = 0;
219 }

◆ 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 }

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().

◆ 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 236 of file FXIntegralBaseUserObject.h.

237 {
238  _function_series.setLocation(location);
239 
241 }

◆ threadJoin()

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

Definition at line 223 of file FXIntegralBaseUserObject.h.

224 {
227 
228  for (std::size_t c = 0; c < _coefficient_partials.size(); ++c)
230 
231  _volume += sibling._volume;
232 }

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 92 of file FXIntegralBaseUserObject.h.

Referenced by FXIntegralBaseUserObject< ElementIntegralVariableUserObject >::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

MooseObject instance of this to provide access to _console

Definition at line 123 of file MutableCoefficientsInterface.h.

Referenced by MutableCoefficientsInterface::importCoefficients(), MutableCoefficientsInterface::resize(), and MutableCoefficientsInterface::setCoefficients().

◆ _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 98 of file FXIntegralBaseUserObject.h.

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

◆ _keep_history

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

Keep the expansion coefficients after each solve.

Definition at line 101 of file FXIntegralBaseUserObject.h.

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

◆ _print_coefficients

const bool MutableCoefficientsInterface::_print_coefficients
protectedinherited

Boolean to flag if the coefficients should be printed when set.

Definition at line 119 of file MutableCoefficientsInterface.h.

Referenced by MutableCoefficientsInterface::importCoefficients(), MutableCoefficientsInterface::resize(), and MutableCoefficientsInterface::setCoefficients().

◆ _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 104 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 107 of file FXIntegralBaseUserObject.h.

◆ _volume

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

Moose volume of evaluation.

Definition at line 110 of file FXIntegralBaseUserObject.h.

Referenced by FXIntegralBaseUserObject< ElementIntegralVariableUserObject >::threadJoin().


The documentation for this class was generated from the following file:
MutableCoefficientsInterface::_print_coefficients
const bool _print_coefficients
Boolean to flag if the coefficients should be printed when set.
Definition: MutableCoefficientsInterface.h:119
FXIntegralBaseUserObject
This class interacts with a MooseApp through functional expansions.
Definition: FXIntegralBaseUserObject.h:43
FXIntegralBaseUserObject::getCentroid
virtual Point getCentroid() const =0
Get the centroid of the evaluated unit.
FXIntegralBaseUserObject::_coefficient_history
std::vector< std::vector< Real > > _coefficient_history
History of the expansion coefficients for each solve.
Definition: FXIntegralBaseUserObject.h:92
FunctionSeries::expand
Real expand()
Expand the function series at the current location and with the current coefficients.
Definition: FunctionSeries.C:263
FunctionSeries::getNumberOfTerms
std::size_t getNumberOfTerms() const
Returns the number of terms (coefficients) in the underlying function series.
Definition: FunctionSeries.C:199
FXIntegralBaseUserObject::_coefficient_partials
std::vector< Real > _coefficient_partials
Current coefficient partial sums.
Definition: FXIntegralBaseUserObject.h:95
MutableCoefficientsInterface::_console
const ConsoleStream & _console
MooseObject instance of this to provide access to _console
Definition: MutableCoefficientsInterface.h:123
MutableCoefficientsInterface::_coefficients
std::vector< Real > & _coefficients
The coefficient array.
Definition: MutableCoefficientsInterface.h:113
FXIntegralBaseUserObject::_volume
Real _volume
Moose volume of evaluation.
Definition: FXIntegralBaseUserObject.h:110
FunctionSeries::isInPhysicalBounds
bool isInPhysicalBounds(const Point &point) const
Returns true if the provided point is within the set physical boundaries.
Definition: FunctionSeries.C:238
MutableCoefficientsInterface::_characteristics
std::vector< std::size_t > & _characteristics
An array of integer characteristics that can be used to check compatibility.
Definition: MutableCoefficientsInterface.h:107
MutableCoefficientsInterface::getSize
std::size_t getSize() const
Get the size, aka number of coefficients.
Definition: MutableCoefficientsInterface.C:80
FXIntegralBaseUserObject::getVolume
virtual Real getVolume() const =0
Get the volume of the evaluated unit.
FXIntegralBaseUserObject::_keep_history
const bool _keep_history
Keep the expansion coefficients after each solve.
Definition: FXIntegralBaseUserObject.h:101
FunctionSeries::getGeneration
const std::vector< Real > & getGeneration()
Returns a vector of the generation-evaluated functional series at the current location.
Definition: FunctionSeries.C:216
name
const std::string name
Definition: Setup.h:21
FunctionSeries::getOrders
const std::vector< std::size_t > & getOrders() const
Returns a vector of the functional orders in the underlying functional series.
Definition: FunctionSeries.C:205
FXIntegralBaseUserObject::_function_series
FunctionSeries & _function_series
Reference to the underlying function series.
Definition: FXIntegralBaseUserObject.h:98
MutableCoefficientsInterface::coefficientsChanged
virtual void coefficientsChanged()
Called when the coefficients have been changed.
Definition: MutableCoefficientsInterface.h:107
FXIntegralBaseUserObject::_print_state
const bool _print_state
Flag to prints the state of the zeroth instance in finalize()
Definition: FXIntegralBaseUserObject.h:104
MutableCoefficientsInterface::setCoefficients
void setCoefficients(const std::vector< Real > &new_coefficients)
Set the coefficients using a copy operation.
Definition: MutableCoefficientsInterface.C:156
FXIntegralBaseUserObject::_standardized_function_volume
const Real _standardized_function_volume
Volume of the standardized functional space of integration.
Definition: FXIntegralBaseUserObject.h:107
MutableCoefficientsInterface::MutableCoefficientsInterface
MutableCoefficientsInterface(const MooseObject *moose_object, const InputParameters &parameters)
Definition: MutableCoefficientsInterface.C:31
FunctionSeries::getStandardizedFunctionVolume
Real getStandardizedFunctionVolume() const
Returns the volume of evaluation in the functional series standardized space.
Definition: FunctionSeries.C:193
MutableCoefficientsInterface::isCompatibleWith
bool isCompatibleWith(const MutableCoefficientsInterface &other) const
Checks to see if another instance is compatible.
Definition: MutableCoefficientsInterface.C:86
FunctionSeries::checkAndConvertFunction
static FunctionSeries & checkAndConvertFunction(const Function &function, const std::string &typeName, const std::string &objectName)
Static function to cast a Function to SeriesFunction.
Definition: FunctionSeries.C:175
MutableCoefficientsInterface::_enforce_size
bool _enforce_size
Boolean that locks or allows resizing of the coefficient array.
Definition: MutableCoefficientsInterface.h:116
FunctionSeries::setLocation
void setLocation(const Point &point)
Set the current evaluation location.
Definition: FunctionSeries.C:244