135 PrimaryVariables& nextValue,
136 const PrimaryVariables& currentValue,
137 const EqVector& update,
141 nextValue = currentValue;
149 Scalar sumSatDelta = 0.0;
150 Scalar maxSatDelta = 0.0;
151 for (
unsigned phaseIdx = 0; phaseIdx < numPhases - 1; ++phaseIdx) {
152 maxSatDelta = std::max(std::abs(update[saturation0Idx + phaseIdx]),
154 sumSatDelta += update[saturation0Idx + phaseIdx];
156 maxSatDelta = std::max(std::abs(-sumSatDelta), maxSatDelta);
158 if (maxSatDelta > 0.2) {
159 const Scalar alpha = 0.2 / maxSatDelta;
160 for (
unsigned phaseIdx = 0; phaseIdx < numPhases - 1; ++phaseIdx) {
161 nextValue[saturation0Idx + phaseIdx] =
162 currentValue[saturation0Idx + phaseIdx] -
163 alpha * update[saturation0Idx + phaseIdx];
168 clampValue_(nextValue[pressure0Idx],
169 currentValue[pressure0Idx] * 0.8,
170 currentValue[pressure0Idx] * 1.2);
173 for (
unsigned compIdx = 0; compIdx < numComponents; ++compIdx) {
174 Scalar& val = nextValue[fugacity0Idx + compIdx];
175 const Scalar oldVal = currentValue[fugacity0Idx + compIdx];
180 const Scalar minPhi =
181 std::max(this->problem().model().minActivityCoeff(globalDofIdx, compIdx),
182 0.001 * currentValue[pressure0Idx]);
186 const Scalar maxDelta = 0.7 * minPhi;
187 clampValue_(val, oldVal - maxDelta, oldVal + maxDelta);
190 val = std::max(val, 0.0);
195 if (this->numIterations_ < 3) {
197 for (
unsigned compIdx = 0; compIdx < numComponents; ++compIdx) {
198 Scalar& val = nextValue[fugacity0Idx + compIdx];
199 const Scalar oldVal = currentValue[fugacity0Idx + compIdx];
200 const Scalar minPhi = this->problem().model().minActivityCoeff(globalDofIdx, compIdx);
201 if (oldVal < 1.0 * minPhi && val > 1.0 * minPhi) {
204 else if (oldVal > 0.0 && val < 0.0) {
210 for (
unsigned phaseIdx = 0; phaseIdx < numPhases - 1; ++phaseIdx) {
211 Scalar& val = nextValue[saturation0Idx + phaseIdx];
212 const Scalar oldVal = currentValue[saturation0Idx + phaseIdx];
213 if (oldVal < 1.0 && val > 1.0) {
216 else if (oldVal > 0.0 && val < 0.0) {