grid

Module

Description

$Id$

** AUTOMATIC CPARAM.INC GENERATION ************************ Declare (for generation of cparam.inc) the number of f array variables and auxiliary variables added by this module

PENCILS PROVIDED x_mn; y_mn; z_mn; r_mn; r_mn1 PENCILS PROVIDED phix; phiy PENCILS PROVIDED pomx; pomy PENCILS PROVIDED rcyl_mn; rcyl_mn1; phi_mn PENCILS PROVIDED evr(3); rr(3); evth(3)


Quick access

Variables:

calc_pencils_grid, calc_pencils_grid_pencpar, calc_pencils_grid_std, find_star_bisection, grid_profile, grid_profile_0d, grid_profile_1d, sus_map_0d, sus_map_1d, symmetrize_grid

Routines:

box_vol(), calc_bound_coeffs(), coarsegrid_interp(), construct_grid(), construct_serial_arrays(), coords_aux(), find_star(), get_dvol(), get_grid_mn(), grid_bound_data(), initialize_grid(), inverse_grid(), pencil_criteria_grid(), pencil_interdep_grid(), real_to_index(), save_grid(), set_coorsys_dimmask()

Needed modules

Variables

  • grid/calc_pencils_grid [public]
  • grid/calc_pencils_grid_pencpar [private]
  • grid/calc_pencils_grid_std [private]
  • grid/find_star_bisection [private]
  • grid/generate_halfgrid [private]
  • grid/grid_profile [public]
  • grid/grid_profile_0d [private]
  • grid/grid_profile_1d [private]
  • grid/sus_map_0d [private]
  • grid/sus_map_1d [private]
  • grid/symmetrize_grid [private]

Subroutines and functions

subroutine  grid/construct_grid(x, y, z, dx, dy, dz)

Constructs a non-equidistant grid x(xi) of an equidistant grid xi with grid spacing dxi=1. For grid_func=’linear’ this is equivalent to an equidistant grid.

dx_1 and dx_tilde are the coefficients that enter the formulae for the 1st and 2nd derivative:

``df/dx’’ = ``df/dxi’’ * dx_1 ``d2f/dx2’’ = ``df2/dxi2’’ * dx_1**2 + dx_tilde * ``df/dxi’’ * dx_1

These coefficients are also very useful when adapting grid dependend stuff such as the timestep. A simple substitution

1./dx -> dx_1

should suffice in most cases.

25-jun-04/tobi+wolf: coded
3-mar-15/MR: calculation of d[xyz]2_bound added: contain twice the distances of

three neighbouring points from the boundary point

9-mar-17/MR: removed unneeded use of optional parameters in calls to grid_profile 6-mar-18/MR: moved call construct_serial_arrays here from initialize_grid

Parameters:
  • x (mx) [real,out]

  • y (my) [real,out]

  • z (mz) [real,out]

  • dx [real,out]

  • dy [real,out]

  • dz [real,out]

Use :

cdata (xprim(), yprim(), zprim(), dx_1(), dx_tilde(), dy_1(), dy_tilde(), dz_1(), dz_tilde())

Call to:

find_star(), fatal_error(), grid_bound_data(), construct_serial_arrays(), coords_aux(), box_vol(), yyinit(), warning(), remove_prof(), not_implemented()

subroutine  grid/set_coorsys_dimmask()

Sets switches for the different coordinate systems.

18-dec-15/MR: outsourced from initialize_grid 16-jan-17/MR: added initialization of dimensionality mask.

Call to:

fatal_error(), construct_serial_arrays(), coords_aux(), box_vol(), yyinit(), warning(), remove_prof(), not_implemented()

subroutine  grid/initialize_grid()

Coordinate-related issues: nonuniform meshes, different coordinate systems

20-jul-10/wlad: moved here from register 3-mar-14/MR: outsourced calculation of box_volume into box_vol 29-sep-14/MR: outsourced calculation of auxiliary quantities for curvilinear

coordinates into coords_aux; set coordinate switches at the beginning

9-jun-15/MR: calculation of Area_* added

18-dec-15/MR: outsourced setting of switches to set_coords_switches; added

initialization of Yin-Yang grid; added dimensionality mask: lists the indices of the non-degenerate directions in the first dimensionality elements of dim_mask

10-oct-17/MR: avoided communication in calculation of r_int and r_ext 10-jan-17/MR: moved call construct_serial_arrays to beginning

Use :

sub (remove_prof()), mpicomm, io (lcollective_io()), general (indgen(), itoa(), find_proc())

Call to:

construct_serial_arrays(), coords_aux(), fatal_error(), box_vol(), yyinit(), warning(), remove_prof(), not_implemented()

subroutine  grid/coarsegrid_interp(f[, ivar1[, ivar2]])
Parameters:
  • f (,,*,*) [real]

  • ivar1 [integer]

  • ivar2 [integer]

Use :

general (ioptest())

Call to:

fatal_error(), not_implemented()

subroutine  grid/save_grid([lrestore])

Saves grid into local statics (needed for downsampled output)

6-mar-14/MR: coded

Parameters:

lrestore [logical]

Use :

general (loptest())

Call to:

fatal_error(), not_implemented()

subroutine  grid/coords_aux(x, y, z)

6-mar-14/MR: outsourced from initialize_grid

Parameters:
  • x (*) [real]

  • y (*) [real]

  • z (*) [real]

Call to:

not_implemented(), fatal_error()

subroutine  grid/box_vol()

calculates box volume

3-mar-14/MR: outsourced from initialize_grid 6-mar-14/MR: changed into subroutine setting global variable box_volume

Call to:

not_implemented(), fatal_error()

subroutine  grid/pencil_criteria_grid()

All pencils that this special module depends on are specified here.

15-nov-06/tony: coded

Call to:

not_implemented(), fatal_error()

subroutine  grid/pencil_interdep_grid(lpencil_in)

Interdependency among pencils provided by this module are specified here.

15-nov-06/tony: coded

Parameters:

lpencil_in (npencils) [logical]

Call to:

not_implemented(), fatal_error()

function  grid/find_star(xi_lo, xi_up, x_lo, x_up, x_star, grid_func[, param2])

Finds the xi that corresponds to the inflection point of the grid-function by means of a newton-raphson root-finding algorithm.

25-jun-04/tobi+wolf: coded

Parameters:
  • xi_lo [real,in]

  • xi_up [real,in]

  • x_lo [real,in]

  • x_up [real,in]

  • x_star [real,in]

  • grid_func [character,in]

  • param2 (3) [real]

Return:

xi_star [real]

Called from:

in_solid_cell()

Call to:

fatal_error(), inverse_grid(), calc_coeffs_1(), calc_bound_coeffs()

subroutine  grid/real_to_index(n, x, xi)

Transforms coordinates in real space to those in index space. In the calling code, x corresponds to the fp array.

10-sep-15/ccyang: coded.

Parameters:
  • n [integer,in,]

  • x (n,3) [real,in]

  • xi (n,3) [real,out]

Call to:

inverse_grid(), fatal_error(), calc_coeffs_1(), calc_bound_coeffs()

subroutine  grid/inverse_grid(dir, x, xi[, local])

Transform the x coordinates in real space to the xi coordinates in index space in dir direction, where dir = 1, 2, or, 3. If local is present and .true., the index space is with respect to the local grid.

24-dec-14/ccyang: coded.

Parameters:
  • dir [integer,in]

  • x (*) [real,in]

  • xi (*) [real,out]

  • local [logical,in,]

Use :

general (arcsinh(), itoa())

Call to:

fatal_error(), calc_coeffs_1(), calc_bound_coeffs()

subroutine  grid/construct_serial_arrays([lprecise_symmetry])

The arrays xyz are local only, yet sometimes the serial array is needed. Construct here the serial arrays out of the local ones, but gathering them processor-wise and broadcasting the constructed array. This is only done in start time, so legibility (3 near-copies of the same code) is preferred over code-reusability (one general piece of code called three times).

19-oct-10/wlad: coded 08-may-12/ccyang: include dx_1, dx_tilde, … arrays 25-feb-13/ccyang: construct global coordinates including ghost cells.

Parameters:

lprecise_symmetry [logical]

Use :

mpicomm (mpisend_real(), mpirecv_real(), mpibcast_real(), mpiallreduce_sum_int(), mpi_comm_pencil()), general (loptest(), find_proc())

Call to:

calc_coeffs_1(), calc_bound_coeffs()

subroutine  grid/get_grid_mn()

Gets the geometry of the pencil at each (m,n) in the mn-loop.

03-jul-13/ccyang: extracted from Equ.

obsolete: if (old_cdtv) then
The following is only kept for backwards compatibility. Will be deleted in the future.

dxyz_2 = max(dx_1(l1:l2)**2, dy_1(m)**2, dz_1(n)**2)

else obsolete

Call to:

calc_coeffs_1(), calc_bound_coeffs()

subroutine  grid/get_dvol(mm, nn, dv)

!$omp declare target

Parameters:
  • mm [integer,in]

  • nn [integer,in]

  • dv (nx) [real,out]

Call to:

calc_coeffs_1(), calc_bound_coeffs()

subroutine  grid/calc_bound_coeffs(coors, coeffs)

Calculates the coefficients of the 6th order difference formula for the first derivative at the boundary points. The grid is provided in form of the coordinate vector coors.

26-mar-15/MR: extracted from deriv_alt.

Parameters:
  • coors (*) [real,in]

  • coeffs (1 + 2 * nghost,2) [real,out]

Use :

deriv (calc_coeffs_1())

Called from:

in_solid_cell(), find_star(), get_dvol(), calc_bound_coeffs()

Call to:

calc_coeffs_1(), calc_bound_coeffs()

subroutine  grid/grid_bound_data()

Assign local boundary data after the grid is constructed.

08-apr-15/MR: coded 23-nov-20/ccyang: added xyz[01]_loc and Lxyz_loc

Use :

mpicomm (mpiallreduce_max())

Call to:

calc_bound_coeffs()