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