MPPICParcelIO.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2013-2022 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "MPPICParcel.H"
27 #include "IOstreams.H"
28 #include "IOField.H"
29 
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 
32 template<class ParcelType>
35 
36 template<class ParcelType>
38 (
39  sizeof(MPPICParcel<ParcelType>) - sizeof(ParcelType)
40 );
41 
42 
43 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
44 
45 template<class ParcelType>
47 :
48  ParcelType(is, readFields),
49  id_(-1, -1)
50 {
51  if (readFields)
52  {
53  if (is.format() == IOstream::ASCII)
54  {
55  is >> id_;
56  }
57  else
58  {
59  is.read(reinterpret_cast<char*>(&id_), sizeofFields_);
60  }
61  }
62 
63  is.check
64  (
65  "MPPICParcel<ParcelType>::Collisions"
66  "(const polyMesh&, Istream&, bool)"
67  );
68 }
69 
70 
71 template<class ParcelType>
72 template<class CloudType>
74 {
76 }
77 
78 
79 template<class ParcelType>
80 template<class CloudType>
82 {
83  ParcelType::writeFields(c);
84 }
85 
86 
87 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
88 
89 template<class ParcelType>
90 Foam::Ostream& Foam::operator<<
91 (
92  Ostream& os,
94 )
95 {
96  if (os.format() == IOstream::ASCII)
97  {
98  os << static_cast<const ParcelType&>(p)
99  << token::SPACE << p.id();
100  }
101  else
102  {
103  os << static_cast<const ParcelType&>(p);
104  os.write
105  (
106  reinterpret_cast<const char*>(&p.id_),
107  MPPICParcel<ParcelType>::sizeofFields_
108  );
109  }
110 
111  os.check
112  (
113  "Ostream& operator<<(Ostream&, const MPPICParcel<ParcelType>&)"
114  );
115 
116  return os;
117 }
118 
119 
120 // ************************************************************************* //
Useful combination of include files which define Sin, Sout and Serr and the use of IO streams general...
Templated base class for dsmc cloud.
Definition: DSMCCloud.H:79
streamFormat format() const
Return current stream format.
Definition: IOstream.H:374
virtual bool check(const char *operation) const
Check IOstream status for given operation.
Definition: IOstream.C:92
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:60
virtual Istream & read(token &)=0
Return next token from stream.
Wrapper around parcel types to add MPPIC modelling.
Definition: MPPICParcel.H:82
MPPICParcel(const polyMesh &mesh, const barycentric &coordinates, const label celli, const label tetFacei, const label tetPti, const label facei)
Construct from mesh, coordinates and topology.
Definition: MPPICParcelI.H:32
static void writeFields(const CloudType &c)
Write.
Definition: MPPICParcelIO.C:81
static void readFields(CloudType &c)
Read.
Definition: MPPICParcelIO.C:73
labelPair id_
Processor and particle ID at the start of a tracking step. Allows.
Definition: MPPICParcel.H:145
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
A class for handling character strings derived from std::string.
Definition: string.H:79
const dimensionedScalar c
Speed of light in a vacuum.
void readFields(const typename GeoFieldType::Mesh &mesh, const IOobjectList &objects, const HashSet< word > &selectedFields, LIFOStack< regIOobject * > &storedObjects)
Read the selected GeometricFields of the specified type.
Definition: ReadFields.C:244
volScalarField & p