www.mooseframework.org
SingleSeriesBasisInterface.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 
FunctionalBasisInterface::_domain_options
static MooseEnum _domain_options
An enumeration of the domains available to each functional series.
Definition: FunctionalBasisInterface.h:115
SingleSeriesBasisInterface::_evaluateGenerationWrapper
std::function< void()> _evaluateGenerationWrapper
The generation evaluation wrapper.
Definition: SingleSeriesBasisInterface.h:91
SingleSeriesBasisInterface::_domains
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 ...
Definition: SingleSeriesBasisInterface.h:60
SingleSeriesBasisInterface::evaluateExpansion
virtual void evaluateExpansion() override
Evaluate the expansion form of the functional basis.
Definition: SingleSeriesBasisInterface.C:57
SingleSeriesBasisInterface.h
SingleSeriesBasisInterface::_evaluateExpansionWrapper
std::function< void()> _evaluateExpansionWrapper
The expansion evaluation wrapper.
Definition: SingleSeriesBasisInterface.h:88
SingleSeriesBasisInterface::_location
std::vector< Real > _location
The domain locations of the current evaluation.
Definition: SingleSeriesBasisInterface.h:99
SingleSeriesBasisInterface::isCacheInvalid
virtual bool isCacheInvalid() const final
Whether the cached values correspond to the current point.
Definition: SingleSeriesBasisInterface.C:45
SingleSeriesBasisInterface::evaluateGeneration
virtual void evaluateGeneration() override
Evaluate the generation form of the functional basis.
Definition: SingleSeriesBasisInterface.C:51
SingleSeriesBasisInterface::SingleSeriesBasisInterface
SingleSeriesBasisInterface()
Definition: SingleSeriesBasisInterface.C:20
SingleSeriesBasisInterface::getOrder
std::size_t getOrder(std::size_t domain) const
Returns the order of the particular domain index.
Definition: SingleSeriesBasisInterface.C:133
SingleSeriesBasisInterface::~SingleSeriesBasisInterface
virtual ~SingleSeriesBasisInterface()
Definition: SingleSeriesBasisInterface.C:138
SingleSeriesBasisInterface::_standardized_location
std::vector< Real > _standardized_location
The standardized location of evaluation.
Definition: SingleSeriesBasisInterface.h:85
SingleSeriesBasisInterface::setPhysicalBounds
virtual void setPhysicalBounds(const std::vector< Real > &bounds) final
Sets the bounds of the series.
Definition: SingleSeriesBasisInterface.C:86
SingleSeriesBasisInterface::_are_physical_bounds_specified
bool _are_physical_bounds_specified
Flag for if the physical bounds are specified for this series.
Definition: SingleSeriesBasisInterface.h:95
FunctionalBasisInterface::_number_of_terms
unsigned int _number_of_terms
The number of terms in the series.
Definition: FunctionalBasisInterface.h:144
SingleSeriesBasisInterface::_physical_bounds
std::vector< Real > _physical_bounds
The physical bounds of the series.
Definition: SingleSeriesBasisInterface.h:82
FunctionalBasisInterface::clearBasisEvaluation
virtual void clearBasisEvaluation(const unsigned int &number_of_terms)
Set all entries of the basis evaluation to zero.
Definition: FunctionalBasisInterface.C:144
SingleSeriesBasisInterface::setLocation
virtual void setLocation(const Point &point) final
Set the location that will be used by the series to compute values.
Definition: SingleSeriesBasisInterface.C:102
FunctionalBasisInterface::_is_cache_invalid
bool _is_cache_invalid
indicates if the evaluated values correspond to the current location
Definition: FunctionalBasisInterface.h:147
SingleSeriesBasisInterface::checkPhysicalBounds
virtual void checkPhysicalBounds(const std::vector< Real > &bounds) const =0
Checks the physical bounds according to the actual implementation.
SingleSeriesBasisInterface::_orders
std::vector< std::size_t > _orders
The order of the series.
Definition: SingleSeriesBasisInterface.h:79
SingleSeriesBasisInterface::calculatedNumberOfTermsBasedOnOrder
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.
SingleSeriesBasisInterface::setOrder
virtual void setOrder(const std::vector< std::size_t > &orders) final
Set the order of the series.
Definition: SingleSeriesBasisInterface.C:63
SingleSeriesBasisInterface::getStandardizedLocation
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...
SingleSeriesBasisInterface::extractLocationFromPoint
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...
Definition: SingleSeriesBasisInterface.C:122
FunctionalBasisInterface
This class provides the basis for any custom functional basis, and is the parent class of both Single...
Definition: FunctionalBasisInterface.h:23