fieldsDistributor.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) 2022-2023 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  fieldsDistributor
28 
29 Description
30  Common methods/utilities for field decomposers/distributors etc.
31 
32 SourceFiles
33  fieldsDistributorTemplates.C
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef Foam_fieldsDistributor_H
38 #define Foam_fieldsDistributor_H
39 
40 #include "bitSet.H"
41 #include "fileOperation.H"
42 #include "PtrList.H"
43 #include "IOobjectList.H"
44 #include "GeometricField.H"
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 namespace Foam
49 {
50 
51 /*---------------------------------------------------------------------------*\
52  Class fieldsDistributor Declaration
53 \*---------------------------------------------------------------------------*/
54 
56 {
57  // Private Methods
58 
59  //- Read volume/surface/point/area fields that may or may not exist
60  //- on all processors
61  template<class BoolListType, class GeoField, class MeshSubsetter>
62  static void readFieldsImpl
63  (
64  refPtr<fileOperation>* readHandlerPtr, // Can be nullptr
65  const BoolListType& haveMeshOnProc,
66  const MeshSubsetter* subsetter, // Can be nullptr
67  const typename GeoField::Mesh& mesh,
68  IOobjectList& allObjects,
70  const bool deregister
71  );
72 
73 
74 public:
75 
76  // Reading helpers
77 
78  //- Generic mesh-based field reading
79  template<class GeoField>
80  static void readField
81  (
82  const IOobject& io,
83  const typename GeoField::Mesh& mesh,
84  const label i,
86  );
87 
88  //- Definition of readField for GeometricFields only
89  template<class Type, template<class> class PatchField, class GeoMesh>
90  static void readField
91  (
92  const IOobject& io,
93  const typename GeoMesh::Mesh& mesh,
94  const label i,
96  );
97 
98 
99  //- Read fields and store on the pointer list
100  template
101  <
102  class Type,
103  template<class> class PatchField,
104  class GeoMesh
105  >
106  static void readFields
107  (
108  const typename GeoMesh::Mesh& mesh,
109  const IOobjectList& objects,
111  const bool readOldTime
112  );
113 
114  //- Read fields and hold on the pointer list
115  template<class Mesh, class GeoField>
116  static void readFields
117  (
118  const Mesh& mesh,
119  const IOobjectList& objects,
121  );
122 
123 
124  //- Read volume/surface/point/area fields that may or may not exist
125  //- on all processors
126  template<class GeoField, class MeshSubsetter>
127  static void readFields
128  (
129  const bitSet& haveMeshOnProc,
130  const MeshSubsetter* subsetter, // Can be nullptr
131  const typename GeoField::Mesh& mesh,
132  IOobjectList& allObjects,
134  const bool deregister = false
135  );
136 
137  //- Read volume/surface/point/area fields that may or may not exist
138  //- on all processors
139  template<class GeoField, class MeshSubsetter>
140  static void readFields
141  (
142  const boolUList& haveMeshOnProc,
143  const MeshSubsetter* subsetter, // Can be nullptr
144  const typename GeoField::Mesh& mesh,
145  IOobjectList& allObjects,
147  const bool deregister = false
148  );
149 
150  //- Read volume/surface/point/area fields that may or may not exist
151  //- on all processors
152  template<class GeoField, class MeshSubsetter>
153  static void readFields
154  (
155  const boolUList& haveMeshOnProc,
156  const typename GeoField::Mesh& mesh,
157  const autoPtr<MeshSubsetter>& subsetter,
158  IOobjectList& allObjects,
160  const bool deregister = false
161  );
162 
163  //- Read volume/surface/point/area fields that may or may not exist
164  //- on all processors
165  template<class GeoField, class MeshSubsetter>
166  static void readFields
167  (
168  const boolUList& haveMeshOnProc,
169  refPtr<fileOperation>& readHandler,
170  const typename GeoField::Mesh& mesh,
171  const autoPtr<MeshSubsetter>& subsetter,
172  IOobjectList& allObjects,
174  const bool deregister = false
175  );
176 };
177 
178 
179 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
180 
181 } // End namespace Foam
182 
183 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
184 
185 #ifdef NoRepository
187 #endif
188 
189 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
190 
191 #endif
192 
193 // ************************************************************************* //
static void readField(const IOobject &io, const typename GeoField::Mesh &mesh, const label i, PtrList< GeoField > &fields)
Generic mesh-based field reading.
List of IOobjects with searching and retrieving facilities. Implemented as a HashTable, so the various sorted methods should be used if traversing in parallel.
Definition: IOobjectList.H:55
Generic GeometricField class.
Definition: areaFieldsFwd.H:50
A class for managing references or pointers (no reference counting)
Definition: HashPtrTable.H:49
multivariateSurfaceInterpolationScheme< scalar >::fieldTable fields
Definition: createFields.H:97
dynamicFvMesh & mesh
static void readFields(const typename GeoMesh::Mesh &mesh, const IOobjectList &objects, PtrList< GeometricField< Type, PatchField, GeoMesh >> &fields, const bool readOldTime)
Read fields and store on the pointer list.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: HashTable.H:105
MESH Mesh
Definition: GeoMesh.H:58
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
Definition: bitSet.H:59
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers...
Definition: List.H:55
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
Generic mesh wrapper used by volMesh, surfaceMesh, pointMesh etc.
Definition: GeoMesh.H:42
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
Namespace for OpenFOAM.