MCPcopy Create free account
hub / github.com/OpenSees/OpenSees / test

Method test

SRC/convergenceTest/CTestRelativeEnergyIncr.cpp:114–206  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 3

getBMethod · 0.80
getXMethod · 0.45
pNormMethod · 0.45

Tested by

no test coverage detected