fvcSurfaceIntegrate.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
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 "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,
46  const SurfaceField<Type>& ssf
47 )
48 {
49  const fvMesh& mesh = ssf.mesh();
50 
51  const labelUList& owner = mesh.owner();
52  const labelUList& 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 labelUList& 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.Vsc();
76 }
77 
78 
79 template<class Type>
82 (
83  const SurfaceField<Type>& ssf
84 )
85 {
86  const fvMesh& mesh = ssf.mesh();
87 
89  (
91  (
92  "surfaceIntegrate("+ssf.name()+')',
93  mesh,
95  (
96  "0",
97  ssf.dimensions()/dimVol,
98  Zero
99  ),
101  )
102  );
103  VolField<Type>& vf = tvf.ref();
104 
107 
108  return tvf;
109 }
110 
111 
112 template<class Type>
115 (
116  const tmp<SurfaceField<Type>>& tssf
117 )
118 {
119  tmp<VolField<Type>> tvf
120  (
121  fvc::surfaceIntegrate(tssf())
122  );
123  tssf.clear();
124  return tvf;
125 }
126 
127 
128 template<class Type>
131 (
132  const SurfaceField<Type>& ssf
133 )
134 {
135  const fvMesh& mesh = ssf.mesh();
136 
137  tmp<VolField<Type>> tvf
138  (
140  (
141  "surfaceSum("+ssf.name()+')',
142  mesh,
143  dimensioned<Type>("0", ssf.dimensions(), Zero),
145  )
146  );
147  VolField<Type>& vf = tvf.ref();
148 
149  const labelUList& owner = mesh.owner();
150  const labelUList& neighbour = mesh.neighbour();
151 
152  forAll(owner, facei)
153  {
154  vf[owner[facei]] += ssf[facei];
155  vf[neighbour[facei]] += ssf[facei];
156  }
157 
158  forAll(mesh.boundary(), patchi)
159  {
160  const labelUList& pFaceCells =
161  mesh.boundary()[patchi].faceCells();
162 
163  const fvsPatchField<Type>& pssf = ssf.boundaryField()[patchi];
164 
165  forAll(mesh.boundary()[patchi], facei)
166  {
167  vf[pFaceCells[facei]] += pssf[facei];
168  }
169  }
170 
172 
173  return tvf;
174 }
175 
176 
177 template<class Type>
179 (
180  const tmp<SurfaceField<Type>>& tssf
181 )
182 {
183  tmp<VolField<Type>> tvf = surfaceSum(tssf());
184  tssf.clear();
185  return tvf;
186 }
187 
188 
189 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
190 
191 } // End namespace fvc
192 
193 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
194 
195 } // End namespace Foam
196 
197 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
const dimensionSet & dimensions() const
Return dimensions.
const Mesh & mesh() const
Return mesh.
Pre-declare SubField and related Field type.
Definition: Field.H:82
Generic GeometricField class.
Internal::FieldType & primitiveFieldRef()
Return a reference to the internal field.
const Boundary & boundaryField() const
Return const-reference to the boundary field.
void correctBoundaryConditions()
Correct boundary field.
const word & name() const
Return name.
Definition: IOobject.H:310
Generic dimensioned Type class.
This boundary condition applies a zero-gradient condition from the patch internal field onto the patc...
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:101
const labelUList & owner() const
Internal face owner.
Definition: fvMesh.H:451
const fvBoundaryMesh & boundary() const
Return reference to boundary mesh.
Definition: fvMesh.C:893
const labelUList & neighbour() const
Internal face neighbour.
Definition: fvMesh.H:457
tmp< DimensionedField< scalar, volMesh > > Vsc() const
Return sub-cycle cell volumes.
An abstract base class with a fat-interface to all derived classes covering all possible ways in whic...
Definition: fvsPatchField.H:82
A class for managing temporary objects.
Definition: tmp.H:55
T & ref() const
Return non-const reference or generate a fatal error.
Definition: tmpI.H:181
Surface integrate surfaceField creating a volField. Surface sum a surfaceField creating a volField.
label patchi
tmp< VolField< Type > > surfaceSum(const SurfaceField< Type > &ssf)
void surfaceIntegrate(Field< Type > &ivf, const SurfaceField< Type > &ssf)
Namespace for OpenFOAM.
static const zero Zero
Definition: zero.H:97
const dimensionSet dimVol