| 116 | |
| 117 | |
| 118 | int CTestRelativeTotalNormDispIncr::test(void) |
| 119 | { |
| 120 | // check to ensure the SOE has been set - this should not happen if the |
| 121 | // return from start() is checked |
| 122 | if (theSOE == 0) { |
| 123 | opserr << "WARNING: CTestRelativeTotalNormDispIncr::test() - no SOE set.\n"; |
| 124 | return -1; |
| 125 | } |
| 126 | |
| 127 | // check to ensure the algo does invoke start() - this is needed otherwise |
| 128 | // may never get convergence later on in analysis! |
| 129 | if (currentIter == 0) { |
| 130 | opserr << "WARNING: CTestRelativeTotalNormDispIncr::test() - start() was never invoked.\n"; |
| 131 | return -2; |
| 132 | } |
| 133 | |
| 134 | // get the X vector & determine it's norm & save the value in norms vector |
| 135 | const Vector &x = theSOE->getX(); |
| 136 | double norm = x.pNorm(nType); |
| 137 | if (currentIter <= maxNumIter) |
| 138 | norms(currentIter-1) = norm; |
| 139 | |
| 140 | // add current norm to total norm |
| 141 | totNorm += norm; |
| 142 | |
| 143 | // get ratio |
| 144 | if (totNorm != 0.0) |
| 145 | norm /= totNorm; |
| 146 | |
| 147 | // print the data if required |
| 148 | if (printFlag == 1) { |
| 149 | opserr << "CTestRelativeTotalNormDispIncr::test() - iteration: " << currentIter; |
| 150 | opserr << " current ratio (|dX|/|dXtot|): " << norm << " (max: " << tol << ")\n"; |
| 151 | } |
| 152 | if (printFlag == 4) { |
| 153 | opserr << "CTestRelativeTotalNormDispIncr::test() - iteration: " << currentIter; |
| 154 | opserr << " current ratio (|dX|/|dXtot|): " << norm << " (max: " << tol << ")\n"; |
| 155 | opserr << "\tNorm deltaX: " << norm << ", Norm deltaR: " << theSOE->getB().pNorm(nType) << endln; |
| 156 | opserr << "\tdeltaX: " << x << "\tdeltaR: " << theSOE->getB(); |
| 157 | } |
| 158 | |
| 159 | // |
| 160 | // check if the algorithm converged |
| 161 | // |
| 162 | |
| 163 | // if converged - print & return ok |
| 164 | if (norm <= tol) { |
| 165 | |
| 166 | // do some printing first |
| 167 | if (printFlag != 0) { |
| 168 | if (printFlag == 1 || printFlag ==4) |
| 169 | opserr << endln; |
| 170 | else if (printFlag == 2 || printFlag == 6) { |
| 171 | opserr << "CTestRelativeTotalNormDispIncr::test() - iteration: " << currentIter; |
| 172 | opserr << " current ratio (|dX|/|dXtot|): " << norm << " (max: " << tol << ")\n"; |
| 173 | } |
| 174 | } |
| 175 | |