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 
27 // ------------------------------------------------------------
28 // RBAssemblyExpansion implementation
29 
31 {
32 }
33 
35  FEMContext & context)
36 {
37  if (q >= get_n_A_terms())
38  libmesh_error_msg("Error: We must have q < get_n_A_terms in perform_A_interior_assembly.");
39 
41 
42  return _A_assembly_vector[q]->interior_assembly( context );
43 }
44 
46  FEMContext & context)
47 {
48  if (q >= get_n_A_terms())
49  libmesh_error_msg("Error: We must have q < get_n_A_terms in perform_A_boundary_assembly.");
50 
52 
53  return _A_assembly_vector[q]->boundary_assembly( context );
54 }
55 
57  FEMContext & context)
58 {
59  if (q >= get_n_F_terms())
60  libmesh_error_msg("Error: We must have q < get_n_F_terms in perform_F_interior_assembly.");
61 
63 
64  return _F_assembly_vector[q]->interior_assembly( context );
65 }
66 
68  FEMContext & context)
69 {
70  if (q >= get_n_F_terms())
71  libmesh_error_msg("Error: We must have q < get_n_F_terms in perform_F_interior_assembly.");
72 
74 
75  return _F_assembly_vector[q]->boundary_assembly( context );
76 }
77 
79  unsigned int q_l,
80  FEMContext & context)
81 {
82  if ((output_index >= get_n_outputs()) || (q_l >= get_n_output_terms(output_index)))
83  libmesh_error_msg("Error: We must have output_index < n_outputs and " \
84  << "q_l < get_n_output_terms(output_index) in perform_output_interior_assembly.");
85 
86  libmesh_assert(_output_assembly_vector[output_index][q_l]);
87 
88  return _output_assembly_vector[output_index][q_l]->interior_assembly(context);
89 }
90 
92  unsigned int q_l,
93  FEMContext & context)
94 {
95  if ((output_index >= get_n_outputs()) || (q_l >= get_n_output_terms(output_index)))
96  libmesh_error_msg("Error: We must have output_index < n_outputs and " \
97  << "q_l < get_n_output_terms(output_index) in perform_output_boundary_assembly.");
98 
99  libmesh_assert(_output_assembly_vector[output_index][q_l]);
100 
101  return _output_assembly_vector[output_index][q_l]->boundary_assembly(context);
102 }
103 
105 {
106  return cast_int<unsigned int>
107  (_A_assembly_vector.size());
108 }
109 
111 {
112  return cast_int<unsigned int>
113  (_F_assembly_vector.size());
114 }
115 
117 {
118  return cast_int<unsigned int>
119  (_output_assembly_vector.size());
120 }
121 
122 unsigned int RBAssemblyExpansion::get_n_output_terms(unsigned int index) const
123 {
124  if (index >= get_n_outputs())
125  libmesh_error_msg("Error: We must have index < n_outputs in get_Q_l.");
126 
127  return cast_int<unsigned int>
128  (_output_assembly_vector[index].size());
129 }
130 
132 {
133  _A_assembly_vector.push_back(Aq_assembly);
134 }
135 
136 void RBAssemblyExpansion::attach_multiple_A_assembly(std::vector<ElemAssembly *> Aq_assembly)
137 {
138  for (std::size_t i=0; i<Aq_assembly.size(); i++)
139  _A_assembly_vector.push_back(Aq_assembly[i]);
140 }
141 
143 {
144  _F_assembly_vector.push_back(Fq_assembly);
145 }
146 
147 void RBAssemblyExpansion::attach_multiple_F_assembly(std::vector<ElemAssembly *> Fq_assembly)
148 {
149  for (std::size_t i=0; i<Fq_assembly.size(); i++)
150  _F_assembly_vector.push_back(Fq_assembly[i]);
151 }
152 
153 void RBAssemblyExpansion::attach_output_assembly(std::vector<ElemAssembly *> output_assembly)
154 {
155  _output_assembly_vector.push_back(output_assembly);
156 }
157 
159 {
160  std::vector<ElemAssembly *> L_vector(1); L_vector[0] = output_assembly;
161 
162  attach_output_assembly(L_vector);
163 }
164 
166 {
167  if (q >= get_n_A_terms())
168  libmesh_error_msg("Error: We must have q < get_n_A_terms in get_A_assembly.");
169 
170  return *_A_assembly_vector[q];
171 }
172 
174 {
175  if (q >= get_n_F_terms())
176  libmesh_error_msg("Error: We must have q < get_n_F_terms in get_F_assembly.");
177 
178  return *_F_assembly_vector[q];
179 }
180 
182  unsigned int q_l)
183 {
184  if ((output_index >= get_n_outputs()) || (q_l >= get_n_output_terms(output_index)))
185  libmesh_error_msg("Error: We must have output_index < n_outputs and " \
186  << "q_l < get_n_output_terms(output_index) in get_output_assembly.");
187 
188  return *_output_assembly_vector[output_index][q_l];
189 }
190 
191 }
ElemAssembly & get_F_assembly(unsigned int q)
Return a reference to the specified F_assembly object.
void attach_multiple_F_assembly(std::vector< ElemAssembly * > Fq_assembly)
Attach multiple ElemAssembly objects for the right-hand side (both interior and boundary assembly)...
void attach_multiple_A_assembly(std::vector< ElemAssembly * > Aq_assembly)
Attach multiple ElemAssembly objects for the left-hand side (both interior and boundary assembly)...
unsigned int get_n_F_terms() const
Get Q_f, the number of terms in the affine expansion for the right-hand side.
void perform_F_boundary_assembly(unsigned int q, FEMContext &context)
Perform the specified F boundary assembly.
ElemAssembly & get_output_assembly(unsigned int output_index, unsigned int q_l)
Return a reference to the specified output assembly object.
unsigned int get_n_output_terms(unsigned int output_index) const
Get the number of affine terms associated with the specified output.
The libMesh namespace provides an interface to certain functionality in the library.
void perform_A_interior_assembly(unsigned int q, FEMContext &context)
Perform the specified A interior 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).
libmesh_assert(j)
std::vector< std::vector< ElemAssembly * > > _output_assembly_vector
Vector storing the function pointers to the assembly routines for the outputs.
void perform_A_boundary_assembly(unsigned int q, FEMContext &context)
Perform the specified A boundary assembly.
unsigned int get_n_outputs() const
Get n_outputs, the number output functionals.
This class provides all data required for a physics package (e.g.
Definition: fem_context.h:61
void perform_output_boundary_assembly(unsigned int output_index, unsigned int q_l, FEMContext &context)
Perform the specified output assembly.
void perform_F_interior_assembly(unsigned int q, FEMContext &context)
Perform the specified F interior assembly.
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.
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
virtual void attach_output_assembly(std::vector< ElemAssembly * > output_assembly)
Attach ElemAssembly object for an output (both interior and boundary assembly).
void perform_output_interior_assembly(unsigned int output_index, unsigned int q_l, FEMContext &context)
Perform the specified output assembly.
unsigned int get_n_A_terms() const
Get Q_a, the number of terms in the affine expansion for the bilinear form.