Tempus  Version of the Day
Time Integration
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Tempus_StepperIMEX_RK_Partition_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_StepperIMEX_RK_Partition_decl_hpp
11 #define Tempus_StepperIMEX_RK_Partition_decl_hpp
12 
13 #include "Tempus_config.hpp"
14 #include "Tempus_StepperRKBase.hpp"
15 #include "Tempus_StepperImplicit.hpp"
16 #include "Tempus_WrapperModelEvaluatorPairPartIMEX_Basic.hpp"
17 
18 namespace Tempus {
19 
310 template <class Scalar>
311 class StepperIMEX_RK_Partition : virtual public Tempus::StepperImplicit<Scalar>,
312  virtual public Tempus::StepperRKBase<Scalar> {
313  public:
320  std::string stepperType = "Partitioned IMEX RK SSP2");
321 
324  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& appModel,
326  bool useFSAL, std::string ICConsistency, bool ICConsistencyCheck,
327  bool zeroInitialGuess,
328  const Teuchos::RCP<StepperRKAppAction<Scalar> >& stepperRKAppAction,
329  std::string stepperType,
330  Teuchos::RCP<const RKButcherTableau<Scalar> > explicitTableau,
331  Teuchos::RCP<const RKButcherTableau<Scalar> > implicitTableau,
332  Scalar order);
333 
335 
338  {
339  return getExplicitTableau();
340  }
341 
343  virtual void setTableaus(
344  std::string stepperType = "",
345  Teuchos::RCP<const RKButcherTableau<Scalar> > explicitTableau =
346  Teuchos::null,
347  Teuchos::RCP<const RKButcherTableau<Scalar> > implicitTableau =
348  Teuchos::null);
349 
351  std::string stepperType);
352 
355  const
356  {
357  return explicitTableau_;
358  }
359 
361  virtual void setExplicitTableau(
362  Teuchos::RCP<const RKButcherTableau<Scalar> > explicitTableau);
363 
366  const
367  {
368  return implicitTableau_;
369  }
370 
372  virtual void setImplicitTableau(
373  Teuchos::RCP<const RKButcherTableau<Scalar> > implicitTableau);
374 
375  virtual void setModel(
376  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& appModel);
377 
379  {
380  return this->wrapperModel_;
381  }
382 
383  virtual void setModelPair(
385  modelPair);
386 
387  virtual void setModelPair(
388  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& explicitModel,
389  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& implicitModel);
390 
392  virtual void initialize();
393 
395  virtual void setInitialConditions(
396  const Teuchos::RCP<SolutionHistory<Scalar> >& solutionHistory);
397 
399  virtual void takeStep(
400  const Teuchos::RCP<SolutionHistory<Scalar> >& solutionHistory);
401 
403  virtual Scalar getOrder() const { return order_; }
404  virtual Scalar getOrderMin() const { return order_; }
405  virtual Scalar getOrderMax() const { return order_; }
406 
407  virtual bool isExplicit() const { return true; }
408  virtual bool isImplicit() const { return true; }
409  virtual bool isExplicitImplicit() const
410  {
411  return isExplicit() && isImplicit();
412  }
413  virtual bool isOneStepMethod() const { return true; }
414  virtual bool isMultiStepMethod() const { return !isOneStepMethod(); }
415  virtual OrderODE getOrderODE() const { return FIRST_ORDER_ODE; }
417 
418  std::vector<Teuchos::RCP<Thyra::VectorBase<Scalar> > >& getStageF()
419  {
420  return stageF_;
421  }
422  std::vector<Teuchos::RCP<Thyra::VectorBase<Scalar> > >& getStageGx()
423  {
424  return stageGx_;
425  }
427 
429  virtual Scalar getAlpha(const Scalar dt) const
430  {
432  return Scalar(1.0) / (dt * A(0, 0)); // Getting the first diagonal coeff!
433  }
435  virtual Scalar getBeta(const Scalar) const { return Scalar(1.0); }
436 
438 
440 
441  virtual void describe(Teuchos::FancyOStream& out,
442  const Teuchos::EVerbosityLevel verbLevel) const;
444 
445  virtual bool isValidSetup(Teuchos::FancyOStream& out) const;
446 
448  const Teuchos::RCP<const Thyra::VectorBase<Scalar> >& X,
449  const Teuchos::RCP<const Thyra::VectorBase<Scalar> >& Y, Scalar time,
450  Scalar stepSize, Scalar stageNumber,
451  const Teuchos::RCP<Thyra::VectorBase<Scalar> >& G) const;
452 
453  void evalExplicitModel(
454  const Teuchos::RCP<const Thyra::VectorBase<Scalar> >& X, Scalar time,
455  Scalar stepSize, Scalar stageNumber,
456  const Teuchos::RCP<Thyra::VectorBase<Scalar> >& F) const;
457 
458  void setOrder(Scalar order) { order_ = order; }
459 
460  protected:
463 
464  Scalar order_;
465 
466  std::vector<Teuchos::RCP<Thyra::VectorBase<Scalar> > > stageF_;
467  std::vector<Teuchos::RCP<Thyra::VectorBase<Scalar> > > stageGx_;
468 
470 };
471 
484 template <typename Scalar>
486  : virtual public Tempus::TimeDerivative<Scalar> {
487  public:
490  Scalar s, Teuchos::RCP<const Thyra::VectorBase<Scalar> > xTilde)
491  {
492  initialize(s, xTilde);
493  }
494 
497 
499  virtual void compute(
502  Teuchos::RCP<Thyra::VectorBase<Scalar> > xDotDot = Teuchos::null)
503  {
504  xDotDot = Teuchos::null;
505 
506  // ith stage
507  // s = 1/(dt*a_ii)
508  // xOld = solution at beginning of time step
509  // xTilde = xOld + dt*(Sum_{j=1}^{i-1} a_ij x_dot_j)
510  // xDotTilde = - (s*x_i - s*xTilde)
511  Thyra::V_StVpStV(xDot.ptr(), s_, *x, -s_, *xTilde_);
512  }
513 
514  virtual void initialize(Scalar s,
516  {
517  s_ = s;
518  xTilde_ = xTilde;
519  }
520 
521  private:
523  Scalar s_; // = 1/(dt*a_ii)
524 };
525 
527 // ------------------------------------------------------------------------
528 template <class Scalar>
530  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& model,
531  std::string stepperType, Teuchos::RCP<Teuchos::ParameterList> pl);
532 
533 } // namespace Tempus
534 #endif // Tempus_StepperIMEX_RK_Partition_decl_hpp
virtual Scalar getAlpha(const Scalar dt) const
Return alpha = d(xDot)/dx.
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
Teuchos::RCP< WrapperModelEvaluator< Scalar > > wrapperModel_
StepperIMEX_RK_Partition(std::string stepperType="Partitioned IMEX RK SSP2")
Default constructor.
Teuchos::RCP< Thyra::VectorBase< Scalar > > xTilde_
virtual void setTableaus(std::string stepperType="", Teuchos::RCP< const RKButcherTableau< Scalar > > explicitTableau=Teuchos::null, Teuchos::RCP< const RKButcherTableau< Scalar > > implicitTableau=Teuchos::null)
Set both the explicit and implicit tableau from ParameterList.
virtual Teuchos::RCP< const RKButcherTableau< Scalar > > getImplicitTableau() const
Return implicit tableau.
virtual Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > getModel() const
virtual void setModelPair(const Teuchos::RCP< WrapperModelEvaluatorPairPartIMEX_Basic< Scalar > > &modelPair)
Create WrapperModelPairIMEX from user-supplied ModelEvaluator pair.
Teuchos::RCP< const RKButcherTableau< Scalar > > implicitTableau_
Partitioned Implicit-Explicit Runge-Kutta (IMEX-RK) time stepper.
std::vector< Teuchos::RCP< Thyra::VectorBase< Scalar > > > & getStageGx()
void evalExplicitModel(const Teuchos::RCP< const Thyra::VectorBase< Scalar > > &X, Scalar time, Scalar stepSize, Scalar stageNumber, const Teuchos::RCP< Thyra::VectorBase< Scalar > > &F) const
StepperIMEX_RKPartTimeDerivative(Scalar s, Teuchos::RCP< const Thyra::VectorBase< Scalar > > xTilde)
Constructor.
Base class for Runge-Kutta methods, ExplicitRK, DIRK and IMEX.
std::vector< Teuchos::RCP< Thyra::VectorBase< Scalar > > > stageF_
Thyra Base interface for implicit time steppers.
virtual Teuchos::RCP< Tempus::StepperState< Scalar > > getDefaultStepperState()
Provide a StepperState to the SolutionState. This Stepper does not have any special state data...
ModelEvaluator pair for implicit and explicit (IMEX) evaulations.
Application Action for StepperRKBase.
void evalImplicitModelExplicitly(const Teuchos::RCP< const Thyra::VectorBase< Scalar > > &X, const Teuchos::RCP< const Thyra::VectorBase< Scalar > > &Y, Scalar time, Scalar stepSize, Scalar stageNumber, const Teuchos::RCP< Thyra::VectorBase< Scalar > > &G) const
virtual Teuchos::RCP< const RKButcherTableau< Scalar > > getExplicitTableau() const
Return explicit tableau.
SolutionHistory is basically a container of SolutionStates. SolutionHistory maintains a collection of...
virtual void setExplicitTableau(Teuchos::RCP< const RKButcherTableau< Scalar > > explicitTableau)
Set the explicit tableau from tableau.
virtual bool isValidSetup(Teuchos::FancyOStream &out) const
Stepper integrates first-order ODEs.
std::vector< Teuchos::RCP< Thyra::VectorBase< Scalar > > > & getStageF()
virtual void initialize(Scalar s, Teuchos::RCP< const Thyra::VectorBase< Scalar > > xTilde)
virtual Teuchos::RCP< const RKButcherTableau< Scalar > > getTableau() const
Returns the explicit tableau!
Teuchos::RCP< const RKButcherTableau< Scalar > > explicitTableau_
This interface defines the time derivative connection between an implicit Stepper and WrapperModelEva...
virtual Scalar getBeta(const Scalar) const
Return beta = d(x)/dx.
virtual void setImplicitTableau(Teuchos::RCP< const RKButcherTableau< Scalar > > implicitTableau)
Set the implicit tableau from tableau.
std::vector< Teuchos::RCP< Thyra::VectorBase< Scalar > > > stageGx_
Teuchos::RCP< const Thyra::VectorBase< Scalar > > xTilde_
Time-derivative interface for Partitioned IMEX RK.
virtual void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const
virtual void setModel(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &appModel)
Set the model.
Teuchos::RCP< StepperIMEX_RK_Partition< Scalar > > createStepperIMEX_RK_Partition(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &model, std::string stepperType, Teuchos::RCP< Teuchos::ParameterList > pl)
Nonmember constructor - ModelEvaluator and ParameterList.
virtual void setTableausPartition(Teuchos::RCP< Teuchos::ParameterList > pl, std::string stepperType)
virtual void takeStep(const Teuchos::RCP< SolutionHistory< Scalar > > &solutionHistory)
Take the specified timestep, dt, and return true if successful.
virtual void setInitialConditions(const Teuchos::RCP< SolutionHistory< Scalar > > &solutionHistory)
Set the initial conditions and make them consistent.
Teuchos::RCP< Thyra::VectorBase< Scalar > > & getXTilde()
virtual void initialize()
Initialize during construction and after changing input parameters.
virtual void compute(Teuchos::RCP< const Thyra::VectorBase< Scalar > > x, Teuchos::RCP< Thyra::VectorBase< Scalar > > xDot, Teuchos::RCP< Thyra::VectorBase< Scalar > > xDotDot=Teuchos::null)
Compute the time derivative.