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-2013 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  {
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  (
54  "fvPatchField<Type>::New(const word&, const word&, const fvPatch&,"
55  "const DimensionedField<Type, volMesh>&)"
56  ) << "Unknown patchField type "
57  << patchFieldType << nl << nl
58  << "Valid patchField types are :" << endl
59  << patchConstructorTablePtr_->sortedToc()
60  << exit(FatalError);
61  }
62 
63  typename patchConstructorTable::iterator patchTypeCstrIter =
64  patchConstructorTablePtr_->find(p.type());
65 
66  if
67  (
68  actualPatchType == word::null
69  || actualPatchType != p.type()
70  )
71  {
72  if (patchTypeCstrIter != patchConstructorTablePtr_->end())
73  {
74  return patchTypeCstrIter()(p, iF);
75  }
76  else
77  {
78  return cstrIter()(p, iF);
79  }
80  }
81  else
82  {
83  tmp<fvPatchField<Type> > tfvp = cstrIter()(p, iF);
84 
85  // Check if constraint type override and store patchType if so
86  if ((patchTypeCstrIter != patchConstructorTablePtr_->end()))
87  {
88  tfvp().patchType() = actualPatchType;
89  }
90  return tfvp;
91  }
92 }
93 
94 
95 template<class Type>
97 (
98  const word& patchFieldType,
99  const fvPatch& p,
101 )
102 {
103  return New(patchFieldType, word::null, p, iF);
104 }
105 
106 
107 template<class Type>
109 (
110  const fvPatch& p,
112  const dictionary& dict
113 )
114 {
115  const word patchFieldType(dict.lookup("type"));
116 
117  if (debug)
118  {
119  Info<< "fvPatchField<Type>::New(const fvPatch&, "
120  "const DimensionedField<Type, volMesh>&, "
121  "const dictionary&) : patchFieldType=" << patchFieldType
122  << endl;
123  }
124 
125  typename dictionaryConstructorTable::iterator cstrIter
126  = dictionaryConstructorTablePtr_->find(patchFieldType);
127 
128  if (cstrIter == dictionaryConstructorTablePtr_->end())
129  {
130  if (!disallowGenericFvPatchField)
131  {
132  cstrIter = dictionaryConstructorTablePtr_->find("generic");
133  }
134 
135  if (cstrIter == dictionaryConstructorTablePtr_->end())
136  {
138  (
139  "fvPatchField<Type>::New(const fvPatch&, "
140  "const DimensionedField<Type, volMesh>&, "
141  "const dictionary&)",
142  dict
143  ) << "Unknown patchField type " << patchFieldType
144  << " for patch type " << p.type() << nl << nl
145  << "Valid patchField types are :" << endl
146  << dictionaryConstructorTablePtr_->sortedToc()
147  << exit(FatalIOError);
148  }
149  }
150 
151  if
152  (
153  !dict.found("patchType")
154  || word(dict.lookup("patchType")) != p.type()
155  )
156  {
157  typename dictionaryConstructorTable::iterator patchTypeCstrIter
158  = dictionaryConstructorTablePtr_->find(p.type());
159 
160  if
161  (
162  patchTypeCstrIter != dictionaryConstructorTablePtr_->end()
163  && patchTypeCstrIter() != cstrIter()
164  )
165  {
167  (
168  "fvPatchField<Type>::New(const fvPatch&, "
169  "const DimensionedField<Type, volMesh>&, "
170  "const dictionary&)",
171  dict
172  ) << "inconsistent patch and patchField types for \n"
173  " patch type " << p.type()
174  << " and patchField type " << patchFieldType
175  << exit(FatalIOError);
176  }
177  }
178 
179  return cstrIter()(p, iF, dict);
180 }
181 
182 
183 template<class Type>
185 (
186  const fvPatchField<Type>& ptf,
187  const fvPatch& p,
189  const fvPatchFieldMapper& pfMapper
190 )
191 {
192  if (debug)
193  {
194  Info<< "fvPatchField<Type>::New(const fvPatchField<Type>&, "
195  "const fvPatch&, const DimensionedField<Type, volMesh>&, "
196  "const fvPatchFieldMapper&) : "
197  "constructing fvPatchField<Type>"
198  << endl;
199  }
200 
201  typename patchMapperConstructorTable::iterator cstrIter =
202  patchMapperConstructorTablePtr_->find(ptf.type());
203 
204  if (cstrIter == patchMapperConstructorTablePtr_->end())
205  {
207  (
208  "fvPatchField<Type>::New(const fvPatchField<Type>&, "
209  "const fvPatch&, const DimensionedField<Type, volMesh>&, "
210  "const fvPatchFieldMapper&)"
211  ) << "Unknown patchField type " << ptf.type() << nl << nl
212  << "Valid patchField types are :" << endl
213  << patchMapperConstructorTablePtr_->sortedToc()
214  << exit(FatalError);
215  }
216 
217  return cstrIter()(ptf, p, iF, pfMapper);
218 }
219 
220 
221 // ************************************************************************* //
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
Definition: dictionary.C:306
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
A class for handling words, derived from string.
Definition: word.H:59
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
Foam::fvPatchFieldMapper.
messageStream Info
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
autoPtr< BasicCompressibleTurbulenceModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &phi, const typename BasicCompressibleTurbulenceModel::transportModel &transport, const word &propertiesName)
static tmp< fvPatchField< Type > > New(const word &, const fvPatch &, const DimensionedField< Type, volMesh > &)
Return a pointer to a new patchField created on freestore given.
dictionary dict
static const char nl
Definition: Ostream.H:260
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
IOerror FatalIOError
volScalarField & p
Definition: createFields.H:51
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:65
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
Definition: error.H:314
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:452
error FatalError
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
#define FatalIOErrorIn(functionName, ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:325
A class for managing temporary objects.
Definition: PtrList.H:118