Tempus Version of the Day
Time Integration
Loading...
Searching...
No Matches
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_config.hpp"
14#include "Tempus_InterpolatorLagrange.hpp"
15
16namespace Tempus {
17
23template<class Scalar>
25{
26public:
27
29 static Teuchos::RCP<Interpolator<Scalar> >
30 createInterpolator(std::string interpolatorType = "")
31 {
32 if (interpolatorType == "")
33 interpolatorType = "Lagrange";
34 return createInterpolator(interpolatorType, Teuchos::null);
35 }
36
38 static Teuchos::RCP<Interpolator<Scalar> >
39 createInterpolator(const Teuchos::RCP<Teuchos::ParameterList>& interpolatorPL)
40 {
41 std::string interpolatorType =
42 interpolatorPL->get<std::string>("Interpolator Type", "Lagrange");
43 return createInterpolator(interpolatorType, interpolatorPL);
44 }
45
46private:
47
49 static Teuchos::RCP<Interpolator<Scalar> >
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
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., "Linear").
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.