https://mooseframework.inl.gov
Loading...
Searching...
No Matches
FunctionalBasisInterface.C
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
3//*
4//* All rights reserved, see COPYRIGHT for full restrictions
5//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6//*
7//* Licensed under LGPL 2.1, please see LICENSE for details
8//* https://www.gnu.org/licenses/lgpl-2.1.html
9
11
13
14/*
15 * The default constructor is used to initialize a series before knowing the number of terms in the
16 * series. This is called from the CSBI, and in the body of the CSBI constructor, setNumberOfTerms()
17 * is used to after-the-fact perform the same initializations that would be done with the
18 * non-default constructor.
19 */
21 : _is_cache_invalid(true), _is_generation(false)
22{
23}
24
25/*
26 * The non-default constructor should be used to initialize a series if the number of terms is
27 * known, such as with a single series.
28 */
29FunctionalBasisInterface::FunctionalBasisInterface(const unsigned int number_of_terms)
30 : _number_of_terms(number_of_terms),
31 _is_cache_invalid(true),
32 _basis_evaluation(_number_of_terms, 0.0),
33 _is_generation(false)
34{
35 _basis_evaluation.shrink_to_fit();
36}
37
38Real
40{
41 return (index > _basis_evaluation.size() ? 0.0 : _basis_evaluation[index]);
42}
43
44bool
49
50bool
55
56const std::vector<Real> &
71
72const std::vector<Real> &
87
88std::size_t
93
94Real
96{
97 // Use getAllGeneration() which will lazily evaluate the series as needed
98 return getAllGeneration().back();
99}
100
101Real
103{
104 Real sum = 0.0;
105
106 // Use getAllGeneration() which will lazily evaluate the series as needed
107 for (auto term : getAllGeneration())
108 sum += term;
109
110 return sum;
111}
112
113Real
115{
116 // Use getAllExpansion() which will lazily evaluate the series as needed
117 return getAllExpansion().back();
118}
119
120Real
122{
123 Real sum = 0.0;
124
125 // Use getAllExpansion() which will lazily evaluate the series as needed
126 for (auto term : getAllExpansion())
127 sum += term;
128
129 return sum;
130}
131
132Real
133FunctionalBasisInterface::load(std::size_t index) const
134{
135 return _basis_evaluation[index];
136}
137
138void
139FunctionalBasisInterface::save(std::size_t index, Real value)
140{
141 _basis_evaluation[index] = value;
142}
143
144void
145FunctionalBasisInterface::clearBasisEvaluation(const unsigned int & number_of_terms)
146{
147 _basis_evaluation.assign(number_of_terms, 0.0);
148 _basis_evaluation.shrink_to_fit();
149}
const std::vector< Real > & getAllGeneration()
Returns an array reference containing the value of each generation term.
Real getGeneration()
Gets the last term of the generation functional basis.
bool _is_cache_invalid
indicates if the evaluated values correspond to the current location
virtual void evaluateGeneration()=0
Evaluate the generation form of the functional basis.
Real getGenerationSeriesSum()
Gets the sum of all terms in the generation functional basis.
const std::vector< Real > & getAllExpansion()
Returns an array reference containing the value of each expansion term.
virtual void evaluateExpansion()=0
Evaluate the expansion form of the functional basis.
bool _is_generation
Indicates whether the current evaluation is expansion or generation.
unsigned int _number_of_terms
The number of terms in the series.
Real getExpansion()
Gets the #_order-th term of the expansion functional basis.
Real getExpansionSeriesSum()
Evaluates the sum of all terms in the expansion functional basis up to #_order.
static MooseEnum _domain_options
An enumeration of the domains available to each functional series.
bool isExpansion() const
Returns true if the current evaluation is expansion.
std::size_t getNumberOfTerms() const
Returns the number of terms in the series.
bool isGeneration() const
Returns true if the current evaluation is generation.
Real load(std::size_t index) const
Helper function to load a value from #_series.
virtual void clearBasisEvaluation(const unsigned int &number_of_terms)
Set all entries of the basis evaluation to zero.
virtual bool isCacheInvalid() const =0
Whether the cached values correspond to the current point.
std::vector< Real > _basis_evaluation
Stores the values of the basis evaluation.
Real operator[](std::size_t index) const
Returns the current evaluation at the given index.
void save(std::size_t index, Real value)
Helper function to store a value in #_series.