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 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  if (debug)
41  {
43  << "patchFieldType = " << patchFieldType
44  << " : " << p.type()
45  << endl;
46  }
47 
48  auto cstrIter = patchConstructorTablePtr_->cfind(patchFieldType);
49 
50  if (!cstrIter.found())
51  {
53  (
54  "patchField",
55  patchFieldType,
56  *patchConstructorTablePtr_
57  ) << exit(FatalError);
58  }
59 
60  auto patchTypeCstrIter = patchConstructorTablePtr_->cfind(p.type());
61 
62  if
63  (
64  actualPatchType == word::null
65  || actualPatchType != p.type()
66  )
67  {
68  if (patchTypeCstrIter.found())
69  {
70  return patchTypeCstrIter()(p, iF);
71  }
72  else
73  {
74  return cstrIter()(p, iF);
75  }
76  }
77 
78 
79  tmp<fvPatchField<Type>> tfvp = cstrIter()(p, iF);
80 
81  // Check if constraint type override and store patchType if so
82  if (patchTypeCstrIter.found())
83  {
84  tfvp.ref().patchType() = actualPatchType;
85  }
86  return tfvp;
87 }
88 
89 
90 template<class Type>
92 (
93  const word& patchFieldType,
94  const fvPatch& p,
96 )
97 {
98  return New(patchFieldType, word::null, p, iF);
99 }
100 
101 
102 template<class Type>
104 (
105  const fvPatch& p,
107  const dictionary& dict
108 )
109 {
110  const word patchFieldType(dict.get<word>("type"));
111 
112  if (debug)
113  {
115  << "patchFieldType = " << patchFieldType
116  << endl;
117  }
118 
119  auto cstrIter = dictionaryConstructorTablePtr_->cfind(patchFieldType);
120 
121  if (!cstrIter.found())
122  {
123  if (!disallowGenericFvPatchField)
124  {
125  cstrIter = dictionaryConstructorTablePtr_->cfind("generic");
126  }
127 
128  if (!cstrIter.found())
129  {
131  << "Unknown patchField type " << patchFieldType
132  << " for patch type " << p.type() << nl << nl
133  << "Valid patchField types :" << endl
134  << dictionaryConstructorTablePtr_->sortedToc()
135  << exit(FatalIOError);
136  }
137  }
138 
139  if
140  (
141  !dict.found("patchType")
142  || dict.get<word>("patchType") != p.type()
143  )
144  {
145  auto patchTypeCstrIter
146  = dictionaryConstructorTablePtr_->cfind(p.type());
147 
148  if (patchTypeCstrIter.found() && patchTypeCstrIter() != cstrIter())
149  {
151  << "inconsistent patch and patchField types for\n"
152  " patch type " << p.type()
153  << " and patchField type " << patchFieldType
154  << exit(FatalIOError);
155  }
156  }
157 
158  return cstrIter()(p, iF, dict);
159 }
160 
161 
162 template<class Type>
164 (
165  const fvPatchField<Type>& ptf,
166  const fvPatch& p,
168  const fvPatchFieldMapper& pfMapper
169 )
170 {
171  if (debug)
172  {
173  InfoInFunction << "Constructing fvPatchField<Type>" << endl;
174  }
175 
176  auto cstrIter = patchMapperConstructorTablePtr_->cfind(ptf.type());
177 
178  if (!cstrIter.found())
179  {
181  (
182  "patchField",
183  ptf.type(),
184  *patchMapperConstructorTablePtr_
185  ) << exit(FatalError);
186  }
187 
188  return cstrIter()(ptf, p, iF, pfMapper);
189 }
190 
191 
192 // ************************************************************************* //
Foam::expressions::patchExpr::debug
int debug
Static debugging option.
Foam::fvPatchField
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: volSurfaceMapping.H:50
InfoInFunction
#define InfoInFunction
Report an information message using Foam::Info.
Definition: messageStream.H:316
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:59
Foam::FatalIOError
IOerror FatalIOError
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:337
Foam::tmp::ref
T & ref() const
Definition: tmpI.H:258
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:63
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:121
FatalErrorInLookup
#define FatalErrorInLookup(lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalError.
Definition: error.H:359
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:92
Foam::nl
constexpr char nl
Definition: Ostream.H:372
FatalIOErrorInFunction
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:375
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