fvPatchFieldNew.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 {
41  << "patchFieldType = " << patchFieldType
42  << " : " << p.type() << nl;
43 
44  auto* ctorPtr = patchConstructorTable(patchFieldType);
45 
46  if (!ctorPtr)
47  {
49  (
50  "patchField",
51  patchFieldType,
52  *patchConstructorTablePtr_
53  ) << exit(FatalError);
54  }
55 
56  auto* patchTypeCtor = patchConstructorTable(p.type());
57 
58  if
59  (
60  actualPatchType == word::null
61  || actualPatchType != p.type()
62  )
63  {
64  if (patchTypeCtor)
65  {
66  return patchTypeCtor(p, iF);
67  }
68  else
69  {
70  return ctorPtr(p, iF);
71  }
72  }
73 
74 
75  tmp<fvPatchField<Type>> tfvp = ctorPtr(p, iF);
76 
77  // Check if constraint type override and store patchType if so
78  if (patchTypeCtor)
79  {
80  tfvp.ref().patchType() = actualPatchType;
81  }
82  return tfvp;
83 }
84 
85 
86 template<class Type>
88 (
89  const word& patchFieldType,
90  const fvPatch& p,
92 )
93 {
94  return New(patchFieldType, word::null, p, iF);
95 }
96 
97 
98 template<class Type>
100 (
101  const fvPatch& p,
103  const dictionary& dict
104 )
105 {
106  const word patchFieldType(dict.get<word>("type"));
107 
109  << "patchFieldType = " << patchFieldType << nl;
110 
111  auto* ctorPtr = dictionaryConstructorTable(patchFieldType);
112 
113  if (!ctorPtr)
114  {
115  if (!disallowGenericFvPatchField)
116  {
117  ctorPtr = dictionaryConstructorTable("generic");
118  }
119 
120  if (!ctorPtr)
121  {
123  << "Unknown patchField type " << patchFieldType
124  << " for patch type " << p.type() << nl << nl
125  << "Valid patchField types :" << endl
126  << dictionaryConstructorTablePtr_->sortedToc()
127  << exit(FatalIOError);
128  }
129  }
130 
131  if
132  (
133  !dict.found("patchType")
134  || dict.get<word>("patchType") != p.type()
135  )
136  {
137  auto* patchTypeCtor = dictionaryConstructorTable(p.type());
138 
139  if (patchTypeCtor && patchTypeCtor != ctorPtr)
140  {
142  << "inconsistent patch and patchField types for\n"
143  " patch type " << p.type()
144  << " and patchField type " << patchFieldType
145  << exit(FatalIOError);
146  }
147  }
148 
149  return ctorPtr(p, iF, dict);
150 }
151 
152 
153 template<class Type>
155 (
156  const fvPatchField<Type>& ptf,
157  const fvPatch& p,
159  const fvPatchFieldMapper& pfMapper
160 )
161 {
163  << "Constructing fvPatchField<Type>" << nl;
164 
165  auto* ctorPtr = patchMapperConstructorTable(ptf.type());
166 
167  if (!ctorPtr)
168  {
170  (
171  "patchField",
172  ptf.type(),
173  *patchMapperConstructorTablePtr_
174  ) << exit(FatalError);
175  }
176 
177  return ctorPtr(ptf, p, iF, pfMapper);
178 }
179 
180 
181 // ************************************************************************* //
Foam::fvPatchField
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: volSurfaceMapping.H:51
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::FatalIOError
IOerror FatalIOError
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
Foam::tmp::ref
T & ref() const
Definition: tmpI.H:227
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::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::fvPatchField::New
static tmp< fvPatchField< Type > > New(const word &, const fvPatch &, const DimensionedField< Type, volMesh > &)
Return a pointer to a new patchField created on freestore given.
Definition: fvPatchFieldNew.C:88
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