From 5309f35f11d7f68391d6e55f25794d28ea42f222 Mon Sep 17 00:00:00 2001 From: andy Date: Mon, 22 Jun 2009 11:52:36 +0100 Subject: [PATCH 01/16] cosmetics --- src/OpenFOAM/fields/cloud/cloud.H | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/OpenFOAM/fields/cloud/cloud.H b/src/OpenFOAM/fields/cloud/cloud.H index 0c0915464e..d48e5dffbb 100644 --- a/src/OpenFOAM/fields/cloud/cloud.H +++ b/src/OpenFOAM/fields/cloud/cloud.H @@ -75,15 +75,15 @@ public: //- The default cloud name: %defaultCloud static word defaultName; + // Constructors //- Construct for the given objectRegistry and named cloud instance cloud(const objectRegistry&, const word& cloudName = ""); - // Destructor - - virtual ~cloud(); + //- Destructor + virtual ~cloud(); // Member Functions From 1083147aa1bad0354cc18e9e580dcf17a1f011fd Mon Sep 17 00:00:00 2001 From: andy Date: Mon, 22 Jun 2009 11:53:21 +0100 Subject: [PATCH 02/16] added proc-local id and orig proc id to particle base class --- src/lagrangian/basic/IOPosition/IOPosition.C | 73 +++++++++++++++++- src/lagrangian/basic/IOPosition/IOPosition.H | 36 +++++---- src/lagrangian/basic/Particle/Particle.C | 16 +++- src/lagrangian/basic/Particle/Particle.H | 19 ++++- src/lagrangian/basic/Particle/ParticleI.H | 80 +++++++++++--------- src/lagrangian/basic/Particle/ParticleIO.C | 33 +++++--- 6 files changed, 190 insertions(+), 67 deletions(-) diff --git a/src/lagrangian/basic/IOPosition/IOPosition.C b/src/lagrangian/basic/IOPosition/IOPosition.C index 7865a12105..810a9fbcf5 100644 --- a/src/lagrangian/basic/IOPosition/IOPosition.C +++ b/src/lagrangian/basic/IOPosition/IOPosition.C @@ -22,12 +22,77 @@ License along with OpenFOAM; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -Description - \*---------------------------------------------------------------------------*/ #include "IOPosition.H" +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +template +Foam::word Foam::IOPosition::particlePropertiesName +( + "particleProperties" +); + +// * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * * // + +template +void Foam::IOPosition::readParticleProperties() +{ + IOobject propsDictHeader + ( + particlePropertiesName, + cloud_.db().time().timeName(), + "uniform"/cloud::prefix/cloud_.name(), + cloud_.db(), + IOobject::MUST_READ, + IOobject::NO_WRITE, + false + ); + + if (propsDictHeader.headerOk()) + { + const IOdictionary propsDict(propsDictHeader); + + word procName("processor" + Foam::name(Pstream::myProcNo())); + if (propsDict.found(procName)) + { + propsDict.subDict(procName).lookup("particleCount") + >> Particle::particleCount; + } + } +} + + +template +void Foam::IOPosition::writeParticleProperties() const +{ + IOdictionary propsDict + ( + IOobject + ( + particlePropertiesName, + cloud_.db().time().timeName(), + "uniform"/cloud::prefix/cloud_.name(), + cloud_.db(), + IOobject::NO_READ, + IOobject::NO_WRITE, + false + ) + ); + + word procName("processor" + Foam::name(Pstream::myProcNo())); + propsDict.add(procName, dictionary()); + propsDict.subDict(procName).add + ( + "particleCount", + Particle::particleCount + ); + + propsDict.regIOobject::write(); +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template @@ -70,6 +135,8 @@ bool Foam::IOPosition::write() const template bool Foam::IOPosition::writeData(Ostream& os) const { + writeParticleProperties(); + os<< cloud_.size() << nl << token::BEGIN_LIST << nl; forAllConstIter(typename Cloud, cloud_, iter) @@ -90,6 +157,8 @@ void Foam::IOPosition::readData bool checkClass ) { + readParticleProperties(); + Istream& is = readStream(checkClass ? typeName : ""); token firstToken(is); diff --git a/src/lagrangian/basic/IOPosition/IOPosition.H b/src/lagrangian/basic/IOPosition/IOPosition.H index 5123644385..069dc0135d 100644 --- a/src/lagrangian/basic/IOPosition/IOPosition.H +++ b/src/lagrangian/basic/IOPosition/IOPosition.H @@ -59,30 +59,38 @@ class IOPosition const Cloud& cloud_; + // Private member functions + + //- Read particle properties dictionary + void readParticleProperties(); + + //- Write particle properties dictionary + void writeParticleProperties() const; + + public: - //- Runtime type name information - virtual const word& type() const - { - return cloud_.type(); - } + // Static data + + //- Runtime type name information + virtual const word& type() const + { + return cloud_.type(); + } + + //- Name of particle properties dictionary + static word particlePropertiesName; + // Constructors //- Construct from cloud - IOPosition - ( - const Cloud& - ); + IOPosition(const Cloud&); // Member functions - void readData - ( - Cloud& c, - bool checkClass - ); + void readData(Cloud& c, bool checkClass); bool write() const; diff --git a/src/lagrangian/basic/Particle/Particle.C b/src/lagrangian/basic/Particle/Particle.C index ee85abda68..4b51b88a45 100644 --- a/src/lagrangian/basic/Particle/Particle.C +++ b/src/lagrangian/basic/Particle/Particle.C @@ -33,6 +33,12 @@ License #include "wallPolyPatch.H" #include "transform.H" +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +template +Foam::label Foam::Particle::particleCount = 0; + + // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // template @@ -69,7 +75,7 @@ void Foam::Particle::findFaces DynamicList