mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
STYLE: improve robustness of wall interactions code (issue #737)
This commit is contained in:
@ -37,21 +37,23 @@ Foam::LocalInteraction<CloudType>::LocalInteraction
|
|||||||
PatchInteractionModel<CloudType>(dict, cloud, typeName),
|
PatchInteractionModel<CloudType>(dict, cloud, typeName),
|
||||||
patchData_(cloud.mesh(), this->coeffDict()),
|
patchData_(cloud.mesh(), this->coeffDict()),
|
||||||
nEscape_(patchData_.size()),
|
nEscape_(patchData_.size()),
|
||||||
massEscape_(patchData_.size()),
|
massEscape_(nEscape_.size()),
|
||||||
nStick_(patchData_.size()),
|
nStick_(nEscape_.size()),
|
||||||
massStick_(patchData_.size()),
|
massStick_(nEscape_.size()),
|
||||||
writeFields_(this->coeffDict().lookupOrDefault("writeFields", false)),
|
writeFields_(this->coeffDict().lookupOrDefault("writeFields", false)),
|
||||||
outputByInjectorId_(this->coeffDict().lookupOrDefault("outputByInjectorId", false)),
|
injIdToIndex_(),
|
||||||
injIdToIndex_(cloud.injectors().size()),
|
|
||||||
massEscapePtr_(nullptr),
|
massEscapePtr_(nullptr),
|
||||||
massStickPtr_(nullptr)
|
massStickPtr_(nullptr)
|
||||||
{
|
{
|
||||||
|
const bool outputByInjectorId
|
||||||
|
= this->coeffDict().lookupOrDefault("outputByInjectorId", false);
|
||||||
|
|
||||||
if (writeFields_)
|
if (writeFields_)
|
||||||
{
|
{
|
||||||
word massEscapeName(this->owner().name() + ":massEscape");
|
Info<< " Interaction fields will be written to "
|
||||||
word massStickName(this->owner().name() + ":massStick");
|
<< this->owner().name() << ":massEscape"
|
||||||
Info<< " Interaction fields will be written to " << massEscapeName
|
<< " and "
|
||||||
<< " and " << massStickName << endl;
|
<< this->owner().name() << ":massStick" << endl;
|
||||||
|
|
||||||
(void)massEscape();
|
(void)massEscape();
|
||||||
(void)massStick();
|
(void)massStick();
|
||||||
@ -61,7 +63,23 @@ Foam::LocalInteraction<CloudType>::LocalInteraction
|
|||||||
Info<< " Interaction fields will not be written" << endl;
|
Info<< " Interaction fields will not be written" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check that interactions are valid/specified
|
// Determine the number of injectors and the injector mapping
|
||||||
|
label nInjectors = 0;
|
||||||
|
if (outputByInjectorId)
|
||||||
|
{
|
||||||
|
for (const auto& inj : cloud.injectors())
|
||||||
|
{
|
||||||
|
injIdToIndex_.insert(inj.injectorID(), nInjectors++);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// The normal case, and safety if injector mapping was somehow null.
|
||||||
|
if (!nInjectors)
|
||||||
|
{
|
||||||
|
nInjectors = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check that interactions are valid/specified
|
||||||
forAll(patchData_, patchi)
|
forAll(patchData_, patchi)
|
||||||
{
|
{
|
||||||
const word& interactionTypeName =
|
const word& interactionTypeName =
|
||||||
@ -80,20 +98,10 @@ Foam::LocalInteraction<CloudType>::LocalInteraction
|
|||||||
<< nl << exit(FatalError);
|
<< nl << exit(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
label nInjectors(1);
|
nEscape_[patchi].setSize(nInjectors, Zero);
|
||||||
if (outputByInjectorId_)
|
massEscape_[patchi].setSize(nInjectors, Zero);
|
||||||
{
|
nStick_[patchi].setSize(nInjectors, Zero);
|
||||||
nInjectors = cloud.injectors().size();
|
massStick_[patchi].setSize(nInjectors, Zero);
|
||||||
for (label i=0; i<nInjectors; i++)
|
|
||||||
{
|
|
||||||
injIdToIndex_.insert(cloud.injectors()[i].injectorID(), i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
nEscape_[patchi].setSize(nInjectors, 0);
|
|
||||||
massEscape_[patchi].setSize(nInjectors, 0.0);
|
|
||||||
nStick_[patchi].setSize(nInjectors, 0);
|
|
||||||
massStick_[patchi].setSize(nInjectors, 0.0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,20 +119,12 @@ Foam::LocalInteraction<CloudType>::LocalInteraction
|
|||||||
nStick_(pim.nStick_),
|
nStick_(pim.nStick_),
|
||||||
massStick_(pim.massStick_),
|
massStick_(pim.massStick_),
|
||||||
writeFields_(pim.writeFields_),
|
writeFields_(pim.writeFields_),
|
||||||
outputByInjectorId_(pim.outputByInjectorId_),
|
|
||||||
injIdToIndex_(pim.injIdToIndex_),
|
injIdToIndex_(pim.injIdToIndex_),
|
||||||
massEscapePtr_(nullptr),
|
massEscapePtr_(nullptr),
|
||||||
massStickPtr_(nullptr)
|
massStickPtr_(nullptr)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
template<class CloudType>
|
|
||||||
Foam::LocalInteraction<CloudType>::~LocalInteraction()
|
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class CloudType>
|
template<class CloudType>
|
||||||
@ -193,12 +193,20 @@ bool Foam::LocalInteraction<CloudType>::correct
|
|||||||
bool& keepParticle
|
bool& keepParticle
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
label patchi = patchData_.applyToPatch(pp.index());
|
const label patchi = patchData_.applyToPatch(pp.index());
|
||||||
|
|
||||||
if (patchi >= 0)
|
if (patchi >= 0)
|
||||||
{
|
{
|
||||||
vector& U = p.U();
|
vector& U = p.U();
|
||||||
|
|
||||||
|
// Location for storing the stats.
|
||||||
|
const label idx =
|
||||||
|
(
|
||||||
|
injIdToIndex_.size()
|
||||||
|
? injIdToIndex_.lookup(p.typeId(), 0)
|
||||||
|
: 0
|
||||||
|
);
|
||||||
|
|
||||||
typename PatchInteractionModel<CloudType>::interactionType it =
|
typename PatchInteractionModel<CloudType>::interactionType it =
|
||||||
this->wordToInteractionType
|
this->wordToInteractionType
|
||||||
(
|
(
|
||||||
@ -213,50 +221,38 @@ bool Foam::LocalInteraction<CloudType>::correct
|
|||||||
}
|
}
|
||||||
case PatchInteractionModel<CloudType>::itEscape:
|
case PatchInteractionModel<CloudType>::itEscape:
|
||||||
{
|
{
|
||||||
scalar dm = p.mass()*p.nParticle();
|
|
||||||
|
|
||||||
keepParticle = false;
|
keepParticle = false;
|
||||||
p.active(false);
|
p.active(false);
|
||||||
U = Zero;
|
U = Zero;
|
||||||
if (outputByInjectorId_)
|
|
||||||
{
|
const scalar dm = p.mass()*p.nParticle();
|
||||||
nEscape_[patchi][injIdToIndex_[p.typeId()]]++;
|
|
||||||
massEscape_[patchi][injIdToIndex_[p.typeId()]] += dm;
|
nEscape_[patchi][idx]++;
|
||||||
}
|
massEscape_[patchi][idx] += dm;
|
||||||
else
|
|
||||||
{
|
|
||||||
nEscape_[patchi][0]++;
|
|
||||||
massEscape_[patchi][0] += dm;
|
|
||||||
}
|
|
||||||
if (writeFields_)
|
if (writeFields_)
|
||||||
{
|
{
|
||||||
label pI = pp.index();
|
const label pI = pp.index();
|
||||||
label fI = pp.whichFace(p.face());
|
const label fI = pp.whichFace(p.face());
|
||||||
massEscape().boundaryFieldRef()[pI][fI] += dm;
|
massEscape().boundaryFieldRef()[pI][fI] += dm;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case PatchInteractionModel<CloudType>::itStick:
|
case PatchInteractionModel<CloudType>::itStick:
|
||||||
{
|
{
|
||||||
scalar dm = p.mass()*p.nParticle();
|
|
||||||
|
|
||||||
keepParticle = true;
|
keepParticle = true;
|
||||||
p.active(false);
|
p.active(false);
|
||||||
U = Zero;
|
U = Zero;
|
||||||
if (outputByInjectorId_)
|
|
||||||
{
|
const scalar dm = p.mass()*p.nParticle();
|
||||||
nStick_[patchi][injIdToIndex_[p.typeId()]]++;
|
|
||||||
massStick_[patchi][injIdToIndex_[p.typeId()]] += dm;
|
nStick_[patchi][idx]++;
|
||||||
}
|
massStick_[patchi][idx] += dm;
|
||||||
else
|
|
||||||
{
|
|
||||||
nStick_[patchi][0]++;
|
|
||||||
massStick_[patchi][0] += dm;
|
|
||||||
}
|
|
||||||
if (writeFields_)
|
if (writeFields_)
|
||||||
{
|
{
|
||||||
label pI = pp.index();
|
const label pI = pp.index();
|
||||||
label fI = pp.whichFace(p.face());
|
const label fI = pp.whichFace(p.face());
|
||||||
massStick().boundaryFieldRef()[pI][fI] += dm;
|
massStick().boundaryFieldRef()[pI][fI] += dm;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -355,21 +351,28 @@ void Foam::LocalInteraction<CloudType>::info(Ostream& os)
|
|||||||
mps[i] = mps[i] + mps0[i];
|
mps[i] = mps[i] + mps0[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (injIdToIndex_.size())
|
||||||
if (outputByInjectorId_)
|
|
||||||
{
|
{
|
||||||
|
// Since injIdToIndex_ is a one-to-one mapping (starting as zero),
|
||||||
|
// can simply invert it.
|
||||||
|
labelList indexToInjector(injIdToIndex_.size());
|
||||||
|
forAllConstIters(injIdToIndex_, iter)
|
||||||
|
{
|
||||||
|
indexToInjector[iter.object()] = iter.key();
|
||||||
|
}
|
||||||
|
|
||||||
forAll(patchData_, i)
|
forAll(patchData_, i)
|
||||||
{
|
{
|
||||||
forAll (mpe[i], injId)
|
forAll(mpe[i], idx)
|
||||||
{
|
{
|
||||||
os << " Parcel fate: patch " << patchData_[i].patchName()
|
os << " Parcel fate: patch " << patchData_[i].patchName()
|
||||||
<< " (number, mass)" << nl
|
<< " (number, mass)" << nl
|
||||||
<< " - escape (injector " << injIdToIndex_.toc()[injId]
|
<< " - escape (injector " << indexToInjector[idx]
|
||||||
<< " ) = " << npe[i][injId]
|
<< " ) = " << npe[i][idx]
|
||||||
<< ", " << mpe[i][injId] << nl
|
<< ", " << mpe[i][idx] << nl
|
||||||
<< " - stick (injector " << injIdToIndex_.toc()[injId]
|
<< " - stick (injector " << indexToInjector[idx]
|
||||||
<< " ) = " << nps[i][injId]
|
<< " ) = " << nps[i][idx]
|
||||||
<< ", " << mps[i][injId] << nl;
|
<< ", " << mps[i][idx] << nl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -379,25 +382,23 @@ void Foam::LocalInteraction<CloudType>::info(Ostream& os)
|
|||||||
{
|
{
|
||||||
os << " Parcel fate: patch " << patchData_[i].patchName()
|
os << " Parcel fate: patch " << patchData_[i].patchName()
|
||||||
<< " (number, mass)" << nl
|
<< " (number, mass)" << nl
|
||||||
<< " - escape = " << npe[i][0]
|
<< " - escape = "
|
||||||
<< ", " << mpe[i][0] << nl
|
<< npe[i][0] << ", " << mpe[i][0] << nl
|
||||||
<< " - stick = " << nps[i][0]
|
<< " - stick = "
|
||||||
<< ", " << mps[i][0] << nl;
|
<< nps[i][0] << ", " << mps[i][0] << nl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->writeTime())
|
if (this->writeTime())
|
||||||
{
|
{
|
||||||
this->setModelProperty("nEscape", npe);
|
this->setModelProperty("nEscape", npe);
|
||||||
nEscape_ = Zero;
|
|
||||||
|
|
||||||
this->setModelProperty("massEscape", mpe);
|
this->setModelProperty("massEscape", mpe);
|
||||||
massEscape_ = Zero;
|
|
||||||
|
|
||||||
this->setModelProperty("nStick", nps);
|
this->setModelProperty("nStick", nps);
|
||||||
nStick_ = Zero;
|
|
||||||
|
|
||||||
this->setModelProperty("massStick", mps);
|
this->setModelProperty("massStick", mps);
|
||||||
|
|
||||||
|
nEscape_ = Zero;
|
||||||
|
massEscape_ = Zero;
|
||||||
|
nStick_ = Zero;
|
||||||
massStick_ = Zero;
|
massStick_ = Zero;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -43,6 +43,7 @@ Description
|
|||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class LocalInteraction Declaration
|
Class LocalInteraction Declaration
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
@ -57,29 +58,25 @@ class LocalInteraction
|
|||||||
//- List of participating patches
|
//- List of participating patches
|
||||||
const patchInteractionDataList patchData_;
|
const patchInteractionDataList patchData_;
|
||||||
|
|
||||||
|
// Bookkeeping for particle fates
|
||||||
|
|
||||||
// Counters for particle fates
|
//- Number of parcels escaped
|
||||||
|
List<List<label>> nEscape_;
|
||||||
|
|
||||||
//- Number of parcels escaped
|
//- Mass of parcels escaped
|
||||||
List<List<label>> nEscape_;
|
List<List<scalar>> massEscape_;
|
||||||
|
|
||||||
//- Mass of parcels escaped
|
//- Number of parcels stuck to patches
|
||||||
List<List<scalar>> massEscape_;
|
List<List<label>> nStick_;
|
||||||
|
|
||||||
//- Number of parcels stuck to patches
|
|
||||||
List<List<label>> nStick_;
|
|
||||||
|
|
||||||
//- Mass of parcels stuck to patches
|
|
||||||
List<List<scalar>> massStick_;
|
|
||||||
|
|
||||||
|
//- Mass of parcels stuck to patches
|
||||||
|
List<List<scalar>> massStick_;
|
||||||
|
|
||||||
//- Flag to output data as fields
|
//- Flag to output data as fields
|
||||||
Switch writeFields_;
|
bool writeFields_;
|
||||||
|
|
||||||
//- Flag to output escaped/mass particles sorted by injectorID
|
//- InjectorId to index map, when outputting escaped/stick/...
|
||||||
Switch outputByInjectorId_;
|
// particles sorted by injectorID
|
||||||
|
|
||||||
//- InjectorId to index map
|
|
||||||
Map<label> injIdToIndex_;
|
Map<label> injIdToIndex_;
|
||||||
|
|
||||||
//- Mass escape field
|
//- Mass escape field
|
||||||
@ -115,7 +112,7 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
//- Destructor
|
//- Destructor
|
||||||
virtual ~LocalInteraction();
|
virtual ~LocalInteraction() = default;
|
||||||
|
|
||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
@ -136,10 +133,8 @@ public:
|
|||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
// I-O
|
//- Write patch interaction info to stream
|
||||||
|
virtual void info(Ostream& os);
|
||||||
//- Write patch interaction info to stream
|
|
||||||
virtual void info(Ostream& os);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -108,13 +108,6 @@ Foam::MultiInteraction<CloudType>::MultiInteraction
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
template<class CloudType>
|
|
||||||
Foam::MultiInteraction<CloudType>::~MultiInteraction()
|
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class CloudType>
|
template<class CloudType>
|
||||||
|
|||||||
@ -130,7 +130,7 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
//- Destructor
|
//- Destructor
|
||||||
virtual ~MultiInteraction();
|
virtual ~MultiInteraction() = default;
|
||||||
|
|
||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|||||||
@ -48,13 +48,6 @@ Foam::NoInteraction<CloudType>::NoInteraction
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
template<class CloudType>
|
|
||||||
Foam::NoInteraction<CloudType>::~NoInteraction()
|
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class CloudType>
|
template<class CloudType>
|
||||||
|
|||||||
@ -76,7 +76,7 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
//- Destructor
|
//- Destructor
|
||||||
virtual ~NoInteraction();
|
virtual ~NoInteraction() = default;
|
||||||
|
|
||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|||||||
@ -151,13 +151,6 @@ Foam::PatchInteractionModel<CloudType>::PatchInteractionModel
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
template<class CloudType>
|
|
||||||
Foam::PatchInteractionModel<CloudType>::~PatchInteractionModel()
|
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class CloudType>
|
template<class CloudType>
|
||||||
|
|||||||
@ -136,7 +136,7 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
//- Destructor
|
//- Destructor
|
||||||
virtual ~PatchInteractionModel();
|
virtual ~PatchInteractionModel() = default;
|
||||||
|
|
||||||
|
|
||||||
//- Selector
|
//- Selector
|
||||||
@ -174,10 +174,8 @@ public:
|
|||||||
void addToEscapedParcels(const scalar mass);
|
void addToEscapedParcels(const scalar mass);
|
||||||
|
|
||||||
|
|
||||||
// I-O
|
//- Write patch interaction info to stream
|
||||||
|
virtual void info(Ostream& os);
|
||||||
//- Write patch interaction info to stream
|
|
||||||
virtual void info(Ostream& os);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -47,13 +47,6 @@ Foam::Rebound<CloudType>::Rebound(const Rebound<CloudType>& pim)
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
template<class CloudType>
|
|
||||||
Foam::Rebound<CloudType>::~Rebound()
|
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class CloudType>
|
template<class CloudType>
|
||||||
|
|||||||
@ -82,10 +82,11 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
//- Destructor
|
//- Destructor
|
||||||
virtual ~Rebound();
|
virtual ~Rebound() = default;
|
||||||
|
|
||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
//- Apply velocity correction
|
//- Apply velocity correction
|
||||||
// Returns true if particle remains in same cell
|
// Returns true if particle remains in same cell
|
||||||
virtual bool correct
|
virtual bool correct
|
||||||
|
|||||||
@ -46,12 +46,11 @@ Foam::StandardWallInteraction<CloudType>::StandardWallInteraction
|
|||||||
massEscape_(nEscape_.size()),
|
massEscape_(nEscape_.size()),
|
||||||
nStick_(nEscape_.size()),
|
nStick_(nEscape_.size()),
|
||||||
massStick_(nEscape_.size()),
|
massStick_(nEscape_.size()),
|
||||||
outputByInjectorId_
|
injIdToIndex_()
|
||||||
(
|
|
||||||
this->coeffDict().lookupOrDefault("outputByInjectorId", false)
|
|
||||||
),
|
|
||||||
injIdToIndex_(cloud.injectors().size())
|
|
||||||
{
|
{
|
||||||
|
const bool outputByInjectorId
|
||||||
|
= this->coeffDict().lookupOrDefault("outputByInjectorId", false);
|
||||||
|
|
||||||
switch (interactionType_)
|
switch (interactionType_)
|
||||||
{
|
{
|
||||||
case PatchInteractionModel<CloudType>::itOther:
|
case PatchInteractionModel<CloudType>::itOther:
|
||||||
@ -76,22 +75,28 @@ Foam::StandardWallInteraction<CloudType>::StandardWallInteraction
|
|||||||
{}
|
{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Determine the number of injectors and the injector mapping
|
||||||
|
label nInjectors = 0;
|
||||||
|
if (outputByInjectorId)
|
||||||
|
{
|
||||||
|
for (const auto& inj : cloud.injectors())
|
||||||
|
{
|
||||||
|
injIdToIndex_.insert(inj.injectorID(), nInjectors++);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// The normal case, and safety if injector mapping was somehow null.
|
||||||
|
if (injIdToIndex_.empty())
|
||||||
|
{
|
||||||
|
nInjectors = 1;
|
||||||
|
}
|
||||||
|
|
||||||
forAll(nEscape_, patchi)
|
forAll(nEscape_, patchi)
|
||||||
{
|
{
|
||||||
label nInjectors(1);
|
nEscape_[patchi].setSize(nInjectors, Zero);
|
||||||
if (outputByInjectorId_)
|
massEscape_[patchi].setSize(nInjectors, Zero);
|
||||||
{
|
nStick_[patchi].setSize(nInjectors, Zero);
|
||||||
nInjectors = cloud.injectors().size();
|
massStick_[patchi].setSize(nInjectors, Zero);
|
||||||
for (label i=0; i<nInjectors; i++)
|
|
||||||
{
|
|
||||||
injIdToIndex_.insert(cloud.injectors()[i].injectorID(), i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
nEscape_[patchi].setSize(nInjectors, 0);
|
|
||||||
massEscape_[patchi].setSize(nInjectors, 0.0);
|
|
||||||
nStick_[patchi].setSize(nInjectors, 0);
|
|
||||||
massStick_[patchi].setSize(nInjectors, 0.0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,7 +116,6 @@ Foam::StandardWallInteraction<CloudType>::StandardWallInteraction
|
|||||||
massEscape_(pim.massEscape_),
|
massEscape_(pim.massEscape_),
|
||||||
nStick_(pim.nStick_),
|
nStick_(pim.nStick_),
|
||||||
massStick_(pim.massStick_),
|
massStick_(pim.massStick_),
|
||||||
outputByInjectorId_(pim.outputByInjectorId_),
|
|
||||||
injIdToIndex_(pim.injIdToIndex_)
|
injIdToIndex_(pim.injIdToIndex_)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@ -130,6 +134,14 @@ bool Foam::StandardWallInteraction<CloudType>::correct
|
|||||||
|
|
||||||
if (isA<wallPolyPatch>(pp))
|
if (isA<wallPolyPatch>(pp))
|
||||||
{
|
{
|
||||||
|
// Location for storing the stats.
|
||||||
|
const label idx =
|
||||||
|
(
|
||||||
|
injIdToIndex_.size()
|
||||||
|
? injIdToIndex_.lookup(p.typeId(), 0)
|
||||||
|
: 0
|
||||||
|
);
|
||||||
|
|
||||||
switch (interactionType_)
|
switch (interactionType_)
|
||||||
{
|
{
|
||||||
case PatchInteractionModel<CloudType>::itNone:
|
case PatchInteractionModel<CloudType>::itNone:
|
||||||
@ -141,17 +153,11 @@ bool Foam::StandardWallInteraction<CloudType>::correct
|
|||||||
keepParticle = false;
|
keepParticle = false;
|
||||||
p.active(false);
|
p.active(false);
|
||||||
U = Zero;
|
U = Zero;
|
||||||
|
|
||||||
const scalar dm = p.nParticle()*p.mass();
|
const scalar dm = p.nParticle()*p.mass();
|
||||||
if (outputByInjectorId_)
|
|
||||||
{
|
nEscape_[pp.index()][idx]++;
|
||||||
nEscape_[pp.index()][injIdToIndex_[p.typeId()]]++;
|
massEscape_[pp.index()][idx] += dm;
|
||||||
massEscape_[pp.index()][injIdToIndex_[p.typeId()]] += dm;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
nEscape_[pp.index()][0]++;
|
|
||||||
massEscape_[pp.index()][0] += dm;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case PatchInteractionModel<CloudType>::itStick:
|
case PatchInteractionModel<CloudType>::itStick:
|
||||||
@ -159,17 +165,11 @@ bool Foam::StandardWallInteraction<CloudType>::correct
|
|||||||
keepParticle = true;
|
keepParticle = true;
|
||||||
p.active(false);
|
p.active(false);
|
||||||
U = Zero;
|
U = Zero;
|
||||||
|
|
||||||
const scalar dm = p.nParticle()*p.mass();
|
const scalar dm = p.nParticle()*p.mass();
|
||||||
if (outputByInjectorId_)
|
|
||||||
{
|
nStick_[pp.index()][idx]++;
|
||||||
nStick_[pp.index()][injIdToIndex_[p.typeId()]]++;
|
massStick_[pp.index()][idx] += dm;
|
||||||
massStick_[pp.index()][injIdToIndex_[p.typeId()]] += dm;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
nStick_[pp.index()][0]++;
|
|
||||||
massStick_[pp.index()][0] += dm;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case PatchInteractionModel<CloudType>::itRebound:
|
case PatchInteractionModel<CloudType>::itRebound:
|
||||||
@ -234,7 +234,7 @@ void Foam::StandardWallInteraction<CloudType>::info(Ostream& os)
|
|||||||
scalarListList mps0(massStick_);
|
scalarListList mps0(massStick_);
|
||||||
this->getModelProperty("massStick", mps0);
|
this->getModelProperty("massStick", mps0);
|
||||||
|
|
||||||
// accumulate current data
|
// Accumulate current data
|
||||||
labelListList npe(nEscape_);
|
labelListList npe(nEscape_);
|
||||||
|
|
||||||
forAll(npe, i)
|
forAll(npe, i)
|
||||||
@ -264,20 +264,28 @@ void Foam::StandardWallInteraction<CloudType>::info(Ostream& os)
|
|||||||
mps[i] = mps[i] + mps0[i];
|
mps[i] = mps[i] + mps0[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (outputByInjectorId_)
|
if (injIdToIndex_.size())
|
||||||
{
|
{
|
||||||
|
// Since injIdToIndex_ is a one-to-one mapping (starting as zero),
|
||||||
|
// can simply invert it.
|
||||||
|
labelList indexToInjector(injIdToIndex_.size());
|
||||||
|
forAllConstIters(injIdToIndex_, iter)
|
||||||
|
{
|
||||||
|
indexToInjector[iter.object()] = iter.key();
|
||||||
|
}
|
||||||
|
|
||||||
forAll(npe, i)
|
forAll(npe, i)
|
||||||
{
|
{
|
||||||
forAll (mpe[i], injId)
|
forAll(mpe[i], idx)
|
||||||
{
|
{
|
||||||
os << " Parcel fate: patch " << mesh_.boundary()[i].name()
|
os << " Parcel fate: patch " << mesh_.boundary()[i].name()
|
||||||
<< " (number, mass)" << nl
|
<< " (number, mass)" << nl
|
||||||
<< " - escape (injector " << injIdToIndex_.toc()[injId]
|
<< " - escape (injector " << indexToInjector[idx]
|
||||||
<< " ) = " << npe[i][injId]
|
<< ") = " << npe[i][idx]
|
||||||
<< ", " << mpe[i][injId] << nl
|
<< ", " << mpe[i][idx] << nl
|
||||||
<< " - stick (injector " << injIdToIndex_.toc()[injId]
|
<< " - stick (injector " << indexToInjector[idx]
|
||||||
<< " ) = " << nps[i][injId]
|
<< ") = " << nps[i][idx]
|
||||||
<< ", " << mps[i][injId] << nl;
|
<< ", " << mps[i][idx] << nl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -285,7 +293,6 @@ void Foam::StandardWallInteraction<CloudType>::info(Ostream& os)
|
|||||||
{
|
{
|
||||||
forAll(npe, i)
|
forAll(npe, i)
|
||||||
{
|
{
|
||||||
|
|
||||||
os << " Parcel fate: patch (number, mass) "
|
os << " Parcel fate: patch (number, mass) "
|
||||||
<< mesh_.boundary()[i].name() << nl
|
<< mesh_.boundary()[i].name() << nl
|
||||||
<< " - escape = "
|
<< " - escape = "
|
||||||
@ -299,15 +306,15 @@ void Foam::StandardWallInteraction<CloudType>::info(Ostream& os)
|
|||||||
if (this->writeTime())
|
if (this->writeTime())
|
||||||
{
|
{
|
||||||
this->setModelProperty("nEscape", npe);
|
this->setModelProperty("nEscape", npe);
|
||||||
nEscape_ = Zero;
|
|
||||||
this->setModelProperty("massEscape", mpe);
|
this->setModelProperty("massEscape", mpe);
|
||||||
massEscape_ = Zero;
|
|
||||||
this->setModelProperty("nStick", nps);
|
this->setModelProperty("nStick", nps);
|
||||||
nStick_ = Zero;
|
|
||||||
this->setModelProperty("massStick", mps);
|
this->setModelProperty("massStick", mps);
|
||||||
|
|
||||||
|
nEscape_ = Zero;
|
||||||
|
massEscape_ = Zero;
|
||||||
|
nStick_ = Zero;
|
||||||
massStick_ = Zero;
|
massStick_ = Zero;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -82,26 +82,26 @@ protected:
|
|||||||
//- Restitution coefficient
|
//- Restitution coefficient
|
||||||
scalar mu_;
|
scalar mu_;
|
||||||
|
|
||||||
|
// Bookkeeping for particle fates
|
||||||
|
|
||||||
// Counters for particle fates
|
//- Number of parcels escaped
|
||||||
|
List<List<label>> nEscape_;
|
||||||
|
|
||||||
//- Number of parcels escaped
|
//- Mass of parcels escaped
|
||||||
List<List<label>> nEscape_;
|
List<List<scalar>> massEscape_;
|
||||||
|
|
||||||
//- Mass of parcels escaped
|
//- Number of parcels stuck to patches
|
||||||
List<List<scalar>> massEscape_;
|
List<List<label>> nStick_;
|
||||||
|
|
||||||
//- Number of parcels stuck to patches
|
//- Mass of parcels stuck to patches
|
||||||
List<List<label>> nStick_;
|
List<List<scalar>> massStick_;
|
||||||
|
|
||||||
//- Mass of parcels stuck to patches
|
//- Flag to output escaped/mass particles sorted by injectorID
|
||||||
List<List<scalar>> massStick_;
|
bool outputByInjectorId_;
|
||||||
|
|
||||||
//- Flag to output escaped/mass particles sorted by injectorID
|
//- InjectorId to index map, when outputting escaped/stick/...
|
||||||
bool outputByInjectorId_;
|
// particles sorted by injectorID
|
||||||
|
Map<label> injIdToIndex_;
|
||||||
//- InjectorId to index map
|
|
||||||
Map<label> injIdToIndex_;
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -144,10 +144,8 @@ public:
|
|||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
// I-O
|
//- Write patch interaction info to stream
|
||||||
|
virtual void info(Ostream& os);
|
||||||
//- Write patch interaction info to stream
|
|
||||||
virtual void info(Ostream& os);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,18 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
cd ${0%/*} || exit 1 # Run from this directory
|
||||||
|
. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions
|
||||||
|
|
||||||
|
restore0Dir
|
||||||
|
|
||||||
|
runApplication blockMesh
|
||||||
|
|
||||||
|
runApplication potentialFoam
|
||||||
|
|
||||||
|
# Remove incompatible (volumetric) flux field
|
||||||
|
\rm -f 0/phi 2>/dev/null
|
||||||
|
|
||||||
|
runApplication decomposePar
|
||||||
|
|
||||||
|
runParallel $(getApplication)
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
@ -0,0 +1,30 @@
|
|||||||
|
/*--------------------------------*- C++ -*----------------------------------*\
|
||||||
|
| ========= | |
|
||||||
|
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||||
|
| \\ / O peration | Version: plus |
|
||||||
|
| \\ / A nd | Web: www.OpenFOAM.com |
|
||||||
|
| \\/ M anipulation | |
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
FoamFile
|
||||||
|
{
|
||||||
|
version 2.0;
|
||||||
|
format ascii;
|
||||||
|
class dictionary;
|
||||||
|
object decomposeParDict;
|
||||||
|
}
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
numberOfSubdomains 4;
|
||||||
|
|
||||||
|
method scotch;
|
||||||
|
|
||||||
|
coeffs
|
||||||
|
{
|
||||||
|
n (2 2 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
distributed no;
|
||||||
|
|
||||||
|
roots ( );
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
Reference in New Issue
Block a user