Merge branch 'feature-LagrangianPatchInterationInfo' into 'develop'

ENH: Adding optional output information ordered by injectorID to LocalInteraction.

See merge request Development/OpenFOAM-plus!187
This commit is contained in:
Andrew Heather
2018-01-24 08:30:27 +00:00
6 changed files with 269 additions and 75 deletions

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -274,6 +274,9 @@ public:
//- Return mass of particles injected (cumulative)
inline scalar massInjected() const;
//- Return injectorID
inline label injectorID() const;
//- Return the end-of-injection time
virtual scalar timeEnd() const = 0;

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -55,6 +55,13 @@ Foam::scalar Foam::InjectionModel<CloudType>::massInjected() const
}
template<class CloudType>
Foam::label Foam::InjectionModel<CloudType>::injectorID() const
{
return injectorID_;
}
template<class CloudType>
Foam::label Foam::InjectionModel<CloudType>::nInjections() const
{

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015-2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -36,11 +36,13 @@ Foam::LocalInteraction<CloudType>::LocalInteraction
:
PatchInteractionModel<CloudType>(dict, cloud, typeName),
patchData_(cloud.mesh(), this->coeffDict()),
nEscape_(patchData_.size(), 0),
massEscape_(patchData_.size(), 0.0),
nStick_(patchData_.size(), 0),
massStick_(patchData_.size(), 0.0),
nEscape_(patchData_.size()),
massEscape_(patchData_.size()),
nStick_(patchData_.size()),
massStick_(patchData_.size()),
writeFields_(this->coeffDict().lookupOrDefault("writeFields", false)),
outputByInjectorId_(this->coeffDict().lookupOrDefault("outputByInjectorId", false)),
injIdToIndex_(cloud.injectors().size()),
massEscapePtr_(nullptr),
massStickPtr_(nullptr)
{
@ -77,6 +79,21 @@ Foam::LocalInteraction<CloudType>::LocalInteraction
<< this->PatchInteractionModel<CloudType>::interactionTypeNames_
<< nl << exit(FatalError);
}
label nInjectors(1);
if (outputByInjectorId_)
{
nInjectors = cloud.injectors().size();
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);
}
}
@ -94,6 +111,8 @@ Foam::LocalInteraction<CloudType>::LocalInteraction
nStick_(pim.nStick_),
massStick_(pim.massStick_),
writeFields_(pim.writeFields_),
outputByInjectorId_(pim.outputByInjectorId_),
injIdToIndex_(pim.injIdToIndex_),
massEscapePtr_(nullptr),
massStickPtr_(nullptr)
{}
@ -199,8 +218,16 @@ bool Foam::LocalInteraction<CloudType>::correct
keepParticle = false;
p.active(false);
U = Zero;
nEscape_[patchi]++;
massEscape_[patchi] += dm;
if (outputByInjectorId_)
{
nEscape_[patchi][injIdToIndex_[p.typeId()]]++;
massEscape_[patchi][injIdToIndex_[p.typeId()]] += dm;
}
else
{
nEscape_[patchi][0]++;
massEscape_[patchi][0] += dm;
}
if (writeFields_)
{
label pI = pp.index();
@ -216,8 +243,16 @@ bool Foam::LocalInteraction<CloudType>::correct
keepParticle = true;
p.active(false);
U = Zero;
nStick_[patchi]++;
massStick_[patchi] += dm;
if (outputByInjectorId_)
{
nStick_[patchi][injIdToIndex_[p.typeId()]]++;
massStick_[patchi][injIdToIndex_[p.typeId()]] += dm;
}
else
{
nStick_[patchi][0]++;
massStick_[patchi][0] += dm;
}
if (writeFields_)
{
label pI = pp.index();
@ -279,59 +314,91 @@ void Foam::LocalInteraction<CloudType>::info(Ostream& os)
PatchInteractionModel<CloudType>::info(os);
// retrieve any stored data
labelList npe0(patchData_.size(), 0);
labelListList npe0(nEscape_);
this->getModelProperty("nEscape", npe0);
scalarList mpe0(patchData_.size(), 0.0);
scalarListList mpe0(massEscape_);
this->getModelProperty("massEscape", mpe0);
labelList nps0(patchData_.size(), 0);
labelListList nps0(nStick_);
this->getModelProperty("nStick", nps0);
scalarList mps0(patchData_.size(), 0.0);
scalarListList mps0(massStick_);
this->getModelProperty("massStick", mps0);
// accumulate current data
labelList npe(nEscape_);
Pstream::listCombineGather(npe, plusEqOp<label>());
npe = npe + npe0;
scalarList mpe(massEscape_);
Pstream::listCombineGather(mpe, plusEqOp<scalar>());
mpe = mpe + mpe0;
labelList nps(nStick_);
Pstream::listCombineGather(nps, plusEqOp<label>());
nps = nps + nps0;
scalarList mps(massStick_);
Pstream::listCombineGather(mps, plusEqOp<scalar>());
mps = mps + mps0;
forAll(patchData_, i)
labelListList npe(nEscape_);
forAll(npe, i)
{
os << " Parcel fate: patch " << patchData_[i].patchName()
<< " (number, mass)" << nl
<< " - escape = " << npe[i]
<< ", " << mpe[i] << nl
<< " - stick = " << nps[i]
<< ", " << mps[i] << nl;
Pstream::listCombineGather(npe[i], plusEqOp<label>());
npe[i] = npe[i] + npe0[i];
}
scalarListList mpe(massEscape_);
forAll(mpe, i)
{
Pstream::listCombineGather(mpe[i], plusEqOp<scalar>());
mpe[i] = mpe[i] + mpe0[i];
}
labelListList nps(nStick_);
forAll(nps, i)
{
Pstream::listCombineGather(nps[i], plusEqOp<label>());
nps[i] = nps[i] + nps0[i];
}
scalarListList mps(massStick_);
forAll(nps, i)
{
Pstream::listCombineGather(mps[i], plusEqOp<scalar>());
mps[i] = mps[i] + mps0[i];
}
if (outputByInjectorId_)
{
forAll(patchData_, i)
{
forAll (mpe[i], injId)
{
os << " Parcel fate: patch " << patchData_[i].patchName()
<< " (number, mass)" << nl
<< " - escape (injector " << injIdToIndex_.toc()[injId]
<< " ) = " << npe[i][injId]
<< ", " << mpe[i][injId] << nl
<< " - stick (injector " << injIdToIndex_.toc()[injId]
<< " ) = " << nps[i][injId]
<< ", " << mps[i][injId] << nl;
}
}
}
else
{
forAll(patchData_, i)
{
os << " Parcel fate: patch " << patchData_[i].patchName()
<< " (number, mass)" << nl
<< " - escape = " << npe[i][0]
<< ", " << mpe[i][0] << nl
<< " - stick = " << nps[i][0]
<< ", " << mps[i][0] << nl;
}
}
if (this->writeTime())
{
this->setModelProperty("nEscape", npe);
nEscape_ = 0;
nEscape_ = Zero;
this->setModelProperty("massEscape", mpe);
massEscape_ = 0.0;
massEscape_ = Zero;
this->setModelProperty("nStick", nps);
nStick_ = 0;
nStick_ = Zero;
this->setModelProperty("massStick", mps);
massStick_ = 0.0;
massStick_ = Zero;
}
}

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -61,21 +61,27 @@ class LocalInteraction
// Counters for particle fates
//- Number of parcels escaped
List<label> nEscape_;
List<List<label>> nEscape_;
//- Mass of parcels escaped
List<scalar> massEscape_;
List<List<scalar>> massEscape_;
//- Number of parcels stuck to patches
List<label> nStick_;
List<List<label>> nStick_;
//- Mass of parcels stuck to patches
List<scalar> massStick_;
List<List<scalar>> massStick_;
//- Flag to output data as fields
Switch writeFields_;
//- Flag to output escaped/mass particles sorted by injectorID
Switch outputByInjectorId_;
//- InjectorId to index map
Map<label> injIdToIndex_;
//- Mass escape field
autoPtr<volScalarField> massEscapePtr_;
@ -83,6 +89,7 @@ class LocalInteraction
autoPtr<volScalarField> massStickPtr_;
public:
//- Runtime type information

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015-2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -35,16 +35,19 @@ Foam::StandardWallInteraction<CloudType>::StandardWallInteraction
)
:
PatchInteractionModel<CloudType>(dict, cloud, typeName),
mesh_(cloud.mesh()),
interactionType_
(
this->wordToInteractionType(this->coeffDict().lookup("type"))
),
e_(0.0),
mu_(0.0),
nEscape_(0),
massEscape_(0.0),
nStick_(0),
massStick_(0.0)
nEscape_(cloud.mesh().boundary().size()),
massEscape_(nEscape_.size()),
nStick_(nEscape_.size()),
massStick_(nEscape_.size()),
outputByInjectorId_(this->coeffDict().lookupOrDefault("outputByInjectorId", false)),
injIdToIndex_(cloud.injectors().size())
{
switch (interactionType_)
{
@ -69,6 +72,24 @@ Foam::StandardWallInteraction<CloudType>::StandardWallInteraction
default:
{}
}
forAll(nEscape_, patchi)
{
label nInjectors(1);
if (outputByInjectorId_)
{
nInjectors = cloud.injectors().size();
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);
}
}
@ -79,13 +100,16 @@ Foam::StandardWallInteraction<CloudType>::StandardWallInteraction
)
:
PatchInteractionModel<CloudType>(pim),
mesh_(pim.mesh_),
interactionType_(pim.interactionType_),
e_(pim.e_),
mu_(pim.mu_),
nEscape_(pim.nEscape_),
massEscape_(pim.massEscape_),
nStick_(pim.nStick_),
massStick_(pim.massStick_)
massStick_(pim.massStick_),
outputByInjectorId_(pim.outputByInjectorId_),
injIdToIndex_(pim.injIdToIndex_)
{}
@ -121,8 +145,17 @@ bool Foam::StandardWallInteraction<CloudType>::correct
keepParticle = false;
p.active(false);
U = Zero;
nEscape_++;
massEscape_ += p.nParticle()*p.mass();
const scalar dm = p.nParticle()*p.mass();
if (outputByInjectorId_)
{
nEscape_[pp.index()][injIdToIndex_[p.typeId()]]++;
massEscape_[pp.index()][injIdToIndex_[p.typeId()]] += dm;
}
else
{
nEscape_[pp.index()][0]++;
massEscape_[pp.index()][0] += dm;
}
break;
}
case PatchInteractionModel<CloudType>::itStick:
@ -130,8 +163,17 @@ bool Foam::StandardWallInteraction<CloudType>::correct
keepParticle = true;
p.active(false);
U = Zero;
nStick_++;
massStick_ += p.nParticle()*p.mass();
const scalar dm = p.nParticle()*p.mass();
if (outputByInjectorId_)
{
nStick_[pp.index()][injIdToIndex_[p.typeId()]]++;
massStick_[pp.index()][injIdToIndex_[p.typeId()]] += dm;
}
else
{
nStick_[pp.index()][0]++;
massStick_[pp.index()][0] += dm;
}
break;
}
case PatchInteractionModel<CloudType>::itRebound:
@ -184,28 +226,87 @@ void Foam::StandardWallInteraction<CloudType>::info(Ostream& os)
{
PatchInteractionModel<CloudType>::info(os);
label npe0 = this->template getModelProperty<scalar>("nEscape");
label npe = npe0 + returnReduce(nEscape_, sumOp<label>());
labelListList npe0(nEscape_);
this->getModelProperty("nEscape", npe0);
scalar mpe0 = this->template getModelProperty<scalar>("massEscape");
scalar mpe = mpe0 + returnReduce(massEscape_, sumOp<scalar>());
scalarListList mpe0(massEscape_);
this->getModelProperty("massEscape", mpe0);
label nps0 = this->template getModelProperty<scalar>("nStick");
label nps = nps0 + returnReduce(nStick_, sumOp<label>());
labelListList nps0(nStick_);
this->getModelProperty("nStick", nps0);
scalar mps0 = this->template getModelProperty<scalar>("massStick");
scalar mps = mps0 + returnReduce(massStick_, sumOp<scalar>());
scalarListList mps0(massStick_);
this->getModelProperty("massStick", mps0);
os << " Parcel fate: walls (number, mass)" << nl
<< " - escape = " << npe << ", " << mpe << nl
<< " - stick = " << nps << ", " << mps << nl;
// accumulate current data
labelListList npe(nEscape_);
forAll(npe, i)
{
Pstream::listCombineGather(npe[i], plusEqOp<label>());
npe[i] = npe[i] + npe0[i];
}
scalarListList mpe(massEscape_);
forAll(mpe, i)
{
Pstream::listCombineGather(mpe[i], plusEqOp<scalar>());
mpe[i] = mpe[i] + mpe0[i];
}
labelListList nps(nStick_);
forAll(nps, i)
{
Pstream::listCombineGather(nps[i], plusEqOp<label>());
nps[i] = nps[i] + nps0[i];
}
scalarListList mps(massStick_);
forAll(nps, i)
{
Pstream::listCombineGather(mps[i], plusEqOp<scalar>());
mps[i] = mps[i] + mps0[i];
}
if (outputByInjectorId_)
{
forAll(npe, i)
{
forAll (mpe[i], injId)
{
os << " Parcel fate: patch " << mesh_.boundary()[i].name()
<< " (number, mass)" << nl
<< " - escape (injector " << injIdToIndex_.toc()[injId]
<< " ) = " << npe[i][injId]
<< ", " << mpe[i][injId] << nl
<< " - stick (injector " << injIdToIndex_.toc()[injId]
<< " ) = " << nps[i][injId]
<< ", " << mps[i][injId] << nl;
}
}
}
else
{
forAll(npe, i)
{
os << " Parcel fate: walls (number, mass) "
<< mesh_.boundary()[i].name() << nl
<< " - escape = "
<< npe[i][0] << ", " << mpe[i][0] << nl
<< " - stick = "
<< nps[i][0] << ", " << mps[i][0] << nl;
}
}
if (this->writeTime())
{
this->setModelProperty("nEscape", npe);
nEscape_ = Zero;
this->setModelProperty("massEscape", mpe);
massEscape_ = Zero;
this->setModelProperty("nStick", nps);
nStick_ = Zero;
this->setModelProperty("massStick", mps);
massStick_ = Zero;
}
}

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -69,6 +69,9 @@ protected:
// Protected data
// Reference to mesh
const fvMesh& mesh_;
//- Interaction type
typename PatchInteractionModel<CloudType>::interactionType
interactionType_;
@ -82,17 +85,23 @@ protected:
// Counters for particle fates
//- Number of parcels escaped
label nEscape_;
//- Number of parcels escaped
List<List<label>> nEscape_;
//- Mass of parcels escaped
scalar massEscape_;
List<List<scalar>> massEscape_;
//- Number of parcels stuck to patches
label nStick_;
List<List<label>> nStick_;
//- Mass of parcels stuck to patches
scalar massStick_;
List<List<scalar>> massStick_;
//- Flag to output escaped/mass particles sorted by injectorID
Switch outputByInjectorId_;
//- InjectorId to index map
Map<label> injIdToIndex_;
public: