Skip to content

Commit 4c461e8

Browse files
committed
Add coded function object to calculate mass flux
1 parent 6fecb40 commit 4c461e8

File tree

2 files changed

+64
-11
lines changed

2 files changed

+64
-11
lines changed

etc/caseDicts/functions/fields/compressibilityMachNo

+21-11
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,37 @@
22
========= |
33
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
44
\\ / O peration | Website: https://openfoam.org
5-
\\ / A nd | Version: dev
5+
\\ / A nd | Version: dev (20241102)
66
\\/ M anipulation |
7+
-------------------------------------------------------------------------------
8+
Description
9+
Caches and writes Mach number based on compressibility
10+
711
\*---------------------------------------------------------------------------*/
812

913
type coded;
14+
libs ( "libutilityFunctionObjects.so" );
1015

11-
libs ("libutilityFunctionObjects.so");
16+
executeControl writeTime;
17+
writeControl writeTime;
1218

13-
name compressibilityMachNo;
19+
codeFields
20+
#{
21+
fields.append("psi");
22+
fields.append("U");
23+
#};
1424

15-
writeControl writeTime;
25+
codeExecute
26+
#{
27+
const volScalarField& psi = mesh().lookupObject<volScalarField>("psi");
28+
const volVectorField& U = mesh().lookupObject<volVectorField>("UMean");
29+
30+
store("Ma", mag(U)*sqrt(psi));
31+
#};
1632

1733
codeWrite
1834
#{
19-
const volVectorField& U(mesh().lookupObject<volVectorField>("U"));
20-
const volScalarField& psi(mesh().lookupObject<volScalarField>("psi"));
21-
22-
volScalarField::New(
23-
"Ma",
24-
mag(U) * sqrt(psi)
25-
)->write();
35+
return writeObject("Ma");
2636
#};
2737

2838
// ************************************************************************* //
+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*--------------------------------*- C++ -*----------------------------------*\
2+
========= |
3+
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4+
\\ / O peration | Website: https://openfoam.org
5+
\\ / A nd | Version: dev (20241102)
6+
\\/ M anipulation |
7+
-------------------------------------------------------------------------------
8+
Description
9+
Caches and writes mass flux
10+
11+
\*---------------------------------------------------------------------------*/
12+
13+
type coded;
14+
libs ( "libutilityFunctionObjects.so" );
15+
16+
executeControl writeTime;
17+
writeControl writeTime;
18+
19+
codeInclude
20+
#{
21+
#include "fvcFlux.H"
22+
#};
23+
24+
codeFields
25+
#{
26+
fields.append("rho");
27+
fields.append("U");
28+
#};
29+
30+
codeExecute
31+
#{
32+
const volScalarField& rho = mesh().lookupObject<volScalarField>("rho");
33+
const volVectorField& U = mesh().lookupObject<volVectorField>("U");
34+
35+
store("varphi", linearInterpolate(rho*U) & mesh().Sf());
36+
#};
37+
38+
codeWrite
39+
#{
40+
return writeObject("varphi");
41+
#};
42+
43+
// ************************************************************************* //

0 commit comments

Comments
 (0)