ENH: Added option to write particle patch interactions to file

File writing is off by default; to activate, add to the patch interaction model
coeff dictionary

    writeToFile yes;
This commit is contained in:
Andrew Heather
2019-12-09 22:31:09 +00:00
committed by Mark Olesen
parent b576f9dcc7
commit deeb27896c
7 changed files with 198 additions and 58 deletions

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2015-2018 OpenCFD Ltd.
Copyright (C) 2015-2019 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -30,6 +30,27 @@ License
// * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * //
template<class CloudType>
void Foam::LocalInteraction<CloudType>::writeFileHeader(Ostream& os)
{
PatchInteractionModel<CloudType>::writeFileHeader(os);
forAll(nEscape_, patchi)
{
const word& patchName = patchData_[patchi].patchName();
forAll(nEscape_[patchi], injectori)
{
const word suffix = Foam::name(injectori);
this->writeTabbed(os, patchName + "_nEscape_" + suffix);
this->writeTabbed(os, patchName + "_massEscape_" + suffix);
this->writeTabbed(os, patchName + "_nStick_" + suffix);
this->writeTabbed(os, patchName + "_massStick_" + suffix);
}
}
}
template<class CloudType>
Foam::LocalInteraction<CloudType>::LocalInteraction
(
@ -356,7 +377,7 @@ void Foam::LocalInteraction<CloudType>::info(Ostream& os)
if (injIdToIndex_.size())
{
// Since injIdToIndex_ is a one-to-one mapping (starting as zero),
// Since injIdToIndex_ is a one-to-one mapping (starting at zero),
// can simply invert it.
labelList indexToInjector(injIdToIndex_.size());
forAllConstIters(injIdToIndex_, iter)
@ -364,34 +385,52 @@ void Foam::LocalInteraction<CloudType>::info(Ostream& os)
indexToInjector[iter.val()] = iter.key();
}
forAll(patchData_, i)
forAll(patchData_, patchi)
{
forAll(mpe[i], idx)
forAll(mpe[patchi], indexi)
{
os << " Parcel fate: patch " << patchData_[i].patchName()
const word& patchName = patchData_[patchi].patchName();
os << " Parcel fate: patch " << patchName
<< " (number, mass)" << nl
<< " - escape (injector " << indexToInjector[idx]
<< " ) = " << npe[i][idx]
<< ", " << mpe[i][idx] << nl
<< " - stick (injector " << indexToInjector[idx]
<< " ) = " << nps[i][idx]
<< ", " << mps[i][idx] << nl;
<< " - escape (injector " << indexToInjector[indexi]
<< " ) = " << npe[patchi][indexi]
<< ", " << mpe[patchi][indexi] << nl
<< " - stick (injector " << indexToInjector[indexi]
<< " ) = " << nps[patchi][indexi]
<< ", " << mps[patchi][indexi] << nl;
}
}
}
else
{
forAll(patchData_, i)
forAll(patchData_, patchi)
{
os << " Parcel fate: patch " << patchData_[i].patchName()
const word& patchName = patchData_[patchi].patchName();
os << " Parcel fate: patch " << patchName
<< " (number, mass)" << nl
<< " - escape = "
<< npe[i][0] << ", " << mpe[i][0] << nl
<< npe[patchi][0] << ", " << mpe[patchi][0] << nl
<< " - stick = "
<< nps[i][0] << ", " << mps[i][0] << nl;
<< nps[patchi][0] << ", " << mps[patchi][0] << nl;
}
}
forAll(npe, patchi)
{
forAll(npe[patchi], injectori)
{
this->file()
<< tab << npe[patchi][injectori]
<< tab << mpe[patchi][injectori]
<< tab << nps[patchi][injectori]
<< tab << mps[patchi][injectori];
}
}
this->file() << endl;
if (this->writeTime())
{
this->setModelProperty("nEscape", npe);

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2018 OpenCFD Ltd.
Copyright (C) 2018-2019 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -61,19 +61,21 @@ class LocalInteraction
//- List of participating patches
const patchInteractionDataList patchData_;
// Bookkeeping for particle fates
//- Number of parcels escaped
List<List<label>> nEscape_;
// Bookkeeping for particle fates
//- Mass of parcels escaped
List<List<scalar>> massEscape_;
//- Number of parcels escaped
List<List<label>> nEscape_;
//- Number of parcels stuck to patches
List<List<label>> nStick_;
//- Mass of parcels escaped
List<List<scalar>> massEscape_;
//- 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
bool writeFields_;
@ -89,6 +91,13 @@ class LocalInteraction
autoPtr<volScalarField> massStickPtr_;
protected:
// Protected Member Functions
//- Output file header information
virtual void writeFileHeader(Ostream& os);
public:

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016 OpenCFD Ltd.
Copyright (C) 2016-2019 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -40,6 +40,20 @@ Foam::wordList Foam::PatchInteractionModel<CloudType>::interactionTypeNames_
};
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
template<class CloudType>
void Foam::PatchInteractionModel<CloudType>::writeFileHeader(Ostream& os)
{
this->writeHeader(os, "Particle patch interaction");
this->writeHeaderValue(os, "Model", this->modelType());
this->writeCommented(os, "Time");
this->writeTabbed(os, "escapedParcels");
this->writeTabbed(os, "escapedMass");
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class CloudType>
@ -120,6 +134,7 @@ Foam::PatchInteractionModel<CloudType>::PatchInteractionModel
)
:
CloudSubModelBase<CloudType>(owner),
functionObjects::writeFile(owner, this->localPath(), typeName, false),
UName_("unknown_U"),
escapedParcels_(0),
escapedMass_(0.0)
@ -135,6 +150,14 @@ Foam::PatchInteractionModel<CloudType>::PatchInteractionModel
)
:
CloudSubModelBase<CloudType>(owner, dict, typeName, type),
functionObjects::writeFile
(
owner,
this->localPath(),
type,
this->coeffDict(),
false // Do not write by default
),
UName_(this->coeffDict().lookupOrDefault("U", word("U"))),
escapedParcels_(0),
escapedMass_(0.0)
@ -148,6 +171,7 @@ Foam::PatchInteractionModel<CloudType>::PatchInteractionModel
)
:
CloudSubModelBase<CloudType>(pim),
functionObjects::writeFile(pim),
UName_(pim.UName_),
escapedParcels_(pim.escapedParcels_),
escapedMass_(pim.escapedMass_)
@ -170,7 +194,7 @@ void Foam::PatchInteractionModel<CloudType>::addToEscapedParcels
)
{
escapedMass_ += mass;
escapedParcels_++;
++escapedParcels_;
}
@ -191,6 +215,18 @@ void Foam::PatchInteractionModel<CloudType>::info(Ostream& os)
<< " - escape = " << escapedParcelsTotal
<< ", " << escapedMassTotal << endl;
if (!this->writtenHeader_)
{
this->writeFileHeader(this->file());
this->writtenHeader_ = true;
this->file() << endl;
}
this->writeCurrentTime(this->file());
this->file()
<< tab << escapedParcelsTotal << tab << escapedMassTotal;
if (this->writeTime())
{
this->setBaseProperty("escapedParcels", escapedParcelsTotal);

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -48,6 +49,7 @@ SourceFiles
#include "wallPolyPatch.H"
#include "tetIndices.H"
#include "CloudSubModelBase.H"
#include "writeFile.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -61,7 +63,8 @@ namespace Foam
template<class CloudType>
class PatchInteractionModel
:
public CloudSubModelBase<CloudType>
public CloudSubModelBase<CloudType>,
public functionObjects::writeFile
{
public:
@ -82,7 +85,7 @@ public:
protected:
// Private data
// Protected data
//- Name of velocity field - default = "U"
const word UName_;
@ -97,6 +100,11 @@ protected:
scalar escapedMass_;
// Protected Member Functions
//- Output file header information
virtual void writeFileHeader(Ostream& os);
public:

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2015-2018 OpenCFD Ltd.
Copyright (C) 2015-2019 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -28,6 +28,29 @@ License
#include "StandardWallInteraction.H"
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
template<class CloudType>
void Foam::StandardWallInteraction<CloudType>::writeFileHeader(Ostream& os)
{
PatchInteractionModel<CloudType>::writeFileHeader(os);
forAll(nEscape_, patchi)
{
const word& patchName = mesh_.boundary()[patchi].name();
forAll(nEscape_[patchi], injectori)
{
const word suffix = Foam::name(injectori);
this->writeTabbed(os, patchName + "_nEscape_" + suffix);
this->writeTabbed(os, patchName + "_massEscape_" + suffix);
this->writeTabbed(os, patchName + "_nStick_" + suffix);
this->writeTabbed(os, patchName + "_massStick_" + suffix);
}
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class CloudType>
@ -51,8 +74,8 @@ Foam::StandardWallInteraction<CloudType>::StandardWallInteraction
massStick_(nEscape_.size()),
injIdToIndex_()
{
const bool outputByInjectorId
= this->coeffDict().lookupOrDefault("outputByInjectorId", false);
const bool outputByInjectorId =
this->coeffDict().lookupOrDefault("outputByInjectorId", false);
switch (interactionType_)
{
@ -277,33 +300,48 @@ void Foam::StandardWallInteraction<CloudType>::info(Ostream& os)
indexToInjector[iter.val()] = iter.key();
}
forAll(npe, i)
forAll(npe, patchi)
{
forAll(mpe[i], idx)
forAll(mpe[patchi], indexi)
{
os << " Parcel fate: patch " << mesh_.boundary()[i].name()
const word& patchName = mesh_.boundary()[patchi].name() ;
os << " Parcel fate: patch " << patchName
<< " (number, mass)" << nl
<< " - escape (injector " << indexToInjector[idx]
<< ") = " << npe[i][idx]
<< ", " << mpe[i][idx] << nl
<< " - stick (injector " << indexToInjector[idx]
<< ") = " << nps[i][idx]
<< ", " << mps[i][idx] << nl;
<< " - escape (injector " << indexToInjector[indexi]
<< ") = " << npe[patchi][indexi]
<< ", " << mpe[patchi][indexi] << nl
<< " - stick (injector " << indexToInjector[indexi]
<< ") = " << nps[patchi][indexi]
<< ", " << mps[patchi][indexi] << nl;
this->file()
<< tab << npe[patchi][indexi] << tab << mpe[patchi][indexi]
<< tab << nps[patchi][indexi] << tab << mps[patchi][indexi];
}
}
this->file() << endl;
}
else
{
forAll(npe, i)
forAll(npe, patchi)
{
os << " Parcel fate: patch (number, mass) "
<< mesh_.boundary()[i].name() << nl
<< " - escape = "
<< npe[i][0] << ", " << mpe[i][0] << nl
<< " - stick = "
<< nps[i][0] << ", " << mps[i][0] << nl;
const word& patchName = mesh_.boundary()[patchi].name();
os << " Parcel fate: patch (number, mass) "
<< patchName << nl
<< " - escape = "
<< npe[patchi][0] << ", " << mpe[patchi][0] << nl
<< " - stick = "
<< nps[patchi][0] << ", " << mps[patchi][0] << nl;
this->file()
<< tab << npe[patchi][0] << tab << mpe[patchi][0]
<< tab << nps[patchi][0] << tab << mps[patchi][0];
}
this->file() << endl;
}
if (this->writeTime())

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2018 OpenCFD Ltd.
Copyright (C) 2018-2019 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -85,19 +85,21 @@ protected:
//- Restitution coefficient
scalar mu_;
// Bookkeeping for particle fates
//- Number of parcels escaped
List<List<label>> nEscape_;
// Bookkeeping for particle fates
//- Mass of parcels escaped
List<List<scalar>> massEscape_;
//- Number of parcels escaped
List<List<label>> nEscape_;
//- Number of parcels stuck to patches
List<List<label>> nStick_;
//- Mass of parcels escaped
List<List<scalar>> massEscape_;
//- 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 escaped/mass particles sorted by injectorID
bool outputByInjectorId_;
@ -107,6 +109,12 @@ protected:
Map<label> injIdToIndex_;
// Protected Member Functions
//- Output file header information
virtual void writeFileHeader(Ostream& os);
public:
//- Runtime type information

View File

@ -121,6 +121,8 @@ subModels
type escape;
}
);
writeToFile yes;
}
RanzMarshallCoeffs