Commit 5968f514 authored by Spencer Sherwin's avatar Spencer Sherwin
Browse files

Merge branch 'fix/iterative-rhs-magnitude' into 'master'

Fix/iterative rhs magnitude

This MR fixes a bug in the calculation of the RHS vector magnitude used to scale the tolerance calculation, which resulted in an artificially higher tolerance being used.

Also fixes a bug in the verbose iteration count output of the CG algorithm when no iterations are performed.

See merge request !721
parents 40452dc8 903c4bd8
......@@ -34,6 +34,7 @@ v4.4.0
- Enabled MUMPS support in PETSc if a Fortran compiler was found and added 3D
support to the Helmholtz smoother used e.g. in FieldConverts C0Projection
module (!714)
- Fix bug in the calculation of the RHS magnitude in CG solver (!721)
- Fix bug in CMake Homebrew and MacPorts detection for OS X (!729)
**ADRSolver:**
......
......@@ -418,6 +418,8 @@ namespace Nektar
Set_Rhs_Magnitude(inGlob);
}
m_totalIterations = 0;
// If input residual is less than tolerance skip solve.
if (eps < m_tolerance * m_tolerance * m_rhs_magnitude)
{
......@@ -432,7 +434,6 @@ namespace Nektar
return;
}
m_totalIterations = 1;
m_precon->DoPreconditioner(r_A, tmp = w_A + nDir);
v_DoMatrixMultiply(w_A, s_A);
......@@ -451,11 +452,12 @@ namespace Nektar
vComm->AllReduce(vExchange, Nektar::LibUtilities::ReduceSum);
rho = vExchange[0];
mu = vExchange[1];
min_resid = m_rhs_magnitude;
beta = 0.0;
alpha = rho/mu;
rho = vExchange[0];
mu = vExchange[1];
min_resid = m_rhs_magnitude;
beta = 0.0;
alpha = rho/mu;
m_totalIterations = 1;
// Continue until convergence
while (true)
......@@ -541,8 +543,12 @@ namespace Nektar
void GlobalLinSysIterative::Set_Rhs_Magnitude(
const NekVector<NekDouble> &pIn)
{
Array<OneD, NekDouble> vExchange(1);
vExchange[0] = Vmath::Dot(pIn.GetDimension(),&pIn[0],&pIn[0]);
Array<OneD, NekDouble> vExchange(1, 0.0);
if (m_map.num_elements() > 0)
{
vExchange[0] = Vmath::Dot2(pIn.GetDimension(),
&pIn[0],&pIn[0],&m_map[0]);
}
m_expList.lock()->GetComm()->GetRowComm()->AllReduce(
vExchange, Nektar::LibUtilities::ReduceSum);
......
......@@ -9,20 +9,14 @@
</files>
<metrics>
<metric type="L2" id="1">
L 2 error (variable u) : 9.90752e-06
L inf error (variable u) : 1.41153e-05
L 2 error (variable v) : 4.56171e-10
L inf error (variable v) : 1.45252e-09
L 2 error (variable p) : 1.50907e-07
L inf error (variable p) : 5.30544e-07
<value variable="u" tolerance="1e-8">9.90752e-06</value>
<value variable="v" tolerance="1e-8">4.56171e-10</value>
<value variable="p" tolerance="1e-8">1.50907e-07</value>
<value variable="u" tolerance="1e-8">9.9054e-06</value>
<value variable="v" tolerance="1e-8">2.96756e-10</value>
<value variable="p" tolerance="1e-8">2.55815e-08</value>
</metric>
<metric type="Linf" id="2">
<value variable="u" tolerance="1e-8">1.41153e-05</value>
<value variable="v" tolerance="1e-8">1.45252e-09</value>
<value variable="p" tolerance="1e-8">5.30544e-07</value>
<value variable="u" tolerance="1e-8">1.40541e-05</value>
<value variable="v" tolerance="1e-8">8.20843e-10</value>
<value variable="p" tolerance="1e-8">2.34497e-07</value>
</metric>
</metrics>
</test>
<?xml version="1.0" encoding="utf-8" ?>
<test>
<description>Kovasznay Flow 3D homogeneous 1D, P=4-9, 20 Fourier modes with HDF5 input - Skew-Symmetric advection(MVM)</description>
<description>Kovasznay Flow 3D homogeneous 1D, P=4-9, 20 Fourier modes in parallel with HDF5 input - Skew-Symmetric advection(MVM)</description>
<executable>IncNavierStokesSolver</executable>
<parameters>KovaFlow_3DH1D_P5_20modes_MVM_hdf5.xml</parameters>
<processes>2</processes>
......@@ -10,16 +10,16 @@
</files>
<metrics>
<metric type="L2" id="1">
<value variable="u" tolerance="1e-12">1.10175e-05</value>
<value variable="v" tolerance="1e-12">6.64294e-06</value>
<value variable="w" tolerance="1e-12">5.74527e-06</value>
<value variable="p" tolerance="1e-8">6.43048e-05</value>
<value variable="u" tolerance="1e-12">1.10128e-05</value>
<value variable="v" tolerance="1e-12">6.64551e-06</value>
<value variable="w" tolerance="1e-12">5.74741e-06</value>
<value variable="p" tolerance="1e-8">6.45012e-05</value>
</metric>
<metric type="Linf" id="2">
<value variable="u" tolerance="1e-12">3.31884e-05</value>
<value variable="v" tolerance="1e-12">2.5058e-05</value>
<value variable="w" tolerance="1e-12">1.70132e-05</value>
<value variable="p" tolerance="1e-8">0.000138713</value>
<value variable="u" tolerance="1e-12">3.3134e-05</value>
<value variable="v" tolerance="1e-12">2.51101e-05</value>
<value variable="w" tolerance="1e-12">1.70084e-05</value>
<value variable="p" tolerance="1e-8">0.000138221</value>
</metric>
</metrics>
</test>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment