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-2026 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, template<class> class PrimitiveField>
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  //- Declare friendship with other geometric field sources
81  template<class Type2, class GeoMesh2, template<class> class PrimitiveField2>
82  friend class GeometricFieldSources;
83 
84 
85  // Constructors
86 
87  //- Construct null
89 
90  //- Construct from a table of field sources
92 
93  //- Construct as copy setting the reference to the internal field
95 
96  //- Construct as copy setting the reference to the internal field
97  template<template<class> class PrimitiveField2>
98  explicit GeometricFieldSources
99  (
100  const Internal&,
102  );
103 
104  //- Construct from dictionary
105  GeometricFieldSources(const Internal&, const dictionary&);
106 
107  //- Construct from types and an error location
109  (
110  const Internal&,
111  const HashTable<word>&,
112  const IOerrorLocation&
113  );
114 
115  //- Copy constructor deleted
116  // as it would not set the internalField reference correctly
118 
119  //- Move constructor deleted
120  // as it would not set the internalField reference correctly
122 
123 
124  //- Destructor
126 
127 
128  // Member Functions
129 
130  //- Access the underlying field table
131  const HashPtrTable<Source>& table() const;
132 
133  //- Access the underlying field table
135 
136  //- Access the error location
137  const IOerrorLocation& errorLocation() const;
138 
139  //- Inherit empty test
141 
142  //- Return a map from the source name to the field source type
143  HashTable<word> types() const;
144 
145  //- Read the sources
146  void readField(const Internal& field, const dictionary& dict);
147 
148  //- Reset the boundary field contents to the given field
149  // Used for mesh to mesh mapping
150  void reset(const Internal&, const GeometricFieldSources&);
151 
152  //- Write sources as dictionary entry
153  void writeEntry(const word& keyword, Ostream& os) const;
154 
155 
156  // Member operators
157 
158  //- Find and return a field source
159  const Source& operator[](const word& sourceName) const;
160 };
161 
162 
163 template<class Type, class GeoMesh, template<class> class PrimitiveField>
164 Ostream& operator<<
165 (
166  Ostream&,
168 );
169 
170 
171 /*---------------------------------------------------------------------------*\
172  Class NoFieldSource Declaration
173 \*---------------------------------------------------------------------------*/
174 
175 template<class Type>
176 class NoFieldSource
177 {
178 public:
179 
180  // Constructors
181 
182  //- Construct null
183  NoFieldSource()
184  {}
185 
186  //- Construct from internal field
187  template<class InternalField>
188  NoFieldSource(const InternalField&)
189  {}
190 
191  //- Dummy clone
192  template<class InternalField>
193  autoPtr<NoFieldSource<Type>> clone(const InternalField&) const
194  {
196  }
197 
198 
199  // Selectors
200 
201  //- Dummy selector
202  template<class InternalField>
204  (
205  const word&,
206  const InternalField&
207  )
208  {
210  }
211 
212  //- Dummy selector
213  template<class InternalField>
215  (
216  const InternalField&,
217  const dictionary&
218  )
219  {
221  }
222 
223 
224  // Member Functions
225 
226  //- Dummy return of the internal field reference
227  const nil internalField() const
228  {
229  return nil();
230  }
231 };
232 
233 
234 template<class Type>
236 {
237  return os;
238 }
239 
240 
241 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
242 
243 } // End namespace Foam
244 
245 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
246 
247 #ifdef NoRepository
248  #include "GeometricFieldSources.C"
249 #endif
250 
251 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
252 
253 #endif
254 
255 // ************************************************************************* //
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.
const IOerrorLocation & errorLocation() const
Access the error location.
const Source & operator[](const word &sourceName) const
Find and return a field source.
void readField(const Internal &field, const dictionary &dict)
Read the sources.
const HashPtrTable< Source > & table() const
Access the underlying field table.
DimensionedField< Type, GeoMesh, PrimitiveField > Internal
Type of the internal field from which this GeometricField is derived.
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.
friend class GeometricFieldSources
Declare friendship with other geometric field sources.
void reset(const Internal &, const GeometricFieldSources &)
Reset the boundary field contents to the given field.
A HashTable specialisation for hashing pointers.
Definition: HashPtrTable.H:68
An STL-conforming hash table.
Definition: HashTable.H:127
static autoPtr< NoFieldSource< Type > > New(const word &, const InternalField &)
Dummy selector.
autoPtr< NoFieldSource< Type > > clone(const InternalField &) const
Dummy clone.
const nil internalField() const
Dummy return of the internal field reference.
NoFieldSource()
Construct null.
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 keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
A zero-sized class without any storage. Used, for example, in HashSet.
Definition: nil.H:59
A class for handling words, derived from string.
Definition: word.H:63
Namespace for OpenFOAM.
Ostream & operator<<(Ostream &os, const fvConstraints &constraints)
dictionary dict