FreeFOAM The Cross-Platform CFD Toolkit
fvcSurfaceIntegrate.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 "fvcSurfaceIntegrate.H"
27 #include <finiteVolume/fvMesh.H>
29 
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34 
35 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 
37 namespace fvc
38 {
39 
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
41 
42 template<class Type>
44 (
45  Field<Type>& ivf,
47 )
48 {
49  const fvMesh& mesh = ssf.mesh();
50 
51  const unallocLabelList& owner = mesh.owner();
52  const unallocLabelList& neighbour = mesh.neighbour();
53 
54  const Field<Type>& issf = ssf;
55 
56  forAll(owner, facei)
57  {
58  ivf[owner[facei]] += issf[facei];
59  ivf[neighbour[facei]] -= issf[facei];
60  }
61 
62  forAll(mesh.boundary(), patchi)
63  {
64  const unallocLabelList& pFaceCells =
65  mesh.boundary()[patchi].faceCells();
66 
67  const fvsPatchField<Type>& pssf = ssf.boundaryField()[patchi];
68 
69  forAll(mesh.boundary()[patchi], facei)
70  {
71  ivf[pFaceCells[facei]] += pssf[facei];
72  }
73  }
74 
75  ivf /= mesh.V();
76 }
77 
78 
79 template<class Type>
82 (
84 )
85 {
86  const fvMesh& mesh = ssf.mesh();
87 
89  (
91  (
92  IOobject
93  (
94  "surfaceIntegrate("+ssf.name()+')',
95  ssf.instance(),
96  mesh,
99  ),
100  mesh,
102  (
103  "0",
104  ssf.dimensions()/dimVol,
106  ),
108  )
109  );
111 
112  surfaceIntegrate(vf.internalField(), ssf);
113  vf.correctBoundaryConditions();
114 
115  return tvf;
116 }
117 
118 
119 template<class Type>
122 (
124 )
125 {
127  (
128  fvc::surfaceIntegrate(tssf())
129  );
130  tssf.clear();
131  return tvf;
132 }
133 
134 
135 template<class Type>
138 (
140 )
141 {
142  const fvMesh& mesh = ssf.mesh();
143 
145  (
147  (
148  IOobject
149  (
150  "surfaceSum("+ssf.name()+')',
151  ssf.instance(),
152  mesh,
155  ),
156  mesh,
159  )
160  );
162 
163  const unallocLabelList& owner = mesh.owner();
164  const unallocLabelList& neighbour = mesh.neighbour();
165 
166  forAll(owner, facei)
167  {
168  vf[owner[facei]] += ssf[facei];
169  vf[neighbour[facei]] += ssf[facei];
170  }
171 
172  forAll(mesh.boundary(), patchi)
173  {
174  const unallocLabelList& pFaceCells =
175  mesh.boundary()[patchi].faceCells();
176 
177  const fvsPatchField<Type>& pssf = ssf.boundaryField()[patchi];
178 
179  forAll(mesh.boundary()[patchi], facei)
180  {
181  vf[pFaceCells[facei]] += pssf[facei];
182  }
183  }
184 
185  vf.correctBoundaryConditions();
186 
187  return tvf;
188 }
189 
190 
191 template<class Type>
193 (
195 )
196 {
198  tssf.clear();
199  return tvf;
200 }
201 
202 
203 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
204 
205 } // End namespace fvc
206 
207 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
208 
209 } // End namespace Foam
210 
211 // ************************ vim: set sw=4 sts=4 et: ************************ //