ENH: Cloud patch interaction model updates

- MultiInteraction: updated to call info() function of child models
- PatchInteractionModel: added postEvolve hook
- KinematicCloud: call patchInteraction() postEvolve hook
This commit is contained in:
Andrew Heather
2020-08-20 12:32:08 +01:00
committed by Kutalmis Bercin
parent 7d897ee7a3
commit b25c4611cb
7 changed files with 99 additions and 12 deletions

View File

@ -244,6 +244,8 @@ void Foam::KinematicCloud<CloudType>::postEvolve
this->dispersion().cacheFields(false);
this->patchInteraction().postEvolve();
forces_.cacheFields(false);
functions_.postEvolve(td);

View File

@ -147,6 +147,7 @@ void Foam::patchInjectionBase::updateMesh(const polyMesh& mesh)
void Foam::patchInjectionBase::setPositionAndCell
(
const fvMesh& mesh,
const scalar fraction01,
Random& rnd,
vector& position,
label& cellOwner,
@ -154,23 +155,15 @@ void Foam::patchInjectionBase::setPositionAndCell
label& tetPti
)
{
scalar areaFraction = rnd.globalPosition(scalar(0), patchArea_);
if (cellOwners_.size() > 0)
{
// Determine which processor to inject from
label proci = 0;
forAllReverse(sumTriMagSf_, i)
{
if (areaFraction >= sumTriMagSf_[i])
{
proci = i;
break;
}
}
const label proci = whichProc(fraction01);
if (Pstream::myProcNo() == proci)
{
const scalar areaFraction = fraction01*patchArea_;
// Find corresponding decomposed face triangle
label trii = 0;
scalar offset = sumTriMagSf_[proci];
@ -271,4 +264,46 @@ void Foam::patchInjectionBase::setPositionAndCell
}
void Foam::patchInjectionBase::setPositionAndCell
(
const fvMesh& mesh,
Random& rnd,
vector& position,
label& cellOwner,
label& tetFacei,
label& tetPti
)
{
scalar fraction01 = rnd.globalSample01<scalar>();
setPositionAndCell
(
mesh,
fraction01,
rnd,
position,
cellOwner,
tetFacei,
tetPti
);
}
Foam::label Foam::patchInjectionBase::whichProc(const scalar fraction01) const
{
const scalar areaFraction = fraction01*patchArea_;
// Determine which processor to inject from
forAllReverse(sumTriMagSf_, i)
{
if (areaFraction >= sumTriMagSf_[i])
{
return i;
}
}
return 0;
}
// ************************************************************************* //

View File

@ -116,6 +116,19 @@ public:
//- Update patch geometry and derived info for injection locations
virtual void updateMesh(const polyMesh& mesh);
//- Set the injection position and owner cell, tetFace and tetPt
// Supply the fraction used to determine the location on the patch
void setPositionAndCell
(
const fvMesh& mesh,
const scalar fraction01,
Random& rnd,
vector& position,
label& cellOwner,
label& tetFacei,
label& tetPti
);
//- Set the injection position and owner cell, tetFace and tetPt
virtual void setPositionAndCell
(
@ -126,6 +139,9 @@ public:
label& tetFacei,
label& tetPti
);
//- Return the processor that has the location specified by the fraction
label whichProc(const scalar fraction01) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -176,4 +176,25 @@ bool Foam::MultiInteraction<CloudType>::correct
}
template<class CloudType>
void Foam::MultiInteraction<CloudType>::postEvolve()
{
for (auto& m : models_)
{
m.postEvolve();
}
}
template<class CloudType>
void Foam::MultiInteraction<CloudType>::info(Ostream& os)
{
for (auto& m : models_)
{
Info<< "Patch interaction model " << m.type() << ':' << endl;
m.info(os);
}
}
// ************************************************************************* //

View File

@ -148,6 +148,12 @@ public:
const polyPatch& pp,
bool& keepParticle
);
//- Post-evolve hook
virtual void postEvolve();
//- Write patch interaction info to stream
virtual void info(Ostream& os);
};

View File

@ -198,6 +198,11 @@ void Foam::PatchInteractionModel<CloudType>::addToEscapedParcels
}
template<class CloudType>
void Foam::PatchInteractionModel<CloudType>::postEvolve()
{}
template<class CloudType>
void Foam::PatchInteractionModel<CloudType>::info(Ostream& os)
{

View File

@ -181,8 +181,10 @@ public:
) = 0;
//- Add to escaped parcels
void addToEscapedParcels(const scalar mass);
virtual void addToEscapedParcels(const scalar mass);
//- Post-evolve hook
virtual void postEvolve();
//- Write patch interaction info to stream
virtual void info(Ostream& os);