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 : // rbOOmit includes 21 : #include "libmesh/rb_assembly_expansion.h" 22 : #include "libmesh/elem_assembly.h" 23 : 24 : namespace libMesh 25 : { 26 : 27 0 : void RBAssemblyExpansion::perform_A_interior_assembly(unsigned int q, 28 : FEMContext & context) const 29 : { 30 0 : libmesh_error_msg_if(q >= get_n_A_terms(), 31 : "Error: We must have q < get_n_A_terms in perform_A_interior_assembly."); 32 : 33 0 : libmesh_assert(_A_assembly_vector[q]); 34 : 35 0 : return _A_assembly_vector[q]->interior_assembly( context ); 36 : } 37 : 38 0 : void RBAssemblyExpansion::perform_A_boundary_assembly(unsigned int q, 39 : FEMContext & context) const 40 : { 41 0 : libmesh_error_msg_if(q >= get_n_A_terms(), 42 : "Error: We must have q < get_n_A_terms in perform_A_boundary_assembly."); 43 : 44 0 : libmesh_assert(_A_assembly_vector[q]); 45 : 46 0 : return _A_assembly_vector[q]->boundary_assembly( context ); 47 : } 48 : 49 0 : void RBAssemblyExpansion::perform_F_interior_assembly(unsigned int q, 50 : FEMContext & context) const 51 : { 52 0 : libmesh_error_msg_if(q >= get_n_F_terms(), 53 : "Error: We must have q < get_n_F_terms in perform_F_interior_assembly."); 54 : 55 0 : libmesh_assert(_A_assembly_vector[q]); 56 : 57 0 : return _F_assembly_vector[q]->interior_assembly( context ); 58 : } 59 : 60 0 : void RBAssemblyExpansion::perform_F_boundary_assembly(unsigned int q, 61 : FEMContext & context) const 62 : { 63 0 : libmesh_error_msg_if(q >= get_n_F_terms(), 64 : "Error: We must have q < get_n_F_terms in perform_F_interior_assembly."); 65 : 66 0 : libmesh_assert(_A_assembly_vector[q]); 67 : 68 0 : return _F_assembly_vector[q]->boundary_assembly( context ); 69 : } 70 : 71 0 : void RBAssemblyExpansion::perform_output_interior_assembly(unsigned int output_index, 72 : unsigned int q_l, 73 : FEMContext & context) const 74 : { 75 0 : libmesh_error_msg_if((output_index >= get_n_outputs()) || (q_l >= get_n_output_terms(output_index)), 76 : "Error: We must have output_index < n_outputs and " 77 : "q_l < get_n_output_terms(output_index) in perform_output_interior_assembly."); 78 : 79 0 : libmesh_assert(_output_assembly_vector[output_index][q_l]); 80 : 81 0 : return _output_assembly_vector[output_index][q_l]->interior_assembly(context); 82 : } 83 : 84 0 : void RBAssemblyExpansion::perform_output_boundary_assembly(unsigned int output_index, 85 : unsigned int q_l, 86 : FEMContext & context) const 87 : { 88 0 : libmesh_error_msg_if((output_index >= get_n_outputs()) || (q_l >= get_n_output_terms(output_index)), 89 : "Error: We must have output_index < n_outputs and " 90 : "q_l < get_n_output_terms(output_index) in perform_output_boundary_assembly."); 91 : 92 0 : libmesh_assert(_output_assembly_vector[output_index][q_l]); 93 : 94 0 : return _output_assembly_vector[output_index][q_l]->boundary_assembly(context); 95 : } 96 : 97 905 : unsigned int RBAssemblyExpansion::get_n_A_terms() const 98 : { 99 : return cast_int<unsigned int> 100 929 : (_A_assembly_vector.size()); 101 : } 102 : 103 1002 : unsigned int RBAssemblyExpansion::get_n_F_terms() const 104 : { 105 : return cast_int<unsigned int> 106 1030 : (_F_assembly_vector.size()); 107 : } 108 : 109 1160 : unsigned int RBAssemblyExpansion::get_n_outputs() const 110 : { 111 : return cast_int<unsigned int> 112 1192 : (_output_assembly_vector.size()); 113 : } 114 : 115 584 : unsigned int RBAssemblyExpansion::get_n_output_terms(unsigned int index) const 116 : { 117 584 : libmesh_error_msg_if(index >= get_n_outputs(), "Error: We must have index < n_outputs in get_Q_l."); 118 : 119 : return cast_int<unsigned int> 120 616 : (_output_assembly_vector[index].size()); 121 : } 122 : 123 1704 : void RBAssemblyExpansion::attach_A_assembly(ElemAssembly * Aq_assembly) 124 : { 125 1704 : _A_assembly_vector.push_back(Aq_assembly); 126 1704 : } 127 : 128 0 : void RBAssemblyExpansion::attach_multiple_A_assembly(std::vector<std::unique_ptr<ElemAssembly>> & Aq_assembly) 129 : { 130 0 : for (auto & up : Aq_assembly) 131 0 : _A_assembly_vector.push_back(up.get()); 132 0 : } 133 : 134 1988 : void RBAssemblyExpansion::attach_F_assembly(ElemAssembly * Fq_assembly) 135 : { 136 1988 : _F_assembly_vector.push_back(Fq_assembly); 137 1988 : } 138 : 139 0 : void RBAssemblyExpansion::attach_multiple_F_assembly(std::vector<std::unique_ptr<ElemAssembly>> & Fq_assembly) 140 : { 141 0 : for (auto & up : Fq_assembly) 142 0 : _F_assembly_vector.push_back(up.get()); 143 0 : } 144 : 145 0 : void RBAssemblyExpansion::attach_output_assembly(std::vector<std::unique_ptr<ElemAssembly>> & output_assembly) 146 : { 147 0 : std::vector<ElemAssembly *> output_assembly_ptr; 148 0 : for (auto & up : output_assembly) 149 0 : output_assembly_ptr.push_back(up.get()); 150 : 151 0 : _output_assembly_vector.push_back(output_assembly_ptr); 152 0 : } 153 : 154 1136 : void RBAssemblyExpansion::attach_output_assembly(std::vector<ElemAssembly *> output_assembly) 155 : { 156 1136 : _output_assembly_vector.push_back(std::move(output_assembly)); 157 1136 : } 158 : 159 1136 : void RBAssemblyExpansion::attach_output_assembly(ElemAssembly * output_assembly) 160 : { 161 1168 : std::vector<ElemAssembly *> L_vector(1); L_vector[0] = output_assembly; 162 : 163 2240 : attach_output_assembly(L_vector); 164 1136 : } 165 : 166 897 : ElemAssembly & RBAssemblyExpansion::get_A_assembly(unsigned int q) 167 : { 168 897 : libmesh_error_msg_if(q >= get_n_A_terms(), 169 : "Error: We must have q < get_n_A_terms in get_A_assembly."); 170 : 171 921 : return *_A_assembly_vector[q]; 172 : } 173 : 174 994 : ElemAssembly & RBAssemblyExpansion::get_F_assembly(unsigned int q) 175 : { 176 994 : libmesh_error_msg_if(q >= get_n_F_terms(), 177 : "Error: We must have q < get_n_F_terms in get_F_assembly."); 178 : 179 1022 : return *_F_assembly_vector[q]; 180 : } 181 : 182 568 : ElemAssembly & RBAssemblyExpansion::get_output_assembly(unsigned int output_index, 183 : unsigned int q_l) 184 : { 185 568 : libmesh_error_msg_if((output_index >= get_n_outputs()) || (q_l >= get_n_output_terms(output_index)), 186 : "Error: We must have output_index < n_outputs and " 187 : "q_l < get_n_output_terms(output_index) in get_output_assembly."); 188 : 189 600 : return *_output_assembly_vector[output_index][q_l]; 190 : } 191 : 192 : }