|
[Sponsors] |
September 7, 2012, 16:07 |
Patches in GmshToFoam
|
#1 |
Senior Member
Hannes Kröger
Join Date: Mar 2009
Location: Rostock, Germany
Posts: 124
Rep Power: 18 |
Hello,
Recently, I have noticed that the "physical surfaces" in gmsh are not properly preserved when the msh file is converted into an OpenFOAM-mesh. All boundary patches end up in the same "default"-patch. I was using OpenFOAM-1.6-ext and gmsh 2.6.2. I have also noticed, that this issue is fixed in OF-2.1.x. I have backported the changes. For those, that are bothered by this issue, here is a patch. |
|
October 11, 2012, 13:42 |
|
#2 |
New Member
Kanuk
Join Date: Oct 2010
Posts: 28
Rep Power: 16 |
Thanks very much for the patch - just what I was looking for!
|
|
March 7, 2013, 10:25 |
missing elements
|
#4 |
Member
Felipe Alves Portela
Join Date: Dec 2012
Location: FR
Posts: 70
Rep Power: 14 |
Hello everyone!
I ran into the issue of missing surfaces when converting from Gmsh to OpenFOAM. When I use gmshToFoam I get this warning first: Code:
--> FOAM Warning : From function polyMesh::polyMesh(... construct from shapes...) in file meshes/polyMesh/polyMeshFromShapeMesh.C at line 619 Found 3108 undefined faces in mesh; adding to default patch. Code:
--> FOAM Warning : From function gmshToFoam in file gmshToFoam.C at line 968 Could not match gmsh face 3(26 346 347) to any of the interior or exterior faces that share the same 0th point I noticed that the only the faces in the structured part of the mesh are missing. I tried applying the patch but the problem didn't go away... Any ideas/suggestions on how to go about this? |
|
March 7, 2013, 10:36 |
|
#5 |
Senior Member
Hisham Elsafti
Join Date: Apr 2011
Location: Braunschweig, Germany
Posts: 257
Blog Entries: 10
Rep Power: 17 |
Hello fportela
The "defaultFaces" empty patch is the patch that includes all Gmsh surfaces that are not assigned to a physical surface. You need to make sure that all surfaces in Gmsh are assigned to physical surfaces unless you need the surface to be an empty patch. It is useful if you mention which OpenFOAM and which Gmsh are you using. If you have further problems, it is a good idea to attach your .geo file Hisham |
|
March 7, 2013, 10:52 |
|
#6 |
Member
Felipe Alves Portela
Join Date: Dec 2012
Location: FR
Posts: 70
Rep Power: 14 |
Hi Hisham,
Thanks for the quick reply! Yes I noticed that defaultFaces contains all the missing information. If you look at the figure in_out_bot_gmsh I attached in the previous post, each surface is defined as a physical surface and that is how I select them for display. Analogously, after conversion, I pick the same surfaces (now using paraView) for display, but now some elements are missing on those surfaces (it's like some surface elements don't belong to the surface itself). I am using Gmsh version 2.6.2 and I have OpenFOAM 2.1.1 |
|
March 7, 2013, 11:05 |
|
#7 |
Senior Member
Hisham Elsafti
Join Date: Apr 2011
Location: Braunschweig, Germany
Posts: 257
Blog Entries: 10
Rep Power: 17 |
I only had problems with internal surfaces in OpenFOAM-2.1 gmshToFoam and it was only assigning the wrong name (It is fixed on the wiki page). So if you sure that you have assigned all surfaces and volumes in Gmsh to physical entities then maybe you can attach or post the ".geo" file!
|
|
March 7, 2013, 13:04 |
|
#8 |
Member
Felipe Alves Portela
Join Date: Dec 2012
Location: FR
Posts: 70
Rep Power: 14 |
Hey Hisham,
I have attached the .geo I'm using for the mesh. I noticed that the issue is probably related with the regions where I do the structured mesh, though I don't understand what exactly is going on... EDIT: I just noticed that for some reason I can't really upload the .geo so I posted it below: Code:
h = 0.002; cl_MR = h/5; cl_buffer_bottom = 10*h; cl_buffer_upper = 20*h; n_inlet = 4; n_outlet = n_inlet; n_upstream_sides = 16; n_downstream_sides = n_upstream_sides; bufferu_to_MR = 2.5*h; bufferd_to_MR = 2.5*h+7.5*h*Cos(24*Pi/180); height = 30*h; width = 30*h; inlet_to_VG = 150*h; length = 300*h; // Vortex generator points p_aft_bottom = newp; Point(p_aft_bottom) = {7.5*h*Cos(24*Pi/180),0,0,cl_MR}; p_aft_upper = newp; Point(p_aft_upper) = {7.5*h*Cos(24*Pi/180),0,h,cl_MR}; p_nose_front = newp; Point(p_nose_front) = {0,-7.5*h*Sin(24*Pi/180),0,cl_MR}; p_nose_back = newp; Point(p_nose_back) = {0,7.5*h*Sin(24*Pi/180),0,cl_MR}; // Domain points p_inlet_bottom_back = newp; Point(p_inlet_bottom_back) = {-inlet_to_VG,width/2,0}; p_inlet_bottom_front = newp; Point(p_inlet_bottom_front) = {-inlet_to_VG,-width/2,0}; p_inlet_upper_back = newp; Point(p_inlet_upper_back) = {-inlet_to_VG,width/2,height}; p_inlet_upper_front = newp; Point(p_inlet_upper_front) = {-inlet_to_VG,-width/2,height}; p_outlet_bottom_back = newp; Point(p_outlet_bottom_back) = {length-inlet_to_VG,width/2,0}; p_outlet_bottom_front = newp; Point(p_outlet_bottom_front) = {length-inlet_to_VG,-width/2,0}; p_outlet_upper_back = newp; Point(p_outlet_upper_back) = {length-inlet_to_VG,width/2,height}; p_outlet_upper_front = newp; Point(p_outlet_upper_front) = {length-inlet_to_VG,-width/2,height}; // Upstream mesh buffer points p_buffu_bottom_back = newp; Point(p_buffu_bottom_back ) = {-bufferu_to_MR,width/2,0,cl_buffer_upper}; p_buffu_bottom_front = newp; Point(p_buffu_bottom_front) = {-bufferu_to_MR,-width/2,0,cl_buffer_upper}; p_buffu_upper_back = newp; Point(p_buffu_upper_back) = {-bufferu_to_MR,width/2,height,cl_buffer_upper}; p_buffu_upper_front = newp; Point(p_buffu_upper_front) = {-bufferu_to_MR,-width/2,height,cl_buffer_upper}; // Downstream mesh buffer points p_buffd_bottom_back = newp; Point(p_buffd_bottom_back ) = {bufferd_to_MR,width/2,0,cl_buffer_bottom}; p_buffd_bottom_front = newp; Point(p_buffd_bottom_front) = {bufferd_to_MR,-width/2,0,cl_buffer_bottom}; p_buffd_upper_back = newp; Point(p_buffd_upper_back) = {bufferd_to_MR,width/2,height,cl_buffer_bottom}; p_buffd_upper_front = newp; Point(p_buffd_upper_front) = {bufferd_to_MR,-width/2,height,cl_buffer_bottom}; // Inlet lines l_in_bottom = newl+100; Line(l_in_bottom) = {p_inlet_bottom_back,p_inlet_bottom_front}; l_in_upper = newl+100; Line(l_in_upper) = {p_inlet_upper_back,p_inlet_upper_front}; l_in_front = newl+100; Line(l_in_front) = {p_inlet_bottom_front,p_inlet_upper_front}; l_in_back = newl+100; Line(l_in_back) = {p_inlet_bottom_back,p_inlet_upper_back}; // Outlet lines l_out_bottom = newl+100; Line(l_out_bottom) = {p_outlet_bottom_back,p_outlet_bottom_front}; l_out_upper = newl+100; Line(l_out_upper) = {p_outlet_upper_back,p_outlet_upper_front}; l_out_front = newl+100; Line(l_out_front) = {p_outlet_bottom_front,p_outlet_upper_front}; l_out_back = newl+100; Line(l_out_back) = {p_outlet_bottom_back,p_outlet_upper_back}; // Downstream mesh buffer outlet lines l_buffd_bottom = newl+100; Line(l_buffd_bottom) = {p_buffd_bottom_back,p_buffd_bottom_front}; l_buffd_upper = newl+100; Line(l_buffd_upper) = {p_buffd_upper_back,p_buffd_upper_front}; l_buffd_front = newl+100; Line(l_buffd_front) = {p_buffd_bottom_front,p_buffd_upper_front}; l_buffd_back = newl+100; Line(l_buffd_back) = {p_buffd_bottom_back,p_buffd_upper_back}; // Upstream mesh buffer inlet lines l_buffu_bottom = newl+100; Line(l_buffu_bottom) = {p_buffu_bottom_back,p_buffu_bottom_front}; l_buffu_upper = newl+100; Line(l_buffu_upper) = {p_buffu_upper_back,p_buffu_upper_front}; l_buffu_front = newl+100; Line(l_buffu_front) = {p_buffu_bottom_front,p_buffu_upper_front}; l_buffu_back = newl+100; Line(l_buffu_back) = {p_buffu_bottom_back,p_buffu_upper_back}; // Upstream sides lines l_ups_bottom_front = newl+100; Line(l_ups_bottom_front) = {p_buffu_bottom_front,p_inlet_bottom_front}; l_ups_upper_front = newl+100; Line(l_ups_upper_front) = {p_buffu_upper_front,p_inlet_upper_front}; l_ups_bottom_back = newl+100; Line(l_ups_bottom_back) = {p_buffu_bottom_back,p_inlet_bottom_back}; l_ups_upper_back = newl+100; Line(l_ups_upper_back) = {p_buffu_upper_back,p_inlet_upper_back}; // Downstream sides lines l_downs_bottom_front = newl+100; Line(l_downs_bottom_front) = {p_buffd_bottom_front,p_outlet_bottom_front}; l_downs_upper_front = newl+100; Line(l_downs_upper_front) = {p_buffd_upper_front,p_outlet_upper_front}; l_downs_bottom_back = newl+100; Line(l_downs_bottom_back) = {p_buffd_bottom_back,p_outlet_bottom_back}; l_downs_upper_back = newl+100; Line(l_downs_upper_back) = {p_buffd_upper_back,p_outlet_upper_back}; // Micro ramp lines l_MR_nose = newl+100; Line(l_MR_nose) = {p_nose_front,p_nose_back}; l_MR_vertical = newl+100; Line(l_MR_vertical) = {p_aft_bottom,p_aft_upper}; l_MR_front_bottom = newl+100; Line(l_MR_front_bottom) = {p_nose_front,p_aft_bottom}; l_MR_back_bottom = newl+100; Line(l_MR_back_bottom) = {p_nose_back,p_aft_bottom}; l_MR_front_upper = newl+100; Line(l_MR_front_upper) = {p_nose_front,p_aft_upper}; l_MR_back_upper = newl+100; Line(l_MR_back_upper) = {p_nose_back,p_aft_upper}; // Connection between buffers lines l_buffers_front_bottom = newl+100; Line(l_buffers_front_bottom) = {p_buffu_bottom_front,p_buffd_bottom_front}; l_buffers_front_upper = newl+100; Line(l_buffers_front_upper) = {p_buffu_upper_front,p_buffd_upper_front}; l_buffers_back_bottom = newl+100; Line(l_buffers_back_bottom) = {p_buffu_bottom_back,p_buffd_bottom_back}; l_buffers_back_upper = newl+100; Line(l_buffers_back_upper) = {p_buffu_upper_back,p_buffd_upper_back}; // Inlet surface ll_inlet = newll; Line Loop(ll_inlet) = {l_in_bottom,-l_in_upper,l_in_front,-l_in_back}; s_inlet = news; Plane Surface(s_inlet) = {ll_inlet}; // Outlet surface ll_outlet = newll; Line Loop(ll_outlet) = {-l_out_bottom,l_out_upper,-l_out_front,l_out_back}; s_outlet = news; Plane Surface(s_outlet) = {ll_outlet}; // Upstream surfaces; ll_ups_front = newll; Line Loop(ll_ups_front) = {-l_ups_bottom_front,-l_in_front,l_ups_upper_front,l_buffu_front}; s_ups_front = news; Plane Surface(s_ups_front) = {ll_ups_front}; ll_ups_back = newll; Line Loop(ll_ups_back) = {l_ups_bottom_back,l_in_back,-l_ups_upper_back,-l_buffu_back}; s_ups_back = news; Plane Surface(s_ups_back) = {ll_ups_back}; ll_ups_bottom = newll; Line Loop(ll_ups_bottom) = {l_ups_bottom_front,-l_ups_bottom_back,-l_in_bottom,l_buffu_bottom}; s_ups_bottom = news; Plane Surface(s_ups_bottom) = {ll_ups_bottom}; ll_ups_upper = newll; Line Loop(ll_ups_upper) = {l_ups_upper_front,-l_ups_upper_back,-l_in_upper,l_buffu_upper}; s_ups_upper = news; Plane Surface(s_ups_upper) = {ll_ups_upper}; // Downstream surfaces; ll_downs_front = newll; Line Loop(ll_downs_front) = {l_downs_bottom_front,l_out_front,-l_downs_upper_front,-l_buffd_front}; s_downs_front = news; Plane Surface(s_downs_front) = {ll_downs_front}; ll_downs_back = newll; Line Loop(ll_downs_back) = {-l_downs_bottom_back,-l_out_back,l_downs_upper_back,l_buffd_back}; s_downs_back = news; Plane Surface(s_downs_back) = {ll_downs_back}; ll_downs_bottom = newll; Line Loop(ll_downs_bottom) = {-l_downs_bottom_front,l_downs_bottom_back,l_out_bottom,-l_buffd_bottom}; s_downs_bottom = news; Plane Surface(s_downs_bottom) = {ll_downs_bottom}; ll_downs_upper = newll; Line Loop(ll_downs_upper) = {l_downs_upper_front,-l_downs_upper_back,-l_out_upper,l_buffd_upper}; s_downs_upper = news; Plane Surface(s_downs_upper) = {ll_downs_upper}; // Upstream mesh buffer inlet surface ll_buffu = newll; Line Loop(ll_buffu) = {l_buffu_bottom,-l_buffu_upper,l_buffu_front,-l_buffu_back}; s_buffu = news; Plane Surface(s_buffu) = {ll_buffu}; // Downstream mesh buffer outlet surface ll_buffd = newll; Line Loop(ll_buffd) = {l_buffd_bottom,-l_buffd_upper,l_buffd_front,-l_buffd_back}; s_buffd = news; Plane Surface(s_buffd) = {ll_buffd}; // Connection between buffers surfaces ll_connbuffs_upper = newll; Line Loop(ll_connbuffs_upper) = {l_buffers_front_upper,-l_buffd_upper,-l_buffers_back_upper,l_buffu_upper}; s_connbuffs_upper = news; Plane Surface(s_connbuffs_upper) = {ll_connbuffs_upper}; ll_MR_hole = newll; Line Loop(ll_MR_hole) = {l_MR_nose,l_MR_back_bottom,-l_MR_front_bottom}; ll_connbuffs_bottom = newll; Line Loop(ll_connbuffs_bottom) = {-l_buffers_front_bottom,l_buffd_bottom,l_buffers_back_bottom,-l_buffu_bottom}; s_connbuffs_bottom = news; Plane Surface(s_connbuffs_bottom) = {ll_connbuffs_bottom,ll_MR_hole}; ll_connbuffs_front = newll; Line Loop(ll_connbuffs_front) = {l_buffers_front_bottom,l_buffd_front,-l_buffers_front_upper,-l_buffu_front}; s_connbuffs_front = news; Plane Surface(s_connbuffs_front) = {ll_connbuffs_front}; ll_connbuffs_back = newll; Line Loop(ll_connbuffs_back) = {-l_buffers_back_bottom,-l_buffd_back,l_buffers_back_upper,l_buffu_back}; s_connbuffs_back = news; Plane Surface(s_connbuffs_back) = {ll_connbuffs_back}; // Micro ramp surfaces ll_MR_upper = newll; Line Loop(ll_MR_upper) = {l_MR_nose,l_MR_back_upper,-l_MR_front_upper}; s_MR_upper = news; Plane Surface(s_MR_upper) = {ll_MR_upper}; ll_MR_front = newll; Line Loop(ll_MR_front) = {-l_MR_vertical,-l_MR_front_bottom,l_MR_front_upper}; s_MR_front = news; Plane Surface(s_MR_front) = {ll_MR_front}; ll_MR_back = newll; Line Loop(ll_MR_back) = {l_MR_vertical,l_MR_back_bottom,-l_MR_back_upper}; s_MR_back = news; Plane Surface(s_MR_back) = {ll_MR_back}; // Upstream volume sl_ups = newsl; Surface Loop(sl_ups) = {s_buffu,s_ups_front,s_ups_back,s_ups_bottom,s_ups_upper,-s_inlet}; v_ups = newv; Volume(v_ups) = {sl_ups}; // Downstream volume sl_downs = newsl; Surface Loop(sl_downs) = {s_buffd,s_downs_front,s_downs_back,s_downs_bottom,s_downs_upper,s_outlet}; v_downs = newv; Volume(v_downs) = {sl_downs}; // Near MR volume sl_between_buffers = newsl; Surface Loop(sl_between_buffers) = {s_connbuffs_upper,s_connbuffs_bottom,s_connbuffs_front,s_connbuffs_back,s_buffu,s_buffd,s_MR_upper,s_MR_front,s_MR_back}; v_between_buffers = newv; Volume(v_between_buffers) = {sl_between_buffers}; // Mesh upstream Transfinite Line {-l_ups_bottom_front,l_ups_upper_front,l_ups_bottom_back,-l_ups_upper_back} = n_upstream_sides ; Transfinite Line {l_buffu_bottom,l_buffu_upper,l_buffu_front,-l_buffu_back,l_in_bottom,l_in_upper,-l_in_front,l_in_back} = n_inlet; Transfinite Surface {s_buffu,s_ups_front,s_ups_back,s_ups_bottom,s_ups_upper,s_inlet} = {} Alternate; Transfinite Volume {v_ups}; // Mesh downstream Transfinite Line {l_downs_bottom_front,-l_downs_upper_front,-l_downs_bottom_back,l_downs_upper_back} = n_downstream_sides ; Transfinite Line {l_buffd_bottom,l_buffd_upper,-l_buffd_front,l_buffd_back,l_out_bottom,l_out_upper,l_out_front,-l_out_back} = n_outlet; Transfinite Surface {s_buffd,s_downs_front,s_downs_back,s_downs_bottom,s_downs_upper,s_outlet} = {} Alternate; Transfinite Volume {v_downs}; // Periodic sides Periodic Surface s_ups_front {-l_ups_bottom_front,-l_in_front,l_ups_upper_front,l_buffu_front} = s_ups_back {l_ups_bottom_back,l_in_back,-l_ups_upper_back,-l_buffu_back}; Periodic Surface s_downs_front {l_downs_bottom_front,l_out_front,-l_downs_upper_front,-l_buffd_front} = s_downs_back {-l_downs_bottom_back,-l_out_back,l_downs_upper_back,l_buffd_back}; Periodic Surface s_connbuffs_front {l_buffers_front_bottom,l_buffd_front,l_buffers_front_upper,l_buffu_front} = s_connbuffs_back {l_buffers_back_bottom,l_buffd_back,l_buffers_back_upper,l_buffu_back}; //Periodic Surface s_inlet {l_in_bottom,l_in_upper,l_in_front,l_in_back} = s_outlet {l_out_bottom,l_out_upper,l_out_back,l_out_front}; Mesh.Optimize=1; Mesh.OptimizeNetgen=1; Physical Volume("volume") = {v_between_buffers,v_downs,v_ups}; Physical Surface("microramp") = {s_MR_upper,s_MR_back,s_MR_front}; Physical Surface("inlet") = {s_inlet}; Physical Surface("outlet") = {s_outlet}; Physical Surface("top") = {s_connbuffs_upper,s_downs_upper,s_ups_upper}; Physical Surface("front") = {s_connbuffs_front,s_downs_front,s_ups_front}; Physical Surface("back") = {s_connbuffs_back,s_downs_back,s_ups_back}; Physical Surface("bottom") = {s_connbuffs_bottom,s_downs_bottom,s_ups_bottom}; Last edited by fportela; March 8, 2013 at 06:21. |
|
March 8, 2013, 06:14 |
|
#9 |
Member
Felipe Alves Portela
Join Date: Dec 2012
Location: FR
Posts: 70
Rep Power: 14 |
I have noticed that this issue depends on how the transfinite surface is done. It seems like for some surfaces using the Right alignment results in the surface not being properly stored while for others this happens with the Left alignment; using the Alternate alignment (as I was trying) therefore results in parts of the surfaces disappearing during the conversion...
So, any idea on how to solve this? I managed to get a successful conversion by making the surfaces transfinite as below: Code:
// Mesh upstream Transfinite Line {-l_ups_bottom_front,l_ups_upper_front,l_ups_bottom_back,-l_ups_upper_back} = n_upstream_sides ; Transfinite Line {l_buffu_bottom,l_buffu_upper,l_buffu_front,-l_buffu_back,l_in_bottom,l_in_upper,-l_in_front,l_in_back} = n_inlet; Transfinite Surface {s_buffu} = {} Left; Transfinite Surface {s_ups_front} = {} Left; Transfinite Surface {s_ups_back} = {} Left; Transfinite Surface {s_ups_bottom} = {} Right; Transfinite Surface {s_ups_upper} = {} Right; Transfinite Surface {s_inlet} = {} Left; Transfinite Volume {v_ups}; // Mesh downstream Transfinite Line {l_downs_bottom_front,-l_downs_upper_front,-l_downs_bottom_back,l_downs_upper_back} = n_downstream_sides ; Transfinite Line {l_buffd_bottom,l_buffd_upper,-l_buffd_front,l_buffd_back,l_out_bottom,l_out_upper,l_out_front,-l_out_back} = n_outlet; Transfinite Surface {s_buffd} = {} Left; Transfinite Surface {s_downs_front} = {} Left; Transfinite Surface {s_downs_back} = {} Left; Transfinite Surface {s_downs_bottom} = {} Right; Transfinite Surface {s_downs_upper} = {} Right; Transfinite Surface {s_outlet} = {} Left; Transfinite Volume {v_downs}; |
|
March 8, 2013, 07:02 |
|
#10 |
Senior Member
Hisham Elsafti
Join Date: Apr 2011
Location: Braunschweig, Germany
Posts: 257
Blog Entries: 10
Rep Power: 17 |
Hi
I think you are totally right. What happens is that some command you apply on the surfaces actually creates new surfaces out of them. You can check that in the ".msh" file as you have geometrical surfaces with tags like 3436 for your triangle elements with type (2). And because the physical surfaces are assigned to much fewer number they are assigned to default. So maybe try without the alternate command! just: Code:
Transfinite Surface {s_buffu,s_ups_front,s_ups_back,s_ups_bottom,s_ups_upper,s_inlet}; Another thing you have very strange elements near the microramp patch (very high aspect ratio) they are not a problem now but I think they will give some hard time with conversion. Hisham |
|
March 8, 2013, 09:01 |
|
#12 |
Member
Felipe Alves Portela
Join Date: Dec 2012
Location: FR
Posts: 70
Rep Power: 14 |
It's not really a solution since the cells don't look as I wanted them to, but I guess this will have to work for now
Thanks for the help! |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Foam::error::PrintStack | almir | OpenFOAM Running, Solving & CFD | 92 | May 21, 2024 08:56 |
Problem using AMI | vinz | OpenFOAM Running, Solving & CFD | 298 | November 13, 2023 09:19 |
Possible bug with stitchMesh and cyclics in OpenFoam | Jack001 | OpenFOAM Pre-Processing | 0 | May 21, 2016 09:00 |
[blockMesh] Merging edge patches | Yosmcer | OpenFOAM Meshing & Mesh Conversion | 11 | November 16, 2014 15:51 |
How to define patches after gmshToFoam ? | seb_j | OpenFOAM | 8 | July 13, 2011 10:25 |