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-------------------------------------------------------------------------------
10License
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
37namespace Foam
38{
39
40// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
41
42namespace fac
43{
44
45// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46
47template<class Type>
48tmp<GeometricField<Type, faPatchField, areaMesh>>
50(
52)
53{
54 const areaVectorField& n = ssf.mesh().faceAreaNormals();
55
58
60
61 Div.primitiveFieldRef() =
64
65 return tDiv;
66}
67
68
69template<class Type>
72(
74)
75{
77 tssf.clear();
78 return tDiv;
79}
80
81
82template<class Type>
83tmp
84<
86 <
88 >
89>
91(
93 const word& name
94)
95{
96 const areaVectorField& n = vf.mesh().faceAreaNormals();
97
98 tmp
99 <
101 <
105 >
106 > tDiv
107 (
109 (
110 vf.mesh(), vf.mesh().divScheme(name)
111 ).ref().facDiv(vf)
112 );
114 <
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
129template<class Type>
130tmp
131<
133 <
135 >
136>
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
152template<class Type>
153tmp
154<
156 <
158 >
159>
161(
163)
164{
165 return fac::div(vf, "div("+vf.name()+')');
166}
167
168
169template<class Type>
170tmp
171<
173 <
175 >
176>
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
193template<class Type>
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
217
218 return tDiv;
219
220}
221
222
223template<class Type>
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
241template<class Type>
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
259template<class Type>
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
278template<class Type>
281(
282 const edgeScalarField& flux,
284)
285{
286 return fac::div
287 (
288 flux, vf, "div("+flux.name()+','+vf.name()+')'
289 );
290}
291
292
293template<class Type>
296(
297 const tmp<edgeScalarField>& tflux,
299)
300{
302 (
303 fac::div(tflux(), vf)
304 );
305 tflux.clear();
306 return tDiv;
307}
308
309
310template<class Type>
313(
314 const edgeScalarField& flux,
316)
317{
319 (
320 fac::div(flux, tvf())
321 );
322 tvf.clear();
323 return tDiv;
324}
325
326
327template<class Type>
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// ************************************************************************* //
label n
const Mesh & mesh() const
Return mesh.
Generic GeometricField class.
Internal::FieldType & primitiveFieldRef(const bool updateAccessTime=true)
Return a reference to the internal field.
void correctBoundaryConditions()
Correct boundary field.
const Internal & internalField() const
Return a const-reference to the dimensioned internal field.
const word & name() const noexcept
Return the object name.
Definition: IOobjectI.H:65
static const Tensor I
Definition: Tensor.H:81
Mesh data needed to do the Finite Area discretisation.
Definition: areaFaMesh.H:56
faPatchField<Type> abstract base class. This class gives a fat-interface to all derived classes cover...
Definition: faPatchField.H:82
Abstract base class for finite area calculus convection schemes.
virtual tmp< GeometricField< Type, faPatchField, areaMesh > > facDiv(const edgeScalarField &, const GeometricField< Type, faPatchField, areaMesh > &) const =0
Abstract base class for finite area calculus div schemes.
Definition: faDivScheme.H:70
virtual tmp< GeometricField< typename innerProduct< vector, Type >::type, faPatchField, areaMesh > > facDiv(const GeometricField< Type, faPatchField, areaMesh > &)=0
A class for managing temporary objects.
Definition: tmp.H:65
void clear() const noexcept
Definition: tmpI.H:287
T & ref() const
Definition: tmpI.H:227
type
Volume classification types.
Definition: volumeType.H:66
A class for handling words, derived from Foam::string.
Definition: word.H:68
Calculate the divergence of the given field.
Edge integrate edgeField creating a areaField. Edge sum a edgeField creating a areaField.
tmp< GeometricField< Type, faPatchField, areaMesh > > div(const GeometricField< Type, faePatchField, edgeMesh > &ssf)
Definition: facDiv.C:50
tmp< GeometricField< Type, faPatchField, areaMesh > > edgeIntegrate(const GeometricField< Type, faePatchField, edgeMesh > &ssf)
Namespace for OpenFOAM.
dimensionSet transform(const dimensionSet &ds)
Return the argument; transformations do not change the dimensions.
Definition: dimensionSet.C:536
dimensionedSymmTensor sqr(const dimensionedVector &dv)
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
Calculate the second temporal derivative.
Spatial transformation functions for primitive fields.