BUG: UListIO: byteSize overflowing on really big faceLists
[OpenFOAM-2.0.x.git] / src / finiteVolume / fields / fvsPatchFields / fvsPatchField / fvsPatchFieldNew.C
blob038b874f140835a472e15cac43a6fbe505782dd1
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
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
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
19     for more details.
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 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
28 namespace Foam
31 // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
33 template<class Type>
34 tmp<fvsPatchField<Type> > fvsPatchField<Type>::New
36     const word& patchFieldType,
37     const word& actualPatchType,
38     const fvPatch& p,
39     const DimensionedField<Type, surfaceMesh>& iF
42     if (debug)
43     {
44         Info<< "fvsPatchField<Type>::New(const word&, const word&"
45                ", const fvPatch&, const Field<Type>&) : "
46                "constructing fvsPatchField<Type>"
47             << endl;
48     }
50     typename patchConstructorTable::iterator cstrIter =
51         patchConstructorTablePtr_->find(patchFieldType);
53     if (cstrIter == patchConstructorTablePtr_->end())
54     {
55         FatalErrorIn
56         (
57             "fvsPatchField<Type>::New(const word&, const word&, const fvPatch&"
58             ", const Field<Type>&)"
59         )   << "Unknown patchField type "
60             << patchFieldType << nl << nl
61             << "Valid patchField types are :" << endl
62             << patchConstructorTablePtr_->sortedToc()
63             << exit(FatalError);
64     }
66     if
67     (
68         actualPatchType == word::null
69      || actualPatchType != p.type()
70     )
71     {
72         typename patchConstructorTable::iterator patchTypeCstrIter =
73             patchConstructorTablePtr_->find(p.type());
75         if (patchTypeCstrIter != patchConstructorTablePtr_->end())
76         {
77             return patchTypeCstrIter()(p, iF);
78         }
79         else
80         {
81             return cstrIter()(p, iF);
82         }
83     }
84     else
85     {
86         return cstrIter()(p, iF);
87     }
91 template<class Type>
92 tmp<fvsPatchField<Type> > fvsPatchField<Type>::New
94     const word& patchFieldType,
95     const fvPatch& p,
96     const DimensionedField<Type, surfaceMesh>& iF
99     return New(patchFieldType, word::null, p, iF);
103 template<class Type>
104 tmp<fvsPatchField<Type> > fvsPatchField<Type>::New
106     const fvPatch& p,
107     const DimensionedField<Type, surfaceMesh>& iF,
108     const dictionary& dict
111     if (debug)
112     {
113         Info<< "fvsPatchField<Type>::New(const fvPatch&, const Field<Type>&, "
114                "const dictionary&) : "
115                "constructing fvsPatchField<Type>"
116             << endl;
117     }
119     const word patchFieldType(dict.lookup("type"));
121     typename dictionaryConstructorTable::iterator cstrIter
122         = dictionaryConstructorTablePtr_->find(patchFieldType);
124     if (cstrIter == dictionaryConstructorTablePtr_->end())
125     {
126         if (!disallowGenericFvsPatchField)
127         {
128             cstrIter = dictionaryConstructorTablePtr_->find("generic");
129         }
131         if (cstrIter == dictionaryConstructorTablePtr_->end())
132         {
133             FatalIOErrorIn
134             (
135                 "fvsPatchField<Type>::New(const fvPatch&, const Field<Type>&, "
136                 "const dictionary&)",
137                 dict
138             )   << "Unknown patchField type " << patchFieldType
139                 << " for patch type " << p.type() << nl << nl
140                 << "Valid patchField types are :" << endl
141                 << dictionaryConstructorTablePtr_->sortedToc()
142                 << exit(FatalIOError);
143         }
144     }
146     if
147     (
148         !dict.found("patchType")
149      || word(dict.lookup("patchType")) != p.type()
150     )
151     {
152         typename dictionaryConstructorTable::iterator patchTypeCstrIter
153             = dictionaryConstructorTablePtr_->find(p.type());
155         if
156         (
157             patchTypeCstrIter != dictionaryConstructorTablePtr_->end()
158          && patchTypeCstrIter() != cstrIter()
159         )
160         {
161             FatalIOErrorIn
162             (
163                 "fvsPatchField<Type>const fvPatch&, const Field<Type>&, "
164                 "const dictionary&)",
165                 dict
166             )   << "inconsistent patch and patchField types for \n"
167                    "    patch type " << p.type()
168                 << " and patchField type " << patchFieldType
169                 << exit(FatalIOError);
170         }
171     }
173     return cstrIter()(p, iF, dict);
177 // Return a pointer to a new patch created on freestore from
178 // a given fvsPatchField<Type> mapped onto a new patch
179 template<class Type>
180 tmp<fvsPatchField<Type> > fvsPatchField<Type>::New
182     const fvsPatchField<Type>& ptf,
183     const fvPatch& p,
184     const DimensionedField<Type, surfaceMesh>& iF,
185     const fvPatchFieldMapper& pfMapper
188     if (debug)
189     {
190         Info<< "fvsPatchField<Type>::New(const fvsPatchField<Type>&,"
191                " const fvPatch&, const Field<Type>&, "
192                "const fvPatchFieldMapper&) : "
193                "constructing fvsPatchField<Type>"
194             << endl;
195     }
197     typename patchMapperConstructorTable::iterator cstrIter =
198         patchMapperConstructorTablePtr_->find(ptf.type());
200     if (cstrIter == patchMapperConstructorTablePtr_->end())
201     {
202         FatalErrorIn
203         (
204             "fvsPatchField<Type>::New(const fvsPatchField<Type>&, "
205             "const fvPatch&, const Field<Type>&, "
206             "const fvPatchFieldMapper&)"
207         )   << "Unknown patchField type " << ptf.type() << nl << nl
208             << "Valid patchField types are :" << endl
209             << patchMapperConstructorTablePtr_->sortedToc()
210             << exit(FatalError);
211     }
213     typename patchMapperConstructorTable::iterator
214         patchTypeCstrIter = patchMapperConstructorTablePtr_->find(p.type());
216     if (patchTypeCstrIter != patchMapperConstructorTablePtr_->end())
217     {
218         return patchTypeCstrIter()(ptf, p, iF, pfMapper);
219     }
220     else
221     {
222         return cstrIter()(ptf, p, iF, pfMapper);
223     }
227 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
229 } // End namespace Foam
231 // ************************************************************************* //