1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
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
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"
31 #include "demandDrivenData.H"
32 #include "transformField.H"
34 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
39 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
42 processorFvPatchField<Type>::processorFvPatchField
45 const DimensionedField<Type, volMesh>& iF
48 coupledFvPatchField<Type>(p, iF),
49 procPatch_(refCast<const processorFvPatch>(p))
54 processorFvPatchField<Type>::processorFvPatchField
57 const DimensionedField<Type, volMesh>& iF,
61 coupledFvPatchField<Type>(p, iF, f),
62 procPatch_(refCast<const processorFvPatch>(p))
66 // Construct by mapping given processorFvPatchField<Type>
68 processorFvPatchField<Type>::processorFvPatchField
70 const processorFvPatchField<Type>& ptf,
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()))
83 "processorFvPatchField<Type>::processorFvPatchField\n"
85 " const processorFvPatchField<Type>& ptf,\n"
86 " const fvPatch& p,\n"
87 " const DimensionedField<Type, volMesh>& iF,\n"
88 " const fvPatchFieldMapper& mapper\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);
101 processorFvPatchField<Type>::processorFvPatchField
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))
115 "processorFvPatchField<Type>::processorFvPatchField\n"
117 " const fvPatch& p,\n"
118 " const Field<Type>& field,\n"
119 " const dictionary& dict\n"
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);
133 processorFvPatchField<Type>::processorFvPatchField
135 const processorFvPatchField<Type>& ptf
138 processorLduInterfaceField(),
139 coupledFvPatchField<Type>(ptf),
140 procPatch_(refCast<const processorFvPatch>(ptf.patch()))
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 * * * * * * * * * * * * * * //
159 processorFvPatchField<Type>::~processorFvPatchField()
163 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
166 tmp<Field<Type> > processorFvPatchField<Type>::patchNeighbourField() const
173 void processorFvPatchField<Type>::initEvaluate
175 const Pstream::commsTypes commsType
178 if (Pstream::parRun())
180 procPatch_.compressedSend(commsType, this->patchInternalField()());
186 void processorFvPatchField<Type>::evaluate
188 const Pstream::commsTypes commsType
191 if (Pstream::parRun())
193 procPatch_.compressedReceive<Type>(commsType, *this);
197 transform(*this, procPatch_.forwardT(), *this);
204 tmp<Field<Type> > processorFvPatchField<Type>::snGrad() const
206 return this->patch().deltaCoeffs()*(*this - this->patchInternalField());
211 void processorFvPatchField<Type>::initInterfaceMatrixUpdate
213 const scalarField& psiInternal,
218 const Pstream::commsTypes commsType
221 procPatch_.compressedSend
224 this->patch().patchInternalField(psiInternal)()
230 void processorFvPatchField<Type>::updateInterfaceMatrix
235 const scalarField& coeffs,
236 const direction cmpt,
237 const Pstream::commsTypes commsType
242 procPatch_.compressedReceive<scalar>(commsType, this->size())()
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)
254 result[faceCells[elemI]] -= coeffs[elemI]*pnf[elemI];
259 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
261 } // End namespace Foam
263 // ************************************************************************* //