GlobalIOField.H
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-2017 OpenFOAM Foundation
9 Copyright (C) 2016-2018 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
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
27Class
28 Foam::GlobalIOField
29
30Description
31 IOField with global data (so optionally read from master)
32
33SourceFiles
34 GlobalIOField.C
35
36\*---------------------------------------------------------------------------*/
37
38#ifndef GlobalIOField_H
39#define GlobalIOField_H
40
41#include "regIOobject.H"
42#include "Field.H"
43
44// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45
46namespace Foam
47{
48
49/*---------------------------------------------------------------------------*\
50 Class GlobalIOField Declaration
51\*---------------------------------------------------------------------------*/
52
53template<class Type>
54class GlobalIOField
55:
56 public regIOobject,
57 public Field<Type>
58{
59
60public:
62 TypeName("Field");
63
64
65 // Constructors
66
67 //- Default copy construct
68 GlobalIOField(const GlobalIOField&) = default;
69
70 //- Construct from IOobject
71 explicit GlobalIOField(const IOobject& io);
72
73 //- Construct from IOobject and size (does not set values)
74 GlobalIOField(const IOobject& io, const label size);
75
76 //- Construct from IOobject and a List/Field content
77 GlobalIOField(const IOobject& io, const UList<Type>& content);
78
79 //- Construct by transferring the Field content
80 GlobalIOField(const IOobject& io, Field<Type>&& content);
81
82 //- Construct by copying/moving tmp content
83 GlobalIOField(const IOobject& io, const tmp<Field<Type>>& tf);
84
85
86 //- Destructor
87 virtual ~GlobalIOField() = default;
88
89
90 // Member Functions
91
92 //- Is object global
93 virtual bool global() const
94 {
95 return true;
96 }
97
98 //- Return complete path + object name if the file exists
99 //- either in the case/processor or case, otherwise null
100 virtual fileName filePath() const
101 {
102 return globalFilePath(type());
103 }
104
105 //- The readData method for regIOobject read operation
106 virtual bool readData(Istream& is);
107
108 //- The writeData method for regIOobject write operation
109 bool writeData(Ostream& os) const;
110
111
112 // Member Operators
113
114 //- Copy assignment of entries
115 void operator=(const GlobalIOField<Type>& rhs);
116
117 //- Copy or move assignment of entries
118 using Field<Type>::operator=;
119
120};
121
122
123// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
124
125} // End namespace Foam
126
127// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
128
129#ifdef NoRepository
130# include "GlobalIOField.C"
131#endif
132
133// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
134
135#endif
136
137// ************************************************************************* //
Generic templated field type.
Definition: Field.H:82
friend Ostream & operator(Ostream &, const Field< Type > &)
IOField with global data (so optionally read from master)
Definition: GlobalIOField.H:57
void operator=(const GlobalIOField< Type > &rhs)
Copy assignment of entries.
bool writeData(Ostream &os) const
The writeData method for regIOobject write operation.
virtual bool global() const
Is object global.
Definition: GlobalIOField.H:92
virtual ~GlobalIOField()=default
Destructor.
virtual fileName filePath() const
Definition: GlobalIOField.H:99
virtual bool readData(Istream &is)
The readData method for regIOobject read operation.
GlobalIOField(const GlobalIOField &)=default
Default copy construct.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:170
fileName globalFilePath(const word &typeName, const bool search=true) const
Helper for filePath that searches up if in parallel.
Definition: IOobject.C:593
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:64
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: UList.H:94
label size() const noexcept
The number of elements in the UList.
Definition: UListI.H:420
A class for handling file names.
Definition: fileName.H:76
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:76
A class for managing temporary objects.
Definition: tmp.H:65
OBJstream os(runTime.globalPath()/outputName)
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
Namespace for OpenFOAM.
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: MSwindows.C:598
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73