libMesh
rb_assembly_expansion.C
Go to the documentation of this file.
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 
28  FEMContext & context) const
29 {
30  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 
34 
35  return _A_assembly_vector[q]->interior_assembly( context );
36 }
37 
39  FEMContext & context) const
40 {
41  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 
45 
46  return _A_assembly_vector[q]->boundary_assembly( context );
47 }
48 
50  FEMContext & context) const
51 {
52  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 
56 
57  return _F_assembly_vector[q]->interior_assembly( context );
58 }
59 
61  FEMContext & context) const
62 {
63  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 
67 
68  return _F_assembly_vector[q]->boundary_assembly( context );
69 }
70 
72  unsigned int q_l,
73  FEMContext & context) const
74 {
75  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  libmesh_assert(_output_assembly_vector[output_index][q_l]);
80 
81  return _output_assembly_vector[output_index][q_l]->interior_assembly(context);
82 }
83 
85  unsigned int q_l,
86  FEMContext & context) const
87 {
88  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  libmesh_assert(_output_assembly_vector[output_index][q_l]);
93 
94  return _output_assembly_vector[output_index][q_l]->boundary_assembly(context);
95 }
96 
98 {
99  return cast_int<unsigned int>
100  (_A_assembly_vector.size());
101 }
102 
104 {
105  return cast_int<unsigned int>
106  (_F_assembly_vector.size());
107 }
108 
110 {
111  return cast_int<unsigned int>
112  (_output_assembly_vector.size());
113 }
114 
115 unsigned int RBAssemblyExpansion::get_n_output_terms(unsigned int index) const
116 {
117  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  (_output_assembly_vector[index].size());
121 }
122 
124 {
125  _A_assembly_vector.push_back(Aq_assembly);
126 }
127 
128 void RBAssemblyExpansion::attach_multiple_A_assembly(std::vector<std::unique_ptr<ElemAssembly>> & Aq_assembly)
129 {
130  for (auto & up : Aq_assembly)
131  _A_assembly_vector.push_back(up.get());
132 }
133 
135 {
136  _F_assembly_vector.push_back(Fq_assembly);
137 }
138 
139 void RBAssemblyExpansion::attach_multiple_F_assembly(std::vector<std::unique_ptr<ElemAssembly>> & Fq_assembly)
140 {
141  for (auto & up : Fq_assembly)
142  _F_assembly_vector.push_back(up.get());
143 }
144 
145 void RBAssemblyExpansion::attach_output_assembly(std::vector<std::unique_ptr<ElemAssembly>> & output_assembly)
146 {
147  std::vector<ElemAssembly *> output_assembly_ptr;
148  for (auto & up : output_assembly)
149  output_assembly_ptr.push_back(up.get());
150 
151  _output_assembly_vector.push_back(output_assembly_ptr);
152 }
153 
154 void RBAssemblyExpansion::attach_output_assembly(std::vector<ElemAssembly *> output_assembly)
155 {
156  _output_assembly_vector.push_back(std::move(output_assembly));
157 }
158 
160 {
161  std::vector<ElemAssembly *> L_vector(1); L_vector[0] = output_assembly;
162 
163  attach_output_assembly(L_vector);
164 }
165 
167 {
168  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  return *_A_assembly_vector[q];
172 }
173 
175 {
176  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  return *_F_assembly_vector[q];
180 }
181 
183  unsigned int q_l)
184 {
185  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  return *_output_assembly_vector[output_index][q_l];
190 }
191 
192 }
void perform_output_boundary_assembly(unsigned int output_index, unsigned int q_l, FEMContext &context) const
Perform the specified output assembly.
unsigned int get_n_outputs() const
Get n_outputs, the number output functionals.
ElemAssembly & get_F_assembly(unsigned int q)
Return a reference to the specified F_assembly object.
void perform_F_interior_assembly(unsigned int q, FEMContext &context) const
Perform the specified F interior assembly.
unsigned int get_n_output_terms(unsigned int output_index) const
Get the number of affine terms associated with the specified output.
ElemAssembly & get_output_assembly(unsigned int output_index, unsigned int q_l)
Return a reference to the specified output assembly object.
The libMesh namespace provides an interface to certain functionality in the library.
void attach_multiple_A_assembly(std::vector< std::unique_ptr< ElemAssembly >> &Aq_assembly)
Attach multiple ElemAssembly objects for the left-hand side (both interior and boundary assembly)...
std::vector< ElemAssembly * > _F_assembly_vector
Vector storing the function pointers to the assembly routines for the rhs affine vectors.
void attach_F_assembly(ElemAssembly *Fq_assembly)
Attach ElemAssembly object for the right-hand side (both interior and boundary assembly).
std::vector< std::vector< ElemAssembly * > > _output_assembly_vector
Vector storing the function pointers to the assembly routines for the outputs.
void perform_output_interior_assembly(unsigned int output_index, unsigned int q_l, FEMContext &context) const
Perform the specified output assembly.
void perform_F_boundary_assembly(unsigned int q, FEMContext &context) const
Perform the specified F boundary assembly.
libmesh_assert(ctx)
This class provides all data required for a physics package (e.g.
Definition: fem_context.h:62
void attach_A_assembly(ElemAssembly *Aq_assembly)
Attach ElemAssembly object for the left-hand side (both interior and boundary assembly).
std::vector< ElemAssembly * > _A_assembly_vector
Vectors storing the function pointers to the assembly routines for the affine operators, both interior and boundary assembly.
void perform_A_boundary_assembly(unsigned int q, FEMContext &context) const
Perform the specified A boundary assembly.
ElemAssembly & get_A_assembly(unsigned int q)
Return a reference to the specified A_assembly object.
ElemAssembly provides a per-element (interior and boundary) assembly functionality.
Definition: elem_assembly.h:38
void perform_A_interior_assembly(unsigned int q, FEMContext &context) const
Perform the specified A interior assembly.
unsigned int get_n_A_terms() const
Get Q_a, the number of terms in the affine expansion for the bilinear form.
unsigned int get_n_F_terms() const
Get Q_f, the number of terms in the affine expansion for the right-hand side.
virtual void attach_output_assembly(std::vector< std::unique_ptr< ElemAssembly >> &output_assembly)
Attach ElemAssembly object for an output (both interior and boundary assembly).
void attach_multiple_F_assembly(std::vector< std::unique_ptr< ElemAssembly >> &Fq_assembly)
Attach multiple ElemAssembly objects for the right-hand side (both interior and boundary assembly)...