fvsPatchFieldNew.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-2023 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 null-constructable patchField type " << patchFieldType
53  << " for patch " << p.name() << " of type " << p.type()
54  << " for field " << iF.name() << nl << nl
55  << "Valid null-constructable patchField types are :" << endl
56  << patchConstructorTablePtr_->sortedToc()
57  << abort(FatalError);
58  }
59 
60  if
61  (
62  actualPatchType == word::null
63  || actualPatchType != p.type()
64  )
65  {
66  typename patchConstructorTable::iterator patchTypeCstrIter =
67  patchConstructorTablePtr_->find(p.type());
68 
69  if (patchTypeCstrIter != patchConstructorTablePtr_->end())
70  {
71  return patchTypeCstrIter()(p, iF);
72  }
73  else
74  {
75  return cstrIter()(p, iF);
76  }
77  }
78  else
79  {
80  return cstrIter()(p, iF);
81  }
82 }
83 
84 
85 template<class Type>
87 (
88  const word& patchFieldType,
89  const fvPatch& p,
91 )
92 {
93  return New(patchFieldType, word::null, p, iF);
94 }
95 
96 
97 template<class Type>
99 (
100  const fvPatch& p,
102  const dictionary& dict
103 )
104 {
105  const word patchFieldType(dict.lookup("type"));
106 
107  if (debug)
108  {
110  << "patchFieldType = " << patchFieldType
111  << ", actualPatchType = "
112  << dict.lookupOrDefault<word>("patchType", word::null)
113  << ", patchType = " << p.type()
114  << endl;
115  }
116 
117  typename dictionaryConstructorTable::iterator cstrIter
118  = dictionaryConstructorTablePtr_->find(patchFieldType);
119 
120  if (cstrIter == dictionaryConstructorTablePtr_->end())
121  {
122  if (!disallowGenericFvsPatchField)
123  {
124  cstrIter = dictionaryConstructorTablePtr_->find("generic");
125  }
126 
127  if (cstrIter == dictionaryConstructorTablePtr_->end())
128  {
130  (
131  dict
132  ) << "Unknown patchField type " << patchFieldType
133  << " for patch " << p.name() << " of type " << p.type()
134  << " for field " << iF.name() << nl << nl
135  << "Valid patchField types are :" << endl
136  << dictionaryConstructorTablePtr_->sortedToc()
137  << exit(FatalIOError);
138  }
139  }
140 
141  if
142  (
143  !dict.found("patchType")
144  || word(dict.lookup("patchType")) != p.type()
145  )
146  {
147  typename dictionaryConstructorTable::iterator patchTypeCstrIter
148  = dictionaryConstructorTablePtr_->find(p.type());
149 
150  if
151  (
152  patchTypeCstrIter != dictionaryConstructorTablePtr_->end()
153  && patchTypeCstrIter() != cstrIter()
154  )
155  {
157  (
158  dict
159  ) << "inconsistent patch and patchField types for \n"
160  " patch type " << p.type()
161  << " and patchField type " << patchFieldType
162  << " for field " << iF.name()
163  << exit(FatalIOError);
164  }
165  }
166 
167  return cstrIter()(p, iF, dict);
168 }
169 
170 
171 template<class Type>
173 (
174  const fvsPatchField<Type>& ptf,
175  const fvPatch& p,
177  const fieldMapper& pfMapper
178 )
179 {
180  if (debug)
181  {
182  InfoInFunction << "Constructing fvsPatchField<Type>" << endl;
183  }
184 
185  typename patchMapperConstructorTable::iterator cstrIter =
186  patchMapperConstructorTablePtr_->find(ptf.type());
187 
188  if (cstrIter == patchMapperConstructorTablePtr_->end())
189  {
191  << "Unknown patchField type " << ptf.type()
192  << " for patch " << p.name() << " of type " << p.type()
193  << " for field " << iF.name() << nl << nl
194  << "Valid patchField types are :" << endl
195  << patchMapperConstructorTablePtr_->sortedToc()
196  << exit(FatalError);
197  }
198 
199  return cstrIter()(ptf, p, iF, pfMapper);
200 }
201 
202 
203 // ************************************************************************* //
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
const word & name() const
Return name.
Definition: IOobject.H:310
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
Abstract base class for field mapping.
Definition: fieldMapper.H:48
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:64
An abstract base class with a fat-interface to all derived classes covering all possible ways in whic...
Definition: fvsPatchField.H:83
static tmp< fvsPatchField< Type > > New(const word &, const fvPatch &, const DimensionedField< Type, surfaceMesh > &)
Return a pointer to a new patchField created on freestore given.
A class for managing temporary objects.
Definition: tmp.H:55
A class for handling words, derived from string.
Definition: word.H:62
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:346
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
#define InfoInFunction
Report an information message using Foam::Info.
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
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:257
errorManip< error > abort(error &err)
Definition: errorManip.H:131
word patchFieldType(const PatchField &pf)
IOerror FatalIOError
error FatalError
static const char nl
Definition: Ostream.H:266
dictionary dict
volScalarField & p