# GmshToFoam: Problem meshing a circle in a square

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

 July 9, 2016, 13:13 GmshToFoam: Problem meshing a circle in a square #1 New Member   Paul Join Date: Jun 2016 Posts: 21 Rep Power: 3 Hi guys, I'm trying to make a simple 2D (well, 3D in OpenFOAM!) mesh using Gmsh. Here's how I've written it: Code: ```//Inputs w=1;//m h=1;//m r=0.3;//m gridsize=w/20; Point(1) = {0, 0, 0, gridsize}; Point(2) = {w, 0, 0, gridsize}; Point(3) = {w, h, 0, gridsize}; Point(4) = {0, h, 0, gridsize}; Point(5) = {w/2, h/2, 0, gridsize}; Point(6) = {(r+w/2), h/2, 0, gridsize}; Point(7) = {w/2, (r+h/2), 0, gridsize}; Point(8) = {(-r+w/2), h/2, 0, gridsize}; Point(9) = {w/2, (-r+h/2), 0, gridsize}; Line(1) = {4, 3}; Line(2) = {3, 2}; Line(3) = {2, 1}; Line(4) = {1, 4}; Circle(5) = {8, 5, 7}; Circle(6) = {7, 5, 6}; Circle(7) = {6, 5, 9}; Circle(8) = {9, 5, 8}; Line Loop(1) = {5, 6, 7, 8}; Line Loop(2) = {4, 1, 2, 3}; Ruled Surface(1) = {1}; Plane Surface(2) = {2, 1}; surfaceVector[] = Extrude {0, 0, 0.1} { Surface{1,2}; Layers{1}; Recombine;}; Physical Volume("internal") = surfaceVector[1]; Physical Surface("LeftWall")=surfaceVector[2]; Physical Surface("RightWall")=surfaceVector[4]; Physical Surface("BottomWall")=surfaceVector[5]; Physical Surface("TopWall")=surfaceVector[3];``` It seems to mesh all right when I run gmsh -3. However, when I run gmshToFoam I get a seg fault immediately after 'Create Time'. Does anyone have any suggestions on getting this thing working? I'm optimistic that such a simple geometry shouldn't pose too much of a challenge! Cheers.

 July 9, 2016, 18:45 #2 Senior Member   Alexey Matveichev Join Date: Aug 2011 Location: Nancy, France Posts: 1,691 Rep Power: 28 Hi, Can not reproduce your error with Gmsh 2.12.0 and neither with OpenFOAM 4.x, nor with OpenFOAM 2.4.x. Though one of peculiarities of your geo file is that gmsh -3 produces only mesh inside circle, so, guess, you need to describe what you are trying to achieve, since "meshing a circle in a square" is rather vague.

 July 10, 2016, 08:32 #3 New Member   Paul Join Date: Jun 2016 Posts: 21 Rep Power: 3 Hi Alexey, thanks for your reply. Apologies for the vagueness - on a second read of the post it is a bit lacking! What I'm trying to make is a mesh of a 'unit cell' in a nuclear reactor, i.e., a circular fuel pin surrounded by a square region of coolant. However, I'm not actually interested in the CFD aspects, rather the neutronics and hence I'm trying to mesh both of these parts of the cell together, albeit as regions with ultimately different properties. Also, I want to ensure that this mesh only has one layer as it's a 2D simulation I intend to run. I now realise that while I did indeed get it to successfully mesh, it only meshes either the circular or square region with a hole, depending upon the order the surfaces are written in the extrude command. From there, placing the .msh file in the system folder, when I run gmshToFoam XXXX.msh in the case file the segFault occurs: Code: ```Create time #0 Foam::error::printStack(Foam::Ostream&) at ??:? #1 Foam::sigSegv::sigHandler(int) at ??:? #2 ? in "/lib/x86_64-linux-gnu/libc.so.6" #3 Foam::PtrList::operator[](int) const at ??:? #4 ? at ??:? #5 __libc_start_main in "/lib/x86_64-linux-gnu/libc.so.6" #6 ? at ??:?Segmentation fault (core dumped)``` It is entirely possible that I'm doing something quite stupid. However, I suspect at least one part of the failure may be that (whether circular or square mesh) there's no wall defined around what is the hole in the square mesh or the circumference in the circular mesh. Ideally of course this shouldn't be a concern as I would like the two meshes joined together but it might be one part of the problem!

 July 10, 2016, 09:10 #4 Senior Member   Alexey Matveichev Join Date: Aug 2011 Location: Nancy, France Posts: 1,691 Rep Power: 28 Hi, The error you are mentioning in the last message is caused by non-existent XXXX.msh, since you put it into system folder and run gmshToFoam (I guess) from case folder. Either put XXXX.msh into case folder, or run gmshToFoam system/XXXX.msh. ChasingNeutrons likes this.

 July 10, 2016, 09:46 #5 New Member   Paul Join Date: Jun 2016 Posts: 21 Rep Power: 3 Knew it was something stupid - thank you very much Alexey. If anyone happens to know how I might combine the circular and square meshes that would also be brilliant although I do suspect it won't prove too difficult in the end!

July 10, 2016, 10:14
#6
Senior Member

Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,691
Rep Power: 28
Oh, I have missed second.

The reason for fancy meshing could be usage of the hole during construction of plane. Usually I try to avoid this functionality and split plane into continuous pieces. You can find example attached to the message.

- Mesh center is in (0, 0, 0).
- Sizes of cells are controlled by variables d1 (point density on the outer lines), d2 (points density on the internal lines), d3 (points density on the circle arcs) rather than by parameter in points definition.
Attached Files
 test.geo.gz (579 Bytes, 7 views)

 Thread Tools Display Modes Linear Mode

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is OffTrackbacks are On Pingbacks are On Refbacks are On Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post [DesignModeler] How to Extrude from Circle to Square dkx209 ANSYS Meshing & Geometry 3 April 9, 2017 11:17 Eizo ANSYS Meshing & Geometry 30 February 17, 2013 03:40 julien.decharentenay OpenFOAM Native Meshers: snappyHexMesh and Others 7 June 16, 2012 08:12 prashanthreddyh ANSYS Meshing & Geometry 1 December 20, 2011 01:35 Gauthier Lambert Main CFD Forum 1 August 3, 2000 09:22

All times are GMT -4. The time now is 01:57.