From 68b129eb96c2985d2ee643f7c1139496dd90b696 Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Tue, 5 Mar 2013 17:02:53 +0000 Subject: [PATCH] [1D] Fixed singular Jacobian errors after grid modification Modification of the grid can interfere with the way the fixed temperature point is handled, leading to solver failures. To fix this, the temperature fixed point is checked and may be recalculated at the start of the solver. --- src/oneD/StFlow.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/oneD/StFlow.cpp b/src/oneD/StFlow.cpp index 037bfb14c..1a2b7551d 100644 --- a/src/oneD/StFlow.cpp +++ b/src/oneD/StFlow.cpp @@ -327,6 +327,30 @@ void StFlow::_finalize(const doublereal* x) if (e) { solveEnergyEqn(); } + + // If the domain contains the temperature fixed point, make sure that it + // is correctly set. This may be necessary when the grid has been modified + // externally. + if (m_tfixed != Undef) { + bool found_zfix = false; + for (size_t j = 0; j < m_points; j++) { + if (z(j) == m_zfixed) { + found_zfix = true; + break; + } + } + if (!found_zfix) { + for (size_t j = 0; j < m_points - 1; j++) { + // Find where the temperature profile crosses the current + // fixed temperature. + if ((T(x, j) - m_tfixed) * (T(x, j+1) - m_tfixed) <= 0.0) { + m_tfixed = T(x, j+1); + m_zfixed = z(j+1); + break; + } + } + } + } }