FreeFOAM The Cross-Platform CFD Toolkit
processorFvPatchField.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 "processorFvPatchField.H"
28 #include <OpenFOAM/IPstream.H>
29 #include <OpenFOAM/OPstream.H>
32 
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37 
38 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
39 
40 template<class Type>
42 (
43  const fvPatch& p,
45 )
46 :
48  procPatch_(refCast<const processorFvPatch>(p))
49 {}
50 
51 
52 template<class Type>
54 (
55  const fvPatch& p,
57  const Field<Type>& f
58 )
59 :
61  procPatch_(refCast<const processorFvPatch>(p))
62 {}
63 
64 
65 // Construct by mapping given processorFvPatchField<Type>
66 template<class Type>
68 (
69  const processorFvPatchField<Type>& ptf,
70  const fvPatch& p,
72  const fvPatchFieldMapper& mapper
73 )
74 :
75  coupledFvPatchField<Type>(ptf, p, iF, mapper),
76  procPatch_(refCast<const processorFvPatch>(p))
77 {
78  if (!isType<processorFvPatch>(this->patch()))
79  {
81  (
82  "processorFvPatchField<Type>::processorFvPatchField\n"
83  "(\n"
84  " const processorFvPatchField<Type>& ptf,\n"
85  " const fvPatch& p,\n"
86  " const DimensionedField<Type, volMesh>& iF,\n"
87  " const fvPatchFieldMapper& mapper\n"
88  ")\n"
89  ) << "\n patch type '" << p.type()
90  << "' not constraint type '" << typeName << "'"
91  << "\n for patch " << p.name()
92  << " of field " << this->dimensionedInternalField().name()
93  << " in file " << this->dimensionedInternalField().objectPath()
94  << exit(FatalIOError);
95  }
96 }
97 
98 
99 template<class Type>
101 (
102  const fvPatch& p,
104  const dictionary& dict
105 )
106 :
107  coupledFvPatchField<Type>(p, iF, dict),
108  procPatch_(refCast<const processorFvPatch>(p))
109 {
110  if (!isType<processorFvPatch>(p))
111  {
113  (
114  "processorFvPatchField<Type>::processorFvPatchField\n"
115  "(\n"
116  " const fvPatch& p,\n"
117  " const Field<Type>& field,\n"
118  " const dictionary& dict\n"
119  ")\n",
120  dict
121  ) << "\n patch type '" << p.type()
122  << "' not constraint type '" << typeName << "'"
123  << "\n for patch " << p.name()
124  << " of field " << this->dimensionedInternalField().name()
125  << " in file " << this->dimensionedInternalField().objectPath()
126  << exit(FatalIOError);
127  }
128 }
129 
130 
131 template<class Type>
133 (
134  const processorFvPatchField<Type>& ptf
135 )
136 :
139  procPatch_(refCast<const processorFvPatch>(ptf.patch()))
140 {}
141 
142 
143 template<class Type>
145 (
146  const processorFvPatchField<Type>& ptf,
148 )
149 :
150  coupledFvPatchField<Type>(ptf, iF),
151  procPatch_(refCast<const processorFvPatch>(ptf.patch()))
152 {}
153 
154 
155 // * * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * //
156 
157 template<class Type>
159 {}
160 
161 
162 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
163 
164 template<class Type>
166 {
167  return *this;
168 }
169 
170 
171 template<class Type>
173 (
174  const Pstream::commsTypes commsType
175 )
176 {
177  if (Pstream::parRun())
178  {
179  procPatch_.compressedSend(commsType, this->patchInternalField()());
180  }
181 }
182 
183 
184 template<class Type>
186 (
187  const Pstream::commsTypes commsType
188 )
189 {
190  if (Pstream::parRun())
191  {
192  procPatch_.compressedReceive<Type>(commsType, *this);
193 
194  if (doTransform())
195  {
196  transform(*this, procPatch_.forwardT(), *this);
197  }
198  }
199 }
200 
201 
202 template<class Type>
204 {
205  return this->patch().deltaCoeffs()*(*this - this->patchInternalField());
206 }
207 
208 
209 template<class Type>
211 (
212  const scalarField& psiInternal,
213  scalarField&,
214  const lduMatrix&,
215  const scalarField&,
216  const direction,
217  const Pstream::commsTypes commsType
218 ) const
219 {
220  procPatch_.compressedSend
221  (
222  commsType,
223  this->patch().patchInternalField(psiInternal)()
224  );
225 }
226 
227 
228 template<class Type>
230 (
231  const scalarField&,
232  scalarField& result,
233  const lduMatrix&,
234  const scalarField& coeffs,
235  const direction cmpt,
236  const Pstream::commsTypes commsType
237 ) const
238 {
239  scalarField pnf
240  (
241  procPatch_.compressedReceive<scalar>(commsType, this->size())()
242  );
243 
244  // Transform according to the transformation tensor
245  transformCoupleField(pnf, cmpt);
246 
247  // Multiply the field by coefficients and add into the result
248 
249  const unallocLabelList& faceCells = this->patch().faceCells();
250 
251  forAll(faceCells, elemI)
252  {
253  result[faceCells[elemI]] -= coeffs[elemI]*pnf[elemI];
254  }
255 }
256 
257 
258 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
259 
260 } // End namespace Foam
261 
262 // ************************ vim: set sw=4 sts=4 et: ************************ //