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-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  libs.open
118  (
119  dict,
120  "libs",
121  dictionaryConstructorTablePtr_
122  );
123 
124  typename dictionaryConstructorTable::iterator cstrIter
125  = dictionaryConstructorTablePtr_->find(patchFieldType);
126 
127  if (cstrIter == dictionaryConstructorTablePtr_->end())
128  {
129  if (!disallowGenericFvPatchField)
130  {
131  cstrIter = dictionaryConstructorTablePtr_->find("generic");
132  }
133 
134  if (cstrIter == dictionaryConstructorTablePtr_->end())
135  {
137  (
138  dict
139  ) << "Unknown patchField type " << patchFieldType
140  << " for patch " << p.name() << " of type " << p.type()
141  << " for field " << iF.name() << nl << nl
142  << "Valid patchField types are :" << endl
143  << dictionaryConstructorTablePtr_->sortedToc()
144  << exit(FatalIOError);
145  }
146  }
147 
148  if
149  (
150  !dict.found("patchType")
151  || word(dict.lookup("patchType")) != p.type()
152  )
153  {
154  typename dictionaryConstructorTable::iterator patchTypeCstrIter
155  = dictionaryConstructorTablePtr_->find(p.type());
156 
157  if
158  (
159  patchTypeCstrIter != dictionaryConstructorTablePtr_->end()
160  && patchTypeCstrIter() != cstrIter()
161  )
162  {
164  (
165  dict
166  ) << "inconsistent patch and patchField types for \n"
167  " patch type " << p.type()
168  << " and patchField type " << patchFieldType
169  << " for field " << iF.name()
170  << exit(FatalIOError);
171  }
172  }
173 
174  return cstrIter()(p, iF, dict);
175 }
176 
177 
178 template<class Type>
180 (
181  const fvPatchField<Type>& ptf,
182  const fvPatch& p,
184  const fieldMapper& pfMapper
185 )
186 {
187  if (debug)
188  {
189  InfoInFunction << "Constructing fvPatchField<Type>" << endl;
190  }
191 
192  typename patchMapperConstructorTable::iterator cstrIter =
193  patchMapperConstructorTablePtr_->find(ptf.type());
194 
195  if (cstrIter == patchMapperConstructorTablePtr_->end())
196  {
198  << "Unknown patchField type " << ptf.type()
199  << " for patch " << p.name() << " of type " << p.type()
200  << " for field " << iF.name() << nl << nl
201  << "Valid patchField types are :" << endl
202  << patchMapperConstructorTablePtr_->sortedToc()
203  << exit(FatalError);
204  }
205 
206  return cstrIter()(ptf, p, iF, pfMapper);
207 }
208 
209 
210 // ************************************************************************* //
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
bool open(const fileName &libName, const bool verbose=true)
Open the named library, optionally with warnings if problems occur.
Abstract base class for field mapping.
Definition: fieldMapper.H:48
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:88
static tmp< fvPatchField< Type > > New(const word &, const fvPatch &, const DimensionedField< Type, volMesh > &)
Return a pointer to a new patchField created on freestore given.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:64
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
dlLibraryTable libs
Table of loaded dynamic libraries.
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