Grid Convergence Equivalent for Spectral-Element

590 views
Skip to first unread message

Akshay Patil

unread,
Jan 27, 2020, 7:17:43 PM1/27/20
to nek...@googlegroups.com
Dear Nek Nerds,

I have been playing around with nek5000 for a while now and wanted to know a few things which have been confusing for me since I mostly worked with Finite-Volume codes:

1. How do I estimate the grid resolution when using genbox. For example: If I wanted to have a grid resolution of 0.001 m or 1mm, how does that translate to the settings for N in case.box file?

2. I am fairly new to nek5000 and have been testing out the code for simple Hagen-Poiseuille flow with N=8,16,32,64 etc to check what exactly changes when I do this. However, case compilation  for 32^3 case when the linear dimensions are 1m x 1m x 1m requires vast computations resources and fails to compile on my server machine.

3. How can I add a time-dependent forcing term (say) sin(w*t).

Thanks a lot in advance for your response and looking forward to hearing any replies to my questions! 


Regards,
Akshay Patil
 

Tanmoy Chatterjee

unread,
Jan 27, 2020, 9:49:06 PM1/27/20
to Akshay Patil, nek...@googlegroups.com
Hi Akshay,
 
1.N alone cannot decide grid resolution. N is the polynomial order in x,yz direction for the series expansion of velocity, temperature etc inside a spectral element. Put in simple terms, inside each element you have N+1 grid points in each direction, inside the spectral element. Spectral elements are pretty much like" hexahedral finite volumes" you use to discretize a geometry. So very very roughly, your grid size in one direction ~ (element length in that direction)/N. It's much more complicated than that since these N+1 are nonuniformly distributed and depends on the roots of Legendre polynomial of order N. Makes Sense?

2. Depends on what is your array size and whether it can fit in memory. Typically in nek data structures are of the form (lx1,ly1, lz1,lelv), where lx1=ly1=lz1=N+1, lelv= local number of elements that fits in one processor memory.  Typically it's a good idea to have a tessalation of conforming spectral element grids for the domain, and within each domain, the order of polynomial for the variable expansion is ~ 7-9.

3. A code snippet can be written inside userf() subroutine ( found in .usr file) as follows.

subroutine userf(........)
include 'SIZE'
include 'TOTAL'
<….some declarations ….>

real omega
omega = <some value>
ffx = sin(omega*time)
ffy = 0.0
ffz = 0.0

return 
end

-------------------------

hope this helps,
Tanmoy 
--
You received this message because you are subscribed to the Google Groups "Nek5000" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nek5000+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nek5000/CACqPjWG8dMO9mO_LP7GAbDy6yk7F%2B3OEd9hS%2BHXTPdQnswkgpg%40mail.gmail.com.

Akshay Patil

unread,
Feb 26, 2020, 9:57:01 PM2/26/20
to Tanmoy Chatterjee, nek...@googlegroups.com
Hi Tanmoy and Nek Nerds,

I know this question was asked earlier however, I am curious how I could evaluate my grid resolution. The problem I am facing is something like this. I want a to have a target grid resolution of say 10 mm in the Vertical direction for a given geometry of 1x1x1m which is periodic in streamwise and lateral direction and has a Symmetry boundary condition on the top and a no slip at the bottom. How can I ensure using genbox that this is what I get? I kind of roughly followed what was said previously about the resolution being ~ (Element Length)/N.


Another approach I tried was to force a Gmsh mesh to the required mesh however I failed to specify a boundary condition as marked in bold above in userbc(). I was successful in specifying the periodic boundary conditions using gmsh2nek however the later part of specifying the symmetry and no slip boundary condition using this tool weren't clear to me. I would be grateful if you can help me with this issue. 

Sorry for the long question! Thanks in advance! :)
--
Regards,
Akshay Patil

Jun Fang

unread,
Feb 26, 2020, 10:28:44 PM2/26/20
to Akshay Patil, Tanmoy Chatterjee, nek...@googlegroups.com

Hi Akshay,

The implementation of BCs consists of at least two parts for Nek cases, that is, the specification of (i) BC tags and (ii) the BC values.
The BC values can be specified in userbc, such as the velocity vectors for inlet velocity BC (with tag ‘v ‘, note that the BC tag is always a character with a length of 3, and it is v + 2 spaces here).
If you generated the mesh from genbox, the BC tags should be specified in your box file. such as the periodic hill example in Nek online tutorial (https://nek5000.github.io/NekDoc/tutorials/perhill.html)

-2                     spatial dimension (will create box.re2)
1                      number of fields
#
#    comments: two dimensional periodic hill
#
#========================================================
#
Box                                       hillp
-22 8                                     Nelx  Nely
0.0 9.0 1.                                x0 x1 ratio
0.0 0.1 0.25 0.5 1.5 2.5 2.75 2.9 3.0     y0 y1 ratio
P  ,P  ,W  ,W                             BC's:  (cbx0, cbx1, cby0, cby1)

If the mesh is generated from GMSH, the periodic BC will be handled by gmsh2nek, and all other BC’s can be implemented in user file. The BC tags can be specified in usrdat2 and BC values be given in userbc. To do that, you should first tag your boundary faces with “Physical group” ids in GMSH. That information will be saved in bc(5,ifc,iel,1). An example in usrdat2 can be like

      do iel=1,nelv
      do ifc=1,2*ndim
        id_face = bc(5,ifc,iel,1)
        if (id_face.eq.1) then        ! surface 1 for inlet
           cbc(ifc,iel,1) = 'v  '
        elseif (id_face.eq.2) then    ! surface 2 for outlet 
           cbc(ifc,iel,1) = 'O  '
        elseif (id_face.eq.3) then    ! surface 3 for wall
           cbc(ifc,iel,1) = 'W  '
        endif
      enddo
      enddo

Here I give tags of inlet BC to the face in “Physical group” 1 and outlet to 2 and wall to 3. In your case, you also have symmetry BC, of which the tag is ‘SYM’.
Please let us know if you have any further questions.

Best,
Jun




--
Jun Fang, Ph.D. - Argonne National Laboratory (630)252-4561

Akshay Patil

unread,
Feb 26, 2020, 10:34:25 PM2/26/20
to Jun Fang, Tanmoy Chatterjee, nek...@googlegroups.com
Dear Jun,

Beautiful! That is the exact explanation I was looking for (the second part). Thanks a lot, also just curious as to how do I look for information beyond the docs? Is there a larger tutorial database? The reason why I ask this is because I am a PhD student who will be potentially working with nek5000 for the rest of the 5 years and it would be great to kind of have some rulebook to play by. I would appreciate if you can point me in the right direction with regards to this. Once again, thank you so much for your help.


--
Regards,
Akshay Patil

Jun Fang

unread,
Feb 26, 2020, 11:05:17 PM2/26/20
to Akshay Patil, Tanmoy Chatterjee, nek...@googlegroups.com
Hi Akshay, 

The online Nek doc only covers the basics to help users get started. I don't think we have any another larger tutorial doc. 
The Google group is our major platform to communicate Nek related experience and expertise. When you encounter an issue, the first step is always to search the past posts in the group. Chances are the same question has been asked and answered before. If not, feel free to post your question, and we are all here to help. As a graduate student, you can try to follow the papers published by other Nek users. It will give you a good idea about what Nek can do. If there is any specific Nek functionality that could potentially benefit your research, you are also encouraged to directly contact the corresponding authors.

Best,
Jun 

Lane Carasik

unread,
Feb 28, 2020, 2:16:02 PM2/28/20
to Nek5000
Hey all,

Is there anything in particular you are looking for in terms of tutorials or documentation? We can add it to a list of things to try and develop as a community.

Akshay Patil

unread,
Feb 28, 2020, 2:44:24 PM2/28/20
to Lane Carasik, Nek5000
Dear Lane,

Just adding my 2cents to your list. I think what would benefit the tutorials/documentation is an extended code guide. I think that is/has been the hardest aspect for me at least to wrap my head around writing sensible piece of code to get a particular job done for my specific case. When I say a code guide I mean something similar to the OpenFOAM platform referenced in the hyperlink below. I am aware that it is possible to read through the code by looking at the source files itself however, I think this would be highly time consuming to start doing code reading when one does not even know where to start with the basics like how does nek5000 handle the geometry information, how is it stored in memory etc. 


For example having small examples which portray different averaging techniques individually. Could be something very simple as taking a volume average of the velocity field or a scalar field. How does one implement a scalar equation in a simple 2D case with an initial condition etc. I had a really hard time trying to dissect the turbChannel case to get the things that I really wanted to do, which as basic averaging. I know it might sound lazy on my part to have this resource readymade but it definitely helps in speeding up the learning curve. 

Additionally, I would be more than happy to contribute in any way possible. I only got started with nek5000 and really like the program capabilities. 

Thanks for hearing me out!

On Fri, Feb 28, 2020 at 11:16 AM Lane Carasik <lbca...@vcu.edu> wrote:
Hey all,

Is there anything in particular you are looking for in terms of tutorials or documentation? We can add it to a list of things to try and develop as a community.

--
You received this message because you are subscribed to the Google Groups "Nek5000" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nek5000+u...@googlegroups.com.


--
Regards,
Akshay Patil

Nadeem Malik

unread,
Feb 28, 2020, 4:06:47 PM2/28/20
to Nek5000

Dear Neks,

May I endorse this last point by Akshay. I myself have been struggling with the code development -- very difficult if you have no previous experience using nek5000. I know nek5000 does not offer support in this, but because there is also no detailed documentation of the code (like OpenFoam does for example) it is doubly difficult.

Regards
Nadeem

To unsubscribe from this group and stop receiving emails from it, send an email to nek5000+unsubscribe@googlegroups.com.


--
Regards,
Akshay Patil

Reply all
Reply to author
Forward
0 new messages