fvsPatchFieldNew.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 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 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
27 
28 namespace Foam
29 {
30 
31 // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
32 
33 template<class Type>
34 tmp<fvsPatchField<Type> > fvsPatchField<Type>::New
35 (
36  const word& patchFieldType,
37  const word& actualPatchType,
38  const fvPatch& p,
40 )
41 {
42  if (debug)
43  {
44  Info<< "fvsPatchField<Type>::New(const word&, const word&"
45  ", const fvPatch&, const Field<Type>&) : "
46  "constructing fvsPatchField<Type>"
47  << endl;
48  }
49 
50  typename patchConstructorTable::iterator cstrIter =
51  patchConstructorTablePtr_->find(patchFieldType);
52 
53  if (cstrIter == patchConstructorTablePtr_->end())
54  {
56  (
57  "fvsPatchField<Type>::New(const word&, const word&, const fvPatch&"
58  ", const Field<Type>&)"
59  ) << "Unknown patchField type "
60  << patchFieldType << nl << nl
61  << "Valid patchField types are :" << endl
62  << patchConstructorTablePtr_->sortedToc()
63  << exit(FatalError);
64  }
65 
66  if
67  (
68  actualPatchType == word::null
69  || actualPatchType != p.type()
70  )
71  {
72  typename patchConstructorTable::iterator patchTypeCstrIter =
73  patchConstructorTablePtr_->find(p.type());
74 
75  if (patchTypeCstrIter != patchConstructorTablePtr_->end())
76  {
77  return patchTypeCstrIter()(p, iF);
78  }
79  else
80  {
81  return cstrIter()(p, iF);
82  }
83  }
84  else
85  {
86  return cstrIter()(p, iF);
87  }
88 }
89 
90 
91 template<class Type>
93 (
94  const word& patchFieldType,
95  const fvPatch& p,
97 )
98 {
99  return New(patchFieldType, word::null, p, iF);
100 }
101 
102 
103 template<class Type>
105 (
106  const fvPatch& p,
108  const dictionary& dict
109 )
110 {
111  if (debug)
112  {
113  Info<< "fvsPatchField<Type>::New(const fvPatch&, const Field<Type>&, "
114  "const dictionary&) : "
115  "constructing fvsPatchField<Type>"
116  << endl;
117  }
118 
119  const word patchFieldType(dict.lookup("type"));
120 
121  typename dictionaryConstructorTable::iterator cstrIter
122  = dictionaryConstructorTablePtr_->find(patchFieldType);
123 
124  if (cstrIter == dictionaryConstructorTablePtr_->end())
125  {
126  if (!disallowGenericFvsPatchField)
127  {
128  cstrIter = dictionaryConstructorTablePtr_->find("generic");
129  }
130 
131  if (cstrIter == dictionaryConstructorTablePtr_->end())
132  {
134  (
135  "fvsPatchField<Type>::New(const fvPatch&, const Field<Type>&, "
136  "const dictionary&)",
137  dict
138  ) << "Unknown patchField type " << patchFieldType
139  << " for patch type " << p.type() << nl << nl
140  << "Valid patchField types are :" << endl
141  << dictionaryConstructorTablePtr_->sortedToc()
142  << exit(FatalIOError);
143  }
144  }
145 
146  if
147  (
148  !dict.found("patchType")
149  || word(dict.lookup("patchType")) != p.type()
150  )
151  {
152  typename dictionaryConstructorTable::iterator patchTypeCstrIter
153  = dictionaryConstructorTablePtr_->find(p.type());
154 
155  if
156  (
157  patchTypeCstrIter != dictionaryConstructorTablePtr_->end()
158  && patchTypeCstrIter() != cstrIter()
159  )
160  {
162  (
163  "fvsPatchField<Type>const fvPatch&, const Field<Type>&, "
164  "const dictionary&)",
165  dict
166  ) << "inconsistent patch and patchField types for \n"
167  " patch type " << p.type()
168  << " and patchField type " << patchFieldType
169  << exit(FatalIOError);
170  }
171  }
172 
173  return cstrIter()(p, iF, dict);
174 }
175 
176 
177 // Return a pointer to a new patch created on freestore from
178 // a given fvsPatchField<Type> mapped onto a new patch
179 template<class Type>
181 (
182  const fvsPatchField<Type>& ptf,
183  const fvPatch& p,
185  const fvPatchFieldMapper& pfMapper
186 )
187 {
188  if (debug)
189  {
190  Info<< "fvsPatchField<Type>::New(const fvsPatchField<Type>&,"
191  " const fvPatch&, const Field<Type>&, "
192  "const fvPatchFieldMapper&) : "
193  "constructing fvsPatchField<Type>"
194  << endl;
195  }
196 
197  typename patchMapperConstructorTable::iterator cstrIter =
198  patchMapperConstructorTablePtr_->find(ptf.type());
199 
200  if (cstrIter == patchMapperConstructorTablePtr_->end())
201  {
203  (
204  "fvsPatchField<Type>::New(const fvsPatchField<Type>&, "
205  "const fvPatch&, const Field<Type>&, "
206  "const fvPatchFieldMapper&)"
207  ) << "Unknown patchField type " << ptf.type() << nl << nl
208  << "Valid patchField types are :" << endl
209  << patchMapperConstructorTablePtr_->sortedToc()
210  << exit(FatalError);
211  }
212 
213  typename patchMapperConstructorTable::iterator
214  patchTypeCstrIter = patchMapperConstructorTablePtr_->find(p.type());
215 
216  if (patchTypeCstrIter != patchMapperConstructorTablePtr_->end())
217  {
218  return patchTypeCstrIter()(ptf, p, iF, pfMapper);
219  }
220  else
221  {
222  return cstrIter()(ptf, p, iF, pfMapper);
223  }
224 }
225 
226 
227 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
228 
229 } // End namespace Foam
230 
231 // ************************************************************************* //
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
Namespace for OpenFOAM.
autoPtr< BasicCompressibleTurbulenceModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &phi, const typename BasicCompressibleTurbulenceModel::transportModel &transport, const word &propertiesName)
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
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
Definition: error.H:314
static tmp< fvsPatchField< Type > > New(const word &, const fvPatch &, const DimensionedField< Type, surfaceMesh > &)
Return a pointer to a new patchField created on freestore given.
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
An abstract base class with a fat-interface to all derived classes covering all possible ways in whic...
Definition: fvsPatchField.H:65
static const word null
An empty word.
Definition: word.H:77