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 -------------------------------------------------------------------------------
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 Class
28  Foam::GlobalIOField
29 
30 Description
31  IOField with global data (so optionally read from master)
32 
33 SourceFiles
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 
46 namespace Foam
47 {
48 
49 /*---------------------------------------------------------------------------*\
50  Class GlobalIOField Declaration
51 \*---------------------------------------------------------------------------*/
52 
53 template<class Type>
54 class GlobalIOField
55 :
56  public regIOobject,
57  public Field<Type>
58 {
59 
60 public:
61 
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 // ************************************************************************* //
regIOobject.H
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:104
Foam::fileName
A class for handling file names.
Definition: fileName.H:69
Foam::GlobalIOField::writeData
bool writeData(Ostream &os) const
The writeData method for regIOobject write operation.
Definition: GlobalIOField.C:136
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::GlobalIOField::filePath
virtual fileName filePath() const
Definition: GlobalIOField.H:99
Foam::GlobalIOField
IOField with global data (so optionally read from master)
Definition: GlobalIOField.H:53
Foam::GlobalIOField::TypeName
TypeName("Field")
Foam::Field
Generic templated field type.
Definition: Field.H:63
Foam::GlobalIOField::~GlobalIOField
virtual ~GlobalIOField()=default
Destructor.
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Field.H
Foam::GlobalIOField::readData
virtual bool readData(Istream &is)
The readData method for regIOobject read operation.
Definition: GlobalIOField.C:128
Foam::IOobject::globalFilePath
fileName globalFilePath(const word &typeName, const bool search=true) const
Helper for filePath that searches up if in parallel.
Definition: IOobject.C:527
Foam::GlobalIOField::operator=
void operator=(const GlobalIOField< Type > &rhs)
Copy assignment of entries.
Definition: GlobalIOField.C:145
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::GlobalIOField::GlobalIOField
GlobalIOField(const GlobalIOField &)=default
Default copy construct.
Foam::regIOobject
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:71
Foam::GlobalIOField::global
virtual bool global() const
Is object global.
Definition: GlobalIOField.H:92
Foam::type
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: MSwindows.C:590
Foam::UList< Type >
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
GlobalIOField.C