facNDiv.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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2016-2017 Wikki Ltd
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "facNDiv.H"
29 #include "faMesh.H"
30 #include "facEdgeIntegrate.H"
31 #include "faDivScheme.H"
32 #include "faConvectionScheme.H"
33 #include "transformField.H"
34 
35 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 
37 namespace Foam
38 {
39 
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
41 
42 namespace fac
43 {
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
47 template<class Type>
48 tmp<GeometricField<Type, faPatchField, areaMesh>>
49 ndiv
50 (
52 )
53 {
54  const areaVectorField& n = ssf.mesh().faceAreaNormals();
55 
57  fac::edgeIntegrate(ssf);
58 
60 
61  v.primitiveFieldRef() = n*(n & v.internalField());
63 
64  return v;
65 }
66 
67 
68 template<class Type>
70 ndiv
71 (
73 )
74 {
76  tssf.clear();
77  return Div;
78 }
79 
80 
81 template<class Type>
82 tmp
83 <
85  <
87  >
88 >
89 ndiv
90 (
92  const word& name
93 )
94 {
95  const areaVectorField& n = vf.mesh().faceAreaNormals();
96 
98  (
100  (
101  vf.mesh(), vf.mesh().divScheme(name)
102  ).ref().facDiv(vf)
103  );
105 
106  Div.primitiveFieldRef() = n*(n & Div.internalField());
107  Div.correctBoundaryConditions();
108 
109  return tDiv;
110 }
111 
112 
113 template<class Type>
114 tmp
115 <
117  <
119  >
120 >
121 ndiv
122 (
124  const word& name
125 )
126 {
127  typedef typename innerProduct<vector, Type>::type DivType;
129  (
130  fac::ndiv(tvvf(), name)
131  );
132  tvvf.clear();
133 
134  return Div;
135 }
136 
137 template<class Type>
138 tmp
139 <
141  <
143  >
144 >
145 ndiv
146 (
148 )
149 {
150  return fac::ndiv(vf, "div("+vf.name()+')');
151 }
152 
153 
154 template<class Type>
155 tmp
156 <
158  <
160  >
161 >
162 ndiv
163 (
165 )
166 {
167  typedef typename innerProduct<vector, Type>::type DivType;
169  (
170  fac::ndiv(tvvf())
171  );
172 
173  tvvf.clear();
174  return Div;
175 }
176 
177 
178 template<class Type>
180 ndiv
181 (
182  const edgeScalarField& flux,
184  const word& name
185 )
186 {
187  const areaVectorField& n = vf.mesh().faceAreaNormals();
188 
190  (
192  (
193  vf.mesh(),
194  flux,
195  vf.mesh().divScheme(name)
196  ).ref().facDiv(flux, vf)
197  );
198 
200 
201  Div.primitiveFieldRef() = n*(n & Div.internalField());
202  Div.correctBoundaryConditions();
203 
204  return tDiv;
205 
206 }
207 
208 
209 template<class Type>
211 ndiv
212 (
213  const tmp<edgeScalarField>& tflux,
215  const word& name
216 )
217 {
219  (
220  fac::ndiv(tflux(), vf, name)
221  );
222  tflux.clear();
223 
224  return Div;
225 }
226 
227 
228 template<class Type>
230 ndiv
231 (
232  const edgeScalarField& flux,
234  const word& name
235 )
236 {
238  (
239  fac::ndiv(flux, tvf(), name)
240  );
241  tvf.clear();
242 
243  return Div;
244 }
245 
246 
247 template<class Type>
249 ndiv
250 (
251  const tmp<edgeScalarField>& tflux,
253  const word& name
254 )
255 {
257  (
258  fac::ndiv(tflux(), tvf(), name)
259  );
260  tflux.clear();
261  tvf.clear();
262 
263  return Div;
264 }
265 
266 
267 template<class Type>
269 ndiv
270 (
271  const edgeScalarField& flux,
273 )
274 {
275  return fac::ndiv
276  (
277  flux, vf, "div("+flux.name()+','+vf.name()+')'
278  );
279 }
280 
281 
282 template<class Type>
284 ndiv
285 (
286  const tmp<edgeScalarField>& tflux,
288 )
289 {
291  (
292  fac::ndiv(tflux(), vf)
293  );
294  tflux.clear();
295  return Div;
296 }
297 
298 
299 template<class Type>
301 ndiv
302 (
303  const edgeScalarField& flux,
305 )
306 {
308  (
309  fac::ndiv(flux, tvf())
310  );
311  tvf.clear();
312  return Div;
313 }
314 
315 
316 template<class Type>
318 ndiv
319 (
320  const tmp<edgeScalarField>& tflux,
322 )
323 {
325  (
326  fac::ndiv(tflux(), tvf())
327  );
328  tflux.clear();
329  tvf.clear();
330 
331  return Div;
332 }
333 
334 
335 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
336 
337 } // End namespace fac
338 
339 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
340 
341 } // End namespace Foam
342 
343 // ************************************************************************* //
Foam::faPatchField
faPatchField<Type> abstract base class. This class gives a fat-interface to all derived classes cover...
Definition: areaFieldsFwd.H:50
Foam::fvc::flux
tmp< surfaceScalarField > flux(const volVectorField &vvf)
Return the face-flux field obtained from the given volVectorField.
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::tmp::clear
void clear() const noexcept
Definition: tmpI.H:287
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::innerProduct
Definition: products.H:141
Foam::fac::ndiv
tmp< GeometricField< Type, faPatchField, areaMesh > > ndiv(const GeometricField< Type, faePatchField, edgeMesh > &ssf)
Definition: facNDiv.C:50
faConvectionScheme.H
faMesh.H
ref
rDeltaT ref()
Foam::GeometricField::internalField
const Internal & internalField() const
Return a const-reference to the dimensioned internal field.
Definition: GeometricFieldI.H:43
transformField.H
Spatial transformation functions for primitive fields.
n
label n
Definition: TABSMDCalcMethod2.H:31
Foam::tmp::ref
T & ref() const
Definition: tmpI.H:227
facEdgeIntegrate.H
Edge integrate edgeField creating a areaField. Edge sum a edgeField creating a areaField.
facNDiv.H
Calculate the divergence of the given field.
Foam::areaMesh
Mesh data needed to do the Finite Area discretisation.
Definition: areaFaMesh.H:53
Foam::fac::edgeIntegrate
tmp< GeometricField< Type, faPatchField, areaMesh > > edgeIntegrate(const GeometricField< Type, faePatchField, edgeMesh > &ssf)
Definition: facEdgeIntegrate.C:47
Foam::fa::convectionScheme
Abstract base class for finite area calculus convection schemes.
Definition: faConvectionScheme.H:65
Foam::fa::divScheme
Abstract base class for finite area calculus div schemes.
Definition: faDivScheme.H:67
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
fac
Calculate the second temporal derivative.
faDivScheme.H
Foam::GeometricField::primitiveFieldRef
Internal::FieldType & primitiveFieldRef(const bool updateAccessTime=true)
Return a reference to the internal field.
Definition: GeometricField.C:766
Foam::GeometricField::correctBoundaryConditions
void correctBoundaryConditions()
Correct boundary field.
Definition: GeometricField.C:940
Foam::GeometricField::ref
Internal & ref(const bool updateAccessTime=true)
Return a reference to the dimensioned internal field.
Definition: GeometricField.C:749
Foam::name
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
Foam::flux
Definition: vector.H:56
Foam::GeometricField
Generic GeometricField class.
Definition: areaFieldsFwd.H:53