BUG: UListIO: byteSize overflowing on really big faceLists
[OpenFOAM-2.0.x.git] / src / OpenFOAM / fields / pointPatchFields / constraint / cyclic / cyclicPointPatchField.C
blob4bc0994526577ea61ad649401764a6821eda6e1f
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
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
13     the Free Software Foundation, either version 3 of the License, or
14     (at your 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, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "cyclicPointPatchField.H"
27 #include "Swap.H"
28 #include "transformField.H"
29 #include "pointFields.H"
31 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
33 template<class Type>
34 Foam::cyclicPointPatchField<Type>::cyclicPointPatchField
36     const pointPatch& p,
37     const DimensionedField<Type, pointMesh>& iF
40     coupledPointPatchField<Type>(p, iF),
41     cyclicPatch_(refCast<const cyclicPointPatch>(p))
45 template<class Type>
46 Foam::cyclicPointPatchField<Type>::cyclicPointPatchField
48     const pointPatch& p,
49     const DimensionedField<Type, pointMesh>& iF,
50     const dictionary& dict
53     coupledPointPatchField<Type>(p, iF, dict),
54     cyclicPatch_(refCast<const cyclicPointPatch>(p))
56     if (!isType<cyclicPointPatch>(p))
57     {
58         FatalIOErrorIn
59         (
60             "cyclicPointPatchField<Type>::cyclicPointPatchField\n"
61             "(\n"
62             "    const pointPatch& p,\n"
63             "    const Field<Type>& field,\n"
64             "    const dictionary& dict\n"
65             ")\n",
66             dict
67         )   << "patch " << this->patch().index() << " not cyclic type. "
68             << "Patch type = " << p.type()
69             << exit(FatalIOError);
70     }
74 template<class Type>
75 Foam::cyclicPointPatchField<Type>::cyclicPointPatchField
77     const cyclicPointPatchField<Type>& ptf,
78     const pointPatch& p,
79     const DimensionedField<Type, pointMesh>& iF,
80     const pointPatchFieldMapper& mapper
83     coupledPointPatchField<Type>(ptf, p, iF, mapper),
84     cyclicPatch_(refCast<const cyclicPointPatch>(p))
86     if (!isType<cyclicPointPatch>(this->patch()))
87     {
88         FatalErrorIn
89         (
90             "cyclicPointPatchField<Type>::cyclicPointPatchField\n"
91             "(\n"
92             "    const cyclicPointPatchField<Type>& ptf,\n"
93             "    const pointPatch& p,\n"
94             "    const DimensionedField<Type, pointMesh>& iF,\n"
95             "    const pointPatchFieldMapper& mapper\n"
96             ")\n"
97         )   << "Field type does not correspond to patch type for patch "
98             << this->patch().index() << "." << endl
99             << "Field type: " << typeName << endl
100             << "Patch type: " << this->patch().type()
101             << exit(FatalError);
102     }
106 template<class Type>
107 Foam::cyclicPointPatchField<Type>::cyclicPointPatchField
109     const cyclicPointPatchField<Type>& ptf,
110     const DimensionedField<Type, pointMesh>& iF
113     coupledPointPatchField<Type>(ptf, iF),
114     cyclicPatch_(ptf.cyclicPatch_)
118 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
120 template<class Type>
121 void Foam::cyclicPointPatchField<Type>::swapAddSeparated
123     const Pstream::commsTypes,
124     Field<Type>& pField
125 ) const
127     // Get neighbouring pointPatch
128     const cyclicPointPatch& nbrPatch = cyclicPatch_.neighbPatch();
130     if (cyclicPatch_.cyclicPatch().owner())
131     {
132         // We inplace modify pField. To prevent the other side (which gets
133         // evaluated at a later date) using already changed values we do
134         // all swaps on the side that gets evaluated first.
136         // Get neighbouring pointPatchField
137         const GeometricField<Type, pointPatchField, pointMesh>& fld =
138             refCast<const GeometricField<Type, pointPatchField, pointMesh> >
139             (
140                 this->dimensionedInternalField()
141             );
143         const cyclicPointPatchField<Type>& nbr =
144             refCast<const cyclicPointPatchField<Type> >
145             (
146                 fld.boundaryField()[nbrPatch.index()]
147             );
150         Field<Type> pf(this->patchInternalField(pField));
151         Field<Type> nbrPf(nbr.patchInternalField(pField));
153         const edgeList& pairs = cyclicPatch_.transformPairs();
155         if (doTransform())
156         {
157             // Transform both sides.
158             forAll(pairs, pairi)
159             {
160                 label pointi = pairs[pairi][0];
161                 label nbrPointi = pairs[pairi][1];
163                 Type tmp = pf[pointi];
164                 pf[pointi] = transform(forwardT()[0], nbrPf[nbrPointi]);
165                 nbrPf[nbrPointi] = transform(reverseT()[0], tmp);
166             }
167         }
168         else
169         {
170             forAll(pairs, pairi)
171             {
172                 Swap(pf[pairs[pairi][0]], nbrPf[pairs[pairi][1]]);
173             }
174         }
175         this->addToInternalField(pField, pf);
176         nbr.addToInternalField(pField, nbrPf);
177     }
181 // ************************************************************************* //