readFields.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) 2016-2022 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 \*---------------------------------------------------------------------------*/
27 
28 // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
29 
30 template<class GeoField>
32 (
33  const IOobject* io,
34  const typename GeoField::Mesh& mesh,
35  const bool syncPar
36 )
37 {
38  if (io)
39  {
40  return tmp<GeoField>::New(*io, mesh);
41  }
42 
43  return nullptr;
44 }
45 
46 
47 template<class GeoField>
49 (
50  const IOobject* io,
51  const fvMeshSubsetProxy& proxy,
52  const bool syncPar
53 )
54 {
55  return
56  proxy.interpolate
57  (
58  getField<GeoField>(io, proxy.baseMesh(), syncPar)
59  );
60 }
61 
62 
63 template<class GeoField>
65 (
66  const typename GeoField::Mesh& mesh,
67  const IOobjectList& objects,
68  const word& fieldName,
69  const bool syncPar
70 )
71 {
72  // Can do something with syncPar on failure ...
73 
74  return getField<GeoField>(objects.findObject(fieldName), mesh, syncPar);
75 }
76 
77 
78 template<class GeoField>
80 (
81  const fvMeshSubsetProxy& proxy,
82  const IOobjectList& objects,
83  const word& fieldName,
84  const bool syncPar
85 )
86 {
87  // Can do something with syncPar on failure ...
88 
89  return getField<GeoField>(objects.findObject(fieldName), proxy, syncPar);
90 }
91 
92 
93 template<class GeoField>
95 (
96  const typename GeoField::Mesh& mesh,
97  const IOobjectList& objects
98 )
99 {
100  const bool syncPar = true;
101 
102  // Available fields of type GeoField, sorted order
103  const wordList fieldNames(objects.sortedNames<GeoField>());
104 
105  // Construct the fields
106  PtrList<const GeoField> fields(fieldNames.size());
107 
108  label nFields = 0;
109 
110  for (const word& fieldName : fieldNames)
111  {
112  auto tfield =
113  getField<GeoField>(mesh, objects, fieldName, syncPar);
114 
115  if (tfield)
116  {
117  fields.set(nFields++, tfield.ptr());
118  }
119  }
120 
121  fields.resize(nFields);
122  return fields;
123 }
124 
125 
126 template<class GeoField>
128 (
129  const fvMeshSubsetProxy& proxy,
130  const IOobjectList& objects
131 )
132 {
133  const bool syncPar = true;
134 
135  // Available fields of type GeoField, sorted order
136  const wordList fieldNames(objects.sortedNames<GeoField>());
137 
138  // Construct the fields
139  PtrList<const GeoField> fields(fieldNames.size());
140 
141  label nFields = 0;
142 
143  for (const word& fieldName : fieldNames)
144  {
145  auto tfield =
146  getField<GeoField>(proxy, objects, fieldName, syncPar);
147 
148  if (tfield)
149  {
150  fields.set(nFields++, tfield.ptr());
151  }
152  }
153 
154  fields.resize(nFields);
155  return fields;
156 }
157 
158 
159 // ************************************************************************* //
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
multivariateSurfaceInterpolationScheme< scalar >::fieldTable fields
Definition: createFields.H:97
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
dynamicFvMesh & mesh
tmp< GeoField > getField(const IOobject *io, const typename GeoField::Mesh &mesh)
Get the field or return nullptr.
Definition: readFields.H:51
List< word > wordList
A List of words.
Definition: fileName.H:58
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers...
Definition: List.H:55
void readFields(const typename GeoFieldType::Mesh &mesh, const IOobjectList &objects, const wordHashSet &selectedFields, LIFOStack< regIOobject *> &storedObjects)
Read the selected GeometricFields of the templated type.
A class for managing temporary objects.
Definition: HashPtrTable.H:50