FreeFOAM The Cross-Platform CFD Toolkit
newFvPatchField.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 // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
27 
28 template<class Type>
30 (
31  const word& patchFieldType,
32  const fvPatch& p,
34 )
35 {
36  if (debug)
37  {
38  Info<< "fvPatchField<Type>::New(const word&, const fvPatch&, "
39  "const DimensionedField<Type, volMesh>&) : patchFieldType="
40  << patchFieldType
41  << endl;
42  }
43 
44  typename patchConstructorTable::iterator cstrIter =
45  patchConstructorTablePtr_->find(patchFieldType);
46 
47  if (cstrIter == patchConstructorTablePtr_->end())
48  {
50  (
51  "fvPatchField<Type>::New(const word&, const fvPatch&, "
52  "const DimensionedField<Type, volMesh>&)"
53  ) << "Unknown patchTypefield type " << patchFieldType
54  << endl << endl
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 (patchTypeCstrIter != patchConstructorTablePtr_->end())
64  {
65  return patchTypeCstrIter()(p, iF);
66  }
67  else
68  {
69  return cstrIter()(p, iF);
70  }
71 }
72 
73 
74 template<class Type>
76 (
77  const fvPatch& p,
79  const dictionary& dict
80 )
81 {
82  word patchFieldType(dict.lookup("type"));
83 
84  if (debug)
85  {
86  Info<< "fvPatchField<Type>::New(const fvPatch&, "
87  "const DimensionedField<Type, volMesh>&, "
88  "const dictionary&) : patchFieldType=" << patchFieldType
89  << endl;
90  }
91 
92  typename dictionaryConstructorTable::iterator cstrIter
93  = dictionaryConstructorTablePtr_->find(patchFieldType);
94 
95  if (cstrIter == dictionaryConstructorTablePtr_->end())
96  {
97  if (!disallowGenericFvPatchField)
98  {
99  cstrIter = dictionaryConstructorTablePtr_->find("generic");
100  }
101 
102  if (cstrIter == dictionaryConstructorTablePtr_->end())
103  {
105  (
106  "fvPatchField<Type>::New(const fvPatch&, "
107  "const DimensionedField<Type, volMesh>&, "
108  "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  "fvPatchField<Type>::New(const fvPatch&, "
136  "const DimensionedField<Type, volMesh>&, "
137  "const dictionary&)",
138  dict
139  ) << "inconsistent patch and patchField types for \n"
140  " patch type " << p.type()
141  << " and patchField type " << patchFieldType
142  << exit(FatalIOError);
143  }
144  }
145 
146  return cstrIter()(p, iF, dict);
147 }
148 
149 
150 template<class Type>
152 (
153  const fvPatchField<Type>& ptf,
154  const fvPatch& p,
156  const fvPatchFieldMapper& pfMapper
157 )
158 {
159  if (debug)
160  {
161  Info<< "fvPatchField<Type>::New(const fvPatchField<Type>&, "
162  "const fvPatch&, const DimensionedField<Type, volMesh>&, "
163  "const fvPatchFieldMapper&) : "
164  "constructing fvPatchField<Type>"
165  << endl;
166  }
167 
168  typename patchMapperConstructorTable::iterator cstrIter =
169  patchMapperConstructorTablePtr_->find(ptf.type());
170 
171  if (cstrIter == patchMapperConstructorTablePtr_->end())
172  {
174  (
175  "fvPatchField<Type>::New(const fvPatchField<Type>&, "
176  "const fvPatch&, const DimensionedField<Type, volMesh>&, "
177  "const fvPatchFieldMapper&)"
178  ) << "unknown patchTypefield type " << ptf.type() << endl << endl
179  << "Valid patchField types are :" << endl
180  << patchMapperConstructorTablePtr_->sortedToc()
181  << exit(FatalError);
182  }
183 
184  return cstrIter()(ptf, p, iF, pfMapper);
185 }
186 
187 
188 // ************************ vim: set sw=4 sts=4 et: ************************ //