https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Protected Attributes | Private Member Functions | Private 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.
 
virtual bool isInPhysicalBounds (const Point &point) const override
 Determines if the point provided is in within the physical bounds.
 
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.
 
virtual const std::vector< Real > & getStandardizedFunctionLimits () const override
 Returns a vector of the lower and upper bounds of the standard functional space.
 
virtual bool isCacheInvalid () const final
 Whether the cached values correspond to the current point.
 
virtual void setLocation (const Point &point) final
 Set the location that will be used by the series to compute values.
 
virtual void setOrder (const std::vector< std::size_t > &orders) final
 Set the order of the series.
 
virtual void setPhysicalBounds (const std::vector< Real > &bounds) final
 Sets the bounds of the series.
 
std::size_t getOrder (std::size_t domain) const
 Returns the order of the particular domain index.
 
Real operator[] (std::size_t index) const
 Returns the current evaluation at the given index.
 
const std::vector< Real > & getAllGeneration ()
 Returns an array reference containing the value of each generation term.
 
const std::vector< Real > & getAllExpansion ()
 Returns an array reference containing the value of each expansion term.
 
std::size_t getNumberOfTerms () const
 Returns the number of terms in the series.
 
Real getGeneration ()
 Gets the last term of the generation functional basis.
 
Real getGenerationSeriesSum ()
 Gets the sum of all terms in the generation functional basis.
 
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.
 
bool isGeneration () const
 Returns true if the current evaluation is generation.
 
bool isExpansion () const
 Returns true if the current evaluation is expansion.
 

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.
 

Static Public Attributes

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

Protected Member Functions

virtual void evaluateOrthonormal ()
 Evaluates the orthonormal form of the basis functions.
 
virtual void evaluateStandard ()
 Evaluates the standard form of the basis functions.
 
virtual void evaluateSqrtMu ()
 Evaluates the 1/sqrt(mu) normalized form of the basis functions.
 
virtual void checkPhysicalBounds (const std::vector< Real > &bounds) const override
 Checks the physical bounds according to the actual implementation.
 
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.
 
void fillOutNegativeRankAndApplyAzimuthalComponent ()
 Helper function used by evaluateGeneration() and evaluateExpansion().
 
std::size_t simpleDoubleToSingle (std::size_t n, long m) const
 Maps the double order/rank idices to a single linear index.
 
virtual void evaluateGeneration () override
 Evaluate the generation form of the functional basis.
 
virtual void evaluateExpansion () override
 Evaluate the expansion form of the functional basis.
 
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.
 
Real load (std::size_t index) const
 Helper function to load a value from #_series.
 
void save (std::size_t index, Real value)
 Helper function to store a value in #_series.
 

Protected Attributes

std::vector< Real > _negative_azimuthal_components
 Stores the recurrence evaluations for the negative rank azimuthal terms.
 
std::vector< Real > _positive_azimuthal_components
 Stores the recurrence evaluations for the positive rank azimuthal terms.
 
std::vector< std::size_t > _orders
 The order of the series.
 
std::vector< Real > _physical_bounds
 The physical bounds of the series.
 
std::vector< Real > _standardized_location
 The standardized location of evaluation.
 
std::function< void()> _evaluateExpansionWrapper
 The expansion evaluation wrapper.
 
std::function< void()> _evaluateGenerationWrapper
 The generation evaluation wrapper.
 
unsigned int _number_of_terms
 The number of terms in the series.
 

Private Member Functions

virtual void clearBasisEvaluation (const unsigned int &number_of_terms)
 Set all entries of the basis evaluation to zero.
 

Private Attributes

bool _are_physical_bounds_specified
 Flag for if the physical bounds are specified for this series.
 
std::vector< Real > _location
 The domain locations of the current evaluation.
 
bool _is_cache_invalid
 indicates if the evaluated values correspond to the current location
 
std::vector< Real > _basis_evaluation
 Stores the values of the basis evaluation.
 
bool _is_generation
 Indicates whether the current evaluation is expansion or generation.
 

Detailed Description

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

Definition at line 17 of file Zernike.h.

Constructor & Destructor Documentation

◆ Zernike() [1/2]

Zernike::Zernike ( )

◆ 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}
void mooseError(Args &&... args)
MooseEnum expansion_type
MooseEnum generation_type
std::function< void()> _evaluateGenerationWrapper
The generation evaluation wrapper.
std::function< void()> _evaluateExpansionWrapper
The expansion evaluation wrapper.
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
virtual void evaluateSqrtMu()
Evaluates the 1/sqrt(mu) normalized form of the basis functions.
Definition Zernike.C:226
virtual void evaluateStandard()
Evaluates the standard form of the basis functions.
Definition Zernike.C:245
virtual void evaluateOrthonormal()
Evaluates the orthonormal form of the basis functions.
Definition Zernike.C:66

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)
privatevirtualinherited

Set all entries of the basis evaluation to zero.

Reimplemented from FunctionalBasisInterface.

Definition at line 120 of file FunctionalBasisInterface.C.

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

Referenced by SingleSeriesBasisInterface::setOrder().

◆ evaluateExpansion()

void SingleSeriesBasisInterface::evaluateExpansion ( )
overrideprotectedvirtualinherited

Evaluate the expansion form of the functional basis.

Implements FunctionalBasisInterface.

Definition at line 57 of file SingleSeriesBasisInterface.C.

◆ evaluateGeneration()

void SingleSeriesBasisInterface::evaluateGeneration ( )
overrideprotectedvirtualinherited

Evaluate the generation form of the functional basis.

Implements FunctionalBasisInterface.

Definition at line 51 of file SingleSeriesBasisInterface.C.

◆ evaluateOrthonormal()

void Zernike::evaluateOrthonormal ( )
protectedvirtual

Evaluates the orthonormal form of the basis functions.

Definition at line 66 of file Zernike.C.

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}
ExpressionBuilder::EBTerm pow(const ExpressionBuilder::EBTerm &left, T exponent)
const double rho
Real load(std::size_t index) const
Helper function to load a value from #_series.
void save(std::size_t index, Real value)
Helper function to store a value in #_series.
std::vector< std::size_t > _orders
The order of the series.
std::vector< Real > _standardized_location
The standardized location of evaluation.
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
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real

Referenced by Zernike().

◆ evaluateSqrtMu()

void Zernike::evaluateSqrtMu ( )
protectedvirtual

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

Definition at line 226 of file Zernike.C.

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}

Referenced by Zernike().

◆ evaluateStandard()

void Zernike::evaluateStandard ( )
protectedvirtual

Evaluates the standard form of the basis functions.

Definition at line 245 of file Zernike.C.

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}

Referenced by evaluateSqrtMu(), and Zernike().

◆ 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 122 of file SingleSeriesBasisInterface.C.

123{
124 std::vector<Real> location(_domains.size());
125
126 // Update the locations as specified by _domain
127 for (std::size_t index = 0; index < _domains.size(); ++index)
128 location[index] = point(_domains[index]);
129 return location;
130}
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 ...

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

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

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}
CTSub CT_OPERATOR_BINARY CTMul CTCompareLess CTCompareGreater CTCompareEqual _arg template * sin(_arg) *_arg.template D< dtag >()) CT_SIMPLE_UNARY_FUNCTION(tan
CTSub CT_OPERATOR_BINARY CTMul CTCompareLess CTCompareGreater CTCompareEqual _arg template cos(_arg) *_arg.template D< dtag >()) CT_SIMPLE_UNARY_FUNCTION(cos

Referenced by evaluateOrthonormal(), and evaluateStandard().

◆ getAllExpansion()

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

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

Definition at line 73 of file FunctionalBasisInterface.C.

74{
76 {
78
80
81 _is_generation = false;
82 _is_cache_invalid = false;
83 }
84
85 return _basis_evaluation;
86}
bool _is_cache_invalid
indicates if the evaluated values correspond to the current location
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.
bool isGeneration() const
Returns true if the current evaluation is generation.
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.

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

◆ getAllGeneration()

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

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

Definition at line 57 of file FunctionalBasisInterface.C.

58{
59 if (isExpansion() || isCacheInvalid())
60 {
62
64
65 _is_generation = true;
66 _is_cache_invalid = false;
67 }
68
69 return _basis_evaluation;
70}
virtual void evaluateGeneration()=0
Evaluate the generation form of the functional basis.
bool isExpansion() const
Returns true if the current evaluation is expansion.

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

◆ getExpansion()

Real FunctionalBasisInterface::getExpansion ( )
inherited

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

Definition at line 114 of file FunctionalBasisInterface.C.

115{
116 // Use getAllExpansion() which will lazily evaluate the series as needed
117 return getAllExpansion().back();
118}
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 121 of file FunctionalBasisInterface.C.

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}

Referenced by TEST(), and TEST().

◆ getGeneration()

Real FunctionalBasisInterface::getGeneration ( )
inherited

Gets the last term of the generation functional basis.

Definition at line 95 of file FunctionalBasisInterface.C.

96{
97 // Use getAllGeneration() which will lazily evaluate the series as needed
98 return getAllGeneration().back();
99}
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 102 of file FunctionalBasisInterface.C.

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}

Referenced by TEST(), and TEST().

◆ getNumberOfTerms()

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

Returns the number of terms in the series.

Definition at line 89 of file FunctionalBasisInterface.C.

90{
91 return _number_of_terms;
92}

Referenced by Legendre::evaluateSqrtMu(), TEST(), TEST(), TEST(), and TEST().

◆ getOrder()

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

Returns the order of the particular domain index.

Definition at line 133 of file SingleSeriesBasisInterface.C.

134{
135 return domain < _orders.size() ? _orders[domain] : -1;
136}

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

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.
CTSub CT_OPERATOR_BINARY CTMul CTCompareLess CTCompareGreater CTCompareEqual _arg template * sqrt(_arg)) *_arg.template D< dtag >()) CT_SIMPLE_UNARY_FUNCTION(tanh
const Real radius

Referenced by isInPhysicalBounds().

◆ isCacheInvalid()

bool SingleSeriesBasisInterface::isCacheInvalid ( ) const
finalvirtualinherited

Whether the cached values correspond to the current point.

Implements FunctionalBasisInterface.

Definition at line 45 of file SingleSeriesBasisInterface.C.

46{
47 return _is_cache_invalid;
48}
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 51 of file FunctionalBasisInterface.C.

52{
53 return !_is_generation;
54}

Referenced by FunctionalBasisInterface::getAllGeneration().

◆ isGeneration()

bool FunctionalBasisInterface::isGeneration ( ) const
inherited

Returns true if the current evaluation is generation.

Definition at line 45 of file FunctionalBasisInterface.C.

46{
47 return _is_generation;
48}

Referenced by FunctionalBasisInterface::getAllExpansion().

◆ 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}
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 override
Standardize the location according to the requirements of the underlying basis, which may actually co...
Definition Zernike.C:397

◆ load()

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

◆ operator[]()

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

Returns the current evaluation at the given index.

Definition at line 39 of file FunctionalBasisInterface.C.

40{
41 return (index > _basis_evaluation.size() ? 0.0 : _basis_evaluation[index]);
42}

◆ save()

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

◆ 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 102 of file SingleSeriesBasisInterface.C.

103{
104 std::vector<Real> oldLocation(_location);
105
106 // Update the physical-space location
108
109 // Standardize the location if standardized bounds exist
112 else
114
115 // Once the location is changed, the cached values correspond to an old location
116 for (std::size_t i = 0; !_is_cache_invalid && (i < _location.size()); ++i)
117 if (oldLocation[i] != _location[i])
118 _is_cache_invalid = true;
119}
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 _are_physical_bounds_specified
Flag for if the physical bounds are specified for this series.
std::vector< Real > _location
The domain locations of the current evaluation.

Referenced by TEST(), TEST(), TEST(), TEST(), and TEST().

◆ setOrder()

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

Set the order of the series.

Implements FunctionalBasisInterface.

Definition at line 63 of file SingleSeriesBasisInterface.C.

64{
65 if (orders.size() != _orders.size())
66 mooseError("SSBI: Invalid 'orders' use in setOrder()!");
67
68 /*
69 * Do nothing if the order isn't changed. Note that this only compares the first value - it is
70 * assumed that a single series only needs to be described using a single order.
71 */
72 if (orders[0] == _orders[0])
73 return;
74
75 _orders = orders;
76
77 // Set the new number of terms in the single series
79
80 // Zero the basis evaluation
82 _is_cache_invalid = true;
83}
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.
virtual void clearBasisEvaluation(const unsigned int &number_of_terms)
Set all entries of the basis evaluation to zero.

◆ setPhysicalBounds()

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

Sets the bounds of the series.

Implements FunctionalBasisInterface.

Definition at line 86 of file SingleSeriesBasisInterface.C.

87{
88 // Use the concrete implementation to check the validity of the bounds
89 checkPhysicalBounds(bounds);
90
91 _physical_bounds = bounds;
93
94 /*
95 * Once the physical bounds have been changed, the normalization of a point will change, so the
96 * cached values will also be incorrect
97 */
98 _is_cache_invalid = true;
99}
virtual void checkPhysicalBounds(const std::vector< Real > &bounds) const =0
Checks the physical bounds according to the actual implementation.

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

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

Referenced by evaluateOrthonormal(), and evaluateStandard().

Member Data Documentation

◆ _are_physical_bounds_specified

bool SingleSeriesBasisInterface::_are_physical_bounds_specified
privateinherited

Flag for if the physical bounds are specified for this series.

Definition at line 95 of file SingleSeriesBasisInterface.h.

Referenced by SingleSeriesBasisInterface::setLocation(), and SingleSeriesBasisInterface::setPhysicalBounds().

◆ _basis_evaluation

std::vector<Real> FunctionalBasisInterface::_basis_evaluation
privateinherited

◆ _domain_options

MooseEnum FunctionalBasisInterface::_domain_options
staticinherited

An enumeration of the domains available to each functional series.

Definition at line 114 of file FunctionalBasisInterface.h.

Referenced by FunctionSeries::FunctionSeries(), SingleSeriesBasisInterface::SingleSeriesBasisInterface(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), 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 60 of file SingleSeriesBasisInterface.h.

Referenced by SingleSeriesBasisInterface::extractLocationFromPoint().

◆ _evaluateExpansionWrapper

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

The expansion evaluation wrapper.

Definition at line 88 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 91 of file SingleSeriesBasisInterface.h.

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

◆ _is_cache_invalid

bool FunctionalBasisInterface::_is_cache_invalid
privateinherited

◆ _is_generation

bool FunctionalBasisInterface::_is_generation
privateinherited

◆ _location

std::vector<Real> SingleSeriesBasisInterface::_location
privateinherited

The domain locations of the current evaluation.

This is private so that derived classes will be required to use _standardized_location, essentially forcing location-awareness compliance

Definition at line 99 of file SingleSeriesBasisInterface.h.

Referenced by SingleSeriesBasisInterface::setLocation().

◆ _negative_azimuthal_components

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

Stores the recurrence evaluations for the negative rank azimuthal terms.

Definition at line 69 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 72 of file Zernike.h.

◆ _standardized_location

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

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