diff --git a/applications/utilities/parallelProcessing/redistributePar/Make/files b/applications/utilities/parallelProcessing/redistributePar/Make/files index 1dfb53f3078d8ccc1cac85efabd4c377b6451fef..3447baa3d827dac259a561af26c9b1b35024cb1a 100644 --- a/applications/utilities/parallelProcessing/redistributePar/Make/files +++ b/applications/utilities/parallelProcessing/redistributePar/Make/files @@ -1,3 +1,4 @@ +passivePositionParticleCloud.C parLagrangianRedistributor.C parFvFieldReconstructor.C loadOrCreateMesh.C diff --git a/applications/utilities/parallelProcessing/redistributePar/parLagrangianRedistributor.C b/applications/utilities/parallelProcessing/redistributePar/parLagrangianRedistributor.C index 73cfda6582ef52e7fa148ffc376e4972f1f0ba17..e35562b6951ca0d561a53aaecd5a27865d553611 100644 --- a/applications/utilities/parallelProcessing/redistributePar/parLagrangianRedistributor.C +++ b/applications/utilities/parallelProcessing/redistributePar/parLagrangianRedistributor.C @@ -25,7 +25,7 @@ License #include "ListOps.H" #include "parLagrangianRedistributor.H" -#include "passiveParticleCloud.H" +#include "passivePositionParticleCloud.H" // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -133,7 +133,7 @@ void Foam::parLagrangianRedistributor::findClouds Foam::autoPtr<Foam::mapDistributeBase> Foam::parLagrangianRedistributor::redistributeLagrangianPositions ( - passiveParticleCloud& lpi + passivePositionParticleCloud& lpi ) const { //Debug(lpi.size()); @@ -147,7 +147,7 @@ Foam::parLagrangianRedistributor::redistributeLagrangianPositions { // List of lists of particles to be transferred for all of the // neighbour processors - List<IDLList<passiveParticle>> particleTransferLists + List<IDLList<passivePositionParticle>> particleTransferLists ( Pstream::nProcs() ); @@ -156,17 +156,15 @@ Foam::parLagrangianRedistributor::redistributeLagrangianPositions labelList destProc(lpi.size()); label particleI = 0; - forAllIter(passiveParticleCloud, lpi, iter) + forAllIter(passivePositionParticleCloud, lpi, iter) { - passiveParticle& ppi = iter(); + passivePositionParticle& ppi = iter(); label destProcI = destinationProcID_[ppi.cell()]; label destCellI = destinationCell_[ppi.cell()]; ppi.cell() = destCellI; destProc[particleI++] = destProcI; - //Pout<< "Sending particle:" << ppi << " to processor " << destProcI - // << " to cell " << destCellI << endl; particleTransferLists[destProcI].append(lpi.remove(&ppi)); } @@ -202,11 +200,11 @@ Foam::parLagrangianRedistributor::redistributeLagrangianPositions lpi.rename(cloudName + "_old"); // New cloud on tgtMesh - passiveParticleCloud lagrangianPositions + passivePositionParticleCloud lagrangianPositions ( tgtMesh_, cloudName, - IDLList<passiveParticle>() + IDLList<passivePositionParticle>() ); @@ -222,32 +220,28 @@ Foam::parLagrangianRedistributor::redistributeLagrangianPositions { UIPstream particleStream(procI, pBufs); - IDLList<passiveParticle> newParticles + // Receive particles and locate them + IDLList<passivePositionParticle> newParticles ( particleStream, - passiveParticle::iNew(tgtMesh_) + passivePositionParticle::iNew(tgtMesh_) ); forAllIter ( - IDLList<passiveParticle>, + IDLList<passivePositionParticle>, newParticles, newpIter ) { - passiveParticle& newp = newpIter(); - newp.relocate(); - + passivePositionParticle& newp = newpIter(); lagrangianPositions.addParticle(newParticles.remove(&newp)); } } } - //OFstream::debug = 1; - //Debug(lagrangianPositions.size()); - IOPosition<passiveParticleCloud>(lagrangianPositions).write(); - //OFstream::debug = 0; + IOPosition<passivePositionParticleCloud>(lagrangianPositions).write(); // Restore cloud name lpi.rename(cloudName); @@ -300,7 +294,7 @@ Foam::parLagrangianRedistributor::redistributeLagrangianPositions ) const { // Load cloud and send particle - passiveParticleCloud lpi(srcMesh_, cloudName, false); + passivePositionParticleCloud lpi(srcMesh_, cloudName, false); return redistributeLagrangianPositions(lpi); } diff --git a/applications/utilities/parallelProcessing/redistributePar/parLagrangianRedistributor.H b/applications/utilities/parallelProcessing/redistributePar/parLagrangianRedistributor.H index 411864ebf1d8fe48bca407fd7cc9fb9ca8604028..f7d1c226cb3d9c520da2cc49c05414ae02bb9a2b 100644 --- a/applications/utilities/parallelProcessing/redistributePar/parLagrangianRedistributor.H +++ b/applications/utilities/parallelProcessing/redistributePar/parLagrangianRedistributor.H @@ -49,7 +49,7 @@ namespace Foam class mapDistributePolyMesh; class mapDistributeBase; class IOobjectList; -class passiveParticleCloud; +class passivePositionParticleCloud; /*---------------------------------------------------------------------------*\ Class parLagrangianRedistributor Declaration @@ -112,7 +112,7 @@ public: //- Redistribute and write lagrangian positions autoPtr<mapDistributeBase> redistributeLagrangianPositions ( - passiveParticleCloud& cloud + passivePositionParticleCloud& cloud ) const; //- Read, redistribute and write lagrangian positions @@ -153,7 +153,7 @@ public: template<class Container> static void readLagrangianFields ( - const passiveParticleCloud& cloud, + const passivePositionParticleCloud& cloud, const IOobjectList& objects, const HashSet<word>& selectedFields ); @@ -163,7 +163,7 @@ public: void redistributeStoredLagrangianFields ( const mapDistributeBase& map, - passiveParticleCloud& cloud + passivePositionParticleCloud& cloud ) const; }; diff --git a/applications/utilities/parallelProcessing/redistributePar/parLagrangianRedistributorRedistributeFields.C b/applications/utilities/parallelProcessing/redistributePar/parLagrangianRedistributorRedistributeFields.C index 1eca70bd1eb2bc2aff2146a334dc56af627ff193..c53514fc83ed8d83cfa71eba6e3348dfac00b7bd 100644 --- a/applications/utilities/parallelProcessing/redistributePar/parLagrangianRedistributorRedistributeFields.C +++ b/applications/utilities/parallelProcessing/redistributePar/parLagrangianRedistributorRedistributeFields.C @@ -29,7 +29,7 @@ License #include "mapDistributePolyMesh.H" #include "cloud.H" #include "CompactIOField.H" -#include "passiveParticleCloud.H" +#include "passivePositionParticleCloud.H" // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // @@ -223,7 +223,7 @@ void Foam::parLagrangianRedistributor::redistributeLagrangianFieldFields template<class Container> void Foam::parLagrangianRedistributor::readLagrangianFields ( - const passiveParticleCloud& cloud, + const passivePositionParticleCloud& cloud, const IOobjectList& objects, const HashSet<word>& selectedFields ) @@ -272,7 +272,7 @@ template<class Container> void Foam::parLagrangianRedistributor::redistributeStoredLagrangianFields ( const mapDistributeBase& map, - passiveParticleCloud& cloud + passivePositionParticleCloud& cloud ) const { HashTable<Container*> fields diff --git a/applications/utilities/parallelProcessing/redistributePar/passivePositionParticle.H b/applications/utilities/parallelProcessing/redistributePar/passivePositionParticle.H new file mode 100644 index 0000000000000000000000000000000000000000..41cc7c16edd433e6945bb60977f09b57eba72432 --- /dev/null +++ b/applications/utilities/parallelProcessing/redistributePar/passivePositionParticle.H @@ -0,0 +1,183 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. + +Class + Foam::passivePositionParticle + +Description + Passive particle, transferring in old format (i.e. position instead of + coordinates). Used for e.g. redistributePar. + +SourceFiles + passivePositionParticle.H + +\*---------------------------------------------------------------------------*/ + +#ifndef passivePositionParticle_H +#define passivePositionParticle_H + +#include "passiveParticle.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class passivePositionParticle Declaration +\*---------------------------------------------------------------------------*/ + +class passivePositionParticle +: + public passiveParticle +{ + // Private member data + + //- Cached position + point position_; + + +public: + + // Constructors + + //- Construct from Istream in old format + passivePositionParticle + ( + const polyMesh& mesh, + Istream& is, + bool readFields, + bool newFormat + ) + : + passiveParticle(mesh, is, readFields, newFormat), + position_(position()) + {} + + //- Construct as copy + passivePositionParticle(const passivePositionParticle& p) + : + passiveParticle(p), + position_(p.position_) + {} + + //- Construct and return a clone + virtual autoPtr<particle> clone() const + { + return autoPtr<particle>(new passivePositionParticle(*this)); + } + + + //- Factory class to read-construct particles used for + // parallel transfer + class iNew + { + const polyMesh& mesh_; + + public: + + iNew(const polyMesh& mesh) + : + mesh_(mesh) + {} + + autoPtr<passivePositionParticle> operator()(Istream& is) const + { + return autoPtr<passivePositionParticle> + ( + // Read in old format + new passivePositionParticle(mesh_, is, true, false) + ); + } + }; + + + // Friend Operators + + friend Ostream& operator<< + ( + Ostream& os, + const passivePositionParticle& ppi + ) + { + // Copy data into old format structure. Exact opposite of + // particleIO.C reading old format. + struct oldParticle + { + vector position; + label celli; + label facei; + scalar stepFraction; + label tetFacei; + label tetPti; + label origProc; + label origId; + } p; + + p.position = ppi.position_; + p.celli = ppi.cell(); + p.facei = ppi.face(); + p.stepFraction = ppi.stepFraction(); + p.tetFacei = ppi.tetFace(); + p.tetPti = ppi.tetPt(); + p.origProc = ppi.origProc(); + p.origId = ppi.origId(); + + 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 + { + const std::size_t sizeofFields + ( + sizeof(oldParticle) - offsetof(oldParticle, position) + ); + + os.write + ( + reinterpret_cast<const char*>(&p.position), + sizeofFields + ); + } + return os; + } +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/utilities/parallelProcessing/redistributePar/passivePositionParticleCloud.C b/applications/utilities/parallelProcessing/redistributePar/passivePositionParticleCloud.C new file mode 100644 index 0000000000000000000000000000000000000000..edd5c3916f3076a74e9c06f77ee97d754aa4132c --- /dev/null +++ b/applications/utilities/parallelProcessing/redistributePar/passivePositionParticleCloud.C @@ -0,0 +1,64 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "passivePositionParticleCloud.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTemplateTypeNameAndDebug(Cloud<passivePositionParticle>, 0); +} + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::passivePositionParticleCloud::passivePositionParticleCloud +( + const polyMesh& mesh, + const word& cloudName, + bool readFields +) +: + Cloud<passivePositionParticle>(mesh, cloudName, false) +{ + if (readFields) + { + passivePositionParticle::readFields(*this); + } +} + + +Foam::passivePositionParticleCloud::passivePositionParticleCloud +( + const polyMesh& mesh, + const word& cloudName, + const IDLList<passivePositionParticle>& particles +) +: + Cloud<passivePositionParticle>(mesh, cloudName, particles) +{} + + +// ************************************************************************* // diff --git a/applications/utilities/parallelProcessing/redistributePar/passivePositionParticleCloud.H b/applications/utilities/parallelProcessing/redistributePar/passivePositionParticleCloud.H new file mode 100644 index 0000000000000000000000000000000000000000..f9a91d0f4265bd0f5b1d79200228ed3d1caf235d --- /dev/null +++ b/applications/utilities/parallelProcessing/redistributePar/passivePositionParticleCloud.H @@ -0,0 +1,93 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. + +Class + Foam::passivePositionParticleCloud + +Description + A Cloud of passive position particles + +SourceFiles + passivePositionParticleCloud.C + +\*---------------------------------------------------------------------------*/ + +#ifndef passivePositionParticleCloud_H +#define passivePositionParticleCloud_H + +#include "Cloud.H" +#include "passivePositionParticle.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class passivePositionParticleCloud Declaration +\*---------------------------------------------------------------------------*/ + +class passivePositionParticleCloud +: + public Cloud<passivePositionParticle> +{ + // Private Member Functions + + //- Disallow default bitwise copy construct + passivePositionParticleCloud(const passivePositionParticleCloud&); + + //- Disallow default bitwise assignment + void operator=(const passivePositionParticleCloud&); + + +public: + + // Constructors + + //- Construct given mesh + passivePositionParticleCloud + ( + const polyMesh&, + const word& cloudName = "defaultCloud", + bool readFields = true + ); + + //- Construct from mesh, cloud name, and a list of particles + passivePositionParticleCloud + ( + const polyMesh& mesh, + const word& cloudName, + const IDLList<passivePositionParticle>& particles + ); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/utilities/parallelProcessing/redistributePar/redistributePar.C b/applications/utilities/parallelProcessing/redistributePar/redistributePar.C index 798d91bf102c2e02e7e1847f084e594a78018ba7..ca116ce38e54a0904cb9b6850c680c7cbb17a588 100644 --- a/applications/utilities/parallelProcessing/redistributePar/redistributePar.C +++ b/applications/utilities/parallelProcessing/redistributePar/redistributePar.C @@ -80,7 +80,7 @@ Usage #include "parFvFieldReconstructor.H" #include "parLagrangianRedistributor.H" -#include "unmappedPassiveParticleCloud.H" +#include "unmappedPassivePositionParticleCloud.H" #include "hexRef8Data.H" #include "meshRefinement.H" #include "pointFields.H" @@ -1908,7 +1908,7 @@ void readLagrangian const fvMesh& mesh, const wordList& cloudNames, const HashSet<word>& selectedLagrangianFields, - PtrList<unmappedPassiveParticleCloud>& clouds + PtrList<unmappedPassivePositionParticleCloud>& clouds ) { (void)mesh.tetBasePtIs(); @@ -1919,13 +1919,13 @@ void readLagrangian clouds.set ( i, - new unmappedPassiveParticleCloud(mesh, cloudNames[i], false) + new unmappedPassivePositionParticleCloud(mesh, cloudNames[i], false) ); //forAllConstIter //( - // unmappedPassiveParticleCloud, + // unmappedPassivePositionParticleCloud, // clouds[i], // iter //) @@ -2087,7 +2087,7 @@ void redistributeLagrangian const fvMesh& mesh, const label nOldCells, const mapDistributePolyMesh& distMap, - PtrList<unmappedPassiveParticleCloud>& clouds + PtrList<unmappedPassivePositionParticleCloud>& clouds ) { if (clouds.size()) @@ -2958,7 +2958,7 @@ int main(int argc, char *argv[]) ); // Read lagrangian fields and store on cloud (objectRegistry) - PtrList<unmappedPassiveParticleCloud> clouds(cloudNames.size()); + PtrList<unmappedPassivePositionParticleCloud> clouds(cloudNames.size()); readLagrangian ( mesh, diff --git a/applications/utilities/parallelProcessing/redistributePar/unmappedPassiveParticleCloud.H b/applications/utilities/parallelProcessing/redistributePar/unmappedPassivePositionParticleCloud.H similarity index 77% rename from applications/utilities/parallelProcessing/redistributePar/unmappedPassiveParticleCloud.H rename to applications/utilities/parallelProcessing/redistributePar/unmappedPassivePositionParticleCloud.H index c1b6d6a208151f1c9c28cb28791b1e21309dbecc..c036ac2114430ccfd4cf04265f948e86d2cd77fb 100644 --- a/applications/utilities/parallelProcessing/redistributePar/unmappedPassiveParticleCloud.H +++ b/applications/utilities/parallelProcessing/redistributePar/unmappedPassivePositionParticleCloud.H @@ -22,21 +22,21 @@ License along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. Class - Foam::unmappedPassiveParticleCloud + Foam::unmappedPassivePositionParticleCloud Description - passiveParticleCloud but with autoMap and writing disabled. Only used - for its objectRegistry to store lagrangian fields + passivePositionParticleCloud but with autoMap and writing disabled. + Only used for its objectRegistry to store lagrangian fields SourceFiles - unmappedPassiveParticleCloud.C + unmappedPassivePositionParticleCloud.C \*---------------------------------------------------------------------------*/ -#ifndef unmappedPassiveParticleCloud_H -#define unmappedPassiveParticleCloud_H +#ifndef unmappedPassivePositionParticleCloud_H +#define unmappedPassivePositionParticleCloud_H -#include "passiveParticleCloud.H" +#include "passivePositionParticleCloud.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -47,9 +47,9 @@ namespace Foam Class unmappedPassiveParticleCloud Declaration \*---------------------------------------------------------------------------*/ -class unmappedPassiveParticleCloud +class unmappedPassivePositionParticleCloud : - public passiveParticleCloud + public passivePositionParticleCloud { public: @@ -57,29 +57,29 @@ public: // Constructors //- Construct given mesh - unmappedPassiveParticleCloud + unmappedPassivePositionParticleCloud ( const polyMesh& mesh, const word& cloudName = "defaultCloud", bool readFields = true ) : - passiveParticleCloud(mesh, cloudName, readFields) + passivePositionParticleCloud(mesh, cloudName, readFields) {} //- Construct from mesh, cloud name, and a list of particles - unmappedPassiveParticleCloud + unmappedPassivePositionParticleCloud ( const polyMesh& mesh, const word& cloudName, - const IDLList<passiveParticle>& particles + const IDLList<passivePositionParticle>& particles ) : - passiveParticleCloud(mesh, cloudName, particles) + passivePositionParticleCloud(mesh, cloudName, particles) {} //- Destructor - virtual ~unmappedPassiveParticleCloud() + virtual ~unmappedPassivePositionParticleCloud() {} //- Switch off remapping of cells of particles when @@ -98,7 +98,6 @@ public: { return true; } - }; diff --git a/src/lagrangian/basic/particle/particle.C b/src/lagrangian/basic/particle/particle.C index 904f4c5723549c1bddc67d9a39473750b095a04f..9725ba4358b63aea28a4f9b8be2e3550541b3562 100644 --- a/src/lagrangian/basic/particle/particle.C +++ b/src/lagrangian/basic/particle/particle.C @@ -512,7 +512,10 @@ void Foam::particle::locate // We hit a boundary ... if (boundaryFail) { - FatalErrorInFunction << boundaryMsg << exit(FatalError); + FatalErrorInFunction << boundaryMsg + << " when tracking from centre " << mesh_.cellCentres()[celli_] + << " of cell " << celli_ << " to position " << position + << exit(FatalError); } else { @@ -1210,11 +1213,11 @@ void Foam::particle::autoMap } -void Foam::particle::relocate() +void Foam::particle::relocate(const point& position) { locate ( - position(), + position, nullptr, celli_, true, diff --git a/src/lagrangian/basic/particle/particle.H b/src/lagrangian/basic/particle/particle.H index 67c4dc393d1ae392e756e27053b1114ef87aece4..50e7e2755edded32326c4a2019b3ba92210c8afd 100644 --- a/src/lagrangian/basic/particle/particle.H +++ b/src/lagrangian/basic/particle/particle.H @@ -662,9 +662,9 @@ public: //- Map after a topology change void autoMap(const vector& position, const mapPolyMesh& mapper); - //- Set the addressing based on the current position and cell + //- Set the addressing based on the provided position and current cell // Used for e.g. redistributePar - void relocate(); + void relocate(const point& position); // I-O diff --git a/src/lagrangian/basic/particle/particleIO.C b/src/lagrangian/basic/particle/particleIO.C index 15ab90ff9e85e111591bcdd717d37314ba4a95b8..5ed13963da66da0d6dba2d15f95fb847ba1aa6c4 100644 --- a/src/lagrangian/basic/particle/particleIO.C +++ b/src/lagrangian/basic/particle/particleIO.C @@ -114,17 +114,20 @@ Foam::particle::particle } else { - const size_t s = - offsetof(oldParticle, facei) - offsetof(oldParticle, position); - - is.read(reinterpret_cast<char*>(&p.position), s); - if (readFields) { + // Read whole struct const size_t s = - sizeof(oldParticle) - offsetof(oldParticle, facei); - - is.read(reinterpret_cast<char*>(&p.facei), s); + sizeof(oldParticle) - offsetof(oldParticle, position); + is.read(reinterpret_cast<char*>(&p.position), s); + } + else + { + // Read only position and cell + const size_t s = + offsetof(oldParticle, facei) + - offsetof(oldParticle, position); + is.read(reinterpret_cast<char*>(&p.position), s); } }