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

Method test

SRC/convergenceTest/CTestFixedNumIter.cpp:105–173  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 3

getBMethod · 0.80
getXMethod · 0.45
pNormMethod · 0.45

Tested by

no test coverage detected