mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
STYLE: consolidate positionsCompat1706 structure (issue #721)
This commit is contained in:
@ -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
|
||||
|
||||
@ -23,8 +23,6 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "IOPosition.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
template<class CloudType>
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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<char*>(&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<char*>(&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_;
|
||||
|
||||
Reference in New Issue
Block a user