https://mooseframework.inl.gov
SingleSeriesBasisInterface.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
11 
12 #include "libmesh/point.h"
13 
14 /*
15  * The default constructor for a single series creates a single-term functional basis of zeroth
16  * order. Although the _physical_bounds flag is set to false anyways, we need to assign some value
17  * here in the constructor so that the order of member variables in the include file doesn't give an
18  * error. The same holds for _standardized_location.
19  */
22  _domains({_domain_options = "x"}),
23  _orders({0}),
24  _physical_bounds(2, 0.0),
25  _standardized_location({0.0}),
26  _are_physical_bounds_specified(false),
27  _location(_domains.size(), 0.0)
28 {
29 }
30 
31 SingleSeriesBasisInterface::SingleSeriesBasisInterface(const std::vector<MooseEnum> & domains,
32  const std::vector<std::size_t> & orders,
33  const unsigned int number_of_terms)
34  : FunctionalBasisInterface(number_of_terms),
35  _domains(domains),
36  _orders(orders),
37  _physical_bounds(2, 0.0),
38  _standardized_location(1, 0.0),
39  _are_physical_bounds_specified(false),
40  _location(_domains.size(), 0.0)
41 {
42 }
43 
44 bool
46 {
47  return _is_cache_invalid;
48 }
49 
50 void
52 {
54 }
55 
56 void
58 {
60 }
61 
62 void
63 SingleSeriesBasisInterface::setOrder(const std::vector<std::size_t> & orders)
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 }
84 
85 void
86 SingleSeriesBasisInterface::setPhysicalBounds(const std::vector<Real> & bounds)
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 }
100 
101 void
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 }
120 
121 std::vector<Real>
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 }
131 
132 std::size_t
133 SingleSeriesBasisInterface::getOrder(std::size_t domain) const
134 {
135  return domain < _orders.size() ? _orders[domain] : -1;
136 }
137 
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 > _standardized_location
The standardized location of evaluation.
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 ...
void mooseError(Args &&... args)
std::function< void()> _evaluateExpansionWrapper
The expansion evaluation wrapper.
virtual void evaluateExpansion() override
Evaluate the expansion form of the functional basis.
std::function< void()> _evaluateGenerationWrapper
The generation evaluation wrapper.
unsigned int _number_of_terms
The number of terms in the series.
virtual void evaluateGeneration() override
Evaluate the generation form of the functional basis.
static MooseEnum _domain_options
An enumeration of the domains available to each functional series.
virtual void clearBasisEvaluation(const unsigned int &number_of_terms)
Set all entries of the basis evaluation to zero.
virtual bool isCacheInvalid() const final
Whether the cached values correspond to the current point.
std::vector< Real > _location
The domain locations of the current evaluation.
std::vector< Real > _physical_bounds
The physical bounds of the series.
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.
virtual void setLocation(const Point &point) final
Set the location that will be used by the series to compute values.
std::size_t getOrder(std::size_t domain) const
Returns the order of the particular domain index.
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...
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.
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...
This class provides the basis for any custom functional basis, and is the parent class of both Single...
bool _is_cache_invalid
indicates if the evaluated values correspond to the current location