Commit b05f2793 authored by andy's avatar andy
Browse files

ENH: Added face post-processing for particle clouds

parent de32813f
......@@ -19,7 +19,8 @@ EXE_INC = \
-I$(LIB_SRC)/thermophysicalModels/radiationModels/lnInclude \
-I$(LIB_SRC)/ODE/lnInclude \
-I$(LIB_SRC)/regionModels/regionModel/lnInclude \
-I$(LIB_SRC)/regionModels/surfaceFilmModels/lnInclude
-I$(LIB_SRC)/regionModels/surfaceFilmModels/lnInclude \
-I$(LIB_SRC)/sampling/lnInclude
EXE_LIBS = \
-lfiniteVolume \
......@@ -42,4 +43,5 @@ EXE_LIBS = \
-lradiationModels \
-lODE \
-lregionModels \
-lsurfaceFilmModels
-lsurfaceFilmModels \
-lsampling
......@@ -20,6 +20,7 @@ EXE_INC = \
-I$(LIB_SRC)/regionModels/regionModel/lnInclude \
-I$(LIB_SRC)/regionModels/surfaceFilmModels/lnInclude \
-I$(LIB_SRC)/ODE/lnInclude \
-I$(LIB_SRC)/sampling/lnInclude \
-I$(FOAM_SOLVERS)/combustion/reactingFoam
......@@ -45,4 +46,5 @@ EXE_LIBS = \
-lradiationModels \
-lregionModels \
-lsurfaceFilmModels \
-lODE
-lODE \
-lsampling
......@@ -14,7 +14,8 @@ EXE_INC = \
-I$(LIB_SRC)/regionModels/regionModel/lnInclude \
-I$(LIB_SRC)/regionModels/surfaceFilmModels/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude \
-I$(LIB_SRC)/dynamicFvMesh/lnInclude
-I$(LIB_SRC)/dynamicFvMesh/lnInclude \
-I$(LIB_SRC)/sampling/lnInclude
EXE_LIBS = \
......@@ -33,4 +34,5 @@ EXE_LIBS = \
-lsurfaceFilmModels \
-ldynamicMesh \
-ldynamicFvMesh \
-ltopoChangerFvMesh
-ltopoChangerFvMesh \
-lsampling
......@@ -12,6 +12,7 @@ EXE_INC = \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/regionModels/regionModel/lnInclude \
-I$(LIB_SRC)/regionModels/surfaceFilmModels/lnInclude \
-I$(LIB_SRC)/sampling/lnInclude
EXE_LIBS = \
-llagrangian \
......@@ -26,4 +27,5 @@ EXE_LIBS = \
-lfiniteVolume \
-lmeshTools \
-lregionModels \
-lsurfaceFilmModels
-lsurfaceFilmModels \
-lsampling
......@@ -20,6 +20,7 @@ EXE_INC = \
-I$(LIB_SRC)/ODE/lnInclude \
-I$(LIB_SRC)/regionModels/regionModel/lnInclude \
-I$(LIB_SRC)/regionModels/surfaceFilmModels/lnInclude \
-I$(LIB_SRC)/sampling/lnInclude \
-I$(FOAM_SOLVERS)/combustion/reactingFoam
......@@ -44,4 +45,5 @@ EXE_LIBS = \
-lradiationModels \
-lODE \
-lregionModels \
-lsurfaceFilmModels
-lsurfaceFilmModels \
-lsampling
......@@ -19,6 +19,7 @@ EXE_INC = \
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
-I$(LIB_SRC)/lagrangian/intermediate/lnInclude \
-I$(LIB_SRC)/ODE/lnInclude \
-I$(LIB_SRC)/sampling/lnInclude \
-I$(FOAM_SOLVERS)/combustion/reactingFoam
......@@ -39,4 +40,5 @@ EXE_LIBS = \
-lradiationModels \
-lsurfaceFilmModels \
-llagrangianIntermediate \
-lODE
-lODE \
-lsampling
......@@ -19,6 +19,7 @@ EXE_INC = \
-I$(LIB_SRC)/ODE/lnInclude \
-I$(LIB_SRC)/regionModels/regionModel/lnInclude \
-I$(LIB_SRC)/regionModels/surfaceFilmModels/lnInclude \
-I$(LIB_SRC)/sampling/lnInclude \
-I$(FOAM_SOLVERS)/combustion/reactingFoam
......@@ -43,4 +44,5 @@ EXE_LIBS = \
-lradiationModels \
-lODE \
-lregionModels \
-lsurfaceFilmModels
-lsurfaceFilmModels \
-lsampling
......@@ -9,7 +9,8 @@ EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/regionModels/regionModel/lnInclude \
-I$(LIB_SRC)/regionModels/surfaceFilmModels/lnInclude
-I$(LIB_SRC)/regionModels/surfaceFilmModels/lnInclude \
-I$(LIB_SRC)/sampling/lnInclude
EXE_LIBS = \
-llagrangian \
......@@ -24,4 +25,5 @@ EXE_LIBS = \
-lfiniteVolume \
-lmeshTools \
-lregionModels \
-lsurfaceFilmModels
-lsurfaceFilmModels \
-lsampling
......@@ -19,7 +19,8 @@ EXE_INC = \
-I$(LIB_SRC)/turbulenceModels/LES/LESdeltas/lnInclude \
-I$(LIB_SRC)/turbulenceModels/compressible/LES/lnInclude \
-I$(LIB_SRC)/regionModels/regionModel/lnInclude \
-I$(LIB_SRC)/regionModels/surfaceFilmModels/lnInclude
-I$(LIB_SRC)/regionModels/surfaceFilmModels/lnInclude \
-I$(LIB_SRC)/sampling/lnInclude
LIB_LIBS = \
-lfiniteVolume \
......
......@@ -19,7 +19,8 @@ EXE_INC = \
-I$(LIB_SRC)/turbulenceModels/compressible/LES/lnInclude \
-I$(LIB_SRC)/regionModels/regionModel/lnInclude \
-I$(LIB_SRC)/regionModels/surfaceFilmModels/lnInclude \
-I$(LIB_SRC)/dynamicFvMesh/lnInclude
-I$(LIB_SRC)/dynamicFvMesh/lnInclude \
-I$(LIB_SRC)/sampling/lnInclude
LIB_LIBS = \
-lfiniteVolume \
......
......@@ -29,10 +29,11 @@ Description
- cloud function objects
- particle forces
- particle forces, e.g.
- buoyancy
- drag
- pressure gradient
- ...
- sub-models:
- dispersion model
......
......@@ -28,6 +28,7 @@ License
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "FacePostProcessing.H"
#include "ParticleTracks.H"
#include "PatchPostProcessing.H"
......@@ -37,6 +38,7 @@ License
\
makeCloudFunctionObject(CloudType); \
\
makeCloudFunctionObjectType(FacePostProcessing, CloudType); \
makeCloudFunctionObjectType(ParticleTracks, CloudType); \
makeCloudFunctionObjectType(PatchPostProcessing, CloudType);
......
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2011 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 "FacePostProcessing.H"
#include "Pstream.H"
#include "ListListOps.H"
#include "surfaceWriter.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class CloudType>
Foam::label Foam::FacePostProcessing<CloudType>::applyToFace
(
const label faceI
) const
{
forAll(fZone_, i)
{
if (fZone_[i] == faceI)
{
return i;
}
}
return -1;
}
template<class CloudType>
void Foam::FacePostProcessing<CloudType>::write()
{
const fvMesh& mesh = this->owner().mesh();
const scalar dt = this->owner().time().deltaTValue();
totalTime_ += dt;
const scalar alpha = (totalTime_ - dt)/totalTime_;
const scalar beta = dt/totalTime_;
massTotal_ += mass_;
massFlux_ = alpha*massFlux_ + beta*mass_/dt;
const label procI = Pstream::myProcNo();
scalarListList allProcMass(Pstream::nProcs());
allProcMass[procI].setSize(massTotal_.size());
allProcMass[procI] = massTotal_;
Pstream::gatherList(allProcMass);
scalarList allMass
(
ListListOps::combine<scalarList>
(
allProcMass, accessOp<scalarList>()
)
);
scalarListList allProcMassFlux(Pstream::nProcs());
allProcMassFlux[procI].setSize(massFlux_.size());
allProcMassFlux[procI] = massFlux_;
Pstream::gatherList(allProcMassFlux);
scalarList allMassFlux
(
ListListOps::combine<scalarList>
(
allProcMassFlux, accessOp<scalarList>()
)
);
Info<< "particleFaceFlux output:" << nl
<< " total mass = " << sum(allMass) << nl
<< " average mass flux = " << sum(allMassFlux) << nl << endl;
if (surfaceFormat_ != "none")
{
labelList pointToGlobal;
labelList uniqueMeshPointLabels;
autoPtr<globalIndex> globalPointsPtr =
mesh.globalData().mergePoints
(
fZone_().meshPoints(),
fZone_().meshPointMap(),
pointToGlobal,
uniqueMeshPointLabels
);
pointField uniquePoints(mesh.points(), uniqueMeshPointLabels);
List<pointField> allProcPoints(Pstream::nProcs());
allProcPoints[procI].setSize(uniquePoints.size());
allProcPoints[procI] = uniquePoints;
Pstream::gatherList(allProcPoints);
pointField allPoints
(
ListListOps::combine<pointField>
(
allProcPoints, accessOp<pointField>()
)
);
faceList faces(fZone_().localFaces());
forAll(faces, i)
{
inplaceRenumber(pointToGlobal, faces[i]);
}
List<faceList> allProcFaces(Pstream::nProcs());
allProcFaces[procI].setSize(faces.size());
allProcFaces[procI] = faces;
Pstream::gatherList(allProcFaces);
faceList allFaces
(
ListListOps::combine<faceList>
(
allProcFaces, accessOp<faceList>()
)
);
if (Pstream::master())
{
fileName outputDir = mesh.time().path();
if (Pstream::parRun())
{
// Put in undecomposed case (Note: gives problems for
// distributed data running)
outputDir =
outputDir/".."/"postProcessing"/cloud::prefix/
this->owner().name()/mesh.time().timeName();
}
else
{
outputDir =
outputDir/"postProcessing"/cloud::prefix/
this->owner().name()/mesh.time().timeName();
}
autoPtr<surfaceWriter> writer(surfaceWriter::New(surfaceFormat_));
writer->write
(
outputDir,
"massTotal",
allPoints,
allFaces,
"massTotal",
massTotal_,
false
);
writer->write
(
outputDir,
"massFlux",
allPoints,
allFaces,
"massFlux",
massFlux_,
false
);
}
}
if (resetOnWrite_)
{
massFlux_ = 0.0;
totalTime_ = 0.0;
}
mass_ = 0.0;
// writeProperties();
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class CloudType>
Foam::FacePostProcessing<CloudType>::FacePostProcessing
(
const dictionary& dict,
CloudType& owner
)
:
CloudFunctionObject<CloudType>(dict, owner, typeName),
fZone_(owner.mesh().faceZones()[this->coeffDict().lookup("faceZone")]),
surfaceFormat_(this->coeffDict().lookup("surfaceFormat")),
resetOnWrite_(this->coeffDict().lookup("resetOnWrite")),
totalTime_(0.0),
mass_(),
massTotal_(),
massFlux_()
{
label allFaces = returnReduce(fZone_().size(), sumOp<scalar>());
Info<< " Number of faces = " << allFaces << endl;
mass_.setSize(fZone_.size(), 0.0);
// readProperties(); AND initialise mass... fields
massTotal_.setSize(fZone_.size(), 0.0);
massFlux_.setSize(fZone_.size(), 0.0);
}
template<class CloudType>
Foam::FacePostProcessing<CloudType>::FacePostProcessing
(
const FacePostProcessing<CloudType>& pff
)
:
CloudFunctionObject<CloudType>(pff),
fZone_(pff.fZone_.clone(pff.fZone_.zoneMesh())),
surfaceFormat_(pff.surfaceFormat_),
resetOnWrite_(pff.resetOnWrite_),
totalTime_(pff.totalTime_),
mass_(pff.mass_),
massTotal_(pff.massTotal_),
massFlux_(pff.massFlux_)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class CloudType>
Foam::FacePostProcessing<CloudType>::~FacePostProcessing()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class CloudType>
void Foam::FacePostProcessing<CloudType>::postPatch
(
const parcelType&,
const label
)
{}
template<class CloudType>
void Foam::FacePostProcessing<CloudType>::postFace(const parcelType& p)
{
if
(
this->owner().solution().output()
|| this->owner().solution().transient()
)
{
const label faceI = applyToFace(p.face());
if (faceI != -1)
{
mass_[faceI] += p.mass()*p.nParticle();
}
}
}
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2011 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::FacePostProcessing
Description
Records particle face quantities on used-specified face zone
Currently supports:
accummulated mass
average mass flux
SourceFiles
FacePostProcessing.C
\*---------------------------------------------------------------------------*/
#ifndef FacePostProcessing_H
#define FacePostProcessing_H
#include "CloudFunctionObject.H"
#include "faceZone.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class FacePostProcessing Declaration
\*---------------------------------------------------------------------------*/
template<class CloudType>
class FacePostProcessing
:
public CloudFunctionObject<CloudType>
{
// Private Data
// Typedefs
//- Convenience typedef for parcel type
typedef typename CloudType::parcelType parcelType;
//- Face zone
const faceZone& fZone_;
//- Surface output format
const word surfaceFormat_;
//- Flag to indicate whether data should be reset/cleared on writing
Switch resetOnWrite_;
//- Total time
scalar totalTime_;
//- Mass storage
scalarField mass_;
//- Mass total storage
scalarField massTotal_;
//- Mass flux storage
scalarField massFlux_;
// Private Member Functions
//- Return index into massFlux_ list if valid face, else -1
label applyToFace(const label faceI) const;
protected:
// Protected Member Functions
//- Write post-processing info
void write();
public:
//- Runtime type information
TypeName("facePostProcessing");
// Constructors
//- Construct from dictionary
FacePostProcessing(const dictionary& dict, CloudType& owner);
//- Construct copy
FacePostProcessing(const FacePostProcessing<CloudType>& ppm);
//- Construct and return a clone
virtual autoPtr<CloudFunctionObject<CloudType> > clone() const
{
return autoPtr<CloudFunctionObject<CloudType> >
(
new FacePostProcessing<CloudType>(*this)
);
}
//- Destructor
virtual ~FacePostProcessing();