Skip to content

Instantly share code, notes, and snippets.

@Foadsf
Created August 21, 2018 21:21
Show Gist options
  • Save Foadsf/56eed7c3b5a24aa0665909aad1576813 to your computer and use it in GitHub Desktop.
Save Foadsf/56eed7c3b5a24aa0665909aad1576813 to your computer and use it in GitHub Desktop.
axisymmetric cylinder and piston for OpenFOAM
//following this: https://openfoamwiki.net/index.php/Main_ContribExamples/AxiSymmetric
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 5 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
root "";
case "";
instance "";
local "";
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
convertToMeters 0.001;
wa 5.0; // wedge angle must be 5 degrees
cr 10.0; // cylinder radius
pr 8.0; //piston radius
cl 50.0; // length of cylinder
px 20.0; // position of piston
pl 10.0; // length of piston
px2 #calc "$px+$pl"; // end of the piston
ms 50; //meshsize
vertices
(
(0 0 0) //00
(#calc "$pr*cos($wa/2)" #calc "$pr*sin($wa/2)" 0) //01
(#calc "$pr*cos($wa/2)" #calc "-$pr*sin($wa/2)" 0) //02
(#calc "$pr*cos($wa/2)" #calc "-$pr*sin($wa/2)" $px) //03
(#calc "$pr*cos($wa/2)" #calc "$pr*sin($wa/2)" $px) //04
(0 0 $px) //05
(#calc "$cr*cos($wa/2)" #calc "$cr*sin($wa/2)" $px) //06
(#calc "$cr*cos($wa/2)" #calc "$cr*sin($wa/2)" 0) //07
(#calc "$cr*cos($wa/2)" #calc "-$cr*sin($wa/2)" 0) //08
(#calc "$cr*cos($wa/2)" #calc "-$cr*sin($wa/2)" $px) //09
(#calc "$cr*cos($wa/2)" #calc "-$cr*sin($wa/2)" $px2) //10
(#calc "$cr*cos($wa/2)" #calc "$cr*sin($wa/2)" $px2) //11
(#calc "$pr*cos($wa/2)" #calc "$pr*sin($wa/2)" $px2) //12
(#calc "$pr*cos($wa/2)" #calc "-$pr*sin($wa/2)" $px2) //13
(#calc "$pr*cos($wa/2)" #calc "-$pr*sin($wa/2)" $cl) //14
(#calc "$pr*cos($wa/2)" #calc "$pr*sin($wa/2)" $cl) //15
(#calc "$cr*cos($wa/2)" #calc "$cr*sin($wa/2)" $cl) //16
(#calc "$cr*cos($wa/2)" #calc "-$cr*sin($wa/2)" $cl) //17
(0 0 $cl) //18
(0 0 $px2) //19
);
blocks
(
hex (0 1 2 0 5 4 3 5) ($ms 1 $ms) simpleGrading (1 1 1)
hex (1 7 8 2 1 4 6 9 3 4) ($ms 1 $ms) simpleGrading (1 1 1)
hex (4 6 9 3 4 12 11 10 13 12) ($ms 1 $ms) simpleGrading (1 1 1)
hex (12 11 10 13 12 15 16 17 14 15) ($ms 1 $ms) simpleGrading (1 1 1)
hex (19 12 13 19 18 15 14 18) ($ms 1 $ms) simpleGrading (1 1 1)
);
edges
(
);
boundary
(
inlet
{
type patch;
faces
(
(0 1 2 0)
(1 7 8 2)
);
}
outlet
{
type patch;
faces
(
(18 15 14 18)
(15 16 17 14)
);
}
walls
{
type wall;
faces
(
(7 8 9 6)
(6 9 10 11)
(11 10 17 16)
);
}
wedges
{
type wedge;
faces
(
(0 1 4 5)
(1 7 6 4)
(4 6 11 12)
(12 11 16 15)
(19 12 15 18)
(0 5 3 2)
(2 3 9 8)
(3 13 10 9)
(13 14 17 10)
(19 18 14 13)
);
}
axis
{
type empty;
faces
(
(0 5 5 0)
(19 18 18 19)
);
}
);
mergePatchPairs
(
);
// ************************************************************************* //
@Foadsf
Copy link
Author

Foadsf commented May 22, 2025

relevant discussions here and here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment