1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
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 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
30 Foam::autoPtr<Foam::pointPatchField<Type> > Foam::pointPatchField<Type>::New
32 const word& patchFieldType,
34 const DimensionedField<Type, pointMesh>& iF
39 Info<< "PointPatchField<Type>::"
40 "New(const word&, const pointPatch&, const Field<Type>&) : "
41 "constructing pointPatchField<Type>"
45 typename pointPatchConstructorTable::iterator cstrIter =
46 pointPatchConstructorTablePtr_->find(patchFieldType);
48 if (cstrIter == pointPatchConstructorTablePtr_->end())
52 "PointPatchField<Type>::New"
53 "(const word&, const pointPatch&, const Field<Type>&)"
54 ) << "Unknown patchTypefield type "
57 << "Valid patchField types are :" << endl
58 << pointPatchConstructorTablePtr_->toc()
62 typename pointPatchConstructorTable::iterator patchTypeCstrIter =
63 pointPatchConstructorTablePtr_->find(p.type());
65 if (patchTypeCstrIter != pointPatchConstructorTablePtr_->end())
67 return autoPtr<pointPatchField<Type> >(patchTypeCstrIter()(p, iF));
71 return autoPtr<pointPatchField<Type> >(cstrIter()(p, iF));
77 Foam::autoPtr<Foam::pointPatchField<Type> > Foam::pointPatchField<Type>::New
80 const DimensionedField<Type, pointMesh>& iF,
81 const dictionary& dict
86 Info<< "PointPatchField<Type>::"
87 "New(const pointPatch&, const Field<Type>&, const dictionary&)"
88 " : constructing pointPatchField<Type>"
92 word patchFieldType(dict.lookup("type"));
94 typename dictionaryConstructorTable::iterator cstrIter
95 = dictionaryConstructorTablePtr_->find(patchFieldType);
97 if (cstrIter == dictionaryConstructorTablePtr_->end())
99 if (!disallowGenericPointPatchField)
101 cstrIter = dictionaryConstructorTablePtr_->find("generic");
104 if (cstrIter == dictionaryConstructorTablePtr_->end())
108 "PointPatchField<Type>::"
109 "New(const pointPatch&, const Field<Type>&, const dictionary&)",
111 ) << "Unknown patchField type " << patchFieldType
112 << " for patch type " << p.type() << endl << endl
113 << "Valid patchField types are :" << endl
114 << dictionaryConstructorTablePtr_->toc()
115 << exit(FatalIOError);
121 !dict.found("patchType")
122 || word(dict.lookup("patchType")) != p.type()
125 typename dictionaryConstructorTable::iterator patchTypeCstrIter
126 = dictionaryConstructorTablePtr_->find(p.type());
130 patchTypeCstrIter != dictionaryConstructorTablePtr_->end()
131 && patchTypeCstrIter() != cstrIter()
136 "PointPatchField<Type>const pointPatch&, "
137 "const Field<Type>&, const dictionary&)",
139 ) << "inconsistent patch and patchField types for \n"
140 << " patch type " << p.type()
141 << " and patchField type " << patchFieldType
142 << exit(FatalIOError);
146 return autoPtr<pointPatchField<Type> >(cstrIter()(p, iF, dict));
150 // Return a pointer to a new patch created on freestore from
151 // a given pointPatchField<Type> mapped onto a new patch
153 Foam::autoPtr<Foam::pointPatchField<Type> > Foam::pointPatchField<Type>::New
155 const pointPatchField<Type>& ptf,
157 const DimensionedField<Type, pointMesh>& iF,
158 const pointPatchFieldMapper& pfMapper
163 Info<< "PointPatchField<Type>::"
164 "New(const pointPatchField<Type>&,"
165 " const pointPatch&, const Field<Type>&, "
166 "const pointPatchFieldMapper&) : "
167 "constructing pointPatchField<Type>"
171 typename patchMapperConstructorTable::iterator cstrIter =
172 patchMapperConstructorTablePtr_->find(ptf.type());
174 if (cstrIter == patchMapperConstructorTablePtr_->end())
178 "PointPatchField<Type>::"
179 "New(const pointPatchField<Type>&, "
180 "const pointPatch&, const Field<Type>&, "
181 "const pointPatchFieldMapper&)"
182 ) << "unknown patchTypefield type "
183 << ptf.type() << endl << endl
184 << "Valid patchField types are :" << endl
185 << patchMapperConstructorTablePtr_->toc()
189 return autoPtr<pointPatchField<Type> >(cstrIter()(ptf, p, iF, pfMapper));
193 // ************************************************************************* //