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
25 \*---------------------------------------------------------------------------*/
27 #include "cyclicFaPatchField.H"
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
37 cyclicFaPatchField<Type>::cyclicFaPatchField
40 const DimensionedField<Type, areaMesh>& iF
43 coupledFaPatchField<Type>(p, iF),
44 cyclicPatch_(refCast<const cyclicFaPatch>(p))
49 cyclicFaPatchField<Type>::cyclicFaPatchField
51 const cyclicFaPatchField<Type>& ptf,
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()))
64 "cyclicFaPatchField<Type>::cyclicFaPatchField\n"
66 " const cyclicFaPatchField<Type>& ptf,\n"
67 " const faPatch& p,\n"
68 " const DimensionedField<Type, areaMesh>& iF,\n"
69 " const faPatchFieldMapper& mapper\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);
82 cyclicFaPatchField<Type>::cyclicFaPatchField
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))
96 "cyclicFaPatchField<Type>::cyclicFaPatchField\n"
98 " const faPatch& p,\n"
99 " const Field<Type>& field,\n"
100 " const dictionary& dict\n"
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);
111 this->evaluate(Pstream::blocking);
116 cyclicFaPatchField<Type>::cyclicFaPatchField
118 const cyclicFaPatchField<Type>& ptf
121 cyclicLduInterfaceField(),
122 coupledFaPatchField<Type>(ptf),
123 cyclicPatch_(ptf.cyclicPatch_)
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 * * * * * * * * * * * * * //
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;
154 for (label facei=0; facei<sizeby2; facei++)
156 pnf[facei] = transform
158 forwardT()[0], iField[faceCells[facei + sizeby2]]
161 pnf[facei + sizeby2] = transform
163 reverseT()[0], iField[faceCells[facei]]
169 for (label facei=0; facei<sizeby2; facei++)
171 pnf[facei] = iField[faceCells[facei + sizeby2]];
172 pnf[facei + sizeby2] = iField[faceCells[facei]];
181 void cyclicFaPatchField<Type>::updateInterfaceMatrix
183 const scalarField& psiInternal,
186 const scalarField& coeffs,
187 const direction cmpt,
188 const Pstream::commsTypes
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++)
198 pnf[facei] = psiInternal[faceCells[facei + sizeby2]];
199 pnf[facei + sizeby2] = psiInternal[faceCells[facei]];
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)
208 result[faceCells[elemI]] -= coeffs[elemI]*pnf[elemI];
213 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
215 } // End namespace Foam
217 // ************************************************************************* //