diff --git a/src/OpenFOAM/fields/cloud/cloud.C b/src/OpenFOAM/fields/cloud/cloud.C index 69cba912e0..172d6aac74 100644 --- a/src/OpenFOAM/fields/cloud/cloud.C +++ b/src/OpenFOAM/fields/cloud/cloud.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. @@ -36,7 +36,6 @@ namespace Foam word cloud::defaultName("defaultCloud"); } - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::cloud::cloud(const objectRegistry& obr, const word& cloudName) @@ -70,4 +69,10 @@ void Foam::cloud::autoMap(const mapPolyMesh&) } +void Foam::cloud::writeObjects(objectRegistry& obr) const +{ + NotImplemented; +} + + // ************************************************************************* // diff --git a/src/OpenFOAM/fields/cloud/cloud.H b/src/OpenFOAM/fields/cloud/cloud.H index 9b7aa43291..844cb9db4e 100644 --- a/src/OpenFOAM/fields/cloud/cloud.H +++ b/src/OpenFOAM/fields/cloud/cloud.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. @@ -36,6 +36,7 @@ SourceFiles #define cloud_H #include "objectRegistry.H" +#include "IOField.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -92,6 +93,24 @@ public: //- Remap the cells of particles corresponding to the // mesh topology change virtual void autoMap(const mapPolyMesh&); + + + // I-O + + //- Read particle fields from objects in the obr registry + //virtual void readObjects(objectRegistry& obr); + + //- Write particle fields as objects into the obr registry + virtual void writeObjects(objectRegistry& obr) const; + + //- Helper to construct IOField on a supplied object registry + template + static IOField& createIOField + ( + const word& fieldName, + const label nParticle, + objectRegistry& obr + ); }; @@ -101,6 +120,12 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +#ifdef NoRepository + #include "cloudTemplates.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + #endif // ************************************************************************* // diff --git a/src/OpenFOAM/fields/cloud/cloudTemplates.C b/src/OpenFOAM/fields/cloud/cloudTemplates.C new file mode 100644 index 0000000000..1b5b2ee8b2 --- /dev/null +++ b/src/OpenFOAM/fields/cloud/cloudTemplates.C @@ -0,0 +1,60 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2016 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "Time.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +template +Foam::IOField& Foam::cloud::createIOField +( + const word& fieldName, + const label nParticle, + objectRegistry& obr +) +{ + IOField* fieldPtr + ( + new IOField + ( + IOobject + ( + fieldName, + obr.time().timeName(), + obr, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + nParticle + ) + ); + + fieldPtr->store(); + + return *fieldPtr; +} + + +// ************************************************************************* // diff --git a/src/lagrangian/basic/particle/particle.H b/src/lagrangian/basic/particle/particle.H index 9f0856e4fa..d94db0dd56 100644 --- a/src/lagrangian/basic/particle/particle.H +++ b/src/lagrangian/basic/particle/particle.H @@ -574,6 +574,10 @@ public: template static void writeFields(const CloudType& c); + //- Write particle fields as objects into the obr registry + template + static void writeObjects(const CloudType& c, objectRegistry& obr); + //- Write the particle position and cell void writePosition(Ostream&) const; diff --git a/src/lagrangian/basic/particle/particleTemplates.C b/src/lagrangian/basic/particle/particleTemplates.C index aa84ad9084..95f018665c 100644 --- a/src/lagrangian/basic/particle/particleTemplates.C +++ b/src/lagrangian/basic/particle/particleTemplates.C @@ -162,7 +162,7 @@ void Foam::particle::writeFields(const CloudType& c) IOPosition ioP(c); ioP.write(); - label np = c.size(); + label np = c.size(); IOField