readFields.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) 2016-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 InClass
27  Foam::readFields
28 
29 Description
30  Helper routines for reading a field or fields, optionally with
31  a mesh subset (using fvMeshSubsetProxy).
32 
33 SourceFiles
34  readFields.C
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef FoamToVTK_readFields_H
39 #define FoamToVTK_readFields_H
40 
41 #include "fvMeshSubsetProxy.H"
42 #include "objectRegistry.H"
43 #include "IOobjectList.H"
44 #include "PtrList.H"
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 namespace Foam
49 {
50 
51 //- Get the field or return nullptr
52 template<class GeoField>
53 tmp<GeoField> getField
54 (
55  const IOobject* io,
56  const typename GeoField::Mesh& mesh,
57  const bool syncPar
58 );
59 
60 
61 //- Get the field and subset it, or return nullptr
62 template<class GeoField>
63 tmp<GeoField> getField
64 (
65  const IOobject* io,
66  const fvMeshSubsetProxy& proxy,
67  const bool syncPar,
68  objectRegistry* cache = nullptr
69 );
70 
71 
72 //- Get the named field from the objects, or return nullptr.
73 template<class GeoField>
74 tmp<GeoField> getField
75 (
76  const typename GeoField::Mesh& mesh,
77  const IOobjectList& objects,
78  const word& fieldName,
79  const bool syncPar
80 );
81 
82 
83 //- Return the named field from the optional cache (if found),
84 //- or get it from the objects and subset it (add to cache).
85 //- Return nullptr if nothing worked.
86 template<class GeoField>
87 tmp<GeoField> getField
88 (
89  const fvMeshSubsetProxy& proxy,
90  const IOobjectList& objects,
91  const word& fieldName,
92  const bool syncPar,
93  objectRegistry* cache = nullptr
94 );
95 
96 
97 //- Read the fields, and return as a pointer list
98 template<class GeoField>
99 PtrList<const GeoField> readFields
100 (
101  const typename GeoField::Mesh& mesh,
102  const IOobjectList& objects
103 );
104 
105 
106 //- Read the fields, optionally subset, and return as a pointer list
107 template<class GeoField>
108 PtrList<const GeoField> readFields
109 (
110  const fvMeshSubsetProxy& proxy,
111  const IOobjectList& objects
112 );
113 
114 
115 } // End namespace Foam
116 
117 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
118 
119 #ifdef NoRepository
120  #include "readFields.C"
121 #endif
122 
123 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
124 
125 #endif
126 
127 // ************************************************************************* //
dynamicFvMesh & mesh
void readFields(const typename GeoFieldType::Mesh &mesh, const IOobjectList &objects, const NameMatchPredicate &selectedFields, DynamicList< regIOobject *> &storedObjects)
Read the selected GeometricFields of the templated type and store on the objectRegistry.
tmp< GeoField > getField(const IOobject &io, const typename GeoField::Mesh &mesh)
Get the field or FatalError.
Definition: readFields.H:51
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, IOobject::NO_REGISTER)
Namespace for OpenFOAM.