Rythmos - Transient Integration for Differential Equations Version of the Day
Loading...
Searching...
No Matches
Rythmos_StepperSupportTypes.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#ifndef Rythmos_STEPPER_SUPPORT_TYPES_H
30#define Rythmos_STEPPER_SUPPORT_TYPES_H
31
32#include "Rythmos_Types.hpp"
33#include "Thyra_VectorBase.hpp"
34
35
36namespace Rythmos {
37
38
40enum StepSizeType { STEP_TYPE_FIXED, STEP_TYPE_VARIABLE };
41
42
44inline
45const char* toString( const StepSizeType stepSizeType )
46{
47 switch(stepSizeType) {
48 case STEP_TYPE_FIXED:
49 return "STEP_TYPE_FIXED";
50 case STEP_TYPE_VARIABLE:
51 return "STEP_TYPE_VARIABLE";
52#ifdef HAVE_RYTHMOS_DEBUG
53 default:
54 TEUCHOS_TEST_FOR_EXCEPT("Invalid enum value!");
55#endif
56 }
57 return 0; // Should never get here!
58}
59
60
62enum EStepStatus {
63 STEP_STATUS_UNINITIALIZED
64 ,STEP_STATUS_CONVERGED
65 ,STEP_STATUS_UNKNOWN
66};
67
68
70inline
71const char* toString(const EStepStatus stepStatus)
72{
73 switch(stepStatus) {
74 case STEP_STATUS_UNINITIALIZED: return "STEP_STATUS_UNINITIALIZED";
75 case STEP_STATUS_CONVERGED: return "STEP_STATUS_CONVERGED";
76 case STEP_STATUS_UNKNOWN: return "STEP_STATUS_UNKNOWN";
77#ifdef HAVE_RYTHMOS_DEBUG
78 default: TEUCHOS_TEST_FOR_EXCEPT(true);
79#endif
80 }
81 return ""; // Never be called!
82}
83
84
86enum EStepLETStatus {
87 STEP_LET_STATUS_PASSED
88 ,STEP_LET_STATUS_FAILED
89 ,STEP_LET_STATUS_UNKNOWN
90};
91
92
94inline
95const char* toString(const EStepLETStatus stepLETStatus)
96{
97 switch(stepLETStatus) {
98 case STEP_LET_STATUS_PASSED: return "STEP_LET_STATUS_PASSED";
99 case STEP_LET_STATUS_FAILED: return "STEP_LET_STATUS_FAILED";
100 case STEP_LET_STATUS_UNKNOWN: return "STEP_LET_STATUS_UNKNOWN";
101#ifdef HAVE_RYTHMOS_DEBUG
102 default: TEUCHOS_TEST_FOR_EXCEPT(true);
103#endif
104 }
105 return ""; // Never be called!
106}
107
108
110enum EBreakPointType {
111 BREAK_POINT_TYPE_HARD,
112 BREAK_POINT_TYPE_SOFT
113};
114
115
117inline
118const char* toString(const EBreakPointType breakPointType)
119{
120 switch(breakPointType) {
121 case BREAK_POINT_TYPE_HARD: return "BREAK_POINT_TYPE_HARD";
122 case BREAK_POINT_TYPE_SOFT: return "BREAK_POINT_TYPE_SOFT";
123#ifdef HAVE_RYTHMOS_DEBUG
124 default: TEUCHOS_TEST_FOR_EXCEPT(true);
125#endif
126 }
127 return ""; // Never be called!
128}
129
130
132template<class Scalar>
135 std::string message;
137 EStepStatus stepStatus;
139 EStepLETStatus stepLETStatus;
141 Scalar stepSize;
143 int order;
145 Scalar time;
148 // 2007/05/21: rabartl: ToDo: Change above stepLetValue to ScalarMag
149 // 2007/05/21: rabartl: ToDo: We must define what the Local Error Test (LET)
150 // is (i.e. what values go into it's computation, what norms are used etc.).
152 RCP<const Thyra::VectorBase<Scalar> > solution;
154 RCP<const Thyra::VectorBase<Scalar> > solutionDot;
156 RCP<const Thyra::VectorBase<Scalar> > residual;
158 RCP<const Teuchos::ParameterList> extraParameters;
161 :stepStatus(STEP_STATUS_UNKNOWN)
162 ,stepLETStatus(STEP_LET_STATUS_UNKNOWN)
163 ,stepLETValue(Scalar(-Teuchos::ScalarTraits<Scalar>::one()))
164 {}
165};
166
167
169template<class Scalar>
170std::ostream& operator<<( std::ostream& out_arg, const StepStatus<Scalar> &stepStatus )
171{
172 using std::endl;
173 RCP<Teuchos::FancyOStream>
174 out = Teuchos::getFancyOStream(Teuchos::rcp(&out_arg,false));
175 Teuchos::OSTab tab(out);
176 *out
177 << "message: \"" << stepStatus.message << "\"" << endl
178 << "stepStatus = " << toString(stepStatus.stepStatus) << endl
179 << "stepLETStatus = " << toString(stepStatus.stepLETStatus) << endl
180 << "stepSize = " << stepStatus.stepSize << endl
181 << "order = " << stepStatus.order << endl
182 << "time = " << stepStatus.time << endl
183 << "stepLETValue = " << stepStatus.stepLETValue << endl;
184 if (stepStatus.solution == Teuchos::null) {
185 *out << "solution = NULL" << endl;
186 }
187 else {
188 *out << "solution = " << stepStatus.solution->description() << endl;
189 }
190 if (stepStatus.solutionDot == Teuchos::null) {
191 *out << "solutionDot = NULL" << endl;
192 }
193 else {
194 *out << "solutionDot = " << stepStatus.solutionDot->description() << endl;
195 }
196 if (stepStatus.residual == Teuchos::null) {
197 *out << "residual = NULL" << endl;
198 }
199 else {
200 *out << "residual = " << stepStatus.residual->description() << endl;
201 }
202 *out << "extraParameters: ";
203 if(stepStatus.extraParameters.get()) {
204 *out << "\n";
205 stepStatus.extraParameters->print(Teuchos::OSTab(out).o(),1000,true);
206 }
207 else {
208 *out << "NONE" << endl;
209 }
210 return out_arg;
211}
212
213} // namespace Rythmos
214
215#endif // Rythmos_STEPPER_SUPPORT_TYPES_H
216
217
218
RCP< const Thyra::VectorBase< Scalar > > solution
RCP< const Thyra::VectorBase< Scalar > > residual
RCP< const Teuchos::ParameterList > extraParameters
RCP< const Thyra::VectorBase< Scalar > > solutionDot