CorrectPhi: Separated correctUphiBCs to simplify and generalise the use of CorrectPhi

This commit is contained in:
Henry Weller
2021-03-01 17:11:05 +00:00
parent 6eb19d1b4a
commit be86c8ec0f
28 changed files with 140 additions and 155 deletions

View File

@ -131,14 +131,7 @@ int main(int argc, char *argv[])
if (correctPhi) if (correctPhi)
{ {
// Calculate absolute flux
// from the mapped surface velocity
phi = mesh.Sf() & rhoUf();
#include "correctPhi.H" #include "correctPhi.H"
// Make the fluxes relative to the mesh-motion
fvc::makeRelative(phi, rho, U);
} }
if (checkMeshCourantNo) if (checkMeshCourantNo)

View File

@ -1,12 +1,19 @@
// Calculate absolute flux
// from the mapped surface velocity
phi = mesh.Sf() & rhoUf();
correctUphiBCs(rho, U, phi, true);
CorrectPhi CorrectPhi
( (
U,
phi, phi,
p, p,
rho, rho,
psi, psi,
dimensionedScalar("rAUf", dimTime, 1), dimensionedScalar("rAUf", dimTime, 1),
divrhoU(), divrhoU(),
pimple, pimple
true
); );
// Make the fluxes relative to the mesh-motion
fvc::makeRelative(phi, rho, U);

View File

@ -124,14 +124,7 @@ int main(int argc, char *argv[])
if (correctPhi) if (correctPhi)
{ {
// Calculate absolute flux
// from the mapped surface velocity
phi = mesh.Sf() & rhoUf();
#include "correctPhi.H" #include "correctPhi.H"
// Make the fluxes relative to the mesh-motion
fvc::makeRelative(phi, rho, U);
} }
if (checkMeshCourantNo) if (checkMeshCourantNo)

View File

@ -128,14 +128,7 @@ int main(int argc, char *argv[])
if (correctPhi) if (correctPhi)
{ {
// Calculate absolute flux
// from the mapped surface velocity
phi = mesh.Sf() & rhoUf();
#include "correctPhi.H" #include "correctPhi.H"
// Make the fluxes relative to the mesh-motion
fvc::makeRelative(phi, rho, U);
} }
if (checkMeshCourantNo) if (checkMeshCourantNo)

View File

@ -1,12 +1,19 @@
// Calculate absolute flux
// from the mapped surface velocity
phi = mesh.Sf() & rhoUf();
correctUphiBCs(rho, U, phi, true);
CorrectPhi CorrectPhi
( (
U,
phi, phi,
p_rgh, p_rgh,
rho, rho,
psi, psi,
dimensionedScalar("rAUf", dimTime, 1), dimensionedScalar("rAUf", dimTime, 1),
divrhoU(), divrhoU(),
pimple, pimple
true
); );
// Make the fluxes relative to the mesh-motion
fvc::makeRelative(phi, rho, U);

View File

@ -1,12 +1,20 @@
// Calculate absolute flux
// from the mapped surface velocity
phi = mesh.Sf() & Uf();
correctUphiBCs(U, phi, true);
CorrectPhi CorrectPhi
( (
U,
phi, phi,
U,
p, p,
dimensionedScalar("rAUf", dimTime, 1), dimensionedScalar("rAUf", dimTime, 1),
geometricZeroField(), geometricZeroField(),
pimple, pimple
true
); );
#include "continuityErrs.H" #include "continuityErrs.H"
// Make the flux relative to the mesh motion
fvc::makeRelative(phi, U);

View File

@ -99,14 +99,7 @@ int main(int argc, char *argv[])
if (correctPhi) if (correctPhi)
{ {
// Calculate absolute flux
// from the mapped surface velocity
phi = mesh.Sf() & Uf();
#include "correctPhi.H" #include "correctPhi.H"
// Make the flux relative to the mesh motion
fvc::makeRelative(phi, U);
} }
if (checkMeshCourantNo) if (checkMeshCourantNo)

View File

@ -1,12 +1,19 @@
// Calculate absolute flux from the mapped surface velocity
phic = mesh.Sf() & Ucf();
correctUphiBCs(Uc, phic, true);
CorrectPhi CorrectPhi
( (
Uc,
phic, phic,
Uc,
p, p,
dimensionedScalar("rAUf", dimTime, 1), dimensionedScalar("rAUf", dimTime, 1),
geometricZeroField(), geometricZeroField(),
pimple, pimple
true
); );
#include "continuityErrs.H" #include "continuityErrs.H"
// Make the flux relative to the mesh motion
fvc::makeRelative(phic, Uc);

View File

@ -119,13 +119,7 @@ int main(int argc, char *argv[])
{ {
if (correctPhi) if (correctPhi)
{ {
// Calculate absolute flux from the mapped surface velocity
phic = mesh.Sf() & Ucf();
#include "correctPhic.H" #include "correctPhic.H"
// Make the flux relative to the mesh motion
fvc::makeRelative(phic, Uc);
} }
if (checkMeshCourantNo) if (checkMeshCourantNo)

View File

@ -126,14 +126,7 @@ int main(int argc, char *argv[])
if (correctPhi) if (correctPhi)
{ {
// Calculate absolute flux
// from the mapped surface velocity
phi = mesh.Sf() & rhoUf();
#include "../../compressible/rhoPimpleFoam/correctPhi.H" #include "../../compressible/rhoPimpleFoam/correctPhi.H"
// Make the fluxes relative to the mesh-motion
fvc::makeRelative(phi, rho, U);
} }
if (checkMeshCourantNo) if (checkMeshCourantNo)

View File

@ -125,14 +125,7 @@ int main(int argc, char *argv[])
if (correctPhi) if (correctPhi)
{ {
// Calculate absolute flux
// from the mapped surface velocity
phi = mesh.Sf() & rhoUf();
#include "../../compressible/rhoPimpleFoam/correctPhi.H" #include "../../compressible/rhoPimpleFoam/correctPhi.H"
// Make the fluxes relative to the mesh-motion
fvc::makeRelative(phi, rho, U);
} }
if (checkMeshCourantNo) if (checkMeshCourantNo)

View File

@ -122,14 +122,7 @@ int main(int argc, char *argv[])
if (correctPhi) if (correctPhi)
{ {
// Calculate absolute flux
// from the mapped surface velocity
phi = mesh.Sf() & rhoUf();
#include "../../compressible/rhoPimpleFoam/correctPhi.H" #include "../../compressible/rhoPimpleFoam/correctPhi.H"
// Make the fluxes relative to the mesh-motion
fvc::makeRelative(phi, rho, U);
} }
if (checkMeshCourantNo) if (checkMeshCourantNo)

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -80,13 +80,7 @@ int main(int argc, char *argv[])
if (mesh.changing() && correctPhi) if (mesh.changing() && correctPhi)
{ {
// Calculate absolute flux from the mapped surface velocity
phi = mesh.Sf() & Uf();
#include "correctPhi.H" #include "correctPhi.H"
// Make the flux relative to the mesh motion
fvc::makeRelative(phi, U);
} }
} }

View File

@ -1,3 +1,6 @@
// Calculate absolute flux from the mapped surface velocity
phi = mesh.Sf() & Uf();
correctUphiBCs(U, phi, true); correctUphiBCs(U, phi, true);
{ {
@ -36,3 +39,6 @@ correctUphiBCs(U, phi, true);
} }
} }
} }
// Make the flux relative to the mesh motion
fvc::makeRelative(phi, U);

View File

@ -2,15 +2,16 @@
// from the mapped surface velocity // from the mapped surface velocity
phi = mesh.Sf() & Uf(); phi = mesh.Sf() & Uf();
correctUphiBCs(U, phi, true);
CorrectPhi CorrectPhi
( (
U,
phi, phi,
U,
p_rgh, p_rgh,
surfaceScalarField("rAUf", fvc::interpolate(rAU())), surfaceScalarField("rAUf", fvc::interpolate(rAU())),
divU(), divU(),
pimple, pimple
true
); );
#include "continuityErrs.H" #include "continuityErrs.H"

View File

@ -2,30 +2,30 @@
// from the mapped surface velocity // from the mapped surface velocity
phi = mesh.Sf() & Uf(); phi = mesh.Sf() & Uf();
correctUphiBCs(U, phi, true);
if (divU.valid()) if (divU.valid())
{ {
CorrectPhi CorrectPhi
( (
U,
phi, phi,
U,
p_rgh, p_rgh,
surfaceScalarField("rAUf", fvc::interpolate(rAU())), surfaceScalarField("rAUf", fvc::interpolate(rAU())),
divU(), divU(),
pimple, pimple
true
); );
} }
else else
{ {
CorrectPhi CorrectPhi
( (
U,
phi, phi,
U,
p_rgh, p_rgh,
surfaceScalarField("rAUf", fvc::interpolate(rAU())), surfaceScalarField("rAUf", fvc::interpolate(rAU())),
geometricZeroField(), geometricZeroField(),
pimple, pimple
true
); );
} }

View File

@ -20,28 +20,30 @@ if
dimensionedScalar(dimTime/dimDensity, 1) dimensionedScalar(dimTime/dimDensity, 1)
); );
correctUphiBCs(U, phi, true);
CorrectPhi CorrectPhi
( (
U,
phi, phi,
U,
p_rgh, p_rgh,
surfaceScalarField("rAUf", fvc::interpolate(rAU())), surfaceScalarField("rAUf", fvc::interpolate(rAU())),
geometricZeroField(), geometricZeroField(),
pimple, pimple
false
); );
} }
else else
{ {
correctUphiBCs(U, phi, true);
CorrectPhi CorrectPhi
( (
U,
phi, phi,
U,
p_rgh, p_rgh,
dimensionedScalar(dimTime/rho.dimensions(), 1), dimensionedScalar(dimTime/rho.dimensions(), 1),
geometricZeroField(), geometricZeroField(),
pimple, pimple
false
); );
} }
} }

View File

@ -1,12 +1,20 @@
// Calculate absolute flux
// from the mapped surface velocity
phi = mesh.Sf() & Uf();
correctUphiBCs(U, phi, true);
CorrectPhi CorrectPhi
( (
U,
phi, phi,
U,
p_rgh, p_rgh,
surfaceScalarField("rAUf", fvc::interpolate(rAU())), surfaceScalarField("rAUf", fvc::interpolate(rAU())),
geometricZeroField(), geometricZeroField(),
pimple, pimple
true
); );
#include "continuityErrs.H" #include "continuityErrs.H"
// Make the flux relative to the mesh motion
fvc::makeRelative(phi, U);

View File

@ -16,30 +16,32 @@ if (correctPhi)
dimensionedScalar(dimTime/dimDensity, 1) dimensionedScalar(dimTime/dimDensity, 1)
); );
correctUphiBCs(U, phi, true);
CorrectPhi CorrectPhi
( (
U,
phi, phi,
U,
p_rgh, p_rgh,
surfaceScalarField("rAUf", fvc::interpolate(rAU())), surfaceScalarField("rAUf", fvc::interpolate(rAU())),
geometricZeroField(), geometricZeroField(),
pimple, pimple
false
); );
#include "continuityErrs.H" #include "continuityErrs.H"
} }
else else
{ {
correctUphiBCs(U, phi, true);
CorrectPhi CorrectPhi
( (
U,
phi, phi,
U,
p_rgh, p_rgh,
dimensionedScalar(dimTime/rho.dimensions(), 1), dimensionedScalar(dimTime/rho.dimensions(), 1),
geometricZeroField(), geometricZeroField(),
pimple, pimple
false
); );
#include "continuityErrs.H" #include "continuityErrs.H"

View File

@ -106,15 +106,8 @@ int main(int argc, char *argv[])
if (correctPhi) if (correctPhi)
{ {
// Calculate absolute flux
// from the mapped surface velocity
phi = mesh.Sf() & Uf();
#include "correctPhi.H" #include "correctPhi.H"
// Make the flux relative to the mesh motion
fvc::makeRelative(phi, U);
mixture.correct(); mixture.correct();
} }

View File

@ -1,12 +1,20 @@
// Calculate absolute flux
// from the mapped surface velocity
phi = mesh.Sf() & Uf();
correctUphiBCs(U, phi, true);
CorrectPhi CorrectPhi
( (
U,
phi, phi,
U,
p_rgh, p_rgh,
surfaceScalarField("rAUf", fvc::interpolate(rAU())), surfaceScalarField("rAUf", fvc::interpolate(rAU())),
geometricZeroField(), geometricZeroField(),
pimple, pimple
true
); );
#include "continuityErrs.H" #include "continuityErrs.H"
// Make the flux relative to the mesh motion
fvc::makeRelative(phi, U);

View File

@ -16,30 +16,32 @@ if (correctPhi)
dimensionedScalar(dimTime/dimDensity, 1) dimensionedScalar(dimTime/dimDensity, 1)
); );
correctUphiBCs(U, phi, true);
CorrectPhi CorrectPhi
( (
U,
phi, phi,
U,
p_rgh, p_rgh,
surfaceScalarField("rAUf", fvc::interpolate(rAU())), surfaceScalarField("rAUf", fvc::interpolate(rAU())),
geometricZeroField(), geometricZeroField(),
pimple, pimple
false
); );
#include "continuityErrs.H" #include "continuityErrs.H"
} }
else else
{ {
correctUphiBCs(U, phi, true);
CorrectPhi CorrectPhi
( (
U,
phi, phi,
U,
p_rgh, p_rgh,
dimensionedScalar(dimTime/rho.dimensions(), 1), dimensionedScalar(dimTime/rho.dimensions(), 1),
geometricZeroField(), geometricZeroField(),
pimple, pimple
false
); );
#include "continuityErrs.H" #include "continuityErrs.H"

View File

@ -100,14 +100,7 @@ int main(int argc, char *argv[])
if (correctPhi) if (correctPhi)
{ {
// Calculate absolute flux
// from the mapped surface velocity
phi = mesh.Sf() & Uf();
#include "correctPhi.H" #include "correctPhi.H"
// Make the flux relative to the mesh motion
fvc::makeRelative(phi, U);
} }
mixture.correct(); mixture.correct();

View File

@ -1,12 +1,20 @@
// Calculate absolute flux
// from the mapped surface velocity
phi = mesh.Sf() & Uf();
correctUphiBCs(U, phi, true);
CorrectPhi CorrectPhi
( (
U,
phi, phi,
U,
p_gh, p_gh,
surfaceScalarField("rAUf", fvc::interpolate(rAU)), surfaceScalarField("rAUf", fvc::interpolate(rAU)),
geometricZeroField(), geometricZeroField(),
pimple, pimple
true
); );
#include "continuityErrs.H" #include "continuityErrs.H"
// Make the flux relative to the mesh motion
fvc::makeRelative(phi, U);

View File

@ -0,0 +1,14 @@
if (!runTime.restart() &&correctPhi)
{
correctUphiBCs(U, phi, true);
CorrectPhi
(
phi,
U,
p_gh,
surfaceScalarField("rAUf", fvc::interpolate(rAU)),
geometricZeroField(),
pimple
);
}

View File

@ -73,10 +73,7 @@ int main(int argc, char *argv[])
dimensionedScalar(dimTime, 1.0) dimensionedScalar(dimTime, 1.0)
); );
if (correctPhi) #include "initCorrectPhi.H"
{
#include "correctPhi.H"
}
#include "createUfIfPresent.H" #include "createUfIfPresent.H"
@ -115,14 +112,7 @@ int main(int argc, char *argv[])
if (correctPhi) if (correctPhi)
{ {
// Calculate absolute flux
// from the mapped surface velocity
phi = mesh.Sf() & Uf();
#include "correctPhi.H" #include "correctPhi.H"
// Make the flux relative to the mesh motion
fvc::makeRelative(phi, U);
} }
if (checkMeshCourantNo) if (checkMeshCourantNo)

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2015-2019 OpenFOAM Foundation \\ / A nd | Copyright (C) 2015-2021 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -41,20 +41,17 @@ License
template<class RAUfType, class DivUType> template<class RAUfType, class DivUType>
void Foam::CorrectPhi void Foam::CorrectPhi
( (
volVectorField& U,
surfaceScalarField& phi, surfaceScalarField& phi,
const volVectorField& U,
const volScalarField& p, const volScalarField& p,
const RAUfType& rAUf, const RAUfType& rAUf,
const DivUType& divU, const DivUType& divU,
nonOrthogonalSolutionControl& pcorrControl, nonOrthogonalSolutionControl& pcorrControl
const bool evaluateUBCs
) )
{ {
const fvMesh& mesh = U.mesh(); const fvMesh& mesh = phi.mesh();
const Time& runTime = mesh.time(); const Time& runTime = mesh.time();
correctUphiBCs(U, phi, evaluateUBCs);
// Initialize BCs list for pcorr to zero-gradient // Initialize BCs list for pcorr to zero-gradient
wordList pcorrTypes wordList pcorrTypes
( (
@ -117,22 +114,18 @@ void Foam::CorrectPhi
template<class RAUfType, class DivRhoUType> template<class RAUfType, class DivRhoUType>
void Foam::CorrectPhi void Foam::CorrectPhi
( (
volVectorField& U,
surfaceScalarField& phi, surfaceScalarField& phi,
const volScalarField& p, const volScalarField& p,
const volScalarField& rho, const volScalarField& rho,
const volScalarField& psi, const volScalarField& psi,
const RAUfType& rAUf, const RAUfType& rAUf,
const DivRhoUType& divRhoU, const DivRhoUType& divRhoU,
nonOrthogonalSolutionControl& pcorrControl, nonOrthogonalSolutionControl& pcorrControl
const bool evaluateUBCs
) )
{ {
const fvMesh& mesh = U.mesh(); const fvMesh& mesh = phi.mesh();
const Time& runTime = mesh.time(); const Time& runTime = mesh.time();
correctUphiBCs(rho, U, phi, evaluateUBCs);
// Initialize BCs list for pcorr to zero-gradient // Initialize BCs list for pcorr to zero-gradient
wordList pcorrTypes wordList pcorrTypes
( (

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2015-2019 OpenFOAM Foundation \\ / A nd | Copyright (C) 2015-2021 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -72,27 +72,24 @@ namespace Foam
template<class RAUfType, class DivUType> template<class RAUfType, class DivUType>
void CorrectPhi void CorrectPhi
( (
volVectorField& U,
surfaceScalarField& phi, surfaceScalarField& phi,
const volVectorField& U,
const volScalarField& p, const volScalarField& p,
const RAUfType& rAUf, const RAUfType& rAUf,
const DivUType& divU, const DivUType& divU,
nonOrthogonalSolutionControl& pcorrControl, nonOrthogonalSolutionControl& pcorrControl
const bool evaluateUBCs
); );
template<class RAUfType, class DivRhoUType> template<class RAUfType, class DivRhoUType>
void CorrectPhi void CorrectPhi
( (
volVectorField& U,
surfaceScalarField& phi, surfaceScalarField& phi,
const volScalarField& p, const volScalarField& p,
const volScalarField& rho, const volScalarField& rho,
const volScalarField& psi, const volScalarField& psi,
const RAUfType& rAUf, const RAUfType& rAUf,
const DivRhoUType& divRhoU, const DivRhoUType& divRhoU,
nonOrthogonalSolutionControl& pcorrControl, nonOrthogonalSolutionControl& pcorrControl
const bool evaluateUBCs
); );
} }