pointPatchFieldNew.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield |2011 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 of2011 OpenFOAM.
10 
11  2011 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  2011 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 with2011 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
27 
28 template<class Type>
30 (
31  const word& patchFieldType,
32  const word& actualPatchType,
33  const pointPatch& p,
35 )
36 {
37  if (debug)
38  {
39  Info<< "PointPatchField<Type>::"
40  "New(const word&, const word&"
41  ", const pointPatch&, const Field<Type>&) : "
42  "constructing pointPatchField<Type>"
43  << endl;
44  }
45 
46  typename pointPatchConstructorTable::iterator cstrIter =
47  pointPatchConstructorTablePtr_->find(patchFieldType);
48 
49  if (cstrIter == pointPatchConstructorTablePtr_->end())
50  {
52  (
53  "PointPatchField<Type>::New"
54  "(const word&, const word&, const pointPatch&, const Field<Type>&)"
55  ) << "Unknown patchFieldType type "
56  << patchFieldType << nl << nl
57  << "Valid patchField types are :" << endl
58  << pointPatchConstructorTablePtr_->sortedToc()
59  << exit(FatalError);
60  }
61 
62  autoPtr<pointPatchField<Type> > pfPtr(cstrIter()(p, iF));
63 
64  if
65  (
66  actualPatchType == word::null
67  || actualPatchType != p.type()
68  )
69  {
70  if (pfPtr().constraintType() != p.constraintType())
71  {
72  // Use default constraint type
73  typename pointPatchConstructorTable::iterator patchTypeCstrIter =
74  pointPatchConstructorTablePtr_->find(p.type());
75 
76  if (patchTypeCstrIter == pointPatchConstructorTablePtr_->end())
77  {
79  (
80  "PointPatchField<Type>::New"
81  "(const word&, const word&"
82  ", const pointPatch&, const Field<Type>&)"
83  ) << "inconsistent patch and patchField types for \n"
84  << " patch type " << p.type()
85  << " and patchField type " << patchFieldType
86  << exit(FatalError);
87  }
88 
89  return patchTypeCstrIter()(p, iF);
90  }
91  }
92  else
93  {
94  if (pointPatchConstructorTablePtr_->found(p.type()))
95  {
96  pfPtr().patchType() = actualPatchType;
97  }
98  }
99 
100  return pfPtr;
101 }
102 
103 
104 template<class Type>
106 (
107  const word& patchFieldType,
108  const pointPatch& p,
110 )
111 {
112  return New(patchFieldType, word::null, p, iF);
113 }
114 
115 
116 template<class Type>
118 (
119  const pointPatch& p,
121  const dictionary& dict
122 )
123 {
124  if (debug)
125  {
126  Info<< "PointPatchField<Type>::"
127  "New(const pointPatch&, const Field<Type>&, const dictionary&)"
128  " : constructing pointPatchField<Type>"
129  << endl;
130  }
131 
132  word patchFieldType(dict.lookup("type"));
133 
134  typename dictionaryConstructorTable::iterator cstrIter
135  = dictionaryConstructorTablePtr_->find(patchFieldType);
136 
137  if (cstrIter == dictionaryConstructorTablePtr_->end())
138  {
139  if (!disallowGenericPointPatchField)
140  {
141  cstrIter = dictionaryConstructorTablePtr_->find("generic");
142  }
143 
144  if (cstrIter == dictionaryConstructorTablePtr_->end())
145  {
147  (
148  "PointPatchField<Type>::"
149  "New(const pointPatch&, const Field<Type>&, const dictionary&)",
150  dict
151  ) << "Unknown patchField type " << patchFieldType
152  << " for patch type " << p.type() << nl << nl
153  << "Valid patchField types are :" << endl
154  << dictionaryConstructorTablePtr_->sortedToc()
155  << exit(FatalIOError);
156  }
157  }
158 
159  // Construct (but not necesarily returned)
160  autoPtr<pointPatchField<Type> > pfPtr(cstrIter()(p, iF, dict));
161 
162  if
163  (
164  !dict.found("patchType")
165  || word(dict.lookup("patchType")) != p.type()
166  )
167  {
168  if (pfPtr().constraintType() == p.constraintType())
169  {
170  // Compatible (constraint-wise) with the patch type
171  return pfPtr;
172  }
173  else
174  {
175  // Use default constraint type
176  typename dictionaryConstructorTable::iterator patchTypeCstrIter
177  = dictionaryConstructorTablePtr_->find(p.type());
178 
179  if (patchTypeCstrIter == dictionaryConstructorTablePtr_->end())
180  {
182  (
183  "PointPatchField<Type>const pointPatch&, "
184  "const Field<Type>&, const dictionary&)",
185  dict
186  ) << "inconsistent patch and patchField types for \n"
187  << " patch type " << p.type()
188  << " and patchField type " << patchFieldType
189  << exit(FatalIOError);
190  }
191 
192  return patchTypeCstrIter()(p, iF, dict);
193  }
194  }
195 
196  return cstrIter()(p, iF, dict);
197 }
198 
199 
200 // Return a pointer to a new patch created on freestore from
201 // a given pointPatchField<Type> mapped onto a new patch
202 template<class Type>
204 (
205  const pointPatchField<Type>& ptf,
206  const pointPatch& p,
208  const pointPatchFieldMapper& pfMapper
209 )
210 {
211  if (debug)
212  {
213  Info<< "PointPatchField<Type>::"
214  "New(const pointPatchField<Type>&,"
215  " const pointPatch&, const Field<Type>&, "
216  "const pointPatchFieldMapper&) : "
217  "constructing pointPatchField<Type>"
218  << endl;
219  }
220 
221  typename patchMapperConstructorTable::iterator cstrIter =
222  patchMapperConstructorTablePtr_->find(ptf.type());
223 
224  if (cstrIter == patchMapperConstructorTablePtr_->end())
225  {
227  (
228  "PointPatchField<Type>::New"
229  "("
230  "const pointPatchField<Type>&, "
231  "const pointPatch&, "
232  "const DimensionedField<Type, pointMesh>&, "
233  "const pointPatchFieldMapper&"
234  ")"
235  ) << "Unknown patchField type "
236  << ptf.type() << nl << nl
237  << "Valid patchField types are :" << endl
238  << patchMapperConstructorTablePtr_->sortedToc()
239  << exit(FatalError);
240  }
241 
242  return cstrIter()(ptf, p, iF, pfMapper);
243 }
244 
245 
246 // ************************************************************************* //
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
Definition: dictionary.C:306
Basic pointPatch represents a set of points from the mesh.
Definition: pointPatch.H:56
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
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 autoPtr< pointPatchField< Type > > New(const word &, const pointPatch &, const DimensionedField< Type, pointMesh > &)
Return a pointer to a new patchField created on freestore given.
dictionary dict
Abstract base class for point-mesh patch fields.
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
virtual const word & constraintType() const
Return the constraint type this pointPatch implements.
Definition: pointPatch.H:160
Foam::pointPatchFieldMapper.
#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
#define FatalIOErrorIn(functionName, ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:325
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:117