fvsPatchFieldNew.C
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) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2019-2022 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
30 
31 template<class Type>
33 (
34  const word& patchFieldType,
35  const word& actualPatchType,
36  const fvPatch& p,
38 )
39 {
41  << "patchFieldType = " << patchFieldType
42  << " [" << actualPatchType
43  << "] : " << p.type() << " name = " << p.name() << endl;
44 
45  auto* ctorPtr = patchConstructorTable(patchFieldType);
46 
47  if (!ctorPtr)
48  {
50  (
51  "patchField",
52  patchFieldType,
53  *patchConstructorTablePtr_
54  ) << exit(FatalError);
55  }
56 
57  if (actualPatchType.empty() || actualPatchType != p.type())
58  {
59  auto* patchTypeCtor = patchConstructorTable(p.type());
60 
61  if (patchTypeCtor)
62  {
63  return patchTypeCtor(p, iF);
64  }
65  }
66 
67  return ctorPtr(p, iF);
68 }
69 
70 
71 template<class Type>
73 (
74  const word& patchFieldType,
75  const fvPatch& p,
77 )
78 {
79  return New(patchFieldType, word::null, p, iF);
80 }
81 
82 
83 template<class Type>
85 (
86  const fvPatch& p,
88  const dictionary& dict
89 )
90 {
91  const word patchFieldType(dict.get<word>("type"));
92 
93  word actualPatchType;
94  dict.readIfPresent("patchType", actualPatchType, keyType::LITERAL);
95 
97  << "patchFieldType = " << patchFieldType
98  << " [" << actualPatchType
99  << "] : " << p.type() << " name = " << p.name() << endl;
100 
101  auto* ctorPtr = dictionaryConstructorTable(patchFieldType);
102 
103  if (!ctorPtr)
104  {
105  if (!fvsPatchFieldBase::disallowGenericPatchField)
106  {
107  ctorPtr = dictionaryConstructorTable("generic");
108  }
109 
110  if (!ctorPtr)
111  {
113  << "Unknown patchField type " << patchFieldType
114  << " for patch type " << p.type() << nl << nl
115  << "Valid patchField types :" << endl
116  << dictionaryConstructorTablePtr_->sortedToc()
117  << exit(FatalIOError);
118  }
119  }
120 
121  if (actualPatchType.empty() || actualPatchType != p.type())
122  {
123  auto* patchTypeCtor = dictionaryConstructorTable(p.type());
124 
125  if (patchTypeCtor && patchTypeCtor != ctorPtr)
126  {
128  << "inconsistent patch and patchField types for\n"
129  " patch type " << p.type()
130  << " and patchField type " << patchFieldType
131  << exit(FatalIOError);
132  }
133  }
135  return ctorPtr(p, iF, dict);
136 }
137 
138 
139 template<class Type>
141 (
142  const fvsPatchField<Type>& ptf,
143  const fvPatch& p,
145  const fvPatchFieldMapper& pfMapper
146 )
147 {
149  << "patchFieldType = " << ptf.type()
150  << " : " << p.type() << " name = " << p.name() << endl;
151 
152  auto* ctorPtr = patchMapperConstructorTable(ptf.type());
153 
154  if (!ctorPtr)
155  {
157  (
158  "patchField",
159  ptf.type(),
160  *patchMapperConstructorTablePtr_
161  ) << exit(FatalError);
162  }
163 
164  auto* patchTypeCtor = patchMapperConstructorTable(p.type());
165 
166  if (patchTypeCtor)
167  {
168  return patchTypeCtor(ptf, p, iF, pfMapper);
169  }
170 
171  return ctorPtr(ptf, p, iF, pfMapper);
172 }
173 
174 
175 // ************************************************************************* //
dictionary dict
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:125
error FatalError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL ERROR&#39; header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
constexpr char nl
The newline &#39;\n&#39; character (0x0a)
Definition: Ostream.H:50
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:531
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:70
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
#define FatalErrorInLookup(lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalError.
Definition: error.H:605
A class for handling words, derived from Foam::string.
Definition: word.H:63
#define DebugInFunction
Report an information message using Foam::Info.
A FieldMapper for finite-volume patch fields.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:627
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: areaFieldsFwd.H:42
volScalarField & p
A class for managing temporary objects.
Definition: HashPtrTable.H:50
An abstract base class with a fat-interface to all derived classes covering all possible ways in whic...
static tmp< fvsPatchField< Type > > New(const word &patchFieldType, const fvPatch &, const DimensionedField< Type, surfaceMesh > &)
Return a pointer to a new patchField created on freestore given.
IOerror FatalIOError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL IO ERROR&#39; header text and ...