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