Tempus  Version of the Day
Time Integration
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Tempus_InterpolatorFactory.hpp
Go to the documentation of this file.
1 // @HEADER
2 // ****************************************************************************
3 // Tempus: Copyright (2017) Sandia Corporation
4 //
5 // Distributed under BSD 3-clause license (See accompanying file Copyright.txt)
6 // ****************************************************************************
7 // @HEADER
8 
9 #ifndef Tempus_InterpolatorFactory_hpp
10 #define Tempus_InterpolatorFactory_hpp
11 
12 #include "Teuchos_ParameterList.hpp"
13 #include "Tempus_InterpolatorLagrange.hpp"
14 
15 namespace Tempus {
16 
17 /** \brief Interpolator factory.
18  *
19  * <b>Adding Interpoloators</b>
20  * -#
21  */
22 template<class Scalar>
24 {
25 public:
26 
27  /// Create default interpolator from interpolator type (e.g., "Linear").
28  static Teuchos::RCP<Interpolator<Scalar> >
29  createInterpolator(std::string interpolatorType = "")
30  {
31  if (interpolatorType == "")
32  interpolatorType = "Lagrange";
33  return createInterpolator(interpolatorType, Teuchos::null);
34  }
35 
36  /// Create interpolator from ParameterList with its details.
37  static Teuchos::RCP<Interpolator<Scalar> >
38  createInterpolator(const Teuchos::RCP<Teuchos::ParameterList>& interpolatorPL)
39  {
40  std::string interpolatorType =
41  interpolatorPL->get<std::string>("Interpolator Type", "Lagrange");
42  return createInterpolator(interpolatorType, interpolatorPL);
43  }
44 
45 private:
46 
47  /// Very simple factory method
48  static Teuchos::RCP<Interpolator<Scalar> >
49  createInterpolator(const std::string& interpolatorType,
50  const Teuchos::RCP<Teuchos::ParameterList>& interpolatorPL)
51  {
52  using Teuchos::rcp;
53 
54  Teuchos::RCP<Interpolator<Scalar> > interpolator;
55  if (interpolatorType == "Lagrange")
56  interpolator = rcp(new InterpolatorLagrange<Scalar>);
57  else {
58  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
59  "Unknown 'Interpolator Type' = " << interpolatorType);
60  }
61  interpolator->setParameterList(interpolatorPL);
62 
63  return interpolator;
64  }
65 
66 };
67 
68 } // namespace Tempus
69 #endif // Tempus_InterpolatorFactory_hpp
static Teuchos::RCP< Interpolator< Scalar > > createInterpolator(const Teuchos::RCP< Teuchos::ParameterList > &interpolatorPL)
Create interpolator from ParameterList with its details.
static Teuchos::RCP< Interpolator< Scalar > > createInterpolator(std::string interpolatorType="")
Create default interpolator from interpolator type (e.g., &quot;Linear&quot;).
static Teuchos::RCP< Interpolator< Scalar > > createInterpolator(const std::string &interpolatorType, const Teuchos::RCP< Teuchos::ParameterList > &interpolatorPL)
Very simple factory method.
Concrete implemenation of Interpolator that does simple lagrange interpolation.