libMesh
rb_theta_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_theta_expansion.h"
22 #include "libmesh/rb_theta.h"
23 #include "libmesh/rb_parameters.h"
24 
25 namespace libMesh
26 {
27 
28 // ------------------------------------------------------------
29 // RBThetaExpansion implementation
30 
32 {
33 }
34 
35 unsigned int RBThetaExpansion::get_n_A_terms() const
36 {
37  return cast_int<unsigned int>
38  (_A_theta_vector.size());
39 }
40 
41 unsigned int RBThetaExpansion::get_n_F_terms() const
42 {
43  return cast_int<unsigned int>
44  (_F_theta_vector.size());
45 }
46 
47 unsigned int RBThetaExpansion::get_n_outputs() const
48 {
49  return cast_int<unsigned int>
50  (_output_theta_vector.size());
51 }
52 
53 unsigned int RBThetaExpansion::get_n_output_terms(unsigned int index) const
54 {
55  if (index >= get_n_outputs())
56  libmesh_error_msg("Error: We must have index < n_outputs in get_Q_l.");
57 
58  return cast_int<unsigned int>
59  (_output_theta_vector[index].size());
60 }
61 
63 {
64  libmesh_assert(theta_q_a);
65 
66  _A_theta_vector.push_back(theta_q_a);
67 }
68 
69 void RBThetaExpansion::attach_multiple_A_theta(std::vector<RBTheta *> theta_q_a)
70 {
71  for (std::size_t i=0; i<theta_q_a.size(); i++)
72  {
73  libmesh_assert(theta_q_a[i]);
74  _A_theta_vector.push_back(theta_q_a[i]);
75  }
76 }
77 
79 {
80  libmesh_assert(theta_q_f);
81 
82  _F_theta_vector.push_back(theta_q_f);
83 }
84 
85 void RBThetaExpansion::attach_multiple_F_theta(std::vector<RBTheta *> theta_q_f)
86 {
87  for (std::size_t i=0; i<theta_q_f.size(); i++)
88  {
89  libmesh_assert(theta_q_f[i]);
90  _F_theta_vector.push_back(theta_q_f[i]);
91  }
92 }
93 
94 void RBThetaExpansion::attach_output_theta(std::vector<RBTheta *> theta_q_l)
95 {
96  _output_theta_vector.push_back(theta_q_l);
97 }
98 
100 {
101  libmesh_assert(theta_q_l);
102 
103  std::vector<RBTheta *> theta_l_vector(1);
104  theta_l_vector[0] = theta_q_l;
105 
106  attach_output_theta(theta_l_vector);
107 }
108 
110  const RBParameters & mu)
111 {
112  if (q >= get_n_A_terms())
113  libmesh_error_msg("Error: We must have q < get_n_A_terms in eval_A_theta.");
114 
116 
117  return _A_theta_vector[q]->evaluate( mu );
118 }
119 
121  const RBParameters & mu)
122 {
123  if (q >= get_n_F_terms())
124  libmesh_error_msg("Error: We must have q < get_n_F_terms in eval_F_theta.");
125 
127 
128  return _F_theta_vector[q]->evaluate( mu );
129 }
130 
131 Number RBThetaExpansion::eval_output_theta(unsigned int output_index,
132  unsigned int q_l,
133  const RBParameters & mu)
134 {
135  if ((output_index >= get_n_outputs()) || (q_l >= get_n_output_terms(output_index)))
136  libmesh_error_msg("Error: We must have output_index < n_outputs and " \
137  << "q_l < get_n_output_terms(output_index) in eval_output_theta.");
138 
139  libmesh_assert(_output_theta_vector[output_index][q_l]);
140 
141  return _output_theta_vector[output_index][q_l]->evaluate( mu );
142 }
143 
144 
145 }
virtual void attach_output_theta(std::vector< RBTheta * > theta_q_l)
Attach a vector of pointers to functor objects that define one of the outputs.
std::vector< RBTheta * > _A_theta_vector
Vector storing the pointers to the RBTheta functors for A.
virtual Number eval_A_theta(unsigned int q, const RBParameters &mu)
Evaluate theta_q_a at the current parameter.
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_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.
virtual void attach_F_theta(RBTheta *theta_q_f)
Attach a pointer to a functor object that defines one of the theta_q_a terms.
libmesh_assert(j)
virtual Number eval_output_theta(unsigned int output_index, unsigned int q_l, const RBParameters &mu)
Evaluate theta_q_l at the current parameter.
std::vector< RBTheta * > _F_theta_vector
Vector storing the RBTheta functors for the affine expansion of the rhs.
unsigned int get_n_F_terms() const
Get Q_f, the number of terms in the affine expansion for the right-hand side.
std::vector< std::vector< RBTheta * > > _output_theta_vector
Vector storing the RBTheta functors for the affine expansion of the outputs.
This class is part of the rbOOmit framework.
Definition: rb_parameters.h:42
unsigned int get_n_outputs() const
Get n_outputs, the number output functionals.
virtual Number eval_F_theta(unsigned int q, const RBParameters &mu)
Evaluate theta_q_f at the current parameter.
This class is part of the rbOOmit framework.
Definition: rb_theta.h:46
virtual void attach_multiple_A_theta(std::vector< RBTheta * > theta_q_a)
Attach a vector of pointers to functor objects that each define one of the theta_q_a terms...
virtual void attach_A_theta(RBTheta *theta_q_a)
Attach a pointer to a functor object that defines one of the theta_q_a terms.
virtual void attach_multiple_F_theta(std::vector< RBTheta * > theta_q_f)
Attach a vector of pointers to functor objects that each define one of the theta_q_f terms...