Skip to content

Commit

Permalink
fvModels: Fix hang due to non-synchronised diagonal construction
Browse files Browse the repository at this point in the history
  • Loading branch information
Will Bainbridge committed Mar 26, 2024
1 parent a833a81 commit 49b0069
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
5 changes: 3 additions & 2 deletions src/finiteVolume/cfdTools/general/fvSource/fvTotalSource.C
Expand Up @@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2021-2023 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2021-2024 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
Expand Down Expand Up @@ -58,10 +58,11 @@ void Foam::fvTotalSource::addSource(fvMatrix<scalar>& eqn) const
eqn.dimensions() = S.dimensions();

// Apply the source
scalarField& eqnSource = eqn.source();
forAll(cells, i)
{
const scalar f = mesh().V()[cells[i]]/V;
eqn.source()[cells[i]] -= f*S.value();
eqnSource[cells[i]] -= f*S.value();
}
}

Expand Down
Expand Up @@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2021-2023 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2021-2024 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
Expand Down Expand Up @@ -60,11 +60,13 @@ void Foam::fvTotalSource::addSupType
);

// Apply the source
Field<Type>& eqnSource = eqn.source();
scalarField& eqnDiag = eqn.diag();
forAll(cells, i)
{
const scalar f = mesh().V()[cells[i]]/V;
eqn.source()[cells[i]] -= f*S.value()*sourceCoeff[i];
eqn.diag()[cells[i]] += f*S.value()*internalCoeff[i];
eqnSource[cells[i]] -= f*S.value()*sourceCoeff[i];
eqnDiag[cells[i]] += f*S.value()*internalCoeff[i];
}
}
else
Expand All @@ -76,10 +78,11 @@ void Foam::fvTotalSource::addSupType
);

// Apply the source
Field<Type>& eqnSource = eqn.source();
forAll(cells, i)
{
const scalar f = mesh().V()[cells[i]]/V;
eqn.source()[cells[i]] -= f*S.value()*value[i];
eqnSource[cells[i]] -= f*S.value()*value[i];
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/fvModels/derived/acceleration/acceleration.C
Expand Up @@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2018-2023 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2018-2024 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
Expand Down Expand Up @@ -77,10 +77,10 @@ void Foam::fv::acceleration::add

const labelUList cells = set_.cells();

vectorField& eqnSource = eqn.source();
forAll(cells, i)
{
const label celli = cells[i];
eqn.source()[celli] -= V[celli]*alphaRho[celli]*a;
eqnSource[cells[i]] -= V[cells[i]]*alphaRho[cells[i]]*a;
}
}

Expand Down
5 changes: 3 additions & 2 deletions src/fvModels/derived/heatSource/heatSource.C
Expand Up @@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2021-2023 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2021-2024 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
Expand Down Expand Up @@ -132,9 +132,10 @@ void Foam::fv::heatSource::addSup
const scalar t = mesh().time().userTimeValue();
const scalar q = q_->value(t);

scalarField& eqnSource = eqn.source();
forAll(cells, i)
{
eqn.source()[cells[i]] -= mesh().V()[cells[i]]*q;
eqnSource[cells[i]] -= mesh().V()[cells[i]]*q;
}
}

Expand Down

0 comments on commit 49b0069

Please sign in to comment.