libMesh
rb_theta.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 // Local includes
21 #include "libmesh/rb_theta.h"
22 #include "libmesh/rb_parameters.h"
23 #include "libmesh/int_range.h"
24 
25 namespace libMesh
26 {
27 
29 {
30  // The RBTheta::evaluate() API is not general enough to handle the
31  // multi-sample RBParameters case, and you must therefore call
32  // RBTheta::evaluate_vec() instead.
33  libmesh_error_msg_if(mu.n_samples() > 1,
34  "You should only call the evaluate_vec() API when using multi-sample RBParameters objects.");
35 
36  return 1.;
37 }
38 
39 std::vector<Number>
40 RBTheta::evaluate_vec(const std::vector<RBParameters> & mus)
41 {
42  // Eventual return value
43  std::vector<Number> result;
44 
45  for (const auto & mu : mus)
46  {
47  // Backwards-compatible behavior: for single-sample RBParameters objects, we fall back on
48  // calling the scalar evaluate() function for this RBTheta object, which may have been
49  // overridden by the user.
50  if (mu.n_samples() == 1)
51  result.push_back( this->evaluate(mu) );
52  else
53  {
54  // For multi-sample RBParameters objects, all we can do is return
55  // mu.n_samples() copies of 1 here at the base class level.
56  result.insert(result.end(), /*count=*/mu.n_samples(), /*val=*/1.);
57  }
58  }
59 
60  return result;
61 }
62 
63 }
virtual std::vector< Number > evaluate_vec(const std::vector< RBParameters > &mus)
Definition: rb_theta.C:40
The libMesh namespace provides an interface to certain functionality in the library.
This class is part of the rbOOmit framework.
Definition: rb_parameters.h:52
unsigned int n_samples() const
Returns the number of samples stored for all parameters.
virtual Number evaluate(const RBParameters &)
Evaluate the functor object for the given parameter.
Definition: rb_theta.C:28