www.mooseframework.org
Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
Legendre Class Referencefinal

This class provides the algorithms and properties of the Legendre polynomial series. More...

#include <Legendre.h>

Inheritance diagram for Legendre:
[legend]

Public Member Functions

 Legendre ()
 
 Legendre (const std::vector< MooseEnum > &domain, const std::vector< std::size_t > &order, MooseEnum expansion_type, MooseEnum generation_type)
 
virtual Real getStandardizedFunctionVolume () const override
 Returns the volume within the standardized function local_limits. More...
 
virtual bool isInPhysicalBounds (const Point &point) const override
 Determines if the point provided is in within the physical bounds. More...
 
virtual std::size_t calculatedNumberOfTermsBasedOnOrder (const std::vector< std::size_t > &order) const override
 Returns the number of terms in the single series given a value for the order. More...
 
virtual const std::vector< Real > & getStandardizedFunctionLimits () const override
 Returns a vector of the lower and upper bounds of the standard functional space. More...
 
virtual bool isCacheInvalid () const final
 Whether the cached values correspond to the current point. More...
 
virtual void setLocation (const Point &point) final
 Set the location that will be used by the series to compute values. More...
 
virtual void setOrder (const std::vector< std::size_t > &orders) final
 Set the order of the series. More...
 
virtual void setPhysicalBounds (const std::vector< Real > &bounds) final
 Sets the bounds of the series. More...
 
std::size_t getOrder (std::size_t domain) const
 Returns the order of the particular domain index. More...
 
Real operator[] (std::size_t index) const
 Returns the current evaluation at the given index. More...
 
const std::vector< Real > & getAllGeneration ()
 Returns an array reference containing the value of each generation term. More...
 
const std::vector< Real > & getAllExpansion ()
 Returns an array reference containing the value of each expansion term. More...
 
std::size_t getNumberOfTerms () const
 Returns the number of terms in the series. More...
 
Real getGeneration ()
 Gets the last term of the generation functional basis. More...
 
Real getGenerationSeriesSum ()
 Gets the sum of all terms in the generation functional basis. More...
 
Real getExpansion ()
 Gets the #_order-th term of the expansion functional basis. More...
 
Real getExpansionSeriesSum ()
 Evaluates the sum of all terms in the expansion functional basis up to #_order. More...
 
bool isGeneration () const
 Returns true if the current evaluation is generation. More...
 
bool isExpansion () const
 Returns true if the current evaluation is expansion. More...
 

Public Attributes

const std::vector< MooseEnum > _domains
 An ordered list of the x, y, and/or z domains needed by the functional basis to convert a point to a standardized location. More...
 

Static Public Attributes

static MooseEnum _domain_options
 An enumeration of the domains available to each functional series. More...
 

Protected Member Functions

virtual void evaluateOrthonormal ()
 Evaluates the orthonormal form of the basis functions. More...
 
virtual void evaluateStandard ()
 Evaluates the standard form of the basis functions. More...
 
virtual void evaluateSqrtMu ()
 Evaluates the 1/sqrt(mu) normalized form of the basis functions. More...
 
virtual void checkPhysicalBounds (const std::vector< Real > &bounds) const override
 Checks the physical bounds according to the actual implementation. More...
 
virtual std::vector< Real > getStandardizedLocation (const std::vector< Real > &location) const override
 Standardize the location according to the requirements of the underlying basis, which may actually convert the Cartesian coordinates into a more suitable system. More...
 
virtual void evaluateGeneration () override
 Evaluate the generation form of the functional basis. More...
 
virtual void evaluateExpansion () override
 Evaluate the expansion form of the functional basis. More...
 
std::vector< Real > extractLocationFromPoint (const Point &point) const
 Convert a spatial point to a location that the series will use to determine the value at which to evaluate the series. More...
 
virtual void clearBasisEvaluation (const unsigned int &number_of_terms)
 Set all entries of the basis evaluation to zero. More...
 
Real load (std::size_t index) const
 Helper function to load a value from #_series. More...
 
void save (std::size_t index, Real value)
 Helper function to store a value in #_series. More...
 

Protected Attributes

std::vector< std::size_t > _orders
 The order of the series. More...
 
std::vector< Real > _physical_bounds
 The physical bounds of the series. More...
 
std::vector< Real > _standardized_location
 The standardized location of evaluation. More...
 
std::function< void()> _evaluateExpansionWrapper
 The expansion evaluation wrapper. More...
 
std::function< void()> _evaluateGenerationWrapper
 The generation evaluation wrapper. More...
 
unsigned int _number_of_terms
 The number of terms in the series. More...
 

Detailed Description

This class provides the algorithms and properties of the Legendre polynomial series.

Definition at line 18 of file Legendre.h.

Constructor & Destructor Documentation

◆ Legendre() [1/2]

Legendre::Legendre ( )

Definition at line 19 of file Legendre.C.

◆ Legendre() [2/2]

Legendre::Legendre ( const std::vector< MooseEnum > &  domain,
const std::vector< std::size_t > &  order,
MooseEnum  expansion_type,
MooseEnum  generation_type 
)

Definition at line 21 of file Legendre.C.

26 {
27  if (expansion_type == "orthonormal")
28  _evaluateExpansionWrapper = [this]() { this->evaluateOrthonormal(); };
29  else if (expansion_type == "sqrt_mu")
30  _evaluateExpansionWrapper = [this]() { this->evaluateSqrtMu(); };
31  else if (expansion_type == "standard")
32  _evaluateExpansionWrapper = [this]() { this->evaluateStandard(); };
33  else
34  mooseError("The specified type of normalization for expansion does not exist");
35 
36  if (generation_type == "orthonormal")
37  _evaluateGenerationWrapper = [this]() { this->evaluateOrthonormal(); };
38  else if (generation_type == "sqrt_mu")
39  _evaluateGenerationWrapper = [this]() { this->evaluateSqrtMu(); };
40  else if (generation_type == "standard")
41  _evaluateGenerationWrapper = [this]() { this->evaluateStandard(); };
42  else
43  mooseError("The specified type of normalization for generation does not exist");
44 }
virtual void evaluateSqrtMu()
Evaluates the 1/sqrt(mu) normalized form of the basis functions.
Definition: Legendre.C:259
std::function< void()> _evaluateExpansionWrapper
The expansion evaluation wrapper.
std::function< void()> _evaluateGenerationWrapper
The generation evaluation wrapper.
MooseEnum expansion_type
virtual std::size_t calculatedNumberOfTermsBasedOnOrder(const std::vector< std::size_t > &order) const override
Returns the number of terms in the single series given a value for the order.
Definition: Legendre.C:47
virtual void evaluateOrthonormal()
Evaluates the orthonormal form of the basis functions.
Definition: Legendre.C:61
virtual void evaluateStandard()
Evaluates the standard form of the basis functions.
Definition: Legendre.C:174
MooseEnum generation_type

Member Function Documentation

◆ calculatedNumberOfTermsBasedOnOrder()

std::size_t Legendre::calculatedNumberOfTermsBasedOnOrder ( const std::vector< std::size_t > &  order) const
overridevirtual

Returns the number of terms in the single series given a value for the order.

Implements SingleSeriesBasisInterface.

Definition at line 47 of file Legendre.C.

48 {
49  return order[0] + 1;
50 }

◆ checkPhysicalBounds()

void Legendre::checkPhysicalBounds ( const std::vector< Real > &  bounds) const
overrideprotectedvirtual

Checks the physical bounds according to the actual implementation.

Implements SingleSeriesBasisInterface.

Definition at line 53 of file Legendre.C.

54 {
55  // Each Legendre series should have a min and max bound
56  if (bounds.size() != 2)
57  mooseError("Legend: Invalid number of bounds specified for single series!");
58 }

◆ clearBasisEvaluation()

void FunctionalBasisInterface::clearBasisEvaluation ( const unsigned int &  number_of_terms)
protectedvirtualinherited

Set all entries of the basis evaluation to zero.

Definition at line 144 of file FunctionalBasisInterface.C.

Referenced by FunctionalBasisInterface::getAllExpansion(), FunctionalBasisInterface::getAllGeneration(), CompositeSeriesBasisInterface::setNumberOfTerms(), and SingleSeriesBasisInterface::setOrder().

145 {
146  _basis_evaluation.assign(number_of_terms, 0.0);
147  _basis_evaluation.shrink_to_fit();
148 }
std::vector< Real > _basis_evaluation
Stores the values of the basis evaluation.

◆ evaluateExpansion()

void SingleSeriesBasisInterface::evaluateExpansion ( )
overrideprotectedvirtualinherited

Evaluate the expansion form of the functional basis.

Implements FunctionalBasisInterface.

Definition at line 55 of file SingleSeriesBasisInterface.C.

56 {
58 }
std::function< void()> _evaluateExpansionWrapper
The expansion evaluation wrapper.

◆ evaluateGeneration()

void SingleSeriesBasisInterface::evaluateGeneration ( )
overrideprotectedvirtualinherited

Evaluate the generation form of the functional basis.

Implements FunctionalBasisInterface.

Definition at line 49 of file SingleSeriesBasisInterface.C.

50 {
52 }
std::function< void()> _evaluateGenerationWrapper
The generation evaluation wrapper.

◆ evaluateOrthonormal()

void Legendre::evaluateOrthonormal ( )
protectedvirtual

Evaluates the orthonormal form of the basis functions.

Definition at line 61 of file Legendre.C.

Referenced by Legendre().

62 {
63  std::size_t k;
64  const Real & x = _standardized_location[0];
65  const Real x2 = x * x;
66 
67  /*
68  * Use direct formula to efficiently evaluate the polynomials for n <= 12
69  *
70  * The performance benefit diminishes for higher n. It is expected that the cost of the direct
71  * calculation nears that of the recurrence relation in the neighborhood of n == 15, although this
72  * theory is untested due to only implementing the direct calculations up to n == 12.
73  *
74  * If you want to calculate the higher-order Legendre Coefficients and code them in then be my
75  * guest.
76  */
77  // clang-format off
78  switch (_orders[0])
79  {
80  default:
81  case MAX_DIRECT_CALCULATION_LEGENDRE: /* 12 */
82  save(12, ((((((676039 * x2 - 1939938) * x2 + 2078505) * x2 - 1021020) * x2 + 225225) * x2 - 18018) * x2 + 231) / 1024
83  * 12.5);
84  libmesh_fallthrough();
85 
86  case 11:
87  save(11, (((((88179 * x2 - 230945) * x2 + 218790) * x2 - 90090) * x2 + 15015) * x2 - 693) * x / 256
88  * 11.5);
89  libmesh_fallthrough();
90 
91  case 10:
92  save(10, (((((46189 * x2 - 109395) * x2 + 90090) * x2 - 30030) * x2 + 3465) * x2 - 63) / 256
93  * 10.5);
94  libmesh_fallthrough();
95 
96  case 9:
97  save(9, ((((12155 * x2 - 25740) * x2 + 18018) * x2 - 4620) * x2 + 315) * x / 128
98  * 9.5);
99  libmesh_fallthrough();
100 
101  case 8:
102  save(8, ((((6435 * x2 - 12012) * x2 + 6930) * x2 - 1260) * x2 + 35) / 128
103  * 8.5);
104  libmesh_fallthrough();
105 
106  case 7:
107  save(7, (((429 * x2 - 693) * x2 + 315) * x2 - 35) * x / 16
108  * 7.5);
109  libmesh_fallthrough();
110 
111  case 6:
112  save(6, (((231 * x2 - 315) * x2 + 105) * x2 - 5) / 16
113  * 6.5);
114  libmesh_fallthrough();
115 
116  case 5:
117  save(5, ((63 * x2 - 70) * x2 + 15) * x / 8
118  * 5.5);
119  libmesh_fallthrough();
120 
121  case 4:
122  save(4, ((35 * x2 - 30) * x2 + 3) / 8
123  * 4.5);
124  libmesh_fallthrough();
125 
126  case 3:
127  save(3, (5 * x2 - 3) * x / 2
128  * 3.5);
129  libmesh_fallthrough();
130 
131  case 2:
132  save(2, (3 * x2 - 1) / 2
133  * 2.5);
134  libmesh_fallthrough();
135 
136  case 1:
137  save(1, x
138  * 1.5);
139  libmesh_fallthrough();
140 
141  case 0:
142  save(0, 1
143  * 0.5);
144  }
145  // clang-format on
146 
147  /*
148  * Evaluate any remaining polynomials.
149  *
150  * The original recurrence relation is:
151  * (2 * k - 1) * x * L_(k-1) - (k - 1) * L_(k-2)
152  * L_k = ---------------------------------------------
153  * k
154  *
155  * However, for FXs we are using a the orthonormalized version of the polynomials, so each
156  * polynomial L_k is multiplied by:
157  * (2 * k + 1)
158  * ----------- essentially: k + 0.5
159  * 2
160  * Reversing this in the previous polynomials and implementing for the current polynomial results
161  * in the orthonormalized recurrence:
162  * (2 * k + 1) / (k - 1) \
163  * L_k = ----------- * | x * L_(k-1) - ----------- * L_(k-2) |
164  * k \ (2 * k - 3) /
165  *
166  * The options are 1) to use this form, or 2) to not apply the orthonormalization at first, and
167  * then loop through all the values in a second loop and then apply the orthonormalization.
168  */
169  for (k = MAX_DIRECT_CALCULATION_LEGENDRE + 1; k <= _orders[0]; ++k)
170  save(k, ((k + k + 1) / Real(k)) * (x * load(k - 1) - ((k - 1) / (k + k - 3.0)) * load(k - 2)));
171 }
std::vector< Real > _standardized_location
The standardized location of evaluation.
void save(std::size_t index, Real value)
Helper function to store a value in #_series.
Real load(std::size_t index) const
Helper function to load a value from #_series.
std::vector< std::size_t > _orders
The order of the series.

◆ evaluateSqrtMu()

void Legendre::evaluateSqrtMu ( )
protectedvirtual

Evaluates the 1/sqrt(mu) normalized form of the basis functions.

Definition at line 259 of file Legendre.C.

Referenced by Legendre().

260 {
262  for (size_t i = 0; i < getNumberOfTerms(); ++i)
263  save(i, load(i) * std::sqrt(i + 0.5));
264 }
void save(std::size_t index, Real value)
Helper function to store a value in #_series.
Real load(std::size_t index) const
Helper function to load a value from #_series.
virtual void evaluateStandard()
Evaluates the standard form of the basis functions.
Definition: Legendre.C:174
std::size_t getNumberOfTerms() const
Returns the number of terms in the series.

◆ evaluateStandard()

void Legendre::evaluateStandard ( )
protectedvirtual

Evaluates the standard form of the basis functions.

Definition at line 174 of file Legendre.C.

Referenced by evaluateSqrtMu(), and Legendre().

175 {
176  std::size_t k;
177  const Real x = _standardized_location[0];
178  const Real x2 = x * x;
179 
180  /*
181  * Use direct formula to efficiently evaluate the polynomials for n <= 12
182  *
183  * The performance benefit diminishes for higher n. It is expected that the cost of the direct
184  * calculation nears that of the recurrence relation in the neighborhood of n == 15, although this
185  * theory is untested due to only implementing the direct calculations up to n == 12.
186  *
187  * If you want to calculate the higher-order Legendre Coefficients and
188  * code them in then be my guest.
189  */
190  // clang-format off
191  switch (_orders[0])
192  {
193  default:
194  case MAX_DIRECT_CALCULATION_LEGENDRE: /* 12 */
195  save(12, ((((((676039 * x2 - 1939938) * x2 + 2078505) * x2 - 1021020) * x2 + 225225) * x2 - 18018) * x2 + 231) / 1024);
196  libmesh_fallthrough();
197 
198  case 11:
199  save(11, (((((88179 * x2 - 230945) * x2 + 218790) * x2 - 90090) * x2 + 15015) * x2 - 693) * x / 256);
200  libmesh_fallthrough();
201 
202  case 10:
203  save(10, (((((46189 * x2 - 109395) * x2 + 90090) * x2 - 30030) * x2 + 3465) * x2 - 63) / 256);
204  libmesh_fallthrough();
205 
206  case 9:
207  save(9, ((((12155 * x2 - 25740) * x2 + 18018) * x2 - 4620) * x2 + 315) * x / 128);
208  libmesh_fallthrough();
209 
210  case 8:
211  save(8, ((((6435 * x2 - 12012) * x2 + 6930) * x2 - 1260) * x2 + 35) / 128);
212  libmesh_fallthrough();
213 
214  case 7:
215  save(7, (((429 * x2 - 693) * x2 + 315) * x2 - 35) * x / 16);
216  libmesh_fallthrough();
217 
218  case 6:
219  save(6, (((231 * x2 - 315) * x2 + 105) * x2 - 5) / 16);
220  libmesh_fallthrough();
221 
222  case 5:
223  save(5, ((63 * x2 - 70) * x2 + 15) * x / 8);
224  libmesh_fallthrough();
225 
226  case 4:
227  save(4, ((35 * x2 - 30) * x2 + 3) / 8);
228  libmesh_fallthrough();
229 
230  case 3:
231  save(3, (5 * x2 - 3) * x / 2);
232  libmesh_fallthrough();
233 
234  case 2:
235  save(2, (3 * x2 - 1) / 2);
236  libmesh_fallthrough();
237 
238  case 1:
239  save(1, x);
240  libmesh_fallthrough();
241 
242  case 0:
243  save(0, 1);
244  }
245  // clang-format on
246 
247  /*
248  * Evaluate any remaining polynomials.
249  * The recurrence relation is:
250  * (2 * k - 1) * x * L_(k-1) - (k - 1) * L_(k-2)
251  * L_k = ---------------------------------------------
252  * k
253  */
254  for (k = MAX_DIRECT_CALCULATION_LEGENDRE + 1; k <= _orders[0]; ++k)
255  save(k, (((2 * k - 1) * x * load(k - 1)) - ((k - 1) * load(k - 2))) / Real(k));
256 }
std::vector< Real > _standardized_location
The standardized location of evaluation.
void save(std::size_t index, Real value)
Helper function to store a value in #_series.
Real load(std::size_t index) const
Helper function to load a value from #_series.
std::vector< std::size_t > _orders
The order of the series.

◆ extractLocationFromPoint()

std::vector< Real > SingleSeriesBasisInterface::extractLocationFromPoint ( const Point &  point) const
protectedinherited

Convert a spatial point to a location that the series will use to determine the value at which to evaluate the series.

Definition at line 120 of file SingleSeriesBasisInterface.C.

Referenced by isInPhysicalBounds(), Zernike::isInPhysicalBounds(), and SingleSeriesBasisInterface::setLocation().

121 {
122  std::vector<Real> location(_domains.size());
123 
124  // Update the locations as specified by _domain
125  for (std::size_t index = 0; index < _domains.size(); ++index)
126  location[index] = point(_domains[index]);
127  return location;
128 }
const std::vector< MooseEnum > _domains
An ordered list of the x, y, and/or z domains needed by the functional basis to convert a point to a ...

◆ getAllExpansion()

const std::vector< Real > & FunctionalBasisInterface::getAllExpansion ( )
inherited

Returns an array reference containing the value of each expansion term.

Definition at line 72 of file FunctionalBasisInterface.C.

Referenced by FunctionalBasisInterface::getExpansion(), and FunctionalBasisInterface::getExpansionSeriesSum().

73 {
74  if (isGeneration() || isCacheInvalid())
75  {
77 
79 
80  _is_generation = false;
81  _is_cache_invalid = false;
82  }
83 
84  return _basis_evaluation;
85 }
std::vector< Real > _basis_evaluation
Stores the values of the basis evaluation.
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.
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.
bool isGeneration() const
Returns true if the current evaluation is generation.
bool _is_cache_invalid
indicates if the evaluated values correspond to the current location

◆ getAllGeneration()

const std::vector< Real > & FunctionalBasisInterface::getAllGeneration ( )
inherited

Returns an array reference containing the value of each generation term.

Definition at line 56 of file FunctionalBasisInterface.C.

Referenced by FunctionalBasisInterface::getGeneration(), and FunctionalBasisInterface::getGenerationSeriesSum().

57 {
58  if (isExpansion() || isCacheInvalid())
59  {
61 
63 
64  _is_generation = true;
65  _is_cache_invalid = false;
66  }
67 
68  return _basis_evaluation;
69 }
std::vector< Real > _basis_evaluation
Stores the values of the basis evaluation.
bool _is_generation
Indicates whether the current evaluation is expansion or generation.
unsigned int _number_of_terms
The number of terms in the 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.
bool isExpansion() const
Returns true if the current evaluation is expansion.
virtual void evaluateGeneration()=0
Evaluate the generation form of the functional basis.
bool _is_cache_invalid
indicates if the evaluated values correspond to the current location

◆ getExpansion()

Real FunctionalBasisInterface::getExpansion ( )
inherited

Gets the #_order-th term of the expansion functional basis.

Definition at line 113 of file FunctionalBasisInterface.C.

114 {
115  // Use getAllExpansion() which will lazily evaluate the series as needed
116  return getAllExpansion().back();
117 }
const std::vector< Real > & getAllExpansion()
Returns an array reference containing the value of each expansion term.

◆ getExpansionSeriesSum()

Real FunctionalBasisInterface::getExpansionSeriesSum ( )
inherited

Evaluates the sum of all terms in the expansion functional basis up to #_order.

Definition at line 120 of file FunctionalBasisInterface.C.

Referenced by TEST().

121 {
122  Real sum = 0.0;
123 
124  // Use getAllExpansion() which will lazily evaluate the series as needed
125  for (auto term : getAllExpansion())
126  sum += term;
127 
128  return sum;
129 }
const std::vector< Real > & getAllExpansion()
Returns an array reference containing the value of each expansion term.

◆ getGeneration()

Real FunctionalBasisInterface::getGeneration ( )
inherited

Gets the last term of the generation functional basis.

Definition at line 94 of file FunctionalBasisInterface.C.

95 {
96  // Use getAllGeneration() which will lazily evaluate the series as needed
97  return getAllGeneration().back();
98 }
const std::vector< Real > & getAllGeneration()
Returns an array reference containing the value of each generation term.

◆ getGenerationSeriesSum()

Real FunctionalBasisInterface::getGenerationSeriesSum ( )
inherited

Gets the sum of all terms in the generation functional basis.

Definition at line 101 of file FunctionalBasisInterface.C.

Referenced by TEST().

102 {
103  Real sum = 0.0;
104 
105  // Use getAllGeneration() which will lazily evaluate the series as needed
106  for (auto term : getAllGeneration())
107  sum += term;
108 
109  return sum;
110 }
const std::vector< Real > & getAllGeneration()
Returns an array reference containing the value of each generation term.

◆ getNumberOfTerms()

std::size_t FunctionalBasisInterface::getNumberOfTerms ( ) const
inherited

Returns the number of terms in the series.

Definition at line 88 of file FunctionalBasisInterface.C.

Referenced by evaluateSqrtMu(), and TEST().

89 {
90  return _number_of_terms;
91 }
unsigned int _number_of_terms
The number of terms in the series.

◆ getOrder()

std::size_t SingleSeriesBasisInterface::getOrder ( std::size_t  domain) const
inherited

Returns the order of the particular domain index.

Definition at line 131 of file SingleSeriesBasisInterface.C.

132 {
133  return domain < _orders.size() ? _orders[domain] : -1;
134 }
std::vector< std::size_t > _orders
The order of the series.

◆ getStandardizedFunctionLimits()

const std::vector< Real > & Legendre::getStandardizedFunctionLimits ( ) const
overridevirtual

Returns a vector of the lower and upper bounds of the standard functional space.

Implements FunctionalBasisInterface.

Definition at line 267 of file Legendre.C.

268 {
269  // Lazily instantiate the function limits array
270  static const std::vector<Real> standardizedFunctionLimits = {-1, 1};
271 
272  return standardizedFunctionLimits;
273 }

◆ getStandardizedFunctionVolume()

Real Legendre::getStandardizedFunctionVolume ( ) const
overridevirtual

Returns the volume within the standardized function local_limits.

Implements FunctionalBasisInterface.

Definition at line 276 of file Legendre.C.

277 {
278  return 2.0; // Span of [-1, 1]
279 }

◆ getStandardizedLocation()

std::vector< Real > Legendre::getStandardizedLocation ( const std::vector< Real > &  location) const
overrideprotectedvirtual

Standardize the location according to the requirements of the underlying basis, which may actually convert the Cartesian coordinates into a more suitable system.

The second version exists simply to return the value.

Implements SingleSeriesBasisInterface.

Definition at line 282 of file Legendre.C.

283 {
284  const Real difference = location[0] - _physical_bounds[0];
285  const Real span = _physical_bounds[1] - _physical_bounds[0];
286 
287  // Convert to [0, 1] (assuming that location[0] is within _physical_bounds)
288  const Real ratio = difference / span;
289 
290  // Legendre space is [-1, 1]
291  return {ratio * 2 - 1};
292 }
std::vector< Real > _physical_bounds
The physical bounds of the series.

◆ isCacheInvalid()

bool SingleSeriesBasisInterface::isCacheInvalid ( ) const
finalvirtualinherited

Whether the cached values correspond to the current point.

Implements FunctionalBasisInterface.

Definition at line 43 of file SingleSeriesBasisInterface.C.

44 {
45  return _is_cache_invalid;
46 }
bool _is_cache_invalid
indicates if the evaluated values correspond to the current location

◆ isExpansion()

bool FunctionalBasisInterface::isExpansion ( ) const
inherited

Returns true if the current evaluation is expansion.

Definition at line 50 of file FunctionalBasisInterface.C.

Referenced by FunctionalBasisInterface::getAllGeneration().

51 {
52  return !_is_generation;
53 }
bool _is_generation
Indicates whether the current evaluation is expansion or generation.

◆ isGeneration()

bool FunctionalBasisInterface::isGeneration ( ) const
inherited

Returns true if the current evaluation is generation.

Definition at line 44 of file FunctionalBasisInterface.C.

Referenced by FunctionalBasisInterface::getAllExpansion().

45 {
46  return _is_generation;
47 }
bool _is_generation
Indicates whether the current evaluation is expansion or generation.

◆ isInPhysicalBounds()

bool Legendre::isInPhysicalBounds ( const Point &  point) const
overridevirtual

Determines if the point provided is in within the physical bounds.

Implements FunctionalBasisInterface.

Definition at line 295 of file Legendre.C.

296 {
297  std::vector<Real> location = extractLocationFromPoint(point);
298 
299  if (location[0] < _physical_bounds[0] || _physical_bounds[1] < location[0])
300  return false;
301  else
302  return true;
303 }
std::vector< Real > _physical_bounds
The physical bounds of the series.
std::vector< Real > extractLocationFromPoint(const Point &point) const
Convert a spatial point to a location that the series will use to determine the value at which to eva...

◆ load()

Real FunctionalBasisInterface::load ( std::size_t  index) const
protectedinherited

Helper function to load a value from #_series.

Definition at line 132 of file FunctionalBasisInterface.C.

Referenced by evaluateOrthonormal(), Zernike::evaluateOrthonormal(), evaluateSqrtMu(), Zernike::evaluateSqrtMu(), evaluateStandard(), Zernike::evaluateStandard(), and Zernike::fillOutNegativeRankAndApplyAzimuthalComponent().

133 {
134  return _basis_evaluation[index];
135 }
std::vector< Real > _basis_evaluation
Stores the values of the basis evaluation.

◆ operator[]()

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

Returns the current evaluation at the given index.

Definition at line 38 of file FunctionalBasisInterface.C.

39 {
40  return (index > _basis_evaluation.size() ? 0.0 : _basis_evaluation[index]);
41 }
std::vector< Real > _basis_evaluation
Stores the values of the basis evaluation.

◆ save()

void FunctionalBasisInterface::save ( std::size_t  index,
Real  value 
)
protectedinherited

Helper function to store a value in #_series.

Definition at line 138 of file FunctionalBasisInterface.C.

Referenced by evaluateOrthonormal(), Zernike::evaluateOrthonormal(), CompositeSeriesBasisInterface::evaluateSeries(), evaluateSqrtMu(), Zernike::evaluateSqrtMu(), evaluateStandard(), Zernike::evaluateStandard(), and Zernike::fillOutNegativeRankAndApplyAzimuthalComponent().

139 {
140  _basis_evaluation[index] = value;
141 }
std::vector< Real > _basis_evaluation
Stores the values of the basis evaluation.

◆ setLocation()

void SingleSeriesBasisInterface::setLocation ( const Point &  point)
finalvirtualinherited

Set the location that will be used by the series to compute values.

Implements FunctionalBasisInterface.

Definition at line 100 of file SingleSeriesBasisInterface.C.

Referenced by TEST().

101 {
102  std::vector<Real> oldLocation(_location);
103 
104  // Update the physical-space location
106 
107  // Standardize the location if standardized bounds exist
110  else
112 
113  // Once the location is changed, the cached values correspond to an old location
114  for (std::size_t i = 0; !_is_cache_invalid && (i < _location.size()); ++i)
115  if (oldLocation[i] != _location[i])
116  _is_cache_invalid = true;
117 }
bool _are_physical_bounds_specified
Flag for if the physical bounds are specified for this series.
std::vector< Real > _standardized_location
The standardized location of evaluation.
std::vector< Real > _location
The domain locations of the current evaluation.
std::vector< Real > extractLocationFromPoint(const Point &point) const
Convert a spatial point to a location that the series will use to determine the value at which to eva...
virtual std::vector< Real > getStandardizedLocation(const std::vector< Real > &location) const =0
Standardize the location according to the requirements of the underlying basis, which may actually co...
bool _is_cache_invalid
indicates if the evaluated values correspond to the current location

◆ setOrder()

void SingleSeriesBasisInterface::setOrder ( const std::vector< std::size_t > &  orders)
finalvirtualinherited

Set the order of the series.

Implements FunctionalBasisInterface.

Definition at line 61 of file SingleSeriesBasisInterface.C.

62 {
63  if (orders.size() != _orders.size())
64  mooseError("SSBI: Invalid 'orders' use in setOrder()!");
65 
66  /*
67  * Do nothing if the order isn't changed. Note that this only compares the first value - it is
68  * assumed that a single series only needs to be described using a single order.
69  */
70  if (orders[0] == _orders[0])
71  return;
72 
73  _orders = orders;
74 
75  // Set the new number of terms in the single series
77 
78  // Zero the basis evaluation
80  _is_cache_invalid = true;
81 }
unsigned int _number_of_terms
The number of terms in the series.
virtual void clearBasisEvaluation(const unsigned int &number_of_terms)
Set all entries of the basis evaluation to zero.
std::vector< std::size_t > _orders
The order of the series.
virtual std::size_t calculatedNumberOfTermsBasedOnOrder(const std::vector< std::size_t > &order) const =0
Returns the number of terms in the single series given a value for the order.
bool _is_cache_invalid
indicates if the evaluated values correspond to the current location

◆ setPhysicalBounds()

void SingleSeriesBasisInterface::setPhysicalBounds ( const std::vector< Real > &  bounds)
finalvirtualinherited

Sets the bounds of the series.

Implements FunctionalBasisInterface.

Definition at line 84 of file SingleSeriesBasisInterface.C.

85 {
86  // Use the concrete implementation to check the validity of the bounds
87  checkPhysicalBounds(bounds);
88 
89  _physical_bounds = bounds;
91 
92  /*
93  * Once the physical bounds have been changed, the normalization of a point will change, so the
94  * cached values will also be incorrect
95  */
96  _is_cache_invalid = true;
97 }
bool _are_physical_bounds_specified
Flag for if the physical bounds are specified for this series.
virtual void checkPhysicalBounds(const std::vector< Real > &bounds) const =0
Checks the physical bounds according to the actual implementation.
std::vector< Real > _physical_bounds
The physical bounds of the series.
bool _is_cache_invalid
indicates if the evaluated values correspond to the current location

Member Data Documentation

◆ _domain_options

MooseEnum FunctionalBasisInterface::_domain_options
staticinherited

An enumeration of the domains available to each functional series.

Definition at line 116 of file FunctionalBasisInterface.h.

Referenced by FunctionSeries::FunctionSeries(), SingleSeriesBasisInterface::SingleSeriesBasisInterface(), and TEST().

◆ _domains

const std::vector<MooseEnum> SingleSeriesBasisInterface::_domains
inherited

An ordered list of the x, y, and/or z domains needed by the functional basis to convert a point to a standardized location.

Definition at line 61 of file SingleSeriesBasisInterface.h.

Referenced by SingleSeriesBasisInterface::extractLocationFromPoint().

◆ _evaluateExpansionWrapper

std::function<void()> SingleSeriesBasisInterface::_evaluateExpansionWrapper
protectedinherited

The expansion evaluation wrapper.

Definition at line 89 of file SingleSeriesBasisInterface.h.

Referenced by SingleSeriesBasisInterface::evaluateExpansion(), Legendre(), and Zernike::Zernike().

◆ _evaluateGenerationWrapper

std::function<void()> SingleSeriesBasisInterface::_evaluateGenerationWrapper
protectedinherited

The generation evaluation wrapper.

Definition at line 92 of file SingleSeriesBasisInterface.h.

Referenced by SingleSeriesBasisInterface::evaluateGeneration(), Legendre(), and Zernike::Zernike().

◆ _number_of_terms

unsigned int FunctionalBasisInterface::_number_of_terms
protectedinherited

◆ _orders

std::vector<std::size_t> SingleSeriesBasisInterface::_orders
protectedinherited

◆ _physical_bounds

std::vector<Real> SingleSeriesBasisInterface::_physical_bounds
protectedinherited

◆ _standardized_location

std::vector<Real> SingleSeriesBasisInterface::_standardized_location
protectedinherited

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