Tempus  Version of the Day
Time Integration
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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 
13 #include "Tempus_config.hpp"
14 #include "Tempus_InterpolatorLagrange.hpp"
15 
16 namespace Tempus {
17 
23 template<class Scalar>
25 {
26 public:
27 
30  createInterpolator(std::string interpolatorType = "")
31  {
32  if (interpolatorType == "")
33  interpolatorType = "Lagrange";
34  return createInterpolator(interpolatorType, Teuchos::null);
35  }
36 
40  {
41  std::string interpolatorType =
42  interpolatorPL->get<std::string>("Interpolator Type", "Lagrange");
43  return createInterpolator(interpolatorType, interpolatorPL);
44  }
45 
46 private:
47 
50  createInterpolator(const std::string& interpolatorType,
51  const Teuchos::RCP<Teuchos::ParameterList>& interpolatorPL)
52  {
53  using Teuchos::rcp;
54 
55  Teuchos::RCP<Interpolator<Scalar> > interpolator;
56  if (interpolatorType == "Lagrange")
57  interpolator = rcp(new InterpolatorLagrange<Scalar>);
58  else {
59  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
60  "Unknown 'Interpolator Type' = " << interpolatorType);
61  }
62  interpolator->setParameterList(interpolatorPL);
63 
64  return interpolator;
65  }
66 
67 };
68 
69 } // namespace Tempus
70 #endif // Tempus_InterpolatorFactory_hpp
T & get(const std::string &name, T def_value)
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
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;).
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
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.