diff --git a/applications/utilities/parallelProcessing/redistributePar/passivePositionParticle.H b/applications/utilities/parallelProcessing/redistributePar/passivePositionParticle.H index 41cc7c16ed..76e8084b80 100644 --- a/applications/utilities/parallelProcessing/redistributePar/passivePositionParticle.H +++ b/applications/utilities/parallelProcessing/redistributePar/passivePositionParticle.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2017 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2017-2018 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -122,17 +122,7 @@ public: { // 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; + particle::positionsCompat1706 p; p.position = ppi.position_; p.celli = ppi.cell(); @@ -158,7 +148,8 @@ public: { const std::size_t sizeofFields ( - sizeof(oldParticle) - offsetof(oldParticle, position) + sizeof(particle::positionsCompat1706) + - offsetof(particle::positionsCompat1706, position) ); os.write diff --git a/src/lagrangian/basic/IOPosition/IOPosition.C b/src/lagrangian/basic/IOPosition/IOPosition.C index 69eeca2474..959db07300 100644 --- a/src/lagrangian/basic/IOPosition/IOPosition.C +++ b/src/lagrangian/basic/IOPosition/IOPosition.C @@ -23,8 +23,6 @@ License \*---------------------------------------------------------------------------*/ -#include "IOPosition.H" - // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // template diff --git a/src/lagrangian/basic/injectedParticle/injectedParticleIO.C b/src/lagrangian/basic/injectedParticle/injectedParticleIO.C index 72d6e87bcb..066eb6444d 100644 --- a/src/lagrangian/basic/injectedParticle/injectedParticleIO.C +++ b/src/lagrangian/basic/injectedParticle/injectedParticleIO.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -204,20 +204,12 @@ void Foam::injectedParticle::writePosition(Ostream& os) const } else { - struct oldParticle - { - vector position; - label celli; - label facei; - scalar stepFraction; - label tetFacei; - label tetPti; - label origProc; - label origId; - } p; + positionsCompat1706 p; const size_t s = - offsetof(oldParticle, facei) - offsetof(oldParticle, position); + ( + offsetof(positionsCompat1706, facei) + - offsetof(positionsCompat1706, position)); p.position = position_; p.celli = cell(); diff --git a/src/lagrangian/basic/particle/particle.H b/src/lagrangian/basic/particle/particle.H index beb2c8a4d6..35da9c8d03 100644 --- a/src/lagrangian/basic/particle/particle.H +++ b/src/lagrangian/basic/particle/particle.H @@ -126,6 +126,20 @@ public: }; + //- Old particle positions content for OpenFOAM-1706 and earlier + struct positionsCompat1706 + { + vector position; + label celli; + label facei; + scalar stepFraction; + label tetFacei; + label tetPti; + label origProc; + label origId; + }; + + private: // Private data diff --git a/src/lagrangian/basic/particle/particleIO.C b/src/lagrangian/basic/particle/particleIO.C index 8115ad62f5..fe234c0753 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-2017 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -86,17 +86,7 @@ Foam::particle::particle } else { - struct oldParticle - { - vector position; - label celli; - label facei; - scalar stepFraction; - label tetFacei; - label tetPti; - label origProc; - label origId; - } p; + positionsCompat1706 p; if (is.format() == IOstream::ASCII) { @@ -118,15 +108,20 @@ Foam::particle::particle { // Read whole struct const size_t s = - sizeof(oldParticle) - offsetof(oldParticle, position); + ( + sizeof(positionsCompat1706) + - offsetof(positionsCompat1706, position) + ); is.read(reinterpret_cast(&p.position), s); } else { // Read only position and cell const size_t s = - offsetof(oldParticle, facei) - - offsetof(oldParticle, position); + ( + offsetof(positionsCompat1706, facei) + - offsetof(positionsCompat1706, position) + ); is.read(reinterpret_cast(&p.position), s); } } @@ -181,20 +176,13 @@ void Foam::particle::writePosition(Ostream& os) const } else { - struct oldParticle - { - vector position; - label celli; - label facei; - scalar stepFraction; - label tetFacei; - label tetPti; - label origProc; - label origId; - } p; + positionsCompat1706 p; const size_t s = - offsetof(oldParticle, facei) - offsetof(oldParticle, position); + ( + offsetof(positionsCompat1706, facei) + - offsetof(positionsCompat1706, position) + ); p.position = position(); p.celli = celli_;