/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2016-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
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 "DSMCParcel.H"
#include "IOstreams.H"
#include "IOField.H"
#include "Cloud.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
template
const std::size_t Foam::DSMCParcel::sizeofFields
(
sizeof(DSMCParcel) - sizeof(ParcelType)
);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template
Foam::DSMCParcel::DSMCParcel
(
const polyMesh& mesh,
Istream& is,
bool readFields,
bool newFormat
)
:
ParcelType(mesh, is, readFields, newFormat),
U_(Zero),
Ei_(0.0),
typeId_(-1)
{
if (readFields)
{
if (is.format() == IOstreamOption::ASCII)
{
is >> U_ >> Ei_ >> typeId_;
}
else if (!is.checkLabelSize<>() || !is.checkScalarSize<>())
{
// Non-native label or scalar size
is.beginRawRead();
readRawScalar(is, U_.data(), vector::nComponents);
readRawScalar(is, &Ei_);
readRawLabel(is, &typeId_);
is.endRawRead();
}
else
{
is.read(reinterpret_cast(&U_), sizeofFields);
}
}
is.check(FUNCTION_NAME);
}
template
void Foam::DSMCParcel::readFields(Cloud>& c)
{
const bool readOnProc = c.size();
ParcelType::readFields(c);
IOField U(c.newIOobject("U", IOobject::MUST_READ), readOnProc);
c.checkFieldIOobject(c, U);
IOField Ei(c.newIOobject("Ei", IOobject::MUST_READ), readOnProc);
c.checkFieldIOobject(c, Ei);
IOField