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 #include <NewtonRaphson.h>
00042 #include <AnalysisModel.h>
00043 #include <StaticAnalysis.h>
00044 #include <IncrementalIntegrator.h>
00045 #include <LinearSOE.h>
00046 #include <Channel.h>
00047 #include <FEM_ObjectBroker.h>
00048 #include <ConvergenceTest.h>
00049 #include <ID.h>
00050
00051
00052 NewtonRaphson::NewtonRaphson(int theTangentToUse)
00053 :EquiSolnAlgo(EquiALGORITHM_TAGS_NewtonRaphson),
00054 theTest(0), tangent(theTangentToUse)
00055 {
00056
00057 }
00058
00059
00060 NewtonRaphson::NewtonRaphson(ConvergenceTest &theT, int theTangentToUse)
00061 :EquiSolnAlgo(EquiALGORITHM_TAGS_NewtonRaphson),
00062 theTest(&theT), tangent(theTangentToUse)
00063 {
00064
00065 }
00066
00067
00068 NewtonRaphson::~NewtonRaphson()
00069 {
00070
00071
00072 }
00073
00074 int
00075 NewtonRaphson::setConvergenceTest(ConvergenceTest *newTest)
00076 {
00077 theTest = newTest;
00078 return 0;
00079 }
00080
00081
00082
00083 int
00084 NewtonRaphson::solveCurrentStep(void)
00085 {
00086
00087
00088 AnalysisModel *theAnaModel = this->getAnalysisModelPtr();
00089 IncrementalIntegrator *theIntegrator = this->getIncrementalIntegratorPtr();
00090 LinearSOE *theSOE = this->getLinearSOEptr();
00091
00092 if ((theAnaModel == 0) || (theIntegrator == 0) || (theSOE == 0)
00093 || (theTest == 0)){
00094 opserr << "WARNING NewtonRaphson::solveCurrentStep() - setLinks() has";
00095 opserr << " not been called - or no ConvergenceTest has been set\n";
00096 return -5;
00097 }
00098
00099 if (theIntegrator->formUnbalance() < 0) {
00100 opserr << "WARNING NewtonRaphson::solveCurrentStep() -";
00101 opserr << "the Integrator failed in formUnbalance()\n";
00102 return -2;
00103 }
00104
00105
00106 theTest->setEquiSolnAlgo(*this);
00107 if (theTest->start() < 0) {
00108 opserr << "NewtnRaphson::solveCurrentStep() -";
00109 opserr << "the ConvergenceTest object failed in start()\n";
00110 return -3;
00111 }
00112
00113 int result = -1;
00114 int count = 0;
00115 do {
00116 if (tangent == INITIAL_THEN_CURRENT_TANGENT) {
00117 if (count == 0) {
00118 if (theIntegrator->formTangent(INITIAL_TANGENT) < 0){
00119 opserr << "WARNING NewtonRaphson::solveCurrentStep() -";
00120 opserr << "the Integrator failed in formTangent()\n";
00121 return -1;
00122 }
00123 } else {
00124 if (theIntegrator->formTangent(CURRENT_TANGENT) < 0){
00125 opserr << "WARNING NewtonRaphson::solveCurrentStep() -";
00126 opserr << "the Integrator failed in formTangent()\n";
00127 return -1;
00128 }
00129 }
00130 } else {
00131 if (theIntegrator->formTangent(tangent) < 0){
00132 opserr << "WARNING NewtonRaphson::solveCurrentStep() -";
00133 opserr << "the Integrator failed in formTangent()\n";
00134 return -1;
00135 }
00136 }
00137
00138 if (theSOE->solve() < 0) {
00139 opserr << "WARNING NewtonRaphson::solveCurrentStep() -";
00140 opserr << "the LinearSysOfEqn failed in solve()\n";
00141 return -3;
00142 }
00143
00144 if (theIntegrator->update(theSOE->getX()) < 0) {
00145 opserr << "WARNING NewtonRaphson::solveCurrentStep() -";
00146 opserr << "the Integrator failed in update()\n";
00147 return -4;
00148 }
00149
00150 if (theIntegrator->formUnbalance() < 0) {
00151 opserr << "WARNING NewtonRaphson::solveCurrentStep() -";
00152 opserr << "the Integrator failed in formUnbalance()\n";
00153 return -2;
00154 }
00155
00156 result = theTest->test();
00157 this->record(count++);
00158
00159 } while (result == -1);
00160
00161 if (result == -2) {
00162 opserr << "NewtnRaphson::solveCurrentStep() -";
00163 opserr << "the ConvergenceTest object failed in test()\n";
00164 return -3;
00165 }
00166
00167
00168
00169 return result;
00170 }
00171
00172 ConvergenceTest *
00173 NewtonRaphson::getConvergenceTest(void)
00174 {
00175 return theTest;
00176 }
00177
00178 int
00179 NewtonRaphson::sendSelf(int cTag, Channel &theChannel)
00180 {
00181 static ID data(1);
00182 data(0) = tangent;
00183 return theChannel.sendID(this->getDbTag(), cTag, data);
00184 }
00185
00186 int
00187 NewtonRaphson::recvSelf(int cTag,
00188 Channel &theChannel,
00189 FEM_ObjectBroker &theBroker)
00190 {
00191 static ID data(1);
00192 theChannel.recvID(this->getDbTag(), cTag, data);
00193 tangent = data(0);
00194 return 0;
00195 }
00196
00197
00198 void
00199 NewtonRaphson::Print(OPS_Stream &s, int flag)
00200 {
00201 if (flag == 0) {
00202 s << "NewtonRaphson" << endln;
00203 }
00204 }
00205
00206
00207
00208
00209
00210
00211
00212
00213