mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Allow access to particle data
This commit is contained in:
@ -1,431 +0,0 @@
|
|||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
========= |
|
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
||||||
\\ / O peration |
|
|
||||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
|
||||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
|
|
||||||
Class
|
|
||||||
Particle
|
|
||||||
|
|
||||||
Description
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
#ifndef Particle_H
|
|
||||||
#define Particle_H
|
|
||||||
|
|
||||||
#include "vector.H"
|
|
||||||
#include "IDLList.H"
|
|
||||||
#include "labelList.H"
|
|
||||||
#include "pointField.H"
|
|
||||||
#include "typeInfo.H"
|
|
||||||
#include "OFstream.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
namespace Foam
|
|
||||||
{
|
|
||||||
|
|
||||||
template<class Particle>
|
|
||||||
class Cloud;
|
|
||||||
|
|
||||||
class wedgePolyPatch;
|
|
||||||
class symmetryPolyPatch;
|
|
||||||
class cyclicPolyPatch;
|
|
||||||
class processorPolyPatch;
|
|
||||||
class wallPolyPatch;
|
|
||||||
class polyPatch;
|
|
||||||
|
|
||||||
// Forward declaration of friend functions and operators
|
|
||||||
|
|
||||||
template<class ParticleType>
|
|
||||||
class Particle;
|
|
||||||
|
|
||||||
template<class ParticleType>
|
|
||||||
Ostream& operator<<
|
|
||||||
(
|
|
||||||
Ostream&,
|
|
||||||
const Particle<ParticleType>&
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
Class Particle Declaration
|
|
||||||
\*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
template<class ParticleType>
|
|
||||||
class Particle
|
|
||||||
:
|
|
||||||
public IDLList<ParticleType>::link
|
|
||||||
{
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
//- Reference to the particle cloud
|
|
||||||
const Cloud<ParticleType>& cloud_;
|
|
||||||
|
|
||||||
//- Position of particle
|
|
||||||
vector position_;
|
|
||||||
|
|
||||||
//- Index of the cell it is in
|
|
||||||
label celli_;
|
|
||||||
|
|
||||||
//- Face index if the particle is on a face otherwise -1
|
|
||||||
label facei_;
|
|
||||||
|
|
||||||
//- Fraction of time-step completed
|
|
||||||
scalar stepFraction_;
|
|
||||||
|
|
||||||
|
|
||||||
// Private member functions
|
|
||||||
|
|
||||||
//- Return the 'lambda' value for the position, p, on the face,
|
|
||||||
// where, p = from + lamda*(to - from)
|
|
||||||
// for non-static meshes
|
|
||||||
inline scalar lambda
|
|
||||||
(
|
|
||||||
const vector& from,
|
|
||||||
const vector& to,
|
|
||||||
const label facei,
|
|
||||||
const scalar stepFraction
|
|
||||||
);
|
|
||||||
|
|
||||||
//- Return the 'lambda' value for the position, p, on the face,
|
|
||||||
// where, p = from + lamda*(to - from)
|
|
||||||
// for static meshes
|
|
||||||
inline scalar lambda
|
|
||||||
(
|
|
||||||
const vector& from,
|
|
||||||
const vector& to,
|
|
||||||
const label facei
|
|
||||||
);
|
|
||||||
|
|
||||||
//- Return the faces between position and cell centre
|
|
||||||
labelList findFaces
|
|
||||||
(
|
|
||||||
const vector& position
|
|
||||||
);
|
|
||||||
|
|
||||||
//- Return the faces between position and cell centre
|
|
||||||
labelList findFaces
|
|
||||||
(
|
|
||||||
const vector& position,
|
|
||||||
const label celli,
|
|
||||||
const scalar stepFraction
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
//- Overridable function to handle the particle hitting a wedgePatch
|
|
||||||
template<class TrackingData>
|
|
||||||
void hitWedgePatch
|
|
||||||
(
|
|
||||||
const wedgePolyPatch&,
|
|
||||||
TrackingData& td
|
|
||||||
);
|
|
||||||
|
|
||||||
//- Overridable function to handle the particle hitting a symmetryPatch
|
|
||||||
template<class TrackingData>
|
|
||||||
void hitSymmetryPatch
|
|
||||||
(
|
|
||||||
const symmetryPolyPatch&,
|
|
||||||
TrackingData& td
|
|
||||||
);
|
|
||||||
|
|
||||||
//- Overridable function to handle the particle hitting a cyclicPatch
|
|
||||||
template<class TrackingData>
|
|
||||||
void hitCyclicPatch
|
|
||||||
(
|
|
||||||
const cyclicPolyPatch&,
|
|
||||||
TrackingData& td
|
|
||||||
);
|
|
||||||
|
|
||||||
//- Overridable function to handle the particle hitting a processorPatch
|
|
||||||
template<class TrackingData>
|
|
||||||
void hitProcessorPatch
|
|
||||||
(
|
|
||||||
const processorPolyPatch&,
|
|
||||||
TrackingData& td
|
|
||||||
);
|
|
||||||
|
|
||||||
//- Overridable function to handle the particle hitting a wallPatch
|
|
||||||
template<class TrackingData>
|
|
||||||
void hitWallPatch
|
|
||||||
(
|
|
||||||
const wallPolyPatch&,
|
|
||||||
TrackingData& td
|
|
||||||
);
|
|
||||||
|
|
||||||
//- Overridable function to handle the particle hitting a general patch
|
|
||||||
template<class TrackingData>
|
|
||||||
void hitPatch
|
|
||||||
(
|
|
||||||
const polyPatch&,
|
|
||||||
TrackingData& td
|
|
||||||
);
|
|
||||||
|
|
||||||
//- Transform the position the particle
|
|
||||||
// according to the given transformation tensor
|
|
||||||
void transformPosition(const tensor& T);
|
|
||||||
|
|
||||||
//- Transform the physical properties of the particle
|
|
||||||
// according to the given transformation tensor
|
|
||||||
void transformProperties(const tensor& T);
|
|
||||||
|
|
||||||
//- Transform the physical properties of the particle
|
|
||||||
// according to the given separation vector
|
|
||||||
void transformProperties(const vector& separation);
|
|
||||||
|
|
||||||
//- Convert global addressing to the processor patch
|
|
||||||
// local equivalents
|
|
||||||
template<class TrackingData>
|
|
||||||
void prepareForParallelTransfer(const label patchi, TrackingData& td);
|
|
||||||
|
|
||||||
//- Convert processor patch addressing to the global equivalents
|
|
||||||
// and set the celli to the face-neighbour
|
|
||||||
template<class TrackingData>
|
|
||||||
void correctAfterParallelTransfer(const label patchi, TrackingData& td);
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
friend class Cloud<ParticleType>;
|
|
||||||
|
|
||||||
|
|
||||||
//- Runtime type information
|
|
||||||
TypeName("Particle");
|
|
||||||
|
|
||||||
|
|
||||||
//- Class used to pass tracking data to the trackToFace function
|
|
||||||
class trackData
|
|
||||||
{
|
|
||||||
|
|
||||||
// Private data
|
|
||||||
|
|
||||||
//- Reference to the cloud containing this particle
|
|
||||||
Cloud<ParticleType>& cloud_;
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
bool switchProcessor;
|
|
||||||
bool keepParticle;
|
|
||||||
|
|
||||||
|
|
||||||
// Constructors
|
|
||||||
|
|
||||||
inline trackData
|
|
||||||
(
|
|
||||||
Cloud<ParticleType>& cloud
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
// Member functions
|
|
||||||
|
|
||||||
inline Cloud<ParticleType>& cloud();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// Constructors
|
|
||||||
|
|
||||||
//- Construct from components
|
|
||||||
Particle
|
|
||||||
(
|
|
||||||
const Cloud<ParticleType>&,
|
|
||||||
const vector& position,
|
|
||||||
const label celli
|
|
||||||
);
|
|
||||||
|
|
||||||
//- Construct from Istream
|
|
||||||
Particle
|
|
||||||
(
|
|
||||||
const Cloud<ParticleType>&,
|
|
||||||
Istream&,
|
|
||||||
bool readFields = true
|
|
||||||
);
|
|
||||||
|
|
||||||
//- Factory class to read-construct particles used for parallel transfer
|
|
||||||
class iNew
|
|
||||||
{
|
|
||||||
|
|
||||||
// Private data
|
|
||||||
|
|
||||||
const Cloud<ParticleType>& cloud_;
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
iNew(const Cloud<ParticleType>& cloud)
|
|
||||||
:
|
|
||||||
cloud_(cloud)
|
|
||||||
{}
|
|
||||||
|
|
||||||
autoPtr<ParticleType> operator()(Istream& is) const
|
|
||||||
{
|
|
||||||
return autoPtr<ParticleType>(new ParticleType(cloud_, is));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// Destructor
|
|
||||||
|
|
||||||
virtual ~Particle()
|
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
// Member Functions
|
|
||||||
|
|
||||||
// Access
|
|
||||||
|
|
||||||
//- Return true if particle is in cell
|
|
||||||
inline bool inCell();
|
|
||||||
|
|
||||||
//- Return true if position is in cell i
|
|
||||||
inline bool inCell
|
|
||||||
(
|
|
||||||
const vector& position,
|
|
||||||
const label celli,
|
|
||||||
const scalar stepFraction
|
|
||||||
);
|
|
||||||
|
|
||||||
//- Return current particle position
|
|
||||||
inline const vector& position() const;
|
|
||||||
|
|
||||||
//- Return current particle position
|
|
||||||
inline vector& position();
|
|
||||||
|
|
||||||
//- Return current cell particle is in
|
|
||||||
inline label cell() const;
|
|
||||||
|
|
||||||
//- Return current face particle is on otherwise -1
|
|
||||||
inline label face() const;
|
|
||||||
|
|
||||||
//- Return reference to the particle cloud
|
|
||||||
inline const Cloud<ParticleType>& cloud() const;
|
|
||||||
|
|
||||||
//- Return the impact model to be used, soft or hard (default).
|
|
||||||
inline bool softImpact() const;
|
|
||||||
|
|
||||||
|
|
||||||
// Check
|
|
||||||
|
|
||||||
//- Is the particle on the boundary/(or outside the domain)?
|
|
||||||
inline bool onBoundary() const;
|
|
||||||
|
|
||||||
//- Which patch is particle on
|
|
||||||
inline label patch(const label facei) const;
|
|
||||||
|
|
||||||
//- Which face of this patch is this particle on
|
|
||||||
inline label patchFace(const label patchi, const label facei) const;
|
|
||||||
|
|
||||||
//- The nearest distance to a wall that
|
|
||||||
// the particle can be in the n direction
|
|
||||||
inline scalar wallImpactDistance(const vector& n) const;
|
|
||||||
|
|
||||||
//- Return the fraction of time-step completed
|
|
||||||
inline scalar& stepFraction();
|
|
||||||
|
|
||||||
//- Return the fraction of time-step completed
|
|
||||||
inline scalar stepFraction() const;
|
|
||||||
|
|
||||||
|
|
||||||
// Track
|
|
||||||
|
|
||||||
//- Track particle to end of trajectory
|
|
||||||
// or until it hits the boundary.
|
|
||||||
// On entry 'stepFraction()' should be set to the fraction of the
|
|
||||||
// time-step at which the tracking starts and on exit it contains
|
|
||||||
// the fraction of the time-step completed.
|
|
||||||
// Returns the boundary face index if the track stops at the
|
|
||||||
// boundary, -1 otherwise.
|
|
||||||
template<class TrackingData>
|
|
||||||
label track
|
|
||||||
(
|
|
||||||
const vector& endPosition,
|
|
||||||
TrackingData& td
|
|
||||||
);
|
|
||||||
|
|
||||||
//- Calls the templated track with dummy TrackingData
|
|
||||||
label track(const vector& endPosition);
|
|
||||||
|
|
||||||
//- Track particle to a given position and returns 1.0 if the
|
|
||||||
// trajectory is completed without hitting a face otherwise
|
|
||||||
// stops at the face and returns the fraction of the trajectory
|
|
||||||
// completed.
|
|
||||||
// on entry 'stepFraction()' should be set to the fraction of the
|
|
||||||
// time-step at which the tracking starts.
|
|
||||||
template<class TrackingData>
|
|
||||||
scalar trackToFace
|
|
||||||
(
|
|
||||||
const vector& endPosition,
|
|
||||||
TrackingData& td
|
|
||||||
);
|
|
||||||
|
|
||||||
//- Calls the templated trackToFace with dummy TrackingData
|
|
||||||
scalar trackToFace(const vector& endPosition);
|
|
||||||
|
|
||||||
//- Return the index of the face to be used in the interpolation routine
|
|
||||||
inline label faceInterpolation() const;
|
|
||||||
|
|
||||||
|
|
||||||
// I-O
|
|
||||||
|
|
||||||
//- Write the fields associated with the owner cloud
|
|
||||||
static void writeFields
|
|
||||||
(
|
|
||||||
const Cloud<ParticleType>& c
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
// Ostream Operator
|
|
||||||
|
|
||||||
friend Ostream& operator<< <ParticleType>
|
|
||||||
(
|
|
||||||
Ostream&,
|
|
||||||
const Particle<ParticleType>&
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
} // End namespace Foam
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
#include "ParticleI.H"
|
|
||||||
|
|
||||||
#define defineParticleTypeNameAndDebug(Type, DebugSwitch) \
|
|
||||||
template<> \
|
|
||||||
const Foam::word Particle<Type>::typeName(#Type); \
|
|
||||||
template<> \
|
|
||||||
int Particle<Type>::debug(Foam::debug::debugSwitch(#Type, DebugSwitch));
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
#ifdef NoRepository
|
|
||||||
# include "Particle.C"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
@ -111,7 +111,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
|
|
||||||
// Private data
|
// Private data
|
||||||
|
|
||||||
@ -169,8 +169,6 @@ private:
|
|||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
// Patch interactions
|
// Patch interactions
|
||||||
|
|
||||||
//- Overridable function to handle the particle hitting a wedgePatch
|
//- Overridable function to handle the particle hitting a wedgePatch
|
||||||
|
|||||||
Reference in New Issue
Block a user