1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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.
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
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/>.
24 \*---------------------------------------------------------------------------*/
26 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
31 // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
34 tmp<fvsPatchField<Type> > fvsPatchField<Type>::New
36 const word& patchFieldType,
37 const word& actualPatchType,
39 const DimensionedField<Type, surfaceMesh>& iF
44 Info<< "fvsPatchField<Type>::New(const word&, const word&"
45 ", const fvPatch&, const Field<Type>&) : "
46 "constructing fvsPatchField<Type>"
50 typename patchConstructorTable::iterator cstrIter =
51 patchConstructorTablePtr_->find(patchFieldType);
53 if (cstrIter == patchConstructorTablePtr_->end())
57 "fvsPatchField<Type>::New(const word&, const word&, const fvPatch&"
58 ", const Field<Type>&)"
59 ) << "Unknown patchField type "
60 << patchFieldType << nl << nl
61 << "Valid patchField types are :" << endl
62 << patchConstructorTablePtr_->sortedToc()
68 actualPatchType == word::null
69 || actualPatchType != p.type()
72 typename patchConstructorTable::iterator patchTypeCstrIter =
73 patchConstructorTablePtr_->find(p.type());
75 if (patchTypeCstrIter != patchConstructorTablePtr_->end())
77 return patchTypeCstrIter()(p, iF);
81 return cstrIter()(p, iF);
86 return cstrIter()(p, iF);
92 tmp<fvsPatchField<Type> > fvsPatchField<Type>::New
94 const word& patchFieldType,
96 const DimensionedField<Type, surfaceMesh>& iF
99 return New(patchFieldType, word::null, p, iF);
104 tmp<fvsPatchField<Type> > fvsPatchField<Type>::New
107 const DimensionedField<Type, surfaceMesh>& iF,
108 const dictionary& dict
113 Info<< "fvsPatchField<Type>::New(const fvPatch&, const Field<Type>&, "
114 "const dictionary&) : "
115 "constructing fvsPatchField<Type>"
119 const word patchFieldType(dict.lookup("type"));
121 typename dictionaryConstructorTable::iterator cstrIter
122 = dictionaryConstructorTablePtr_->find(patchFieldType);
124 if (cstrIter == dictionaryConstructorTablePtr_->end())
126 if (!disallowGenericFvsPatchField)
128 cstrIter = dictionaryConstructorTablePtr_->find("generic");
131 if (cstrIter == dictionaryConstructorTablePtr_->end())
135 "fvsPatchField<Type>::New(const fvPatch&, const Field<Type>&, "
136 "const dictionary&)",
138 ) << "Unknown patchField type " << patchFieldType
139 << " for patch type " << p.type() << nl << nl
140 << "Valid patchField types are :" << endl
141 << dictionaryConstructorTablePtr_->sortedToc()
142 << exit(FatalIOError);
148 !dict.found("patchType")
149 || word(dict.lookup("patchType")) != p.type()
152 typename dictionaryConstructorTable::iterator patchTypeCstrIter
153 = dictionaryConstructorTablePtr_->find(p.type());
157 patchTypeCstrIter != dictionaryConstructorTablePtr_->end()
158 && patchTypeCstrIter() != cstrIter()
163 "fvsPatchField<Type>const fvPatch&, const Field<Type>&, "
164 "const dictionary&)",
166 ) << "inconsistent patch and patchField types for \n"
167 " patch type " << p.type()
168 << " and patchField type " << patchFieldType
169 << exit(FatalIOError);
173 return cstrIter()(p, iF, dict);
177 // Return a pointer to a new patch created on freestore from
178 // a given fvsPatchField<Type> mapped onto a new patch
180 tmp<fvsPatchField<Type> > fvsPatchField<Type>::New
182 const fvsPatchField<Type>& ptf,
184 const DimensionedField<Type, surfaceMesh>& iF,
185 const fvPatchFieldMapper& pfMapper
190 Info<< "fvsPatchField<Type>::New(const fvsPatchField<Type>&,"
191 " const fvPatch&, const Field<Type>&, "
192 "const fvPatchFieldMapper&) : "
193 "constructing fvsPatchField<Type>"
197 typename patchMapperConstructorTable::iterator cstrIter =
198 patchMapperConstructorTablePtr_->find(ptf.type());
200 if (cstrIter == patchMapperConstructorTablePtr_->end())
204 "fvsPatchField<Type>::New(const fvsPatchField<Type>&, "
205 "const fvPatch&, const Field<Type>&, "
206 "const fvPatchFieldMapper&)"
207 ) << "Unknown patchField type " << ptf.type() << nl << nl
208 << "Valid patchField types are :" << endl
209 << patchMapperConstructorTablePtr_->sortedToc()
213 typename patchMapperConstructorTable::iterator
214 patchTypeCstrIter = patchMapperConstructorTablePtr_->find(p.type());
216 if (patchTypeCstrIter != patchMapperConstructorTablePtr_->end())
218 return patchTypeCstrIter()(ptf, p, iF, pfMapper);
222 return cstrIter()(ptf, p, iF, pfMapper);
227 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
229 } // End namespace Foam
231 // ************************************************************************* //