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-2021 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 {
40  DebugInFunction << "Constructing fvsPatchField" << endl;
41 
42  auto* ctorPtr = patchConstructorTable(patchFieldType);
43 
44  if (!ctorPtr)
45  {
47  (
48  "patchField",
49  patchFieldType,
50  *patchConstructorTablePtr_
51  ) << exit(FatalError);
52  }
53 
54  if
55  (
56  actualPatchType == word::null
57  || actualPatchType != p.type()
58  )
59  {
60  auto* patchTypeCtor = patchConstructorTable(p.type());
61 
62  if (patchTypeCtor)
63  {
64  return patchTypeCtor(p, iF);
65  }
66  }
67 
68  return ctorPtr(p, iF);
69 }
70 
71 
72 template<class Type>
74 (
75  const word& patchFieldType,
76  const fvPatch& p,
78 )
79 {
80  return New(patchFieldType, word::null, p, iF);
81 }
82 
83 
84 template<class Type>
86 (
87  const fvPatch& p,
89  const dictionary& dict
90 )
91 {
92  DebugInFunction << "Constructing fvsPatchField" << endl;
93 
94  const word patchFieldType(dict.get<word>("type"));
95 
96  auto* ctorPtr = dictionaryConstructorTable(patchFieldType);
97 
98  if (!ctorPtr)
99  {
100  if (!disallowGenericFvsPatchField)
101  {
102  ctorPtr = dictionaryConstructorTable("generic");
103  }
104 
105  if (!ctorPtr)
106  {
108  << "Unknown patchField type " << patchFieldType
109  << " for patch type " << p.type() << nl << nl
110  << "Valid patchField types :" << endl
111  << dictionaryConstructorTablePtr_->sortedToc()
112  << exit(FatalIOError);
113  }
114  }
115 
116  if
117  (
118  !dict.found("patchType")
119  || dict.get<word>("patchType") != p.type()
120  )
121  {
122  auto* patchTypeCtor = dictionaryConstructorTable(p.type());
123 
124  if (patchTypeCtor && patchTypeCtor != ctorPtr)
125  {
127  << "inconsistent patch and patchField types for\n"
128  " patch type " << p.type()
129  << " and patchField type " << patchFieldType
130  << exit(FatalIOError);
131  }
132  }
133 
134  return ctorPtr(p, iF, dict);
135 }
136 
137 
138 template<class Type>
140 (
141  const fvsPatchField<Type>& ptf,
142  const fvPatch& p,
144  const fvPatchFieldMapper& pfMapper
145 )
146 {
147  DebugInFunction << "Constructing fvsPatchField" << endl;
148 
149  auto* ctorPtr = patchMapperConstructorTable(ptf.type());
150 
151  if (!ctorPtr)
152  {
154  (
155  "patchField",
156  ptf.type(),
157  *patchMapperConstructorTablePtr_
158  ) << exit(FatalError);
159  }
160 
161  auto* patchTypeCtor = patchMapperConstructorTable(p.type());
162 
163  if (patchTypeCtor)
164  {
165  return patchTypeCtor(ptf, p, iF, pfMapper);
166  }
167 
168  return ctorPtr(ptf, p, iF, pfMapper);
169 }
170 
171 
172 // ************************************************************************* //
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::fvsPatchField
An abstract base class with a fat-interface to all derived classes covering all possible ways in whic...
Definition: fvsPatchField.H:68
Foam::FatalIOError
IOerror FatalIOError
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
DebugInFunction
#define DebugInFunction
Report an information message using Foam::Info.
Definition: messageStream.H:388
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:65
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::fvsPatchField::New
static tmp< fvsPatchField< Type > > New(const word &, const fvPatch &, const DimensionedField< Type, surfaceMesh > &)
Return a pointer to a new patchField created on freestore given.
Definition: fvsPatchFieldNew.C:74
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
FatalErrorInLookup
#define FatalErrorInLookup(lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalError.
Definition: error.H:457
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
Foam::New
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
Definition: DimensionedFieldReuseFunctions.H:105
Foam::nl
constexpr char nl
Definition: Ostream.H:404
FatalIOErrorInFunction
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:473
Foam::fvPatchFieldMapper
Foam::fvPatchFieldMapper.
Definition: fvPatchFieldMapper.H:47
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:54