Loading...
Searching...
No Matches
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>
49ndiv
50(
52)
53{
54 const areaVectorField& n = ssf.mesh().faceAreaNormals();
55
58
60
61 v.primitiveFieldRef() = n*(n & v.internalField());
64 return v;
65}
66
67
68template<class Type>
70ndiv
71(
73)
74{
76 tssf.clear();
77 return Div;
78}
79
80
81template<class Type>
83<
85 <
87 >
88>
89ndiv
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>
129 (
130 fac::ndiv(tvvf(), name)
131 );
132 tvvf.clear();
133
134 return Div;
135}
136
137template<class Type>
145ndiv
146(
148)
149{
150 return fac::ndiv(vf, "div("+vf.name()+')');
151}
152
153
154template<class Type>
169 (
170 fac::ndiv(tvvf())
171 );
172
173 tvvf.clear();
174 return Div;
175}
176
177
178template<class Type>
180ndiv
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>
211ndiv
212(
213 const tmp<edgeScalarField>& tflux,
215 const word& name
216)
217{
219 (
220 fac::ndiv(tflux(), vf, name)
221 );
222 tflux.clear();
224 return Div;
225}
226
227
228template<class Type>
230ndiv
231(
232 const edgeScalarField& flux,
234 const word& name
235)
236{
238 (
239 fac::ndiv(flux, tvf(), name)
240 );
241 tvf.clear();
243 return Div;
244}
245
246
247template<class Type>
249ndiv
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();
263 return Div;
264}
265
266
267template<class Type>
269ndiv
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>
284ndiv
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>
301ndiv
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>
318ndiv
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 noexcept
Return const reference to mesh.
Generic GeometricField class.
Internal::FieldType & primitiveFieldRef(const bool updateAccessTime=true)
Return a reference to the internal field values.
const Internal & internalField() const noexcept
Return a const-reference to the dimensioned internal field.
void correctBoundaryConditions()
Correct boundary field.
const word & name() const noexcept
Return the object name.
Definition IOobjectI.H:205
Mesh data needed to do the Finite Area discretisation.
Definition areaFaMesh.H:50
faPatchField<Type> abstract base class. This class gives a fat-interface to all derived classes cover...
static tmp< convectionScheme< Type > > New(const faMesh &mesh, const edgeScalarField &faceFlux, Istream &schemeData)
Return a pointer to a new convectionScheme created on freestore.
static tmp< divScheme< Type > > New(const faMesh &mesh, Istream &schemeData)
Return a pointer to a new divScheme created on freestore.
Definition faDivScheme.C:35
typeOfRank< typenamepTraits< arg1 >::cmptType, direction(pTraits< arg1 >::rank)+direction(pTraits< arg2 >::rank) -2 >::type type
Definition products.H:155
A class for managing temporary objects.
Definition tmp.H:75
void clear() const noexcept
If object pointer points to valid object: delete object and set pointer to nullptr.
Definition tmpI.H:289
T & ref() const
Return non-const reference to the contents of a non-null managed pointer.
Definition tmpI.H:235
A class for handling words, derived from Foam::string.
Definition word.H:66
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:43
Namespace for OpenFOAM.
GeometricField< vector, faPatchField, areaMesh > areaVectorField
GeometricField< scalar, faePatchField, edgeMesh > edgeScalarField
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition exprTraits.C:127
Calculate the second temporal derivative.
Spatial transformation functions for primitive fields.