Line data Source code
1 : // rbOOmit: An implementation of the Certified Reduced Basis method. 2 : // Copyright (C) 2009, 2010 David J. Knezevic 3 : 4 : // This file is part of rbOOmit. 5 : 6 : // rbOOmit is free software; you can redistribute it and/or 7 : // modify it under the terms of the GNU Lesser General Public 8 : // License as published by the Free Software Foundation; either 9 : // version 2.1 of the License, or (at your option) any later version. 10 : 11 : // rbOOmit is distributed in the hope that it will be useful, 12 : // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 : // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 : // Lesser General Public License for more details. 15 : 16 : // You should have received a copy of the GNU Lesser General Public 17 : // License along with this library; if not, write to the Free Software 18 : // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 : 20 : #ifndef LIBMESH_RB_THETA_EXPANSION_H 21 : #define LIBMESH_RB_THETA_EXPANSION_H 22 : 23 : // libMesh includes 24 : #include "libmesh/libmesh_common.h" 25 : #include "libmesh/reference_counted_object.h" 26 : 27 : // C++ includes 28 : #include <vector> 29 : #include <memory> 30 : 31 : namespace libMesh 32 : { 33 : 34 : class RBTheta; 35 : class RBParameters; 36 : 37 : /** 38 : * This class stores the set of RBTheta functor objects that define 39 : * the "parameter-dependent expansion" of a PDE. 40 : * 41 : * \author David J. Knezevic 42 : * \date 2011 43 : */ 44 : class RBThetaExpansion : public ReferenceCountedObject<RBThetaExpansion> 45 : { 46 : public: 47 : 48 : /** 49 : * All special functions can be defaulted for this simple class. 50 : */ 51 : RBThetaExpansion() = default; 52 : RBThetaExpansion (RBThetaExpansion &&) = default; 53 : RBThetaExpansion (const RBThetaExpansion &) = default; 54 : RBThetaExpansion & operator= (const RBThetaExpansion &) = default; 55 : RBThetaExpansion & operator= (RBThetaExpansion &&) = default; 56 0 : virtual ~RBThetaExpansion () = default; 57 : 58 : /** 59 : * Evaluate theta_q_a at the current parameter. Override 60 : * if the theta functions need to be treated differently 61 : * in subclasses. 62 : */ 63 : virtual Number eval_A_theta(unsigned int q, 64 : const RBParameters & mu) const; 65 : 66 : /** 67 : * Evaluate theta_q_a at multiple parameters simultaneously. 68 : */ 69 : virtual std::vector<Number> eval_A_theta(unsigned int q, 70 : const std::vector<RBParameters> & mus) const; 71 : 72 : /** 73 : * Evaluate theta_q_f at the current parameter. 74 : */ 75 : virtual Number eval_F_theta(unsigned int q, 76 : const RBParameters & mu) const; 77 : 78 : /** 79 : * Evaluate theta_q_f at multiple parameters simultaneously. 80 : */ 81 : virtual std::vector<Number> eval_F_theta(unsigned int q, 82 : const std::vector<RBParameters> & mus) const; 83 : 84 : /** 85 : * Evaluate theta_q_l at the current parameter. 86 : */ 87 : virtual Number eval_output_theta(unsigned int output_index, 88 : unsigned int q_l, 89 : const RBParameters & mu) const; 90 : 91 : /** 92 : * Evaluate theta_q_l at multiple parameters simultaneously. 93 : */ 94 : virtual std::vector<Number> eval_output_theta(unsigned int output_index, 95 : unsigned int q_l, 96 : const std::vector<RBParameters> & mus) const; 97 : 98 : /** 99 : * Get Q_a, the number of terms in the affine 100 : * expansion for the bilinear form. 101 : */ 102 : unsigned int get_n_A_terms() const; 103 : 104 : /** 105 : * Get Q_f, the number of terms in the affine 106 : * expansion for the right-hand side. 107 : */ 108 : unsigned int get_n_F_terms() const; 109 : 110 : /** 111 : * Get n_outputs, the number output functionals. 112 : */ 113 : unsigned int get_n_outputs() const; 114 : 115 : /** 116 : * Get the number of affine terms associated with the specified output. 117 : */ 118 : unsigned int get_n_output_terms(unsigned int output_index) const; 119 : 120 : /** 121 : * Returns the total number of affine terms associated with all outputs. 122 : */ 123 : unsigned int get_total_n_output_terms() const; 124 : 125 : /** 126 : * Computes the one-dimensional index for output n, term q_l implied by 127 : * a "row-major" ordering of the outputs. This is useful for indexing into 128 : * pre-evaluated theta arrays, which store the pre-evaluated output theta 129 : * values in this order following the "A" and "F" theta values. 130 : */ 131 : unsigned int output_index_1D(unsigned int n, unsigned int q_l) const; 132 : 133 : /** 134 : * Attach a pointer to a functor object that defines one 135 : * of the theta_q_a terms. 136 : */ 137 : virtual void attach_A_theta(RBTheta * theta_q_a); 138 : 139 : /** 140 : * Attach a vector of pointers to functor objects that each define one 141 : * of the theta_q_a terms. 142 : */ 143 : virtual void attach_multiple_A_theta(std::vector<std::unique_ptr<RBTheta>> & theta_q_a); 144 : 145 : /** 146 : * Attach a pointer to a functor object that defines one 147 : * of the theta_q_a terms. 148 : */ 149 : virtual void attach_F_theta(RBTheta * theta_q_f); 150 : 151 : /** 152 : * Attach a vector of pointers to functor objects that each define one 153 : * of the theta_q_f terms. 154 : */ 155 : virtual void attach_multiple_F_theta(std::vector<std::unique_ptr<RBTheta>> & theta_q_f); 156 : 157 : /** 158 : * Attach a vector of pointers to functor objects that define one 159 : * of the outputs. 160 : */ 161 : virtual void attach_output_theta(std::vector<std::unique_ptr<RBTheta>> & theta_q_l); 162 : 163 : /** 164 : * Attach a vector of pointers to functor objects that define one 165 : * of the outputs. 166 : */ 167 : virtual void attach_output_theta(std::vector<RBTheta*> theta_q_l); 168 : 169 : /** 170 : * Attach a pointer to a functor object that defines one 171 : * of the outputs. 172 : */ 173 : virtual void attach_output_theta(RBTheta * theta_q_l); 174 : 175 : private: 176 : 177 : /** 178 : * Vector storing the pointers to the RBTheta functors for A. 179 : */ 180 : std::vector<RBTheta *> _A_theta_vector; 181 : 182 : /** 183 : * Vector storing the RBTheta functors for the affine expansion of the rhs. 184 : */ 185 : std::vector<RBTheta *> _F_theta_vector; 186 : 187 : /** 188 : * Vector storing the RBTheta functors for the affine expansion of the outputs. 189 : */ 190 : std::vector<std::vector<RBTheta *>> _output_theta_vector; 191 : }; 192 : 193 : } 194 : 195 : #endif // LIBMESH_RB_THETA_EXPANSION_H