initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / OpenFOAM / fields / pointPatchFields / pointPatchField / newPointPatchField.C
blob0669f0e79653094ab2b5180c9375fcd14dcd5b41
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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  * * * * * * * * * * * * * * //
29 template<class Type>
30 Foam::autoPtr<Foam::pointPatchField<Type> > Foam::pointPatchField<Type>::New
32     const word& patchFieldType,
33     const pointPatch& p,
34     const DimensionedField<Type, pointMesh>& iF
37     if (debug)
38     {
39         Info<< "PointPatchField<Type>::"
40                "New(const word&, const pointPatch&, const Field<Type>&) : "
41                "constructing pointPatchField<Type>"
42             << endl;
43     }
45     typename pointPatchConstructorTable::iterator cstrIter =
46         pointPatchConstructorTablePtr_->find(patchFieldType);
48     if (cstrIter == pointPatchConstructorTablePtr_->end())
49     {
50         FatalErrorIn
51         (
52             "PointPatchField<Type>::New"
53             "(const word&, const pointPatch&, const Field<Type>&)"
54         )   << "Unknown patchTypefield type "
55             << patchFieldType
56             << endl << endl
57             << "Valid patchField types are :" << endl
58             << pointPatchConstructorTablePtr_->toc()
59             << exit(FatalError);
60     }
62     typename pointPatchConstructorTable::iterator patchTypeCstrIter =
63         pointPatchConstructorTablePtr_->find(p.type());
65     if (patchTypeCstrIter != pointPatchConstructorTablePtr_->end())
66     {
67         return autoPtr<pointPatchField<Type> >(patchTypeCstrIter()(p, iF));
68     }
69     else
70     {
71         return autoPtr<pointPatchField<Type> >(cstrIter()(p, iF));
72     }
76 template<class Type>
77 Foam::autoPtr<Foam::pointPatchField<Type> > Foam::pointPatchField<Type>::New
79     const pointPatch& p,
80     const DimensionedField<Type, pointMesh>& iF,
81     const dictionary& dict
84     if (debug)
85     {
86         Info<< "PointPatchField<Type>::"
87                "New(const pointPatch&, const Field<Type>&, const dictionary&)"
88                " : constructing pointPatchField<Type>"
89             << endl;
90     }
92     word patchFieldType(dict.lookup("type"));
94     typename dictionaryConstructorTable::iterator cstrIter
95         = dictionaryConstructorTablePtr_->find(patchFieldType);
97     if (cstrIter == dictionaryConstructorTablePtr_->end())
98     {
99         if (!disallowGenericPointPatchField)
100         {
101             cstrIter = dictionaryConstructorTablePtr_->find("generic");
102         }
104         if (cstrIter == dictionaryConstructorTablePtr_->end())
105         {
106             FatalIOErrorIn
107             (
108                 "PointPatchField<Type>::"
109                 "New(const pointPatch&, const Field<Type>&, const dictionary&)",
110                 dict
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);
116         }
117     }
119     if
120     (
121        !dict.found("patchType")
122      || word(dict.lookup("patchType")) != p.type()
123     )
124     {
125         typename dictionaryConstructorTable::iterator patchTypeCstrIter
126             = dictionaryConstructorTablePtr_->find(p.type());
128         if
129         (
130             patchTypeCstrIter != dictionaryConstructorTablePtr_->end()
131          && patchTypeCstrIter() != cstrIter()
132         )
133         {
134             FatalIOErrorIn
135             (
136                 "PointPatchField<Type>const pointPatch&, "
137                 "const Field<Type>&, const dictionary&)",
138                 dict
139             )   << "inconsistent patch and patchField types for \n"
140                 << "    patch type " << p.type()
141                 << " and patchField type " << patchFieldType
142                 << exit(FatalIOError);
143         }
144     }
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
152 template<class Type>
153 Foam::autoPtr<Foam::pointPatchField<Type> > Foam::pointPatchField<Type>::New
155     const pointPatchField<Type>& ptf,
156     const pointPatch& p,
157     const DimensionedField<Type, pointMesh>& iF,
158     const pointPatchFieldMapper& pfMapper
161     if (debug)
162     {
163         Info<< "PointPatchField<Type>::"
164                "New(const pointPatchField<Type>&,"
165                " const pointPatch&, const Field<Type>&, "
166                "const pointPatchFieldMapper&) : "
167                "constructing pointPatchField<Type>"
168             << endl;
169     }
171     typename patchMapperConstructorTable::iterator cstrIter =
172         patchMapperConstructorTablePtr_->find(ptf.type());
174     if (cstrIter == patchMapperConstructorTablePtr_->end())
175     {
176         FatalErrorIn
177         (
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()
186             << exit(FatalError);
187     }
189     return autoPtr<pointPatchField<Type> >(cstrIter()(ptf, p, iF, pfMapper));
193 // ************************************************************************* //