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 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 cstrIter = patchConstructorTablePtr_->cfind(patchFieldType);
43 
44  if (!cstrIter.found())
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 patchTypeCstrIter = patchConstructorTablePtr_->cfind(p.type());
61 
62  if (patchTypeCstrIter.found())
63  {
64  return patchTypeCstrIter()(p, iF);
65  }
66  }
67 
68  return cstrIter()(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 cstrIter = dictionaryConstructorTablePtr_->cfind(patchFieldType);
97 
98  if (!cstrIter.found())
99  {
100  if (!disallowGenericFvsPatchField)
101  {
102  cstrIter = dictionaryConstructorTablePtr_->cfind("generic");
103  }
104 
105  if (!cstrIter.found())
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 patchTypeCstrIter
123  = dictionaryConstructorTablePtr_->cfind(p.type());
124 
125  if (patchTypeCstrIter.found() && patchTypeCstrIter() != cstrIter())
126  {
128  << "inconsistent patch and patchField types for\n"
129  " patch type " << p.type()
130  << " and patchField type " << patchFieldType
131  << exit(FatalIOError);
132  }
133  }
134 
135  return cstrIter()(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 {
148  DebugInFunction << "Constructing fvsPatchField" << endl;
149 
150  auto cstrIter = patchMapperConstructorTablePtr_->cfind(ptf.type());
151 
152  if (!cstrIter.found())
153  {
155  (
156  "patchField",
157  ptf.type(),
158  *patchMapperConstructorTablePtr_
159  ) << exit(FatalError);
160  }
161 
162  auto patchTypeCstrIter = patchMapperConstructorTablePtr_->cfind(p.type());
163 
164  if (patchTypeCstrIter.found())
165  {
166  return patchTypeCstrIter()(ptf, p, iF, pfMapper);
167  }
168 
169  return cstrIter()(ptf, p, iF, pfMapper);
170 }
171 
172 
173 // ************************************************************************* //
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::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:350
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::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: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::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