81 PrimaryVariables& nextValue,
82 const PrimaryVariables& currentValue,
83 const EqVector& update,
87 nextValue = currentValue;
94 constexpr Scalar max_percent_change = 0.2;
95 constexpr Scalar upper_bound = 1. + max_percent_change;
96 constexpr Scalar lower_bound = 1. - max_percent_change;
97 clampValue_(nextValue[pressure0Idx],
98 currentValue[pressure0Idx] * lower_bound,
99 currentValue[pressure0Idx] * upper_bound);
105 Scalar maxDeltaZ = 0.0;
106 Scalar sumDeltaZ = 0.0;
107 for (
unsigned compIdx = 0; compIdx < numComponents - 1; ++compIdx) {
108 maxDeltaZ = std::max(std::abs(update[z0Idx + compIdx]), maxDeltaZ);
109 sumDeltaZ += update[z0Idx + compIdx];
111 maxDeltaZ = std::max(std::abs(sumDeltaZ), maxDeltaZ);
115 constexpr Scalar deltaz_limit = 0.2;
116 if (maxDeltaZ > deltaz_limit) {
117 Scalar alpha = deltaz_limit / maxDeltaZ;
118 for (
unsigned compIdx = 0; compIdx < numComponents - 1; ++compIdx) {
119 nextValue[z0Idx + compIdx] = currentValue[z0Idx + compIdx] - alpha * update[z0Idx + compIdx];
125 for (
unsigned compIdx = 0; compIdx < numComponents - 1; ++compIdx) {
126 clampValue_(nextValue[z0Idx + compIdx], tol, 1-tol);