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
00030
00031 #ifndef SUNDANCE_DOUBLING_STEP_CONTROLLER_H
00032 #define SUNDANCE_DOUBLING_STEP_CONTROLLER_H
00033
00034 #include "SundanceFieldWriter.hpp"
00035 #include "SundanceFieldWriterFactory.hpp"
00036 #include "SundanceTransientStepProblem.hpp"
00037 #include "SundanceExprComparison.hpp"
00038 #include "SundanceEventDetector.hpp"
00039
00040
00041
00042 namespace Sundance
00043 {
00044
00045
00046 class StepControlParameters
00047 {
00048 public:
00049
00050 StepControlParameters()
00051 {initDefaults();}
00052
00053 double tStart_;
00054
00055 double tStop_;
00056
00057 double tau_;
00058
00059 double initialStepsize_;
00060
00061 double minStepsizeFactor_;
00062
00063 double maxStepsizeFactor_;
00064
00065 double stepsizeReductionSafetyFactor_;
00066
00067 int maxSteps_;
00068
00069 int verbosity_;
00070
00071 int stepOrder_;
00072
00073 private:
00074 void initDefaults()
00075 {
00076 tStart_ = 0.0;
00077 tStop_ = 0.0;
00078 tau_ = 1.0e-6;
00079 initialStepsize_ = 0.01;
00080 minStepsizeFactor_ = 0.01;
00081 maxStepsizeFactor_ = 10.0;
00082 stepsizeReductionSafetyFactor_ = 0.9;
00083 maxSteps_ = 100000;
00084 verbosity_ = 0;
00085 stepOrder_ = 2;
00086 }
00087 };
00088
00089
00090 class OutputControlParameters
00091 {
00092 public:
00093
00094 OutputControlParameters(
00095 const FieldWriterFactory& wf,
00096 const string& filename,
00097 const double& writeInterval,
00098 int verb=0)
00099 :
00100 writeInterval_(writeInterval),
00101 wf_(wf),
00102 filename_(filename),
00103 verbosity_(verb)
00104 {}
00105
00106 double writeInterval_;
00107 FieldWriterFactory wf_;
00108 string filename_;
00109 int verbosity_;
00110 };
00111
00112
00113
00114 class DoublingStepController
00115 {
00116 public:
00117
00118 DoublingStepController(
00119 const TransientStepProblem& prob,
00120 const NonlinearSolver<double>& solver,
00121 const StepControlParameters& stepControl,
00122 const OutputControlParameters& outputControl,
00123 const RCP<ExprComparisonBase>& compare)
00124 : prob_(prob),
00125 stepControl_(stepControl),
00126 outputControl_(outputControl),
00127 solver_(solver),
00128 compare_(compare),
00129 eventHandler_()
00130 {}
00131
00132
00133 void setEventHandler(RCP<EventDetectorBase> e)
00134 {eventHandler_ = e;}
00135
00136
00137
00138 bool run() const ;
00139
00140
00141 void write(int index, double t, const Expr& u) const ;
00142
00143 private:
00144 TransientStepProblem prob_;
00145 StepControlParameters stepControl_;
00146 OutputControlParameters outputControl_;
00147 NonlinearSolver<double> solver_;
00148 RCP<ExprComparisonBase> compare_;
00149 RCP<EventDetectorBase> eventHandler_;
00150 };
00151
00152
00153 }
00154
00155
00156 #endif