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 #include <VariableTimeStepDirectIntegrationAnalysis.h>
00038 #include <EquiSolnAlgo.h>
00039 #include <TransientIntegrator.h>
00040 #include <Domain.h>
00041 #include <ConvergenceTest.h>
00042 #include <float.h>
00043
00044
00045 VariableTimeStepDirectIntegrationAnalysis::VariableTimeStepDirectIntegrationAnalysis(
00046 Domain &the_Domain,
00047 ConstraintHandler &theHandler,
00048 DOF_Numberer &theNumberer,
00049 AnalysisModel &theModel,
00050 EquiSolnAlgo &theSolnAlgo,
00051 LinearSOE &theLinSOE,
00052 TransientIntegrator &theTransientIntegrator)
00053
00054 :DirectIntegrationAnalysis(the_Domain, theHandler, theNumberer, theModel,
00055 theSolnAlgo, theLinSOE, theTransientIntegrator)
00056 {
00057
00058 }
00059
00060 VariableTimeStepDirectIntegrationAnalysis::~VariableTimeStepDirectIntegrationAnalysis()
00061 {
00062
00063 }
00064
00065
00066 int
00067 VariableTimeStepDirectIntegrationAnalysis::analyze(int numSteps, double dT, double dtMin, double dtMax, double perCent)
00068 {
00069
00070 Domain *theDom = this->getDomainPtr();
00071 EquiSolnAlgo *theAlgo = this->getAlgorithm();
00072 TransientIntegrator *theIntegratr = this->getIntegrator();
00073 ConvergenceTest *theTest = theAlgo->getTest();
00074
00075
00076 int result = 0;
00077 double totalTimeIncr = numSteps * dT;
00078 double currentTimeIncr = 0.0;
00079 double currentDt = dT;
00080
00081
00082 while (currentTimeIncr < totalTimeIncr) {
00083
00084
00085 if (this->checkDomainChange() < 0) {
00086 cerr << "VariableTimeStepDirectIntegrationAnalysis::analyze() - failed";
00087 cerr << " failed at time " << theDom->getCurrentTime() << endl;
00088 return -1;
00089 }
00090
00091
00092
00093
00094
00095
00096
00097 if (theIntegratr->newStep(currentDt) < 0) {
00098 result = -2;
00099 }
00100
00101 if (result >= 0) {
00102 result = theAlgo->solveCurrentStep();
00103 if (result < 0)
00104 result = -3;
00105 }
00106
00107 if (result >= 0) {
00108 result = theIntegratr->commit();
00109 if (result < 0)
00110 result = -4;
00111 }
00112
00113
00114
00115
00116 if (result >= 0)
00117 currentTimeIncr += currentDt;
00118 else {
00119
00120
00121 theDom->revertToLastCommit();
00122 theIntegratr->revertToLastStep();
00123
00124
00125 if (currentDt <= dtMin) {
00126 cerr << "VariableTimeStepDirectIntegrationAnalysis::analyze() - ";
00127 cerr << " failed at time " << theDom->getCurrentTime() << endl;
00128 return result;
00129 }
00130
00131
00132 result = 0;
00133 }
00134
00135
00136 currentDt = this->determineDt(currentDt, dtMin, dtMax, perCent, theTest);
00137 }
00138
00139 return 0;
00140 }
00141
00142
00143
00144
00145
00146 double
00147 VariableTimeStepDirectIntegrationAnalysis::determineDt(double dT,
00148 double dtMin,
00149 double dtMax,
00150 double perCent,
00151 ConvergenceTest *theTest)
00152 {
00153 double newDt = dT;
00154
00155
00156 double algoPercent = 1.0;
00157 if (theTest != 0)
00158 algoPercent = theTest->getRatioNumToMax();
00159
00160
00161
00162 double factor = perCent/algoPercent;
00163 newDt *= factor;
00164
00165
00166 if (newDt < dtMin)
00167 newDt = dtMin - DBL_EPSILON;
00168
00169 else if (newDt > dtMax)
00170 newDt = dtMax;
00171
00172 return newDt;
00173 }
00174
00175