Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

VariableTimeStepDirectIntegrationAnalysis.cpp

Go to the documentation of this file.
00001 /* ****************************************************************** **
00002 **    OpenSees - Open System for Earthquake Engineering Simulation    **
00003 **          Pacific Earthquake Engineering Research Center            **
00004 **                                                                    **
00005 **                                                                    **
00006 ** (C) Copyright 1999, The Regents of the University of California    **
00007 ** All Rights Reserved.                                               **
00008 **                                                                    **
00009 ** Commercial use of this program without express permission of the   **
00010 ** University of California, Berkeley, is strictly prohibited.  See   **
00011 ** file 'COPYRIGHT'  in main directory for information on usage and   **
00012 ** redistribution,  and for a DISCLAIMER OF ALL WARRANTIES.           **
00013 **                                                                    **
00014 ** Developed by:                                                      **
00015 **   Frank McKenna (fmckenna@ce.berkeley.edu)                         **
00016 **   Gregory L. Fenves (fenves@ce.berkeley.edu)                       **
00017 **   Filip C. Filippou (filippou@ce.berkeley.edu)                     **
00018 **                                                                    **
00019 ** ****************************************************************** */
00020                                                                         
00021 // $Revision: 1.1 $
00022 // $Date: 2000/12/13 04:44:25 $
00023 // $Source: /usr/local/cvs/OpenSees/SRC/analysis/analysis/VariableTimeStepDirectIntegrationAnalysis.cpp,v $
00024                                                                         
00025                                                                         
00026 // File: ~/analysis/analysis/VariableTimeStepDirectIntegrationAnalysis.C
00027 // 
00028 // Written: fmk 
00029 // Created: 10/00
00030 // Revision: A
00031 //
00032 // Description: This file contains the implementation of the
00033 // VariableTimeStepDirectIntegrationAnalysis class.
00034 //
00035 // What: "@(#) VariableTimeStepDirectIntegrationAnalysis.C, revA"
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 // Constructor
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   // get some pointers
00070   Domain *theDom = this->getDomainPtr();
00071   EquiSolnAlgo *theAlgo = this->getAlgorithm();
00072   TransientIntegrator *theIntegratr = this->getIntegrator();
00073   ConvergenceTest *theTest = theAlgo->getTest();
00074 
00075   // set some variables
00076   int result = 0;  
00077   double totalTimeIncr = numSteps * dT;
00078   double currentTimeIncr = 0.0;
00079   double currentDt = dT;
00080   
00081   // loop until analysis has performed the total time incr requested
00082   while (currentTimeIncr < totalTimeIncr) {
00083 
00084     // check if domain has undergone change
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     // do newStep(), solveCurrentStep() and commit() as in regular
00093     // DirectINtegrationAnalysis - difference is we do not return
00094     // if a failure - we stop the analysis & resize time step if failure
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     // if the time step was successfull increment delta T for the analysis
00114     // othewise revert the Domain to last committed state & see if can go on
00115 
00116     if (result >= 0) 
00117       currentTimeIncr += currentDt;
00118     else {
00119 
00120       // invoke the revertToLastCommit
00121       theDom->revertToLastCommit();     
00122       theIntegratr->revertToLastStep();
00123 
00124       // if last dT was <= min specified the analysis FAILS - return FAILURE
00125       if (currentDt <= dtMin) {
00126  cerr << "VariableTimeStepDirectIntegrationAnalysis::analyze() - ";
00127  cerr << " failed at time " << theDom->getCurrentTime() << endl;
00128  return result;
00129       }
00130       
00131       // if still here reset result for next loop
00132       result = 0;
00133     }
00134 
00135     // now we determine a new delta T for next loop
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   // get the number of trial steps in the last solveCurrentStep()
00156   double algoPercent = 1.0;
00157   if (theTest != 0)
00158     algoPercent = theTest->getRatioNumToMax();
00159   
00160   
00161   // determine new dT based on last dT and Jd and #iter of last step
00162   double factor = perCent/algoPercent;
00163   newDt *= factor;
00164   
00165   // ensure: dtMin <~~ dT <= dtMax
00166   if (newDt < dtMin)
00167     newDt = dtMin - DBL_EPSILON;  // to ensure we get out of the analysis 
00168                                // loop if can't converge on next step
00169   else if (newDt > dtMax)
00170     newDt = dtMax;
00171     
00172   return newDt;
00173 }
00174 
00175 
Copyright Contact Us