Fix tutorials: coupled/conjugateHeatFoam/conjugateCavity: fix Allrun file
[OpenFOAM-1.6-ext.git] / src / finiteVolume / fields / fvsPatchFields / fvsPatchField / newFvsPatchField.C
blob25818a8c04f41aa924533db6123da6e873174cd1
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright held by original author
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 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
29 namespace Foam
32 // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
34 template<class Type>
35 tmp<fvsPatchField<Type> > fvsPatchField<Type>::New
37     const word& patchFieldType,
38     const fvPatch& p,
39     const DimensionedField<Type, surfaceMesh>& iF
42     if (debug)
43     {
44         Info<< "fvsPatchField<Type>::New(const word&, const fvPatch&, "
45                "const DimensionedField<Type, surfaceMesh>&) : "
46                "constructing fvsPatchField<Type>"
47             << endl;
48     }
50     typename patchConstructorTable::iterator cstrIter =
51         patchConstructorTablePtr_->find(patchFieldType);
53     if (cstrIter == patchConstructorTablePtr_->end())
54     {
55         if (cstrIter == patchConstructorTablePtr_->end())
56         {
57             FatalErrorIn
58             (
59                 "fvsPatchField<Type>::New(const word&, const fvPatch&, "
60                 "const DimensionedField<Type, surfaceMesh>)"
61             )   << "Unknown patch field type " << patchFieldType
62                 << endl << endl
63                 << "Valid patchField types are :" << endl
64                 << patchConstructorTablePtr_->toc()
65                 << exit(FatalError);
66         }
67     }
69     typename patchConstructorTable::iterator patchTypeCstrIter =
70         patchConstructorTablePtr_->find(p.type());
72     if (patchTypeCstrIter != patchConstructorTablePtr_->end())
73     {
74         return patchTypeCstrIter()(p, iF);
75     }
76     else
77     {
78         return cstrIter()(p, iF);
79     }
83 template<class Type>
84 tmp<fvsPatchField<Type> > fvsPatchField<Type>::New
86     const fvPatch& p,
87     const DimensionedField<Type, surfaceMesh>& iF,
88     const dictionary& dict
91     if (debug)
92     {
93         Info<< "fvsPatchField<Type>::New(const fvPatch&, "
94                 "const DimensionedField<Type, surfaceMesh>&, "
95                 "const dictionary&) : "
96                "constructing fvsPatchField<Type>"
97             << endl;
98     }
100     word patchFieldType(dict.lookup("type"));
102     typename dictionaryConstructorTable::iterator cstrIter
103         = dictionaryConstructorTablePtr_->find(patchFieldType);
105     if (cstrIter == dictionaryConstructorTablePtr_->end())
106     {
107         if (!disallowDefaultFvsPatchField)
108         {
109             cstrIter = dictionaryConstructorTablePtr_->find
110             (
111                 fvsPatchField<Type>::calculatedType()
112             );
113         }
115         if (cstrIter == dictionaryConstructorTablePtr_->end())
116         {
117             FatalIOErrorIn
118             (
119                 "fvsPatchField<Type>::New(const fvPatch&, "
120                 "const DimensionedField<Type, surfaceMesh>&, "
121                 "const dictionary&)",
122                 dict
123             )   << "Unknown patchField type " << patchFieldType
124                 << " for patch type " << p.type() << endl << endl
125                 << "Valid patchField types are :" << endl
126                 << dictionaryConstructorTablePtr_->toc()
127                 << exit(FatalIOError);
128         }
129     }
131     if 
132     (
133         !dict.found("patchType")
134      || word(dict.lookup("patchType")) != p.type()
135     )
136     {
137         typename dictionaryConstructorTable::iterator patchTypeCstrIter
138             = dictionaryConstructorTablePtr_->find(p.type());
140         if
141         (
142             patchTypeCstrIter != dictionaryConstructorTablePtr_->end()
143          && patchTypeCstrIter() != cstrIter()
144         )
145         {
146             FatalIOErrorIn
147             (
148                 "fvsPatchField<Type>const fvPatch&, "
149                 "const DimensionedField<Type, surfaceMesh>&, "
150                 "const dictionary&)",
151                 dict
152             )   << "inconsistent patch and patchField types for \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_->toc()
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 // ************************************************************************* //