Tempus  Version of the Day
Time Integration
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Tempus_IntegratorBasic_decl.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_IntegratorBasic_decl_hpp
11 #define Tempus_IntegratorBasic_decl_hpp
12 
13 #include "Teuchos_Time.hpp"
14 
15 #include "Thyra_ModelEvaluator.hpp"
16 
17 #include "Tempus_config.hpp"
18 #include "Tempus_Stepper.hpp"
19 #include "Tempus_Integrator.hpp"
20 #include "Tempus_TimeStepControl.hpp"
21 #include "Tempus_IntegratorObserverBasic.hpp"
22 
23 namespace Tempus {
24 
27 template <class Scalar>
28 class IntegratorBasic : virtual public Tempus::Integrator<Scalar> {
29  public:
33 
36  Teuchos::RCP<SolutionHistory<Scalar> > solutionHistory,
37  Teuchos::RCP<TimeStepControl<Scalar> > timeStepControl,
38  Teuchos::RCP<IntegratorObserver<Scalar> > integratorObserver,
39  std::vector<int> outputScreenIndices,
40  int outputScreenInterval);
41 
43  virtual void copy(Teuchos::RCP<IntegratorBasic<Scalar> > iB);
44 
46  virtual ~IntegratorBasic() {}
47 
49 
50  virtual bool advanceTime();
53  virtual bool advanceTime(const Scalar timeFinal) override;
55  virtual void startIntegrator();
57  virtual void startTimeStep();
59  virtual void checkTimeStep();
61  virtual void endIntegrator();
63 
65 
66  virtual Scalar getTime() const override
68  {
69  return solutionHistory_->getCurrentTime();
70  }
72  virtual int getIndex() const override
73  {
74  return solutionHistory_->getCurrentIndex();
75  }
77  virtual Status getStatus() const override { return integratorStatus_; }
79  virtual void setStatus(const Status st) override { integratorStatus_ = st; }
81  virtual Teuchos::RCP<Stepper<Scalar> > getStepper() const override
82  {
83  return stepper_;
84  }
86  virtual void setModel(
89  virtual void setStepper(Teuchos::RCP<Stepper<Scalar> > stepper);
91  virtual void initializeSolutionHistory(
92  Teuchos::RCP<SolutionState<Scalar> > state = Teuchos::null);
94  virtual void initializeSolutionHistory(
95  Scalar t0, Teuchos::RCP<const Thyra::VectorBase<Scalar> > x0,
96  Teuchos::RCP<const Thyra::VectorBase<Scalar> > xdot0 = Teuchos::null,
97  Teuchos::RCP<const Thyra::VectorBase<Scalar> > xdotdot0 = Teuchos::null);
100  const override
101  {
102  return solutionHistory_;
103  }
106  override
107  {
108  return solutionHistory_;
109  }
111  virtual void setSolutionHistory(
112  Teuchos::RCP<SolutionHistory<Scalar> > sh = Teuchos::null);
115  const override
116  {
117  return timeStepControl_;
118  }
120  override
121  {
122  return timeStepControl_;
123  }
125  virtual void setTimeStepControl(
126  Teuchos::RCP<TimeStepControl<Scalar> > tsc = Teuchos::null);
129  {
130  return integratorObserver_;
131  }
133  virtual void setObserver(
134  Teuchos::RCP<IntegratorObserver<Scalar> > obs = Teuchos::null);
136  virtual void initialize();
138  bool isInitialized() { return isInitialized_; }
139 
140  // TODO: finish this
143  {
144  return integratorTimer_;
145  }
147  {
148  return stepperTimer_;
149  }
150 
153  {
154  return solutionHistory_->getCurrentState()->getX();
155  }
158  {
159  return solutionHistory_->getCurrentState()->getXDot();
160  }
163  {
164  return solutionHistory_->getCurrentState()->getXDotDot();
165  }
166 
169  {
170  return solutionHistory_->getCurrentState();
171  }
172 
173  virtual void setScreenOutputIndexInterval(int i)
174  {
176  }
177 
178  virtual int getScreenOutputIndexInterval() const
179  {
180  return outputScreenInterval_;
181  }
182 
183  virtual void setScreenOutputIndexList(std::vector<int> indices)
184  {
185  outputScreenIndices_ = indices;
186  }
187 
189  virtual void setScreenOutputIndexList(std::string str);
190 
191  virtual std::vector<int> getScreenOutputIndexList() const
192  {
193  return outputScreenIndices_;
194  }
195 
196  virtual std::string getScreenOutputIndexListString() const;
198 
200  {
201  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
202  " IntegratorBasic::parseScreenOutput() -- "
203  "Should call setScreenOutputIndexList()\n");
204  }
205 
207 
209 
210  std::string description() const override;
212  const Teuchos::EVerbosityLevel verbLevel) const override;
214 
216  void setIntegratorName(std::string i) { integratorName_ = i; }
218  std::string getIntegratorName() const { return integratorName_; }
219 
221  std::string getIntegratorType() const { return integratorType_; }
222 
223  protected:
225  void setIntegratorType(std::string i);
226  std::string integratorName_;
227  std::string integratorType_;
228 
233 
234  std::vector<int> outputScreenIndices_;
236 
243 
246 };
247 
249 template <class Scalar>
251  Teuchos::RCP<Teuchos::ParameterList> pList, bool runInitialize = true);
252 
254 template <class Scalar>
258  bool runInitialize = true);
259 
261 template <class Scalar>
264  std::string stepperType);
265 
267 template <class Scalar>
269 
271 template <class Scalar>
274  std::vector<Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> > > models,
275  bool runInitialize = true);
276 
277 } // namespace Tempus
278 
279 #endif // Tempus_IntegratorBasic_decl_hpp
virtual bool advanceTime()
Advance the solution to timeMax, and return true if successful.
Teuchos::RCP< Stepper< Scalar > > stepper_
virtual Teuchos::RCP< Stepper< Scalar > > getStepper() const override
Get the Stepper.
int outputScreenInterval_
screen output interval.
virtual Scalar getTime() const override
Get current time.
virtual void setModel(Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > model)
Set the model on the stepper.
virtual void setStatus(const Status st) override
Set Status.
Teuchos::RCP< Teuchos::Time > integratorTimer_
std::string description() const override
virtual void setTimeStepControl(Teuchos::RCP< TimeStepControl< Scalar > > tsc=Teuchos::null)
Set the TimeStepControl.
virtual void setObserver(Teuchos::RCP< IntegratorObserver< Scalar > > obs=Teuchos::null)
Set the Observer.
virtual Teuchos::RCP< SolutionState< Scalar > > getCurrentState()
Get current state.
virtual Status getStatus() const override
Get Status.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Teuchos::RCP< Teuchos::Time > stepperTimer_
virtual Teuchos::RCP< Thyra::VectorBase< Scalar > > getXDotDot() const
Get current the second time derivative of the solution, xdotdot.
virtual std::string getScreenOutputIndexListString() const
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
Create valid IntegratorBasic ParameterList.
virtual void setStepper(Teuchos::RCP< Stepper< Scalar > > stepper)
Set the Stepper.
Thyra Base interface for time steppers.
virtual void checkTimeStep()
Check if time step has passed or failed.
virtual Teuchos::RCP< const SolutionHistory< Scalar > > getSolutionHistory() const override
Get the SolutionHistory.
virtual void setSolutionHistory(Teuchos::RCP< SolutionHistory< Scalar > > sh=Teuchos::null)
Set the SolutionHistory.
std::string integratorName_
integrator name used for I/O.
Status
Status for the Integrator, the Stepper and the SolutionState.
std::string getIntegratorType() const
Get the Integrator Type.
IntegratorObserver class for time integrators.
Teuchos::RCP< TimeStepControl< Scalar > > timeStepControl_
Teuchos::RCP< SolutionHistory< Scalar > > solutionHistory_
std::string getIntegratorName() const
Get the Integrator Name.
TimeStepControl manages the time step size. There several mechanisms that effect the time step size a...
virtual int getIndex() const override
Get current index.
virtual void initializeSolutionHistory(Teuchos::RCP< SolutionState< Scalar > > state=Teuchos::null)
Set the initial state which has the initial conditions.
virtual std::vector< int > getScreenOutputIndexList() const
virtual void setScreenOutputIndexList(std::vector< int > indices)
SolutionHistory is basically a container of SolutionStates. SolutionHistory maintains a collection of...
bool isInitialized()
Return true if IntegratorBasic is initialized.
virtual int getScreenOutputIndexInterval() const
void setIntegratorName(std::string i)
Set the Integrator Name.
virtual Teuchos::RCP< const TimeStepControl< Scalar > > getTimeStepControl() const override
Get the TimeStepControl.
virtual void initialize()
Initializes the Integrator after set* function calls.
virtual void endIntegrator()
Perform tasks after end of integrator.
virtual ~IntegratorBasic()
Destructor.
virtual void startIntegrator()
Perform tasks before start of integrator.
void setIntegratorType(std::string i)
Set the Integrator Type.
Thyra Base interface for time integrators. Time integrators are designed to advance the solution from...
virtual Teuchos::RCP< Teuchos::Time > getStepperTimer() const override
virtual void copy(Teuchos::RCP< IntegratorBasic< Scalar > > iB)
Copy (a shallow copy)
virtual Teuchos::RCP< SolutionHistory< Scalar > > getNonConstSolutionHistory() override
Get the SolutionHistory.
virtual Teuchos::RCP< TimeStepControl< Scalar > > getNonConstTimeStepControl() override
virtual void startTimeStep()
Start time step.
virtual Teuchos::RCP< Thyra::VectorBase< Scalar > > getXDot() const
Get current the time derivative of the solution, xdot.
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const override
virtual Teuchos::RCP< IntegratorObserver< Scalar > > getObserver()
Get the Observer.
Teuchos::RCP< IntegratorBasic< Scalar > > createIntegratorBasic(Teuchos::RCP< Teuchos::ParameterList > pList, bool runInitialize=true)
Nonmember constructor.
Teuchos::RCP< IntegratorObserver< Scalar > > integratorObserver_
virtual Teuchos::RCP< Thyra::VectorBase< Scalar > > getX() const
Get current the solution, x.
std::vector< int > outputScreenIndices_
Vector of screen output indices.
std::string integratorType_
the integrator type.
Solution state for integrators and steppers.
virtual Teuchos::RCP< Teuchos::Time > getIntegratorTimer() const override
Returns the IntegratorTimer_ for this Integrator.
virtual void setScreenOutputIndexInterval(int i)