This email from eh.asgari@gmail.com originates from outside Imperial. Do not click on links and attachments unless you recognise the sender. If you trust the sender, add them to your safe senders list to disable email stamping for this address.

 

Dear All

I could find a solution to my problem with 2-D mesh in Gmsh. The issue was that Gmsh couldn't recognize the boundary curves.

Here is the solution: 
1. I exported the mesh to ICEM CFD and used its "FEA Solve Options" to convert the mesh to Nastran format. Note than on the "Write/View Input File" tab, both "Shell Elements" and "Bar Elements" should set to "All".

2. After converting the mesh to Nastran format, open it in Gmsh. By default, Gmsh won't show 1-D boundary elements. To fix this, navigate to "All general options", under "Mesh", activate "1D elements" on the "Visibility" tab. Now, you will be able to select curves and specify them to Physical groups.

I hope this helps.

Kind regards
syavash



On Tue, May 9, 2023, 18:59 Ehsan Asgari <eh.asgari@gmail.com> wrote:
Thank you Tsing-Hsuan.

I appreciate you sharing your code. I will look into it. I will let you know if I find a more suitable solution.

Kind regards
syavash

On Tue, May 9, 2023, 16:36 Ma, Ting-Hsuan <TIM48@pitt.edu> wrote:
Hi,

I would recommend using the script method in Gmsh to add in the physical groups for 1d elements. A lot of time they are in incremental numbers, so it is easy to iterate through them. Below I'll provide the python code I wrote for my own use. I will emphasize here that you should double check the curves are set up in incremental numbers before applying the codes below.

##### Below this section is setting parameters for NekMesh #####
## Note that this could be done in Gmsh, but it's faster to automate it
## Note that Curve loop will need to be defined after all physical groups like
#  inlet, outlet, top, and bottom boundary. If this is not done in order,
#  mesh verticies will exhibit a no-slip boundary condition onto the interior
#  flow. The order is paramount!
loopRange = range(1,result.shape[0])
botRange = range(0,rows.shape[0]-1)
outRange = range(rows.shape[0]-1, (rows.shape[0]+inlet.shape[0]))
topRange = range((rows.shape[0]+inlet.shape[0]), (rows.shape[0]+inlet.shape[0]+top.shape[0])-1)
inRange = range((rows.shape[0]+inlet.shape[0]+top.shape[0])-1, result.shape[0])
idx = loopRange[-1]+2 # define physical groups for rest of the assignment

## Bottom Boundary
print("//+")
print('Physical Curve("Bottom", %d) = {' % (int(idx)), end= '')
for i in botRange:
    if i == botRange[-1]:
      print("%d" % (int(i)+1), end = '};\n')
      print("//+")
    else:
      print("%d," % (int(i)+1), end = '')

## Outlet
print('Physical Curve("Outlet", %d) = {' % (int(idx+1)), end= '')
for i in outRange:
    if i == outRange[-1]:
      print("%d" % (int(i)+1), end = '};\n')
      print("//+")
    else:
      print("%d," % (int(i)+1), end = '')

## Top Boundary
print('Physical Curve("Top", %d) = {' % (int(idx+2)), end= '')
for i in topRange:
    if i == topRange[-1]:
      print("%d" % (int(i)+1), end = '};\n')
      print("//+")
    else:
      print("%d," % (int(i)+1), end = '')
     
## Inlet
print('Physical Curve("Inlet", %d) = {' % (int(idx+3)), end= '')
for i in inRange:
    if i == inRange[-1]:
      print("%d" % (int(i)+1), end = '};\n')
      print("//+")
    else:
      print("%d," % (int(i)+1), end = '')
     
# Physical Groups
print("Curve Loop(1) = {", end="")
for i in loopRange:
    print("%d," % (int(i)), end="")
    if i == loopRange[-1]:
      print("%d" % (int(i)+1), end="};\n")
      print("//+")

print("Plane Surface(1) = {1};")
print("//+")
print('Physical Surface("Fluid", %d) = {1};' % (int(idx+4)) )