initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / finiteVolume / fields / fvPatchFields / fvPatchField / newFvPatchField.C
blob59fc3b363350825273474e1aba64ca5a3b9aaedd
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 // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
29 template<class Type>
30 Foam::tmp<Foam::fvPatchField<Type> > Foam::fvPatchField<Type>::New
32     const word& patchFieldType,
33     const fvPatch& p,
34     const DimensionedField<Type, volMesh>& iF
37     if (debug)
38     {
39         Info<< "fvPatchField<Type>::New(const word&, const fvPatch&, "
40                "const DimensionedField<Type, volMesh>&) : patchFieldType="
41             << patchFieldType
42             << endl;
43     }
45     typename patchConstructorTable::iterator cstrIter =
46         patchConstructorTablePtr_->find(patchFieldType);
48     if (cstrIter == patchConstructorTablePtr_->end())
49     {
50         FatalErrorIn
51         (
52             "fvPatchField<Type>::New(const word&, const fvPatch&, "
53             "const DimensionedField<Type, volMesh>&)"
54         )   << "Unknown patchTypefield type " << patchFieldType
55             << endl << endl
56             << "Valid patchField types are :" << endl
57             << patchConstructorTablePtr_->toc()
58             << exit(FatalError);
59     }
61     typename patchConstructorTable::iterator patchTypeCstrIter =
62         patchConstructorTablePtr_->find(p.type());
64     if (patchTypeCstrIter != patchConstructorTablePtr_->end())
65     {
66         return patchTypeCstrIter()(p, iF);
67     }
68     else
69     {
70         return cstrIter()(p, iF);
71     }
75 template<class Type>
76 Foam::tmp<Foam::fvPatchField<Type> > Foam::fvPatchField<Type>::New
78     const fvPatch& p,
79     const DimensionedField<Type, volMesh>& iF,
80     const dictionary& dict
83     word patchFieldType(dict.lookup("type"));
85     if (debug)
86     {
87         Info<< "fvPatchField<Type>::New(const fvPatch&, "
88                "const DimensionedField<Type, volMesh>&, "
89                "const dictionary&) : patchFieldType="  << patchFieldType
90             << endl;
91     }
93     typename dictionaryConstructorTable::iterator cstrIter
94         = dictionaryConstructorTablePtr_->find(patchFieldType);
96     if (cstrIter == dictionaryConstructorTablePtr_->end())
97     {
98         if (!disallowGenericFvPatchField)
99         {
100             cstrIter = dictionaryConstructorTablePtr_->find("generic");
101         }
103         if (cstrIter == dictionaryConstructorTablePtr_->end())
104         {
105             FatalIOErrorIn
106             (
107                 "fvPatchField<Type>::New(const fvPatch&, "
108                 "const DimensionedField<Type, volMesh>&, "
109                 "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                 "fvPatchField<Type>::New(const fvPatch&, "
137                 "const DimensionedField<Type, volMesh>&, "
138                 "const dictionary&)",
139                 dict
140             )   << "inconsistent patch and patchField types for \n"
141                    "    patch type " << p.type()
142                 << " and patchField type " << patchFieldType
143                 << exit(FatalIOError);
144         }
145     }
147     return cstrIter()(p, iF, dict);
151 template<class Type>
152 Foam::tmp<Foam::fvPatchField<Type> > Foam::fvPatchField<Type>::New
154     const fvPatchField<Type>& ptf,
155     const fvPatch& p,
156     const DimensionedField<Type, volMesh>& iF,
157     const fvPatchFieldMapper& pfMapper
160     if (debug)
161     {
162         Info<< "fvPatchField<Type>::New(const fvPatchField<Type>&, "
163                "const fvPatch&, const DimensionedField<Type, volMesh>&, "
164                "const fvPatchFieldMapper&) : "
165                "constructing fvPatchField<Type>"
166             << endl;
167     }
169     typename patchMapperConstructorTable::iterator cstrIter =
170         patchMapperConstructorTablePtr_->find(ptf.type());
172     if (cstrIter == patchMapperConstructorTablePtr_->end())
173     {
174         FatalErrorIn
175         (
176             "fvPatchField<Type>::New(const fvPatchField<Type>&, "
177             "const fvPatch&, const DimensionedField<Type, volMesh>&, "
178             "const fvPatchFieldMapper&)"
179         )   << "unknown patchTypefield type " << ptf.type() << endl << endl
180             << "Valid patchField types are :" << endl
181             << patchMapperConstructorTablePtr_->toc()
182             << exit(FatalError);
183     }
185     return cstrIter()(ptf, p, iF, pfMapper);
189 // ************************************************************************* //