Skip to content

Commit

Permalink
fvModels: clouds: Extend to work with incompressible solvers
Browse files Browse the repository at this point in the history
  • Loading branch information
Will Bainbridge committed Aug 24, 2021
1 parent a33a4d7 commit 5f11467
Show file tree
Hide file tree
Showing 3 changed files with 228 additions and 48 deletions.
4 changes: 2 additions & 2 deletions src/functionObjects/lagrangian/particles/particles.H
Expand Up @@ -25,8 +25,8 @@ Class
Foam::functionObjects::particles
Description
This functionObject tracks a uncoupled kinematic particle cloud in the
specified velocity field of an incompressible flow (laminar, RANS or LES).
This functionObject tracks a particle cloud in the specified velocity field
of an incompressible flow (laminar, RANS or LES).
It may be used in conjunction with any transient single-phase incompressible
flow solver such as pisoFoam or pimpleFoam and tracks the particles or
Expand Down
197 changes: 158 additions & 39 deletions src/lagrangian/parcel/fvModels/clouds.C
Expand Up @@ -57,16 +57,87 @@ Foam::fv::clouds::clouds
)
:
fvModel(sourceName, modelType, dict, mesh),
carrierThermo_
g_
(
mesh.lookupObject<fluidThermo>(physicalProperties::typeName)
IOobject
(
"g",
mesh.time().constant(),
mesh,
IOobject::READ_IF_PRESENT,
IOobject::NO_WRITE
),
dimensionedVector(dimAcceleration, Zero)
),
carrierHasThermo_
(
mesh.foundObject<fluidThermo>(physicalProperties::typeName)
),
tCarrierThermo_
(
carrierHasThermo_
? tmpNrc<fluidThermo>
(
mesh.lookupObject<fluidThermo>(physicalProperties::typeName)
)
: tmpNrc<fluidThermo>(nullptr)
),
tCarrierViscosity_
(
carrierHasThermo_
? tmpNrc<viscosityModel>(nullptr)
: tmpNrc<viscosityModel>
(
mesh.lookupObject<viscosityModel>(physicalProperties::typeName)
)
),
clouds_
tRho_
(
mesh.lookupObject<volScalarField>("rho"),
mesh.lookupObject<volVectorField>("U"),
mesh.lookupObject<uniformDimensionedVectorField>("g"),
carrierThermo_
carrierHasThermo_
? tmp<volScalarField>(nullptr)
: tmp<volScalarField>
(
new volScalarField
(
IOobject
(
"rho",
mesh.time().timeName(),
mesh
),
mesh,
dimensionedScalar("rho", dimDensity, tCarrierViscosity_())
)
)
),
tMu_
(
carrierHasThermo_
? tmp<volScalarField>(nullptr)
: tmp<volScalarField>
(
new volScalarField("mu", tRho_()*tCarrierViscosity_().nu())
)
),
rhoName_(dict.lookupOrDefault<word>("rho", "rho")),
UName_(dict.lookupOrDefault<word>("U", "U")),
cloudsPtr_
(
carrierHasThermo_
? new parcelCloudList
(
mesh.lookupObject<volScalarField>(rhoName_),
mesh.lookupObject<volVectorField>(UName_),
g_,
tCarrierThermo_()
)
: new parcelCloudList
(
tRho_(),
mesh.lookupObject<volVectorField>(UName_),
tMu_(),
g_
)
),
curTimeIndex_(-1)
{}
Expand All @@ -76,20 +147,29 @@ Foam::fv::clouds::clouds

Foam::wordList Foam::fv::clouds::addSupFields() const
{
wordList fieldNames({"rho", "U", carrierThermo_.he().name()});
wordList fieldNames(1, UName_);

if (isA<basicSpecieMixture>(carrierThermo_))
if (carrierHasThermo_)
{
const basicSpecieMixture& composition =
refCast<const basicSpecieMixture>(carrierThermo_);
const fluidThermo& carrierThermo = tCarrierThermo_();

fieldNames.append(rhoName_);

const PtrList<volScalarField>& Y = composition.Y();
fieldNames.append(carrierThermo.he().name());

forAll(Y, i)
if (isA<basicSpecieMixture>(carrierThermo))
{
if (composition.solve(i))
const basicSpecieMixture& composition =
refCast<const basicSpecieMixture>(carrierThermo);

const PtrList<volScalarField>& Y = composition.Y();

forAll(Y, i)
{
fieldNames.append(Y[i].name());
if (composition.solve(i))
{
fieldNames.append(Y[i].name());
}
}
}
}
Expand All @@ -105,7 +185,12 @@ void Foam::fv::clouds::correct()
return;
}

clouds_.evolve();
if (!carrierHasThermo_)
{
tMu_.ref() = tRho_()*tCarrierViscosity_().nu();
}

cloudsPtr_().evolve();

curTimeIndex_ = mesh().time().timeIndex();
}
Expand All @@ -122,16 +207,18 @@ void Foam::fv::clouds::addSup
Info<< type() << ": applying source to " << eqn.psi().name() << endl;
}

if (fieldName == "rho")
{
eqn += clouds_.Srho(eqn.psi());
}
else
if (!carrierHasThermo_)
{
FatalErrorInFunction
<< "Support for field " << fieldName << " is not implemented"
<< "Applying source to compressible equation when carrier thermo "
<< "is not available"
<< exit(FatalError);
}

if (fieldName == rhoName_)
{
eqn += cloudsPtr_().Srho(eqn.psi());
}
}


Expand All @@ -147,35 +234,65 @@ void Foam::fv::clouds::addSup
Info<< type() << ": applying source to " << eqn.psi().name() << endl;
}

if (fieldName == "rho")
if (!carrierHasThermo_)
{
FatalErrorInFunction
<< "Applying source to compressible equation when carrier thermo "
<< "is not available"
<< exit(FatalError);
}

const fluidThermo& carrierThermo = tCarrierThermo_();

if (fieldName == rhoName_)
{
eqn += clouds_.Srho(eqn.psi());
eqn += cloudsPtr_().Srho(eqn.psi());
}
else if (fieldName == carrierThermo_.he().name())
else if (fieldName == carrierThermo.he().name())
{
eqn += clouds_.Sh(eqn.psi());
eqn += cloudsPtr_().Sh(eqn.psi());
}
else if
(
isA<basicSpecieMixture>(carrierThermo_)
&& refCast<const basicSpecieMixture>(carrierThermo_).contains
isA<basicSpecieMixture>(carrierThermo)
&& refCast<const basicSpecieMixture>(carrierThermo).contains
(
eqn.psi().name()
)
)
{
eqn += clouds_.SYi
eqn += cloudsPtr_().SYi
(
refCast<const basicSpecieMixture>(carrierThermo_).index(eqn.psi()),
refCast<const basicSpecieMixture>(carrierThermo).index(eqn.psi()),
eqn.psi()
);
}
else
}


void Foam::fv::clouds::addSup
(
fvMatrix<vector>& eqn,
const word& fieldName
) const
{
if (debug)
{
Info<< type() << ": applying source to " << eqn.psi().name() << endl;
}

if (carrierHasThermo_)
{
FatalErrorInFunction
<< "Support for field " << fieldName << " is not implemented"
<< "Applying source to incompressible equation when carrier thermo "
<< "is available"
<< exit(FatalError);
}

if (fieldName == UName_)
{
eqn += cloudsPtr_().SU(eqn.psi())/tRho_();
}
}


Expand All @@ -191,23 +308,25 @@ void Foam::fv::clouds::addSup
Info<< type() << ": applying source to " << eqn.psi().name() << endl;
}

if (fieldName == "U")
{
eqn += clouds_.SU(eqn.psi());
}
else
if (!carrierHasThermo_)
{
FatalErrorInFunction
<< "Support for field " << fieldName << " is not implemented"
<< "Applying source to compressible equation when carrier thermo "
<< "is not available"
<< exit(FatalError);
}

if (fieldName == UName_)
{
eqn += cloudsPtr_().SU(eqn.psi());
}
}


void Foam::fv::clouds::preUpdateMesh()
{
// Store the particle positions
clouds_.storeGlobalPositions();
cloudsPtr_().storeGlobalPositions();
}


Expand Down

0 comments on commit 5f11467

Please sign in to comment.