Boundary ID after n2to3

45 views
Skip to first unread message

Sai Pranay

unread,
Aug 30, 2024, 9:55:23 AM8/30/24
to Nek5000
Hello all, 

Is there a way to get the boundary ID info of all the surfaces after performing n2to3 subroutine. i.e. from a .re2 format mesh
I need this info to get information out of the wall boundary ID. 
I tried converting the mesh into a .rea format but I couldn't decipher the info there. 

Do let me know if there is way to do it.

Thanks

YuHsiang Lan

unread,
Aug 30, 2024, 10:19:03 AM8/30/24
to Nek5000
Hi,

n2to3 should preserve the boundaryID of the original 2D mesh and extrude it to all elements on the face 1 to face 4.
Face 5 and 6 will use user's input and store BC in CBC.

In userdat2, you can do something like this

do iel=1,nelt
do ifc=1,4   ! convert bc id to cbc based on original 2D mesh
   if (boundaryID(ifc,iel).eq.1) cbc(ifc,iel,1) = 'W  '
enddo
do ifc=5,6   ! convert face 5-6 (z direction) from n2to3
   if (cbc(ifc,iel,1).eq.'v  ') cbc(ifc,iel,1) = 'W  '
enddo
enddo

Personally, I like putting use CBC to carry my boundary conditions. And, I use 'W  ', 'W01', 'W02', ... to act as a the boundaryID.
Therefore, if you want to distinguish the newly generated BC on face 5-6 and some other 'W  ', you can put 'W01' in n2to3 and convert it in userdat2.

Hope this helps,
Yu-Hsiang
--

Sai Pranay

unread,
Aug 30, 2024, 11:43:54 AM8/30/24
to Nek5000
Thank you

I donot want to convert/assign IDs, just see/visualise what ID's are assigned where. 


Pranay

Filipe Brandao

unread,
Dec 12, 2025, 1:16:09 PM12/12/25
to Nek5000
I am facing similar issue here. I have a 2D mesh created with gmsh with only 3 boundary IDs: 1- inlet, 2 - outlet, 3 - walls.

When executing the n2to3 command, we are asked to inform the boundary type for boundaries 5 and 6. What about boundary ID 4? I am prescribing the following in the .usr file :

    call setbc(1,1,'v  ') ! inflow
    call setbc(2,1,'O  ') ! outlet
    call setbc(3,1,'W  ') ! wall

    call setbc(5,1,'P  ')
    call setbc(6,1,'P  ')

I am not setting anything to ID 4 because I am assuming I would not have one. Is this correct? How can I find out?

Filipe


YuHsiang Lan

unread,
Dec 13, 2025, 3:21:38 PM12/13/25
to Nek5000
Hi Filipe,

setbc(bid, ifld, cbc3) assign the BC for ifield = ifld and maps boundaryID = bid to cbc3.
To use it, you need to make sure your boundaryID actually contains that ID tag.

n3to3 doesn't assign boundaryID.
When doing extrusion, it keeps the boundaryID and CBC on the 2D perimeter, but it only assigns CBC, not boundaryID, to the new faces on Zmin and Zmax.

Although n2to3 mention "(5)" and "(6)" boundary condition, it means the ordering of faces, not boundaryID.
  Zmin = face 5 of the bottom layer elements
  Zmax = face 6 of the top layer elements

For your case:
1. You probably don't have IDs 4, 5 or 6 in your mesh if your 2D mesh never had them in the first place.
2. You don't need to do anything for Zmin and Zmax faces because n2to3 already tagged them with your inputs, and Nek will read those into CBC.

Hope this helps,
Yu-Hsiang
--


Filipe Brandao

unread,
Dec 15, 2025, 3:10:35 PM12/15/25
to Nek5000
Hi YuHsiang,

So in usrdat or usrdat2, I would only need to set BCs for IDs 1, 2 and 3 correct?
Reply all
Reply to author
Forward
0 new messages