From b6ca9887b001920ec67154651f303ce4e79c56c6 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Thu, 21 Apr 2016 08:47:50 +0200 Subject: [PATCH] ENH: add parcel property types (fixes #109) - assists in decoding what the binary IO content means ENH: use label instead of bool for the KinematicParcel active state (fixes #111) - avoids internal padding of the data structure and simplifies downstream use. ENH: make particle sizeofFields public (fixes #110) Also fixes #108 (missing faceI and stepFraction entries) which had also been fixed in the upstream as well. --- .../parcels/Templates/DSMCParcel/DSMCParcel.H | 12 +++---- .../Templates/DSMCParcel/DSMCParcelIO.C | 8 ++--- src/lagrangian/basic/particle/particle.H | 16 ++++++--- src/lagrangian/basic/particle/particleIO.C | 11 +++--- .../basic/particle/particleMacros.H | 32 ++++++++++++++++- .../CollidingParcel/CollidingParcel.H | 20 +++++++---- .../CollidingParcel/CollidingParcelIO.C | 6 ++-- .../KinematicParcel/KinematicParcel.H | 35 ++++++++++++++----- .../KinematicParcel/KinematicParcelI.H | 6 ++-- .../KinematicParcel/KinematicParcelIO.C | 14 +++++--- .../Templates/MPPICParcel/MPPICParcel.H | 22 +++++++----- .../Templates/MPPICParcel/MPPICParcelIO.C | 12 ++++--- .../ReactingMultiphaseParcel.H | 21 +++++++---- .../ReactingMultiphaseParcelIO.C | 8 +++-- .../Templates/ReactingParcel/ReactingParcel.H | 20 +++++++---- .../ReactingParcel/ReactingParcelIO.C | 12 ++++--- .../Templates/ThermoParcel/ThermoParcel.H | 20 +++++++---- .../Templates/ThermoParcel/ThermoParcelIO.C | 12 ++++--- .../LocalInteraction/LocalInteraction.C | 9 +++-- .../PatchInteractionModel/Rebound/Rebound.C | 4 +-- .../StandardWallInteraction.C | 8 ++--- .../molecule/molecule/molecule.H | 17 +++++---- .../molecule/molecule/moleculeIO.C | 8 ++--- src/lagrangian/solidParticle/solidParticle.H | 11 +++--- .../solidParticle/solidParticleIO.C | 6 ++-- .../Templates/SprayParcel/SprayParcel.H | 34 +++++++++++++----- .../Templates/SprayParcel/SprayParcelIO.C | 12 ++++--- 27 files changed, 259 insertions(+), 137 deletions(-) diff --git a/src/lagrangian/DSMC/parcels/Templates/DSMCParcel/DSMCParcel.H b/src/lagrangian/DSMC/parcels/Templates/DSMCParcel/DSMCParcel.H index fc540a3d12..a1dc5e3f31 100644 --- a/src/lagrangian/DSMC/parcels/Templates/DSMCParcel/DSMCParcel.H +++ b/src/lagrangian/DSMC/parcels/Templates/DSMCParcel/DSMCParcel.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -69,14 +69,12 @@ class DSMCParcel : public ParcelType { - // Private member data - - //- Size in bytes of the fields - static const std::size_t sizeofFields_; - - public: + //- Size in bytes of the fields + static const std::size_t sizeofFields; + + //- Class to hold DSMC particle constant properties class constantProperties { diff --git a/src/lagrangian/DSMC/parcels/Templates/DSMCParcel/DSMCParcelIO.C b/src/lagrangian/DSMC/parcels/Templates/DSMCParcel/DSMCParcelIO.C index c47e7bff39..292f445f93 100644 --- a/src/lagrangian/DSMC/parcels/Templates/DSMCParcel/DSMCParcelIO.C +++ b/src/lagrangian/DSMC/parcels/Templates/DSMCParcel/DSMCParcelIO.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -31,7 +31,7 @@ License // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // template -const std::size_t Foam::DSMCParcel::sizeofFields_ +const std::size_t Foam::DSMCParcel::sizeofFields ( sizeof(DSMCParcel) - sizeof(ParcelType) ); @@ -62,7 +62,7 @@ Foam::DSMCParcel::DSMCParcel } else { - is.read(reinterpret_cast(&U_), sizeofFields_); + is.read(reinterpret_cast(&U_), sizeofFields); } } @@ -160,7 +160,7 @@ Foam::Ostream& Foam::operator<< os.write ( reinterpret_cast(&p.U_), - DSMCParcel::sizeofFields_ + DSMCParcel::sizeofFields ); } diff --git a/src/lagrangian/basic/particle/particle.H b/src/lagrangian/basic/particle/particle.H index 4bbd17bcc4..ea0cc38a36 100644 --- a/src/lagrangian/basic/particle/particle.H +++ b/src/lagrangian/basic/particle/particle.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -85,12 +85,12 @@ class particle //- Size in bytes of the position data static const std::size_t sizeofPosition_; - //- Size in bytes of the fields - static const std::size_t sizeofFields_; - - public: + //- Size in bytes of the fields + static const std::size_t sizeofFields; + + template class TrackingData { @@ -319,6 +319,12 @@ public: "tetFaceI tetPtI origProc origId" ); + //- String representation of property types + DefinePropertyTypes + ( + "vector label label scalar label label label label" + ); + //- Cumulative particle counter - used to provode unique ID static label particleCount_; diff --git a/src/lagrangian/basic/particle/particleIO.C b/src/lagrangian/basic/particle/particleIO.C index 7d617175cf..081a506049 100644 --- a/src/lagrangian/basic/particle/particleIO.C +++ b/src/lagrangian/basic/particle/particleIO.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -28,14 +28,15 @@ License // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // -Foam::string Foam::particle::propertyList_ = Foam::particle::propertyList(); +Foam::string Foam::particle::propertyList_ = Foam::particle::propertyList(); +Foam::string Foam::particle::propertyTypes_ = Foam::particle::propertyTypes(); const std::size_t Foam::particle::sizeofPosition_ ( offsetof(particle, faceI_) - offsetof(particle, position_) ); -const std::size_t Foam::particle::sizeofFields_ +const std::size_t Foam::particle::sizeofFields ( sizeof(particle) - offsetof(particle, position_) ); @@ -73,7 +74,7 @@ Foam::particle::particle(const polyMesh& mesh, Istream& is, bool readFields) { if (readFields) { - is.read(reinterpret_cast(&position_), sizeofFields_); + is.read(reinterpret_cast(&position_), sizeofFields); } else { @@ -120,7 +121,7 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const particle& p) os.write ( reinterpret_cast(&p.position_), - particle::sizeofFields_ + particle::sizeofFields ); } diff --git a/src/lagrangian/basic/particle/particleMacros.H b/src/lagrangian/basic/particle/particleMacros.H index 3d95f1fbcb..8bb09dd133 100644 --- a/src/lagrangian/basic/particle/particleMacros.H +++ b/src/lagrangian/basic/particle/particleMacros.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -39,6 +39,9 @@ namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +//- Define a static 'propertyList' for particle properties +// The property list is space-delimited with brackets for vector groupings +// \sa AddToPropertyList #define DefinePropertyList(str) \ \ static string propertyList_; \ @@ -49,6 +52,9 @@ namespace Foam } +//- Add to existing static 'propertyList' for particle properties +// The property list is space-delimited with brackets for vector groupings +// \sa DefinePropertyList #define AddToPropertyList(ParcelType, str) \ \ static string propertyList_; \ @@ -59,6 +65,30 @@ namespace Foam } +//- Define a static 'propertyTypes' for the types of particle properties +// \sa AddToPropertyTypes +#define DefinePropertyTypes(str) \ + \ + static string propertyTypes_; \ + \ + static string propertyTypes() \ + { \ + return str; \ + } + + +//- Add to existing static 'propertyTypes' for the types of particle properties +// \sa AddToPropertyTypes +#define AddToPropertyTypes(ParcelType, str) \ + \ + static string propertyTypes_; \ + \ + static string propertyTypes() \ + { \ + return ParcelType::propertyTypes() + str; \ + } + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam diff --git a/src/lagrangian/intermediate/parcels/Templates/CollidingParcel/CollidingParcel.H b/src/lagrangian/intermediate/parcels/Templates/CollidingParcel/CollidingParcel.H index 5bc6051ccc..bac35769f4 100644 --- a/src/lagrangian/intermediate/parcels/Templates/CollidingParcel/CollidingParcel.H +++ b/src/lagrangian/intermediate/parcels/Templates/CollidingParcel/CollidingParcel.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -72,14 +72,12 @@ class CollidingParcel : public ParcelType { - // Private member data - - //- Size in bytes of the fields - static const std::size_t sizeofFields_; - - public: + //- Size in bytes of the fields + static const std::size_t sizeofFields; + + //- Class to hold thermo particle constant properties class constantProperties : @@ -160,6 +158,14 @@ public: + " (collisionRecordsWallData)" ); + //- String representation of property types + static string propertyTypes() + { + // TODO: collision information types + NotImplemented; + return string::null; + } + // Constructors diff --git a/src/lagrangian/intermediate/parcels/Templates/CollidingParcel/CollidingParcelIO.C b/src/lagrangian/intermediate/parcels/Templates/CollidingParcel/CollidingParcelIO.C index f0c2007e48..8f0c8b6b46 100644 --- a/src/lagrangian/intermediate/parcels/Templates/CollidingParcel/CollidingParcelIO.C +++ b/src/lagrangian/intermediate/parcels/Templates/CollidingParcel/CollidingParcelIO.C @@ -34,7 +34,7 @@ Foam::string Foam::CollidingParcel::propertyList_ = Foam::CollidingParcel::propertyList(); template -const std::size_t Foam::CollidingParcel::sizeofFields_ +const std::size_t Foam::CollidingParcel::sizeofFields ( offsetof(CollidingParcel, collisionRecords_) - offsetof(CollidingParcel, f_) @@ -67,7 +67,7 @@ Foam::CollidingParcel::CollidingParcel } else { - is.read(reinterpret_cast(&f_), sizeofFields_); + is.read(reinterpret_cast(&f_), sizeofFields); } is >> collisionRecords_; @@ -297,7 +297,7 @@ Foam::Ostream& Foam::operator<< os.write ( reinterpret_cast(&p.f_), - CollidingParcel::sizeofFields_ + CollidingParcel::sizeofFields ); os << p.collisionRecords(); } diff --git a/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.H b/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.H index 864bbb1bbd..f4e57dde49 100644 --- a/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.H +++ b/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -80,15 +80,15 @@ class KinematicParcel { // Private data - //- Size in bytes of the fields - static const std::size_t sizeofFields_; - //- Number of particle tracking attempts before we assume that it stalls static label maxTrackAttempts; - public: + //- Size in bytes of the fields + static const std::size_t sizeofFields; + + //- Class to hold kinematic particle constant properties class constantProperties { @@ -234,7 +234,8 @@ protected: // Parcel properties //- Active flag - tracking inactive when active = false - bool active_; + // Store as label for data alignment, but only has bool states + label active_; //- Parcel type id label typeId_; @@ -309,7 +310,7 @@ public: + " typeId" + " nParticle" + " d" - + " dTarget " + + " dTarget" + " (Ux Uy Uz)" + " rho" + " age" @@ -317,6 +318,22 @@ public: + " (UTurbx UTurby UTurbz)" ); + //- String representation of property types + AddToPropertyTypes + ( + ParcelType, + " label" + + " label" + + " scalar" + + " scalar" + + " scalar" + + " vector" + + " scalar" + + " scalar" + + " scalar" + + " vector" + ); + // Constructors @@ -442,8 +459,8 @@ public: // Edit - //- Return const access to active flag - inline bool& active(); + //- Set active flag to the specified state + inline void active(const bool state); //- Return access to type id inline label& typeId(); diff --git a/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcelI.H b/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcelI.H index ca445b3f64..0c4aa60766 100644 --- a/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcelI.H +++ b/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcelI.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -265,9 +265,9 @@ inline Foam::scalar Foam::KinematicParcel::muc() const template -inline bool& Foam::KinematicParcel::active() +inline void Foam::KinematicParcel::active(const bool state) { - return active_; + active_ = state; } diff --git a/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcelIO.C b/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcelIO.C index 9015582842..22da248dd6 100644 --- a/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcelIO.C +++ b/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcelIO.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -35,7 +35,11 @@ Foam::string Foam::KinematicParcel::propertyList_ = Foam::KinematicParcel::propertyList(); template -const std::size_t Foam::KinematicParcel::sizeofFields_ +Foam::string Foam::KinematicParcel::propertyTypes_ = + Foam::KinematicParcel::propertyTypes(); + +template +const std::size_t Foam::KinematicParcel::sizeofFields ( offsetof(KinematicParcel, rhoc_) - offsetof(KinematicParcel, active_) @@ -84,7 +88,7 @@ Foam::KinematicParcel::KinematicParcel } else { - is.read(reinterpret_cast(&active_), sizeofFields_); + is.read(reinterpret_cast(&active_), sizeofFields); } } @@ -229,7 +233,7 @@ Foam::Ostream& Foam::operator<< if (os.format() == IOstream::ASCII) { os << static_cast(p) - << token::SPACE << p.active() + << token::SPACE << bool(p.active()) << token::SPACE << p.typeId() << token::SPACE << p.nParticle() << token::SPACE << p.d() @@ -246,7 +250,7 @@ Foam::Ostream& Foam::operator<< os.write ( reinterpret_cast(&p.active_), - KinematicParcel::sizeofFields_ + KinematicParcel::sizeofFields ); } diff --git a/src/lagrangian/intermediate/parcels/Templates/MPPICParcel/MPPICParcel.H b/src/lagrangian/intermediate/parcels/Templates/MPPICParcel/MPPICParcel.H index 38c2ceb4e4..0f2d4043a0 100644 --- a/src/lagrangian/intermediate/parcels/Templates/MPPICParcel/MPPICParcel.H +++ b/src/lagrangian/intermediate/parcels/Templates/MPPICParcel/MPPICParcel.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -73,14 +73,13 @@ class MPPICParcel : public ParcelType { - // Private data - - //- Size in bytes of the fields - static const std::size_t sizeofFields_; - - public: + //- Size in bytes of the fields + static const std::size_t sizeofFields; + + + //- Tracking data template class TrackingData : @@ -175,7 +174,14 @@ public: AddToPropertyList ( ParcelType, - "(UCorrectx UCorrecty UCorrectz)" + " (UCorrectx UCorrecty UCorrectz)" + ); + + //- String representation of property types + AddToPropertyTypes + ( + ParcelType, + " vector" ); diff --git a/src/lagrangian/intermediate/parcels/Templates/MPPICParcel/MPPICParcelIO.C b/src/lagrangian/intermediate/parcels/Templates/MPPICParcel/MPPICParcelIO.C index ab4eb3e0c9..28af8d627e 100644 --- a/src/lagrangian/intermediate/parcels/Templates/MPPICParcel/MPPICParcelIO.C +++ b/src/lagrangian/intermediate/parcels/Templates/MPPICParcel/MPPICParcelIO.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -34,7 +34,11 @@ Foam::string Foam::MPPICParcel::propertyList_ = Foam::MPPICParcel::propertyList(); template -const std::size_t Foam::MPPICParcel::sizeofFields_ +Foam::string Foam::MPPICParcel::propertyTypes_ = + Foam::MPPICParcel::propertyTypes(); + +template +const std::size_t Foam::MPPICParcel::sizeofFields ( sizeof(MPPICParcel) - sizeof(ParcelType) ); @@ -61,7 +65,7 @@ Foam::MPPICParcel::MPPICParcel } else { - is.read(reinterpret_cast(&UCorrect_), sizeofFields_); + is.read(reinterpret_cast(&UCorrect_), sizeofFields); } } @@ -146,7 +150,7 @@ Foam::Ostream& Foam::operator<< os.write ( reinterpret_cast(&p.UCorrect_), - MPPICParcel::sizeofFields_ + MPPICParcel::sizeofFields ); } diff --git a/src/lagrangian/intermediate/parcels/Templates/ReactingMultiphaseParcel/ReactingMultiphaseParcel.H b/src/lagrangian/intermediate/parcels/Templates/ReactingMultiphaseParcel/ReactingMultiphaseParcel.H index b431e36866..bc8d2780a6 100644 --- a/src/lagrangian/intermediate/parcels/Templates/ReactingMultiphaseParcel/ReactingMultiphaseParcel.H +++ b/src/lagrangian/intermediate/parcels/Templates/ReactingMultiphaseParcel/ReactingMultiphaseParcel.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -66,14 +66,12 @@ class ReactingMultiphaseParcel : public ParcelType { - // Private data - - //- Size in bytes of the fields - static const std::size_t sizeofFields_; - - public: + //- Size in bytes of the fields + static const std::size_t sizeofFields; + + // IDs of phases in ReacingParcel phase list (Y) static const label GAS; @@ -267,6 +265,15 @@ public: + " nSolid(Y1..YN)" ); + //- String representation of property types + AddToPropertyTypes + ( + ParcelType, + " List" + + " List" + + " List" + ); + // Constructors diff --git a/src/lagrangian/intermediate/parcels/Templates/ReactingMultiphaseParcel/ReactingMultiphaseParcelIO.C b/src/lagrangian/intermediate/parcels/Templates/ReactingMultiphaseParcel/ReactingMultiphaseParcelIO.C index e219f5ee95..2a776383ae 100644 --- a/src/lagrangian/intermediate/parcels/Templates/ReactingMultiphaseParcel/ReactingMultiphaseParcelIO.C +++ b/src/lagrangian/intermediate/parcels/Templates/ReactingMultiphaseParcel/ReactingMultiphaseParcelIO.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -33,7 +33,11 @@ Foam::string Foam::ReactingMultiphaseParcel::propertyList_ = Foam::ReactingMultiphaseParcel::propertyList(); template -const std::size_t Foam::ReactingMultiphaseParcel::sizeofFields_ +Foam::string Foam::ReactingMultiphaseParcel::propertyTypes_ = + Foam::ReactingMultiphaseParcel::propertyTypes(); + +template +const std::size_t Foam::ReactingMultiphaseParcel::sizeofFields ( 0 ); diff --git a/src/lagrangian/intermediate/parcels/Templates/ReactingParcel/ReactingParcel.H b/src/lagrangian/intermediate/parcels/Templates/ReactingParcel/ReactingParcel.H index a89bc9c4cf..0e84c7828f 100644 --- a/src/lagrangian/intermediate/parcels/Templates/ReactingParcel/ReactingParcel.H +++ b/src/lagrangian/intermediate/parcels/Templates/ReactingParcel/ReactingParcel.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -67,14 +67,12 @@ class ReactingParcel : public ParcelType { - // Private data - - //- Size in bytes of the fields - static const std::size_t sizeofFields_; - - public: + //- Size in bytes of the fields + static const std::size_t sizeofFields; + + //- Class to hold reacting parcel constant properties class constantProperties : @@ -221,6 +219,14 @@ public: + " nPhases(Y1..YN)" ); + //- String representation of property types + AddToPropertyTypes + ( + ParcelType, + " scalar" + + " List" + ); + // Constructors diff --git a/src/lagrangian/intermediate/parcels/Templates/ReactingParcel/ReactingParcelIO.C b/src/lagrangian/intermediate/parcels/Templates/ReactingParcel/ReactingParcelIO.C index f0254656cf..3eb02e4e2a 100644 --- a/src/lagrangian/intermediate/parcels/Templates/ReactingParcel/ReactingParcelIO.C +++ b/src/lagrangian/intermediate/parcels/Templates/ReactingParcel/ReactingParcelIO.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -33,7 +33,11 @@ Foam::string Foam::ReactingParcel::propertyList_ = Foam::ReactingParcel::propertyList(); template -const std::size_t Foam::ReactingParcel::sizeofFields_ +Foam::string Foam::ReactingParcel::propertyTypes_ = + Foam::ReactingParcel::propertyTypes(); + +template +const std::size_t Foam::ReactingParcel::sizeofFields ( sizeof(scalar) ); @@ -64,7 +68,7 @@ Foam::ReactingParcel::ReactingParcel } else { - is.read(reinterpret_cast(&mass0_), sizeofFields_); + is.read(reinterpret_cast(&mass0_), sizeofFields); is >> Ymix; } @@ -251,7 +255,7 @@ Foam::Ostream& Foam::operator<< os.write ( reinterpret_cast(&p.mass0_), - ReactingParcel::sizeofFields_ + ReactingParcel::sizeofFields ); os << p.Y(); } diff --git a/src/lagrangian/intermediate/parcels/Templates/ThermoParcel/ThermoParcel.H b/src/lagrangian/intermediate/parcels/Templates/ThermoParcel/ThermoParcel.H index 3ea797ff8d..ac0e968771 100644 --- a/src/lagrangian/intermediate/parcels/Templates/ThermoParcel/ThermoParcel.H +++ b/src/lagrangian/intermediate/parcels/Templates/ThermoParcel/ThermoParcel.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -67,14 +67,12 @@ class ThermoParcel : public ParcelType { - // Private data - - //- Size in bytes of the fields - static const std::size_t sizeofFields_; - - public: + //- Size in bytes of the fields + static const std::size_t sizeofFields; + + //- Class to hold thermo particle constant properties class constantProperties : @@ -277,6 +275,14 @@ public: + " Cp" ); + //- String representation of property types + AddToPropertyTypes + ( + ParcelType, + " scalar" + + " scalar" + ); + // Constructors diff --git a/src/lagrangian/intermediate/parcels/Templates/ThermoParcel/ThermoParcelIO.C b/src/lagrangian/intermediate/parcels/Templates/ThermoParcel/ThermoParcelIO.C index 93e60505b8..da0b6bd5ae 100644 --- a/src/lagrangian/intermediate/parcels/Templates/ThermoParcel/ThermoParcelIO.C +++ b/src/lagrangian/intermediate/parcels/Templates/ThermoParcel/ThermoParcelIO.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -33,7 +33,11 @@ Foam::string Foam::ThermoParcel::propertyList_ = Foam::ThermoParcel::propertyList(); template -const std::size_t Foam::ThermoParcel::sizeofFields_ +Foam::string Foam::ThermoParcel::propertyTypes_ = + Foam::ThermoParcel::propertyTypes(); + +template +const std::size_t Foam::ThermoParcel::sizeofFields ( offsetof(ThermoParcel, Tc_) - offsetof(ThermoParcel, T_) @@ -65,7 +69,7 @@ Foam::ThermoParcel::ThermoParcel } else { - is.read(reinterpret_cast(&T_), sizeofFields_); + is.read(reinterpret_cast(&T_), sizeofFields); } } @@ -154,7 +158,7 @@ Foam::Ostream& Foam::operator<< os.write ( reinterpret_cast(&p.T_), - ThermoParcel::sizeofFields_ + ThermoParcel::sizeofFields ); } diff --git a/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/LocalInteraction/LocalInteraction.C b/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/LocalInteraction/LocalInteraction.C index 3798229091..f7ee9e88aa 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/LocalInteraction/LocalInteraction.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/LocalInteraction/LocalInteraction.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -181,7 +181,6 @@ bool Foam::LocalInteraction::correct if (patchI >= 0) { vector& U = p.U(); - bool& active = p.active(); typename PatchInteractionModel::interactionType it = this->wordToInteractionType @@ -196,7 +195,7 @@ bool Foam::LocalInteraction::correct scalar dm = p.mass()*p.nParticle(); keepParticle = false; - active = false; + p.active(false); U = Zero; nEscape_[patchI]++; massEscape_[patchI] += dm; @@ -213,7 +212,7 @@ bool Foam::LocalInteraction::correct scalar dm = p.mass()*p.nParticle(); keepParticle = true; - active = false; + p.active(false); U = Zero; nStick_[patchI]++; massStick_[patchI] += dm; @@ -228,7 +227,7 @@ bool Foam::LocalInteraction::correct case PatchInteractionModel::itRebound: { keepParticle = true; - active = true; + p.active(true); vector nw; vector Up; diff --git a/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/Rebound/Rebound.C b/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/Rebound/Rebound.C index f6c1fda460..5eb43b55f3 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/Rebound/Rebound.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/Rebound/Rebound.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -69,7 +69,7 @@ bool Foam::Rebound::correct vector& U = p.U(); keepParticle = true; - p.active() = true; + p.active(true); vector nw; vector Up; diff --git a/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/StandardWallInteraction/StandardWallInteraction.C b/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/StandardWallInteraction/StandardWallInteraction.C index 38b57a2721..61c5829281 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/StandardWallInteraction/StandardWallInteraction.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/StandardWallInteraction/StandardWallInteraction.C @@ -112,8 +112,6 @@ bool Foam::StandardWallInteraction::correct { vector& U = p.U(); - bool& active = p.active(); - if (isA(pp)) { switch (interactionType_) @@ -121,7 +119,7 @@ bool Foam::StandardWallInteraction::correct case PatchInteractionModel::itEscape: { keepParticle = false; - active = false; + p.active(false); U = Zero; nEscape_++; massEscape_ += p.nParticle()*p.mass(); @@ -130,7 +128,7 @@ bool Foam::StandardWallInteraction::correct case PatchInteractionModel::itStick: { keepParticle = true; - active = false; + p.active(false); U = Zero; nStick_++; massStick_ += p.nParticle()*p.mass(); @@ -139,7 +137,7 @@ bool Foam::StandardWallInteraction::correct case PatchInteractionModel::itRebound: { keepParticle = true; - active = true; + p.active(true); vector nw; vector Up; diff --git a/src/lagrangian/molecularDynamics/molecule/molecule/molecule.H b/src/lagrangian/molecularDynamics/molecule/molecule/molecule.H index a3d0682c9d..a47550becc 100644 --- a/src/lagrangian/molecularDynamics/molecule/molecule/molecule.H +++ b/src/lagrangian/molecularDynamics/molecule/molecule/molecule.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -58,17 +58,15 @@ class molecule : public particle { - // Private data - - //- Size in bytes of the fields - static const std::size_t sizeofFields_; - - public: + //- Size in bytes of the fields + static const std::size_t sizeofFields; + + // Values of special that are less than zero are for built-in functionality. - // Values greater than zero are user specifiable/expandable (i.e. test - // special_ >= SPECIAL_USER) + // Values greater than zero are user specifiable/expandable + // (i.e. test special_ >= SPECIAL_USER) enum specialTypes { @@ -78,6 +76,7 @@ public: SPECIAL_USER = 1 }; + //- Class to hold molecule constant properties class constantProperties { diff --git a/src/lagrangian/molecularDynamics/molecule/molecule/moleculeIO.C b/src/lagrangian/molecularDynamics/molecule/molecule/moleculeIO.C index d6fd3cbd29..9b15c28c18 100644 --- a/src/lagrangian/molecularDynamics/molecule/molecule/moleculeIO.C +++ b/src/lagrangian/molecularDynamics/molecule/molecule/moleculeIO.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -29,7 +29,7 @@ License // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // -const std::size_t Foam::molecule::sizeofFields_ +const std::size_t Foam::molecule::sizeofFields ( offsetof(molecule, siteForces_) - offsetof(molecule, Q_) ); @@ -77,7 +77,7 @@ Foam::molecule::molecule } else { - is.read(reinterpret_cast(&Q_), sizeofFields_); + is.read(reinterpret_cast(&Q_), sizeofFields); is >> siteForces_ >> sitePositions_; } } @@ -276,7 +276,7 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const molecule& mol) os.write ( reinterpret_cast(&mol.Q_), - molecule::sizeofFields_ + molecule::sizeofFields ); os << mol.siteForces_ << mol.sitePositions_; } diff --git a/src/lagrangian/solidParticle/solidParticle.H b/src/lagrangian/solidParticle/solidParticle.H index 7bbd2dc330..f476e03d54 100644 --- a/src/lagrangian/solidParticle/solidParticle.H +++ b/src/lagrangian/solidParticle/solidParticle.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -61,9 +61,6 @@ class solidParticle { // Private data - //- Size in bytes of the fields - static const std::size_t sizeofFields_; - //- Diameter scalar d_; @@ -116,6 +113,12 @@ public: }; + // Static data members + + //- Size in bytes of the fields + static const std::size_t sizeofFields; + + // Constructors //- Construct from components diff --git a/src/lagrangian/solidParticle/solidParticleIO.C b/src/lagrangian/solidParticle/solidParticleIO.C index fe50df977f..c27cdbb94d 100644 --- a/src/lagrangian/solidParticle/solidParticleIO.C +++ b/src/lagrangian/solidParticle/solidParticleIO.C @@ -28,7 +28,7 @@ License // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // -const std::size_t Foam::solidParticle::sizeofFields_ +const std::size_t Foam::solidParticle::sizeofFields ( sizeof(solidParticle) - sizeof(particle) ); @@ -54,7 +54,7 @@ Foam::solidParticle::solidParticle } else { - is.read(reinterpret_cast(&d_), sizeofFields_); + is.read(reinterpret_cast(&d_), sizeofFields); } } @@ -130,7 +130,7 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const solidParticle& p) os.write ( reinterpret_cast(&p.d_), - solidParticle::sizeofFields_ + solidParticle::sizeofFields ); } diff --git a/src/lagrangian/spray/parcels/Templates/SprayParcel/SprayParcel.H b/src/lagrangian/spray/parcels/Templates/SprayParcel/SprayParcel.H index 1acbc4a849..76210b20c0 100644 --- a/src/lagrangian/spray/parcels/Templates/SprayParcel/SprayParcel.H +++ b/src/lagrangian/spray/parcels/Templates/SprayParcel/SprayParcel.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -25,7 +25,7 @@ Class Foam::SprayParcel Description - Reacing spray parcel, with added functionality for atomization and breakup + Reacting spray parcel, with added functionality for atomization and breakup \*---------------------------------------------------------------------------*/ @@ -59,12 +59,6 @@ class SprayParcel : public ParcelType { - // Private data - - //- Size in bytes of the fields - static const std::size_t sizeofFields_; - - public: //- Class to hold reacting particle constant properties @@ -178,6 +172,9 @@ public: // Static data members + //- Size in bytes of the fields + static const std::size_t sizeofFields; + //- Runtime type information TypeName("SprayParcel"); @@ -185,7 +182,7 @@ public: AddToPropertyList ( ParcelType, - + " d0" + " d0" + " position0" + " sigma" + " mu" @@ -200,6 +197,25 @@ public: + " user" ); + //- String representation of property types + AddToPropertyTypes + ( + ParcelType, + " scalar" + + " vector" + + " scalar" + + " scalar" + + " scalar" + + " scalar" + + " scalar" + + " scalar" + + " scalar" + + " scalar" + + " scalar" + + " scalar" + + " scalar" + ); + // Constructors diff --git a/src/lagrangian/spray/parcels/Templates/SprayParcel/SprayParcelIO.C b/src/lagrangian/spray/parcels/Templates/SprayParcel/SprayParcelIO.C index f5510d10a7..482bb4e42b 100644 --- a/src/lagrangian/spray/parcels/Templates/SprayParcel/SprayParcelIO.C +++ b/src/lagrangian/spray/parcels/Templates/SprayParcel/SprayParcelIO.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -32,9 +32,13 @@ template Foam::string Foam::SprayParcel::propertyList_ = Foam::SprayParcel::propertyList(); +template +Foam::string Foam::SprayParcel::propertyTypes_ = + Foam::SprayParcel::propertyTypes(); + template -const std::size_t Foam::SprayParcel::sizeofFields_ +const std::size_t Foam::SprayParcel::sizeofFields ( sizeof(SprayParcel) - sizeof(ParcelType) ); @@ -85,7 +89,7 @@ Foam::SprayParcel::SprayParcel } else { - is.read(reinterpret_cast(&d0_), sizeofFields_); + is.read(reinterpret_cast(&d0_), sizeofFields); } } @@ -311,7 +315,7 @@ Foam::Ostream& Foam::operator<< os.write ( reinterpret_cast(&p.d0_), - SprayParcel::sizeofFields_ + SprayParcel::sizeofFields ); }