IOmapDistribute.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2014-2015 OpenFOAM Foundation
9  Copyright (C) 2015-2022 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "IOmapDistribute.H"
30 
31 /* * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * */
32 
33 namespace Foam
34 {
35  defineTypeNameAndDebug(IOmapDistribute, 0);
36 }
37 
38 
39 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
40 
41 bool Foam::IOmapDistribute::readContents()
42 {
43  if (isReadRequired() || (isReadOptional() && headerOk()))
44  {
45  readStream(typeName) >> *this;
46  close();
47  return true;
48  }
49 
50  return false;
51 }
52 
53 
54 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
55 
57 :
59 {
60  // Warn for MUST_READ_IF_MODIFIED
61  warnNoRereading<IOmapDistribute>();
62 
63  readContents();
64 }
65 
66 
68 (
69  const IOobject& io,
70  const mapDistribute& map
71 )
72 :
74 {
75  // Warn for MUST_READ_IF_MODIFIED
76  warnNoRereading<IOmapDistribute>();
77 
78  if (!readContents())
79  {
81  }
82 }
83 
84 
86 (
87  const IOobject& io,
88  mapDistribute&& map
89 )
90 :
91  regIOobject(io)
92 {
93  // Warn for MUST_READ_IF_MODIFIED
94  warnNoRereading<IOmapDistribute>();
95 
97 
98  readContents();
99 }
100 
101 
102 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
105 {
106  return (is >> *this).good();
107 }
108 
109 
111 {
112  return (os << *this).good();
113 }
114 
115 
116 // ************************************************************************* //
IOmapDistribute(const IOobject &io)
Construct from IOobject.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
bool headerOk()
Read and check header info. Does not check the headerClassName.
Definition: regIOobject.C:505
void operator=(const mapDistribute &rhs)
Copy assignment.
bool isReadOptional() const noexcept
True if (LAZY_READ) bits are set [same as READ_IF_PRESENT].
virtual bool writeData(Ostream &) const
WriteData function required for regIOobject write operation.
void close()
Close Istream.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
OBJstream os(runTime.globalPath()/outputName)
defineTypeNameAndDebug(combustionModel, 0)
bool isReadRequired() const noexcept
True if (MUST_READ | READ_MODIFIED) bits are set.
Class containing processor-to-processor mapping information.
void transfer(mapDistribute &map)
Transfer the contents of the argument and annul the argument.
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:66
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, IOobject::NO_REGISTER)
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition: IOobject.H:172
Istream & readStream(const word &, const bool readOnProc=true)
Return Istream and check object type against that given.
virtual bool readData(Istream &)
ReadData function required for regIOobject read operation.
Namespace for OpenFOAM.