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