fvPatchFieldNew.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  {
40  << "patchFieldType = " << patchFieldType
41  << " : " << p.type()
42  << endl;
43  }
44 
45  typename patchConstructorTable::iterator cstrIter =
46  patchConstructorTablePtr_->find(patchFieldType);
47 
48  if (cstrIter == patchConstructorTablePtr_->end())
49  {
51  << "Unknown patchField type "
52  << patchFieldType << nl << nl
53  << "Valid patchField types are :" << endl
54  << patchConstructorTablePtr_->sortedToc()
55  << exit(FatalError);
56  }
57 
58  typename patchConstructorTable::iterator patchTypeCstrIter =
59  patchConstructorTablePtr_->find(p.type());
60 
61  if
62  (
63  actualPatchType == word::null
64  || actualPatchType != p.type()
65  )
66  {
67  if (patchTypeCstrIter != patchConstructorTablePtr_->end())
68  {
69  return patchTypeCstrIter()(p, iF);
70  }
71  else
72  {
73  return cstrIter()(p, iF);
74  }
75  }
76  else
77  {
78  tmp<fvPatchField<Type>> tfvp = cstrIter()(p, iF);
79 
80  // Check if constraint type override and store patchType if so
81  if ((patchTypeCstrIter != patchConstructorTablePtr_->end()))
82  {
83  tfvp.ref().patchType() = actualPatchType;
84  }
85  return tfvp;
86  }
87 }
88 
89 
90 template<class Type>
92 (
93  const word& patchFieldType,
94  const fvPatch& p,
96 )
97 {
98  return New(patchFieldType, word::null, p, iF);
99 }
100 
101 
102 template<class Type>
104 (
105  const fvPatch& p,
107  const dictionary& dict
108 )
109 {
110  const word patchFieldType(dict.lookup("type"));
111 
112  if (debug)
113  {
115  << "patchFieldType = " << patchFieldType
116  << endl;
117  }
118 
119  typename dictionaryConstructorTable::iterator cstrIter
120  = dictionaryConstructorTablePtr_->find(patchFieldType);
121 
122  if (cstrIter == dictionaryConstructorTablePtr_->end())
123  {
124  if (!disallowGenericFvPatchField)
125  {
126  cstrIter = dictionaryConstructorTablePtr_->find("generic");
127  }
128 
129  if (cstrIter == dictionaryConstructorTablePtr_->end())
130  {
132  (
133  dict
134  ) << "Unknown patchField type " << patchFieldType
135  << " for patch type " << p.type() << nl << nl
136  << "Valid patchField types are :" << endl
137  << dictionaryConstructorTablePtr_->sortedToc()
138  << exit(FatalIOError);
139  }
140  }
141 
142  if
143  (
144  !dict.found("patchType")
145  || word(dict.lookup("patchType")) != p.type()
146  )
147  {
148  typename dictionaryConstructorTable::iterator patchTypeCstrIter
149  = dictionaryConstructorTablePtr_->find(p.type());
150 
151  if
152  (
153  patchTypeCstrIter != dictionaryConstructorTablePtr_->end()
154  && patchTypeCstrIter() != cstrIter()
155  )
156  {
158  (
159  dict
160  ) << "inconsistent patch and patchField types for \n"
161  " patch type " << p.type()
162  << " and patchField type " << patchFieldType
163  << exit(FatalIOError);
164  }
165  }
166 
167  return cstrIter()(p, iF, dict);
168 }
169 
170 
171 template<class Type>
173 (
174  const fvPatchField<Type>& ptf,
175  const fvPatch& p,
177  const fvPatchFieldMapper& pfMapper
178 )
179 {
180  if (debug)
181  {
182  InfoInFunction << "Constructing fvPatchField<Type>" << endl;
183  }
184 
185  typename patchMapperConstructorTable::iterator cstrIter =
186  patchMapperConstructorTablePtr_->find(ptf.type());
187 
188  if (cstrIter == patchMapperConstructorTablePtr_->end())
189  {
191  << "Unknown patchField type " << ptf.type() << nl << nl
192  << "Valid patchField types are :" << endl
193  << patchMapperConstructorTablePtr_->sortedToc()
194  << exit(FatalError);
195  }
196 
197  return cstrIter()(ptf, p, iF, pfMapper);
198 }
199 
200 
201 // ************************************************************************* //
dictionary dict
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
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:65
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
A class for handling words, derived from string.
Definition: word.H:59
Foam::fvPatchFieldMapper.
static tmp< fvPatchField< Type > > New(const word &, const fvPatch &, const DimensionedField< Type, volMesh > &)
Return a pointer to a new patchField created on freestore given.
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
Definition: dictionary.C:306
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:54
T & ref() const
Return non-const reference or generate a fatal error.
Definition: tmpI.H:174
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:451
IOerror FatalIOError
#define InfoInFunction
Report an information message using Foam::Info.