FreeFOAM The Cross-Platform CFD Toolkit
newPointPatchField.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) 1991-2010 OpenCFD Ltd.
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 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
27 
28 template<class Type>
30 (
31  const word& patchFieldType,
32  const pointPatch& p,
34 )
35 {
36  if (debug)
37  {
38  Info<< "PointPatchField<Type>::"
39  "New(const word&, const pointPatch&, const Field<Type>&) : "
40  "constructing pointPatchField<Type>"
41  << endl;
42  }
43 
44  typename pointPatchConstructorTable::iterator cstrIter =
45  pointPatchConstructorTablePtr_->find(patchFieldType);
46 
47  if (cstrIter == pointPatchConstructorTablePtr_->end())
48  {
50  (
51  "PointPatchField<Type>::New"
52  "(const word&, const pointPatch&, const Field<Type>&)"
53  ) << "Unknown patchTypefield type "
54  << patchFieldType
55  << endl << endl
56  << "Valid patchField types are :" << endl
57  << pointPatchConstructorTablePtr_->sortedToc()
58  << exit(FatalError);
59  }
60 
61  typename pointPatchConstructorTable::iterator patchTypeCstrIter =
62  pointPatchConstructorTablePtr_->find(p.type());
63 
64  if (patchTypeCstrIter != pointPatchConstructorTablePtr_->end())
65  {
66  return autoPtr<pointPatchField<Type> >(patchTypeCstrIter()(p, iF));
67  }
68  else
69  {
70  return autoPtr<pointPatchField<Type> >(cstrIter()(p, iF));
71  }
72 }
73 
74 
75 template<class Type>
77 (
78  const pointPatch& p,
80  const dictionary& dict
81 )
82 {
83  if (debug)
84  {
85  Info<< "PointPatchField<Type>::"
86  "New(const pointPatch&, const Field<Type>&, const dictionary&)"
87  " : constructing pointPatchField<Type>"
88  << endl;
89  }
90 
91  word patchFieldType(dict.lookup("type"));
92 
93  typename dictionaryConstructorTable::iterator cstrIter
94  = dictionaryConstructorTablePtr_->find(patchFieldType);
95 
96  if (cstrIter == dictionaryConstructorTablePtr_->end())
97  {
98  if (!disallowGenericPointPatchField)
99  {
100  cstrIter = dictionaryConstructorTablePtr_->find("generic");
101  }
102 
103  if (cstrIter == dictionaryConstructorTablePtr_->end())
104  {
106  (
107  "PointPatchField<Type>::"
108  "New(const pointPatch&, const Field<Type>&, const dictionary&)",
109  dict
110  ) << "Unknown patchField type " << patchFieldType
111  << " for patch type " << p.type() << endl << endl
112  << "Valid patchField types are :" << endl
113  << dictionaryConstructorTablePtr_->sortedToc()
114  << exit(FatalIOError);
115  }
116  }
117 
118  if
119  (
120  !dict.found("patchType")
121  || word(dict.lookup("patchType")) != p.type()
122  )
123  {
124  typename dictionaryConstructorTable::iterator patchTypeCstrIter
125  = dictionaryConstructorTablePtr_->find(p.type());
126 
127  if
128  (
129  patchTypeCstrIter != dictionaryConstructorTablePtr_->end()
130  && patchTypeCstrIter() != cstrIter()
131  )
132  {
134  (
135  "PointPatchField<Type>const pointPatch&, "
136  "const Field<Type>&, const dictionary&)",
137  dict
138  ) << "inconsistent patch and patchField types for \n"
139  << " patch type " << p.type()
140  << " and patchField type " << patchFieldType
141  << exit(FatalIOError);
142  }
143  }
144 
145  return autoPtr<pointPatchField<Type> >(cstrIter()(p, iF, dict));
146 }
147 
148 
149 // Return a pointer to a new patch created on freestore from
150 // a given pointPatchField<Type> mapped onto a new patch
151 template<class Type>
153 (
154  const pointPatchField<Type>& ptf,
155  const pointPatch& p,
157  const pointPatchFieldMapper& pfMapper
158 )
159 {
160  if (debug)
161  {
162  Info<< "PointPatchField<Type>::"
163  "New(const pointPatchField<Type>&,"
164  " const pointPatch&, const Field<Type>&, "
165  "const pointPatchFieldMapper&) : "
166  "constructing pointPatchField<Type>"
167  << endl;
168  }
169 
170  typename patchMapperConstructorTable::iterator cstrIter =
171  patchMapperConstructorTablePtr_->find(ptf.type());
172 
173  if (cstrIter == patchMapperConstructorTablePtr_->end())
174  {
176  (
177  "PointPatchField<Type>::"
178  "New(const pointPatchField<Type>&, "
179  "const pointPatch&, const Field<Type>&, "
180  "const pointPatchFieldMapper&)"
181  ) << "unknown patchTypefield type "
182  << ptf.type() << endl << endl
183  << "Valid patchField types are :" << endl
184  << patchMapperConstructorTablePtr_->sortedToc()
185  << exit(FatalError);
186  }
187 
188  return autoPtr<pointPatchField<Type> >(cstrIter()(ptf, p, iF, pfMapper));
189 }
190 
191 
192 // ************************ vim: set sw=4 sts=4 et: ************************ //