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, 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
109 
110  //- Copy constructor deleted
111  // as it would not set the internalField reference correctly
113 
114  //- Move constructor deleted
115  // as it would not set the internalField reference correctly
117 
118 
119  //- Destructor
121 
122 
123  // Member Functions
124 
125  //- Access the underlying field table
126  const HashPtrTable<Source>& table() const;
127 
128  //- Access the underlying field table
130 
131  //- Inherit empty test
133 
134  //- Return a map from the source name to the field source type
135  HashTable<word> types() const;
136 
137  //- Read the sources
138  void readField(const Internal& field, const dictionary& dict);
139 
140  //- Reset the boundary field contents to the given field
141  // Used for mesh to mesh mapping
142  void reset(const Internal&, const GeometricFieldSources&);
143 
144  //- Write sources as dictionary entry
145  void writeEntry(const word& keyword, Ostream& os) const;
146 
147 
148  // Member operators
149 
150  //- Find and return a field source
151  const Source& operator[](const word& sourceName) const;
152 };
153 
154 
155 template<class Type, class GeoMesh, template<class> class PrimitiveField>
156 Ostream& operator<<
157 (
158  Ostream&,
160 );
161 
162 
163 /*---------------------------------------------------------------------------*\
164  Class NoFieldSource Declaration
165 \*---------------------------------------------------------------------------*/
166 
167 template<class Type>
168 class NoFieldSource
169 {
170 public:
171 
172  // Constructors
173 
174  //- Construct null
175  NoFieldSource()
176  {}
177 
178  //- Construct from internal field
179  template<class InternalField>
180  NoFieldSource(const InternalField&)
181  {}
182 
183  //- Dummy clone
184  template<class InternalField>
185  autoPtr<NoFieldSource<Type>> clone(const InternalField&) const
186  {
188  }
189 
190 
191  // Selectors
192 
193  //- Dummy selector
194  template<class InternalField>
196  (
197  const word&,
198  const InternalField&
199  )
200  {
202  }
203 
204  //- Dummy selector
205  template<class InternalField>
207  (
208  const InternalField&,
209  const dictionary&
210  )
211  {
213  }
214 
215 
216  // Member Functions
217 
218  //- Dummy return of the internal field reference
219  const nil internalField() const
220  {
221  return nil();
222  }
223 };
224 
225 
226 template<class Type>
228 {
229  return os;
230 }
231 
232 
233 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
234 
235 } // End namespace Foam
236 
237 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
238 
239 #ifdef NoRepository
240  #include "GeometricFieldSources.C"
241 #endif
242 
243 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
244 
245 #endif
246 
247 // ************************************************************************* //
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 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:67
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:62
Namespace for OpenFOAM.
Ostream & operator<<(Ostream &os, const fvConstraints &constraints)
dictionary dict