IOmapDistributePolyMesh.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) 2015 OpenFOAM Foundation
9  Copyright (C) 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 
30 
31 /* * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * */
32 
33 namespace Foam
34 {
35  defineTypeNameAndDebug(IOmapDistributePolyMesh, 0);
36 }
37 
38 
39 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
40 
41 bool Foam::IOmapDistributePolyMesh::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<IOmapDistributePolyMesh>();
62 
63  readContents();
64 }
65 
66 
68 (
69  const IOobject& io,
70  const mapDistributePolyMesh& map
71 )
72 :
74 {
75  // Warn for MUST_READ_IF_MODIFIED
76  warnNoRereading<IOmapDistributePolyMesh>();
77 
78  if (!readContents())
79  {
81  }
82 }
83 
84 
86 (
87  const IOobject& io,
88  mapDistributePolyMesh&& map
89 )
90 :
91  regIOobject(io)
92 {
93  // Warn for MUST_READ_IF_MODIFIED
94  warnNoRereading<IOmapDistributePolyMesh>();
95 
97 
98  readContents();
99 }
100 
101 
103 (
104  const IOobject& io,
105  const mapDistributePolyMesh& map
106 )
107 :
108  regIOobject(io),
109  contentRef_(map) // cref
110 {}
111 
112 
113 // Not sure if we need this yet...
114 //
126 
127 
128 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
129 
131 {
132  is >> *this;
133  return is.good();
134 }
135 
136 
138 {
139  os << *this;
140  return os.good();
141 }
142 
143 
145 {
146  is >> contentRef_.ref();
147  return is.good();
148 }
149 
150 
152 {
153  os << contentRef_.cref();
154  return os.good();
155 }
156 
157 
158 // ************************************************************************* //
virtual bool readData(Istream &is)
The readData method for regIOobject read operation.
void operator=(const mapDistributePolyMesh &map)
Copy assignment.
virtual bool readData(Istream &is)
The readData method for regIOobject read operation.
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
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
IOmapDistributePolyMeshRef()=delete
No default construct.
bool isReadOptional() const noexcept
True if (LAZY_READ) bits are set [same as READ_IF_PRESENT].
virtual bool writeData(Ostream &os) const
The writeData method for regIOobject write operation.
void transfer(mapDistributePolyMesh &map)
Transfer the contents of the argument and annul the argument.
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.
virtual bool writeData(Ostream &os) const
The writeData method for regIOobject write operation.
bool good() const noexcept
True if next operation might succeed.
Definition: IOstream.H:281
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.
IOmapDistributePolyMesh(const IOobject &io)
Construct from IOobject.
Namespace for OpenFOAM.