# [blockMesh] Another cylinder question

 Register Blogs Members List Search Today's Posts Mark Forums Read

 January 5, 2015, 09:25 Another cylinder question #1 Member   Jeremy Dudley Join Date: Jul 2010 Posts: 45 Rep Power: 13 This time it is a cylinder in a cylinder. The aim is to have the inner cylinder represent an inlet, discharging flow near the floor of the tank, across 1/8 of the tank diameter. The opposite 1/8 of the tank, at the surface, is where the flow discharges. I have created vertices for three concentric circles (inlet radius, intermediate radius - to allow definition of a cleaning outlet - and outer wall) and at four depths (floor; top of inlet diffuser; base of outlet weir; tank surface) When I run blockMesh I get a message to check the topology. I have tried commenting out all the blocks but the first, and changing the vertex order from anti-clockwise to clockwise - but that has made no difference to the message. The vertices for each circle are created as (x y z) (-x y z) (-x -y z) (x -y z) where x = radius x cos(3 PI / 8), y = radius x sin(3 PI / 8), so that I get four points to define my intended inlet/outlet regions occupying 1/8 of the tank.

 January 5, 2015, 09:29 #3 Member   Jeremy Dudley Join Date: Jul 2010 Posts: 45 Rep Power: 13 And here are the diagnostics Creating curved edges Creating topology blocks Creating topology patches Check topology Backtrace: ZN10StackTraceC1Ev module: libstack_trace.dll ZN4Foam9blockMesh13verboseOutputE module:\libblockMesh.dll

 January 5, 2015, 21:56 #4 Member   Jeremy Dudley Join Date: Jul 2010 Posts: 45 Rep Power: 13 If I add patches (); to my file the topology diagnostic clears. But now I can do with help orienting my blocks as I move around the cylinder. I get the following messages: Creating block mesh topology --> FOAM Warning : From function cellModel::mag(const labelList&, const pointField&) in file meshes/meshShapes/cellModel/cellModel.C at line 128 zero or negative pyramid volume: -0.073657 for face 0 --> FOAM Warning : From function cellModel::mag(const labelList&, const pointField&) in file meshes/meshShapes/cellModel/cellModel.C at line 128 zero or negative pyramid volume: -0.073657 for face 1 --> FOAM Warning : From function cellModel::mag(const labelList&, const pointField&) in file meshes/meshShapes/cellModel/cellModel.C at line 128 zero or negative pyramid volume: -0.0883883 for face 2 --> FOAM Warning : From function cellModel::mag(const labelList&, const pointField&) in file meshes/meshShapes/cellModel/cellModel.C at line 128 zero or negative pyramid volume: -0.0589256 for face 3 --> FOAM Warning : From function cellModel::mag(const labelList&, const pointField&) in file meshes/meshShapes/cellModel/cellModel.C at line 128 zero or negative pyramid volume: -0.073657 for face 4 --> FOAM Warning : From function cellModel::mag(const labelList&, const pointField&) in file meshes/meshShapes/cellModel/cellModel.C at line 128 zero or negative pyramid volume: -0.073657 for face 5 --> FOAM Warning : From function blockMesh::createTopology(IOdictionary&) in file blockMesh/blockMeshTopology.C at line 255 negative volume block : 0, probably defined inside-out --> FOAM Warning : From function cellModel::mag(const labelList&, const pointField&) in file meshes/meshShapes/cellModel/cellModel.C at line 128 zero or negative pyramid volume: -0.073657 for face 0 --> FOAM Warning : From function cellModel::mag(const labelList&, const pointField&) in file meshes/meshShapes/cellModel/cellModel.C at line 128 zero or negative pyramid volume: -0.073657 for face 1 --> FOAM Warning : From function cellModel::mag(const labelList&, const pointField&) in file meshes/meshShapes/cellModel/cellModel.C at line 128 zero or negative pyramid volume: -0.0589256 for face 2 --> FOAM Warning : From function cellModel::mag(const labelList&, const pointField&) in file meshes/meshShapes/cellModel/cellModel.C at line 128 zero or negative pyramid volume: -0.0883883 for face 3 --> FOAM Warning : From function cellModel::mag(const labelList&, const pointField&) in file meshes/meshShapes/cellModel/cellModel.C at line 128 zero or negative pyramid volume: -0.073657 for face 4 --> FOAM Warning : From function cellModel::mag(const labelList&, const pointField&) in file meshes/meshShapes/cellModel/cellModel.C at line 128 zero or negative pyramid volume: -0.073657 for face 5 --> FOAM Warning : From function blockMesh::createTopology(IOdictionary&) in file blockMesh/blockMeshTopology.C at line 255 negative volume block : 1, probably defined inside-out Reading physicalType from existing boundary file Default patch type set to empty --> FOAM Warning : From function polyMesh:olyMesh(... construct from shapes...) in file meshes/polyMesh/polyMeshFromShapeMesh.C at line 888 Found 10 undefined faces in mesh; adding to default patch. Check topology Basic statistics Number of internal faces : 1 Number of boundary faces : 10 Number of defined boundary faces : 10 Number of undefined boundary faces : 0 Checking patch -> block consistency Creating block offsets Creating merge list . Creating polyMesh from blockMesh Creating patches Creating cells Creating points with scale 1 Writing polyMesh ---------------- Mesh Information ---------------- boundingBox: (-1.5 -1.38582 0) (0.574025 1.5 1) nPoints: 225 nCells: 128 nFaces: 464 nInternalFaces: 304 ---------------- Patches ---------------- patch 0 (start: 304 size: 160) name: defaultFaces End

 January 6, 2015, 05:09 #6 Member   Jeremy Dudley Join Date: Jul 2010 Posts: 45 Rep Power: 13 For completeness, this is the VBA code I was using to create the geometry. Now to resolve the boundary patches! Option Explicit Sub CreateMesh() Dim iFile As Long Dim Ri As Single, Rs As Single, Ro As Single Dim Hv As Single, Wh As Single, H As Single Dim Hw As Single, theta As Single Dim x As Single, y As Single iFile = FreeFile Open ThisWorkbook.Path & "\blockMeshDict" For Output As #iFile Print #iFile, "FoamFile" Print #iFile, "{version 2.0;" Print #iFile, " format ascii;" Print #iFile, " class dictionary;" Print #iFile, " object blockMeshDict;}" Ri = 1 Rs = 1.5 Ro = 6.6 Hv = 1 Wh = 0.5 H = 3 ' ' Ri = inner radius ' Ro = outer radius ' Hv = Voluflow height ' Wh = Weir height ' Wv = Voluflow width ' Lw = Weir length ' H = Height Hw = H - Wh ' Height to weir ' Create points Print #iFile, "convertToMeters 1.0;" Print #iFile, "vertices (" ' Cartesian coordinates (X Y Z) Const PI = 3.1415926535 theta = 3 * PI / 8 ' Feed point Print #iFile, "("; Ri * Cos(theta); Ri * Sin(theta); " 0.0) // 0" Print #iFile, "("; -Ri * Cos(theta); Ri * Sin(theta); " 0.0) // 1" Print #iFile, "("; -Ri * Cos(theta); -Ri * Sin(theta); " 0.0) // 2" Print #iFile, "("; Ri * Cos(theta); -Ri * Sin(theta); " 0.0) // 3" ' Sludge takeoff ' No hard data; assume opposite centre to inlet. Print #iFile, "("; Rs * Cos(theta); Rs * Sin(theta); " 0.0) // 4" Print #iFile, "("; -Rs * Cos(theta); Rs * Sin(theta); " 0.0) // 5" Print #iFile, "("; -Rs * Cos(theta); -Rs * Sin(theta); " 0.0) // 6" Print #iFile, "("; Rs * Cos(theta); -Rs * Sin(theta); " 0.0) // 7" ' Outer cylinder Print #iFile, "("; Ro * Cos(theta); Ro * Sin(theta); " 0.0) // 8" Print #iFile, "("; -Ro * Cos(theta); Ro * Sin(theta); " 0.0) // 9" Print #iFile, "("; -Ro * Cos(theta); -Ro * Sin(theta); " 0.0) // 10" Print #iFile, "("; Ro * Cos(theta); -Ro * Sin(theta); " 0.0) // 11" ' Feed top Print #iFile, "("; Ri * Cos(theta); Ri * Sin(theta); Hv; ") // 12" Print #iFile, "("; -Ri * Cos(theta); Ri * Sin(theta); Hv; ") // 13" Print #iFile, "("; -Ri * Cos(theta); -Ri * Sin(theta); Hv; ") // 14" Print #iFile, "("; Ri * Cos(theta); -Ri * Sin(theta); Hv; ") // 15" Print #iFile, "("; Rs * Cos(theta); Rs * Sin(theta); Hv; ") // 16" Print #iFile, "("; -Rs * Cos(theta); Rs * Sin(theta); Hv; ") // 17" Print #iFile, "("; -Rs * Cos(theta); -Rs * Sin(theta); Hv; ") // 18" Print #iFile, "("; Rs * Cos(theta); -Rs * Sin(theta); Hv; ") // 19" Print #iFile, "("; Ro * Cos(theta); Ro * Sin(theta); Hv; ") // 20" Print #iFile, "("; -Ro * Cos(theta); Ro * Sin(theta); Hv; ") // 21" Print #iFile, "("; -Ro * Cos(theta); -Ro * Sin(theta); Hv; ") // 22" Print #iFile, "("; Ro * Cos(theta); -Ro * Sin(theta); Hv; ") // 23" ' Weir base Print #iFile, "("; Ri * Cos(theta); Ri * Sin(theta); Hw; ") // 24" Print #iFile, "("; -Ri * Cos(theta); Ri * Sin(theta); Hw; ") // 25" Print #iFile, "("; -Ri * Cos(theta); -Ri * Sin(theta); Hw; ") // 26" Print #iFile, "("; Ri * Cos(theta); -Ri * Sin(theta); Hw; ") // 27" Print #iFile, "("; Rs * Cos(theta); Rs * Sin(theta); Hw; ") // 28" Print #iFile, "("; -Rs * Cos(theta); Rs * Sin(theta); Hw; ") // 29" Print #iFile, "("; -Rs * Cos(theta); -Rs * Sin(theta); Hw; ") // 30" Print #iFile, "("; Rs * Cos(theta); -Rs * Sin(theta); Hw; ") // 31" Print #iFile, "("; Ro * Cos(theta); Ro * Sin(theta); Hw; ") // 32" Print #iFile, "("; -Ro * Cos(theta); Ro * Sin(theta); Hw; ") // 33" Print #iFile, "("; -Ro * Cos(theta); -Ro * Sin(theta); Hw; ") // 34" Print #iFile, "("; Ro * Cos(theta); -Ro * Sin(theta); Hw; ") // 35" ' tank top Print #iFile, "("; Ri * Cos(theta); Ri * Sin(theta); H; ") // 36" Print #iFile, "("; -Ri * Cos(theta); Ri * Sin(theta); H; ") // 37" Print #iFile, "("; -Ri * Cos(theta); -Ri * Sin(theta); H; ") // 38" Print #iFile, "("; Ri * Cos(theta); -Ri * Sin(theta); H; ") // 39" Print #iFile, "("; Rs * Cos(theta); Rs * Sin(theta); H; ") // 40" Print #iFile, "("; -Rs * Cos(theta); Rs * Sin(theta); H; ") // 41" Print #iFile, "("; -Rs * Cos(theta); -Rs * Sin(theta); H; ") // 42" Print #iFile, "("; Rs * Cos(theta); -Rs * Sin(theta); H; ") // 43" Print #iFile, "("; Ro * Cos(theta); Ro * Sin(theta); H; ") // 44" Print #iFile, "("; -Ro * Cos(theta); Ro * Sin(theta); H; ") // 45" Print #iFile, "("; -Ro * Cos(theta); -Ro * Sin(theta); H; ") // 46" Print #iFile, "("; Ro * Cos(theta); -Ro * Sin(theta); H; ") // 47" Print #iFile, ");" ' Create blocks Print #iFile, "blocks (" ' Layer 1 - Floor to inlet top WriteBlocks iFile, 0, 4, 4, 4 ' feed to sludge WriteBlocks iFile, 4, 4, 4, 4 ' sludge to wall ' Layer 2 - inlet top to weir base WriteBlocks iFile, 12, 4, 4, 4 WriteBlocks iFile, 12 + 4, 4, 4, 4 ' Layer 3 - weir base to weir top WriteBlocks iFile, 24, 4, 4, 4 WriteBlocks iFile, 24 + 4, 4, 4, 4 Print #iFile, ");" ' Create the circle quadrants Print #iFile, "edges (" Print #iFile, " arc 0 1 ("; 0; Ri; " 0.0)" Print #iFile, " arc 1 2 ("; -Ri; " 0.0 "; " 0.0)" Print #iFile, " arc 2 3 ("; 0; -Ri; " 0.0)" Print #iFile, " arc 3 0 ("; Ri; " 0.0 "; " 0.0)" Print #iFile, " arc 4 5 ("; 0; Rs; 0; ")" Print #iFile, " arc 5 6 ("; -Rs; " 0.0 "; 0; ")" Print #iFile, " arc 6 7 ("; 0; -Rs; 0; ")" Print #iFile, " arc 7 4 ("; Rs; " 0.0 "; 0; ")" Print #iFile, " arc 8 9 ("; 0; Ro; 0; ")" Print #iFile, " arc 9 10 ("; -Ro; " 0.0 "; 0; ")" Print #iFile, " arc 10 11 ("; 0; -Ro; 0; ")" Print #iFile, " arc 11 8 ("; Ro; " 0.0 "; 0; ")" Print #iFile, " arc 12 13 ("; 0; Ri; Hv; ")" Print #iFile, " arc 13 14 ("; -Ri; " 0.0 "; Hv; ")" Print #iFile, " arc 14 15 ("; 0; -Ri; Hv; ")" Print #iFile, " arc 15 12 ("; Ri; " 0.0 "; Hv; ")" ' Arcs at Rs Print #iFile, " arc 16 17 ("; 0; Rs; Hv; ")" Print #iFile, " arc 17 18 ("; -Rs; " 0.0 "; Hv; ")" Print #iFile, " arc 18 19 ("; 0; -Rs; Hv; ")" Print #iFile, " arc 19 16 ("; Rs; " 0.0 "; Hv; ")" Print #iFile, " arc 20 21 ("; 0; Ro; Hv; ")" Print #iFile, " arc 21 22 ("; -Ro; " 0.0 "; Hv; ")" Print #iFile, " arc 22 23 ("; 0; -Ro; Hv; ")" Print #iFile, " arc 23 20 ("; Ro; " 0.0 "; Hv; ")" Print #iFile, " arc 24 25 ("; 0; Ri; Hw; ")" Print #iFile, " arc 25 26 ("; -Ri; " 0.0 "; Hw; ")" Print #iFile, " arc 26 27 ("; 0; -Ri; Hw; ")" Print #iFile, " arc 27 24 ("; Ri; " 0.0 "; Hw; ")" Print #iFile, " arc 28 29 ("; 0; Rs; Hw; ")" Print #iFile, " arc 29 30 ("; -Rs; " 0.0 "; Hw; ")" Print #iFile, " arc 30 31 ("; 0; -Rs; Hw; ")" Print #iFile, " arc 31 28 ("; Rs; " 0.0 "; Hw; ")" ' Arcs at Ro Print #iFile, " arc 32 33 ("; 0; Ro; Hw; ")" Print #iFile, " arc 33 34 ("; -Ro; " 0.0 "; Hw; ")" Print #iFile, " arc 34 35 ("; 0; -Ro; Hw; ")" Print #iFile, " arc 35 32 ("; Ro; " 0.0 "; Hw; ")" Print #iFile, " arc 36 37 ("; 0; Ri; H; ")" Print #iFile, " arc 37 38 ("; -Ri; " 0.0 "; H; ")" Print #iFile, " arc 38 39 ("; 0; -Ri; H; ")" Print #iFile, " arc 39 36 ("; Ri; " 0.0 "; H; ")" Print #iFile, " arc 40 41 ("; 0; Rs; H; ")" Print #iFile, " arc 41 42 ("; -Rs; " 0.0 "; H; ")" Print #iFile, " arc 42 43 ("; 0; -Rs; H; ")" Print #iFile, " arc 43 40 ("; Rs; " 0.0 "; H; ")" Print #iFile, " arc 44 45 ("; 0; Ro; H; ")" Print #iFile, " arc 45 46 ("; -Ro; " 0.0 "; H; ")" Print #iFile, " arc 46 47 ("; 0; -Ro; H; ")" Print #iFile, " arc 47 44 ("; Ro; " 0.0 "; H; ")" Print #iFile, ");" ' Merge blocks ' Create boundary faces Print #iFile, "patches (" 'Print #iFile, " patch inlet(" 'Print #iFile, " ()" 'Print #iFile, " )" 'Print #iFile, " patch outlet(" 'Print #iFile, " ()" 'Print #iFile, " )" 'Print #iFile, " patch sludge(" 'Print #iFile, " ()" 'Print #iFile, " )" Print #iFile, " );" Print #iFile, "walls (" Print #iFile, " );" Print #iFile, "mergePatchPairs ();" Close #iFile End Sub ' NPR: Number of points in radial direction ' NPT: Number of points in tangential direction ' NPZ: Number of points in vertical direction Sub WriteBlocks(iFile As Long, inc As Long, NPR As Long, NPT As Long, NPZ As Long) Print #iFile, " hex (" & WriteHex("1 0 4 5 13 12 16 17", inc) & ")"; Print #iFile, " ("; NPR; NPT; NPZ; ")"; Print #iFile, " simpleGrading (1 1 1)" Print #iFile, " hex (" & WriteHex("6 2 1 5 18 14 13 17", inc) & ")"; Print #iFile, " ("; NPR; NPT; NPZ; ")"; Print #iFile, " simpleGrading (1 1 1)" Print #iFile, " hex (" & WriteHex("6 7 3 2 18 19 15 14", inc) & ")"; Print #iFile, " ("; NPR; NPT; NPZ; ")"; Print #iFile, " simpleGrading (1 1 1)" Print #iFile, " hex (" & WriteHex("7 4 0 3 19 16 12 15", inc) & ")"; Print #iFile, " ("; NPR; NPT; NPZ; ")"; Print #iFile, " simpleGrading (1 1 1)" End Sub Function WriteHex(ByVal sLine As String, inc As Long) As String Dim v As Variant Dim i As Long sLine = Trim\$(sLine) v = Split(sLine, " ") sLine = "" For i = LBound(v) To UBound(v) sLine = sLine & v(i) + inc & " " Next i sLine = Trim\$(sLine) WriteHex = sLine End Function