Forward compatibility: flex
[foam-extend-3.2.git] / src / finiteVolume / fields / fvsPatchFields / fvsPatchField / newFvsPatchField.C
blobaa54c01b1a8c7bfc97bd9024fa0b7bfca02b36bc
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 \*---------------------------------------------------------------------------*/
26 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
28 namespace Foam
31 // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
33 template<class Type>
34 tmp<fvsPatchField<Type> > fvsPatchField<Type>::New
36     const word& patchFieldType,
37     const fvPatch& p,
38     const DimensionedField<Type, surfaceMesh>& iF
41     if (debug)
42     {
43         Info<< "fvsPatchField<Type>::New(const word&, const fvPatch&, "
44                "const DimensionedField<Type, surfaceMesh>&) : "
45                "constructing fvsPatchField<Type>"
46             << endl;
47     }
49     typename patchConstructorTable::iterator cstrIter =
50         patchConstructorTablePtr_->find(patchFieldType);
52     if (cstrIter == patchConstructorTablePtr_->end())
53     {
54         if (cstrIter == patchConstructorTablePtr_->end())
55         {
56             FatalErrorIn
57             (
58                 "fvsPatchField<Type>::New(const word&, const fvPatch&, "
59                 "const DimensionedField<Type, surfaceMesh>)"
60             )   << "Unknown patch field type " << patchFieldType
61                 << endl << endl
62                 << "Valid patchField types are :" << endl
63                 << patchConstructorTablePtr_->sortedToc()
64                 << exit(FatalError);
65         }
66     }
68     typename patchConstructorTable::iterator patchTypeCstrIter =
69         patchConstructorTablePtr_->find(p.type());
71     if (patchTypeCstrIter != patchConstructorTablePtr_->end())
72     {
73         return patchTypeCstrIter()(p, iF);
74     }
75     else
76     {
77         return cstrIter()(p, iF);
78     }
82 template<class Type>
83 tmp<fvsPatchField<Type> > fvsPatchField<Type>::New
85     const fvPatch& p,
86     const DimensionedField<Type, surfaceMesh>& iF,
87     const dictionary& dict
90     if (debug)
91     {
92         Info<< "fvsPatchField<Type>::New(const fvPatch&, "
93                 "const DimensionedField<Type, surfaceMesh>&, "
94                 "const dictionary&) : "
95                "constructing fvsPatchField<Type>"
96             << endl;
97     }
99     word patchFieldType(dict.lookup("type"));
101     typename dictionaryConstructorTable::iterator cstrIter
102         = dictionaryConstructorTablePtr_->find(patchFieldType);
104     if (cstrIter == dictionaryConstructorTablePtr_->end())
105     {
106         if (!disallowDefaultFvsPatchField)
107         {
108             cstrIter = dictionaryConstructorTablePtr_->find
109             (
110                 fvsPatchField<Type>::calculatedType()
111             );
112         }
114         if (cstrIter == dictionaryConstructorTablePtr_->end())
115         {
116             FatalIOErrorIn
117             (
118                 "fvsPatchField<Type>::New(const fvPatch&, "
119                 "const DimensionedField<Type, surfaceMesh>&, "
120                 "const dictionary&)",
121                 dict
122             )   << "Unknown patchField type " << patchFieldType
123                 << " for patch type " << p.type() << endl << endl
124                 << "Valid patchField types are :" << endl
125                 << dictionaryConstructorTablePtr_->sortedToc()
126                 << exit(FatalIOError);
127         }
128     }
130     if
131     (
132         !dict.found("patchType")
133      || word(dict.lookup("patchType")) != p.type()
134     )
135     {
136         typename dictionaryConstructorTable::iterator patchTypeCstrIter
137             = dictionaryConstructorTablePtr_->find(p.type());
139         if
140         (
141             patchTypeCstrIter != dictionaryConstructorTablePtr_->end()
142          && patchTypeCstrIter() != cstrIter()
143         )
144         {
145             FatalIOErrorIn
146             (
147                 "fvsPatchField<Type>const fvPatch&, "
148                 "const DimensionedField<Type, surfaceMesh>&, "
149                 "const dictionary&)",
150                 dict
151             )   << "inconsistent patch and patchField types for field "
152                 << iF.name() << "\n"
153                 << "    patch type " << p.type()
154                 << " and patchField type " << patchFieldType
155                 << exit(FatalIOError);
156         }
157     }
159     return cstrIter()(p, iF, dict);
163 // Return a pointer to a new patch created on freestore from
164 // a given fvsPatchField<Type> mapped onto a new patch
165 template<class Type>
166 tmp<fvsPatchField<Type> > fvsPatchField<Type>::New
168     const fvsPatchField<Type>& ptf,
169     const fvPatch& p,
170     const DimensionedField<Type, surfaceMesh>& iF,
171     const fvPatchFieldMapper& pfMapper
174     if (debug)
175     {
176         Info<< "fvsPatchField<Type>::New(const fvsPatchField<Type>&,"
177                " const fvPatch&, const DimensionedField<Type, surfaceMesh>&, "
178                "const fvPatchFieldMapper&) : "
179                "constructing fvsPatchField<Type>"
180             << endl;
181     }
183     typename patchMapperConstructorTable::iterator cstrIter =
184         patchMapperConstructorTablePtr_->find(ptf.type());
186     if (cstrIter == patchMapperConstructorTablePtr_->end())
187     {
188         FatalErrorIn
189         (
190             "fvsPatchField<Type>::New(const fvsPatchField<Type>&, "
191             "const fvPatch&, const Field<Type>&, "
192             "const fvPatchFieldMapper&)"
193         )   << "unknown patch field type " << ptf.type() << endl << endl
194             << "Valid patchField types are :" << endl
195             << patchMapperConstructorTablePtr_->sortedToc()
196             << exit(FatalError);
197     }
199     typename patchMapperConstructorTable::iterator
200         patchTypeCstrIter = patchMapperConstructorTablePtr_->find(p.type());
202     if (patchTypeCstrIter != patchMapperConstructorTablePtr_->end())
203     {
204         return patchTypeCstrIter()(ptf, p, iF, pfMapper);
205     }
206     else
207     {
208         return cstrIter()(ptf, p, iF, pfMapper);
209     }
213 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
215 } // End namespace Foam
217 // ************************************************************************* //