00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef Rythmos_STEPPER_SUPPORT_TYPES_H
00030 #define Rythmos_STEPPER_SUPPORT_TYPES_H
00031
00032 #include "Rythmos_Types.hpp"
00033 #include "Thyra_VectorBase.hpp"
00034
00035
00036 namespace Rythmos {
00037
00038
00040 enum StepSizeType { STEP_TYPE_FIXED, STEP_TYPE_VARIABLE };
00041
00042
00044 inline
00045 const char* toString( const StepSizeType stepSizeType )
00046 {
00047 switch(stepSizeType) {
00048 case STEP_TYPE_FIXED:
00049 return "STEP_TYPE_FIXED";
00050 case STEP_TYPE_VARIABLE:
00051 return "STEP_TYPE_VARIABLE";
00052 #ifdef RYTHMOS_DEBUG
00053 default:
00054 TEST_FOR_EXCEPT("Invalid enum value!");
00055 #endif
00056 }
00057 return 0;
00058 }
00059
00060
00062 enum EStepStatus {
00063 STEP_STATUS_UNINITIALIZED
00064 ,STEP_STATUS_CONVERGED
00065 ,STEP_STATUS_UNKNOWN
00066 };
00067
00068
00070 inline
00071 const char* toString(const EStepStatus stepStatus)
00072 {
00073 switch(stepStatus) {
00074 case STEP_STATUS_UNINITIALIZED: return "STEP_STATUS_UNINITIALIZED";
00075 case STEP_STATUS_CONVERGED: return "STEP_STATUS_CONVERGED";
00076 case STEP_STATUS_UNKNOWN: return "STEP_STATUS_UNKNOWN";
00077 #ifdef RYTHMOS_DEBUG
00078 default: TEST_FOR_EXCEPT(true);
00079 #endif
00080 }
00081 return "";
00082 }
00083
00084
00086 enum EStepLETStatus {
00087 STEP_LET_STATUS_PASSED
00088 ,STEP_LET_STATUS_FAILED
00089 ,STEP_LET_STATUS_UNKNOWN
00090 };
00091
00092
00094 inline
00095 const char* toString(const EStepLETStatus stepLETStatus)
00096 {
00097 switch(stepLETStatus) {
00098 case STEP_LET_STATUS_PASSED: return "STEP_LET_STATUS_PASSED";
00099 case STEP_LET_STATUS_FAILED: return "STEP_LET_STATUS_FAILED";
00100 case STEP_LET_STATUS_UNKNOWN: return "STEP_LET_STATUS_UNKNOWN";
00101 #ifdef RYTHMOS_DEBUG
00102 default: TEST_FOR_EXCEPT(true);
00103 #endif
00104 }
00105 return "";
00106 }
00107
00108
00110 enum EBreakPointType {
00111 BREAK_POINT_TYPE_HARD,
00112 BREAK_POINT_TYPE_SOFT
00113 };
00114
00115
00117 inline
00118 const char* toString(const EBreakPointType breakPointType)
00119 {
00120 switch(breakPointType) {
00121 case BREAK_POINT_TYPE_HARD: return "BREAK_POINT_TYPE_HARD";
00122 case BREAK_POINT_TYPE_SOFT: return "BREAK_POINT_TYPE_SOFT";
00123 #ifdef RYTHMOS_DEBUG
00124 default: TEST_FOR_EXCEPT(true);
00125 #endif
00126 }
00127 return "";
00128 }
00129
00130
00132 template<class Scalar>
00133 struct StepStatus {
00135 std::string message;
00137 EStepStatus stepStatus;
00139 EStepLETStatus stepLETStatus;
00141 Scalar stepSize;
00143 int order;
00145 Scalar time;
00147 Scalar stepLETValue;
00148
00149
00150
00152 RCP<const Thyra::VectorBase<Scalar> > solution;
00154 RCP<const Thyra::VectorBase<Scalar> > solutionDot;
00156 RCP<const Thyra::VectorBase<Scalar> > residual;
00158 RCP<const Teuchos::ParameterList> extraParameters;
00160 StepStatus()
00161 :stepStatus(STEP_STATUS_UNKNOWN)
00162 ,stepLETStatus(STEP_LET_STATUS_UNKNOWN)
00163 ,stepLETValue(Scalar(-Teuchos::ScalarTraits<Scalar>::one()))
00164 {}
00165 };
00166
00167
00169 template<class Scalar>
00170 std::ostream& operator<<( std::ostream& out_arg, const StepStatus<Scalar> &stepStatus )
00171 {
00172 using std::endl;
00173 RCP<Teuchos::FancyOStream>
00174 out = Teuchos::getFancyOStream(Teuchos::rcp(&out_arg,false));
00175 Teuchos::OSTab tab(out);
00176 *out
00177 << "message: \"" << stepStatus.message << "\"" << endl
00178 << "stepStatus = " << toString(stepStatus.stepStatus) << endl
00179 << "stepLETStatus = " << toString(stepStatus.stepLETStatus) << endl
00180 << "stepSize = " << stepStatus.stepSize << endl
00181 << "order = " << stepStatus.order << endl
00182 << "time = " << stepStatus.time << endl
00183 << "stepLETValue = " << stepStatus.stepLETValue << endl;
00184 if (stepStatus.solution == Teuchos::null) {
00185 *out << "solution = NULL" << endl;
00186 }
00187 else {
00188 *out << "solution = " << stepStatus.solution->description() << endl;
00189 }
00190 if (stepStatus.solutionDot == Teuchos::null) {
00191 *out << "solutionDot = NULL" << endl;
00192 }
00193 else {
00194 *out << "solutionDot = " << stepStatus.solutionDot->description() << endl;
00195 }
00196 if (stepStatus.residual == Teuchos::null) {
00197 *out << "residual = NULL" << endl;
00198 }
00199 else {
00200 *out << "residual = " << stepStatus.residual->description() << endl;
00201 }
00202 *out << "extraParameters: ";
00203 if(stepStatus.extraParameters.get()) {
00204 *out << "\n";
00205 stepStatus.extraParameters->print(Teuchos::OSTab(out).o(),1000,true);
00206 }
00207 else {
00208 *out << "NONE" << endl;
00209 }
00210 return out_arg;
00211 }
00212
00213 }
00214
00215 #endif // Rythmos_STEPPER_SUPPORT_TYPES_H
00216
00217
00218