initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / OpenFOAM / fields / pointPatchFields / constraint / cyclic / cyclicPointPatchField.C
blob40aa26a36aa1c207fab90f3012456c2f84277635
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 "cyclicPointPatchField.H"
28 #include "Swap.H"
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32 namespace Foam
35 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
37 template<class Type>
38 cyclicPointPatchField<Type>::cyclicPointPatchField
40     const pointPatch& p,
41     const DimensionedField<Type, pointMesh>& iF
44     coupledPointPatchField<Type>(p, iF),
45     cyclicPatch_(refCast<const cyclicPointPatch>(p))
49 template<class Type>
50 cyclicPointPatchField<Type>::cyclicPointPatchField
52     const pointPatch& p,
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))
61     {
62         FatalIOErrorIn
63         (
64             "cyclicPointPatchField<Type>::cyclicPointPatchField\n"
65             "(\n"
66             "    const pointPatch& p,\n"
67             "    const Field<Type>& field,\n"
68             "    const dictionary& dict\n"
69             ")\n",
70             dict
71         )   << "patch " << this->patch().index() << " not cyclic type. "
72             << "Patch type = " << p.type()
73             << exit(FatalIOError);
74     }
78 template<class Type>
79 cyclicPointPatchField<Type>::cyclicPointPatchField
81     const cyclicPointPatchField<Type>& ptf,
82     const pointPatch& p,
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()))
91     {
92         FatalErrorIn
93         (
94             "cyclicPointPatchField<Type>::cyclicPointPatchField\n"
95             "(\n"
96             "    const cyclicPointPatchField<Type>& ptf,\n"
97             "    const pointPatch& p,\n"
98             "    const DimensionedField<Type, pointMesh>& iF,\n"
99             "    const pointPatchFieldMapper& mapper\n"
100             ")\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()
105             << exit(FatalError);
106     }
110 template<class 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  * * * * * * * * * * * * * //
124 template<class Type>
125 void cyclicPointPatchField<Type>::swapAdd(Field<Type>& pField) const
127     Field<Type> pf(this->patchInternalField(pField));
129     const edgeList& pairs = cyclicPatch_.transformPairs();
131     if (doTransform())
132     {
133         forAll(pairs, pairi)
134         {
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);
138         }
139     }
140     else
141     {
142         forAll(pairs, pairi)
143         {
144             Swap(pf[pairs[pairi][0]], pf[pairs[pairi][1]]);
145         }
146     }
148     addToInternalField(pField, pf);
152 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
154 } // End namespace Foam
156 // ************************************************************************* //