GeometricFieldSources.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2023-2024 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::GeometricFieldSources
26 
27 Description
28  Part of a geometric field used for setting the values associated with
29  optional sources
30 
31 SourceFiles
32  GeometricFieldSources.C
33 
34 \*---------------------------------------------------------------------------*/
35 
36 #ifndef GeometricFieldSources_H
37 #define GeometricFieldSources_H
38 
39 #include "dimensionedTypes.H"
40 #include "DimensionedField.H"
41 #include "HashPtrTable.H"
42 
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 
45 namespace Foam
46 {
47 
48 class dictionary;
49 
50 /*---------------------------------------------------------------------------*\
51  Class GeometricFieldSources Declaration
52 \*---------------------------------------------------------------------------*/
53 
54 template<class Type, class GeoMesh>
56 :
57  private HashPtrTable<typename GeoMesh::template FieldSource<Type>>
58 {
59 public:
60 
61  // Public Typedefs
62 
63  //- Type of the internal field from which this GeometricField is derived
65 
66  //- Type of the field source of which this field sources is composed
67  typedef typename GeoMesh::template FieldSource<Type> Source;
68 
69 
70 private:
71 
72  // Private Data
73 
74  //- Cached IO error location for delayed error messages
75  IOerrorLocation errorLocation_;
76 
77 
78 public:
79 
80  // Constructors
81 
82  //- Construct null
84 
85  //- Construct from a table of field sources
87 
88  //- Construct as copy setting the reference to the internal field
90 
91  //- Construct from dictionary
93 
94  //- Construct from types
96 
97  //- Copy constructor deleted
98  // as it would not set the internalField reference correctly
100 
101  //- Move constructor deleted
102  // as it would not set the internalField reference correctly
104 
105 
106  //- Destructor
108 
109 
110  // Member Functions
111 
112  //- Access the underlying field table
113  const HashPtrTable<Source>& table() const;
114 
115  //- Access the underlying field table
117 
118  //- Inherit empty test
120 
121  //- Return a map from the source name to the field source type
122  HashTable<word> types() const;
123 
124  //- Read the sources
125  void readField(const Internal& field, const dictionary& dict);
126 
127  //- Reset the boundary field contents to the given field
128  // Used for mesh to mesh mapping
129  void reset(const GeometricFieldSources&);
130 
131  //- Write sources as dictionary entry
132  void writeEntry(const word& keyword, Ostream& os) const;
133 
134 
135  // Member operators
136 
137  //- Find and return a field source
138  const Source& operator[](const word& sourceName) const;
139 };
140 
141 
142 template<class Type, class GeoMesh>
143 Ostream& operator<<
144 (
145  Ostream&,
147 );
148 
149 
150 /*---------------------------------------------------------------------------*\
151  Class NoFieldSource Declaration
152 \*---------------------------------------------------------------------------*/
153 
154 template<class Type, class GeoMesh>
155 class NoFieldSource
156 {
157  // Private Data
158 
159  //- Reference to internal field
160  const DimensionedField<Type, GeoMesh>& internalField_;
161 
162 
163 public:
164 
165  // Constructors
166 
167  //- Construct from internal field
169  (
171  )
172  :
173  internalField_(iF)
174  {}
175 
176  //- Dummy clone
178  (
180  ) const
181  {
182  return
184  (
186  );
187  }
188 
189 
190  // Selectors
191 
192  //- Dummy selector
194  (
195  const word& fieldSourceType,
197  )
198  {
199  return
201  (
203  );
204  }
205 
206  //- Dummy selector
208  (
210  const dictionary& dict
211  )
212  {
213  return
215  (
217  );
218  }
219 
220 
221  // Member Functions
222 
223  //- Return the internal field reference
225  {
226  return internalField_;
227  }
228 };
229 
230 
231 template<class Type, class GeoMesh>
233 {
234  return os;
235 }
236 
237 
238 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
239 
240 } // End namespace Foam
241 
242 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
243 
244 #ifdef NoRepository
245  #include "GeometricFieldSources.C"
246 #endif
247 
248 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
249 
250 #endif
251 
252 // ************************************************************************* //
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Part of a geometric field used for setting the values associated with optional sources.
DimensionedField< Type, GeoMesh > Internal
Type of the internal field from which this GeometricField is derived.
void readField(const Internal &field, const dictionary &dict)
Read the sources.
void writeEntry(const word &keyword, Ostream &os) const
Write sources as dictionary entry.
GeoMesh::template FieldSource< Type > Source
Type of the field source of which this field sources is composed.
HashTable< word > types() const
Return a map from the source name to the field source type.
const HashPtrTable< Source > & table() const
Access the underlying field table.
void reset(const GeometricFieldSources &)
Reset the boundary field contents to the given field.
const Source & operator[](const word &sourceName) const
Find and return a field source.
A HashTable specialisation for hashing pointers.
Definition: HashPtrTable.H:67
An STL-conforming hash table.
Definition: HashTable.H:127
NoFieldSource(const DimensionedField< Type, GeoMesh > &iF)
Construct from internal field.
autoPtr< NoFieldSource< Type, GeoMesh > > clone(const DimensionedField< Type, GeoMesh > &iF) const
Dummy clone.
const DimensionedField< Type, GeoMesh > & internalField() const
Return the internal field reference.
static autoPtr< NoFieldSource< Type, GeoMesh > > New(const word &fieldSourceType, const DimensionedField< Type, GeoMesh > &iF)
Dummy selector.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
A class for handling words, derived from string.
Definition: word.H:62
Namespace for OpenFOAM.
Ostream & operator<<(Ostream &os, const fvConstraints &constraints)
dictionary dict