fixed writing out entries in advective bc
[OpenFOAM-1.6-ext.git] / src / finiteArea / fields / faPatchFields / constraint / cyclic / cyclicFaPatchField.C
blobf49649a617fb354f0e2b7b5f2f6a24a332c4c1b7
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 #include "cyclicFaPatchField.H"
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
31 namespace Foam
34 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
36 template<class Type>
37 cyclicFaPatchField<Type>::cyclicFaPatchField
39     const faPatch& p,
40     const DimensionedField<Type, areaMesh>& iF
43     coupledFaPatchField<Type>(p, iF),
44     cyclicPatch_(refCast<const cyclicFaPatch>(p))
48 template<class Type>
49 cyclicFaPatchField<Type>::cyclicFaPatchField
51     const cyclicFaPatchField<Type>& ptf,
52     const faPatch& p,
53     const DimensionedField<Type, areaMesh>& iF,
54     const faPatchFieldMapper& mapper
57     coupledFaPatchField<Type>(ptf, p, iF, mapper),
58     cyclicPatch_(refCast<const cyclicFaPatch>(p))
60     if (!isType<cyclicFaPatch>(this->patch()))
61     {
62         FatalErrorIn
63         (
64             "cyclicFaPatchField<Type>::cyclicFaPatchField\n"
65             "(\n"
66             "    const cyclicFaPatchField<Type>& ptf,\n"
67             "    const faPatch& p,\n"
68             "    const DimensionedField<Type, areaMesh>& iF,\n"
69             "    const faPatchFieldMapper& mapper\n"
70             ")\n"
71         )   << "\n    patch type '" << p.type()
72             << "' not constraint type '" << typeName << "'"
73             << "\n    for patch " << p.name()
74             << " of field " << this->dimensionedInternalField().name()
75             << " in file " << this->dimensionedInternalField().objectPath()
76             << exit(FatalIOError);
77     }
81 template<class Type>
82 cyclicFaPatchField<Type>::cyclicFaPatchField
84     const faPatch& p,
85     const DimensionedField<Type, areaMesh>& iF,
86     const dictionary& dict
89     coupledFaPatchField<Type>(p, iF, dict),
90     cyclicPatch_(refCast<const cyclicFaPatch>(p))
92     if (!isType<cyclicFaPatch>(p))
93     {
94         FatalIOErrorIn
95         (
96             "cyclicFaPatchField<Type>::cyclicFaPatchField\n"
97             "(\n"
98             "    const faPatch& p,\n"
99             "    const Field<Type>& field,\n"
100             "    const dictionary& dict\n"
101             ")\n",
102             dict
103         )   << "\n    patch type '" << p.type()
104             << "' not constraint type '" << typeName << "'"
105             << "\n    for patch " << p.name()
106             << " of field " << this->dimensionedInternalField().name()
107             << " in file " << this->dimensionedInternalField().objectPath()
108             << exit(FatalIOError);
109     }
111     this->evaluate(Pstream::blocking);
115 template<class Type>
116 cyclicFaPatchField<Type>::cyclicFaPatchField
118     const cyclicFaPatchField<Type>& ptf
121     cyclicLduInterfaceField(),
122     coupledFaPatchField<Type>(ptf),
123     cyclicPatch_(ptf.cyclicPatch_)
127 template<class Type>
128 cyclicFaPatchField<Type>::cyclicFaPatchField
130     const cyclicFaPatchField<Type>& ptf,
131     const DimensionedField<Type, areaMesh>& iF
134     coupledFaPatchField<Type>(ptf, iF),
135     cyclicPatch_(ptf.cyclicPatch_)
139 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
141 template<class Type>
142 tmp<Field<Type> > cyclicFaPatchField<Type>::patchNeighbourField() const
144     const Field<Type>& iField = this->internalField();
145     const unallocLabelList& faceCells = cyclicPatch_.faceCells();
147     tmp<Field<Type> > tpnf(new Field<Type>(this->size()));
148     Field<Type>& pnf = tpnf();
150     label sizeby2 = this->size()/2;
152     if (doTransform())
153     {
154         for (label facei=0; facei<sizeby2; facei++)
155         {
156             pnf[facei] = transform
157             (
158                 forwardT()[0], iField[faceCells[facei + sizeby2]]
159             );
161             pnf[facei + sizeby2] = transform
162             (
163                 reverseT()[0], iField[faceCells[facei]]
164             );
165         }
166     }
167     else
168     {
169         for (label facei=0; facei<sizeby2; facei++)
170         {
171             pnf[facei] = iField[faceCells[facei + sizeby2]];
172             pnf[facei + sizeby2] = iField[faceCells[facei]];
173         }
174     }
176     return tpnf;
180 template<class Type>
181 void cyclicFaPatchField<Type>::updateInterfaceMatrix
183     const scalarField& psiInternal,
184     scalarField& result,
185     const lduMatrix&,
186     const scalarField& coeffs,
187     const direction cmpt,
188     const Pstream::commsTypes
189 ) const
191     scalarField pnf(this->size());
193     label sizeby2 = this->size()/2;
194     const unallocLabelList& faceCells = cyclicPatch_.faceCells();
196     for (label facei=0; facei<sizeby2; facei++)
197     {
198         pnf[facei] = psiInternal[faceCells[facei + sizeby2]];
199         pnf[facei + sizeby2] = psiInternal[faceCells[facei]];
200     }
202     // Transform according to the transformation tensors
203     transformCoupleField(pnf, cmpt);
205     // Multiply the field by coefficients and add into the result
206     forAll(faceCells, elemI)
207     {
208         result[faceCells[elemI]] -= coeffs[elemI]*pnf[elemI];
209     }
213 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
215 } // End namespace Foam
217 // ************************************************************************* //