facDiv.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 "facDiv.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 div
50 (
52 )
53 {
54  const areaVectorField& n = ssf.mesh().faceAreaNormals();
55 
57  fac::edgeIntegrate(ssf);
58 
60 
61  Div.primitiveFieldRef() =
64 
65  return tDiv;
66 }
67 
68 
69 template<class Type>
71 div
72 (
74 )
75 {
77  tssf.clear();
78  return tDiv;
79 }
80 
81 
82 template<class Type>
83 tmp
84 <
86  <
88  >
89 >
90 div
91 (
93  const word& name
94 )
95 {
96  const areaVectorField& n = vf.mesh().faceAreaNormals();
97 
98  tmp
99  <
101  <
103  faPatchField,
104  areaMesh
105  >
106  > tDiv
107  (
109  (
110  vf.mesh(), vf.mesh().divScheme(name)
111  ).ref().facDiv(vf)
112  );
114  <
116  faPatchField,
117  areaMesh
118  >& Div = tDiv.ref();
119 
120  Div.primitiveFieldRef() =
121  transform(tensor::I - sqr(n), Div.internalField());
122 
123  Div.correctBoundaryConditions();
124 
125  return tDiv;
126 }
127 
128 
129 template<class Type>
130 tmp
131 <
133  <
135  >
136 >
137 div
138 (
140  const word& name
141 )
142 {
143  typedef typename innerProduct<vector, Type>::type DivType;
145  (
146  fac::div(tvvf(), name)
147  );
148  tvvf.clear();
149  return tDiv;
150 }
151 
152 template<class Type>
153 tmp
154 <
156  <
158  >
159 >
160 div
161 (
163 )
164 {
165  return fac::div(vf, "div("+vf.name()+')');
166 }
167 
168 
169 template<class Type>
170 tmp
171 <
173  <
175  >
176 >
177 div
178 (
180 )
181 {
182  typedef typename innerProduct<vector, Type>::type DivType;
184  (
185  fac::div(tvvf())
186  );
187 
188  tvvf.clear();
189  return tDiv;
190 }
191 
192 
193 template<class Type>
195 div
196 (
197  const edgeScalarField& flux,
199  const word& name
200 )
201 {
202  const areaVectorField& n = vf.mesh().faceAreaNormals();
203 
205  (
207  (
208  vf.mesh(),
209  flux,
210  vf.mesh().divScheme(name)
211  ).ref().facDiv(flux, vf)
212  );
214 
215  Div.primitiveFieldRef() = transform(tensor::I - sqr(n), Div.internalField());
216  Div.correctBoundaryConditions();
217 
218  return tDiv;
219 
220 }
221 
222 
223 template<class Type>
225 div
226 (
227  const tmp<edgeScalarField>& tflux,
229  const word& name
230 )
231 {
233  (
234  fac::div(tflux(), vf, name)
235  );
236  tflux.clear();
237  return tDiv;
238 }
239 
240 
241 template<class Type>
243 div
244 (
245  const edgeScalarField& flux,
247  const word& name
248 )
249 {
251  (
252  fac::div(flux, tvf(), name)
253  );
254  tvf.clear();
255  return tDiv;
256 }
257 
258 
259 template<class Type>
261 div
262 (
263  const tmp<edgeScalarField>& tflux,
265  const word& name
266 )
267 {
269  (
270  fac::div(tflux(), tvf(), name)
271  );
272  tflux.clear();
273  tvf.clear();
274  return tDiv;
275 }
276 
277 
278 template<class Type>
280 div
281 (
282  const edgeScalarField& flux,
284 )
285 {
286  return fac::div
287  (
288  flux, vf, "div("+flux.name()+','+vf.name()+')'
289  );
290 }
291 
292 
293 template<class Type>
295 div
296 (
297  const tmp<edgeScalarField>& tflux,
299 )
300 {
302  (
303  fac::div(tflux(), vf)
304  );
305  tflux.clear();
306  return tDiv;
307 }
308 
309 
310 template<class Type>
312 div
313 (
314  const edgeScalarField& flux,
316 )
317 {
319  (
320  fac::div(flux, tvf())
321  );
322  tvf.clear();
323  return tDiv;
324 }
325 
326 
327 template<class Type>
329 div
330 (
331  const tmp<edgeScalarField>& tflux,
333 )
334 {
336  (
337  fac::div(tflux(), tvf())
338  );
339  tflux.clear();
340  tvf.clear();
341  return tDiv;
342 }
343 
344 
345 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
346 
347 } // End namespace fac
348 
349 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
350 
351 } // End namespace Foam
352 
353 // ************************************************************************* //
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::Tensor::I
static const Tensor I
Definition: Tensor.H:85
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
faConvectionScheme.H
facDiv.H
Calculate the divergence of the given field.
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
Foam::transform
dimensionSet transform(const dimensionSet &ds)
Return the argument; transformations do not change the dimensions.
Definition: dimensionSet.C:521
Foam::fac::div
tmp< GeometricField< Type, faPatchField, areaMesh > > div(const GeometricField< Type, faePatchField, edgeMesh > &ssf)
Definition: facDiv.C:50
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.
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::sqr
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Definition: dimensionedSymmTensor.C:51
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