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-2015 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,
39  const DimensionedField<Type, surfaceMesh>& iF
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  << "Unknown patchField type "
57  << patchFieldType << nl << nl
58  << "Valid patchField types are :" << endl
59  << patchConstructorTablePtr_->sortedToc()
60  << exit(FatalError);
61  }
62 
63  if
64  (
65  actualPatchType == word::null
66  || actualPatchType != p.type()
67  )
68  {
69  typename patchConstructorTable::iterator patchTypeCstrIter =
70  patchConstructorTablePtr_->find(p.type());
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  return cstrIter()(p, iF);
84  }
85 }
86 
87 
88 template<class Type>
89 tmp<fvsPatchField<Type> > fvsPatchField<Type>::New
90 (
91  const word& patchFieldType,
92  const fvPatch& p,
93  const DimensionedField<Type, surfaceMesh>& iF
94 )
95 {
96  return New(patchFieldType, word::null, p, iF);
97 }
98 
99 
100 template<class Type>
101 tmp<fvsPatchField<Type> > fvsPatchField<Type>::New
102 (
103  const fvPatch& p,
104  const DimensionedField<Type, surfaceMesh>& iF,
105  const dictionary& dict
106 )
107 {
108  if (debug)
109  {
110  Info<< "fvsPatchField<Type>::New(const fvPatch&, const Field<Type>&, "
111  "const dictionary&) : "
112  "constructing fvsPatchField<Type>"
113  << endl;
114  }
115 
116  const word patchFieldType(dict.lookup("type"));
117 
118  typename dictionaryConstructorTable::iterator cstrIter
119  = dictionaryConstructorTablePtr_->find(patchFieldType);
120 
121  if (cstrIter == dictionaryConstructorTablePtr_->end())
122  {
123  if (!disallowGenericFvsPatchField)
124  {
125  cstrIter = dictionaryConstructorTablePtr_->find("generic");
126  }
127 
128  if (cstrIter == dictionaryConstructorTablePtr_->end())
129  {
131  (
132  dict
133  ) << "Unknown patchField type " << patchFieldType
134  << " for patch type " << p.type() << nl << nl
135  << "Valid patchField types are :" << endl
136  << dictionaryConstructorTablePtr_->sortedToc()
137  << exit(FatalIOError);
138  }
139  }
140 
141  if
142  (
143  !dict.found("patchType")
144  || word(dict.lookup("patchType")) != p.type()
145  )
146  {
147  typename dictionaryConstructorTable::iterator patchTypeCstrIter
148  = dictionaryConstructorTablePtr_->find(p.type());
149 
150  if
151  (
152  patchTypeCstrIter != dictionaryConstructorTablePtr_->end()
153  && patchTypeCstrIter() != cstrIter()
154  )
155  {
157  (
158  dict
159  ) << "inconsistent patch and patchField types for \n"
160  " patch type " << p.type()
161  << " and patchField type " << patchFieldType
162  << exit(FatalIOError);
163  }
164  }
165 
166  return cstrIter()(p, iF, dict);
167 }
168 
169 
170 // Return a pointer to a new patch created on freestore from
171 // a given fvsPatchField<Type> mapped onto a new patch
172 template<class Type>
173 tmp<fvsPatchField<Type> > fvsPatchField<Type>::New
174 (
175  const fvsPatchField<Type>& ptf,
176  const fvPatch& p,
177  const DimensionedField<Type, surfaceMesh>& iF,
178  const fvPatchFieldMapper& pfMapper
179 )
180 {
181  if (debug)
182  {
183  Info<< "fvsPatchField<Type>::New(const fvsPatchField<Type>&,"
184  " const fvPatch&, const Field<Type>&, "
185  "const fvPatchFieldMapper&) : "
186  "constructing fvsPatchField<Type>"
187  << endl;
188  }
189 
190  typename patchMapperConstructorTable::iterator cstrIter =
191  patchMapperConstructorTablePtr_->find(ptf.type());
192 
193  if (cstrIter == patchMapperConstructorTablePtr_->end())
194  {
196  << "Unknown patchField type " << ptf.type() << nl << nl
197  << "Valid patchField types are :" << endl
198  << patchMapperConstructorTablePtr_->sortedToc()
199  << exit(FatalError);
200  }
201 
202  typename patchMapperConstructorTable::iterator
203  patchTypeCstrIter = patchMapperConstructorTablePtr_->find(p.type());
204 
205  if (patchTypeCstrIter != patchMapperConstructorTablePtr_->end())
206  {
207  return patchTypeCstrIter()(ptf, p, iF, pfMapper);
208  }
209  else
210  {
211  return cstrIter()(ptf, p, iF, pfMapper);
212  }
213 }
214 
215 
216 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
217 
218 } // End namespace Foam
219 
220 // ************************************************************************* //
p
p
Definition: pEqn.H:62
Foam::compressible::New
autoPtr< BasicCompressibleTurbulenceModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &phi, const typename BasicCompressibleTurbulenceModel::transportModel &transport, const word &propertiesName)
Definition: turbulentFluidThermoModel.C:36
Foam::FatalIOError
IOerror FatalIOError
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::nl
static const char nl
Definition: Ostream.H:260
Foam::Info
messageStream Info
Foam::fvsPatchField::New
static tmp< fvsPatchField< Type > > New(const word &, const fvPatch &, const DimensionedField< Type, surfaceMesh > &)
Return a pointer to a new patchField created on freestore given.
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::FatalError
error FatalError
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:318
FatalIOErrorInFunction
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:330