1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
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
26 Martin Beaudoin, Hydro-Quebec, (2008)
29 Hrvoje Jasak, Wikki Ltd.
31 \*---------------------------------------------------------------------------*/
33 #include "cyclicGgiFvPatchField.H"
34 #include "symmTransformField.H"
36 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
41 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
44 cyclicGgiFvPatchField<Type>::cyclicGgiFvPatchField
47 const DimensionedField<Type, volMesh>& iF
50 coupledFvPatchField<Type>(p, iF),
51 cyclicGgiPatch_(refCast<const cyclicGgiFvPatch>(p))
56 cyclicGgiFvPatchField<Type>::cyclicGgiFvPatchField
59 const DimensionedField<Type, volMesh>& iF,
60 const dictionary& dict
63 coupledFvPatchField<Type>(p, iF, dict, false),
64 cyclicGgiPatch_(refCast<const cyclicGgiFvPatch>(p))
66 if (!isType<cyclicGgiFvPatch>(p))
70 "cyclicGgiFvPatchField<Type>::cyclicGgiFvPatchField\n"
72 " const fvPatch& p,\n"
73 " const DimensionedField<Type, volMesh>& iF,\n"
74 " const dictionary& dict\n"
77 ) << "patch " << this->patch().index() << " not cyclicGgi type. "
78 << "Patch type = " << p.type()
79 << exit(FatalIOError);
82 if (!dict.found("value"))
84 // Grab the internal value for initialisation. (?) HJ, 27/Feb/2009
85 fvPatchField<Type>::operator=(this->patchInternalField()());
91 cyclicGgiFvPatchField<Type>::cyclicGgiFvPatchField
93 const cyclicGgiFvPatchField<Type>& ptf,
95 const DimensionedField<Type, volMesh>& iF,
96 const fvPatchFieldMapper& mapper
99 coupledFvPatchField<Type>(ptf, p, iF, mapper),
100 cyclicGgiPatch_(refCast<const cyclicGgiFvPatch>(p))
102 if (!isType<cyclicGgiFvPatch>(this->patch()))
106 "cyclicGgiFvPatchField<Type>::cyclicGgiFvPatchField\n"
108 " const cyclicGgiFvPatchField<Type>& ptf,\n"
109 " const fvPatch& p,\n"
110 " const DimensionedField<Type, volMesh>& iF,\n"
111 " const fvPatchFieldMapper& mapper\n"
113 ) << "Field type does not correspond to patch type for patch "
114 << this->patch().index() << "." << endl
115 << "Field type: " << typeName << endl
116 << "Patch type: " << this->patch().type()
123 cyclicGgiFvPatchField<Type>::cyclicGgiFvPatchField
125 const cyclicGgiFvPatchField<Type>& ptf,
126 const DimensionedField<Type, volMesh>& iF
129 ggiLduInterfaceField(),
130 coupledFvPatchField<Type>(ptf, iF),
131 cyclicGgiPatch_(refCast<const cyclicGgiFvPatch>(ptf.patch()))
136 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
138 // Return neighbour field
140 tmp<Field<Type> > cyclicGgiFvPatchField<Type>::patchNeighbourField() const
142 const Field<Type>& iField = this->internalField();
144 // Get shadow face-cells and assemble shadow field
145 const unallocLabelList& sfc = cyclicGgiPatch_.shadow().faceCells();
147 Field<Type> sField(sfc.size());
151 sField[i] = iField[sfc[i]];
154 // Transformation is handled in interpolation. HJ, 7/Jan/2009
155 tmp<Field<Type> > tpnf(cyclicGgiPatch_.interpolate(sField));
156 Field<Type>& pnf = tpnf();
158 if (cyclicGgiPatch_.bridgeOverlap())
160 // Symmetry treatment used for overlap
161 vectorField nHat = this->patch().nf();
163 // Use mirrored internal field for neighbour
165 Field<Type> bridgeField =
166 transform(I - 2.0*sqr(nHat), this->patchInternalField());
168 cyclicGgiPatch_.bridge(bridgeField, pnf);
176 void cyclicGgiFvPatchField<Type>::initEvaluate
178 const Pstream::commsTypes commsType
181 if (!this->updated())
183 this->updateCoeffs();
188 this->patch().weights()*this->patchInternalField()
189 + (1.0 - this->patch().weights())*this->patchNeighbourField()
192 if (cyclicGgiPatch_.bridgeOverlap())
194 // Symmetry treatment used for overlap
195 vectorField nHat = this->patch().nf();
197 Field<Type> bridgeField =
199 this->patchInternalField()
200 + transform(I - 2.0*sqr(nHat), this->patchInternalField())
203 cyclicGgiPatch_.bridge(bridgeField, pf);
206 Field<Type>::operator=(pf);
211 void cyclicGgiFvPatchField<Type>::evaluate
213 const Pstream::commsTypes
216 if (!this->updated())
218 this->updateCoeffs();
224 void cyclicGgiFvPatchField<Type>::initInterfaceMatrixUpdate
226 const scalarField& psiInternal,
229 const scalarField& coeffs,
230 const direction cmpt,
231 const Pstream::commsTypes commsType
234 // Get shadow face-cells and assemble shadow field
235 const unallocLabelList& sfc = cyclicGgiPatch_.shadow().faceCells();
237 scalarField sField(sfc.size());
241 sField[i] = psiInternal[sfc[i]];
244 // Transform according to the transformation tensor, using the slave
245 // side transform. Warning: forwardT() corresponds to the slave
246 // patch. HJ, 12/Jan/2009
247 transformCoupleField(sField, cmpt);
249 // Note: scalar interpolate does not get a transform, so this is safe
251 scalarField pnf = cyclicGgiPatch_.interpolate(sField);
253 // Multiply the field by coefficients and add into the result
254 const unallocLabelList& fc = cyclicGgiPatch_.faceCells();
258 result[fc[elemI]] -= coeffs[elemI]*pnf[elemI];
263 // Return matrix product for coupled boundary
265 void cyclicGgiFvPatchField<Type>::updateInterfaceMatrix
267 const scalarField& psiInternal,
270 const scalarField& coeffs,
271 const direction cmpt,
272 const Pstream::commsTypes
277 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
279 } // End namespace Foam
281 // ************************************************************************* //