FreeFOAM The Cross-Platform CFD Toolkit
jumpCyclicFvPatchField.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 
27 
28 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
29 
30 namespace Foam
31 {
32 
33 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
34 
35 template<class Type>
37 (
38  const fvPatch& p,
40 )
41 :
43 {}
44 
45 
46 template<class Type>
48 (
50  const fvPatch& p,
52  const fvPatchFieldMapper& mapper
53 )
54 :
55  cyclicFvPatchField<Type>(ptf, p, iF, mapper)
56 {}
57 
58 
59 template<class Type>
61 (
62  const fvPatch& p,
64  const dictionary& dict
65 )
66 :
67  cyclicFvPatchField<Type>(p, iF, dict)
68 {
69  // Call this evaluation in derived classes
70  //this->evaluate(Pstream::blocking);
71 }
72 
73 
74 template<class Type>
76 (
78 )
79 :
82 {}
83 
84 
85 template<class Type>
87 (
90 )
91 :
93 {}
94 
95 
96 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
97 
98 template<class Type>
100 {
101  const Field<Type>& iField = this->internalField();
102  const unallocLabelList& faceCells = this->cyclicPatch().faceCells();
103 
104  tmp<Field<Type> > tpnf(new Field<Type>(this->size()));
105  Field<Type>& pnf = tpnf();
106 
107  tmp<Field<scalar> > tjf = jump();
108  const Field<scalar>& jf = tjf();
109 
110  label sizeby2 = this->size()/2;
111 
112  if (this->doTransform())
113  {
114  for (label facei=0; facei<sizeby2; facei++)
115  {
116  pnf[facei] = transform
117  (
118  this->forwardT()[0], iField[faceCells[facei + sizeby2]]
119  ) - jf[facei];
120 
121  pnf[facei + sizeby2] = transform
122  (
123  this->reverseT()[0], iField[faceCells[facei]] + jf[facei]
124  );
125  }
126  }
127  else
128  {
129  for (label facei=0; facei<sizeby2; facei++)
130  {
131  pnf[facei] = iField[faceCells[facei + sizeby2]] - jf[facei];
132  pnf[facei + sizeby2] = iField[faceCells[facei]] + jf[facei];
133  }
134  }
135 
136  return tpnf;
137 }
138 
139 
140 template<class Type>
142 (
143  const scalarField& psiInternal,
144  scalarField& result,
145  const lduMatrix&,
146  const scalarField& coeffs,
147  const direction cmpt,
148  const Pstream::commsTypes
149 ) const
150 {
151  scalarField pnf(this->size());
152 
153  label sizeby2 = this->size()/2;
154  const unallocLabelList& faceCells = this->cyclicPatch().faceCells();
155 
156  if (&psiInternal == &this->internalField())
157  {
158  tmp<Field<scalar> > tjf = jump();
159  const Field<scalar>& jf = tjf();
160 
161  for (label facei=0; facei<sizeby2; facei++)
162  {
163  pnf[facei] = psiInternal[faceCells[facei + sizeby2]] - jf[facei];
164  pnf[facei + sizeby2] = psiInternal[faceCells[facei]] + jf[facei];
165  }
166  }
167  else
168  {
169  for (label facei=0; facei<sizeby2; facei++)
170  {
171  pnf[facei] = psiInternal[faceCells[facei + sizeby2]];
172  pnf[facei + sizeby2] = psiInternal[faceCells[facei]];
173  }
174  }
175 
176  // Transform according to the transformation tensors
177  this->transformCoupleField(pnf, cmpt);
178 
179  // Multiply the field by coefficients and add into the result
180  forAll(faceCells, elemI)
181  {
182  result[faceCells[elemI]] -= coeffs[elemI]*pnf[elemI];
183  }
184 }
185 
186 
187 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
188 
189 } // End namespace Foam
190 
191 // ************************ vim: set sw=4 sts=4 et: ************************ //