fvPatchFieldNew.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
27 
28 template<class Type>
30 (
31  const word& patchFieldType,
32  const word& actualPatchType,
33  const fvPatch& p,
35 )
36 {
37  if (debug)
38  {
40  << "patchFieldType = " << patchFieldType
41  << ", actualPatchType = " << actualPatchType
42  << ", patchType = " << p.type()
43  << endl;
44  }
45 
46  typename patchConstructorTable::iterator cstrIter =
47  patchConstructorTablePtr_->find(patchFieldType);
48 
49  if (cstrIter == patchConstructorTablePtr_->end())
50  {
52  << "Unknown patchField type "
53  << patchFieldType << nl << nl
54  << "Valid patchField types are :" << endl
55  << patchConstructorTablePtr_->sortedToc()
56  << exit(FatalError);
57  }
58 
59  if
60  (
61  actualPatchType == word::null
62  || actualPatchType != p.type()
63  )
64  {
65  typename patchConstructorTable::iterator patchTypeCstrIter =
66  patchConstructorTablePtr_->find(p.type());
67 
68  if (patchTypeCstrIter != patchConstructorTablePtr_->end())
69  {
70  return patchTypeCstrIter()(p, iF);
71  }
72  else
73  {
74  return cstrIter()(p, iF);
75  }
76  }
77  else
78  {
79  return cstrIter()(p, iF);
80  }
81 }
82 
83 
84 template<class Type>
86 (
87  const word& patchFieldType,
88  const fvPatch& p,
90 )
91 {
92  return New(patchFieldType, word::null, p, iF);
93 }
94 
95 
96 template<class Type>
98 (
99  const fvPatch& p,
101  const dictionary& dict
102 )
103 {
104  const word patchFieldType(dict.lookup("type"));
105 
106  if (debug)
107  {
109  << "patchFieldType = " << patchFieldType
110  << ", actualPatchType = "
111  << dict.lookupOrDefault<word>("patchType", word::null)
112  << ", patchType = " << p.type()
113  << endl;
114  }
115 
116  typename dictionaryConstructorTable::iterator cstrIter
117  = dictionaryConstructorTablePtr_->find(patchFieldType);
118 
119  if (cstrIter == dictionaryConstructorTablePtr_->end())
120  {
121  if (!disallowGenericFvPatchField)
122  {
123  cstrIter = dictionaryConstructorTablePtr_->find("generic");
124  }
125 
126  if (cstrIter == dictionaryConstructorTablePtr_->end())
127  {
129  (
130  dict
131  ) << "Unknown patchField type " << patchFieldType
132  << " for patch type " << p.type() << nl << nl
133  << "Valid patchField types are :" << endl
134  << dictionaryConstructorTablePtr_->sortedToc()
135  << exit(FatalIOError);
136  }
137  }
138 
139  if
140  (
141  !dict.found("patchType")
142  || word(dict.lookup("patchType")) != p.type()
143  )
144  {
145  typename dictionaryConstructorTable::iterator patchTypeCstrIter
146  = dictionaryConstructorTablePtr_->find(p.type());
147 
148  if
149  (
150  patchTypeCstrIter != dictionaryConstructorTablePtr_->end()
151  && patchTypeCstrIter() != cstrIter()
152  )
153  {
155  (
156  dict
157  ) << "inconsistent patch and patchField types for \n"
158  " patch type " << p.type()
159  << " and patchField type " << patchFieldType
160  << exit(FatalIOError);
161  }
162  }
163 
164  return cstrIter()(p, iF, dict);
165 }
166 
167 
168 template<class Type>
170 (
171  const fvPatchField<Type>& ptf,
172  const fvPatch& p,
174  const fvPatchFieldMapper& pfMapper
175 )
176 {
177  if (debug)
178  {
179  InfoInFunction << "Constructing fvPatchField<Type>" << endl;
180  }
181 
182  typename patchMapperConstructorTable::iterator cstrIter =
183  patchMapperConstructorTablePtr_->find(ptf.type());
184 
185  if (cstrIter == patchMapperConstructorTablePtr_->end())
186  {
188  << "Unknown patchField type " << ptf.type() << nl << nl
189  << "Valid patchField types are :" << endl
190  << patchMapperConstructorTablePtr_->sortedToc()
191  << exit(FatalError);
192  }
193 
194  return cstrIter()(ptf, p, iF, pfMapper);
195 }
196 
197 
198 // ************************************************************************* //
dictionary dict
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
Definition: dictionary.C:663
autoPtr< CompressibleMomentumTransportModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &phi, const viscosity &viscosity)
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
error FatalError
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:306
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:63
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:66
A class for handling words, derived from string.
Definition: word.H:59
Foam::fvPatchFieldMapper.
static tmp< fvPatchField< Type > > New(const word &, const fvPatch &, const DimensionedField< Type, volMesh > &)
Return a pointer to a new patchField created on freestore given.
static const char nl
Definition: Ostream.H:260
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:318
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
volScalarField & p
A class for managing temporary objects.
Definition: PtrList.H:53
word patchFieldType(const PatchField &pf)
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:864
IOerror FatalIOError
#define InfoInFunction
Report an information message using Foam::Info.