Rythmos - Transient Integration for Differential Equations Version of the Day
Loading...
Searching...
No Matches
Rythmos_StepControlStrategyBase.hpp
1//@HEADER
2// ***********************************************************************
3//
4// Rythmos Package
5// Copyright (2006) Sandia Corporation
6//
7// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8// license for use of this work by or on behalf of the U.S. Government.
9//
10// This library is free software; you can redistribute it and/or modify
11// it under the terms of the GNU Lesser General Public License as
12// published by the Free Software Foundation; either version 2.1 of the
13// License, or (at your option) any later version.
14//
15// This library is distributed in the hope that it will be useful, but
16// WITHOUT ANY WARRANTY; without even the implied warranty of
17// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18// Lesser General Public License for more details.
19//
20// You should have received a copy of the GNU Lesser General Public
21// License along with this library; if not, write to the Free Software
22// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
23// USA
24// Questions? Contact Todd S. Coffey (tscoffe@sandia.gov)
25//
26// ***********************************************************************
27//@HEADER
28
29
30#ifndef RYTHMOS_STEP_CONTROL_STRATEGY_BASE_HPP
31#define RYTHMOS_STEP_CONTROL_STRATEGY_BASE_HPP
32
33
34#include "Rythmos_StepperBase.hpp"
35
36namespace Rythmos {
37
38
46enum AttemptedStepStatusFlag { PREDICT_AGAIN, CONTINUE_ANYWAY, REP_ERR_FAIL, REP_CONV_FAIL };
47
49enum StepControlStrategyState { UNINITIALIZED, BEFORE_FIRST_STEP, MID_STEP, AFTER_CORRECTION, READY_FOR_NEXT_STEP, BEFORE_FIRST_STAGE, MID_STAGE };
50/*
51 * 9/10/15- Sidafa
52 * added BEFORE_FIRST_STAGE and MID_STAGE for Multi-Stage (RK) step control state
53 * - for the inter-stage control state
54 */
55
57inline
58const char* toString( const StepControlStrategyState stepControlStrategyState )
59{
60 switch(stepControlStrategyState) {
61 case UNINITIALIZED:
62 return "UNINITIALIZED";
63 case BEFORE_FIRST_STEP:
64 return "BEFORE_FIRST_STEP";
65 case MID_STEP:
66 return "MID_STEP";
67 case AFTER_CORRECTION:
68 return "AFTER_CORRECTION";
69 case READY_FOR_NEXT_STEP:
70 return "READY_FOR_NEXT_STEP";
71 case BEFORE_FIRST_STAGE:
72 return "BEFORE_FIRST_STAGE";
73 case MID_STAGE:
74 return "MID_STAGE";
75#ifdef HAVE_RYTHMOS_DEBUG
76 default:
77 TEUCHOS_TEST_FOR_EXCEPT("Invalid enum value!");
78#endif
79 }
80 return 0; // Should never get here!
81}
82
105template<class Scalar>
107 : virtual public Teuchos::Describable
108 , virtual public Teuchos::ParameterListAcceptor
109 , virtual public Teuchos::VerboseObject<StepControlStrategyBase<Scalar> >
110{
111public:
112
114 virtual void initialize(const StepperBase<Scalar>& stepper) =0;
115
118 const StepperBase<Scalar>& stepper
119 , const Scalar& stepSize
120 , const StepSizeType& stepSizeType
121 ) = 0;
122
124 virtual void nextStepSize(
125 const StepperBase<Scalar>& stepper
126 , Scalar* stepSize
127 , StepSizeType* stepSizeType
128 , int* order
129 ) = 0;
130
132 virtual void setCorrection(
133 const StepperBase<Scalar>& stepper
134 , const RCP<const Thyra::VectorBase<Scalar> >& soln
135 , const RCP<const Thyra::VectorBase<Scalar> >& ee
136 , int solveStatus
137 ) = 0;
138
140 virtual bool acceptStep(
141 const StepperBase<Scalar>& stepper
142 ,Scalar* LETValue
143 ) = 0;
144
146 virtual void completeStep(
147 const StepperBase<Scalar>& stepper
148 ) = 0;
149
151 virtual AttemptedStepStatusFlag rejectStep(
152 const StepperBase<Scalar>& stepper
153 ) = 0;
154
156 virtual StepControlStrategyState getCurrentState() = 0;
157
159 virtual int getMaxOrder() const = 0;
160
162 virtual void setStepControlData(const StepperBase<Scalar>& stepper) = 0;
163
165 virtual bool supportsCloning() const;
166
168 virtual RCP<StepControlStrategyBase<Scalar> > cloneStepControlStrategyAlgorithm() const;
169
170
171};
172
173template<class Scalar>
175{
176 return false;
177}
178
179
180template<class Scalar>
181RCP<StepControlStrategyBase<Scalar> >
186
187
188} // namespace Rythmos
189
190
191#endif // RYTHMOS_STEP_CONTROL_STRATEGY_BASE_HPP
The member functions in the StepControlStrategyBase move you between these states in the following fa...
virtual void setCorrection(const StepperBase< Scalar > &stepper, const RCP< const Thyra::VectorBase< Scalar > > &soln, const RCP< const Thyra::VectorBase< Scalar > > &ee, int solveStatus)=0
virtual void completeStep(const StepperBase< Scalar > &stepper)=0
virtual void setRequestedStepSize(const StepperBase< Scalar > &stepper, const Scalar &stepSize, const StepSizeType &stepSizeType)=0
virtual int getMaxOrder() const =0
virtual void setStepControlData(const StepperBase< Scalar > &stepper)=0
virtual void nextStepSize(const StepperBase< Scalar > &stepper, Scalar *stepSize, StepSizeType *stepSizeType, int *order)=0
virtual RCP< StepControlStrategyBase< Scalar > > cloneStepControlStrategyAlgorithm() const
virtual AttemptedStepStatusFlag rejectStep(const StepperBase< Scalar > &stepper)=0
virtual void initialize(const StepperBase< Scalar > &stepper)=0
virtual bool acceptStep(const StepperBase< Scalar > &stepper, Scalar *LETValue)=0
virtual StepControlStrategyState getCurrentState()=0