initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / finiteVolume / fields / fvPatchFields / constraint / processor / processorFvPatchField.C
blobc2ae8d81be20fc8f4d3a2f2a76c345dc2167be57
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
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 "processorFvPatchField.H"
28 #include "processorFvPatch.H"
29 #include "IPstream.H"
30 #include "OPstream.H"
31 #include "demandDrivenData.H"
32 #include "transformField.H"
34 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 namespace Foam
39 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
41 template<class Type>
42 processorFvPatchField<Type>::processorFvPatchField
44     const fvPatch& p,
45     const DimensionedField<Type, volMesh>& iF
48     coupledFvPatchField<Type>(p, iF),
49     procPatch_(refCast<const processorFvPatch>(p))
53 template<class Type>
54 processorFvPatchField<Type>::processorFvPatchField
56     const fvPatch& p,
57     const DimensionedField<Type, volMesh>& iF,
58     const Field<Type>& f
61     coupledFvPatchField<Type>(p, iF, f),
62     procPatch_(refCast<const processorFvPatch>(p))
66 // Construct by mapping given processorFvPatchField<Type>
67 template<class Type>
68 processorFvPatchField<Type>::processorFvPatchField
70     const processorFvPatchField<Type>& ptf,
71     const fvPatch& p,
72     const DimensionedField<Type, volMesh>& iF,
73     const fvPatchFieldMapper& mapper
76     coupledFvPatchField<Type>(ptf, p, iF, mapper),
77     procPatch_(refCast<const processorFvPatch>(p))
79     if (!isType<processorFvPatch>(this->patch()))
80     {
81         FatalErrorIn
82         (
83             "processorFvPatchField<Type>::processorFvPatchField\n"
84             "(\n"
85             "    const processorFvPatchField<Type>& ptf,\n"
86             "    const fvPatch& p,\n"
87             "    const DimensionedField<Type, volMesh>& iF,\n"
88             "    const fvPatchFieldMapper& mapper\n"
89             ")\n"
90         )   << "\n    patch type '" << p.type()
91             << "' not constraint type '" << typeName << "'"
92             << "\n    for patch " << p.name()
93             << " of field " << this->dimensionedInternalField().name()
94             << " in file " << this->dimensionedInternalField().objectPath()
95             << exit(FatalIOError);
96     }
100 template<class Type>
101 processorFvPatchField<Type>::processorFvPatchField
103     const fvPatch& p,
104     const DimensionedField<Type, volMesh>& iF,
105     const dictionary& dict
108     coupledFvPatchField<Type>(p, iF, dict),
109     procPatch_(refCast<const processorFvPatch>(p))
111     if (!isType<processorFvPatch>(p))
112     {
113         FatalIOErrorIn
114         (
115             "processorFvPatchField<Type>::processorFvPatchField\n"
116             "(\n"
117             "    const fvPatch& p,\n"
118             "    const Field<Type>& field,\n"
119             "    const dictionary& dict\n"
120             ")\n",
121             dict
122         )   << "\n    patch type '" << p.type()
123             << "' not constraint type '" << typeName << "'"
124             << "\n    for patch " << p.name()
125             << " of field " << this->dimensionedInternalField().name()
126             << " in file " << this->dimensionedInternalField().objectPath()
127             << exit(FatalIOError);
128     }
132 template<class Type>
133 processorFvPatchField<Type>::processorFvPatchField
135     const processorFvPatchField<Type>& ptf
138     processorLduInterfaceField(),
139     coupledFvPatchField<Type>(ptf),
140     procPatch_(refCast<const processorFvPatch>(ptf.patch()))
144 template<class Type>
145 processorFvPatchField<Type>::processorFvPatchField
147     const processorFvPatchField<Type>& ptf,
148     const DimensionedField<Type, volMesh>& iF
151     coupledFvPatchField<Type>(ptf, iF),
152     procPatch_(refCast<const processorFvPatch>(ptf.patch()))
156 // * * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * //
158 template<class Type>
159 processorFvPatchField<Type>::~processorFvPatchField()
163 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
165 template<class Type>
166 tmp<Field<Type> > processorFvPatchField<Type>::patchNeighbourField() const
168     return *this;
172 template<class Type>
173 void processorFvPatchField<Type>::initEvaluate
175     const Pstream::commsTypes commsType
178     if (Pstream::parRun())
179     {
180         procPatch_.compressedSend(commsType, this->patchInternalField()());
181     }
185 template<class Type>
186 void processorFvPatchField<Type>::evaluate
188     const Pstream::commsTypes commsType
191     if (Pstream::parRun())
192     {
193         procPatch_.compressedReceive<Type>(commsType, *this);
195         if (doTransform())
196         {
197             transform(*this, procPatch_.forwardT(), *this);
198         }
199     }
203 template<class Type>
204 tmp<Field<Type> > processorFvPatchField<Type>::snGrad() const
206     return this->patch().deltaCoeffs()*(*this - this->patchInternalField());
210 template<class Type>
211 void processorFvPatchField<Type>::initInterfaceMatrixUpdate
213     const scalarField& psiInternal,
214     scalarField&,
215     const lduMatrix&,
216     const scalarField&,
217     const direction,
218     const Pstream::commsTypes commsType
219 ) const
221     procPatch_.compressedSend
222     (
223         commsType,
224         this->patch().patchInternalField(psiInternal)()
225     );
229 template<class Type>
230 void processorFvPatchField<Type>::updateInterfaceMatrix
232     const scalarField&,
233     scalarField& result,
234     const lduMatrix&,
235     const scalarField& coeffs,
236     const direction cmpt,
237     const Pstream::commsTypes commsType
238 ) const
240     scalarField pnf
241     (
242         procPatch_.compressedReceive<scalar>(commsType, this->size())()
243     );
245     // Transform according to the transformation tensor
246     transformCoupleField(pnf, cmpt);
248     // Multiply the field by coefficients and add into the result
250     const unallocLabelList& faceCells = this->patch().faceCells();
252     forAll(faceCells, elemI)
253     {
254         result[faceCells[elemI]] -= coeffs[elemI]*pnf[elemI];
255     }
259 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
261 } // End namespace Foam
263 // ************************************************************************* //