From f5da7edfe42288dff23e2ea1ff2bf1eb6fbc7326 Mon Sep 17 00:00:00 2001 From: andy Date: Thu, 24 Feb 2011 16:44:18 +0000 Subject: [PATCH] ENH: Re-worked lagrangian/dsmc --- .../clouds/Templates/DsmcCloud/DsmcCloud.C | 6 +- .../parcels/Templates/DsmcParcel/DsmcParcel.C | 56 ++--------- .../parcels/Templates/DsmcParcel/DsmcParcel.H | 96 ++++++++----------- .../Templates/DsmcParcel/DsmcParcelI.H | 56 ++++------- .../Templates/DsmcParcel/DsmcParcelIO.C | 27 +++--- .../derived/dsmcParcel/defineDsmcParcel.C | 6 +- .../parcels/derived/dsmcParcel/dsmcParcel.C | 14 +-- .../parcels/derived/dsmcParcel/dsmcParcel.H | 10 +- .../makeDsmcParcelBinaryCollisionModels.C | 27 ++---- .../makeDsmcParcelInflowBoundaryModels.C | 22 ++--- .../makeDsmcParcelWallInteractionModels.C | 29 ++---- .../BinaryCollisionModel.H | 12 +-- .../InflowBoundaryModel/InflowBoundaryModel.H | 12 +-- .../WallInteractionModel.H | 12 +-- 14 files changed, 144 insertions(+), 241 deletions(-) diff --git a/src/lagrangian/dsmc/clouds/Templates/DsmcCloud/DsmcCloud.C b/src/lagrangian/dsmc/clouds/Templates/DsmcCloud/DsmcCloud.C index 793bc39fc9..b23817d98e 100644 --- a/src/lagrangian/dsmc/clouds/Templates/DsmcCloud/DsmcCloud.C +++ b/src/lagrangian/dsmc/clouds/Templates/DsmcCloud/DsmcCloud.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2009-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2009-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -501,7 +501,7 @@ void Foam::DsmcCloud::addNewParcel { ParcelType* pPtr = new ParcelType ( - *this, + mesh_, position, U, Ei, @@ -970,7 +970,7 @@ Foam::DsmcCloud::~DsmcCloud() template void Foam::DsmcCloud::evolve() { - typename ParcelType::trackData td(*this); + typename ParcelType::trackingData td(*this); // Reset the data collection fields resetFields(); diff --git a/src/lagrangian/dsmc/parcels/Templates/DsmcParcel/DsmcParcel.C b/src/lagrangian/dsmc/parcels/Templates/DsmcParcel/DsmcParcel.C index 843a96456f..fa79ac2ddd 100644 --- a/src/lagrangian/dsmc/parcels/Templates/DsmcParcel/DsmcParcel.C +++ b/src/lagrangian/dsmc/parcels/Templates/DsmcParcel/DsmcParcel.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2009-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2009-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -30,13 +30,10 @@ License template template -bool Foam::DsmcParcel::move -( - TrackData& td, - const scalar trackTime -) +bool Foam::DsmcParcel::move(TrackData& td, const scalar trackTime) { - ParcelType& p = static_cast(*this); + typename TrackData::cloudType::parcelType& p = + static_cast(*this); td.switchProcessor = false; td.keepParticle = true; @@ -113,15 +110,6 @@ void Foam::DsmcParcel::hitProcessorPatch } -template -void Foam::DsmcParcel::hitProcessorPatch -( - const processorPolyPatch&, - int& -) -{} - - template template void Foam::DsmcParcel::hitWallPatch @@ -174,7 +162,7 @@ void Foam::DsmcParcel::hitWallPatch td.cloud().wallInteraction().correct ( - static_cast(*this), + static_cast &>(*this), wpp ); @@ -215,44 +203,18 @@ void Foam::DsmcParcel::hitWallPatch } -template -void Foam::DsmcParcel::hitWallPatch -( - const wallPolyPatch&, - int&, - const tetIndices& -) -{} - - template template -void Foam::DsmcParcel::hitPatch -( - const polyPatch&, - TrackData& td -) +void Foam::DsmcParcel::hitPatch(const polyPatch&, TrackData& td) { td.keepParticle = false; } template -void Foam::DsmcParcel::hitPatch -( - const polyPatch&, - int& -) -{} - - -template -void Foam::DsmcParcel::transformProperties -( - const tensor& T -) +void Foam::DsmcParcel::transformProperties(const tensor& T) { - Particle::transformProperties(T); + ParcelType::transformProperties(T); U_ = transform(T, U_); } @@ -263,7 +225,7 @@ void Foam::DsmcParcel::transformProperties const vector& separation ) { - Particle::transformProperties(separation); + ParcelType::transformProperties(separation); } diff --git a/src/lagrangian/dsmc/parcels/Templates/DsmcParcel/DsmcParcel.H b/src/lagrangian/dsmc/parcels/Templates/DsmcParcel/DsmcParcel.H index 6047911db0..2ddd8ef060 100644 --- a/src/lagrangian/dsmc/parcels/Templates/DsmcParcel/DsmcParcel.H +++ b/src/lagrangian/dsmc/parcels/Templates/DsmcParcel/DsmcParcel.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2009-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2009-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -37,7 +37,7 @@ SourceFiles #ifndef DsmcParcel_H #define DsmcParcel_H -#include "Particle.H" +#include "particle.H" #include "IOstream.H" #include "autoPtr.H" #include "contiguous.H" @@ -68,7 +68,7 @@ Ostream& operator<< template class DsmcParcel : - public Particle + public ParcelType { public: @@ -123,31 +123,22 @@ public: //- Class used to pass kinematic tracking data to the trackToFace function - class trackData + class trackingData : - public Particle::trackData + public particle::TrackingData > > { - // Private data - - //- Reference to the cloud containing this particle - DsmcCloud& cloud_; - - public: // Constructors //- Construct from components - inline trackData - ( - DsmcCloud& cloud - ); - - - // Member functions - - //- Return access to the owner cloud - inline DsmcCloud& cloud(); + trackingData(DsmcCloud >& cloud) + : + particle::TrackingData > > + ( + cloud + ) + {} }; @@ -181,7 +172,7 @@ public: //- Construct from components inline DsmcParcel ( - DsmcCloud& owner, + const polyMesh& mesh, const vector& position, const vector& U, const scalar Ei, @@ -194,21 +185,41 @@ public: //- Construct from Istream DsmcParcel ( - const Cloud& c, + const polyMesh& mesh, Istream& is, bool readFields = true ); //- Construct and return a clone - virtual autoPtr > clone() const + virtual autoPtr clone() const { - return autoPtr > - ( - new DsmcParcel(*this) - ); + return autoPtr(new DsmcParcel(*this)); } + //- Factory class to read-construct particles used for + // parallel transfer + class iNew + { + const polyMesh& mesh_; + + public: + + iNew(const polyMesh& mesh) + : + mesh_(mesh) + {} + + autoPtr > operator()(Istream& is) const + { + return autoPtr > + ( + new DsmcParcel(mesh_, is, true) + ); + } + }; + + // Member Functions // Access @@ -263,14 +274,6 @@ public: TrackData& td ); - //- Overridable function to handle the particle hitting a - // processorPatch without trackData - void hitProcessorPatch - ( - const processorPolyPatch&, - int& - ); - //- Overridable function to handle the particle hitting a wallPatch template void hitWallPatch @@ -280,15 +283,6 @@ public: const tetIndices& ); - //- Overridable function to handle the particle hitting a wallPatch - // without trackData - void hitWallPatch - ( - const wallPolyPatch&, - int&, - const tetIndices& - ); - //- Overridable function to handle the particle hitting a polyPatch template void hitPatch @@ -297,14 +291,6 @@ public: TrackData& td ); - //- Overridable function to handle the particle hitting a polyPatch - //- without trackData - void hitPatch - ( - const polyPatch&, - int& - ); - //- Transform the physical properties of the particle // according to the given transformation tensor void transformProperties(const tensor& T); @@ -316,9 +302,9 @@ public: // I-O - static void readFields(Cloud& c); + static void readFields(Cloud >& c); - static void writeFields(const Cloud& c); + static void writeFields(const Cloud >& c); // Ostream Operator diff --git a/src/lagrangian/dsmc/parcels/Templates/DsmcParcel/DsmcParcelI.H b/src/lagrangian/dsmc/parcels/Templates/DsmcParcel/DsmcParcelI.H index 5bfc61b44b..de021a15e1 100644 --- a/src/lagrangian/dsmc/parcels/Templates/DsmcParcel/DsmcParcelI.H +++ b/src/lagrangian/dsmc/parcels/Templates/DsmcParcel/DsmcParcelI.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2009-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2009-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -27,7 +27,7 @@ License // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -template +template inline Foam::DsmcParcel::constantProperties::constantProperties() : mass_(0), @@ -35,7 +35,7 @@ inline Foam::DsmcParcel::constantProperties::constantProperties() {} -template +template inline Foam::DsmcParcel::constantProperties::constantProperties ( const dictionary& dict @@ -51,21 +51,10 @@ inline Foam::DsmcParcel::constantProperties::constantProperties {} -template -inline Foam::DsmcParcel::trackData::trackData -( - DsmcCloud& cloud -) -: - Particle::trackData(cloud), - cloud_(cloud) -{} - - -template +template inline Foam::DsmcParcel::DsmcParcel ( - DsmcCloud& owner, + const polyMesh& mesh, const vector& position, const vector& U, const scalar Ei, @@ -75,7 +64,7 @@ inline Foam::DsmcParcel::DsmcParcel const label typeId ) : - Particle(owner, position, cellI, tetFaceI, tetPtI), + ParcelType(mesh, position, cellI, tetFaceI, tetPtI), U_(U), Ei_(Ei), typeId_(typeId) @@ -84,7 +73,7 @@ inline Foam::DsmcParcel::DsmcParcel // * * * * * * * * * constantProperties Member Functions * * * * * * * * * * // -template +template inline Foam::scalar Foam::DsmcParcel::constantProperties::mass() const { @@ -92,15 +81,14 @@ Foam::DsmcParcel::constantProperties::mass() const } -template -inline Foam::scalar -Foam::DsmcParcel::constantProperties::d() const +template +inline Foam::scalar Foam::DsmcParcel::constantProperties::d() const { return d_; } -template +template inline Foam::scalar Foam::DsmcParcel::constantProperties::sigmaT() const { @@ -108,7 +96,7 @@ Foam::DsmcParcel::constantProperties::sigmaT() const } -template +template inline Foam::scalar Foam::DsmcParcel::constantProperties::internalDegreesOfFreedom() const @@ -117,7 +105,7 @@ const } -template +template inline Foam::scalar Foam::DsmcParcel::constantProperties::omega() const { @@ -125,47 +113,37 @@ Foam::DsmcParcel::constantProperties::omega() const } -// * * * * * * * * * * * trackData Member Functions * * * * * * * * * * * * // - -template -inline Foam::DsmcCloud& -Foam::DsmcParcel::trackData::cloud() -{ - return cloud_; -} - - // * * * * * * * * * * DsmcParcel Member Functions * * * * * * * * * * // -template +template inline Foam::label Foam::DsmcParcel::typeId() const { return typeId_; } -template +template inline const Foam::vector& Foam::DsmcParcel::U() const { return U_; } -template +template inline Foam::scalar Foam::DsmcParcel::Ei() const { return Ei_; } -template +template inline Foam::vector& Foam::DsmcParcel::U() { return U_; } -template +template inline Foam::scalar& Foam::DsmcParcel::Ei() { return Ei_; diff --git a/src/lagrangian/dsmc/parcels/Templates/DsmcParcel/DsmcParcelIO.C b/src/lagrangian/dsmc/parcels/Templates/DsmcParcel/DsmcParcelIO.C index b95cd14a88..203ddd3fd3 100644 --- a/src/lagrangian/dsmc/parcels/Templates/DsmcParcel/DsmcParcelIO.C +++ b/src/lagrangian/dsmc/parcels/Templates/DsmcParcel/DsmcParcelIO.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2009-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2009-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -33,12 +33,12 @@ License template Foam::DsmcParcel::DsmcParcel ( - const Cloud& cloud, + const polyMesh& mesh, Istream& is, bool readFields ) : - Particle(cloud, is, readFields), + ParcelType(mesh, is, readFields), U_(vector::zero), Ei_(0.0), typeId_(-1) @@ -73,14 +73,14 @@ Foam::DsmcParcel::DsmcParcel template -void Foam::DsmcParcel::readFields(Cloud& c) +void Foam::DsmcParcel::readFields(Cloud >& c) { if (!c.size()) { return; } - Particle::readFields(c); + ParcelType::readFields(c); IOField U(c.fieldIOobject("U", IOobject::MUST_READ)); c.checkFieldIOobject(c, U); @@ -92,9 +92,9 @@ void Foam::DsmcParcel::readFields(Cloud& c) c.checkFieldIOobject(c, typeId); label i = 0; - forAllIter(typename Cloud, c, iter) + forAllIter(typename Cloud >, c, iter) { - ParcelType& p = iter(); + DsmcParcel& p = iter(); p.U_ = U[i]; p.Ei_ = Ei[i]; @@ -105,9 +105,12 @@ void Foam::DsmcParcel::readFields(Cloud& c) template -void Foam::DsmcParcel::writeFields(const Cloud& c) +void Foam::DsmcParcel::writeFields +( + const Cloud >& c +) { - Particle::writeFields(c); + ParcelType::writeFields(c); label np = c.size(); @@ -116,7 +119,7 @@ void Foam::DsmcParcel::writeFields(const Cloud& c) IOField