Rythmos - Transient Integration for Differential Equations Version of the Day
Rythmos_StepperSupportTypes.hpp
00001 //@HEADER
00002 // ***********************************************************************
00003 //
00004 //                           Rythmos Package
00005 //                 Copyright (2006) Sandia Corporation
00006 //
00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00008 // license for use of this work by or on behalf of the U.S. Government.
00009 //
00010 // This library is free software; you can redistribute it and/or modify
00011 // it under the terms of the GNU Lesser General Public License as
00012 // published by the Free Software Foundation; either version 2.1 of the
00013 // License, or (at your option) any later version.
00014 //
00015 // This library is distributed in the hope that it will be useful, but
00016 // WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018 // Lesser General Public License for more details.
00019 //
00020 // You should have received a copy of the GNU Lesser General Public
00021 // License along with this library; if not, write to the Free Software
00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00023 // USA
00024 // Questions? Contact Todd S. Coffey (tscoffe@sandia.gov)
00025 //
00026 // ***********************************************************************
00027 //@HEADER
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; // Should never get here!
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 ""; // Never be called!
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 ""; // Never be called!
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 ""; // Never be called!
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   // 2007/05/21: rabartl: ToDo: Change above stepLetValue to ScalarMag
00149   // 2007/05/21: rabartl: ToDo: We must define what the Local Error Test (LET)
00150   // is (i.e. what values go into it's computation, what norms are used etc.).
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 } // namespace Rythmos
00214 
00215 #endif // Rythmos_STEPPER_SUPPORT_TYPES_H
00216 
00217 
00218 
 All Classes Functions Variables Typedefs Friends