BUG: fvMatrix: avoiding dupolicate adjustment. Fixes #2658

This commit is contained in:
mattijs 2022-12-19 11:47:15 +00:00
parent 87cff55f9e
commit 5fa37fb41c
2 changed files with 32 additions and 15 deletions

View File

@ -328,14 +328,11 @@ void Foam::faMatrix<Type>::setValuesFromList
GeometricField<Type, faPatchField, areaMesh>&
>(psi_).primitiveFieldRef();
forAll(faceLabels, i)
{
const label facei = faceLabels[i];
const Type& value = values[i];
psi[facei] = value;
source_[facei] = value*Diag[facei];
}
// Following actions:
// - adjust local field psi
// - set local matrix to be diagonal (so adjust source)
// - cut connections to neighbours
// - make (on non-adjusted cells) contribution explicit
if (symmetric() || asymmetric())
{
@ -392,6 +389,17 @@ void Foam::faMatrix<Type>::setValuesFromList
}
}
}
// Note: above loop might have affected source terms on adjusted cells
// so make sure to adjust them afterwards
forAll(faceLabels, i)
{
const label facei = faceLabels[i];
const Type& value = values[i];
psi[facei] = value;
source_[facei] = value*Diag[facei];
}
}

View File

@ -242,14 +242,12 @@ void Foam::fvMatrix<Type>::setValuesFromList
GeometricField<Type, fvPatchField, volMesh>&
>(psi_).primitiveFieldRef();
forAll(cellLabels, i)
{
const label celli = cellLabels[i];
const Type& value = values[i];
psi[celli] = value;
source_[celli] = value*Diag[celli];
}
// Following actions:
// - adjust local field psi
// - set local matrix to be diagonal (so adjust source)
// - cut connections to neighbours
// - make (on non-adjusted cells) contribution explicit
if (symmetric() || asymmetric())
{
@ -306,6 +304,17 @@ void Foam::fvMatrix<Type>::setValuesFromList
}
}
}
// Note: above loop might have affected source terms on adjusted cells
// so make sure to adjust them afterwards
forAll(cellLabels, i)
{
const label celli = cellLabels[i];
const Type& value = values[i];
psi[celli] = value;
source_[celli] = value*Diag[celli];
}
}