From cf07fdc957fdd575ef24e90b91dcba138ddfb91c Mon Sep 17 00:00:00 2001 From: Henry Date: Sun, 22 Feb 2015 12:14:46 +0000 Subject: [PATCH] lagrangian: Improved handling of binary transfers Now using memory offsets to calculate transfer block sizes rather than sum of 'sizeof' to ensure word alignment is accounted for --- .../parcels/Templates/DSMCParcel/DSMCParcel.H | 17 +- .../Templates/DSMCParcel/DSMCParcelIO.C | 21 +- src/lagrangian/basic/IOPosition/IOPosition.C | 13 +- src/lagrangian/basic/particle/particle.H | 14 +- src/lagrangian/basic/particle/particleIO.C | 114 ++++----- .../CollidingParcel/CollidingParcel.H | 10 +- .../CollidingParcel/CollidingParcelIO.C | 29 ++- .../KinematicParcel/KinematicParcel.H | 17 +- .../KinematicParcel/KinematicParcelIO.C | 21 +- .../Templates/MPPICParcel/MPPICParcel.H | 8 +- .../Templates/MPPICParcel/MPPICParcelIO.C | 16 +- .../ReactingMultiphaseParcel.H | 8 +- .../ReactingMultiphaseParcelIO.C | 8 +- .../Templates/ReactingParcel/ReactingParcel.H | 23 +- .../ReactingParcel/ReactingParcelIO.C | 16 +- .../Templates/ThermoParcel/ThermoParcel.H | 8 +- .../Templates/ThermoParcel/ThermoParcelIO.C | 20 +- .../MPPIC/AveragingMethods/Dual/Dual.H | 6 +- .../molecule/molecule/molecule.H | 7 +- .../molecule/molecule/moleculeIO.C | 43 +--- src/lagrangian/solidParticle/solidParticle.H | 7 +- .../solidParticle/solidParticleIO.C | 18 +- .../Templates/SprayParcel/SprayParcel.H | 10 +- .../Templates/SprayParcel/SprayParcelIO.C | 54 +---- .../wallBoundedParticle.C | 223 +++--------------- .../wallBoundedParticle.H | 10 +- 26 files changed, 286 insertions(+), 455 deletions(-) diff --git a/src/lagrangian/DSMC/parcels/Templates/DSMCParcel/DSMCParcel.H b/src/lagrangian/DSMC/parcels/Templates/DSMCParcel/DSMCParcel.H index c55e16dfb..3d9106c7e 100644 --- a/src/lagrangian/DSMC/parcels/Templates/DSMCParcel/DSMCParcel.H +++ b/src/lagrangian/DSMC/parcels/Templates/DSMCParcel/DSMCParcel.H @@ -41,7 +41,6 @@ SourceFiles #include "IOstream.H" #include "autoPtr.H" #include "contiguous.H" - #include "DSMCCloud.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -70,6 +69,12 @@ class DSMCParcel : public ParcelType { + // Private member data + + //- Size in bytes of the fields + static const std::size_t sizeofFields_; + + public: //- Class to hold DSMC particle constant properties @@ -92,7 +97,7 @@ public: public: - // Constrcutors + // Constructors //- Null constructor, allows List of constantProperties to be // created before the contents is initialised @@ -104,10 +109,10 @@ public: // Member functions - //- Return const access to the particle density + //- Return const access to the particle mass [kg] inline scalar mass() const; - //- Return const access to the minimum particle mass + //- Return const access to the hard sphere diameter [m] inline scalar d() const; //- Return the reference total collision cross section @@ -152,7 +157,7 @@ protected: vector U_; //- Internal energy of the Parcel, covering all non-translational - // degrees of freedom [J] + // degrees of freedom [J] scalar Ei_; //- Parcel type id @@ -196,7 +201,6 @@ public: return autoPtr(new DSMCParcel(*this)); } - //- Factory class to read-construct particles used for // parallel transfer class iNew @@ -233,6 +237,7 @@ public: //- Return const access to internal energy inline scalar Ei() const; + // Edit //- Return access to velocity diff --git a/src/lagrangian/DSMC/parcels/Templates/DSMCParcel/DSMCParcelIO.C b/src/lagrangian/DSMC/parcels/Templates/DSMCParcel/DSMCParcelIO.C index f0b7d6277..6c6c545ae 100644 --- a/src/lagrangian/DSMC/parcels/Templates/DSMCParcel/DSMCParcelIO.C +++ b/src/lagrangian/DSMC/parcels/Templates/DSMCParcel/DSMCParcelIO.C @@ -28,6 +28,15 @@ License #include "IOField.H" #include "Cloud.H" +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +template +const std::size_t Foam::DSMCParcel::sizeofFields_ +( + sizeof(DSMCParcel) - sizeof(ParcelType) +); + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template @@ -53,13 +62,7 @@ Foam::DSMCParcel::DSMCParcel } else { - is.read - ( - reinterpret_cast(&U_), - sizeof(U_) - + sizeof(Ei_) - + sizeof(typeId_) - ); + is.read(reinterpret_cast(&U_), sizeofFields_); } } @@ -157,9 +160,7 @@ Foam::Ostream& Foam::operator<< os.write ( reinterpret_cast(&p.U_), - sizeof(p.U()) - + sizeof(p.Ei()) - + sizeof(p.typeId()) + DSMCParcel::sizeofFields_ ); } diff --git a/src/lagrangian/basic/IOPosition/IOPosition.C b/src/lagrangian/basic/IOPosition/IOPosition.C index 7b933dd51..5bb41e5fd 100644 --- a/src/lagrangian/basic/IOPosition/IOPosition.C +++ b/src/lagrangian/basic/IOPosition/IOPosition.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -68,11 +68,7 @@ bool Foam::IOPosition::writeData(Ostream& os) const forAllConstIter(typename CloudType, cloud_, iter) { - const typename CloudType::particleType& p = iter(); - - // Prevent writing additional fields - p.write(os, false); - + iter().writePosition(os); os << nl; } @@ -100,7 +96,7 @@ void Foam::IOPosition::readData(CloudType& c, bool checkClass) for (label i=0; i::readData(CloudType& c, bool checkClass) ) { is.putBack(lastToken); - // Do not read any fields, position only + + // Write position only c.append(new typename CloudType::particleType(mesh, is, false)); is >> lastToken; } diff --git a/src/lagrangian/basic/particle/particle.H b/src/lagrangian/basic/particle/particle.H index c2d10f46b..cbc29774a 100644 --- a/src/lagrangian/basic/particle/particle.H +++ b/src/lagrangian/basic/particle/particle.H @@ -80,6 +80,15 @@ class particle : public IDLList::link { + // Private member data + + //- 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: template @@ -358,7 +367,6 @@ public: return autoPtr(new particle(*this)); } - //- Factory class to read-construct particles used for // parallel transfer class iNew @@ -556,8 +564,8 @@ public: template static void writeFields(const CloudType& c); - //- Write the particle data - void write(Ostream& os, bool writeFields) const; + //- Write the particle position and cell + void writePosition(Ostream&) const; // Friend Operators diff --git a/src/lagrangian/basic/particle/particleIO.C b/src/lagrangian/basic/particle/particleIO.C index 6484cf07a..7d617175c 100644 --- a/src/lagrangian/basic/particle/particleIO.C +++ b/src/lagrangian/basic/particle/particleIO.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -25,12 +25,21 @@ License #include "particle.H" #include "IOstreams.H" -#include "IOPosition.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // Foam::string Foam::particle::propertyList_ = Foam::particle::propertyList(); +const std::size_t Foam::particle::sizeofPosition_ +( + offsetof(particle, faceI_) - offsetof(particle, position_) +); + +const std::size_t Foam::particle::sizeofFields_ +( + sizeof(particle) - offsetof(particle, position_) +); + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -46,45 +55,29 @@ Foam::particle::particle(const polyMesh& mesh, Istream& is, bool readFields) origProc_(Pstream::myProcNo()), origId_(-1) { - // readFields : read additional data. Should be consistent with writeFields. - if (is.format() == IOstream::ASCII) { is >> position_ >> cellI_; if (readFields) { - is >> tetFaceI_ >> tetPtI_ >> origProc_ >> origId_; + is >> faceI_ + >> stepFraction_ + >> tetFaceI_ + >> tetPtI_ + >> origProc_ + >> origId_; } } else { - // In binary read all particle data - needed for parallel transfer if (readFields) { - is.read - ( - reinterpret_cast(&position_), - sizeof(position_) - + sizeof(cellI_) - + sizeof(faceI_) - + sizeof(stepFraction_) - + sizeof(tetFaceI_) - + sizeof(tetPtI_) - + sizeof(origProc_) - + sizeof(origId_) - ); + is.read(reinterpret_cast(&position_), sizeofFields_); } else { - is.read - ( - reinterpret_cast(&position_), - sizeof(position_) - + sizeof(cellI_) - + sizeof(faceI_) - + sizeof(stepFraction_) - ); + is.read(reinterpret_cast(&position_), sizeofPosition_); } } @@ -93,66 +86,43 @@ Foam::particle::particle(const polyMesh& mesh, Istream& is, bool readFields) } -void Foam::particle::write(Ostream& os, bool writeFields) const +void Foam::particle::writePosition(Ostream& os) const { if (os.format() == IOstream::ASCII) { - if (writeFields) - { - // Write the additional entries - os << position_ - << token::SPACE << cellI_ - << token::SPACE << tetFaceI_ - << token::SPACE << tetPtI_ - << token::SPACE << origProc_ - << token::SPACE << origId_; - } - else - { - os << position_ - << token::SPACE << cellI_; - } + os << position_ << token::SPACE << cellI_; } else { - // In binary write both cellI_ and faceI_, needed for parallel transfer - if (writeFields) - { - os.write - ( - reinterpret_cast(&position_), - sizeof(position_) - + sizeof(cellI_) - + sizeof(faceI_) - + sizeof(stepFraction_) - + sizeof(tetFaceI_) - + sizeof(tetPtI_) - + sizeof(origProc_) - + sizeof(origId_) - ); - } - else - { - os.write - ( - reinterpret_cast(&position_), - sizeof(position_) - + sizeof(cellI_) - + sizeof(faceI_) - + sizeof(stepFraction_) - ); - } + os.write(reinterpret_cast(&position_), sizeofPosition_); } // Check state of Ostream - os.check("particle::write(Ostream& os, bool) const"); + os.check("particle::writePosition(Ostream& os, bool) const"); } Foam::Ostream& Foam::operator<<(Ostream& os, const particle& p) { - // Write all data - p.write(os, true); + if (os.format() == IOstream::ASCII) + { + os << p.position_ + << token::SPACE << p.cellI_ + << token::SPACE << p.faceI_ + << token::SPACE << p.stepFraction_ + << token::SPACE << p.tetFaceI_ + << token::SPACE << p.tetPtI_ + << token::SPACE << p.origProc_ + << token::SPACE << p.origId_; + } + else + { + os.write + ( + reinterpret_cast(&p.position_), + particle::sizeofFields_ + ); + } return os; } diff --git a/src/lagrangian/intermediate/parcels/Templates/CollidingParcel/CollidingParcel.H b/src/lagrangian/intermediate/parcels/Templates/CollidingParcel/CollidingParcel.H index d6c187515..ae98aae25 100644 --- a/src/lagrangian/intermediate/parcels/Templates/CollidingParcel/CollidingParcel.H +++ b/src/lagrangian/intermediate/parcels/Templates/CollidingParcel/CollidingParcel.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -38,12 +38,10 @@ SourceFiles #define CollidingParcel_H #include "particle.H" - #include "CollisionRecordList.H" #include "labelFieldIOField.H" #include "vectorFieldIOField.H" - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam @@ -74,6 +72,12 @@ class CollidingParcel : public ParcelType { + // Private member data + + //- Size in bytes of the fields + static const std::size_t sizeofFields_; + + public: //- Class to hold thermo particle constant properties diff --git a/src/lagrangian/intermediate/parcels/Templates/CollidingParcel/CollidingParcelIO.C b/src/lagrangian/intermediate/parcels/Templates/CollidingParcel/CollidingParcelIO.C index 020a66323..25aee6fa8 100644 --- a/src/lagrangian/intermediate/parcels/Templates/CollidingParcel/CollidingParcelIO.C +++ b/src/lagrangian/intermediate/parcels/Templates/CollidingParcel/CollidingParcelIO.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -33,6 +33,13 @@ template Foam::string Foam::CollidingParcel::propertyList_ = Foam::CollidingParcel::propertyList(); +template +const std::size_t Foam::CollidingParcel::sizeofFields_ +( + offsetof(CollidingParcel, collisionRecords_) + - offsetof(CollidingParcel, f_) +); + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -60,13 +67,7 @@ Foam::CollidingParcel::CollidingParcel } else { - is.read - ( - reinterpret_cast(&f_), - + sizeof(f_) - + sizeof(angularMomentum_) - + sizeof(torque_) - ); + is.read(reinterpret_cast(&f_), sizeofFields_); } is >> collisionRecords_; @@ -285,10 +286,10 @@ Foam::Ostream& Foam::operator<< if (os.format() == IOstream::ASCII) { os << static_cast(p) - << token::SPACE << p.f() - << token::SPACE << p.angularMomentum() - << token::SPACE << p.torque() - << token::SPACE << p.collisionRecords(); + << token::SPACE << p.f_ + << token::SPACE << p.angularMomentum_ + << token::SPACE << p.torque_ + << token::SPACE << p.collisionRecords_; } else { @@ -296,9 +297,7 @@ Foam::Ostream& Foam::operator<< os.write ( reinterpret_cast(&p.f_), - + sizeof(p.f()) - + sizeof(p.angularMomentum()) - + sizeof(p.torque()) + 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 6b6f25828..85d48c598 100644 --- a/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.H +++ b/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -78,6 +78,15 @@ class KinematicParcel : public ParcelType { + // 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: //- Class to hold kinematic particle constant properties @@ -137,7 +146,7 @@ public: //- Return const access to the particle density inline scalar rho0() const; - //- Return const access to the minimum particle mass + //- Return const access to the minimum parcel mass inline scalar minParcelMass() const; }; @@ -218,10 +227,6 @@ public: }; - //- Number of particle tracking attempts before we assume that it stalls - static label maxTrackAttempts; - - protected: // Protected data diff --git a/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcelIO.C b/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcelIO.C index 5bcd22421..79ef7f29f 100644 --- a/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcelIO.C +++ b/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcelIO.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -34,6 +34,14 @@ template Foam::string Foam::KinematicParcel::propertyList_ = Foam::KinematicParcel::propertyList(); +template +const std::size_t Foam::KinematicParcel::sizeofFields_ +( + offsetof(KinematicParcel, rhoc_) + - offsetof(KinematicParcel, active_) +); + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template @@ -76,8 +84,7 @@ Foam::KinematicParcel::KinematicParcel } else { - label size = long(&UTurb_) - long(&active_) + sizeof(UTurb_); - is.read(reinterpret_cast(&active_), size); + is.read(reinterpret_cast(&active_), sizeofFields_); } } @@ -236,9 +243,11 @@ Foam::Ostream& Foam::operator<< else { os << static_cast(p); - - label size = long(&p.UTurb_) - long(&p.active_) + sizeof(p.UTurb_); - os.write(reinterpret_cast(&p.active_), size); + os.write + ( + reinterpret_cast(&p.active_), + KinematicParcel::sizeofFields_ + ); } // Check state of Ostream diff --git a/src/lagrangian/intermediate/parcels/Templates/MPPICParcel/MPPICParcel.H b/src/lagrangian/intermediate/parcels/Templates/MPPICParcel/MPPICParcel.H index c095821f8..b4d6573ea 100644 --- a/src/lagrangian/intermediate/parcels/Templates/MPPICParcel/MPPICParcel.H +++ b/src/lagrangian/intermediate/parcels/Templates/MPPICParcel/MPPICParcel.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2013 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2013-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -73,6 +73,12 @@ class MPPICParcel : public ParcelType { + // Private data + + //- Size in bytes of the fields + static const std::size_t sizeofFields_; + + public: template diff --git a/src/lagrangian/intermediate/parcels/Templates/MPPICParcel/MPPICParcelIO.C b/src/lagrangian/intermediate/parcels/Templates/MPPICParcel/MPPICParcelIO.C index f0eff872b..78ec2af31 100644 --- a/src/lagrangian/intermediate/parcels/Templates/MPPICParcel/MPPICParcelIO.C +++ b/src/lagrangian/intermediate/parcels/Templates/MPPICParcel/MPPICParcelIO.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2013 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2013-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -33,6 +33,12 @@ template Foam::string Foam::MPPICParcel::propertyList_ = Foam::MPPICParcel::propertyList(); +template +const std::size_t Foam::MPPICParcel::sizeofFields_ +( + sizeof(MPPICParcel) - sizeof(ParcelType) +); + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -55,11 +61,7 @@ Foam::MPPICParcel::MPPICParcel } else { - is.read - ( - reinterpret_cast(&UCorrect_), - + sizeof(UCorrect_) - ); + is.read(reinterpret_cast(&UCorrect_), sizeofFields_); } } @@ -144,7 +146,7 @@ Foam::Ostream& Foam::operator<< os.write ( reinterpret_cast(&p.UCorrect_), - + sizeof(p.UCorrect()) + MPPICParcel::sizeofFields_ ); } diff --git a/src/lagrangian/intermediate/parcels/Templates/ReactingMultiphaseParcel/ReactingMultiphaseParcel.H b/src/lagrangian/intermediate/parcels/Templates/ReactingMultiphaseParcel/ReactingMultiphaseParcel.H index 63f06904c..4539dc3cb 100644 --- a/src/lagrangian/intermediate/parcels/Templates/ReactingMultiphaseParcel/ReactingMultiphaseParcel.H +++ b/src/lagrangian/intermediate/parcels/Templates/ReactingMultiphaseParcel/ReactingMultiphaseParcel.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -66,6 +66,12 @@ class ReactingMultiphaseParcel : public ParcelType { + // Private data + + //- Size in bytes of the fields + static const std::size_t sizeofFields_; + + public: // IDs of phases in ReacingParcel phase list (Y) diff --git a/src/lagrangian/intermediate/parcels/Templates/ReactingMultiphaseParcel/ReactingMultiphaseParcelIO.C b/src/lagrangian/intermediate/parcels/Templates/ReactingMultiphaseParcel/ReactingMultiphaseParcelIO.C index 949537632..77dd06b7b 100644 --- a/src/lagrangian/intermediate/parcels/Templates/ReactingMultiphaseParcel/ReactingMultiphaseParcelIO.C +++ b/src/lagrangian/intermediate/parcels/Templates/ReactingMultiphaseParcel/ReactingMultiphaseParcelIO.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -32,6 +32,12 @@ template Foam::string Foam::ReactingMultiphaseParcel::propertyList_ = Foam::ReactingMultiphaseParcel::propertyList(); +template +const std::size_t Foam::ReactingMultiphaseParcel::sizeofFields_ +( + 0 +); + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // diff --git a/src/lagrangian/intermediate/parcels/Templates/ReactingParcel/ReactingParcel.H b/src/lagrangian/intermediate/parcels/Templates/ReactingParcel/ReactingParcel.H index 1a2d9bf06..c077a29bb 100644 --- a/src/lagrangian/intermediate/parcels/Templates/ReactingParcel/ReactingParcel.H +++ b/src/lagrangian/intermediate/parcels/Templates/ReactingParcel/ReactingParcel.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -57,6 +57,7 @@ Ostream& operator<< const ReactingParcel& ); + /*---------------------------------------------------------------------------*\ Class ReactingParcel Declaration \*---------------------------------------------------------------------------*/ @@ -66,9 +67,15 @@ class ReactingParcel : public ParcelType { + // Private data + + //- Size in bytes of the fields + static const std::size_t sizeofFields_; + + public: - //- Class to hold reacting particle constant properties + //- Class to hold reacting parcel constant properties class constantProperties : public ParcelType::constantProperties @@ -151,7 +158,7 @@ protected: // Parcel properties - //- Initial particle mass [kg] + //- Initial mass [kg] scalar mass0_; //- Mass fractions of mixture [] @@ -183,9 +190,9 @@ protected: const label idPhase, // id of phase involved in phase change const scalar YPhase, // total mass fraction const scalarField& YComponents, // component mass fractions - scalarField& dMassPC, // mass transfer - local to particle - scalar& Sh, // explicit particle enthalpy source - scalar& N, // flux of species emitted from particle + scalarField& dMassPC, // mass transfer - local to parcel + scalar& Sh, // explicit parcel enthalpy source + scalar& N, // flux of species emitted from parcel scalar& NCpW, // sum of N*Cp*W of emission species scalarField& Cs // carrier conc. of emission species ); @@ -308,7 +315,7 @@ public: // Access - //- Return const access to initial particle mass [kg] + //- Return const access to initial mass [kg] inline scalar mass0() const; //- Return const access to mass fractions of mixture [] @@ -323,7 +330,7 @@ public: // Edit - //- Return access to initial particle mass [kg] + //- Return access to initial mass [kg] inline scalar& mass0(); //- Return access to mass fractions of mixture [] diff --git a/src/lagrangian/intermediate/parcels/Templates/ReactingParcel/ReactingParcelIO.C b/src/lagrangian/intermediate/parcels/Templates/ReactingParcel/ReactingParcelIO.C index 918ebdde6..4a1133acc 100644 --- a/src/lagrangian/intermediate/parcels/Templates/ReactingParcel/ReactingParcelIO.C +++ b/src/lagrangian/intermediate/parcels/Templates/ReactingParcel/ReactingParcelIO.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -32,6 +32,12 @@ template Foam::string Foam::ReactingParcel::propertyList_ = Foam::ReactingParcel::propertyList(); +template +const std::size_t Foam::ReactingParcel::sizeofFields_ +( + sizeof(scalar) +); + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -58,11 +64,7 @@ Foam::ReactingParcel::ReactingParcel } else { - is.read - ( - reinterpret_cast(&mass0_), - + sizeof(mass0_) - ); + is.read(reinterpret_cast(&mass0_), sizeofFields_); is >> Ymix; } @@ -249,7 +251,7 @@ Foam::Ostream& Foam::operator<< os.write ( reinterpret_cast(&p.mass0_), - sizeof(p.mass0()) + 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 4e405344e..47424b082 100644 --- a/src/lagrangian/intermediate/parcels/Templates/ThermoParcel/ThermoParcel.H +++ b/src/lagrangian/intermediate/parcels/Templates/ThermoParcel/ThermoParcel.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -67,6 +67,12 @@ class ThermoParcel : public ParcelType { + // Private data + + //- Size in bytes of the fields + static const std::size_t sizeofFields_; + + public: //- Class to hold thermo particle constant properties diff --git a/src/lagrangian/intermediate/parcels/Templates/ThermoParcel/ThermoParcelIO.C b/src/lagrangian/intermediate/parcels/Templates/ThermoParcel/ThermoParcelIO.C index 73621467d..0cf0be0bb 100644 --- a/src/lagrangian/intermediate/parcels/Templates/ThermoParcel/ThermoParcelIO.C +++ b/src/lagrangian/intermediate/parcels/Templates/ThermoParcel/ThermoParcelIO.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -32,6 +32,13 @@ template Foam::string Foam::ThermoParcel::propertyList_ = Foam::ThermoParcel::propertyList(); +template +const std::size_t Foam::ThermoParcel::sizeofFields_ +( + offsetof(ThermoParcel, Tc_) + - offsetof(ThermoParcel, T_) +); + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -58,8 +65,7 @@ Foam::ThermoParcel::ThermoParcel } else { - label size = long(&Cp_) - long(&T_) + sizeof(Cp_); - is.read(reinterpret_cast(&T_), size); + is.read(reinterpret_cast(&T_), sizeofFields_); } } @@ -145,9 +151,11 @@ Foam::Ostream& Foam::operator<< else { os << static_cast(p); - - label size = long(&p.Cp_) - long(&p.T_) + sizeof(p.Cp_); - os.write(reinterpret_cast(&p.T_), size); + os.write + ( + reinterpret_cast(&p.T_), + ThermoParcel::sizeofFields_ + ); } // Check state of Ostream diff --git a/src/lagrangian/intermediate/submodels/MPPIC/AveragingMethods/Dual/Dual.H b/src/lagrangian/intermediate/submodels/MPPIC/AveragingMethods/Dual/Dual.H index 0c905e003..a3c7579e7 100644 --- a/src/lagrangian/intermediate/submodels/MPPIC/AveragingMethods/Dual/Dual.H +++ b/src/lagrangian/intermediate/submodels/MPPIC/AveragingMethods/Dual/Dual.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2013-2014 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2013-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -32,7 +32,7 @@ Description terahedrons surrounding each point. The latter forms a type of dual mesh. The interpolation is weighted by proximity to the cell centre or point, as calculated by the barycentric coordinate within the tethrahedron. - + Values are interpolated linearly across the tethrahedron. Gradients are calculated directly from the point values using a first order finite element basis. The computed gradient is assumed constant over the @@ -98,7 +98,7 @@ private: //- Private static member functions - + //- Return the size of the FieldField parts static autoPtr size(const fvMesh &mesh); diff --git a/src/lagrangian/molecularDynamics/molecule/molecule/molecule.H b/src/lagrangian/molecularDynamics/molecule/molecule/molecule.H index de0745df7..a3d0682c9 100644 --- a/src/lagrangian/molecularDynamics/molecule/molecule/molecule.H +++ b/src/lagrangian/molecularDynamics/molecule/molecule/molecule.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -58,6 +58,11 @@ class molecule : public particle { + // Private data + + //- Size in bytes of the fields + static const std::size_t sizeofFields_; + public: diff --git a/src/lagrangian/molecularDynamics/molecule/molecule/moleculeIO.C b/src/lagrangian/molecularDynamics/molecule/molecule/moleculeIO.C index 0b7210327..c7829e695 100644 --- a/src/lagrangian/molecularDynamics/molecule/molecule/moleculeIO.C +++ b/src/lagrangian/molecularDynamics/molecule/molecule/moleculeIO.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -27,6 +27,14 @@ License #include "IOstreams.H" #include "moleculeCloud.H" +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +const std::size_t Foam::molecule::sizeofFields_ +( + offsetof(molecule, siteForces_) - offsetof(molecule, Q_) +); + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::molecule::molecule @@ -59,31 +67,17 @@ Foam::molecule::molecule is >> a_; is >> pi_; is >> tau_; - is >> siteForces_; + is >> specialPosition_; potentialEnergy_ = readScalar(is); is >> rf_; special_ = readLabel(is); id_ = readLabel(is); + is >> siteForces_; is >> sitePositions_; - is >> specialPosition_; } else { - is.read - ( - reinterpret_cast(&Q_), - sizeof(Q_) - + sizeof(v_) - + sizeof(a_) - + sizeof(pi_) - + sizeof(tau_) - + sizeof(specialPosition_) - + sizeof(potentialEnergy_) - + sizeof(rf_) - + sizeof(special_) - + sizeof(id_) - ); - + is.read(reinterpret_cast(&Q_), sizeofFields_); is >> siteForces_ >> sitePositions_; } } @@ -263,8 +257,6 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const molecule& mol) if (os.format() == IOstream::ASCII) { os << token::SPACE << static_cast(mol) - << token::SPACE << mol.face() - << token::SPACE << mol.stepFraction() << token::SPACE << mol.Q_ << token::SPACE << mol.v_ << token::SPACE << mol.a_ @@ -284,16 +276,7 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const molecule& mol) os.write ( reinterpret_cast(&mol.Q_), - sizeof(mol.Q_) - + sizeof(mol.v_) - + sizeof(mol.a_) - + sizeof(mol.pi_) - + sizeof(mol.tau_) - + sizeof(mol.specialPosition_) - + sizeof(mol.potentialEnergy_) - + sizeof(mol.rf_) - + sizeof(mol.special_) - + sizeof(mol.id_) + molecule::sizeofFields_ ); os << mol.siteForces_ << mol.sitePositions_; } diff --git a/src/lagrangian/solidParticle/solidParticle.H b/src/lagrangian/solidParticle/solidParticle.H index 7fdf17a9b..7bbd2dc33 100644 --- a/src/lagrangian/solidParticle/solidParticle.H +++ b/src/lagrangian/solidParticle/solidParticle.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -59,7 +59,10 @@ class solidParticle : public particle { - // Private member data + // Private data + + //- Size in bytes of the fields + static const std::size_t sizeofFields_; //- Diameter scalar d_; diff --git a/src/lagrangian/solidParticle/solidParticleIO.C b/src/lagrangian/solidParticle/solidParticleIO.C index f2f9cc899..fe50df977 100644 --- a/src/lagrangian/solidParticle/solidParticleIO.C +++ b/src/lagrangian/solidParticle/solidParticleIO.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -26,6 +26,14 @@ License #include "solidParticle.H" #include "IOstreams.H" +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +const std::size_t Foam::solidParticle::sizeofFields_ +( + sizeof(solidParticle) - sizeof(particle) +); + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::solidParticle::solidParticle @@ -46,11 +54,7 @@ Foam::solidParticle::solidParticle } else { - is.read - ( - reinterpret_cast(&d_), - sizeof(d_) + sizeof(U_) - ); + is.read(reinterpret_cast(&d_), sizeofFields_); } } @@ -126,7 +130,7 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const solidParticle& p) os.write ( reinterpret_cast(&p.d_), - sizeof(p.d_) + sizeof(p.U_) + solidParticle::sizeofFields_ ); } diff --git a/src/lagrangian/spray/parcels/Templates/SprayParcel/SprayParcel.H b/src/lagrangian/spray/parcels/Templates/SprayParcel/SprayParcel.H index ebd03f669..4e1fab22d 100644 --- a/src/lagrangian/spray/parcels/Templates/SprayParcel/SprayParcel.H +++ b/src/lagrangian/spray/parcels/Templates/SprayParcel/SprayParcel.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -59,6 +59,11 @@ class SprayParcel : public ParcelType { + // Private data + + //- Size in bytes of the fields + static const std::size_t sizeofFields_; + public: @@ -173,9 +178,6 @@ public: // Static data members - //- String representation of properties - static string propHeader; - //- Runtime type information TypeName("SprayParcel"); diff --git a/src/lagrangian/spray/parcels/Templates/SprayParcel/SprayParcelIO.C b/src/lagrangian/spray/parcels/Templates/SprayParcel/SprayParcelIO.C index 6708e73e7..7d85441b1 100644 --- a/src/lagrangian/spray/parcels/Templates/SprayParcel/SprayParcelIO.C +++ b/src/lagrangian/spray/parcels/Templates/SprayParcel/SprayParcelIO.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -29,21 +29,10 @@ License // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // template -Foam::string Foam::SprayParcel::propHeader = - ParcelType::propHeader - + " d0" - + " position0" - + " sigma" - + " mu" - + " liquidCore" - + " KHindex" - + " y" - + " yDot" - + " tc" - + " ms" - + " injector" - + " tMom" - + " user"; +const std::size_t Foam::SprayParcel::sizeofFields_ +( + sizeof(SprayParcel) - sizeof(ParcelType) +); // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -73,7 +62,6 @@ Foam::SprayParcel::SprayParcel { if (readFields) { - if (is.format() == IOstream::ASCII) { d0_ = readScalar(is); @@ -92,23 +80,7 @@ Foam::SprayParcel::SprayParcel } else { - is.read - ( - reinterpret_cast(&d0_), - sizeof(d0_) - + sizeof(position0_) - + sizeof(sigma_) - + sizeof(mu_) - + sizeof(liquidCore_) - + sizeof(KHindex_) - + sizeof(y_) - + sizeof(yDot_) - + sizeof(tc_) - + sizeof(ms_) - + sizeof(injector_) - + sizeof(tMom_) - + sizeof(user_) - ); + is.read(reinterpret_cast(&d0_), sizeofFields_); } } @@ -334,19 +306,7 @@ Foam::Ostream& Foam::operator<< os.write ( reinterpret_cast(&p.d0_), - sizeof(p.d0()) - + sizeof(p.position0()) - + sizeof(p.sigma()) - + sizeof(p.mu()) - + sizeof(p.liquidCore()) - + sizeof(p.KHindex()) - + sizeof(p.y()) - + sizeof(p.yDot()) - + sizeof(p.tc()) - + sizeof(p.ms()) - + sizeof(p.injector()) - + sizeof(p.tMom()) - + sizeof(p.user()) + SprayParcel::sizeofFields_ ); } diff --git a/src/postProcessing/functionObjects/field/wallBoundedStreamLine/wallBoundedParticle.C b/src/postProcessing/functionObjects/field/wallBoundedStreamLine/wallBoundedParticle.C index f4f8fd528..f9d1407c1 100644 --- a/src/postProcessing/functionObjects/field/wallBoundedStreamLine/wallBoundedParticle.C +++ b/src/postProcessing/functionObjects/field/wallBoundedStreamLine/wallBoundedParticle.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -24,88 +24,23 @@ License \*---------------------------------------------------------------------------*/ #include "wallBoundedParticle.H" -#include "vectorFieldIOField.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // -namespace Foam -{ -// defineParticleTypeNameAndDebug(wallBoundedParticle, 0); -} +const std::size_t Foam::wallBoundedParticle::sizeofFields_ +( + sizeof(wallBoundedParticle) - sizeof(particle) +); // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -//// Check position is inside tet -//void Foam::wallBoundedParticle::checkInside() const -//{ -// const tetIndices ti(currentTetIndices()); -// const tetPointRef tpr(ti.tet(mesh_)); -// if (!tpr.inside(position())) -// { -// FatalErrorIn("wallBoundedParticle::checkInside(..)") -// << "Particle:" //<< static_cast(*this) -// << info() -// << "is not inside " << tpr -// << abort(FatalError); -// } -//} -// -// -//void Foam::wallBoundedParticle::checkOnEdge() const -//{ -// // Check that edge (as indicated by meshEdgeStart_, diagEdge_) is -// // indeed one that contains the position. -// const edge e = currentEdge(); -// -// linePointRef ln(e.line(mesh_.points())); -// -// pointHit ph(ln.nearestDist(position())); -// -// if (ph.distance() > 1e-6) -// { -// FatalErrorIn -// ( -// "wallBoundedParticle::checkOnEdge()" -// ) << "Problem :" -// << " particle:" //<< static_cast(*this) -// << info() -// << "edge:" << e -// << " at:" << ln -// << " distance:" << ph.distance() -// << abort(FatalError); -// } -//} -// -// -//void Foam::wallBoundedParticle::checkOnTriangle(const point& p) -//const -//{ -// const triFace tri(currentTetIndices().faceTriIs(mesh_)); -// pointHit ph = tri.nearestPoint(p, mesh_.points()); -// if (ph.distance() > 1e-9) -// { -// FatalErrorIn -// ( -// "wallBoundedParticle::checkOnTriangle(const point&)" -// ) << "Problem :" -// << " particle:" //<< static_cast(*this) -// << info() -// << "point:" << p -// << " distance:" << ph.distance() -// << abort(FatalError); -// } -//} - - -// Construct the edge the particle is on (according to meshEdgeStart_, -// diagEdge_) Foam::edge Foam::wallBoundedParticle::currentEdge() const { if ((meshEdgeStart_ != -1) == (diagEdge_ != -1)) { FatalErrorIn("wallBoundedParticle::currentEdge() const") - << "Particle:" //<< static_cast(*this) + << "Particle:" << info() << "cannot both be on a mesh edge and a face-diagonal edge." << " meshEdgeStart_:" << meshEdgeStart_ @@ -123,6 +58,7 @@ Foam::edge Foam::wallBoundedParticle::currentEdge() const { label faceBasePtI = mesh_.tetBasePtIs()[tetFace()]; label diagPtI = (faceBasePtI+diagEdge_)%f.size(); + return edge(f[faceBasePtI], f[diagPtI]); } } @@ -133,15 +69,12 @@ void Foam::wallBoundedParticle::crossEdgeConnectedFace const edge& meshEdge ) { - //label oldFaceI = tetFace(); - // Update tetFace, tetPt particle::crossEdgeConnectedFace(cell(), tetFace(), tetPt(), meshEdge); // Update face to be same as tracking one face() = tetFace(); - // And adapt meshEdgeStart_. const Foam::face& f = mesh_.faces()[tetFace()]; label fp = findIndex(f, meshEdge[0]); @@ -165,7 +98,7 @@ void Foam::wallBoundedParticle::crossEdgeConnectedFace "wallBoundedParticle::crossEdgeConnectedFace" "(const edge&)" ) << "Problem :" - << " particle:" //<< static_cast(*this) + << " particle:" << info() << "face:" << tetFace() << " verts:" << f @@ -176,14 +109,7 @@ void Foam::wallBoundedParticle::crossEdgeConnectedFace diagEdge_ = -1; - //Pout<< " crossed meshEdge " - // << meshEdge.line(mesh().points()) - // << " from face:" << oldFaceI - // << " to face:" << tetFace() << endl; - - // Check that still on same mesh edge - const edge eNew(f[meshEdgeStart_], f.nextLabel(meshEdgeStart_)); if (eNew != meshEdge) { @@ -193,11 +119,6 @@ void Foam::wallBoundedParticle::crossEdgeConnectedFace "(const edge&)" ) << "Problem" << abort(FatalError); } - - - // Check that edge (as indicated by meshEdgeStart_) is indeed one that - // contains the position. - //checkOnEdge(); } @@ -206,20 +127,18 @@ void Foam::wallBoundedParticle::crossDiagonalEdge() if (diagEdge_ == -1) { FatalErrorIn("wallBoundedParticle::crossDiagonalEdge()") - << "Particle:" //<< static_cast(*this) + << "Particle:" << info() << "not on a diagonal edge" << abort(FatalError); } if (meshEdgeStart_ != -1) { FatalErrorIn("wallBoundedParticle::crossDiagonalEdge()") - << "Particle:" //<< static_cast(*this) + << "Particle:" << info() << "meshEdgeStart_:" << meshEdgeStart_ << abort(FatalError); } - //label oldTetPt = tetPt(); - const Foam::face& f = mesh_.faces()[tetFace()]; // tetPtI starts from 1, goes up to f.size()-2 @@ -238,7 +157,7 @@ void Foam::wallBoundedParticle::crossDiagonalEdge() else { FatalErrorIn("wallBoundedParticle::crossDiagonalEdge()") - << "Particle:" //<< static_cast(*this) + << "Particle:" << info() << "tetPt:" << tetPt() << " diagEdge:" << diagEdge_ << abort(FatalError); @@ -246,17 +165,9 @@ void Foam::wallBoundedParticle::crossDiagonalEdge() } meshEdgeStart_ = -1; - - //Pout<< " crossed diagonalEdge " - // << currentEdge().line(mesh().points()) - // << " from tetPt:" << oldTetPt - // << " to tetPt:" << tetPt() << endl; } -//- Track through a single triangle. -// Gets passed tet+triangle the particle is in. Updates position() but nothing -// else. Returns the triangle edge the particle is now on. Foam::scalar Foam::wallBoundedParticle::trackFaceTri ( const vector& endPosition, @@ -266,14 +177,6 @@ Foam::scalar Foam::wallBoundedParticle::trackFaceTri // Track p from position to endPosition const triFace tri(currentTetIndices().faceTriIs(mesh_)); vector n = tri.normal(mesh_.points()); - //if (mag(n) < sqr(SMALL)) - //{ - // FatalErrorIn("wallBoundedParticle::trackFaceTri(..)") - // << "Small triangle." //<< static_cast(*this) - // << info() - // << "n:" << n - // << abort(FatalError); - //} n /= mag(n)+VSMALL; // Check which edge intersects the trajectory. @@ -281,9 +184,6 @@ Foam::scalar Foam::wallBoundedParticle::trackFaceTri minEdgeI = -1; scalar minS = 1; // end position - //const point oldPosition(position()); - - edge currentE(-1, -1); if (meshEdgeStart_ != -1 || diagEdge_ != -1) { @@ -309,21 +209,6 @@ Foam::scalar Foam::wallBoundedParticle::trackFaceTri // Outwards pointing normal vector edgeNormal = (pt1-pt0)^n; - //if (mag(edgeNormal) < SMALL) - //{ - // FatalErrorIn("wallBoundedParticle::trackFaceTri(..)") - // << "Edge not perpendicular to triangle." - // //<< static_cast(*this) - // << info() - // << "triangle n:" << n - // << " edgeNormal:" << edgeNormal - // << " on tri:" << tri - // << " at:" << pt0 - // << " at:" << pt1 - // << abort(FatalError); - //} - - edgeNormal /= mag(edgeNormal)+VSMALL; // Determine whether position and end point on either side of edge. @@ -362,25 +247,10 @@ Foam::scalar Foam::wallBoundedParticle::trackFaceTri const point& triPt = mesh_.points()[tri[0]]; position() -= ((position()-triPt)&n)*n; - - //Pout<< " tracked from:" << oldPosition << " to:" << position() - // << " projectedEnd:" << endPosition - // << " at s:" << minS << endl; - //if (minEdgeI != -1) - //{ - // Pout<< " on edge:" << minEdgeI - // << " on edge:" - // << mesh_.points()[tri[minEdgeI]] - // << mesh_.points()[tri[tri.fcIndex(minEdgeI)]] - // << endl; - //} - return minS; } -// See if the current triangle has got a point on the -// correct side of the edge. bool Foam::wallBoundedParticle::isTriAlongTrack ( const point& endPosition @@ -454,18 +324,7 @@ Foam::wallBoundedParticle::wallBoundedParticle particle(mesh, position, cellI, tetFaceI, tetPtI), meshEdgeStart_(meshEdgeStart), diagEdge_(diagEdge) -{ - //checkInside(); - - //if (meshEdgeStart_ != -1 || diagEdge_ != -1) - //{ - // checkOnEdge(); - //} - - // Unfortunately have no access to trackdata so cannot check if particle - // is on a wallPatch or has an mesh edge set (either of which is - // a requirement). -} +{} Foam::wallBoundedParticle::wallBoundedParticle @@ -514,46 +373,6 @@ Foam::wallBoundedParticle::wallBoundedParticle {} -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -void Foam::wallBoundedParticle::write(Ostream& os, bool writeFields) const -{ - const particle& p = static_cast(*this); - - if (os.format() == IOstream::ASCII) - { - // Write base particle - p.write(os, writeFields); - - if (writeFields) - { - // Write the additional entries - os << token::SPACE << meshEdgeStart_ - << token::SPACE << diagEdge_; - } - } - else - { - // Write base particle - p.write(os, writeFields); - - // Write additional entries - if (writeFields) - { - os.write - ( - reinterpret_cast(&meshEdgeStart_), - sizeof(meshEdgeStart_) - + sizeof(diagEdge_) - ); - } - } - - // Check state of Ostream - os.check("wallBoundedParticle::write(Ostream& os, bool) const"); -} - - // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // Foam::Ostream& Foam::operator<< @@ -562,8 +381,21 @@ Foam::Ostream& Foam::operator<< const wallBoundedParticle& p ) { - // Write all data - p.write(os, true); + if (os.format() == IOstream::ASCII) + { + os << static_cast(p) + << token::SPACE << p.meshEdgeStart_ + << token::SPACE << p.diagEdge_; + } + else + { + os << static_cast(p); + os.write + ( + reinterpret_cast(&p.meshEdgeStart_), + wallBoundedParticle::sizeofFields_ + ); + } return os; } @@ -602,5 +434,4 @@ Foam::Ostream& Foam::operator<< } - // ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/wallBoundedStreamLine/wallBoundedParticle.H b/src/postProcessing/functionObjects/field/wallBoundedStreamLine/wallBoundedParticle.H index 55ba6c27f..0054ec2bb 100644 --- a/src/postProcessing/functionObjects/field/wallBoundedStreamLine/wallBoundedParticle.H +++ b/src/postProcessing/functionObjects/field/wallBoundedStreamLine/wallBoundedParticle.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -54,6 +54,11 @@ class wallBoundedParticle : public particle { + // Private data + + //- Size in bytes of the fields + static const std::size_t sizeofFields_; + public: @@ -317,9 +322,6 @@ public: template static void writeFields(const CloudType&); - //- Write the particle data - void write(Ostream& os, bool writeFields) const; - // Ostream Operator