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: Time Integration and Sensitivity Analysis Package
4 //
5 // Copyright 2017 NTESS and the Tempus contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 //@HEADER
9 
10 #ifndef Tempus_InterpolatorFactory_hpp
11 #define Tempus_InterpolatorFactory_hpp
12 
14 #include "Tempus_config.hpp"
15 #include "Tempus_InterpolatorLagrange.hpp"
16 
17 namespace Tempus {
18 
24 template <class Scalar>
26  public:
29  std::string interpolatorType = "")
30  {
31  if (interpolatorType == "") interpolatorType = "Lagrange";
32  return createInterpolator(interpolatorType, Teuchos::null);
33  }
34 
37  const Teuchos::RCP<Teuchos::ParameterList>& interpolatorPL)
38  {
39  std::string interpolatorType =
40  interpolatorPL->get<std::string>("Interpolator Type", "Lagrange");
41  return createInterpolator(interpolatorType, interpolatorPL);
42  }
43 
44  private:
47  const std::string& interpolatorType,
48  const Teuchos::RCP<Teuchos::ParameterList>& interpolatorPL)
49  {
50  using Teuchos::rcp;
51 
52  Teuchos::RCP<Interpolator<Scalar> > interpolator;
53  if (interpolatorType == "Lagrange")
54  interpolator = rcp(new InterpolatorLagrange<Scalar>);
55  else {
57  true, std::logic_error,
58  "Unknown 'Interpolator Type' = " << interpolatorType);
59  }
60  interpolator->setParameterList(interpolatorPL);
61 
62  return interpolator;
63  }
64 };
65 
66 } // namespace Tempus
67 #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.