FreeFOAM The Cross-Platform CFD Toolkit
cyclicPointPatchField.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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.
20 
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/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "cyclicPointPatchField.H"
27 #include <OpenFOAM/Swap.H>
28 
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
30 
31 namespace Foam
32 {
33 
34 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
35 
36 template<class Type>
38 (
39  const pointPatch& p,
41 )
42 :
44  cyclicPatch_(refCast<const cyclicPointPatch>(p))
45 {}
46 
47 
48 template<class Type>
50 (
51  const pointPatch& p,
53  const dictionary& dict
54 )
55 :
57  cyclicPatch_(refCast<const cyclicPointPatch>(p))
58 {
59  if (!isType<cyclicPointPatch>(p))
60  {
62  (
63  "cyclicPointPatchField<Type>::cyclicPointPatchField\n"
64  "(\n"
65  " const pointPatch& p,\n"
66  " const Field<Type>& field,\n"
67  " const dictionary& dict\n"
68  ")\n",
69  dict
70  ) << "patch " << this->patch().index() << " not cyclic type. "
71  << "Patch type = " << p.type()
72  << exit(FatalIOError);
73  }
74 }
75 
76 
77 template<class Type>
79 (
80  const cyclicPointPatchField<Type>& ptf,
81  const pointPatch& p,
83  const pointPatchFieldMapper& mapper
84 )
85 :
86  coupledPointPatchField<Type>(ptf, p, iF, mapper),
87  cyclicPatch_(refCast<const cyclicPointPatch>(p))
88 {
89  if (!isType<cyclicPointPatch>(this->patch()))
90  {
92  (
93  "cyclicPointPatchField<Type>::cyclicPointPatchField\n"
94  "(\n"
95  " const cyclicPointPatchField<Type>& ptf,\n"
96  " const pointPatch& p,\n"
97  " const DimensionedField<Type, pointMesh>& iF,\n"
98  " const pointPatchFieldMapper& mapper\n"
99  ")\n"
100  ) << "Field type does not correspond to patch type for patch "
101  << this->patch().index() << "." << endl
102  << "Field type: " << typeName << endl
103  << "Patch type: " << this->patch().type()
104  << exit(FatalError);
105  }
106 }
107 
108 
109 template<class Type>
111 (
112  const cyclicPointPatchField<Type>& ptf,
114 )
115 :
117  cyclicPatch_(ptf.cyclicPatch_)
118 {}
119 
120 
121 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
122 
123 template<class Type>
125 {
126  Field<Type> pf(this->patchInternalField(pField));
127 
128  const edgeList& pairs = cyclicPatch_.transformPairs();
129 
130  if (doTransform())
131  {
132  forAll(pairs, pairi)
133  {
134  Type tmp = pf[pairs[pairi][0]];
135  pf[pairs[pairi][0]] = transform(forwardT()[0], pf[pairs[pairi][1]]);
136  pf[pairs[pairi][1]] = transform(reverseT()[0], tmp);
137  }
138  }
139  else
140  {
141  forAll(pairs, pairi)
142  {
143  Swap(pf[pairs[pairi][0]], pf[pairs[pairi][1]]);
144  }
145  }
146 
147  addToInternalField(pField, pf);
148 }
149 
150 
151 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
152 
153 } // End namespace Foam
154 
155 // ************************ vim: set sw=4 sts=4 et: ************************ //