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

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

#include <Zernike.h>

Inheritance diagram for Zernike:
[legend]

Public Member Functions

 Zernike ()
 
 Zernike (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...
 
void fillOutNegativeRankAndApplyAzimuthalComponent ()
 Helper function used by evaluateGeneration() and evaluateExpansion(). More...
 
std::size_t simpleDoubleToSingle (std::size_t n, long m) const
 Maps the double order/rank idices to a single linear index. 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< Real > _negative_azimuthal_components
 Stores the recurrence evaluations for the negative rank azimuthal terms. More...
 
std::vector< Real > _positive_azimuthal_components
 Stores the recurrence evaluations for the positive rank azimuthal terms. More...
 
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 Zernike polynomial series.

Definition at line 18 of file Zernike.h.

Constructor & Destructor Documentation

◆ Zernike() [1/2]

Zernike::Zernike ( )

Definition at line 20 of file Zernike.C.

◆ Zernike() [2/2]

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

Definition at line 22 of file Zernike.C.

27 {
28  if (expansion_type == "orthonormal")
29  _evaluateExpansionWrapper = [this]() { this->evaluateOrthonormal(); };
30  else if (expansion_type == "sqrt_mu")
31  _evaluateExpansionWrapper = [this]() { this->evaluateSqrtMu(); };
32  else if (expansion_type == "standard")
33  _evaluateExpansionWrapper = [this]() { this->evaluateStandard(); };
34  else
35  mooseError("The specified type of normalization for expansion does not exist");
36 
37  if (generation_type == "orthonormal")
38  _evaluateGenerationWrapper = [this]() { this->evaluateOrthonormal(); };
39  else if (generation_type == "sqrt_mu")
40  _evaluateGenerationWrapper = [this]() { this->evaluateSqrtMu(); };
41  else if (generation_type == "standard")
42  _evaluateGenerationWrapper = [this]() { this->evaluateStandard(); };
43  else
44  mooseError("The specified type of normalization for generation does not exist");
45 }
virtual void evaluateSqrtMu()
Evaluates the 1/sqrt(mu) normalized form of the basis functions.
Definition: Zernike.C:226
std::function< void()> _evaluateExpansionWrapper
The expansion evaluation wrapper.
std::function< void()> _evaluateGenerationWrapper
The generation evaluation wrapper.
virtual void evaluateOrthonormal()
Evaluates the orthonormal form of the basis functions.
Definition: Zernike.C:66
virtual void evaluateStandard()
Evaluates the standard form of the basis functions.
Definition: Zernike.C:245
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: Zernike.C:48
MooseEnum generation_type

Member Function Documentation

◆ calculatedNumberOfTermsBasedOnOrder()

std::size_t Zernike::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 48 of file Zernike.C.

49 {
50  return ((order[0] + 1) * (order[0] + 2)) / 2;
51 }

◆ checkPhysicalBounds()

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

Checks the physical bounds according to the actual implementation.

Implements SingleSeriesBasisInterface.

Definition at line 54 of file Zernike.C.

55 {
56  /*
57  * Each single series is assumed to be a function of a single coordinate, which should only have
58  * two bounds.
59  */
60  if (bounds.size() != 3)
61  mooseError("Zernike: Invalid number of bounds specified for single series!");
62 }

◆ 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 Zernike::evaluateOrthonormal ( )
protectedvirtual

Evaluates the orthonormal form of the basis functions.

Definition at line 66 of file Zernike.C.

Referenced by Zernike().

67 {
68  std::size_t n;
69  long j, q;
70  Real H1, H2, H3;
71  const Real & rho = _standardized_location[0];
72  const Real rho2 = rho * rho;
73  const Real rho4 = rho2 * rho2;
74 
75  if (MooseUtils::absoluteFuzzyEqual(rho, 0.0))
76  {
77  for (n = 0; n <= _orders[0]; n += 2)
78  {
79  j = simpleDoubleToSingle(n, 0);
80 
81  if ((n / 2) % 2 != 0)
82  save(j, -1 * (n + 1) / M_PI);
83  else
84  save(j, 1 * (n + 1) / M_PI);
85  }
86 
87  return;
88  }
89 
90  switch (_orders[0])
91  {
92  default:
93  case MAX_DIRECT_CALCULATION_ZERNIKE: /* 10 */
94  save(65, rho4 * rho4 * rho2
95  * 22 / M_PI);
96  save(64, (10 * rho2 - 9) * rho4 * rho4
97  * 22 / M_PI);
98  save(63, ((45 * rho2 - 72) * rho2 + 28) * rho4 * rho2
99  * 22 / M_PI);
100  save(62, (((120 * rho2 - 252) * rho2 + 168) * rho2- 35) * rho4
101  * 22 / M_PI);
102  save(61, ((((210 * rho2 - 504) * rho2 + 420) * rho2 - 140) * rho2 + 15) * rho2
103  * 22 / M_PI);
104  save(60, (((((252 * rho2 - 630) * rho2 + 560) * rho2 - 210) * rho2 + 30) * rho2 - 1)
105  * 11 / M_PI);
106  libmesh_fallthrough();
107 
108  case 9:
109  save(54, rho4 * rho4 * rho
110  * 20 / M_PI);
111  save(53, (9 * rho2 - 8) * rho4 * rho2 * rho
112  * 20 / M_PI);
113  save(52, ((36 * rho2 - 56) * rho2 + 21) * rho4 * rho
114  * 20 / M_PI);
115  save(51, (((84 * rho2 - 168) * rho2 + 105) * rho2 - 20) * rho2 * rho
116  * 20 / M_PI);
117  save(50, ((((126 * rho2 - 280) * rho2 + 210) * rho2 - 60) * rho2 + 5) * rho
118  * 20 / M_PI);
119  libmesh_fallthrough();
120 
121  case 8:
122  save(44, rho4 * rho4
123  * 18 / M_PI);
124  save(43, (8 * rho2 - 7) * rho4 * rho2
125  * 18 / M_PI);
126  save(42, ((28 * rho2 - 42) * rho2 + 15) * rho4
127  * 18 / M_PI);
128  save(41, (((56 * rho2 - 105) * rho2 + 60) * rho2 - 10) * rho2
129  * 18 / M_PI);
130  save(40, ((((70 * rho2 - 140) * rho2 + 90) * rho2 - 20) * rho2 + 1)
131  * 9 / M_PI);
132  libmesh_fallthrough();
133 
134  case 7:
135  save(35, rho4 * rho2 * rho
136  * 16 / M_PI);
137  save(34, (7 * rho2 - 6) * rho4 * rho
138  * 16 / M_PI);
139  save(33, ((21 * rho2 - 30) * rho2 + 10) * rho2 * rho
140  * 16 / M_PI);
141  save(32, (((35 * rho2 - 60) * rho2 + 30) * rho2 - 4) * rho
142  * 16 / M_PI);
143  libmesh_fallthrough();
144 
145  case 6:
146  save(27, rho4 * rho2
147  * 14 / M_PI);
148  save(26, (6 * rho2 - 5) * rho4
149  * 14 / M_PI);
150  save(25, ((15 * rho2 - 20) * rho2 + 6) * rho2
151  * 14 / M_PI);
152  save(24, (((20 * rho2 - 30) * rho2 + 12) * rho2 - 1)
153  * 7 / M_PI);
154  libmesh_fallthrough();
155 
156  case 5:
157  save(20, rho4 * rho
158  * 12 / M_PI);
159  save(19, (5 * rho2 - 4) * rho2 * rho
160  * 12 / M_PI);
161  save(18, ((10 * rho2 - 12) * rho2 + 3) * rho
162  * 12 / M_PI);
163  libmesh_fallthrough();
164 
165  case 4:
166  save(14, rho4
167  * 10 / M_PI);
168  save(13, (4 * rho2 - 3) * rho2
169  * 10 / M_PI);
170  save(12, ((6 * rho2 - 6) * rho2 + 1)
171  * 5 / M_PI);
172  libmesh_fallthrough();
173 
174  case 3:
175  save(9, rho2 * rho
176  * 8 / M_PI);
177  save(8, (3 * rho2 - 2) * rho
178  * 8 / M_PI);
179  libmesh_fallthrough();
180 
181  case 2:
182  save(5, rho2
183  * 6 / M_PI);
184  save(4, (2 * rho2 - 1)
185  * 3 / M_PI);
186  libmesh_fallthrough();
187 
188  case 1:
189  save(2, rho
190  * 4 / M_PI);
191  libmesh_fallthrough();
192 
193  case 0:
194  save(0, 1
195  * 1 / M_PI);
196  }
197 
198  for (n = MAX_DIRECT_CALCULATION_ZERNIKE + 1; n <= _orders[0]; ++n)
199  {
200  j = simpleDoubleToSingle(n, n);
201  save(j, pow(rho, n)
202  * (n + n + 2) / M_PI);
203 
204  j--;
205  save(j, n * load(j + 1) - (n + 1) * load(j - (n + n)));
206 
207  for (q = n; q >= 4; q -= 2)
208  {
209  H3 = (-4 * (q - 2) * (q - 3)) / ((n + q - 2) * (n - q + 4.0));
210  H2 = (H3 * (n + q) * (n - q + 2)) / (4.0 * (q - 1)) + (q - 2);
211  H1 = q * (q - 1) / 2 - q * H2 + (H3 * (n + q + 2) * (n - q)) / 8.0;
212  j--;
213  if (q == 4)
214  save(j, (H1 * load(j + 2) + (H2 + H3 / rho2) * load(j + 1))
215  * 0.5);
216  else
217  save(j, H1 * load(j + 2) + (H2 + H3 / rho2) * load(j + 1));
218  }
219  }
220 
222 }
std::size_t simpleDoubleToSingle(std::size_t n, long m) const
Maps the double order/rank idices to a single linear index.
Definition: Zernike.C:436
void fillOutNegativeRankAndApplyAzimuthalComponent()
Helper function used by evaluateGeneration() and evaluateExpansion().
Definition: Zernike.C:363
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.
ExpressionBuilder::EBTerm pow(const ExpressionBuilder::EBTerm &left, T exponent)
std::vector< std::size_t > _orders
The order of the series.

◆ evaluateSqrtMu()

void Zernike::evaluateSqrtMu ( )
protectedvirtual

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

Definition at line 226 of file Zernike.C.

Referenced by Zernike().

227 {
229  save(0, load(0) / std::sqrt(M_PI));
230  size_t j = 1;
231  for (size_t n = 1; n < _orders[0] + 1; ++n)
232  {
233  for (size_t m = 0; m < n + 1; ++m)
234  {
235  if (m != 0 && n / m == 2 && n % m == 0)
236  save(j, load(j) * std::sqrt((n + 1) / M_PI));
237  else
238  save(j, load(j) * std::sqrt((2 * n + 2) / M_PI));
239  ++j;
240  }
241  }
242 }
void save(std::size_t index, Real value)
Helper function to store a value in #_series.
virtual void evaluateStandard()
Evaluates the standard form of the basis functions.
Definition: Zernike.C:245
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.

◆ evaluateStandard()

void Zernike::evaluateStandard ( )
protectedvirtual

Evaluates the standard form of the basis functions.

Definition at line 245 of file Zernike.C.

Referenced by evaluateSqrtMu(), and Zernike().

246 {
247  std::size_t n;
248  long j, q;
249  Real H1, H2, H3;
250  const Real & rho = _standardized_location[0];
251  const Real rho2 = rho * rho;
252  const Real rho4 = rho2 * rho2;
253 
254  if (MooseUtils::absoluteFuzzyLessEqual(rho, 0))
255  {
256  for (n = 0; n <= _orders[0]; n += 2)
257  {
258  j = simpleDoubleToSingle(n, 0);
259 
260  if ((n / 2) % 2 != 0)
261  save(j, -1);
262  else
263  save(j, 1);
264  }
265 
266  return;
267  }
268 
269  switch (_orders[0])
270  {
271  default:
272  case MAX_DIRECT_CALCULATION_ZERNIKE: /* 10 */
273  save(65, rho4 * rho4 * rho2);
274  save(64, (10 * rho2 - 9) * rho4 * rho4);
275  save(63, ((45 * rho2 - 72) * rho2 + 28) * rho4 * rho2);
276  save(62, (((120 * rho2 - 252) * rho2 + 168) * rho2 - 35) * rho4);
277  save(61, ((((210 * rho2 - 504) * rho2 + 420) * rho2 - 140) * rho2 + 15) * rho2);
278  save(60, ((((252 * rho2 - 630) * rho2 + 560) * rho2 - 210) * rho2 + 30) * rho2 - 1);
279  libmesh_fallthrough();
280 
281  case 9:
282  save(54, rho4 * rho4 * rho);
283  save(53, (9 * rho2 - 8) * rho4 * rho2 * rho);
284  save(52, ((36 * rho2 - 56) * rho2 + 21) * rho4 * rho);
285  save(51, (((84 * rho2 - 168) * rho2 + 105) * rho2 - 20) * rho2 * rho);
286  save(50, ((((126 * rho2 - 280) * rho2 + 210) * rho2 - 60) * rho2 + 5) * rho);
287  libmesh_fallthrough();
288 
289  case 8:
290  save(44, rho4 * rho4);
291  save(43, (8 * rho2 - 7) * rho4 * rho2);
292  save(42, ((28 * rho2 - 42) * rho2 + 15) * rho4);
293  save(41, (((56 * rho2 - 105) * rho2 + 60) * rho2 - 10) * rho2);
294  save(40, (((70 * rho2 - 140) * rho2 + 90) * rho2 - 20) * rho2 + 1);
295  libmesh_fallthrough();
296 
297  case 7:
298  save(35, rho4 * rho2 * rho);
299  save(34, (7 * rho2 - 6) * rho4 * rho);
300  save(33, ((21 * rho2 - 30) * rho2 + 10) * rho2 * rho);
301  save(32, (((35 * rho2 - 60) * rho2 + 30) * rho2 - 4) * rho);
302  libmesh_fallthrough();
303 
304  case 6:
305  save(27, rho4 * rho2);
306  save(26, (6 * rho2 - 5) * rho4);
307  save(25, ((15 * rho2 - 20) * rho2 + 6) * rho2);
308  save(24, ((20 * rho2 - 30) * rho2 + 12) * rho2 - 1);
309  libmesh_fallthrough();
310 
311  case 5:
312  save(20, rho4 * rho);
313  save(19, (5 * rho2 - 4) * rho2 * rho);
314  save(18, ((10 * rho2 - 12) * rho2 + 3) * rho);
315  libmesh_fallthrough();
316 
317  case 4:
318  save(14, rho4);
319  save(13, (4 * rho2 - 3) * rho2);
320  save(12, (6 * rho2 - 6) * rho2 + 1);
321  libmesh_fallthrough();
322 
323  case 3:
324  save(9, rho2 * rho);
325  save(8, (3 * rho2 - 2) * rho);
326  libmesh_fallthrough();
327 
328  case 2:
329  save(5, rho2);
330  save(4, 2 * rho2 - 1);
331  libmesh_fallthrough();
332 
333  case 1:
334  save(2, rho);
335  libmesh_fallthrough();
336 
337  case 0:
338  save(0, 1);
339  }
340 
341  for (n = MAX_DIRECT_CALCULATION_ZERNIKE + 1; n <= _orders[0]; ++n)
342  {
343  j = simpleDoubleToSingle(n, n);
344  save(j, pow(rho, n));
345 
346  j--;
347  save(j, n * load(j + 1) - (n - 1) * load(j - (n + n)));
348 
349  for (q = n; q >= 4; q -= 2)
350  {
351  H3 = (-4 * (q - 2) * (q - 3)) / ((n + q - 2) * (n - q + 4.0));
352  H2 = (H3 * (n + q) * (n - q + 2)) / (4.0 * (q - 1)) + (q - 2);
353  H1 = q * (q - 1) / 2 - q * H2 + (H3 * (n + q + 2) * (n - q)) / 8.0;
354  j--;
355  save(j, H1 * load(j + 2) + (H2 + H3 / rho2) * load(j + 1));
356  }
357  }
358 
360 }
std::size_t simpleDoubleToSingle(std::size_t n, long m) const
Maps the double order/rank idices to a single linear index.
Definition: Zernike.C:436
void fillOutNegativeRankAndApplyAzimuthalComponent()
Helper function used by evaluateGeneration() and evaluateExpansion().
Definition: Zernike.C:363
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.
ExpressionBuilder::EBTerm pow(const ExpressionBuilder::EBTerm &left, T exponent)
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 Legendre::isInPhysicalBounds(), 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 ...

◆ fillOutNegativeRankAndApplyAzimuthalComponent()

void Zernike::fillOutNegativeRankAndApplyAzimuthalComponent ( )
protected

Helper function used by evaluateGeneration() and evaluateExpansion().

It uses the evaluated value array of the zero and positive rank terms to: 1) fill out the negative rank terms 2) apply the azimuthal components to all terms

Definition at line 363 of file Zernike.C.

Referenced by evaluateOrthonormal(), and evaluateStandard().

364 {
365  std::size_t n;
366  long j, m, q, a;
367  const Real & phi = _standardized_location[1];
368 
369  j = 0;
370  for (n = 1; n <= _orders[0]; ++n)
371  {
372  j += n;
373  for (m = 0, q = a = n; m < q; ++m, --q, a -= 2)
374  {
375  save(j + m, load(j + q) * sin(a * phi));
376  save(j + q, load(j + q) * cos(a * phi));
377  }
378  }
379 }
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.

◆ 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 Legendre::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 > & Zernike::getStandardizedFunctionLimits ( ) const
overridevirtual

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

Implements FunctionalBasisInterface.

Definition at line 382 of file Zernike.C.

383 {
384  // Lazily instantiate the function limits array
385  static const std::vector<Real> standardizedFunctionLimits = {0, 1, -M_PI, M_PI};
386 
387  return standardizedFunctionLimits;
388 }

◆ getStandardizedFunctionVolume()

Real Zernike::getStandardizedFunctionVolume ( ) const
overridevirtual

Returns the volume within the standardized function local_limits.

Implements FunctionalBasisInterface.

Definition at line 391 of file Zernike.C.

392 {
393  return M_PI; // The area of a unit disc is pi
394 }

◆ getStandardizedLocation()

std::vector< Real > Zernike::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 397 of file Zernike.C.

Referenced by isInPhysicalBounds().

398 {
399  // Get the offset corresponding to the 'x' direction
400  const Real offset1 = location[0] - _physical_bounds[0];
401  // Get the offset corresponding to the 'y' direction
402  const Real offset2 = location[1] - _physical_bounds[1];
403  // Get the user-provided radius bound
404  const Real & radius = _physical_bounds[2];
405  // Covert to a radis and normalize
406  const Real standardizedRadius = sqrt(offset1 * offset1 + offset2 * offset2) / radius;
407  // Get the angle
408  const Real theta = atan2(offset2, offset1);
409 
410  return {standardizedRadius, theta};
411 }
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 Zernike::isInPhysicalBounds ( const Point &  point) const
overridevirtual

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

Implements FunctionalBasisInterface.

Definition at line 414 of file Zernike.C.

415 {
416  /*
417  * Because Zernike polynomials live in RZ space, the easiest approach to check
418  * this is to convert the physical location into a standardized location, then
419  * check against the radius and theta bounds.
420  */
421  const std::vector<Real> location = extractLocationFromPoint(point);
422  const std::vector<Real> standardized_location = getStandardizedLocation(location);
423 
424  /*
425  * The radius (standardized_location[0]) is always positive, so only check
426  * against the maximum radius (1). The theta components should always be in
427  * bounds.
428  */
429  if (standardized_location[0] > 1.0)
430  return false;
431  else
432  return true;
433 }
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 co...
Definition: Zernike.C:397
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 Legendre::evaluateOrthonormal(), evaluateOrthonormal(), Legendre::evaluateSqrtMu(), evaluateSqrtMu(), Legendre::evaluateStandard(), evaluateStandard(), and 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 Legendre::evaluateOrthonormal(), evaluateOrthonormal(), CompositeSeriesBasisInterface::evaluateSeries(), Legendre::evaluateSqrtMu(), evaluateSqrtMu(), Legendre::evaluateStandard(), evaluateStandard(), and 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

◆ simpleDoubleToSingle()

std::size_t Zernike::simpleDoubleToSingle ( std::size_t  n,
long  m 
) const
protected

Maps the double order/rank idices to a single linear index.

Definition at line 436 of file Zernike.C.

Referenced by evaluateOrthonormal(), and evaluateStandard().

437 {
438  return (n * (n + 2) + m) / 2;
439 }

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::Legendre(), and 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::Legendre(), and Zernike().

◆ _negative_azimuthal_components

std::vector<Real> Zernike::_negative_azimuthal_components
protected

Stores the recurrence evaluations for the negative rank azimuthal terms.

Definition at line 70 of file Zernike.h.

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

◆ _positive_azimuthal_components

std::vector<Real> Zernike::_positive_azimuthal_components
protected

Stores the recurrence evaluations for the positive rank azimuthal terms.

Definition at line 73 of file Zernike.h.

◆ _standardized_location

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

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