genericPatchFieldBase.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) 2021-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 Class
27  Foam::genericPatchFieldBase
28 
29 Description
30  Generic infrastructure for reading/writing unknown patch types.
31 
32 SourceFiles
33  genericPatchFieldBase.C
34  genericPatchFieldBaseTemplates.C
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef Foam_genericPatchFieldBase_H
39 #define Foam_genericPatchFieldBase_H
40 
41 #include "dictionary.H"
42 #include "primitiveFields.H"
43 #include "HashPtrTable.H"
44 #include "IOobject.H"
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 namespace Foam
49 {
50 
51 /*---------------------------------------------------------------------------*\
52  Class genericPatchFieldBase Declaration
53 \*---------------------------------------------------------------------------*/
54 
56 {
57  // Private Data
58 
59  //- The non-generic patch name
60  word actualTypeName_;
61 
62  //- Copy of the input dictionary (used for transcribing)
63  dictionary dict_;
64 
65 
66  // The data fields read.
67  // Do not need to handle generic for 'label' since these
68  // will be limited to known field types.
69 
70  HashPtrTable<scalarField> scalarFields_;
71  HashPtrTable<vectorField> vectorFields_;
72  HashPtrTable<sphericalTensorField> sphTensorFields_;
73  HashPtrTable<symmTensorField> symmTensorFields_;
74  HashPtrTable<tensorField> tensorFields_;
75 
76 
77  // Private Member Functions
78 
79  bool checkFieldSize
80  (
81  const label fieldSize,
82  const label patchSize,
83  const word& patchName,
84  const keyType& key,
85  const IOobject& io
86  ) const;
87 
88 
89 protected:
90 
91  // Protected Member Functions
92 
93  //- Add error message to FatalError about solving with
94  //- generic condition
96  (
97  const word& patchName,
98  const IOobject& io
99  ) const;
100 
101  //- FatalError for missing entry
102  void reportMissingEntry
103  (
104  const word& entryName,
105  const word& patchName,
106  const IOobject& io
107  ) const;
108 
109  void processGeneric
110  (
111  const label patchSize,
112  const word& patchName,
113  const IOobject& io,
114  const bool separateValue
115  );
116 
117  bool processEntry
118  (
119  const entry& dEntry,
120  const label patchSize,
121  const word& patchName,
122  const IOobject& io
123  );
124 
125  //- Write a single entry, with lookup of hashed values
126  void putEntry(const entry& e, Ostream& os) const;
127 
128  //- Write all generic entries from dictionary,
129  //- optionally treating the "value" entry separately
130  void writeGeneric(Ostream& os, const bool separateValue) const;
131 
132  //- Implementation for construct with mapper
133  template<class MapperType>
134  void mapGeneric
135  (
136  const genericPatchFieldBase& rhs,
137  const MapperType& mapper
138  );
139 
140  //- Implementation for autoMap of self given a mapping object
141  template<class MapperType>
142  void autoMapGeneric(const MapperType& mapper);
143 
144  //- Implementation for reverse map given patch field onto this
145  //- patch field
146  void rmapGeneric
147  (
148  const genericPatchFieldBase& rhs,
149  const labelList& addr
150  );
151 
152 
153  // Constructors
154 
155  //- Partial copy construct. Only copy type and dictionary
157 
158 
159 public:
160 
161  // Constructors
162 
163  //- Default construct, generally not useful.
164  genericPatchFieldBase() = default;
165 
166  //- Copy construct
168 
169  //- Move construct
171 
172  //- Initialize from dictionary
173  explicit genericPatchFieldBase(const dictionary& dict);
174 
175 
176  // Member Functions
177 
178  //- The actual patch type
179  const word& actualType() const noexcept
180  {
181  return actualTypeName_;
182  }
183 };
184 
185 
186 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
187 
188 } // End namespace Foam
189 
190 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
191 
192 #ifdef NoRepository
194 #endif
195 
196 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
197 
198 #endif
199 
200 // ************************************************************************* //
A class for handling keywords in dictionaries.
Definition: keyType.H:66
dictionary dict
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
void writeGeneric(Ostream &os, const bool separateValue) const
Write all generic entries from dictionary, optionally treating the "value" entry separately.
A HashTable of pointers to objects of type <T>, with deallocation management of the pointers...
Definition: HashPtrTable.H:51
bool processEntry(const entry &dEntry, const label patchSize, const word &patchName, const IOobject &io)
void reportMissingEntry(const word &entryName, const word &patchName, const IOobject &io) const
FatalError for missing entry.
const dimensionedScalar e
Elementary charge.
Definition: createFields.H:11
void genericFatalSolveError(const word &patchName, const IOobject &io) const
Add error message to FatalError about solving with generic condition.
A class for handling words, derived from Foam::string.
Definition: word.H:63
void processGeneric(const label patchSize, const word &patchName, const IOobject &io, const bool separateValue)
void mapGeneric(const genericPatchFieldBase &rhs, const MapperType &mapper)
Implementation for construct with mapper.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
const direction noexcept
Definition: Scalar.H:258
void rmapGeneric(const genericPatchFieldBase &rhs, const labelList &addr)
Implementation for reverse map given patch field onto this patch field.
OBJstream os(runTime.globalPath()/outputName)
Generic infrastructure for reading/writing unknown patch types.
const word & actualType() const noexcept
The actual patch type.
Specialisations of Field<T> for scalar, vector and tensor.
void putEntry(const entry &e, Ostream &os) const
Write a single entry, with lookup of hashed values.
void autoMapGeneric(const MapperType &mapper)
Implementation for autoMap of self given a mapping object.
auto key(const Type &t) -> typename std::enable_if< std::is_enum< Type >::value, typename std::underlying_type< Type >::type >::type
Definition: foamGltfBase.H:103
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition: zero.H:57
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, IOobject::NO_REGISTER)
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition: IOobject.H:172
genericPatchFieldBase()=default
Default construct, generally not useful.
Namespace for OpenFOAM.
A keyword and a list of tokens is an &#39;entry&#39;.
Definition: entry.H:63