tutorials: Updates to #codeStream and #calc examples

Simplifications have been made where possible, as permitted by the new
$<type>var syntax. Duplication has been reduced in similar blockMesh
files (e.g., sloshingTank cases). Settings that cannot practically be
changed have been hard-coded (e.g., angle in the mixerVessel2D
blockMeshDict). The rotor2D blockMeshDict has been centralised and
extended to work with an arbitrary number of rotor blades.
This commit is contained in:
Will Bainbridge
2023-06-23 08:49:43 +01:00
parent 24995dcbd4
commit 33eb61406b
42 changed files with 587 additions and 864 deletions

View File

@ -17,23 +17,11 @@ speed 250;
angleOfAttack 0; // degs
angle #calc "degToRad($angleOfAttack)";
liftDir #codeStream
{
codeInclude #{ #include "vector.H" #};
code #{ os << vector(-::sin($angle), 0, ::cos($angle)); #};
};
dragDir #codeStream
{
codeInclude #{ #include "vector.H" #};
code #{ os << vector(::cos($angle), 0, ::sin($angle)); #};
};
liftDir #calc "vector(-::sin($angle), 0, ::cos($angle))";
dragDir #calc "vector(::cos($angle), 0, ::sin($angle))";
Uinlet #codeStream
{
codeInclude #{ #include "vector.H" #};
code #{ os << $speed*vector(::cos($angle), 0, ::sin($angle)); #};
};
Uinlet #calc "$speed*$<vector>dragDir";
dimensions [0 1 -1 0 0 0 0];

View File

@ -26,7 +26,7 @@ baffles
surface searchableCylinder;
point1 (0 0 -100);
point2 (0 0 100);
radius $rotorRegion;
radius $rMid;
owner
{

View File

@ -25,18 +25,18 @@ baffles
surface searchableCylinder;
point1 (0 0 -100);
point2 (0 0 100);
radius $rotorRegion;
radius $rMid;
owner
{
name nonCouple1;
type patch;
name nonCouple1;
type patch;
}
neighbour
{
name nonCouple2;
type patch;
name nonCouple2;
type patch;
}
}
}

View File

@ -9,6 +9,7 @@ FoamFile
{
format ascii;
class volVectorField;
location "0";
object U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -19,6 +20,8 @@ internalField uniform (1 0 0);
boundaryField
{
#includeEtc "caseDicts/setConstraintTypes"
rotor
{
type movingWallVelocity;
@ -30,16 +33,6 @@ boundaryField
type freestreamVelocity;
freestreamValue $internalField;
}
front
{
type empty;
}
back
{
type empty;
}
}
// ************************************************************************* //

View File

@ -20,6 +20,8 @@ internalField uniform 3.75e-4;
boundaryField
{
#includeEtc "caseDicts/setConstraintTypes"
rotor
{
type epsilonWallFunction;
@ -31,16 +33,6 @@ boundaryField
type inletOutlet;
inletValue uniform 3.75e-4;
}
front
{
type empty;
}
back
{
type empty;
}
}

View File

@ -20,6 +20,8 @@ internalField uniform 3.75e-3;
boundaryField
{
#includeEtc "caseDicts/setConstraintTypes"
rotor
{
type kqRWallFunction;
@ -31,16 +33,6 @@ boundaryField
type inletOutlet;
inletValue uniform 3.75e-3;
}
front
{
type empty;
}
back
{
type empty;
}
}

View File

@ -20,6 +20,8 @@ internalField uniform 0;
boundaryField
{
#includeEtc "caseDicts/setConstraintTypes"
rotor
{
type nutkWallFunction;
@ -31,16 +33,6 @@ boundaryField
type calculated;
value uniform 0;
}
front
{
type empty;
}
back
{
type empty;
}
}

View File

@ -9,6 +9,7 @@ FoamFile
{
format ascii;
class volScalarField;
location "0";
object p;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -19,6 +20,8 @@ internalField uniform 0;
boundaryField
{
#includeEtc "caseDicts/setConstraintTypes"
rotor
{
type zeroGradient;
@ -29,16 +32,6 @@ boundaryField
type freestreamPressure;
freestreamValue $internalField;
}
front
{
type empty;
}
back
{
type empty;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,30 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: dev
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
nBlades 4;
rHub 0.005;
rTip 0.02;
rFreestream 0.1;
halfDepth 0.005;
nCellsHubTip 6;
nCellsTipFreestream 24;
nCellsBladeBlade 24;
#include "$FOAM_TUTORIALS/resources/blockMesh/rotor2D"
// ************************************************************************* //

View File

@ -1,185 +0,0 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: dev
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
convertToMeters 1.0;
hub 0.005;
rotorBlades 0.02;
freestream 0.1;
halfDepth 0.005;
angle 90;
nRadialRotorCells 6;
nRadialOuterCells 24;
nCircCells 24;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
vertices #codeStream
{
codeInclude
#{
#include "pointField.H"
#include "transformField.H"
#};
code
#{
const pointField initPoints
({
point(-$freestream, 0, -$halfDepth),
point(-$rotorBlades, 0, -$halfDepth),
point(-$hub, 0, -$halfDepth),
point(-$hub, 0, -$halfDepth),
});
pointField points;
// Rotate points around z-axis and append
for (label i = 0; i < 4; i++)
{
points.append(transform(Rz(degToRad(i*$angle)), initPoints));
}
// Duplicate z points
points.append(points + vector(0, 0, 2*$halfDepth));
os << points;
#};
};
rotorBlock all ($nCircCells $nRadialRotorCells 1) simpleGrading (1 1 1);
outerBlock all ($nCircCells $nRadialOuterCells 1) simpleGrading (1 1 1);
blocks
(
hex (6 2 1 5 22 18 17 21) $rotorBlock
hex (10 7 5 9 26 23 21 25) $rotorBlock
hex (14 11 9 13 30 27 25 29) $rotorBlock
hex (3 15 13 1 19 31 29 17) $rotorBlock
hex (5 1 0 4 21 17 16 20) $outerBlock
hex (9 5 4 8 25 21 20 24) $outerBlock
hex (13 9 8 12 29 25 24 28) $outerBlock
hex (1 13 12 0 17 29 28 16) $outerBlock
);
circle $angle (0 0 1);
edges
(
arc 2 6 $circle
arc 7 10 $circle
arc 11 14 $circle
arc 15 3 $circle
arc 18 22 $circle
arc 23 26 $circle
arc 27 30 $circle
arc 31 19 $circle
arc 1 5 $circle
arc 5 9 $circle
arc 9 13 $circle
arc 13 1 $circle
arc 17 21 $circle
arc 21 25 $circle
arc 25 29 $circle
arc 29 17 $circle
arc 0 4 $circle
arc 4 8 $circle
arc 8 12 $circle
arc 12 0 $circle
arc 16 20 $circle
arc 20 24 $circle
arc 24 28 $circle
arc 28 16 $circle
);
defaultPatch
{
name walls;
type wall;
}
boundary
(
rotor
{
type wall;
faces
(
(2 18 22 6)
(7 23 26 10)
(11 27 30 14)
(15 31 19 3)
(1 17 18 2)
(17 1 3 19)
(5 21 22 6)
(21 5 7 23)
(26 10 9 25)
(11 27 25 9)
(30 14 13 29)
(29 13 15 31)
);
}
freestream
{
type patch;
faces
(
(16 0 4 20)
(20 4 8 24)
(24 8 12 28)
(28 12 0 16)
);
}
front
{
type empty;
faces
(
(17 21 22 18)
(21 25 26 23)
(25 29 30 27)
(29 17 19 31)
(16 20 21 17)
(20 24 25 21)
(25 24 28 29)
(29 28 16 17)
);
}
back
{
type empty;
faces
(
(5 1 2 6)
(5 7 10 9)
(9 11 14 13)
(15 3 1 13)
(0 1 5 4)
(4 5 9 8)
(8 9 13 12)
(12 13 1 0)
);
}
);
// ************************************************************************* //

View File

@ -9,6 +9,7 @@ FoamFile
{
format ascii;
class volVectorField;
location "0";
object U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -19,6 +20,8 @@ internalField uniform (1 0 0);
boundaryField
{
#includeEtc "caseDicts/setConstraintTypes"
rotor
{
type MRFnoSlip;
@ -30,16 +33,6 @@ boundaryField
freestreamValue0 (1 0 0);
freestreamValue $internalField;
}
front
{
type empty;
}
back
{
type empty;
}
}
// ************************************************************************* //

View File

@ -20,6 +20,8 @@ internalField uniform 3.75e-4;
boundaryField
{
#includeEtc "caseDicts/setConstraintTypes"
rotor
{
type epsilonWallFunction;
@ -31,16 +33,6 @@ boundaryField
type inletOutlet;
inletValue uniform 3.75e-4;
}
front
{
type empty;
}
back
{
type empty;
}
}

View File

@ -20,6 +20,8 @@ internalField uniform 3.75e-3;
boundaryField
{
#includeEtc "caseDicts/setConstraintTypes"
rotor
{
type kqRWallFunction;
@ -31,16 +33,6 @@ boundaryField
type inletOutlet;
inletValue uniform 3.75e-3;
}
front
{
type empty;
}
back
{
type empty;
}
}

View File

@ -20,6 +20,8 @@ internalField uniform 0;
boundaryField
{
#includeEtc "caseDicts/setConstraintTypes"
rotor
{
type nutkWallFunction;
@ -31,16 +33,6 @@ boundaryField
type calculated;
value uniform 0;
}
front
{
type empty;
}
back
{
type empty;
}
}

View File

@ -9,6 +9,7 @@ FoamFile
{
format ascii;
class volScalarField;
location "0";
object p;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -19,6 +20,8 @@ internalField uniform 0;
boundaryField
{
#includeEtc "caseDicts/setConstraintTypes"
rotor
{
type zeroGradient;
@ -29,16 +32,6 @@ boundaryField
type freestreamPressure;
freestreamValue $internalField;
}
front
{
type empty;
}
back
{
type empty;
}
}
// ************************************************************************* //

View File

@ -13,173 +13,18 @@ FoamFile
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
convertToMeters 1.0;
nBlades 4;
hub 0.005;
rotorBlades 0.02;
freestream 0.1;
halfDepth 0.005;
angle 90;
rHub 0.005;
rTip 0.02;
rFreestream 0.1;
nRadialRotorCells 6;
nRadialOuterCells 24;
nCircCells 24;
halfDepth 0.005;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
nCellsHubTip 6;
nCellsTipFreestream 24;
nCellsBladeBlade 24;
vertices #codeStream
{
codeInclude
#{
#include "pointField.H"
#include "transformField.H"
#};
code
#{
const pointField initPoints
({
point(-$freestream, 0, -$halfDepth),
point(-$rotorBlades, 0, -$halfDepth),
point(-$hub, 0, -$halfDepth),
point(-$hub, 0, -$halfDepth),
});
pointField points;
// Rotate points around z-axis and append
for (label i = 0; i < 4; i++)
{
points.append(transform(Rz(degToRad(i*$angle)), initPoints));
}
// Duplicate z points
points.append(points + vector(0, 0, 2*$halfDepth));
os << points;
#};
};
rotorBlock ($nCircCells $nRadialRotorCells 1) simpleGrading (1 1 1);
outerBlock ($nCircCells $nRadialOuterCells 1) simpleGrading (1 1 1);
blocks
(
hex (6 2 1 5 22 18 17 21) $rotorBlock
hex (10 7 5 9 26 23 21 25) $rotorBlock
hex (14 11 9 13 30 27 25 29) $rotorBlock
hex (3 15 13 1 19 31 29 17) $rotorBlock
hex (5 1 0 4 21 17 16 20) $outerBlock
hex (9 5 4 8 25 21 20 24) $outerBlock
hex (13 9 8 12 29 25 24 28) $outerBlock
hex (1 13 12 0 17 29 28 16) $outerBlock
);
circle $angle (0 0 1);
edges
(
arc 2 6 $circle
arc 7 10 $circle
arc 11 14 $circle
arc 15 3 $circle
arc 18 22 $circle
arc 23 26 $circle
arc 27 30 $circle
arc 31 19 $circle
arc 1 5 $circle
arc 5 9 $circle
arc 9 13 $circle
arc 13 1 $circle
arc 17 21 $circle
arc 21 25 $circle
arc 25 29 $circle
arc 29 17 $circle
arc 0 4 $circle
arc 4 8 $circle
arc 8 12 $circle
arc 12 0 $circle
arc 16 20 $circle
arc 20 24 $circle
arc 24 28 $circle
arc 28 16 $circle
);
defaultPatch
{
name walls;
type wall;
}
boundary
(
rotor
{
type wall;
faces
(
(2 18 22 6)
(7 23 26 10)
(11 27 30 14)
(15 31 19 3)
(1 17 18 2)
(17 1 3 19)
(5 21 22 6)
(21 5 7 23)
(26 10 9 25)
(11 27 25 9)
(30 14 13 29)
(29 13 15 31)
);
}
freestream
{
type patch;
faces
(
(16 0 4 20)
(20 4 8 24)
(24 8 12 28)
(28 12 0 16)
);
}
front
{
type empty;
faces
(
(17 21 22 18)
(21 25 26 23)
(25 29 30 27)
(29 17 19 31)
(16 20 21 17)
(20 24 25 21)
(25 24 28 29)
(29 28 16 17)
);
}
back
{
type empty;
faces
(
(5 1 2 6)
(5 7 10 9)
(9 11 14 13)
(15 3 1 13)
(0 1 5 4)
(4 5 9 8)
(8 9 13 12)
(12 13 1 0)
);
}
);
#include "$FOAM_TUTORIALS/resources/blockMesh/rotor2D"
// ************************************************************************* //

View File

@ -40,16 +40,13 @@ mover
parent root;
// Cuboid dimensions
Lx 0.3;
Ly 0.2;
Lz 0.5;
L (0.3 0.2 0.5);
// Density of the cuboid
rho 500;
// Cuboid mass
mass #calc "$rho*$Lx*$Ly*$Lz";
L ($Lx $Ly $Lz);
mass #calc "$rho*cmptProduct($<vector>L)";
centreOfMass (0 0 0.25);
transform (1 0 0 0 1 0 0 0 1) (0.5 0.45 0.1);

View File

@ -30,34 +30,16 @@ mover
centreOfMass (0.5 0.45 0.35);
// Cuboid dimensions
Lx 0.3;
Ly 0.2;
Lz 0.5;
L (0.3 0.2 0.5);
// Density of the solid
rhoSolid 500;
// Cuboid mass
mass #calc "$rhoSolid*$Lx*$Ly*$Lz";
mass #calc "$rhoSolid*cmptProduct($<vector>L)";
// Cuboid moment of inertia about the centre of mass
momentOfInertia #codeStream
{
codeInclude
#{
#include "diagTensor.H"
#};
code
#{
scalar sqrLx = sqr($Lx);
scalar sqrLy = sqr($Ly);
scalar sqrLz = sqr($Lz);
os <<
$mass
*diagTensor(sqrLy + sqrLz, sqrLx + sqrLz, sqrLx + sqrLy)/12.0;
#};
};
momentOfInertia #calc "$mass*(tensor::one-tensor::I)&cmptSqr($<vector>L)/12";
report on;
accelerationRelaxation 0.7;

View File

@ -40,16 +40,13 @@ mover
parent root;
// Cuboid dimensions
Lx 0.3;
Ly 0.2;
Lz 0.5;
L (0.3 0.2 0.5);
// Density of the cuboid
rho 500;
// Cuboid mass
mass #calc "$rho*$Lx*$Ly*$Lz";
L ($Lx $Ly $Lz);
mass #calc "$rho*cmptProduct($<vector>L)";
centreOfMass (0 0 0.25);
transform (1 0 0 0 1 0 0 0 1) (0.5 0.45 0.1);

View File

@ -30,34 +30,16 @@ mover
centreOfMass (0.5 0.45 0.35);
// Cuboid dimensions
Lx 0.3;
Ly 0.2;
Lz 0.5;
L (0.3 0.2 0.5);
// Density of the solid
rhoSolid 500;
// Cuboid mass
mass #calc "$rhoSolid*$Lx*$Ly*$Lz";
mass #calc "$rhoSolid*cmptProduct($<vector>L)";
// Cuboid moment of inertia about the centre of mass
momentOfInertia #codeStream
{
codeInclude
#{
#include "diagTensor.H"
#};
code
#{
scalar sqrLx = sqr($Lx);
scalar sqrLy = sqr($Ly);
scalar sqrLz = sqr($Lz);
os <<
$mass
*diagTensor(sqrLy + sqrLz, sqrLx + sqrLz, sqrLx + sqrLy)/12.0;
#};
};
momentOfInertia #calc "$mass*(tensor::one-tensor::I)&cmptSqr($<vector>L)/12";
report on;
accelerationRelaxation 0.7;

View File

@ -25,7 +25,7 @@ baffles
surface searchableCylinder;
point1 (0 0 -100);
point2 (0 0 100);
radius $rotorRegion;
radius $rMid;
owner
{

View File

@ -19,7 +19,7 @@ internalField uniform (0 0 0);
boundaryField
{
walls
wall
{
type movingWallVelocity;
value uniform (0 0 0);

View File

@ -19,7 +19,7 @@ internalField uniform 0;
boundaryField
{
walls
wall
{
type zeroGradient;
}

View File

@ -19,7 +19,7 @@ internalField uniform 0;
boundaryField
{
walls
wall
{
type fixedFluxPressure;
}

View File

@ -19,7 +19,7 @@ internalField uniform (0 0 0);
boundaryField
{
walls
wall
{
type movingWallVelocity;
value uniform (0 0 0);

View File

@ -19,7 +19,7 @@ internalField uniform 0;
boundaryField
{
walls
wall
{
type zeroGradient;
}

View File

@ -19,7 +19,7 @@ internalField uniform 0;
boundaryField
{
walls
wall
{
type fixedFluxPressure;
}

View File

@ -19,7 +19,7 @@ internalField uniform (0 0 0);
boundaryField
{
walls
wall
{
type movingWallVelocity;
value uniform (0 0 0);

View File

@ -19,7 +19,7 @@ internalField uniform 0;
boundaryField
{
walls
wall
{
type zeroGradient;
}

View File

@ -19,7 +19,7 @@ internalField uniform 0;
boundaryField
{
walls
wall
{
type fixedFluxPressure;
}

View File

@ -25,7 +25,7 @@ baffles
surface searchableCylinder;
point1 (0 0 -100);
point2 (0 0 100);
radius $rotorRegion;
radius $rMid;
owner
{

View File

@ -13,19 +13,19 @@ FoamFile
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
convertToMeters 1.0;
convertToMeters 1.0;
hub 0.02;
rotorBlades 0.05;
rotorRegion 0.06;
statorBlades 0.07;
stator 0.1;
halfDepth 0.005;
angle 45;
rHub 0.02; // Radius of the rotor hub
rRotorTip 0.05; // Radius of the rotor blade tips
rMid 0.06; // Radius of the midpoint between rotor and stator
rStatorTip 0.07; // Radius of the stator blade tips
rVessel 0.1; // Radius of the outer vessel wall
nRadialEndsCells 12;
nRadialMidsCells 4;
nCircCells 12;
halfDepth 0.005; // Half-depth of the 2-D slab
nCellsRootTip 12; // Number of cells radially along the blades
nCellsMid 4; // Number of cells radially across the mid section (/2)
nCellsBladeBlade 12; // Number of cells tangentially between blades (/2)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -39,166 +39,162 @@ vertices #codeStream
code
#{
const pointField initPoints
const pointField points0
({
point(-$stator, 0, -$halfDepth),
point(-$stator, 0, -$halfDepth),
point(-$statorBlades, 0, -$halfDepth),
point(-$rotorRegion, 0, -$halfDepth),
point(-$rotorBlades, 0, -$halfDepth),
point(-$hub, 0, -$halfDepth),
point(-$hub, 0, -$halfDepth),
point(-$rVessel, 0, -$halfDepth),
point(-$rVessel, 0, -$halfDepth),
point(-$rStatorTip, 0, -$halfDepth),
point(-$rMid, 0, -$halfDepth),
point(-$rRotorTip, 0, -$halfDepth),
point(-$rHub, 0, -$halfDepth),
point(-$rHub, 0, -$halfDepth),
});
pointField points;
// Rotate points around z-axis and append
for (label i = 0; i < 8; i++)
{
points.append(transform(Rz(degToRad(i*$angle)), initPoints));
points.append(transform(Rz(degToRad(i*45)), points0));
}
// Duplicate z points
points.append(points + vector(0, 0, 2*$halfDepth));
os << points;
#};
};
hubTankBlocks ($nCircCells $nRadialEndsCells 1) simpleGrading (1 1 1);
middleBocks ($nCircCells $nRadialMidsCells 1) simpleGrading (1 1 1);
bladeBlock ($nCellsBladeBlade $nCellsRootTip 1) simpleGrading (1 1 1);
midBlock ($nCellsBladeBlade $nCellsMid 1) simpleGrading (1 1 1);
blocks
(
hex (0 8 9 2 56 64 65 58) stator $hubTankBlocks
hex (2 9 10 3 58 65 66 59) stator $middleBocks
hex (3 10 11 4 59 66 67 60) rotor $middleBocks
hex (4 11 12 5 60 67 68 61) rotor $hubTankBlocks
hex (0 8 9 2 56 64 65 58) stator $bladeBlock
hex (2 9 10 3 58 65 66 59) stator $midBlock
hex (3 10 11 4 59 66 67 60) rotor $midBlock
hex (4 11 12 5 60 67 68 61) rotor $bladeBlock
hex (7 14 16 9 63 70 72 65) stator $hubTankBlocks
hex (9 16 17 10 65 72 73 66) stator $middleBocks
hex (10 17 18 11 66 73 74 67) rotor $middleBocks
hex (11 18 20 12 67 74 76 68) rotor $hubTankBlocks
hex (7 14 16 9 63 70 72 65) stator $bladeBlock
hex (9 16 17 10 65 72 73 66) stator $midBlock
hex (10 17 18 11 66 73 74 67) rotor $midBlock
hex (11 18 20 12 67 74 76 68) rotor $bladeBlock
hex (14 22 23 16 70 78 79 72) stator $hubTankBlocks
hex (16 23 24 17 72 79 80 73) stator $middleBocks
hex (17 24 25 18 73 80 81 74) rotor $middleBocks
hex (18 25 26 19 74 81 82 75) rotor $hubTankBlocks
hex (14 22 23 16 70 78 79 72) stator $bladeBlock
hex (16 23 24 17 72 79 80 73) stator $midBlock
hex (17 24 25 18 73 80 81 74) rotor $midBlock
hex (18 25 26 19 74 81 82 75) rotor $bladeBlock
hex (21 28 30 23 77 84 86 79) stator $hubTankBlocks
hex (23 30 31 24 79 86 87 80) stator $middleBocks
hex (24 31 32 25 80 87 88 81) rotor $middleBocks
hex (25 32 34 26 81 88 90 82) rotor $hubTankBlocks
hex (21 28 30 23 77 84 86 79) stator $bladeBlock
hex (23 30 31 24 79 86 87 80) stator $midBlock
hex (24 31 32 25 80 87 88 81) rotor $midBlock
hex (25 32 34 26 81 88 90 82) rotor $bladeBlock
hex (28 36 37 30 84 92 93 86) stator $hubTankBlocks
hex (30 37 38 31 86 93 94 87) stator $middleBocks
hex (31 38 39 32 87 94 95 88) rotor $middleBocks
hex (32 39 40 33 88 95 96 89) rotor $hubTankBlocks
hex (28 36 37 30 84 92 93 86) stator $bladeBlock
hex (30 37 38 31 86 93 94 87) stator $midBlock
hex (31 38 39 32 87 94 95 88) rotor $midBlock
hex (32 39 40 33 88 95 96 89) rotor $bladeBlock
hex (35 42 44 37 91 98 100 93) stator $hubTankBlocks
hex (37 44 45 38 93 100 101 94) stator $middleBocks
hex (38 45 46 39 94 101 102 95) rotor $middleBocks
hex (39 46 48 40 95 102 104 96) rotor $hubTankBlocks
hex (35 42 44 37 91 98 100 93) stator $bladeBlock
hex (37 44 45 38 93 100 101 94) stator $midBlock
hex (38 45 46 39 94 101 102 95) rotor $midBlock
hex (39 46 48 40 95 102 104 96) rotor $bladeBlock
hex (42 50 51 44 98 106 107 100) stator $hubTankBlocks
hex (44 51 52 45 100 107 108 101) stator $middleBocks
hex (45 52 53 46 101 108 109 102) rotor $middleBocks
hex (46 53 54 47 102 109 110 103) rotor $hubTankBlocks
hex (42 50 51 44 98 106 107 100) stator $bladeBlock
hex (44 51 52 45 100 107 108 101) stator $midBlock
hex (45 52 53 46 101 108 109 102) rotor $midBlock
hex (46 53 54 47 102 109 110 103) rotor $bladeBlock
hex (49 0 2 51 105 56 58 107) stator $hubTankBlocks
hex (51 2 3 52 107 58 59 108) stator $middleBocks
hex (52 3 4 53 108 59 60 109) rotor $middleBocks
hex (53 4 6 54 109 60 62 110) rotor $hubTankBlocks
hex (49 0 2 51 105 56 58 107) stator $bladeBlock
hex (51 2 3 52 107 58 59 108) stator $midBlock
hex (52 3 4 53 108 59 60 109) rotor $midBlock
hex (53 4 6 54 109 60 62 110) rotor $bladeBlock
);
circle $angle (0 0 1);
arc 45 (0 0 1);
edges
(
arc 0 8 $circle
arc 7 14 $circle
arc 14 22 $circle
arc 21 28 $circle
arc 28 36 $circle
arc 35 42 $circle
arc 42 50 $circle
arc 49 0 $circle
arc 56 64 $circle
arc 63 70 $circle
arc 70 78 $circle
arc 77 84 $circle
arc 84 92 $circle
arc 91 98 $circle
arc 98 106 $circle
arc 105 56 $circle
arc 0 8 $arc
arc 7 14 $arc
arc 14 22 $arc
arc 21 28 $arc
arc 28 36 $arc
arc 35 42 $arc
arc 42 50 $arc
arc 49 0 $arc
arc 56 64 $arc
arc 63 70 $arc
arc 70 78 $arc
arc 77 84 $arc
arc 84 92 $arc
arc 91 98 $arc
arc 98 106 $arc
arc 105 56 $arc
arc 2 9 $circle
arc 9 16 $circle
arc 16 23 $circle
arc 23 30 $circle
arc 30 37 $circle
arc 37 44 $circle
arc 44 51 $circle
arc 51 2 $circle
arc 58 65 $circle
arc 65 72 $circle
arc 72 79 $circle
arc 79 86 $circle
arc 86 93 $circle
arc 93 100 $circle
arc 100 107 $circle
arc 107 58 $circle
arc 2 9 $arc
arc 9 16 $arc
arc 16 23 $arc
arc 23 30 $arc
arc 30 37 $arc
arc 37 44 $arc
arc 44 51 $arc
arc 51 2 $arc
arc 58 65 $arc
arc 65 72 $arc
arc 72 79 $arc
arc 79 86 $arc
arc 86 93 $arc
arc 93 100 $arc
arc 100 107 $arc
arc 107 58 $arc
arc 3 10 $circle
arc 10 17 $circle
arc 17 24 $circle
arc 24 31 $circle
arc 31 38 $circle
arc 38 45 $circle
arc 45 52 $circle
arc 52 3 $circle
arc 59 66 $circle
arc 66 73 $circle
arc 73 80 $circle
arc 80 87 $circle
arc 87 94 $circle
arc 94 101 $circle
arc 101 108 $circle
arc 108 59 $circle
arc 3 10 $arc
arc 10 17 $arc
arc 17 24 $arc
arc 24 31 $arc
arc 31 38 $arc
arc 38 45 $arc
arc 45 52 $arc
arc 52 3 $arc
arc 59 66 $arc
arc 66 73 $arc
arc 73 80 $arc
arc 80 87 $arc
arc 87 94 $arc
arc 94 101 $arc
arc 101 108 $arc
arc 108 59 $arc
arc 4 11 $circle
arc 11 18 $circle
arc 18 25 $circle
arc 25 32 $circle
arc 32 39 $circle
arc 39 46 $circle
arc 46 53 $circle
arc 53 4 $circle
arc 60 67 $circle
arc 67 74 $circle
arc 74 81 $circle
arc 81 88 $circle
arc 88 95 $circle
arc 95 102 $circle
arc 102 109 $circle
arc 109 60 $circle
arc 4 11 $arc
arc 11 18 $arc
arc 18 25 $arc
arc 25 32 $arc
arc 32 39 $arc
arc 39 46 $arc
arc 46 53 $arc
arc 53 4 $arc
arc 60 67 $arc
arc 67 74 $arc
arc 74 81 $arc
arc 81 88 $arc
arc 88 95 $arc
arc 95 102 $arc
arc 102 109 $arc
arc 109 60 $arc
arc 5 12 $circle
arc 12 20 $circle
arc 19 26 $circle
arc 26 34 $circle
arc 33 40 $circle
arc 40 48 $circle
arc 47 54 $circle
arc 54 6 $circle
arc 61 68 $circle
arc 68 76 $circle
arc 75 82 $circle
arc 82 90 $circle
arc 89 96 $circle
arc 96 104 $circle
arc 103 110 $circle
arc 110 62 $circle
arc 5 12 $arc
arc 12 20 $arc
arc 19 26 $arc
arc 26 34 $arc
arc 33 40 $arc
arc 40 48 $arc
arc 47 54 $arc
arc 54 6 $arc
arc 61 68 $arc
arc 68 76 $arc
arc 75 82 $arc
arc 82 90 $arc
arc 89 96 $arc
arc 96 104 $arc
arc 103 110 $arc
arc 110 62 $arc
);
defaultPatch

View File

@ -0,0 +1,224 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: dev
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// In the case system/blockMeshDict, set the following variables:
/*
nBlades 4; // Number of rotor blades
rHub 0.005; // Radius of the hub
rTip 0.02; // Radius of the blade tips
rFreestream 0.1; // Radius of the freestream boundary
halfDepth 0.005; // Half-depth of the 2-D slab
nCellsHubTip 6; // Number of cells radially from hub to blade tip
nCellsTipFreestream 24; // Number of cells radially from blade tip to the
// freestream boundary
nCellsBladeBlade 24; // Number of cells tangentially between blades
*/
// Then #include this file:
/*
#include "$FOAM_TUTORIALS/resources/blockMesh/rotor2D"
*/
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
vertices #codeStream
{
codeInclude
#{
#include "pointField.H"
#include "SubField.H"
#include "transformField.H"
#};
code
#{
// Get the radii. Note using $<scalar>rHub instead of $rHub means that
// rHub can change without needing to recompile this code. The same is
// true for access of other settings throughout this file.
const scalarField rs
({
$<scalar>rHub,
$<scalar>rHub,
$<scalar>rTip,
$<scalar>rFreestream
});
// Create points for the blade aligned with the X-axis
pointField points(4, point(0, 0, -$<scalar>halfDepth));
points.replace(0, -rs);
// Create equivalent points for other blades by rotating
for (label i = 1; i < $<label>nBlades; i ++)
{
points.append
(
transform
(
Rz(degToRad(i*360/scalar($<label>nBlades))),
SubField<point>(points, 4)
)
);
}
// Add the points on the other side of the slab
points.append(points + vector(0, 0, 2*$<scalar>halfDepth));
// Write out
os << points;
#};
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
blocks
(
#codeStream
{
codeInclude
#{
#include "labelField.H"
#};
code
#{
const label viN = 4*$<label>nBlades;
auto makeBlock = [&]
(
const label v0,
const label v1,
const label v2,
const label v3,
const label nCellsRadial
)
{
labelList vs({v0%viN, v1%viN, v2%viN, v3%viN});
vs.append(labelField(vs) + viN);
os << "hex " << vs << " all "
<< Vector<label>(nCellsRadial, $<label>nCellsBladeBlade, 1)
<< " simpleGrading " << Vector<label>(1, 1, 1) << nl;
};
for (label i = 0; i < $<label>nBlades; i ++)
{
const label vi0 = i*4;
makeBlock(vi0+1, vi0+2, vi0+6, vi0+4, $<label>nCellsHubTip);
makeBlock(vi0+2, vi0+3, vi0+7, vi0+6, $<label>nCellsTipFreestream);
}
#};
}
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
edges
(
#codeStream
{
code
#{
const label viN = 4*$<label>nBlades;
auto makeArc = [&](const label v0, const label v1)
{
for (label i = 0; i < 2; ++ i)
{
os << "arc " << v0%viN + i*viN << ' ' << v1%viN + i*viN << ' '
<< 360/scalar($<label>nBlades) << ' ' << vector(0, 0, 1) << nl;
}
};
for (label i = 0; i < $<label>nBlades; i ++)
{
const label vi0 = i*4;
makeArc(vi0+1, vi0+4);
makeArc(vi0+2, vi0+6);
makeArc(vi0+3, vi0+7);
}
#};
}
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
defaultPatch
{
name frontAndBack;
type empty;
}
boundary
(
rotor
{
type wall;
faces
(
#codeStream
{
code
#{
const label viN = 4*$<label>nBlades;
auto makeFace = [&](const label v0, const label v1)
{
os << labelList({v0%viN, v1%viN, v1%viN+viN, v0%viN+viN});
};
for (label i = 0; i < $<label>nBlades; i ++)
{
const label vi0 = i*4;
makeFace(vi0+2, vi0+1);
makeFace(vi0+1, vi0+4);
makeFace(vi0+4, vi0+6);
}
#};
}
);
}
freestream
{
type wall;
faces
(
#codeStream
{
code
#{
const label viN = 4*$<label>nBlades;
auto makeFace = [&](const label v0, const label v1)
{
os << labelList({v0%viN, v1%viN, v1%viN+viN, v0%viN+viN});
};
for (label i = 0; i < $<label>nBlades; i ++)
{
const label vi0 = i*4;
makeFace(vi0+3, vi0+7);
}
#};
}
);
}
);
// ************************************************************************* //

View File

@ -0,0 +1,127 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: dev
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
convertToMeters 1;
//depth ?; // Depth of tank (x-direction)
width 40; // Width of tank (y-direction)
height 30; // Depth of tank (z-direction)
lowerHeight 5; // Height to the top of lower chamfer
upperHeight 10; // Height of upper chamfer
angleLower 45; // Angle of lower chamfer to the horizontal
angleUpper 45; // Angle of upper chamfer to the horizontal
moveZ -10; // Moving tank in z direction
//xCells ?; // Number of cells in the depth
yCells 40; // Number of cells in the width
zLowCells 6; // Number of cells in the height of the lower chamfer
zMidCells 16; // Number of cells in the height between the chamfers
zUpCells 12; // Number of cells in the height of the upper chamfer
//frontAndBackPatchType ?; // Type of the front and back patch
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
vertices #codeStream
{
codeInclude
#{
#include "pointField.H"
#};
code
#{
const scalar halfDepth = ($depth)/2.0;
const scalar halfWidth = ($width)/2.0;
const scalar yBottom =
halfWidth - ($lowerHeight)/tan(degToRad($angleLower));
const scalar yTop =
halfWidth - ($upperHeight)/tan(degToRad($angleUpper));
const scalar zMid = $height - $upperHeight;
pointField points
({
point(-halfDepth, -yBottom, 0), // pt 0
point(-halfDepth, -halfWidth, $lowerHeight), // pt 1
point(-halfDepth, -halfWidth, zMid), // pt 2
point(-halfDepth, -yTop, $height), // pt 3
});
// Move points in z direction
points += vector(0, 0, $moveZ);
// Duplicate y points
points.append(cmptMultiply(points, vector(1, -1, 1)));
// Duplicate x points
points.append(cmptMultiply(points, vector(-1, 1, 1)));
os << points;
#};
};
blocks
(
hex (0 8 12 4 1 9 13 5) ($xCells $yCells $zLowCells) simpleGrading (1 1 1)
hex (1 9 13 5 2 10 14 6) ($xCells $yCells $zMidCells) simpleGrading (1 1 1)
hex (2 10 14 6 3 11 15 7) ($xCells $yCells $zUpCells) simpleGrading (1 1 1)
);
boundary
(
walls
{
type wall;
faces
(
(0 4 12 8)
(4 5 13 12)
(5 6 14 13)
(6 7 15 14)
(7 3 11 15)
(3 2 10 11)
(2 1 9 10)
(1 0 8 9)
);
}
front
{
type $frontAndBackPatchType;
faces
(
(8 12 13 9)
(9 13 14 10)
(10 14 15 11)
);
}
back
{
type $frontAndBackPatchType;
faces
(
(0 1 5 4)
(1 2 6 5)
(2 3 7 6)
);
}
);
// ************************************************************************* //

View File

@ -13,112 +13,12 @@ FoamFile
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
convertToMeters 1;
depth 1; // Depth of tank (x-direction)
depth 1; // Depth of tank (x-direction)
width 40; // Width of tank (y-direction)
height 30; // Depth of tank (z-direction)
xCells 1; // Number of cells in the depth
lowerHeight 5; // Height to the top of lower chamfer
upperHeight 10; // Height of upper chamfer
frontAndBackPatchType empty; // Type of the front and back patch
angleLower 45; // Angle of lower chamfer to the horizontal
angleUpper 45; // Angle of upper chamfer to the horizontal
moveZ -10; // Moving tank in z direction
xCells 1; // Number of cells in the depth
yCells 40; // Number of cells in the width
zLowCells 6; // Number of cells in the height of the lower champfer
zMidCells 16; // Number of cells in the height between the chamfers
zUpCells 12; // Number of cells in the height of the upper champfer
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
vertices #codeStream
{
codeInclude
#{
#include "pointField.H"
#};
code
#{
const scalar halfDepth = ($depth)/2.0;
const scalar halfWidth = ($width)/2.0;
const scalar yBottom =
halfWidth - ($lowerHeight)/tan(degToRad($angleLower));
const scalar yTop =
halfWidth - ($upperHeight)/tan(degToRad($angleUpper));
const scalar zMid = $height - $upperHeight;
pointField points
({
point(-halfDepth, -yBottom, 0), // pt 0
point(-halfDepth, -halfWidth, $lowerHeight), // pt 1
point(-halfDepth, -halfWidth, zMid), // pt 2
point(-halfDepth, -yTop, $height), // pt 3
});
// Move points in z direction
points += vector(0, 0, $moveZ);
// Duplicate y points
points.append(cmptMultiply(points, vector(1, -1, 1)));
// Duplicate x points
points.append(cmptMultiply(points, vector(-1, 1, 1)));
os << points;
#};
};
blocks
(
hex (0 8 12 4 1 9 13 5) ($xCells $yCells $zLowCells) simpleGrading (1 1 1)
hex (1 9 13 5 2 10 14 6) ($xCells $yCells $zMidCells) simpleGrading (1 1 1)
hex (2 10 14 6 3 11 15 7) ($xCells $yCells $zUpCells) simpleGrading (1 1 1)
);
boundary
(
walls
{
type wall;
faces
(
(0 4 12 8)
(4 5 13 12)
(5 6 14 13)
(6 7 15 14)
(7 3 11 15)
(3 2 10 11)
(2 1 9 10)
(1 0 8 9)
);
}
front
{
type empty;
faces
(
(8 12 13 9)
(9 13 14 10)
(10 14 15 11)
);
}
back
{
type empty;
faces
(
(0 1 5 4)
(1 2 6 5)
(2 3 7 6)
);
}
);
#include "sloshingTank"
// ************************************************************************* //

View File

@ -13,96 +13,12 @@ FoamFile
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
convertToMeters 1;
depth 20; // Depth of tank (x-direction)
depth 20; // Depth of tank (x-direction)
width 40; // Width of tank (y-direction)
height 30; // Depth of tank (z-direction)
xCells 19; // Number of cells in the depth
lowerHeight 5; // Height to the top of lower chamfer
upperHeight 10; // Height of upper chamfer
frontAndBackPatchType wall; // Type of the front and back patch
angleLower 45; // Angle of lower chamfer to the horizontal
angleUpper 45; // Angle of upper chamfer to the horizontal
moveZ -10; // Moving tank in z direction
xCells 19; // Number of cells in the depth
yCells 40; // Number of cells in the width
zLowCells 6; // Number of cells in the height of the lower champfer
zMidCells 16; // Number of cells in the height between the chamfers
zUpCells 12; // Number of cells in the height of the upper champfer
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
vertices #codeStream
{
codeInclude
#{
#include "pointField.H"
#};
code
#{
const scalar halfDepth = ($depth)/2.0;
const scalar halfWidth = ($width)/2.0;
const scalar yBottom =
halfWidth - ($lowerHeight)/tan(degToRad($angleLower));
const scalar yTop =
halfWidth - ($upperHeight)/tan(degToRad($angleUpper));
const scalar zMid = $height - $upperHeight;
pointField points
({
point(-halfDepth, -yBottom, 0), // pt 0
point(-halfDepth, -halfWidth, $lowerHeight), // pt 1
point(-halfDepth, -halfWidth, zMid), // pt 2
point(-halfDepth, -yTop, $height), // pt 3
});
// Move points in z direction
points += vector(0, 0, $moveZ);
// Duplicate y points
points.append(cmptMultiply(points, vector(1, -1, 1)));
// Duplicate x points
points.append(cmptMultiply(points, vector(-1, 1, 1)));
os << points;
#};
};
blocks
(
hex (0 8 12 4 1 9 13 5) ($xCells $yCells $zLowCells) simpleGrading (1 1 1)
hex (1 9 13 5 2 10 14 6) ($xCells $yCells $zMidCells) simpleGrading (1 1 1)
hex (2 10 14 6 3 11 15 7) ($xCells $yCells $zUpCells) simpleGrading (1 1 1)
);
boundary
(
walls
{
type wall;
faces
(
(0 4 12 8)
(4 5 13 12)
(5 6 14 13)
(6 7 15 14)
(7 3 11 15)
(3 2 10 11)
(2 1 9 10)
(1 0 8 9)
(8 12 13 9)
(9 13 14 10)
(10 14 15 11)
(0 1 5 4)
(1 2 6 5)
(2 3 7 6)
);
}
);
#include "sloshingTank"
// ************************************************************************* //