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: 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
13#include "Teuchos_ParameterList.hpp"
14#include "Tempus_config.hpp"
15#include "Tempus_InterpolatorLagrange.hpp"
16
17namespace Tempus {
18
24template <class Scalar>
26 public:
28 static Teuchos::RCP<Interpolator<Scalar> > createInterpolator(
29 std::string interpolatorType = "")
30 {
31 if (interpolatorType == "") interpolatorType = "Lagrange";
32 return createInterpolator(interpolatorType, Teuchos::null);
33 }
34
36 static Teuchos::RCP<Interpolator<Scalar> > createInterpolator(
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:
46 static Teuchos::RCP<Interpolator<Scalar> > createInterpolator(
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 {
56 TEUCHOS_TEST_FOR_EXCEPTION(
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
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.