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-2020 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 cstrIter = patchConstructorTablePtr_->cfind(patchFieldType);
45 
46  if (!cstrIter.found())
47  {
49  (
50  "patchField",
51  patchFieldType,
52  *patchConstructorTablePtr_
53  ) << exit(FatalError);
54  }
55 
56  auto patchTypeCstrIter = patchConstructorTablePtr_->cfind(p.type());
57 
58  if
59  (
60  actualPatchType == word::null
61  || actualPatchType != p.type()
62  )
63  {
64  if (patchTypeCstrIter.found())
65  {
66  return patchTypeCstrIter()(p, iF);
67  }
68  else
69  {
70  return cstrIter()(p, iF);
71  }
72  }
73 
74 
75  tmp<fvPatchField<Type>> tfvp = cstrIter()(p, iF);
76 
77  // Check if constraint type override and store patchType if so
78  if (patchTypeCstrIter.found())
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 cstrIter = dictionaryConstructorTablePtr_->cfind(patchFieldType);
112 
113  if (!cstrIter.found())
114  {
115  if (!disallowGenericFvPatchField)
116  {
117  cstrIter = dictionaryConstructorTablePtr_->cfind("generic");
118  }
119 
120  if (!cstrIter.found())
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 patchTypeCstrIter
138  = dictionaryConstructorTablePtr_->cfind(p.type());
139 
140  if (patchTypeCstrIter.found() && patchTypeCstrIter() != cstrIter())
141  {
143  << "inconsistent patch and patchField types for\n"
144  " patch type " << p.type()
145  << " and patchField type " << patchFieldType
146  << exit(FatalIOError);
147  }
148  }
149 
150  return cstrIter()(p, iF, dict);
151 }
152 
153 
154 template<class Type>
156 (
157  const fvPatchField<Type>& ptf,
158  const fvPatch& p,
160  const fvPatchFieldMapper& pfMapper
161 )
162 {
164  << "Constructing fvPatchField<Type>" << nl;
165 
166  auto cstrIter = patchMapperConstructorTablePtr_->cfind(ptf.type());
167 
168  if (!cstrIter.found())
169  {
171  (
172  "patchField",
173  ptf.type(),
174  *patchMapperConstructorTablePtr_
175  ) << exit(FatalError);
176  }
177 
178  return cstrIter()(ptf, p, iF, pfMapper);
179 }
180 
181 
182 // ************************************************************************* //
Foam::fvPatchField
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: volSurfaceMapping.H:50
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:61
Foam::FatalIOError
IOerror FatalIOError
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:350
Foam::tmp::ref
T & ref() const
Definition: tmpI.H:228
DebugInFunction
#define DebugInFunction
Report an information message using Foam::Info.
Definition: messageStream.H:365
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:121
FatalErrorInLookup
#define FatalErrorInLookup(lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalError.
Definition: error.H:385
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:385
FatalIOErrorInFunction
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:401
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