1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 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, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32 // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
35 tmp<fvsPatchField<Type> > fvsPatchField<Type>::New
37 const word& patchFieldType,
39 const DimensionedField<Type, surfaceMesh>& iF
44 Info<< "fvsPatchField<Type>::New(const word&, const fvPatch&, "
45 "const DimensionedField<Type, surfaceMesh>&) : "
46 "constructing fvsPatchField<Type>"
50 typename patchConstructorTable::iterator cstrIter =
51 patchConstructorTablePtr_->find(patchFieldType);
53 if (cstrIter == patchConstructorTablePtr_->end())
55 if (cstrIter == patchConstructorTablePtr_->end())
59 "fvsPatchField<Type>::New(const word&, const fvPatch&, "
60 "const DimensionedField<Type, surfaceMesh>)"
61 ) << "Unknown patch field type " << patchFieldType
63 << "Valid patchField types are :" << endl
64 << patchConstructorTablePtr_->toc()
69 typename patchConstructorTable::iterator patchTypeCstrIter =
70 patchConstructorTablePtr_->find(p.type());
72 if (patchTypeCstrIter != patchConstructorTablePtr_->end())
74 return patchTypeCstrIter()(p, iF);
78 return cstrIter()(p, iF);
84 tmp<fvsPatchField<Type> > fvsPatchField<Type>::New
87 const DimensionedField<Type, surfaceMesh>& iF,
88 const dictionary& dict
93 Info<< "fvsPatchField<Type>::New(const fvPatch&, "
94 "const DimensionedField<Type, surfaceMesh>&, "
95 "const dictionary&) : "
96 "constructing fvsPatchField<Type>"
100 word patchFieldType(dict.lookup("type"));
102 typename dictionaryConstructorTable::iterator cstrIter
103 = dictionaryConstructorTablePtr_->find(patchFieldType);
105 if (cstrIter == dictionaryConstructorTablePtr_->end())
107 if (!disallowDefaultFvsPatchField)
109 cstrIter = dictionaryConstructorTablePtr_->find
111 fvsPatchField<Type>::calculatedType()
115 if (cstrIter == dictionaryConstructorTablePtr_->end())
119 "fvsPatchField<Type>::New(const fvPatch&, "
120 "const DimensionedField<Type, surfaceMesh>&, "
121 "const dictionary&)",
123 ) << "Unknown patchField type " << patchFieldType
124 << " for patch type " << p.type() << endl << endl
125 << "Valid patchField types are :" << endl
126 << dictionaryConstructorTablePtr_->toc()
127 << exit(FatalIOError);
133 !dict.found("patchType")
134 || word(dict.lookup("patchType")) != p.type()
137 typename dictionaryConstructorTable::iterator patchTypeCstrIter
138 = dictionaryConstructorTablePtr_->find(p.type());
142 patchTypeCstrIter != dictionaryConstructorTablePtr_->end()
143 && patchTypeCstrIter() != cstrIter()
148 "fvsPatchField<Type>const fvPatch&, "
149 "const DimensionedField<Type, surfaceMesh>&, "
150 "const dictionary&)",
152 ) << "inconsistent patch and patchField types for \n"
153 " patch type " << p.type()
154 << " and patchField type " << patchFieldType
155 << exit(FatalIOError);
159 return cstrIter()(p, iF, dict);
163 // Return a pointer to a new patch created on freestore from
164 // a given fvsPatchField<Type> mapped onto a new patch
166 tmp<fvsPatchField<Type> > fvsPatchField<Type>::New
168 const fvsPatchField<Type>& ptf,
170 const DimensionedField<Type, surfaceMesh>& iF,
171 const fvPatchFieldMapper& pfMapper
176 Info<< "fvsPatchField<Type>::New(const fvsPatchField<Type>&,"
177 " const fvPatch&, const DimensionedField<Type, surfaceMesh>&, "
178 "const fvPatchFieldMapper&) : "
179 "constructing fvsPatchField<Type>"
183 typename patchMapperConstructorTable::iterator cstrIter =
184 patchMapperConstructorTablePtr_->find(ptf.type());
186 if (cstrIter == patchMapperConstructorTablePtr_->end())
190 "fvsPatchField<Type>::New(const fvsPatchField<Type>&, "
191 "const fvPatch&, const Field<Type>&, "
192 "const fvPatchFieldMapper&)"
193 ) << "unknown patch field type " << ptf.type() << endl << endl
194 << "Valid patchField types are :" << endl
195 << patchMapperConstructorTablePtr_->toc()
199 typename patchMapperConstructorTable::iterator
200 patchTypeCstrIter = patchMapperConstructorTablePtr_->find(p.type());
202 if (patchTypeCstrIter != patchMapperConstructorTablePtr_->end())
204 return patchTypeCstrIter()(ptf, p, iF, pfMapper);
208 return cstrIter()(ptf, p, iF, pfMapper);
213 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
215 } // End namespace Foam
217 // ************************************************************************* //