mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
old "positions" file form
The change to barycentric-based tracking changed the contents of the
cloud "positions" file to a new format comprising the barycentric
co-ordinates and other cell position-based info. This broke
backwards compatibility, providing no option to restart old cases
(v1706 and earlier), and caused difficulties for dependent code, e.g.
for post-processing utilities that could only infer the contents only
after reading.
The barycentric position info is now written to a file called
"coordinates" with provision to restart old cases for which only the
"positions" file is available. Related utilities, e.g. for parallel
running and data conversion have been updated to be able to support both
file types.
To write the "positions" file by default, use set the following option
in the InfoSwitches section of the controlDict:
writeLagrangianPositions 1;
140 lines
3.5 KiB
C
140 lines
3.5 KiB
C
/*---------------------------------------------------------------------------*\
|
|
========= |
|
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
\\ / O peration |
|
|
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
|
|
\\/ 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 "solidParticle.H"
|
|
#include "IOstreams.H"
|
|
|
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
|
|
|
const std::size_t Foam::solidParticle::sizeofFields
|
|
(
|
|
sizeof(solidParticle) - sizeof(particle)
|
|
);
|
|
|
|
|
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
|
|
|
Foam::solidParticle::solidParticle
|
|
(
|
|
const polyMesh& mesh,
|
|
Istream& is,
|
|
bool readFields,
|
|
bool newFormat
|
|
)
|
|
:
|
|
particle(mesh, is, readFields, newFormat)
|
|
{
|
|
if (readFields)
|
|
{
|
|
if (is.format() == IOstream::ASCII)
|
|
{
|
|
d_ = readScalar(is);
|
|
is >> U_;
|
|
}
|
|
else
|
|
{
|
|
is.read(reinterpret_cast<char*>(&d_), sizeofFields);
|
|
}
|
|
}
|
|
|
|
is.check(FUNCTION_NAME);
|
|
}
|
|
|
|
|
|
void Foam::solidParticle::readFields(Cloud<solidParticle>& c)
|
|
{
|
|
bool valid = c.size();
|
|
|
|
particle::readFields(c);
|
|
|
|
IOField<scalar> d(c.fieldIOobject("d", IOobject::MUST_READ), valid);
|
|
c.checkFieldIOobject(c, d);
|
|
|
|
IOField<vector> U(c.fieldIOobject("U", IOobject::MUST_READ), valid);
|
|
c.checkFieldIOobject(c, U);
|
|
|
|
label i = 0;
|
|
forAllIter(Cloud<solidParticle>, c, iter)
|
|
{
|
|
solidParticle& p = iter();
|
|
|
|
p.d_ = d[i];
|
|
p.U_ = U[i];
|
|
i++;
|
|
}
|
|
}
|
|
|
|
|
|
void Foam::solidParticle::writeFields(const Cloud<solidParticle>& c)
|
|
{
|
|
particle::writeFields(c);
|
|
|
|
label np = c.size();
|
|
|
|
IOField<scalar> d(c.fieldIOobject("d", IOobject::NO_READ), np);
|
|
IOField<vector> U(c.fieldIOobject("U", IOobject::NO_READ), np);
|
|
|
|
label i = 0;
|
|
forAllConstIter(Cloud<solidParticle>, c, iter)
|
|
{
|
|
const solidParticle& p = iter();
|
|
|
|
d[i] = p.d_;
|
|
U[i] = p.U_;
|
|
i++;
|
|
}
|
|
|
|
d.write(np > 0);
|
|
U.write(np > 0);
|
|
}
|
|
|
|
|
|
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
|
|
|
Foam::Ostream& Foam::operator<<(Ostream& os, const solidParticle& p)
|
|
{
|
|
if (os.format() == IOstream::ASCII)
|
|
{
|
|
os << static_cast<const particle&>(p)
|
|
<< token::SPACE << p.d_
|
|
<< token::SPACE << p.U_;
|
|
}
|
|
else
|
|
{
|
|
os << static_cast<const particle&>(p);
|
|
os.write
|
|
(
|
|
reinterpret_cast<const char*>(&p.d_),
|
|
solidParticle::sizeofFields
|
|
);
|
|
}
|
|
|
|
os.check(FUNCTION_NAME);
|
|
return os;
|
|
}
|
|
|
|
|
|
// ************************************************************************* //
|