|
[Sponsors] | |||||
[blockMesh] Creating an axisymmetric piston cylinder in blockMeshDict |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|
|
#1 | |
|
Member
Foad
Join Date: Aug 2017
Posts: 59
Rep Power: 10 ![]() |
I'm trying to follow this tutorial to create an axisymmetric cylinder and piston in blockMeshDict and this is my blockMeshDict file:
Code:
/*--------------------------------*- 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
(
);
// ************************************************************************* //
However when I try to compile the mesh I get the infamous error message: Quote:
|
||
|
|
|
||
|
|
|
#2 |
|
Senior Member
anonymous
Join Date: Jan 2016
Posts: 416
Rep Power: 15 ![]() |
Hi!
Your patch definition is bad. --> FOAM FATAL ERROR: face 1 in patch 1 does not have neighbour cell face: 4(15 16 17 14) So in patch 1 (outlet), the face 1 (15 16 17 14) is not valid. But there are also some weird stuff going on. If you create a hex, how can you have 10 vertices for a hex??? Check your block and patch definitions! Maybe this can help you a bit: https://cfd.direct/openfoam/user-guide/v6-blockmesh/ |
|
|
|
|
|
|
|
|
#3 | |
|
Member
Foad
Join Date: Aug 2017
Posts: 59
Rep Power: 10 ![]() |
I changed the blocks section to:
Code:
blocks
(
hex (0 1 2 0 5 4 3 5) ($ms 1 $ms) simpleGrading (1 1 1)
hex (1 7 8 2 4 6 9 3) ($ms 1 $ms) simpleGrading (1 1 1)
hex (4 6 9 3 12 11 10 13) ($ms 1 $ms) simpleGrading (1 1 1)
hex (12 11 10 13 15 16 17 14) ($ms 1 $ms) simpleGrading (1 1 1)
hex (19 12 13 19 18 15 14 18) ($ms 1 $ms) simpleGrading (1 1 1)
);
Quote:
Also here you may see an image illustrating the points: New Doc 2018-08-21.pdf |
||
|
|
|
||
|
|
|
#4 |
|
Senior Member
anonymous
Join Date: Jan 2016
Posts: 416
Rep Power: 15 ![]() |
Sorry now i'm a bit lost. I do not really understand this error message, but there is some problem with the wedge patch.
Maybe try to split the wedge patch into 2 patches: wedgeFront and wedgeBack. I'm not sure if they can be in the same patch. If still not working, you can try with patchtype patch for the wegdes just to generate the mesh and at least you will see if your geometry is correct. (but it won't solve the problem since you will need a wedge type.) |
|
|
|
|
|
|
|
|
#5 |
|
Member
Foad
Join Date: Aug 2017
Posts: 59
Rep Power: 10 ![]() |
I will try splitting patches.
Have you seen any working examples of using blockMeshDict to create an axisymmetric model? |
|
|
|
|
|
|
|
|
#6 |
|
Senior Member
anonymous
Join Date: Jan 2016
Posts: 416
Rep Power: 15 ![]() |
Yes I've also tried it a long time ago and it is working perfectly.
You can find tutorial blockMesh files containing wedge like: find $FOAM_TUTORIALS -name blockMeshDict | xargs grep -l -i wedge an example: incompressible/pimplyDyMFoam/movingCone |
|
|
|
|
|
|
|
|
#7 |
|
Member
Foad
Join Date: Aug 2017
Posts: 59
Rep Power: 10 ![]() |
I divided the wedges boundary as suggested:
Code:
wedgeBack
{
type wedge;
faces
(
(0 1 4 5)
(1 7 6 4)
(4 6 11 12)
(12 11 16 15)
(19 12 15 18)
);
}
wedgeFront
{
type wedge;
faces
(
(0 5 3 2)
(2 3 9 8)
(3 13 10 9)
(13 14 17 10)
(19 18 14 13)
);
}
Code:
Creating block mesh topology
--> FOAM Warning :
From function Foam::polyMesh::polyMesh(const Foam::IOobject&, const Foam::Xfer<Foam::Field<Foam::Vector<double> > >&, const cellShapeList&, const faceListList&, const wordList&, const Foam::PtrList<Foam::dictionary>&, const Foam::word&, const Foam::word&, bool)
in file meshes/polyMesh/polyMeshFromShapeMesh.C at line 871
Found 3 undefined faces in mesh; adding to default patch.
--> FOAM Warning :
From function virtual void Foam::wedgePolyPatch::calcGeometry(Foam::PstreamBuffers&)
in file meshes/polyMesh/polyPatches/constraint/wedge/wedgePolyPatch.C at line 70
Wedge patch 'wedgeFront' is not planar.
At local face at (-3.20457 2.39389 10) the normal (0.598472 0.801143 0) differs from the average normal (0.598471 0.801144 1.11022e-18) by 2.72438e-12
Either correct the patch or split it into planar parts
--> FOAM Warning :
From function virtual void Foam::wedgePolyPatch::calcGeometry(Foam::PstreamBuffers&)
in file meshes/polyMesh/polyPatches/constraint/wedge/wedgePolyPatch.C at line 70
Wedge patch 'wedgeFront' is not planar.
At local face at (-7.2103 5.38625 10) the normal (0.59847 0.801145 1.38778e-18) differs from the average normal (0.598471 0.801144 1.11022e-18) by 1.21084e-12
Either correct the patch or split it into planar parts
--> FOAM Warning :
From function virtual void Foam::wedgePolyPatch::calcGeometry(Foam::PstreamBuffers&)
in file meshes/polyMesh/polyPatches/constraint/wedge/wedgePolyPatch.C at line 70
Wedge patch 'wedgeFront' is not planar.
At local face at (-7.2103 5.38625 25) the normal (0.59847 0.801145 2.77556e-18) differs from the average normal (0.598471 0.801144 1.11022e-18) by 1.21084e-12
Either correct the patch or split it into planar parts
--> FOAM Warning :
From function virtual void Foam::wedgePolyPatch::calcGeometry(Foam::PstreamBuffers&)
in file meshes/polyMesh/polyPatches/constraint/wedge/wedgePolyPatch.C at line 70
Wedge patch 'wedgeFront' is not planar.
At local face at (-7.2103 5.38625 40) the normal (0.59847 0.801145 1.38778e-18) differs from the average normal (0.598471 0.801144 1.11022e-18) by 1.21084e-12
Either correct the patch or split it into planar parts
--> FOAM Warning :
From function virtual void Foam::wedgePolyPatch::calcGeometry(Foam::PstreamBuffers&)
in file meshes/polyMesh/polyPatches/constraint/wedge/wedgePolyPatch.C at line 70
Wedge patch 'wedgeFront' is not planar.
At local face at (-3.20457 2.39389 40) the normal (0.598472 0.801143 0) differs from the average normal (0.598471 0.801144 1.11022e-18) by 2.72438e-12
Either correct the patch or split it into planar parts
--> FOAM Warning :
From function virtual void Foam::wedgePolyPatch::calcGeometry(Foam::PstreamBuffers&)
in file meshes/polyMesh/polyPatches/constraint/wedge/wedgePolyPatch.C at line 70
Wedge patch 'wedgeFront' is not planar.
At local face at (-3.20457 -2.39389 10) the normal (0.598472 -0.801143 0) differs from the average normal (0.598471 -0.801144 -1.11022e-18) by 2.72438e-12
Either correct the patch or split it into planar parts
--> FOAM Warning :
From function virtual void Foam::wedgePolyPatch::calcGeometry(Foam::PstreamBuffers&)
in file meshes/polyMesh/polyPatches/constraint/wedge/wedgePolyPatch.C at line 70
Wedge patch 'wedgeFront' is not planar.
At local face at (-7.2103 -5.38625 10) the normal (0.59847 -0.801145 -1.38778e-18) differs from the average normal (0.598471 -0.801144 -1.11022e-18) by 1.21084e-12
Either correct the patch or split it into planar parts
--> FOAM Warning :
From function virtual void Foam::wedgePolyPatch::calcGeometry(Foam::PstreamBuffers&)
in file meshes/polyMesh/polyPatches/constraint/wedge/wedgePolyPatch.C at line 70
Wedge patch 'wedgeFront' is not planar.
At local face at (-7.2103 -5.38625 25) the normal (0.59847 -0.801145 -2.77556e-18) differs from the average normal (0.598471 -0.801144 -1.11022e-18) by 1.21084e-12
Either correct the patch or split it into planar parts
--> FOAM Warning :
From function virtual void Foam::wedgePolyPatch::calcGeometry(Foam::PstreamBuffers&)
in file meshes/polyMesh/polyPatches/constraint/wedge/wedgePolyPatch.C at line 70
Wedge patch 'wedgeFront' is not planar.
At local face at (-7.2103 -5.38625 40) the normal (0.59847 -0.801145 -1.38778e-18) differs from the average normal (0.598471 -0.801144 -1.11022e-18) by 1.21084e-12
Either correct the patch or split it into planar parts
--> FOAM Warning :
From function virtual void Foam::wedgePolyPatch::calcGeometry(Foam::PstreamBuffers&)
in file meshes/polyMesh/polyPatches/constraint/wedge/wedgePolyPatch.C at line 70
Wedge patch 'wedgeFront' is not planar.
At local face at (-3.20457 -2.39389 40) the normal (0.598472 -0.801143 0) differs from the average normal (0.598471 -0.801144 -1.11022e-18) by 2.72438e-12
Either correct the patch or split it into planar parts
Code:
--> FOAM FATAL ERROR:
wedge wedgeFront centre plane does not align with a coordinate plane by 0.360319
From function virtual void Foam::wedgePolyPatch::calcGeometry(Foam::PstreamBuffers&)
in file meshes/polyMesh/polyPatches/constraint/wedge/wedgePolyPatch.C at line 98.
FOAM exiting
Last edited by foadsf; August 22, 2018 at 20:44. |
|
|
|
|
|
|
|
|
#8 |
|
Member
Foad
Join Date: Aug 2017
Posts: 59
Rep Power: 10 ![]() |
with the help of StackOverflow I managed to get most of I want:
Code:
//following this: https://openfoamwiki.net/index.php/Main_ContribExamples/AxiSymmetric
// /cygdrive/c/Users/sojoodif/surfdrive/sync/MyPhD/simulation/OpenFOAM/20180131_2
/*--------------------------------*- 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*constant::mathematical::pi/180; // wedge angle must be smaller than 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 2 1 0 5 3 4 5) ($ms 1 $ms) simpleGrading (1 1 1)
hex (1 2 8 7 4 3 9 6) (1 1 $ms) simpleGrading (1 1 1)
hex (4 3 9 6 12 13 10 11) (1 1 $ms) simpleGrading (1 1 1)
hex (12 13 10 11 15 14 17 16) (1 1 $ms) simpleGrading (1 1 1)
hex (19 13 12 19 18 14 15 18) ($ms 1 $ms) simpleGrading (1 1 1)
);
edges
(
);
boundary
(
inlet
{
type patch;
faces
(
(0 2 1 0)
(1 2 8 7)
);
}
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)
(5 4 3 5)
(12 13 3 4)
(19 13 12 19)
);
}
wedgeFront
{
type wedge;
faces
(
(0 1 4 5)
(1 7 6 4)
(4 6 11 12)
(12 11 16 15)
(19 12 15 18)
);
}
wedgeBack
{
type wedge;
faces
(
(0 2 3 5)
(2 8 9 3)
(3 9 10 13)
(13 10 17 14)
(19 13 14 18)
);
}
axis
{
type empty;
faces
(
(0 5 5 0)
(19 18 18 19)
);
}
);
mergePatchPairs
(
);
// ************************************************************************* //
|
|
|
|
|
|
|
|
|
#10 |
|
Senior Member
anonymous
Join Date: Jan 2016
Posts: 416
Rep Power: 15 ![]() |
If you do what i suggested earlier, you could be done a long time ago...
( Use patch instead of wedge for troubleshooting and then just swap back to wedge.. ) In openFoam warnings tell you a LOT! So if you have an error, first read it! That long warning what you posted only tell you that you missed 3 boundary patches from the definition so they are in the defaultFaces patch, and the others tell you that your wedge patches are not planar... For the first time these errors looks weird, but they help you a lot! (in this case exactly tells you what was your mistake) If you have 2 neighboring blocks, the spacing on the same face must be identical and you will have no error... You really have to read that cfd.direct link what I sent you because all of your mistakes could be avoided if you know the basics of blockMesh |
|
|
|
|
|
|
|
|
#11 |
|
Member
Foad
Join Date: Aug 2017
Posts: 59
Rep Power: 10 ![]() |
After years of development, I've created a complete minimal working example that solves all the issues discussed in this thread.
GitHub Repository: openfoam-axisymmetric-piston-cfd What's Included: - Working blockMeshDict with proper wedge boundaries - Automated setup script - one command runs everything - Complete case files (system/, constant/, 0/) - Mesh quality validation - passes all OpenFOAM checks - Documentation with geometry parameters explained Key Solutions Implemented: 1. Environment variables properly set for #calc expressions 2. 5° wedge angle in radians with correct coordinate calculation 3. Proper boundary face ordering following right-hand rule 4. Separated wedge patches (wedgeFront/wedgeBack) as suggested by simrego Quick Start: Code:
git clone https://github.com/Foadsf/openfoam-axisymmetric-piston-cfd.git cd openfoam-axisymmetric-piston-cfd ./run_mwe.sh Thanks to everyone who contributed to solving this problem back in 2018! This repository now provides a solid foundation for anyone working with axisymmetric piston-cylinder geometries in OpenFOAM. |
|
|
|
|
|
![]() |
| Tags |
| axisymmetric, blockmeshdict, openfoam |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| [blockMesh] Creating a tapered cylinder | tanveerfathima | OpenFOAM Meshing & Mesh Conversion | 1 | December 4, 2018 07:22 |
| Moving piston inside cylinder | Hope2010 | STAR-CCM+ | 4 | November 13, 2013 00:48 |
| Fuel film on piston and cylinder | kri321shna | STAR-CD | 4 | April 19, 2012 11:58 |
| simulation of piston motion inside a hydraulic cylinder | mosman | FLUENT | 0 | August 6, 2011 16:44 |
| Creating cylinder in STAR-CD | Sachin | Siemens | 2 | March 6, 2008 03:53 |