CorrectPhi: Change the divU argument to autoPtr<volScalarField>
If divU is valid the velocity divergence is included in the pcorr equation. This simplifies the logic in multiphase moveMesh functions supporting incompressible (with or without mass sources) and compressible fluids.
This commit is contained in:
@ -9,7 +9,7 @@ CorrectPhi
|
||||
Uc,
|
||||
p,
|
||||
dimensionedScalar("rAUf", dimTime, 1),
|
||||
geometricZeroField(),
|
||||
autoPtr<volScalarField>(),
|
||||
pressureReference,
|
||||
pimple
|
||||
);
|
||||
|
||||
@ -66,8 +66,6 @@ void Foam::solvers::VoFSolver::moveMesh()
|
||||
correctUphiBCs(U_, phi, true);
|
||||
|
||||
if (incompressible())
|
||||
{
|
||||
if (divU.valid())
|
||||
{
|
||||
CorrectPhi
|
||||
(
|
||||
@ -75,26 +73,12 @@ void Foam::solvers::VoFSolver::moveMesh()
|
||||
U,
|
||||
p_rgh,
|
||||
surfaceScalarField("rAUf", fvc::interpolate(rAU())),
|
||||
divU(),
|
||||
divU,
|
||||
pressureReference(),
|
||||
pimple
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
CorrectPhi
|
||||
(
|
||||
phi,
|
||||
U,
|
||||
p_rgh,
|
||||
surfaceScalarField("rAUf", fvc::interpolate(rAU())),
|
||||
geometricZeroField(),
|
||||
pressureReference(),
|
||||
pimple
|
||||
);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CorrectPhi
|
||||
(
|
||||
|
||||
@ -54,7 +54,7 @@ void Foam::solvers::incompressibleFluid::moveMesh()
|
||||
U,
|
||||
p,
|
||||
dimensionedScalar("rAUf", dimTime, 1),
|
||||
geometricZeroField(),
|
||||
autoPtr<volScalarField>(),
|
||||
pressureReference,
|
||||
pimple
|
||||
);
|
||||
|
||||
@ -128,7 +128,7 @@ Foam::solvers::incompressibleMultiphaseVoF::incompressibleMultiphaseVoF
|
||||
U,
|
||||
p_rgh,
|
||||
surfaceScalarField("rAUf", fvc::interpolate(rAU())),
|
||||
geometricZeroField(),
|
||||
autoPtr<volScalarField>(),
|
||||
pressureReference(),
|
||||
pimple
|
||||
);
|
||||
@ -143,7 +143,7 @@ Foam::solvers::incompressibleMultiphaseVoF::incompressibleMultiphaseVoF
|
||||
U,
|
||||
p_rgh,
|
||||
dimensionedScalar(dimTime/rho.dimensions(), 1),
|
||||
geometricZeroField(),
|
||||
autoPtr<volScalarField>(),
|
||||
pressureReference(),
|
||||
pimple
|
||||
);
|
||||
|
||||
@ -113,7 +113,7 @@ Foam::solvers::incompressibleVoF::incompressibleVoF(fvMesh& mesh)
|
||||
U,
|
||||
p_rgh,
|
||||
surfaceScalarField("rAUf", fvc::interpolate(rAU())),
|
||||
geometricZeroField(),
|
||||
autoPtr<volScalarField>(),
|
||||
pressureReference(),
|
||||
pimple
|
||||
);
|
||||
@ -128,7 +128,7 @@ Foam::solvers::incompressibleVoF::incompressibleVoF(fvMesh& mesh)
|
||||
U,
|
||||
p_rgh,
|
||||
dimensionedScalar(dimTime/rho.dimensions(), 1),
|
||||
geometricZeroField(),
|
||||
autoPtr<volScalarField>(),
|
||||
pressureReference(),
|
||||
pimple
|
||||
);
|
||||
|
||||
@ -153,7 +153,7 @@ protected:
|
||||
//- Stored divU from the previous mesh so that it can be
|
||||
// mapped and used in correctPhi to ensure the corrected phi
|
||||
// has the same divergence
|
||||
tmp<volScalarField> divU;
|
||||
autoPtr<volScalarField> divU;
|
||||
|
||||
//- Read controls
|
||||
void readControls();
|
||||
|
||||
@ -519,10 +519,10 @@ Foam::MovingPhaseModel<BasePhaseModel>::K() const
|
||||
|
||||
|
||||
template<class BasePhaseModel>
|
||||
Foam::tmp<Foam::volScalarField>
|
||||
const Foam::autoPtr<Foam::volScalarField>&
|
||||
Foam::MovingPhaseModel<BasePhaseModel>::divU() const
|
||||
{
|
||||
return divU_.valid() ? tmp<volScalarField>(divU_()) : tmp<volScalarField>();
|
||||
return divU_;
|
||||
}
|
||||
|
||||
|
||||
@ -531,13 +531,13 @@ void Foam::MovingPhaseModel<BasePhaseModel>::divU(tmp<volScalarField> divU)
|
||||
{
|
||||
if (!divU_.valid())
|
||||
{
|
||||
divU_ = divU;
|
||||
divU_.ref().rename(IOobject::groupName("divU", this->name()));
|
||||
divU_.ref().checkIn();
|
||||
divU_ = divU.ptr();
|
||||
divU_().rename(IOobject::groupName("divU", this->name()));
|
||||
divU_().checkIn();
|
||||
}
|
||||
else
|
||||
{
|
||||
divU_.ref() = divU;
|
||||
divU_() = divU;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -119,7 +119,7 @@ protected:
|
||||
mutable tmp<surfaceScalarField> DUDtf_;
|
||||
|
||||
//- Dilatation rate
|
||||
tmp<volScalarField> divU_;
|
||||
autoPtr<volScalarField> divU_;
|
||||
|
||||
//- Turbulence model
|
||||
autoPtr<phaseCompressible::momentumTransportModel> momentumTransport_;
|
||||
@ -253,7 +253,7 @@ public:
|
||||
// Compressibility (variable density)
|
||||
|
||||
//- Return the phase dilatation rate (d(alpha)/dt + div(alpha*phi))
|
||||
virtual tmp<volScalarField> divU() const;
|
||||
virtual const autoPtr<volScalarField>& divU() const;
|
||||
|
||||
//- Set the phase dilatation rate (d(alpha)/dt + div(alpha*phi))
|
||||
virtual void divU(tmp<volScalarField> divU);
|
||||
|
||||
@ -259,10 +259,11 @@ Foam::StationaryPhaseModel<BasePhaseModel>::K() const
|
||||
|
||||
|
||||
template<class BasePhaseModel>
|
||||
Foam::tmp<Foam::volScalarField>
|
||||
const Foam::autoPtr<Foam::volScalarField>&
|
||||
Foam::StationaryPhaseModel<BasePhaseModel>::divU() const
|
||||
{
|
||||
return tmp<volScalarField>();
|
||||
static autoPtr<volScalarField> divU_;
|
||||
return divU_;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -136,7 +136,7 @@ public:
|
||||
// Compressibility (variable density)
|
||||
|
||||
//- Return the phase dilatation rate (d(alpha)/dt + div(alpha*phi))
|
||||
virtual tmp<volScalarField> divU() const;
|
||||
virtual const autoPtr<volScalarField>& divU() const;
|
||||
|
||||
//- Set the phase dilatation rate (d(alpha)/dt + div(alpha*phi))
|
||||
virtual void divU(tmp<volScalarField> divU);
|
||||
|
||||
@ -246,7 +246,7 @@ public:
|
||||
virtual bool isochoric() const = 0;
|
||||
|
||||
//- Return the phase dilatation rate (d(alpha)/dt + div(alpha*phi))
|
||||
virtual tmp<volScalarField> divU() const = 0;
|
||||
virtual const autoPtr<volScalarField>& divU() const = 0;
|
||||
|
||||
//- Set the phase dilatation rate (d(alpha)/dt + div(alpha*phi))
|
||||
virtual void divU(tmp<volScalarField> divU) = 0;
|
||||
|
||||
@ -728,7 +728,7 @@ void Foam::phaseSystem::correctBoundaryFlux()
|
||||
void Foam::phaseSystem::correctPhi
|
||||
(
|
||||
const volScalarField& p_rgh,
|
||||
const tmp<volScalarField>& divU,
|
||||
const autoPtr<volScalarField>& divU,
|
||||
const pressureReference& pressureReference,
|
||||
nonOrthogonalSolutionControl& pimple
|
||||
)
|
||||
@ -777,8 +777,6 @@ void Foam::phaseSystem::correctPhi
|
||||
}
|
||||
|
||||
if (incompressible())
|
||||
{
|
||||
if (divU.valid())
|
||||
{
|
||||
CorrectPhi
|
||||
(
|
||||
@ -786,26 +784,12 @@ void Foam::phaseSystem::correctPhi
|
||||
movingPhases()[0].U(),
|
||||
p_rgh,
|
||||
dimensionedScalar(dimTime/dimDensity, 1),
|
||||
divU(),
|
||||
divU,
|
||||
pressureReference,
|
||||
pimple
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
CorrectPhi
|
||||
(
|
||||
phi_,
|
||||
movingPhases()[0].U(),
|
||||
p_rgh,
|
||||
dimensionedScalar(dimTime/dimDensity, 1),
|
||||
geometricZeroField(),
|
||||
pressureReference,
|
||||
pimple
|
||||
);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
volScalarField psi
|
||||
(
|
||||
|
||||
@ -656,7 +656,7 @@ public:
|
||||
void correctPhi
|
||||
(
|
||||
const volScalarField& p_rgh,
|
||||
const tmp<volScalarField>& divU,
|
||||
const autoPtr<volScalarField>& divU,
|
||||
const pressureReference& pressureReference,
|
||||
nonOrthogonalSolutionControl& pimple
|
||||
);
|
||||
|
||||
@ -39,14 +39,14 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class RAUfType, class DivUType>
|
||||
template<class RAUfType>
|
||||
void Foam::CorrectPhi
|
||||
(
|
||||
surfaceScalarField& phi,
|
||||
const volVectorField& U,
|
||||
const volScalarField& p,
|
||||
const RAUfType& rAUf,
|
||||
const DivUType& divU,
|
||||
const autoPtr<volScalarField>& divU,
|
||||
const pressureReference& pressureReference,
|
||||
nonOrthogonalSolutionControl& pcorrControl
|
||||
)
|
||||
@ -98,7 +98,13 @@ void Foam::CorrectPhi
|
||||
// matches the divU provided (from previous iteration, time-step...)
|
||||
fvScalarMatrix pcorrEqn
|
||||
(
|
||||
fvm::laplacian(rAUf, pcorr) == fvc::div(phi) - divU
|
||||
fvm::laplacian(rAUf, pcorr)
|
||||
==
|
||||
(
|
||||
divU.valid()
|
||||
? fvc::div(phi) - divU()
|
||||
: fvc::div(phi)
|
||||
)
|
||||
);
|
||||
|
||||
pcorrEqn.setReference(pressureReference.refCell(), 0);
|
||||
@ -113,14 +119,14 @@ void Foam::CorrectPhi
|
||||
}
|
||||
|
||||
|
||||
template<class RAUfType, class DivRhoUType>
|
||||
template<class RAUfType>
|
||||
void Foam::CorrectPhi
|
||||
(
|
||||
surfaceScalarField& phi,
|
||||
const volScalarField& p,
|
||||
const volScalarField& psi,
|
||||
const RAUfType& rAUf,
|
||||
const DivRhoUType& divRhoU,
|
||||
const volScalarField& divRhoU,
|
||||
nonOrthogonalSolutionControl& pcorrControl
|
||||
)
|
||||
{
|
||||
|
||||
@ -70,26 +70,26 @@ namespace Foam
|
||||
const bool evaluateUBCs
|
||||
);
|
||||
|
||||
template<class RAUfType, class DivUType>
|
||||
template<class RAUfType>
|
||||
void CorrectPhi
|
||||
(
|
||||
surfaceScalarField& phi,
|
||||
const volVectorField& U,
|
||||
const volScalarField& p,
|
||||
const RAUfType& rAUf,
|
||||
const DivUType& divU,
|
||||
const autoPtr<volScalarField>& divU,
|
||||
const pressureReference& pressureReference,
|
||||
nonOrthogonalSolutionControl& pcorrControl
|
||||
);
|
||||
|
||||
template<class RAUfType, class DivRhoUType>
|
||||
template<class RAUfType>
|
||||
void CorrectPhi
|
||||
(
|
||||
surfaceScalarField& phi,
|
||||
const volScalarField& p,
|
||||
const volScalarField& psi,
|
||||
const RAUfType& rAUf,
|
||||
const DivRhoUType& divRhoU,
|
||||
const volScalarField& divRhoU,
|
||||
nonOrthogonalSolutionControl& pcorrControl
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user