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  public:
28  std::string interpolatorType = "")
29  {
30  if (interpolatorType == "") interpolatorType = "Lagrange";
31  return createInterpolator(interpolatorType, Teuchos::null);
32  }
33 
36  const Teuchos::RCP<Teuchos::ParameterList>& interpolatorPL)
37  {
38  std::string interpolatorType =
39  interpolatorPL->get<std::string>("Interpolator Type", "Lagrange");
40  return createInterpolator(interpolatorType, interpolatorPL);
41  }
42 
43  private:
46  const std::string& interpolatorType,
47  const Teuchos::RCP<Teuchos::ParameterList>& interpolatorPL)
48  {
49  using Teuchos::rcp;
50 
51  Teuchos::RCP<Interpolator<Scalar> > interpolator;
52  if (interpolatorType == "Lagrange")
53  interpolator = rcp(new InterpolatorLagrange<Scalar>);
54  else {
56  true, std::logic_error,
57  "Unknown 'Interpolator Type' = " << interpolatorType);
58  }
59  interpolator->setParameterList(interpolatorPL);
60 
61  return interpolator;
62  }
63 };
64 
65 } // namespace Tempus
66 #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.