fixed writing out entries in advective bc
[OpenFOAM-1.6-ext.git] / src / finiteArea / fields / faPatchFields / faPatchField / newFaPatchField.C
blobbcb7500768fe32a58f656c518433ad3c92dea2ce
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 namespace Foam
30 // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
32 template<class Type>
33 tmp<faPatchField<Type> > faPatchField<Type>::New
35     const word& patchFieldType,
36     const faPatch& p,
37     const DimensionedField<Type, areaMesh>& iF
40     if (debug)
41     {
42         Info<< "faPatchField<Type>::New(const word&, const faPatch&, "
43                "const DimensionedField<Type, areaMesh>&) : "
44                "constructing faPatchField<Type>"
45             << endl;
46     }
48     typename patchConstructorTable::iterator cstrIter =
49         patchConstructorTablePtr_->find(patchFieldType);
51     if (cstrIter == patchConstructorTablePtr_->end())
52     {
53         FatalErrorIn
54         (
55             "faPatchField<Type>::New(const word&, const faPatch&, "
56             "const DimensionedField<Type, areaMesh>&)"
57         )   << "Unknown patchTypefield type " << patchFieldType
58             << endl << endl
59             << "Valid patchField types are :" << endl
60             << patchConstructorTablePtr_->toc()
61             << exit(FatalError);
62     }
64     typename patchConstructorTable::iterator patchTypeCstrIter =
65         patchConstructorTablePtr_->find(p.type());
67     if (patchTypeCstrIter != patchConstructorTablePtr_->end())
68     {
69         return patchTypeCstrIter()(p, iF);
70     }
71     else
72     {
73         return cstrIter()(p, iF);
74     }
78 template<class Type>
79 tmp<faPatchField<Type> > faPatchField<Type>::New
81     const faPatch& p,
82     const DimensionedField<Type, areaMesh>& iF,
83     const dictionary& dict
86     if (debug)
87     {
88         Info<< "faPatchField<Type>::New(const faPatch&, "
89                "const DimensionedField<Type, areaMesh>&, const dictionary&) : "
90                "constructing faPatchField<Type>"
91             << endl;
92     }
94     word patchFieldType(dict.lookup("type"));
96     typename dictionaryConstructorTable::iterator cstrIter
97         = dictionaryConstructorTablePtr_->find(patchFieldType);
99     if (cstrIter == dictionaryConstructorTablePtr_->end())
100     {
101         if (!disallowDefaultFaPatchField)
102         {
103             cstrIter = dictionaryConstructorTablePtr_->find("default");
104         }
106         if (cstrIter == dictionaryConstructorTablePtr_->end())
107         {
108             FatalIOErrorIn
109             (
110                 "faPatchField<Type>::New(const faPatch&, "
111                 "const DimensionedField<Type, areaMesh>&, const dictionary&)",
112                 dict
113             )   << "Unknown patchField type " << patchFieldType
114                 << " for patch type " << p.type() << endl << endl
115                 << "Valid patchField types are :" << endl
116                 << dictionaryConstructorTablePtr_->toc()
117                 << exit(FatalIOError);
118         }
119     }
121     typename dictionaryConstructorTable::iterator patchTypeCstrIter
122         = dictionaryConstructorTablePtr_->find(p.type());
124     if
125     (
126         patchTypeCstrIter != dictionaryConstructorTablePtr_->end()
127      && *patchTypeCstrIter != *cstrIter
128     )
129     {
130         FatalIOErrorIn
131         (
132             "faPatchField<Type>const faPatch&, "
133             "const DimensionedField<Type, areaMesh>&, const dictionary&)",
134             dict
135         ) << "inconsistent patch and patchField types for \n"
136              "    patch type " << p.type()
137             << " and patchField type " << patchFieldType
138             << exit(FatalIOError);
139     }
141     return cstrIter()(p, iF, dict);
145 template<class Type>
146 tmp<faPatchField<Type> > faPatchField<Type>::New
148     const faPatchField<Type>& ptf,
149     const faPatch& p,
150     const DimensionedField<Type, areaMesh>& iF,
151     const faPatchFieldMapper& pfMapper
154     if (debug)
155     {
156         Info<< "faPatchField<Type>::New(const faPatchField<Type>&,"
157                " const faPatch&, const DimensionedField<Type, areaMesh>&, "
158                "const faPatchFieldMapper&) : "
159                "constructing faPatchField<Type>"
160             << endl;
161     }
163     typename patchMapperConstructorTable::iterator cstrIter =
164         patchMapperConstructorTablePtr_->find(ptf.type());
166     if (cstrIter == patchMapperConstructorTablePtr_->end())
167     {
168         FatalErrorIn
169         (
170             "faPatchField<Type>::New(const faPatchField<Type>&, "
171             "const faPatch&, const DimensionedField<Type, areaMesh>&, "
172             "const faPatchFieldMapper&)"
173         )   << "unknown patchTypefield type " << ptf.type() << endl << endl
174             << "Valid patchField types are :" << endl
175             << patchMapperConstructorTablePtr_->toc()
176             << exit(FatalError);
177     }
179     typename patchMapperConstructorTable::iterator
180         patchTypeCstrIter = patchMapperConstructorTablePtr_->find(p.type());
182     if (patchTypeCstrIter != patchMapperConstructorTablePtr_->end())
183     {
184         return patchTypeCstrIter()(ptf, p, iF, pfMapper);
185     }
186     else
187     {
188         return cstrIter()(ptf, p, iF, pfMapper);
189     }
193 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
195 } // End namespace Foam
197 // ************************************************************************* //