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