mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: Lagrangian - added new PatchInteractionFields cloud function object
Creates volume fields whose boundaries are used to store patch interaction
statistics.
Current field output per patch face:
- \<cloud\>\<model\>:count - cumulative particle hits
- \<cloud\>\<model\>:mass - cumuluative mass of hitting particles
Fields can be reset according to:
- none: fields are not reset
- timeStep: reset at each time step
- writeTime: reset at each write time
Usage
patchInteractionFields1
{
type patchInteractionFields;
resetMode writeTime;
}
This commit is contained in:
committed by
Andrew Heather
parent
8268d8aaba
commit
9d765adaf4
@ -37,6 +37,7 @@ License
|
|||||||
#include "ParticleTracks.H"
|
#include "ParticleTracks.H"
|
||||||
#include "ParticleTrap.H"
|
#include "ParticleTrap.H"
|
||||||
#include "PatchCollisionDensity.H"
|
#include "PatchCollisionDensity.H"
|
||||||
|
#include "PatchInteractionFields.H"
|
||||||
#include "PatchPostProcessing.H"
|
#include "PatchPostProcessing.H"
|
||||||
#include "PatchParticleHistogram.H"
|
#include "PatchParticleHistogram.H"
|
||||||
#include "RemoveParcels.H"
|
#include "RemoveParcels.H"
|
||||||
@ -54,6 +55,7 @@ License
|
|||||||
makeCloudFunctionObjectType(ParticleTracks, CloudType); \
|
makeCloudFunctionObjectType(ParticleTracks, CloudType); \
|
||||||
makeCloudFunctionObjectType(ParticleTrap, CloudType); \
|
makeCloudFunctionObjectType(ParticleTrap, CloudType); \
|
||||||
makeCloudFunctionObjectType(PatchCollisionDensity, CloudType); \
|
makeCloudFunctionObjectType(PatchCollisionDensity, CloudType); \
|
||||||
|
makeCloudFunctionObjectType(PatchInteractionFields, CloudType); \
|
||||||
makeCloudFunctionObjectType(PatchPostProcessing, CloudType); \
|
makeCloudFunctionObjectType(PatchPostProcessing, CloudType); \
|
||||||
makeCloudFunctionObjectType(PatchParticleHistogram, CloudType); \
|
makeCloudFunctionObjectType(PatchParticleHistogram, CloudType); \
|
||||||
makeCloudFunctionObjectType(RemoveParcels, CloudType); \
|
makeCloudFunctionObjectType(RemoveParcels, CloudType); \
|
||||||
|
|||||||
@ -37,6 +37,7 @@ License
|
|||||||
#include "ParticleTracks.H"
|
#include "ParticleTracks.H"
|
||||||
#include "ParticleTrap.H"
|
#include "ParticleTrap.H"
|
||||||
#include "PatchCollisionDensity.H"
|
#include "PatchCollisionDensity.H"
|
||||||
|
#include "PatchInteractionFields.H"
|
||||||
#include "PatchPostProcessing.H"
|
#include "PatchPostProcessing.H"
|
||||||
#include "PatchParticleHistogram.H"
|
#include "PatchParticleHistogram.H"
|
||||||
#include "RemoveParcels.H"
|
#include "RemoveParcels.H"
|
||||||
@ -55,6 +56,7 @@ License
|
|||||||
makeCloudFunctionObjectType(ParticleTracks, CloudType); \
|
makeCloudFunctionObjectType(ParticleTracks, CloudType); \
|
||||||
makeCloudFunctionObjectType(ParticleTrap, CloudType); \
|
makeCloudFunctionObjectType(ParticleTrap, CloudType); \
|
||||||
makeCloudFunctionObjectType(PatchCollisionDensity, CloudType); \
|
makeCloudFunctionObjectType(PatchCollisionDensity, CloudType); \
|
||||||
|
makeCloudFunctionObjectType(PatchInteractionFields, CloudType); \
|
||||||
makeCloudFunctionObjectType(PatchPostProcessing, CloudType); \
|
makeCloudFunctionObjectType(PatchPostProcessing, CloudType); \
|
||||||
makeCloudFunctionObjectType(PatchParticleHistogram, CloudType); \
|
makeCloudFunctionObjectType(PatchParticleHistogram, CloudType); \
|
||||||
makeCloudFunctionObjectType(RemoveParcels, CloudType); \
|
makeCloudFunctionObjectType(RemoveParcels, CloudType); \
|
||||||
|
|||||||
@ -0,0 +1,188 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | www.openfoam.com
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Copyright (C) 2020 OpenCFD Ltd.
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
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 "PatchInteractionFields.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class CloudType>
|
||||||
|
const Foam::Enum<typename Foam::PatchInteractionFields<CloudType>::resetMode>
|
||||||
|
Foam::PatchInteractionFields<CloudType>::resetModeNames_
|
||||||
|
({
|
||||||
|
{ resetMode::none, "none" },
|
||||||
|
{ resetMode::timeStep, "timeStep" },
|
||||||
|
{ resetMode::writeTime, "writeTime" },
|
||||||
|
});
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class CloudType>
|
||||||
|
void Foam::PatchInteractionFields<CloudType>::clearOrReset
|
||||||
|
(
|
||||||
|
autoPtr<volScalarField>& fieldPtr,
|
||||||
|
const word& fieldName,
|
||||||
|
const dimensionSet& dims
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
if (fieldPtr)
|
||||||
|
{
|
||||||
|
fieldPtr->primitiveFieldRef() = 0.0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const fvMesh& mesh = this->owner().mesh();
|
||||||
|
|
||||||
|
fieldPtr.reset
|
||||||
|
(
|
||||||
|
new volScalarField
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
this->owner().name() + ":" + this->modelName() + ":" + fieldName,
|
||||||
|
mesh.time().timeName(),
|
||||||
|
mesh,
|
||||||
|
IOobject::READ_IF_PRESENT,
|
||||||
|
IOobject::NO_WRITE
|
||||||
|
),
|
||||||
|
mesh,
|
||||||
|
dimensionedScalar(dims, Zero)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class CloudType>
|
||||||
|
void Foam::PatchInteractionFields<CloudType>::reset()
|
||||||
|
{
|
||||||
|
clearOrReset(massPtr_, "mass", dimMass);
|
||||||
|
clearOrReset(countPtr_, "count", dimless);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class CloudType>
|
||||||
|
void Foam::PatchInteractionFields<CloudType>::write()
|
||||||
|
{
|
||||||
|
if (massPtr_)
|
||||||
|
{
|
||||||
|
massPtr_->write();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FatalErrorInFunction
|
||||||
|
<< "massPtr not valid" << abort(FatalError);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (countPtr_)
|
||||||
|
{
|
||||||
|
countPtr_->write();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FatalErrorInFunction
|
||||||
|
<< "countPtr not valid" << abort(FatalError);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (resetMode_ == resetMode::writeTime)
|
||||||
|
{
|
||||||
|
reset();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class CloudType>
|
||||||
|
Foam::PatchInteractionFields<CloudType>::PatchInteractionFields
|
||||||
|
(
|
||||||
|
const dictionary& dict,
|
||||||
|
CloudType& owner,
|
||||||
|
const word& modelName
|
||||||
|
)
|
||||||
|
:
|
||||||
|
CloudFunctionObject<CloudType>(dict, owner, modelName, typeName),
|
||||||
|
massPtr_(nullptr),
|
||||||
|
countPtr_(nullptr),
|
||||||
|
resetMode_
|
||||||
|
(
|
||||||
|
resetModeNames_.getOrDefault
|
||||||
|
(
|
||||||
|
"resetMode",
|
||||||
|
this->coeffDict(),
|
||||||
|
resetMode::none
|
||||||
|
)
|
||||||
|
)
|
||||||
|
{
|
||||||
|
reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class CloudType>
|
||||||
|
Foam::PatchInteractionFields<CloudType>::PatchInteractionFields
|
||||||
|
(
|
||||||
|
const PatchInteractionFields<CloudType>& pii
|
||||||
|
)
|
||||||
|
:
|
||||||
|
CloudFunctionObject<CloudType>(pii),
|
||||||
|
massPtr_(nullptr),
|
||||||
|
countPtr_(nullptr),
|
||||||
|
resetMode_(pii.resetMode_)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class CloudType>
|
||||||
|
void Foam::PatchInteractionFields<CloudType>::preEvolve
|
||||||
|
(
|
||||||
|
const typename parcelType::trackingData&
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (resetMode_ == resetMode::timeStep)
|
||||||
|
{
|
||||||
|
reset();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class CloudType>
|
||||||
|
void Foam::PatchInteractionFields<CloudType>::postPatch
|
||||||
|
(
|
||||||
|
const parcelType& p,
|
||||||
|
const polyPatch& pp,
|
||||||
|
bool&
|
||||||
|
)
|
||||||
|
{
|
||||||
|
const label patchi = pp.index();
|
||||||
|
const label facei = pp.whichFace(p.face());
|
||||||
|
|
||||||
|
massPtr_->boundaryFieldRef()[patchi][facei] += p.nParticle()*p.mass();
|
||||||
|
countPtr_->boundaryFieldRef()[patchi][facei] += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,199 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | www.openfoam.com
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Copyright (C) 2020 OpenCFD Ltd.
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
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::PatchInteractionFields
|
||||||
|
|
||||||
|
Group
|
||||||
|
grpLagrangianIntermediateFunctionObjects
|
||||||
|
|
||||||
|
Description
|
||||||
|
Creates volume fields whose boundaries are used to store patch interaction
|
||||||
|
statistics.
|
||||||
|
|
||||||
|
Current field output per patch face:
|
||||||
|
- \<cloud\>\<model\>:count - cumulative particle hits
|
||||||
|
- \<cloud\>\<model\>:mass - cumulative mass of hitting particles
|
||||||
|
|
||||||
|
Fields can be reset according to:
|
||||||
|
- none: fields are not reset
|
||||||
|
- timeStep: reset at each time step
|
||||||
|
- writeTime: reset at each write time
|
||||||
|
|
||||||
|
Usage
|
||||||
|
|
||||||
|
\verbatim
|
||||||
|
patchInteractionFields1
|
||||||
|
{
|
||||||
|
type patchInteractionFields;
|
||||||
|
resetMode writeTime;
|
||||||
|
}
|
||||||
|
\endverbatim
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
PatchInteractionFields.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef PatchInteractionFields_H
|
||||||
|
#define PatchInteractionFields_H
|
||||||
|
|
||||||
|
#include "CloudFunctionObject.H"
|
||||||
|
#include "volFields.H"
|
||||||
|
#include "Enum.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class PatchInteractionFields Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
template<class CloudType>
|
||||||
|
class PatchInteractionFields
|
||||||
|
:
|
||||||
|
public CloudFunctionObject<CloudType>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
// Public enumerations
|
||||||
|
|
||||||
|
//- Reset mode
|
||||||
|
enum class resetMode
|
||||||
|
{
|
||||||
|
none,
|
||||||
|
timeStep,
|
||||||
|
writeTime
|
||||||
|
};
|
||||||
|
|
||||||
|
static const Enum<resetMode> resetModeNames_;
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
// Private Data
|
||||||
|
|
||||||
|
//- Convenience typedef for parcel type
|
||||||
|
typedef typename CloudType::parcelType parcelType;
|
||||||
|
|
||||||
|
//- Parcel mass field
|
||||||
|
autoPtr<volScalarField> massPtr_;
|
||||||
|
|
||||||
|
//- Parcel count field
|
||||||
|
autoPtr<volScalarField> countPtr_;
|
||||||
|
|
||||||
|
//- Reset mode
|
||||||
|
resetMode resetMode_;
|
||||||
|
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
// Protected Member Functions
|
||||||
|
|
||||||
|
//- Create|read|reset the fields
|
||||||
|
void reset();
|
||||||
|
|
||||||
|
//- Write post-processing info
|
||||||
|
virtual void write();
|
||||||
|
|
||||||
|
//- Helper function to clear or reset fields
|
||||||
|
void clearOrReset
|
||||||
|
(
|
||||||
|
autoPtr<volScalarField>& fieldPtr,
|
||||||
|
const word& fieldName,
|
||||||
|
const dimensionSet& dims
|
||||||
|
) const;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Runtime type information
|
||||||
|
TypeName("patchInteractionFields");
|
||||||
|
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from dictionary
|
||||||
|
PatchInteractionFields
|
||||||
|
(
|
||||||
|
const dictionary& dict,
|
||||||
|
CloudType& owner,
|
||||||
|
const word& modelName
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct copy
|
||||||
|
PatchInteractionFields(const PatchInteractionFields<CloudType>& pii);
|
||||||
|
|
||||||
|
//- Construct and return a clone
|
||||||
|
virtual autoPtr<CloudFunctionObject<CloudType>> clone() const
|
||||||
|
{
|
||||||
|
return autoPtr<CloudFunctionObject<CloudType>>
|
||||||
|
(
|
||||||
|
new PatchInteractionFields<CloudType>(*this)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
virtual ~PatchInteractionFields() = default;
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
// Evaluation
|
||||||
|
|
||||||
|
//- Pre-evolve hook
|
||||||
|
virtual void preEvolve
|
||||||
|
(
|
||||||
|
const typename parcelType::trackingData& td
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Post-patch hook
|
||||||
|
virtual void postPatch
|
||||||
|
(
|
||||||
|
const parcelType& p,
|
||||||
|
const polyPatch& pp,
|
||||||
|
bool& keepParticle
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#ifdef NoRepository
|
||||||
|
#include "PatchInteractionFields.C"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -199,6 +199,12 @@ cloudFunctions
|
|||||||
cycLeft
|
cycLeft
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
patchInteractionFields1
|
||||||
|
{
|
||||||
|
type patchInteractionFields;
|
||||||
|
resetMode writeTime;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user