Error in accessing neighbouring nodes


In order to incorporate a new term, I am dsicretizing a fourth order term for which I need to access nodes which are second adjacent ( for example, north of north node) and so on.

Like done for north node as, i_left = equation_stencil%c(-1,0,0) , I tried to make similar changes and declared a variable i_left_left=equation_stencil%c(-2,0,0) and so on.
There was no problem in compilation.
However, while running the code, there was an error:
Subscript array C has value -2 which is less than lower bound of -1.

I searched in the files and found that a similar declaration has already been used ( for example, variable i_front2 and so on).
May you please help in this regard.
( The changes are being made in the file " discretize_cell_transport_equation.f90"

stencil size depends on the implicit advection scheme used. If you choose o2_upwind as advection scheme you will solve your problem. But you may need to use explicit scheme. in this case, choose directly in the
fortran code the stencil you need. In the routine

src/notus/ui/tree/numerical_parameters/species_transport/finalization.f90 (and/or energy/finalization.f90 depending on the equation you solve)


  else if (species_transport_advection_term_discretization_type == explicit_discretization) then
     ! Explicit discretization
     stl_type = STENCIL_1_STAR


     stl_type = STENCIL_2_STAR ! 9 pts in 2D, WW W P E EE, ...


     stl_type = STENCIL_2_SQUARE !25 points (include diagonals)

See you

Thanks for your kind reply. if I understood correctly, then doing this initializes 9 point stencil even though the scheme may correspond to lower point ( for example central difference is 5 point).
And as there is not implicit scheme ( currently) having 9 point stencil, the procedure described by you suits best.


Yes. The matrix size is larger, you can fill the null element as you need.
(implicit advection second order upwind scheme is a 9 point stencil scheme but you don’t use it)


In regard to your previous reply, I would like to seek one more clarification:

I changed the stencil condition for explicit term. However, the term I am adding fourth derivative, I would like to add it implicitly. Thus, wouldn’t the following be appropriate:

  1. Initialize implicit second order centered_o2
  2. In finalization, set stencil_2_star for species transport.
  3. In “mod_discretize_cell_transport_equation” , add the relevant additions to be done in the matrix.

( I have done the above described procedure).

Also, while changing matrix,
is the following call correct ( for l and ia)
do k=ks,ke
do j=js,je
do i=is,ie

		   l=equation_ls_map%l(i,j,k) - 1  
		   ia=l*equation_stencil%size + 1 

. enddo

Thank you

Hello Deewakar,
As in other posts you asked questions about WENO scheme, I supposed that you are using explicit scheme for the advection term. But if you use implicit second order scheme, your change is OK.
Your loop is OK
See you

Thanks for your prompt response.
In the same loop, if I need to access a face variable while discretization ( say a variable B),
then for writing at P node (i,j,k), then w and e node (face) can be represented by
B%u(i,j,k) and B%u(i+1,j,k), receptively.
Similarly for y direction, with B%v(i,j,k) for s and B%v(i,j+1,k) for n node.

Is this correct?

yes that’s fine
see you