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 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
29 Foam::autoPtr<Foam::pointPatchField<Type> > Foam::pointPatchField<Type>::New
31 const word& patchFieldType,
32 const word& actualPatchType,
34 const DimensionedField<Type, pointMesh>& iF
39 Info<< "PointPatchField<Type>::"
40 "New(const word&, const word&"
41 ", const pointPatch&, const Field<Type>&) : "
42 "constructing pointPatchField<Type>"
46 typename pointPatchConstructorTable::iterator cstrIter =
47 pointPatchConstructorTablePtr_->find(patchFieldType);
49 if (cstrIter == pointPatchConstructorTablePtr_->end())
53 "PointPatchField<Type>::New"
54 "(const word&, const word&, const pointPatch&, const Field<Type>&)"
55 ) << "Unknown patchFieldType type "
56 << patchFieldType << nl << nl
57 << "Valid patchField types are :" << endl
58 << pointPatchConstructorTablePtr_->sortedToc()
62 autoPtr<pointPatchField<Type> > pfPtr(cstrIter()(p, iF));
66 actualPatchType == word::null
67 || actualPatchType != p.type()
70 if (pfPtr().constraintType() != p.constraintType())
72 // Use default constraint type
73 typename pointPatchConstructorTable::iterator patchTypeCstrIter =
74 pointPatchConstructorTablePtr_->find(p.type());
76 if (patchTypeCstrIter == pointPatchConstructorTablePtr_->end())
80 "PointPatchField<Type>::New"
81 "(const word&, const word&"
82 ", const pointPatch&, const Field<Type>&)"
83 ) << "inconsistent patch and patchField types for \n"
84 << " patch type " << p.type()
85 << " and patchField type " << patchFieldType
89 return patchTypeCstrIter()(p, iF);
98 Foam::autoPtr<Foam::pointPatchField<Type> > Foam::pointPatchField<Type>::New
100 const word& patchFieldType,
102 const DimensionedField<Type, pointMesh>& iF
105 return New(patchFieldType, word::null, p, iF);
110 Foam::autoPtr<Foam::pointPatchField<Type> > Foam::pointPatchField<Type>::New
113 const DimensionedField<Type, pointMesh>& iF,
114 const dictionary& dict
119 Info<< "PointPatchField<Type>::"
120 "New(const pointPatch&, const Field<Type>&, const dictionary&)"
121 " : constructing pointPatchField<Type>"
125 word patchFieldType(dict.lookup("type"));
127 typename dictionaryConstructorTable::iterator cstrIter
128 = dictionaryConstructorTablePtr_->find(patchFieldType);
130 if (cstrIter == dictionaryConstructorTablePtr_->end())
132 if (!disallowGenericPointPatchField)
134 cstrIter = dictionaryConstructorTablePtr_->find("generic");
137 if (cstrIter == dictionaryConstructorTablePtr_->end())
141 "PointPatchField<Type>::"
142 "New(const pointPatch&, const Field<Type>&, const dictionary&)",
144 ) << "Unknown patchField type " << patchFieldType
145 << " for patch type " << p.type() << nl << nl
146 << "Valid patchField types are :" << endl
147 << dictionaryConstructorTablePtr_->sortedToc()
148 << exit(FatalIOError);
152 // Construct (but not necesarily returned)
153 autoPtr<pointPatchField<Type> > pfPtr(cstrIter()(p, iF, dict));
157 !dict.found("patchType")
158 || word(dict.lookup("patchType")) != p.type()
161 if (pfPtr().constraintType() == p.constraintType())
163 // Compatible (constraint-wise) with the patch type
168 // Use default constraint type
169 typename dictionaryConstructorTable::iterator patchTypeCstrIter
170 = dictionaryConstructorTablePtr_->find(p.type());
172 if (patchTypeCstrIter == dictionaryConstructorTablePtr_->end())
176 "PointPatchField<Type>const pointPatch&, "
177 "const Field<Type>&, const dictionary&)",
179 ) << "inconsistent patch and patchField types for \n"
180 << " patch type " << p.type()
181 << " and patchField type " << patchFieldType
182 << exit(FatalIOError);
185 return patchTypeCstrIter()(p, iF, dict);
189 return cstrIter()(p, iF, dict);
193 // Return a pointer to a new patch created on freestore from
194 // a given pointPatchField<Type> mapped onto a new patch
196 Foam::autoPtr<Foam::pointPatchField<Type> > Foam::pointPatchField<Type>::New
198 const pointPatchField<Type>& ptf,
200 const DimensionedField<Type, pointMesh>& iF,
201 const pointPatchFieldMapper& pfMapper
206 Info<< "PointPatchField<Type>::"
207 "New(const pointPatchField<Type>&,"
208 " const pointPatch&, const Field<Type>&, "
209 "const pointPatchFieldMapper&) : "
210 "constructing pointPatchField<Type>"
214 typename patchMapperConstructorTable::iterator cstrIter =
215 patchMapperConstructorTablePtr_->find(ptf.type());
217 if (cstrIter == patchMapperConstructorTablePtr_->end())
221 "PointPatchField<Type>::New"
223 "const pointPatchField<Type>&, "
224 "const pointPatch&, "
225 "const DimensionedField<Type, pointMesh>&, "
226 "const pointPatchFieldMapper&"
228 ) << "Unknown patchField type "
229 << ptf.type() << nl << nl
230 << "Valid patchField types are :" << endl
231 << patchMapperConstructorTablePtr_->sortedToc()
235 return cstrIter()(ptf, p, iF, pfMapper);
239 // ************************************************************************* //