Line data Source code
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 : 10 : #include "SingleSeriesBasisInterface.h" 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 : */ 20 0 : SingleSeriesBasisInterface::SingleSeriesBasisInterface() 21 : : FunctionalBasisInterface(1), 22 0 : _domains({_domain_options = "x"}), 23 0 : _orders({0}), 24 0 : _physical_bounds(2, 0.0), 25 0 : _standardized_location({0.0}), 26 0 : _are_physical_bounds_specified(false), 27 0 : _location(_domains.size(), 0.0) 28 : { 29 0 : } 30 : 31 416 : SingleSeriesBasisInterface::SingleSeriesBasisInterface(const std::vector<MooseEnum> & domains, 32 : const std::vector<std::size_t> & orders, 33 416 : const unsigned int number_of_terms) 34 : : FunctionalBasisInterface(number_of_terms), 35 416 : _domains(domains), 36 416 : _orders(orders), 37 416 : _physical_bounds(2, 0.0), 38 416 : _standardized_location(1, 0.0), 39 416 : _are_physical_bounds_specified(false), 40 832 : _location(_domains.size(), 0.0) 41 : { 42 416 : } 43 : 44 : bool 45 814290 : SingleSeriesBasisInterface::isCacheInvalid() const 46 : { 47 814290 : return _is_cache_invalid; 48 : } 49 : 50 : void 51 281031 : SingleSeriesBasisInterface::evaluateGeneration() 52 : { 53 281031 : _evaluateGenerationWrapper(); 54 281031 : } 55 : 56 : void 57 160148 : SingleSeriesBasisInterface::evaluateExpansion() 58 : { 59 160148 : _evaluateExpansionWrapper(); 60 160148 : } 61 : 62 : void 63 0 : SingleSeriesBasisInterface::setOrder(const std::vector<std::size_t> & orders) 64 : { 65 0 : if (orders.size() != _orders.size()) 66 0 : 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 0 : if (orders[0] == _orders[0]) 73 : return; 74 : 75 0 : _orders = orders; 76 : 77 : // Set the new number of terms in the single series 78 0 : _number_of_terms = calculatedNumberOfTermsBasedOnOrder(_orders); 79 : 80 : // Zero the basis evaluation 81 0 : clearBasisEvaluation(_number_of_terms); 82 0 : _is_cache_invalid = true; 83 : } 84 : 85 : void 86 380 : SingleSeriesBasisInterface::setPhysicalBounds(const std::vector<Real> & bounds) 87 : { 88 : // Use the concrete implementation to check the validity of the bounds 89 380 : checkPhysicalBounds(bounds); 90 : 91 380 : _physical_bounds = bounds; 92 380 : _are_physical_bounds_specified = true; 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 380 : _is_cache_invalid = true; 99 380 : } 100 : 101 : void 102 441080 : SingleSeriesBasisInterface::setLocation(const Point & point) 103 : { 104 441080 : std::vector<Real> oldLocation(_location); 105 : 106 : // Update the physical-space location 107 882160 : _location = extractLocationFromPoint(point); 108 : 109 : // Standardize the location if standardized bounds exist 110 441080 : if (_are_physical_bounds_specified) 111 441052 : _standardized_location = getStandardizedLocation(_location); 112 : else 113 28 : _standardized_location = _location; 114 : 115 : // Once the location is changed, the cached values correspond to an old location 116 881957 : for (std::size_t i = 0; !_is_cache_invalid && (i < _location.size()); ++i) 117 440877 : if (oldLocation[i] != _location[i]) 118 440877 : _is_cache_invalid = true; 119 441080 : } 120 : 121 : std::vector<Real> 122 748150 : SingleSeriesBasisInterface::extractLocationFromPoint(const Point & point) const 123 : { 124 748150 : std::vector<Real> location(_domains.size()); 125 : 126 : // Update the locations as specified by _domain 127 1496309 : for (std::size_t index = 0; index < _domains.size(); ++index) 128 748159 : location[index] = point(_domains[index]); 129 748150 : return location; 130 : } 131 : 132 : std::size_t 133 1628 : SingleSeriesBasisInterface::getOrder(std::size_t domain) const 134 : { 135 1628 : return domain < _orders.size() ? _orders[domain] : -1; 136 : } 137 : 138 764 : SingleSeriesBasisInterface::~SingleSeriesBasisInterface() {}