Commit 271c8c8c authored by Andrew Heather's avatar Andrew Heather
Browse files

ENH: Added new extractEulerianParticles function object

Generates discrete particle data from multiphase calculations by
interrogating the phase fraction field at a faceZone.

Data is written in raw form, i.e. per particle collected, with
as an optional binned distribution
parent 47439e49
......@@ -72,6 +72,8 @@ externalCoupled/externalCoupled.C
externalCoupled/externalCoupledMixed/externalCoupledMixedFvPatchFields.C
externalCoupled/externalCoupledTemperatureMixed/externalCoupledTemperatureMixedFvPatchScalarField.C
extractEulerianParticles/extractEulerianParticles/extractEulerianParticles.C
ddt2/ddt2.C
zeroGradient/zeroGradient.C
......
......@@ -2,6 +2,7 @@ EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
-I$(LIB_SRC)/lagrangian/distributionModels/lnInclude \
-I$(LIB_SRC)/fileFormats/lnInclude \
-I$(LIB_SRC)/sampling/lnInclude \
-I$(LIB_SRC)/surfMesh/lnInclude \
......@@ -19,18 +20,22 @@ EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/sampling/lnInclude \
-I$(LIB_SRC)/surfMesh/lnInclude
-I$(LIB_SRC)/surfMesh/lnInclude \
-I$(LIB_SRC)/fvAgglomerationMethods/pairPatchAgglomeration/lnInclude
LIB_LIBS = \
-lfiniteVolume \
-lmeshTools \
-llagrangian \
-ldistributionModels \
-lsampling \
-lsurfMesh \
-lfluidThermophysicalModels \
-lincompressibleTransportModels \
-lturbulenceModels \
-lcompressibleTransportModels \
-lincompressibleTurbulenceModels \
-lcompressibleTurbulenceModels \
-lmeshTools \
-lsampling \
-lsurfMesh \
-lchemistryModel \
-lreactionThermophysicalModels
-lreactionThermophysicalModels \
-lpairPatchAgglomeration
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015-2016 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "eulerianParticle.H"
#include "mathematicalConstants.H"
using namespace Foam::constant;
// * * * * * * * * * * * * * * * * Constructor * * * * * * * * * * * * * * * //
Foam::functionObjects::eulerianParticle::eulerianParticle()
:
globalFaceIHit(-1),
VC(vector::zero),
VU(vector::zero),
V(0),
time(0),
timeIndex(0)
{}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
Foam::Ostream& Foam::operator<<(Ostream& os, const eulerianParticle& p)
{
os << p.globalFaceIHit << token::SPACE
<< p.VC << token::SPACE
<< p.VU << token::SPACE
<< p.V << token::SPACE
<< p.time << token::SPACE
<< p.timeIndex;
return os;
}
Foam::Istream& Foam::operator>>(Istream& is, eulerianParticle& p)
{
is >> p.globalFaceIHit
>> p.VC
>> p.VU
>> p.V
>> p.time
>> p.timeIndex;
return is;
}
void Foam::functionObjects::eulerianParticle::write(Ostream& os) const
{
scalar pDiameter = cbrt(6*V/constant::mathematical::pi);
vector U = VU/(V + ROOTVSMALL);
vector C = VC/(V + ROOTVSMALL);
os << time << token::SPACE
<< globalFaceIHit << token::SPACE
<< C << token::SPACE
<< pDiameter << token::SPACE
<< U << token::SPACE
<< endl;
}
Foam::dictionary Foam::functionObjects::eulerianParticle::writeDict() const
{
scalar pDiameter = cbrt(6*V/constant::mathematical::pi);
vector U = VU/(V + ROOTVSMALL);
vector C = VC/(V + ROOTVSMALL);
dictionary dict;
dict.add("time", time);
dict.add("meshFace", globalFaceIHit);
dict.add("position", C);
dict.add("diameter", pDiameter);
dict.add("U", U);
return dict;
}
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015-2016 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::eulerianParticle
Description
Lightweight class to store particle data derived from VOF calculations,
with special handling for input, output and parallel reduction.
SourceFiles
eulerianParticle.H
eulerianParticle.C
eulerianParticleTemplates.C
\*---------------------------------------------------------------------------*/
#ifndef functionObjects_eulerianParticle_H
#define functionObjects_eulerianParticle_H
#include "label.H"
#include "scalar.H"
#include "vector.H"
#include "dictionary.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of classes
class Istream;
class Ostream;
namespace functionObjects
{
class eulerianParticle;
}
// Forward declaration of friend functions and operators
Istream& operator>>(Istream&, functionObjects::eulerianParticle&);
Ostream& operator<<(Ostream&, const functionObjects::eulerianParticle&);
namespace functionObjects
{
/*---------------------------------------------------------------------------*\
Class eulerianParticle Declaration
\*---------------------------------------------------------------------------*/
class eulerianParticle
{
public:
// Public data
//- Index of face in faceZone that this particle hits. Also used to
// identify the index of the coarse face of the surface agglomeration
// Note: value of -1 used to indicate that the particle has not
// been initialised
label globalFaceIHit;
//- Volume multiplied by face centres [m4]
vector VC;
//- Volume multiplied by velocity [m4/s]
vector VU;
//- Volume [m3]
scalar V;
//- Injection time - set at collection [s]
scalar time;
//- Index of last output time
label timeIndex;
//- Constructor
eulerianParticle();
// Public Member Functions
//- Write to stream
void write(Ostream& os) const;
//- Write to dictionary
Foam::dictionary writeDict() const;
// Operators
friend bool operator==
(
const eulerianParticle& a,
const eulerianParticle& b
)
{
return
a.globalFaceIHit == b.globalFaceIHit
&& a.VC == b.VC
&& a.VU == b.VU
&& a.V == b.V
&& a.time == b.time
&& a.timeIndex == b.timeIndex;
}
friend bool operator!=
(
const eulerianParticle& a,
const eulerianParticle& b
)
{
return !(a == b);
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace functionObjects
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "eulerianParticleTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015-2016 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
namespace Foam
{
namespace functionObjects
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class VOFParticle>
class sumParticleOp
{
public:
eulerianParticle operator()
(
const eulerianParticle& p0,
const eulerianParticle& p1
) const
{
if ((p0.globalFaceIHit != -1) && (p1.globalFaceIHit == -1))
{
return p0;
}
else if ((p0.globalFaceIHit == -1) && (p1.globalFaceIHit != -1))
{
return p1;
}
else if ((p0.globalFaceIHit != -1) && (p1.globalFaceIHit != -1))
{
// Choose particle with the largest collected volume and
// accumulate total volume
if (p0.V > p1.V)
{
eulerianParticle p = p0;
p.V = p0.V + p1.V;
p.VC = p0.VC + p1.VC;
p.VU = p0.VU + p1.VU;
return p;
}
else
{
eulerianParticle p = p1;
p.V = p0.V + p1.V;
p.VC = p0.VC + p1.VC;
p.VU = p0.VU + p1.VU;
return p;
}
}
else
{
eulerianParticle p;
return p;
}
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace functionObjects
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015-2016 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::functionObjects::extractEulerianParticles
Group
grpFieldFunctionObjects
Description
Generates particle size information from Eulerian calculations, e.g. VoF.
Particle data is written to the directory:
\verbatim
$FOAM_CASE/postProcessing/<name>/rawParticlesDict
$FOAM_CASE/postProcessing/<name>/particleDistribution
\endverbatim
Usage
extractEulerianParticles1
{
type extractEulerianParticles;
libs ("libfieldFunctionObjects.so");
...
faceZone f0;
nLocations 10;
alphaName alpha.water;
UName U;
rhoName rho;
phiName phi;
createDistribution yes;
distributionBinWidth 1e-4;
resetDistributionOnWrite no;
writeRawData yes;
}
\endverbatim
where the entries comprise:
\table
Property | Description | Required | Default value
type | type name: extractEulerianParticles | yes |
faceZone | Name of faceZone used as collection surface | yes |
nLocations | Number of injection bins to generate | yes |
aplhaName | Name of phase indicator field | yes |
rhoName | Name of density field | yes |
phiNane | Name of flux field | yes |
createDistribution | Flag to create a binned distribution | yes |
distributionBinWidth | Binned distribution bin width| yes |
writeRawData | Flag to write raw particle data | yes |
\endtable
SourceFiles
extractEulerianParticles.C
\*---------------------------------------------------------------------------*/
#ifndef functionObjects_extractEulerianParticles_H
#define functionObjects_extractEulerianParticles_H
#include "fvMeshFunctionObject.H"
#include "writeFile.H"
#include "runTimeSelectionTables.H"
#include "polyMesh.H"
#include "surfaceFieldsFwd.H"
#include "vectorList.H"
#include "globalIndex.H"
#include "cachedRandom.H"
#include "eulerianParticle.H"
#include "IOdictionary.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace functionObjects
{
/*---------------------------------------------------------------------------*\
Class extractEulerianParticlesFunctionObject Declaration
\*---------------------------------------------------------------------------*/
class extractEulerianParticles
:
public fvMeshFunctionObject,
public writeFile
{
protected:
// Protected data
//- Flag to write the raw collected particle data
bool writeRawData_;
//- Raw particle output dictionary
autoPtr<IOdictionary> rawParticlesDictPtr_;
//- List to keep track of output times
DynamicList<scalar> outputTimes_;
// faceZone info
//- Name of faceZone to sample
word faceZoneName_;
//- Index of the faceZone
label zoneID_;
//- Patch indices where faceZone face intersect patch
labelList patchIDs_;
//- Patch face indices where faceZone face intersect patch
labelList patchFaceIDs_;
//- Global face addressing
globalIndex globalFaces_;
// Field names
//- Name of phase fraction field
word alphaName_;
//- Value of phase fraction used to identify particle boundaries
scalar alphaThreshold_;
//- Name of the velocity field, default = U
word UName_;
//- Name of the density field, defauls = rho
word rhoName_;
//- Name of the flux field, default ="rho"
word phiName_;
// Agglomeration
//- Number of sample locations to generate
label nInjectorLocations_;
//- Agglomeration addressing from fine to coarse
labelList fineToCoarseAddr_;
//- Agglomeration addressing from coarse to fine
labelListList coarseToFineAddr_;
//- Coarse face positions
vectorList coarsePosition_;
//- Global coarse face addressing
globalIndex globalCoarseFaces_;
// Particle collection info
//- Time of last write step
scalar lastOutputTime_;
//- Region indices in faceZone faces from last iteration
labelList regions0_;
//- Number of regions from last iteration
label nRegions0_;
//- Particle properties (partial, being accumulated)
List<eulerianParticle> particles_;
//- Map from region to index in particles_ list
Map<label> regionToParticleMap_;