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-2016 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 // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
27 
28 template<class Type>
30 (
31  const word& patchFieldType,
32  const word& actualPatchType,
33  const fvPatch& p,
35 )
36 {
37  if (debug)
38  {
39  InfoInFunction << "Constructing fvsPatchField<Type>" << endl;
40  }
41 
42  typename patchConstructorTable::iterator cstrIter =
43  patchConstructorTablePtr_->find(patchFieldType);
44 
45  if (cstrIter == patchConstructorTablePtr_->end())
46  {
48  << "Unknown patchField type "
49  << patchFieldType << nl << nl
50  << "Valid patchField types are :" << endl
51  << patchConstructorTablePtr_->sortedToc()
52  << exit(FatalError);
53  }
54 
55  if
56  (
57  actualPatchType == word::null
58  || actualPatchType != p.type()
59  )
60  {
61  typename patchConstructorTable::iterator patchTypeCstrIter =
62  patchConstructorTablePtr_->find(p.type());
63 
64  if (patchTypeCstrIter != patchConstructorTablePtr_->end())
65  {
66  return patchTypeCstrIter()(p, iF);
67  }
68  else
69  {
70  return cstrIter()(p, iF);
71  }
72  }
73  else
74  {
75  return cstrIter()(p, iF);
76  }
77 }
78 
79 
80 template<class Type>
82 (
83  const word& patchFieldType,
84  const fvPatch& p,
86 )
87 {
88  return New(patchFieldType, word::null, p, iF);
89 }
90 
91 
92 template<class Type>
94 (
95  const fvPatch& p,
97  const dictionary& dict
98 )
99 {
100  if (debug)
101  {
102  InfoInFunction << "Constructing fvsPatchField<Type>" << endl;
103  }
104 
105  const word patchFieldType(dict.lookup("type"));
106 
107  typename dictionaryConstructorTable::iterator cstrIter
108  = dictionaryConstructorTablePtr_->find(patchFieldType);
109 
110  if (cstrIter == dictionaryConstructorTablePtr_->end())
111  {
112  if (!disallowGenericFvsPatchField)
113  {
114  cstrIter = dictionaryConstructorTablePtr_->find("generic");
115  }
116 
117  if (cstrIter == dictionaryConstructorTablePtr_->end())
118  {
120  (
121  dict
122  ) << "Unknown patchField type " << patchFieldType
123  << " for patch type " << p.type() << nl << nl
124  << "Valid patchField types are :" << endl
125  << dictionaryConstructorTablePtr_->sortedToc()
126  << exit(FatalIOError);
127  }
128  }
129 
130  if
131  (
132  !dict.found("patchType")
133  || word(dict.lookup("patchType")) != p.type()
134  )
135  {
136  typename dictionaryConstructorTable::iterator patchTypeCstrIter
137  = dictionaryConstructorTablePtr_->find(p.type());
138 
139  if
140  (
141  patchTypeCstrIter != dictionaryConstructorTablePtr_->end()
142  && patchTypeCstrIter() != cstrIter()
143  )
144  {
146  (
147  dict
148  ) << "inconsistent patch and patchField types for \n"
149  " patch type " << p.type()
150  << " and patchField type " << patchFieldType
151  << exit(FatalIOError);
152  }
153  }
154 
155  return cstrIter()(p, iF, dict);
156 }
157 
158 
159 template<class Type>
161 (
162  const fvsPatchField<Type>& ptf,
163  const fvPatch& p,
165  const fvPatchFieldMapper& pfMapper
166 )
167 {
168  if (debug)
169  {
170  InfoInFunction << "Constructing fvsPatchField<Type>" << endl;
171  }
172 
173  typename patchMapperConstructorTable::iterator cstrIter =
174  patchMapperConstructorTablePtr_->find(ptf.type());
175 
176  if (cstrIter == patchMapperConstructorTablePtr_->end())
177  {
179  << "Unknown patchField type " << ptf.type() << nl << nl
180  << "Valid patchField types are :" << endl
181  << patchMapperConstructorTablePtr_->sortedToc()
182  << exit(FatalError);
183  }
184 
185  typename patchMapperConstructorTable::iterator
186  patchTypeCstrIter = patchMapperConstructorTablePtr_->find(p.type());
187 
188  if (patchTypeCstrIter != patchMapperConstructorTablePtr_->end())
189  {
190  return patchTypeCstrIter()(ptf, p, iF, pfMapper);
191  }
192  else
193  {
194  return cstrIter()(ptf, p, iF, pfMapper);
195  }
196 }
197 
198 
199 // ************************************************************************* //
dictionary dict
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
Definition: dictionary.C:431
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
error FatalError
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:319
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:253
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
static tmp< fvsPatchField< Type > > New(const word &, const fvPatch &, const DimensionedField< Type, surfaceMesh > &)
Return a pointer to a new patchField created on freestore given.
A class for handling words, derived from string.
Definition: word.H:59
Foam::fvPatchFieldMapper.
static const char nl
Definition: Ostream.H:262
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:331
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
volScalarField & p
A class for managing temporary objects.
Definition: PtrList.H:53
An abstract base class with a fat-interface to all derived classes covering all possible ways in whic...
Definition: fvsPatchField.H:65
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:576
IOerror FatalIOError
#define InfoInFunction
Report an information message using Foam::Info.