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 "cyclicPointPatchField.H"
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
38 cyclicPointPatchField<Type>::cyclicPointPatchField
41 const DimensionedField<Type, pointMesh>& iF
44 coupledPointPatchField<Type>(p, iF),
45 cyclicPatch_(refCast<const cyclicPointPatch>(p))
50 cyclicPointPatchField<Type>::cyclicPointPatchField
53 const DimensionedField<Type, pointMesh>& iF,
54 const dictionary& dict
57 coupledPointPatchField<Type>(p, iF, dict),
58 cyclicPatch_(refCast<const cyclicPointPatch>(p))
60 if (!isType<cyclicPointPatch>(p))
64 "cyclicPointPatchField<Type>::cyclicPointPatchField\n"
66 " const pointPatch& p,\n"
67 " const Field<Type>& field,\n"
68 " const dictionary& dict\n"
71 ) << "patch " << this->patch().index() << " not cyclic type. "
72 << "Patch type = " << p.type()
73 << exit(FatalIOError);
79 cyclicPointPatchField<Type>::cyclicPointPatchField
81 const cyclicPointPatchField<Type>& ptf,
83 const DimensionedField<Type, pointMesh>& iF,
84 const pointPatchFieldMapper& mapper
87 coupledPointPatchField<Type>(ptf, p, iF, mapper),
88 cyclicPatch_(refCast<const cyclicPointPatch>(p))
90 if (!isType<cyclicPointPatch>(this->patch()))
94 "cyclicPointPatchField<Type>::cyclicPointPatchField\n"
96 " const cyclicPointPatchField<Type>& ptf,\n"
97 " const pointPatch& p,\n"
98 " const DimensionedField<Type, pointMesh>& iF,\n"
99 " const pointPatchFieldMapper& mapper\n"
101 ) << "Field type does not correspond to patch type for patch "
102 << this->patch().index() << "." << endl
103 << "Field type: " << typeName << endl
104 << "Patch type: " << this->patch().type()
111 cyclicPointPatchField<Type>::cyclicPointPatchField
113 const cyclicPointPatchField<Type>& ptf,
114 const DimensionedField<Type, pointMesh>& iF
117 coupledPointPatchField<Type>(ptf, iF),
118 cyclicPatch_(ptf.cyclicPatch_)
122 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
125 void cyclicPointPatchField<Type>::swapAdd(Field<Type>& pField) const
127 Field<Type> pf(this->patchInternalField(pField));
129 const edgeList& pairs = cyclicPatch_.transformPairs();
135 Type tmp = pf[pairs[pairi][0]];
136 pf[pairs[pairi][0]] = transform(forwardT()[0], pf[pairs[pairi][1]]);
137 pf[pairs[pairi][1]] = transform(reverseT()[0], tmp);
144 Swap(pf[pairs[pairi][0]], pf[pairs[pairi][1]]);
148 addToInternalField(pField, pf);
152 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
154 } // End namespace Foam
156 // ************************************************************************* //