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-2026 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 
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 {
87  (
89  (
90  "surfaceIntegrate("+ssf.name()+')',
91  ssf.mesh()(),
93  (
94  "0",
95  ssf.dimensions()/dimVolume,
96  Zero
97  )
98  )
99  );
100  VolInternalField<Type>& vf = tvf.ref();
101 
102  surfaceIntegrate(vf.primitiveFieldRef(), ssf);
103 
104  return tvf;
105 }
106 
107 
108 template<class Type>
111 (
112  const tmp<SurfaceField<Type>>& tssf
113 )
114 {
116  (
117  fvc::surfaceIntegrate(tssf())
118  );
119  tssf.clear();
120  return tvf;
121 }
122 
123 
124 template<class Type>
127 (
128  const SurfaceField<Type>& ssf
129 )
130 {
131  tmp<VolField<Type>> tvf
132  (
134  (
135  "surfaceIntegrate("+ssf.name()+')',
136  ssf.mesh()(),
138  (
139  "0",
140  ssf.dimensions()/dimVolume,
141  Zero
142  ),
144  )
145  );
146  VolField<Type>& vf = tvf.ref();
147 
150 
151  return tvf;
152 }
153 
154 
155 template<class Type>
158 (
159  const tmp<SurfaceField<Type>>& tssf
160 )
161 {
162  tmp<VolField<Type>> tvf
163  (
165  );
166  tssf.clear();
167  return tvf;
168 }
169 
170 
171 template<class Type>
173 {
174  const fvMesh& mesh = ssf.mesh()();
175 
177  (
179  (
180  "surfaceSum("+ssf.name()+')',
181  mesh,
182  dimensioned<Type>("0", ssf.dimensions(), Zero)
183  )
184  );
185  VolInternalField<Type>& vf = tvf.ref();
186 
187  const labelUList& owner = mesh.owner();
188  const labelUList& neighbour = mesh.neighbour();
189 
190  forAll(owner, facei)
191  {
192  vf[owner[facei]] += ssf[facei];
193  vf[neighbour[facei]] += ssf[facei];
194  }
195 
197  {
198  const labelUList& pFaceCells =
199  mesh.boundary()[patchi].faceCells();
200 
201  const fvsPatchField<Type>& pssf = ssf.boundaryField()[patchi];
202 
203  forAll(mesh.boundary()[patchi], facei)
204  {
205  vf[pFaceCells[facei]] += pssf[facei];
206  }
207  }
208 
209  return tvf;
210 }
211 
212 
213 template<class Type>
215 (
216  const tmp<SurfaceField<Type>>& tssf
217 )
218 {
219  tmp<VolInternalField<Type>> tvf = surfaceSum(tssf());
220  tssf.clear();
221  return tvf;
222 }
223 
224 
225 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
226 
227 } // End namespace fvc
228 
229 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
230 
231 } // End namespace Foam
232 
233 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:449
const dimensionSet & dimensions() const
Return dimensions.
const GeoMesh & mesh() const
Return mesh.
Pre-declare SubField and related Field type.
Definition: Field.H:83
Generic GeometricField class.
const Boundary & boundaryField() const
Return const-reference to the boundary field.
Internal::FieldType & primitiveFieldRef()
Return a reference to the primitive field.
void correctBoundaryConditions()
Correct boundary field.
const word & name() const
Return name.
Definition: IOobject.H:307
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:98
const labelUList & owner() const
Internal face owner.
Definition: fvMesh.H:490
const fvBoundaryMesh & boundary() const
Return reference to boundary mesh.
Definition: fvMesh.C:932
const labelUList & neighbour() const
Internal face neighbour.
Definition: fvMesh.H:496
tmp< DimensionedField< scalar, fvMesh > > 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:86
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:197
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
Surface integrate surfaceField creating a volField. Surface sum a surfaceField creating a volField.
label patchi
void surfaceIntegrate(Field< Type > &ivf, const SurfaceField< Type > &ssf)
tmp< VolField< Type > > surfaceIntegrateExtrapolate(const SurfaceField< Type > &ssf)
tmp< VolInternalField< Type > > surfaceSum(const SurfaceField< Type > &ssf)
Namespace for OpenFOAM.
static const zero Zero
Definition: zero.H:97
const dimensionSet & dimVolume
Definition: dimensions.C:150
typename VolField< Type >::Internal VolInternalField
Definition: volFieldsFwd.H:59