diff --git a/src/lagrangian/basic/particle/particle.C b/src/lagrangian/basic/particle/particle.C new file mode 100644 index 0000000000..c2ae9af0d2 --- /dev/null +++ b/src/lagrangian/basic/particle/particle.C @@ -0,0 +1,147 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2004-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 . + +\*---------------------------------------------------------------------------*/ + +#include "particle.H" +#include "transform.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +Foam::label Foam::particle::particleCount_ = 0; + +const Foam::scalar Foam::particle::trackingCorrectionTol = 1e-5; + +namespace Foam +{ + defineTypeNameAndDebug(particle, 0); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::particle::particle +( + const polyMesh& mesh, + const vector& position, + const label cellI, + const label tetFaceI, + const label tetPtI +) +: + mesh_(mesh), + position_(position), + cellI_(cellI), + faceI_(-1), + stepFraction_(0.0), + tetFaceI_(tetFaceI), + tetPtI_(tetPtI), + origProc_(Pstream::myProcNo()), + origId_(getNewParticleID()) +{} + + +Foam::particle::particle +( + const polyMesh& mesh, + const vector& position, + const label cellI, + bool doCellFacePt +) +: + mesh_(mesh), + position_(position), + cellI_(cellI), + faceI_(-1), + stepFraction_(0.0), + tetFaceI_(-1), + tetPtI_(-1), + origProc_(Pstream::myProcNo()), + origId_(getNewParticleID()) +{ + if (doCellFacePt) + { + initCellFacePt(); + } +} + + +Foam::particle::particle(const particle& p) +: + mesh_(p.mesh_), + position_(p.position_), + cellI_(p.cellI_), + faceI_(p.faceI_), + stepFraction_(p.stepFraction_), + tetFaceI_(p.tetFaceI_), + tetPtI_(p.tetPtI_), + origProc_(p.origProc_), + origId_(p.origId_) +{} + + +Foam::particle::particle(const particle& p, const polyMesh& mesh) +: + mesh_(mesh), + position_(p.position_), + cellI_(p.cellI_), + faceI_(p.faceI_), + stepFraction_(p.stepFraction_), + tetFaceI_(p.tetFaceI_), + tetPtI_(p.tetPtI_), + origProc_(p.origProc_), + origId_(p.origId_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::particle::transformPosition(const tensor& T) +{ + position_ = transform(T, position_); +} + + +void Foam::particle::transformProperties(const tensor&) +{} + + +void Foam::particle::transformProperties(const vector&) +{} + + +// * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * * // + +bool Foam::operator==(const particle& pA, const particle& pB) +{ + return (pA.origProc() == pB.origProc() && pA.origId() == pB.origId()); +} + + +bool Foam::operator!=(const particle& pA, const particle& pB) +{ + return !(pA == pB); +} + + +// ************************************************************************* // diff --git a/src/lagrangian/basic/Particle/Particle.H b/src/lagrangian/basic/particle/particle.H similarity index 75% rename from src/lagrangian/basic/Particle/Particle.H rename to src/lagrangian/basic/particle/particle.H index 743925525a..f9b832348f 100644 --- a/src/lagrangian/basic/Particle/Particle.H +++ b/src/lagrangian/basic/particle/particle.H @@ -22,99 +22,102 @@ License along with OpenFOAM. If not, see . Class - Foam::Particle + Foam::particle Description + Base particle class \*---------------------------------------------------------------------------*/ -#ifndef Particle_H -#define Particle_H +#ifndef particle_H +#define particle_H #include "vector.H" +#include "Cloud.H" #include "IDLList.H" #include "labelList.H" #include "pointField.H" #include "faceList.H" -#include "typeInfo.H" +//#include "typeInfo.H" #include "OFstream.H" #include "tetPointRef.H" #include "FixedList.H" #include "polyMeshTetDecomposition.H" -#include "wallPolyPatch.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { -template -class Cloud; +// Forward declaration of classes +class particle; + +class polyPatch; -class wedgePolyPatch; -class symmetryPolyPatch; class cyclicPolyPatch; class processorPolyPatch; +class symmetryPolyPatch; class wallPolyPatch; -class polyPatch; +class wedgePolyPatch; // Forward declaration of friend functions and operators -template -class Particle; - -// Friend Operators - -template Ostream& operator<< ( Ostream&, - const Particle& + const particle& ); -template -bool operator==(const Particle&, const Particle&); +bool operator==(const particle&, const particle&); -template -bool operator!=(const Particle&, const Particle&); +bool operator!=(const particle&, const particle&); /*---------------------------------------------------------------------------*\ - Class Particle Declaration + Class Particle Declaration \*---------------------------------------------------------------------------*/ -template -class Particle +class particle : - public IDLList::link + public IDLList::link { - public: - //- Class used to pass tracking data to the trackToFace function - class trackData + template + class TrackingData { - // Private data - //- Reference to the cloud containing this particle - Cloud& cloud_; + //- Reference to the cloud containing (this) particle + CloudType& cloud_; public: - bool switchProcessor; - bool keepParticle; + // Public data + + typedef CloudType cloudType; + + //- Flag to switch processor + bool switchProcessor; + + //- Flag to indicate whether to keep particle (false = delete) + bool keepParticle; - // Constructors - - inline trackData(Cloud& cloud); + // Constructor + TrackingData(CloudType& cloud) + : + cloud_(cloud) + {} // Member functions //- Return a reference to the cloud - inline Cloud& cloud(); + CloudType& cloud() + { + return cloud_; + } }; @@ -122,8 +125,8 @@ protected: // Protected data - //- Reference to the particle cloud - const Cloud& cloud_; + //- Reference to the polyMesh database + const polyMesh& mesh_; //- Position of particle vector position_; @@ -156,7 +159,7 @@ protected: // Private Member Functions //- Find the tet tri faces between position and tet centre - inline void findTris + void findTris ( const vector& position, DynamicList