TUT: use #eval instead of #calc where possible

This commit is contained in:
Mark Olesen 2019-10-01 10:14:55 +02:00 committed by Andrew Heather
parent 02914539f7
commit e7f380dcd5
12 changed files with 119 additions and 123 deletions

View File

@ -25,43 +25,41 @@ t -10;
u 10; u 10;
o 10; o 10;
d2r #calc "constant::mathematical::pi/180"; r0CosT #eval{ $r0*cos(degToRad($t )) };
r0CosTO #eval{ $r0*cos(degToRad($t+$o)) };
r0CosU #eval{ $r0*cos(degToRad($u )) };
r0CosUO #eval{ $r0*cos(degToRad($u+$o)) };
r0SinT #eval{ $r0*sin(degToRad($t )) };
r0SinTO #eval{ $r0*sin(degToRad($t+$o)) };
r0SinU #eval{ $r0*sin(degToRad($u )) };
r0SinUO #eval{ $r0*sin(degToRad($u+$o)) };
r0CosT #calc "$r0*cos($d2r*($t ))"; r1CosT #eval{ $r1*cos(degToRad($t )) };
r0CosTO #calc "$r0*cos($d2r*($t+$o))"; r1CosTO #eval{ $r1*cos(degToRad($t+$o)) };
r0CosU #calc "$r0*cos($d2r*($u ))"; r1CosU #eval{ $r1*cos(degToRad($u )) };
r0CosUO #calc "$r0*cos($d2r*($u+$o))"; r1CosUO #eval{ $r1*cos(degToRad($u+$o)) };
r0SinT #calc "$r0*sin($d2r*($t ))"; r1SinT #eval{ $r1*sin(degToRad($t )) };
r0SinTO #calc "$r0*sin($d2r*($t+$o))"; r1SinTO #eval{ $r1*sin(degToRad($t+$o)) };
r0SinU #calc "$r0*sin($d2r*($u ))"; r1SinU #eval{ $r1*sin(degToRad($u )) };
r0SinUO #calc "$r0*sin($d2r*($u+$o))"; r1SinUO #eval{ $r1*sin(degToRad($u+$o)) };
r1CosT #calc "$r1*cos($d2r*($t ))"; r2CosT #eval{ $r2*cos(degToRad($t )) };
r1CosTO #calc "$r1*cos($d2r*($t+$o))"; r2CosTO #eval{ $r2*cos(degToRad($t+$o)) };
r1CosU #calc "$r1*cos($d2r*($u ))"; r2CosU #eval{ $r2*cos(degToRad($u )) };
r1CosUO #calc "$r1*cos($d2r*($u+$o))"; r2CosUO #eval{ $r2*cos(degToRad($u+$o)) };
r1SinT #calc "$r1*sin($d2r*($t ))"; r2SinT #eval{ $r2*sin(degToRad($t )) };
r1SinTO #calc "$r1*sin($d2r*($t+$o))"; r2SinTO #eval{ $r2*sin(degToRad($t+$o)) };
r1SinU #calc "$r1*sin($d2r*($u ))"; r2SinU #eval{ $r2*sin(degToRad($u )) };
r1SinUO #calc "$r1*sin($d2r*($u+$o))"; r2SinUO #eval{ $r2*sin(degToRad($u+$o)) };
r2CosT #calc "$r2*cos($d2r*($t ))"; r3CosT #eval{ $r3*cos(degToRad($t )) };
r2CosTO #calc "$r2*cos($d2r*($t+$o))"; r3CosTO #eval{ $r3*cos(degToRad($t+$o)) };
r2CosU #calc "$r2*cos($d2r*($u ))"; r3CosU #eval{ $r3*cos(degToRad($u )) };
r2CosUO #calc "$r2*cos($d2r*($u+$o))"; r3CosUO #eval{ $r3*cos(degToRad($u+$o)) };
r2SinT #calc "$r2*sin($d2r*($t ))"; r3SinT #eval{ $r3*sin(degToRad($t )) };
r2SinTO #calc "$r2*sin($d2r*($t+$o))"; r3SinTO #eval{ $r3*sin(degToRad($t+$o)) };
r2SinU #calc "$r2*sin($d2r*($u ))"; r3SinU #eval{ $r3*sin(degToRad($u )) };
r2SinUO #calc "$r2*sin($d2r*($u+$o))"; r3SinUO #eval{ $r3*sin(degToRad($u+$o)) };
r3CosT #calc "$r3*cos($d2r*($t ))";
r3CosTO #calc "$r3*cos($d2r*($t+$o))";
r3CosU #calc "$r3*cos($d2r*($u ))";
r3CosUO #calc "$r3*cos($d2r*($u+$o))";
r3SinT #calc "$r3*sin($d2r*($t ))";
r3SinTO #calc "$r3*sin($d2r*($t+$o))";
r3SinU #calc "$r3*sin($d2r*($u ))";
r3SinUO #calc "$r3*sin($d2r*($u+$o))";
vertices vertices
( (

View File

@ -16,10 +16,11 @@ FoamFile
scale 1; scale 1;
L #calc "20*M_PI"; L #eval{ 20*pi() };
H #calc "1"; H 1.0;
H2 #calc "2*$H"; H2 #eval{ 2*$H };
W #calc "M_PI"; W #eval{ pi() };
vertices vertices
( (

View File

@ -45,6 +45,10 @@ timePrecision 6;
runTimeModifiable true; runTimeModifiable true;
// Allow 10% run-up before calculating mean
timeStart #eval #{ 0.1 * ${/endTime} #};
functions functions
{ {
Q1 Q1
@ -84,7 +88,7 @@ functions
type fieldAverage; type fieldAverage;
libs (fieldFunctionObjects); libs (fieldFunctionObjects);
writeControl writeTime; writeControl writeTime;
timeStart 8.5; timeStart ${/timeStart};
fields fields
( (

View File

@ -23,17 +23,17 @@ z_pad 1;
x0 0; x0 0;
x1 $x_up; x1 $x_up;
x2 #calc "$x1 + 1"; x2 #eval{ $x1 + 1 };
x3 #calc "$x2 + $x_down"; x3 #eval{ $x2 + $x_down };
y0 0; y0 0;
y1 $y_pad; y1 $y_pad;
y2 #calc "$y1 + 1"; y2 #eval{ $y1 + 1 };
y3 #calc "$y2 + $y_pad"; y3 #eval{ $y2 + $y_pad };
z0 0; z0 0;
z1 1; z1 1;
z2 #calc "$z1 + $z_pad"; z2 #eval{ $z1 + $z_pad };
nx1 40; nx1 40;
nx2 40; nx2 40;

View File

@ -20,14 +20,12 @@ scale 1;
halfAngle 45.0; halfAngle 45.0;
//- Radius of pipe [m] //- Radius of pipe [m]
radius 0.5; radius 0.5;
y #eval{ $radius*sin(degToRad($halfAngle)) };
radHalfAngle #calc "degToRad($halfAngle)"; minY #eval{ -1*$y };
y #calc "$radius*sin($radHalfAngle)"; z #eval{ $radius*cos(degToRad($halfAngle)) };
minY #calc "-1.0*$y"; minZ #eval{ -1*$z };
z #calc "$radius*cos($radHalfAngle)";
minZ #calc "-1.0*$z";
vertices vertices
( (

View File

@ -32,83 +32,79 @@ sphereLayerThickness 2.0; // Total layer thickness in sphere radii
sphereRadius 0.028; sphereRadius 0.028;
sphereCentreHeight 0.147; // y-coord of sphere centre sphereCentreHeight 0.147; // y-coord of sphere centre
pi #calc "Foam::constant::mathematical::pi";
// Calculated positions // Calculated positions
sphereRadiusPosition #calc "-1.0*(1.0 + $sphereLayerThickness)*$sphereRadius"; //"-1.0* $sphereRadius"; sphereRadiusPosition #eval{ -1.0*(1.0 + $sphereLayerThickness)*$sphereRadius };
AMIBlockPosition #calc "2.0*$sphereRadiusPosition + $sphereRadius"; AMIBlockPosition #eval{ 2.0*$sphereRadiusPosition + $sphereRadius };
// Centre plane is z=0, so use half of wedge angle to calculate pos and neg // Centre plane is z=0, so use half of wedge angle to calculate pos and neg
// z-positions // z-positions
halfAngleRad #calc "0.5*$wedgeAngle*$pi/180.0"; tanAlpha #eval{ tan(0.5*degToRad($wedgeAngle)) };
tanAlpha #calc "tan($halfAngleRad)";
// Multiply by -1 because tan give negative value // Multiply by -1 because tan give negative value
firstBlockPosDepth #calc "-1.0*$tanAlpha*$sphereRadiusPosition"; firstBlockPosDepth #eval{ -1.0*$tanAlpha*$sphereRadiusPosition };
firstBlockNegDepth #calc "-1.0*$firstBlockPosDepth"; firstBlockNegDepth #eval{ -1.0*$firstBlockPosDepth };
AMIBlockPosDepth #calc "-1.0*$tanAlpha*$AMIBlockPosition"; AMIBlockPosDepth #eval{ -1.0*$tanAlpha*$AMIBlockPosition };
AMIBlockNegDepth #calc "-1.0*$AMIBlockPosDepth"; AMIBlockNegDepth #eval{ -1.0*$AMIBlockPosDepth };
farFieldPosDepth #calc "-1.0*$tanAlpha*$farFieldWall"; farFieldPosDepth #eval{ -1.0*$tanAlpha*$farFieldWall };
farFieldNegDepth #calc "-1.0*$farFieldPosDepth"; farFieldNegDepth #eval{ -1.0*$farFieldPosDepth };
bottomBlockTopHeight #calc "$sphereCentreHeight - $lowerSphereBlock*$sphereRadius"; bottomBlockTopHeight #eval{ $sphereCentreHeight - $lowerSphereBlock*$sphereRadius };
topBlockBottomHeight #calc "$sphereCentreHeight + $upperSphereBlock*$sphereRadius"; topBlockBottomHeight #eval{ $sphereCentreHeight + $upperSphereBlock*$sphereRadius };
topSphere #calc "$sphereCentreHeight + $sphereRadius"; topSphere #eval{ $sphereCentreHeight + $sphereRadius };
bottomSphere #calc "$sphereCentreHeight - $sphereRadius"; bottomSphere #eval{ $sphereCentreHeight - $sphereRadius };
topSphereLayer #calc "$sphereCentreHeight + (1.0 + $sphereLayerThickness)*$sphereRadius"; topSphereLayer #eval{ $sphereCentreHeight + (1.0 + $sphereLayerThickness)*$sphereRadius };
bottomSphereLayer #calc "$sphereCentreHeight - (1.0 + $sphereLayerThickness)*$sphereRadius"; bottomSphereLayer #eval{ $sphereCentreHeight - (1.0 + $sphereLayerThickness)*$sphereRadius };
// Layer block below sphere // Layer block below sphere
innerBottomLayerX #calc "-1.0*cos(45.0*$pi/180.0)*$sphereRadius"; innerBottomLayerX #eval{ -1.0*cos(degToRad(45.0))*$sphereRadius };
innerBottomLayerY #calc "$sphereCentreHeight - cos(45.0*$pi/180.0)*$sphereRadius"; innerBottomLayerY #eval{ $sphereCentreHeight - cos(degToRad(45.0))*$sphereRadius };
innerBottomLayerZPos #calc "-1.0*$tanAlpha*$innerBottomLayerX"; innerBottomLayerZPos #eval{ -1.0*$tanAlpha*$innerBottomLayerX };
innerBottomLayerZNeg #calc "-1.0*$innerBottomLayerZPos"; innerBottomLayerZNeg #eval{ -1.0*$innerBottomLayerZPos };
innerBottomArcX1 #calc "-1.0*sin(22.5*$pi/180.0)*$sphereRadius"; innerBottomArcX1 #eval{ -1.0*sin(degToRad(22.5))*$sphereRadius };
innerBottomArcY1 #calc "$sphereCentreHeight - cos(22.5*$pi/180.0)*$sphereRadius"; innerBottomArcY1 #eval{ $sphereCentreHeight - cos(degToRad(22.5))*$sphereRadius };
innerBottomArcZ1Pos #calc "$innerBottomArcX1*$tanAlpha"; innerBottomArcZ1Pos #eval{ $innerBottomArcX1*$tanAlpha };
innerBottomArcZ1Neg #calc "-1.0*$innerBottomArcZ1Pos"; innerBottomArcZ1Neg #eval{ -1.0*$innerBottomArcZ1Pos };
outerBottomArcX1 #calc "-1.0*sin(22.5*$pi/180.0)*$sphereRadius*(1.0 + $sphereLayerThickness)"; outerBottomArcX1 #eval{ -1.0*sin(degToRad(22.5))*$sphereRadius*(1.0 + $sphereLayerThickness) };
outerBottomArcY1 #calc #{ $sphereCentreHeight - cos(22.5*$pi/180.0)*$sphereRadius*(1.0 + $sphereLayerThickness) #}; outerBottomArcY1 #eval{ $sphereCentreHeight - cos(degToRad(22.5))*$sphereRadius*(1.0 + $sphereLayerThickness) };
outerBottomArcZ1Pos #calc "$outerBottomArcX1*$tanAlpha"; outerBottomArcZ1Pos #eval{ $outerBottomArcX1*$tanAlpha };
outerBottomArcZ1Neg #calc "-1.0*$outerBottomArcZ1Pos"; outerBottomArcZ1Neg #eval{ -1.0*$outerBottomArcZ1Pos };
outerBottomLayerX #calc "-1.0*cos(45.0*$pi/180.0)*(1.0 + $sphereLayerThickness)*$sphereRadius"; outerBottomLayerX #eval{ -1.0*cos(degToRad(45.0))*(1.0 + $sphereLayerThickness)*$sphereRadius };
outerBottomLayerY #calc "$sphereCentreHeight - cos(45.0*$pi/180.0)*(1.0 + $sphereLayerThickness)*$sphereRadius"; outerBottomLayerY #eval{ $sphereCentreHeight - cos(degToRad(45.0))*(1.0 + $sphereLayerThickness)*$sphereRadius };
outerBottomLayerZPos #calc "-1.0*$tanAlpha*$outerBottomLayerX"; outerBottomLayerZPos #eval{ -1.0*$tanAlpha*$outerBottomLayerX };
outerBottomLayerZNeg #calc "-1.0*$outerBottomLayerZPos"; outerBottomLayerZNeg #eval{ -1.0*$outerBottomLayerZPos };
// Layer block above sphere // Layer block above sphere
innerTopLayerX #calc "cos(135.0*$pi/180.0)*$sphereRadius"; innerTopLayerX #eval{ cos(degToRad(135.0))*$sphereRadius };
innerTopLayerY #calc "$sphereCentreHeight - cos(135.0*$pi/180.0)*$sphereRadius"; innerTopLayerY #eval{ $sphereCentreHeight - cos(degToRad(135.0))*$sphereRadius };
innerTopLayerZPos #calc "-1.0*$tanAlpha*$innerBottomLayerX"; innerTopLayerZPos #eval{ -1.0*$tanAlpha*$innerBottomLayerX };
innerTopLayerZNeg #calc "-1.0*$innerBottomLayerZPos"; innerTopLayerZNeg #eval{ -1.0*$innerBottomLayerZPos };
innerTopArcX1 #calc "-1.0*sin(157.5*$pi/180.0)*$sphereRadius"; innerTopArcX1 #eval{ -1.0*sin(degToRad(157.5))*$sphereRadius };
innerTopArcY1 #calc "$sphereCentreHeight - cos(157.5*$pi/180.0)*$sphereRadius"; innerTopArcY1 #eval{ $sphereCentreHeight - cos(degToRad(157.5))*$sphereRadius };
innerTopArcZ1Pos #calc "$innerTopArcX1*$tanAlpha"; innerTopArcZ1Pos #eval{ $innerTopArcX1*$tanAlpha };
innerTopArcZ1Neg #calc "-1.0*$innerTopArcZ1Pos"; innerTopArcZ1Neg #eval{ -1.0*$innerTopArcZ1Pos };
outerTopArcX1 #calc "-1.0*sin(157.5*$pi/180.0)*$sphereRadius*(1.0 + $sphereLayerThickness)"; outerTopArcX1 #eval{ -1.0*sin(degToRad(157.5))*$sphereRadius*(1.0 + $sphereLayerThickness) };
outerTopArcY1 #calc "$sphereCentreHeight - cos(157.5*$pi/180.0)*$sphereRadius*(1.0 + $sphereLayerThickness)"; outerTopArcY1 #eval{ $sphereCentreHeight - cos(degToRad(157.5))*$sphereRadius*(1.0 + $sphereLayerThickness) };
outerTopArcZ1Pos #calc "$outerTopArcX1*$tanAlpha"; outerTopArcZ1Pos #eval{ $outerTopArcX1*$tanAlpha };
outerTopArcZ1Neg #calc "-1.0*$outerTopArcZ1Pos"; outerTopArcZ1Neg #eval{ -1.0*$outerTopArcZ1Pos };
outerTopLayerX #calc "cos(135.0*$pi/180.0)*(1.0 + $sphereLayerThickness)*$sphereRadius"; outerTopLayerX #eval{ cos(degToRad(135.0))*(1.0 + $sphereLayerThickness)*$sphereRadius };
outerTopLayerY #calc "$sphereCentreHeight - cos(135.0*$pi/180.0)*(1.0 + $sphereLayerThickness)*$sphereRadius"; outerTopLayerY #eval{ $sphereCentreHeight - cos(degToRad(135.0))*(1.0 + $sphereLayerThickness)*$sphereRadius };
outerTopLayerZPos #calc "-1.0*$tanAlpha*$outerTopLayerX"; outerTopLayerZPos #eval{ -1.0*$tanAlpha*$outerTopLayerX };
outerTopLayerZNeg #calc "-1.0*$outerTopLayerZPos"; outerTopLayerZNeg #eval{ -1.0*$outerTopLayerZPos };
// Layer block left of sphere // Layer block left of sphere
innerLeftArcX #calc "-1.0*$sphereRadius"; innerLeftArcX #eval{ -1.0*$sphereRadius };
innerLeftArcY #calc "$sphereCentreHeight"; innerLeftArcY #eval{ $sphereCentreHeight };
innerLeftArcZPos #calc "-1.0*$tanAlpha*$innerLeftArcX"; innerLeftArcZPos #eval{ -1.0*$tanAlpha*$innerLeftArcX };
innerLeftArcZNeg #calc "-1.0*$innerLeftArcZPos"; innerLeftArcZNeg #eval{ -1.0*$innerLeftArcZPos };
outerLeftArcX #calc "-1.0*(1.0 + $sphereLayerThickness)*$sphereRadius";
outerLeftArcZPos #calc "-1.0*$tanAlpha*$outerLeftArcX";
outerLeftArcZNeg #calc "-1.0*$outerLeftArcZPos";
outerLeftArcX #eval{ -1.0*(1.0 + $sphereLayerThickness)*$sphereRadius };
outerLeftArcZPos #eval{ -1.0*$tanAlpha*$outerLeftArcX };
outerLeftArcZNeg #eval{ -1.0*$outerLeftArcZPos };
vertices vertices
@ -159,9 +155,10 @@ vertices
edgeNumber 1; // 0.707; edgeNumber 1; // 0.707;
layerGrading 0.5; layerGrading 0.5;
invLayerGrading #calc "1.0/$layerGrading"; invLayerGrading #eval{ 1.0/$layerGrading };
blockGrading 0.3; blockGrading 0.3;
invBlockGrading #calc "1.0/$blockGrading"; invBlockGrading #eval{ 1.0/$blockGrading };
blocks blocks
( (

View File

@ -47,7 +47,7 @@ rigidBodyMotionCoeffs
rho 500; rho 500;
// Cuboid mass // Cuboid mass
mass #calc "$rho*$Lx*$Ly*$Lz"; mass #eval{ $rho*$Lx*$Ly*$Lz };
L ($Lx $Ly $Lz); L ($Lx $Ly $Lz);
centreOfMass (0 0 0.25); centreOfMass (0 0 0.25);
transform (1 0 0 0 1 0 0 0 1) (0.5 0.45 0.1); transform (1 0 0 0 1 0 0 0 1) (0.5 0.45 0.1);

View File

@ -37,7 +37,7 @@ sixDoFRigidBodyMotionCoeffs
rhoSolid 500; rhoSolid 500;
// Cuboid mass // Cuboid mass
mass #calc "$rhoSolid*$Lx*$Ly*$Lz"; mass #eval{ $rhoSolid*$Lx*$Ly*$Lz };
// Cuboid moment of inertia about the centre of mass // Cuboid moment of inertia about the centre of mass
momentOfInertia #codeStream momentOfInertia #codeStream

View File

@ -38,7 +38,7 @@ sixDoFRigidBodyMotionCoeffs
rhoSolid 700; rhoSolid 700;
// Cuboid mass // Cuboid mass
mass #calc "$rhoSolid*$Lx*$Ly*$Lz"; mass #eval{ $rhoSolid*$Lx*$Ly*$Lz };
// Cuboid moment of inertia about the centre of mass // Cuboid moment of inertia about the centre of mass
momentOfInertia #codeStream momentOfInertia #codeStream

View File

@ -14,8 +14,6 @@ FoamFile
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dynamicFvMesh dynamicOversetFvMesh; dynamicFvMesh dynamicOversetFvMesh;
solvers solvers
@ -55,7 +53,7 @@ solvers
rhoSolid 500; rhoSolid 500;
// Cuboid mass // Cuboid mass
mass #calc "$rhoSolid*$Lx*$Ly*$Lz"; mass #eval{ $rhoSolid*$Lx*$Ly*$Lz };
// Cuboid moment of inertia about the centre of mass // Cuboid moment of inertia about the centre of mass
momentOfInertia #codeStream momentOfInertia #codeStream

View File

@ -14,12 +14,12 @@ FoamFile
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
scale 1; scale 1;
L 0.125664;// "20*M_PI"; L 0.125664;
H #calc "1"; H 1.0;
H2 #calc "2*$H"; H2 #eval{ 2*$H };
W #calc "M_PI"; W #eval{ pi() };
vertices vertices
( (

View File

@ -48,7 +48,7 @@ runTimeModifiable false;
adjustTimeStep false; adjustTimeStep false;
// Allow 10% run-up before calculating mean // Allow 10% run-up before calculating mean
timeStart #calc #{ 0.1 * ${/endTime} #}; timeStart #eval #{ 0.1 * ${/endTime} #};
functions functions
{ {