Files
OpenFOAM-12/tutorials/fluid/blockedChannel/system/generateAlphas
2024-07-06 16:02:47 +01:00

56 lines
1.5 KiB
C++

/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 12
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
type coded;
// Load the library containing the 'coded' functionObject
libs ("libutilityFunctionObjects.so");
name generateAlphas;
codeWrite
#{
const dimensionedVector dx(dimless/dimLength, vector(1, 0, 0));
const dimensionedVector dy(dimless/dimLength, vector(0, 1, 0));
const volScalarField x(mesh().C() & dx), y(mesh().C() & dy);
const scalar x0 = 0.032, x1 = 0.064, x2 = 0.128, x3 = 0.224;
const volScalarField f
(
pos(x - x0)*pos(x1 - x)*(x - x0)/(x1 - x0)
+ pos(x - x1)*pos(x2 - x)
+ pos(x - x2)*pos(x3 - x)*(x3 - x)/(x3 - x2)
);
volScalarField
(
IOobject
(
IOobject::groupName("alpha", "volume"),
mesh().time().constant(),
mesh()
),
0.5*pos(y - (-0.088))*pos((-0.056) - y)*f
).write();
volScalarField
(
IOobject
(
IOobject::groupName("alpha", "solid"),
mesh().time().constant(),
mesh()
),
0.5*pos(y - (-0.124))*pos((-0.092) - y)*f
).write();
#};
// ************************************************************************* //