Merge branch 'master' of ssh://git.code.sf.net/p/foam-extend/foam-extend-3.2
[foam-extend-3.2.git] / src / finiteVolume / fields / fvPatchFields / fvPatchField / newFvPatchField.C
blob6801fcf5a34a1a2dc19a95ec50ae9a69b753e548
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | foam-extend: Open Source CFD
4    \\    /   O peration     | Version:     3.2
5     \\  /    A nd           | Web:         http://www.foam-extend.org
6      \\/     M anipulation  | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
8 License
9     This file is part of foam-extend.
11     foam-extend 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 3 of the License, or (at your
14     option) any later version.
16     foam-extend is distributed in the hope that it will be useful, but
17     WITHOUT ANY WARRANTY; without even the implied warranty of
18     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19     General Public License for more details.
21     You should have received a copy of the GNU General Public License
22     along with foam-extend.  If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
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 patch field type " << patchFieldType
55             << " for field " << iF.name() << " on patch " << p.name()
56             << nl << nl
57             << "Valid patchField types are :" << endl
58             << patchConstructorTablePtr_->sortedToc()
59             << exit(FatalError);
60     }
62     typename patchConstructorTable::iterator patchTypeCstrIter =
63         patchConstructorTablePtr_->find(p.type());
65     if (patchTypeCstrIter != patchConstructorTablePtr_->end())
66     {
67         return patchTypeCstrIter()(p, iF);
68     }
69     else
70     {
71         return cstrIter()(p, iF);
72     }
76 template<class Type>
77 Foam::tmp<Foam::fvPatchField<Type> > Foam::fvPatchField<Type>::New
79     const fvPatch& p,
80     const DimensionedField<Type, volMesh>& iF,
81     const dictionary& dict
84     word patchFieldType(dict.lookup("type"));
86     if (debug)
87     {
88         Info<< "fvPatchField<Type>::New(const fvPatch&, "
89                "const DimensionedField<Type, volMesh>&, "
90                "const dictionary&) : patchFieldType = "  << patchFieldType
91             << endl;
92     }
94     typename dictionaryConstructorTable::iterator cstrIter
95         = dictionaryConstructorTablePtr_->find(patchFieldType);
97     if (cstrIter == dictionaryConstructorTablePtr_->end())
98     {
99         if (!disallowGenericFvPatchField)
100         {
101             cstrIter = dictionaryConstructorTablePtr_->find("generic");
102         }
104         if (cstrIter == dictionaryConstructorTablePtr_->end())
105         {
106             FatalIOErrorIn
107             (
108                 "fvPatchField<Type>::New(const fvPatch&, "
109                 "const DimensionedField<Type, volMesh>&, "
110                 "const dictionary&)",
111                 dict
112             )   << "Unknown patch field type " << patchFieldType
113                 << " for field " << iF.name() << " on patch " << p.name()
114                 << " for patch type " << p.type() << endl << endl
115                 << "Valid patch field types are :" << endl
116                 << dictionaryConstructorTablePtr_->sortedToc()
117                 << exit(FatalIOError);
118         }
119     }
121     if
122     (
123        !dict.found("patchType")
124      || word(dict.lookup("patchType")) != p.type()
125     )
126     {
127         typename dictionaryConstructorTable::iterator patchTypeCstrIter
128             = dictionaryConstructorTablePtr_->find(p.type());
130         if
131         (
132             patchTypeCstrIter != dictionaryConstructorTablePtr_->end()
133          && patchTypeCstrIter() != cstrIter()
134         )
135         {
136             FatalIOErrorIn
137             (
138                 "fvPatchField<Type>::New(const fvPatch&, "
139                 "const DimensionedField<Type, volMesh>&, "
140                 "const dictionary&)",
141                 dict
142             )   << "Inconsistent patch and patchField types for field "
143                 << iF.name() << " on patch " << p.name() << "\n"
144                 << "    patch type " << p.type()
145                 << " and patchField type " << patchFieldType
146                 << exit(FatalIOError);
147         }
148     }
150     return cstrIter()(p, iF, dict);
154 template<class Type>
155 Foam::tmp<Foam::fvPatchField<Type> > Foam::fvPatchField<Type>::New
157     const fvPatchField<Type>& ptf,
158     const fvPatch& p,
159     const DimensionedField<Type, volMesh>& iF,
160     const fvPatchFieldMapper& pfMapper
163     if (debug)
164     {
165         Info<< "fvPatchField<Type>::New(const fvPatchField<Type>&, "
166                "const fvPatch&, const DimensionedField<Type, volMesh>&, "
167                "const fvPatchFieldMapper&) : "
168                "constructing fvPatchField<Type>"
169             << endl;
170     }
172     typename patchMapperConstructorTable::iterator cstrIter =
173         patchMapperConstructorTablePtr_->find(ptf.type());
175     if (cstrIter == patchMapperConstructorTablePtr_->end())
176     {
177         FatalErrorIn
178         (
179             "fvPatchField<Type>::New(const fvPatchField<Type>&, "
180             "const fvPatch&, const DimensionedField<Type, volMesh>&, "
181             "const fvPatchFieldMapper&)"
182         )   << "unknown patch field type " << ptf.type()
183             << " for field " << iF.name() << " on patch " << p.name()
184             << nl << nl
185             << "Valid patchField types are :" << endl
186             << patchMapperConstructorTablePtr_->sortedToc()
187             << exit(FatalError);
188     }
190     return cstrIter()(ptf, p, iF, pfMapper);
194 // ************************************************************************* //