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 | Copyright (C) 2011-2015 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,
34  const DimensionedField<Type, volMesh>& iF
35 )
36 {
37  if (debug)
38  {
39  Info<< "fvPatchField<Type>::New(const word&, const word&, "
40  "const fvPatch&, const DimensionedField<Type, volMesh>&) :"
41  " patchFieldType="
42  << patchFieldType
43  << " : " << p.type()
44  << endl;
45  }
46 
47  typename patchConstructorTable::iterator cstrIter =
48  patchConstructorTablePtr_->find(patchFieldType);
49 
50  if (cstrIter == patchConstructorTablePtr_->end())
51  {
53  << "Unknown patchField type "
54  << patchFieldType << nl << nl
55  << "Valid patchField types are :" << endl
56  << patchConstructorTablePtr_->sortedToc()
57  << exit(FatalError);
58  }
59 
60  typename patchConstructorTable::iterator patchTypeCstrIter =
61  patchConstructorTablePtr_->find(p.type());
62 
63  if
64  (
65  actualPatchType == word::null
66  || actualPatchType != p.type()
67  )
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  tmp<fvPatchField<Type> > tfvp = cstrIter()(p, iF);
81 
82  // Check if constraint type override and store patchType if so
83  if ((patchTypeCstrIter != patchConstructorTablePtr_->end()))
84  {
85  tfvp().patchType() = actualPatchType;
86  }
87  return tfvp;
88  }
89 }
90 
91 
92 template<class Type>
94 (
95  const word& patchFieldType,
96  const fvPatch& p,
97  const DimensionedField<Type, volMesh>& iF
98 )
99 {
100  return New(patchFieldType, word::null, p, iF);
101 }
102 
103 
104 template<class Type>
106 (
107  const fvPatch& p,
108  const DimensionedField<Type, volMesh>& iF,
109  const dictionary& dict
110 )
111 {
112  const word patchFieldType(dict.lookup("type"));
113 
114  if (debug)
115  {
116  Info<< "fvPatchField<Type>::New(const fvPatch&, "
117  "const DimensionedField<Type, volMesh>&, "
118  "const dictionary&) : patchFieldType=" << patchFieldType
119  << endl;
120  }
121 
122  typename dictionaryConstructorTable::iterator cstrIter
123  = dictionaryConstructorTablePtr_->find(patchFieldType);
124 
125  if (cstrIter == dictionaryConstructorTablePtr_->end())
126  {
127  if (!disallowGenericFvPatchField)
128  {
129  cstrIter = dictionaryConstructorTablePtr_->find("generic");
130  }
131 
132  if (cstrIter == dictionaryConstructorTablePtr_->end())
133  {
135  (
136  dict
137  ) << "Unknown patchField type " << patchFieldType
138  << " for patch type " << p.type() << nl << nl
139  << "Valid patchField types are :" << endl
140  << dictionaryConstructorTablePtr_->sortedToc()
141  << exit(FatalIOError);
142  }
143  }
144 
145  if
146  (
147  !dict.found("patchType")
148  || word(dict.lookup("patchType")) != p.type()
149  )
150  {
151  typename dictionaryConstructorTable::iterator patchTypeCstrIter
152  = dictionaryConstructorTablePtr_->find(p.type());
153 
154  if
155  (
156  patchTypeCstrIter != dictionaryConstructorTablePtr_->end()
157  && patchTypeCstrIter() != cstrIter()
158  )
159  {
161  (
162  dict
163  ) << "inconsistent patch and patchField types for \n"
164  " patch type " << p.type()
165  << " and patchField type " << patchFieldType
166  << exit(FatalIOError);
167  }
168  }
169 
170  return cstrIter()(p, iF, dict);
171 }
172 
173 
174 template<class Type>
176 (
177  const fvPatchField<Type>& ptf,
178  const fvPatch& p,
179  const DimensionedField<Type, volMesh>& iF,
180  const fvPatchFieldMapper& pfMapper
181 )
182 {
183  if (debug)
184  {
185  Info<< "fvPatchField<Type>::New(const fvPatchField<Type>&, "
186  "const fvPatch&, const DimensionedField<Type, volMesh>&, "
187  "const fvPatchFieldMapper&) : "
188  "constructing fvPatchField<Type>"
189  << 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() << nl << nl
199  << "Valid patchField types are :" << endl
200  << patchMapperConstructorTablePtr_->sortedToc()
201  << exit(FatalError);
202  }
203 
204  return cstrIter()(ptf, p, iF, pfMapper);
205 }
206 
207 
208 // ************************************************************************* //
p
p
Definition: pEqn.H:62
Foam::compressible::New
autoPtr< BasicCompressibleTurbulenceModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &phi, const typename BasicCompressibleTurbulenceModel::transportModel &transport, const word &propertiesName)
Definition: turbulentFluidThermoModel.C:36
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:118
Foam::FatalIOError
IOerror FatalIOError
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::nl
static const char nl
Definition: Ostream.H:260
Foam::Info
messageStream Info
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::FatalError
error FatalError
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.
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:318
FatalIOErrorInFunction
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:330