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-------------------------------------------------------------------------------
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 "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
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 v.primitiveFieldRef() = n*(n & v.internalField());
63
64 return v;
65}
66
67
68template<class Type>
71(
73)
74{
76 tssf.clear();
77 return Div;
78}
79
80
81template<class Type>
82tmp
83<
85 <
87 >
88>
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());
108
109 return tDiv;
110}
111
112
113template<class Type>
114tmp
115<
117 <
119 >
120>
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
137template<class Type>
138tmp
139<
141 <
143 >
144>
146(
148)
149{
150 return fac::ndiv(vf, "div("+vf.name()+')');
151}
152
153
154template<class Type>
155tmp
156<
158 <
160 >
161>
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
178template<class Type>
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());
203
204 return tDiv;
205
206}
207
208
209template<class Type>
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
228template<class Type>
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
247template<class Type>
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
267template<class Type>
270(
271 const edgeScalarField& flux,
273)
274{
275 return fac::ndiv
276 (
277 flux, vf, "div("+flux.name()+','+vf.name()+')'
278 );
279}
280
281
282template<class Type>
285(
286 const tmp<edgeScalarField>& tflux,
288)
289{
291 (
292 fac::ndiv(tflux(), vf)
293 );
294 tflux.clear();
295 return Div;
296}
297
298
299template<class Type>
302(
303 const edgeScalarField& flux,
305)
306{
308 (
309 fac::ndiv(flux, tvf())
310 );
311 tvf.clear();
312 return Div;
313}
314
315
316template<class Type>
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// ************************************************************************* //
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
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
Edge integrate edgeField creating a areaField. Edge sum a edgeField creating a areaField.
Calculate the divergence of the given field.
tmp< GeometricField< Type, faPatchField, areaMesh > > edgeIntegrate(const GeometricField< Type, faePatchField, edgeMesh > &ssf)
tmp< GeometricField< Type, faPatchField, areaMesh > > ndiv(const GeometricField< Type, faePatchField, edgeMesh > &ssf)
Definition: facNDiv.C:50
Namespace for OpenFOAM.
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.