Octopus
derivatives_oct_m Module Reference

This module calculates the derivatives (gradients, Laplacians, etc.) of a function. More...

Detailed Description

This module calculates the derivatives (gradients, Laplacians, etc.) of a function.

Note
the function whose derivative is to be calculated has to be defined (1:mesh%np_part), while the (1:mesh%np) values of the derivative are calculated.

Data Types

type  derivatives_handle_batch_t
 handle to transfer data from the start() to finish() calls. More...
 
type  derivatives_t
 class representing derivatives More...
 

Functions/Subroutines

subroutine, public derivatives_init (der, namespace, space, coord_system, order)
 
subroutine, public derivatives_end (der)
 
subroutine derivatives_get_stencil_lapl (der, space, coord_system)
 
subroutine, public derivatives_lapl_diag (der, lapl)
 Returns the diagonal elements of the Laplacian, needed for preconditioning. More...
 
subroutine derivatives_get_stencil_grad (der)
 
subroutine, public derivatives_build (der, namespace, space, mesh, qvector, regenerate, verbose)
 build the derivatives object: More...
 
subroutine get_rhs_lapl (der, polynomials, rhs)
 
subroutine get_rhs_grad (der, polynomials, dir, rhs)
 
subroutine derivatives_make_discretization (namespace, dim, periodic_dim, mesh, masses, pol, rhs, nderiv, op, name, verbose)
 
logical function derivatives_overlap (this)
 
subroutine, public derivatives_get_lapl (this, namespace, op, space, name, order)
 
logical function, dimension(1:this%mesh%np), public derivatives_get_inner_boundary_mask (this)
 This function tells whether a point in the grid is contained in a layer of the width of the stencil between the last row of points in the grid. More...
 
real(real64) function, public derivatives_lapl_get_max_eigenvalue (this)
 Get maximum eigenvalue of discrete Laplacian. For the star and star_general stencils, use the Fourier transform of the stencil evaluated at the maximum phase to get an upper bound on the spectrum. For all other stencils, use the upper bound from the continuum. More...
 
subroutine, public dderivatives_perform (op, der, ff, op_ff, ghost_update, set_bc, factor)
 apply a nl_operator to a mesh function More...
 
subroutine, public dderivatives_lapl (der, ff, op_ff, ghost_update, set_bc, factor)
 apply the Laplacian to a mesh function More...
 
subroutine, public dderivatives_grad (der, ff, op_ff, ghost_update, set_bc, to_cartesian)
 apply the gradient to a mesh function More...
 
subroutine, public dderivatives_partial (der, ff, op_ff, dir, ghost_update, set_bc)
 apply the partial derivative along dir to a mesh function More...
 
subroutine, public dderivatives_div (der, ff, op_ff, ghost_update, set_bc, to_cartesian)
 apply the divergence operator to a vector of mesh functions More...
 
subroutine, public dderivatives_curl (der, ff, op_ff, ghost_update, set_bc)
 apply the curl operator to a vector of mesh functions More...
 
subroutine, public dderivatives_test (this, namespace, repetitions, min_blocksize, max_blocksize)
 unit test for derivatives More...
 
subroutine, public dderivatives_batch_start (op, der, ff, opff, handle, ghost_update, set_bc, factor)
 apply a non-local operator to a batch (1st part) More...
 
subroutine, public dderivatives_batch_finish (handle, async)
 apply a non-local operator to a batch (2nd part) More...
 
subroutine, public dderivatives_batch_perform (op, der, ff, opff, ghost_update, set_bc, factor, async)
 apply an operator to a bach of mesh functions More...
 
subroutine, public dderivatives_batch_grad (der, ffb, opffb, ghost_update, set_bc, to_cartesian, metric, factor)
 apply the gradient to a batch of mesh functions More...
 
subroutine dbatch_vector_uvw_to_xyz (der, coord_system, uvw, xyz, metric)
 transform a vector of batches from affine to cartesian coordinates More...
 
subroutine, public dderivatives_batch_curl (der, ffb, ghost_update, set_bc)
 apply the curl to a batch of mesh functions More...
 
subroutine, public dderivatives_batch_curl_from_gradient (der, ffb, gradb)
 calculate the curl from a batch and its gradient More...
 
subroutine, public dderivatives_batch_div (der, ffb, opffb, ghost_update, set_bc, to_cartesian)
 calculate the divergence of a vector of batches More...
 
subroutine, public zderivatives_perform (op, der, ff, op_ff, ghost_update, set_bc, factor)
 apply a nl_operator to a mesh function More...
 
subroutine, public zderivatives_lapl (der, ff, op_ff, ghost_update, set_bc, factor)
 apply the Laplacian to a mesh function More...
 
subroutine, public zderivatives_grad (der, ff, op_ff, ghost_update, set_bc, to_cartesian)
 apply the gradient to a mesh function More...
 
subroutine, public zderivatives_partial (der, ff, op_ff, dir, ghost_update, set_bc)
 apply the partial derivative along dir to a mesh function More...
 
subroutine, public zderivatives_div (der, ff, op_ff, ghost_update, set_bc, to_cartesian)
 apply the divergence operator to a vector of mesh functions More...
 
subroutine, public zderivatives_curl (der, ff, op_ff, ghost_update, set_bc)
 apply the curl operator to a vector of mesh functions More...
 
subroutine, public zderivatives_test (this, namespace, repetitions, min_blocksize, max_blocksize)
 unit test for derivatives More...
 
subroutine, public zderivatives_batch_start (op, der, ff, opff, handle, ghost_update, set_bc, factor)
 apply a non-local operator to a batch (1st part) More...
 
subroutine, public zderivatives_batch_finish (handle, async)
 apply a non-local operator to a batch (2nd part) More...
 
subroutine, public zderivatives_batch_perform (op, der, ff, opff, ghost_update, set_bc, factor, async)
 apply an operator to a bach of mesh functions More...
 
subroutine, public zderivatives_batch_grad (der, ffb, opffb, ghost_update, set_bc, to_cartesian, metric, factor)
 apply the gradient to a batch of mesh functions More...
 
subroutine zbatch_vector_uvw_to_xyz (der, coord_system, uvw, xyz, metric)
 transform a vector of batches from affine to cartesian coordinates More...
 
subroutine, public zderivatives_batch_curl (der, ffb, ghost_update, set_bc)
 apply the curl to a batch of mesh functions More...
 
subroutine, public zderivatives_batch_curl_from_gradient (der, ffb, gradb)
 calculate the curl from a batch and its gradient More...
 
subroutine, public zderivatives_batch_div (der, ffb, opffb, ghost_update, set_bc, to_cartesian)
 calculate the divergence of a vector of batches More...
 

Variables

integer, parameter der_bc_zero_f = 0
 function is zero at the boundaries More...
 
integer, parameter der_bc_zero_df = 1
 first derivative of the function is zero More...
 
integer, parameter der_bc_period = 2
 boundary is periodic More...
 
integer, parameter, public der_star = 1
 
integer, parameter, public der_variational = 2
 
integer, parameter, public der_cube = 3
 
integer, parameter, public der_starplus = 4
 
integer, parameter, public der_stargeneral = 5
 
integer, parameter blocking = 1
 
integer, parameter non_blocking = 2
 
type(accel_kernel_tkernel_uvw_xyz
 
type(accel_kernel_tkernel_dcurl
 
type(accel_kernel_tkernel_zcurl
 

Function/Subroutine Documentation

◆ derivatives_init()

subroutine, public derivatives_oct_m::derivatives_init ( type(derivatives_t), intent(inout), target  der,
type(namespace_t), intent(in)  namespace,
class(space_t), intent(in)  space,
class(coordinate_system_t), intent(in)  coord_system,
integer, intent(in), optional  order 
)

Definition at line 278 of file derivatives.F90.

◆ derivatives_end()

subroutine, public derivatives_oct_m::derivatives_end ( type(derivatives_t), intent(inout)  der)

Definition at line 431 of file derivatives.F90.

◆ derivatives_get_stencil_lapl()

subroutine derivatives_oct_m::derivatives_get_stencil_lapl ( type(derivatives_t), intent(inout)  der,
class(space_t), intent(in)  space,
class(coordinate_system_t), intent(in)  coord_system 
)
private

Definition at line 463 of file derivatives.F90.

◆ derivatives_lapl_diag()

subroutine, public derivatives_oct_m::derivatives_lapl_diag ( type(derivatives_t), intent(in)  der,
real(real64), dimension(:), intent(out)  lapl 
)

Returns the diagonal elements of the Laplacian, needed for preconditioning.

Parameters
[out]lapllapl(meshnp)

Definition at line 494 of file derivatives.F90.

◆ derivatives_get_stencil_grad()

subroutine derivatives_oct_m::derivatives_get_stencil_grad ( type(derivatives_t), intent(inout)  der)
private

Definition at line 511 of file derivatives.F90.

◆ derivatives_build()

subroutine, public derivatives_oct_m::derivatives_build ( type(derivatives_t), intent(inout)  der,
type(namespace_t), intent(in)  namespace,
class(space_t), intent(in)  space,
class(mesh_t), intent(in), target  mesh,
real(real64), dimension(:), intent(in), optional  qvector,
logical, intent(in), optional  regenerate,
logical, intent(in), optional  verbose 
)

build the derivatives object:

This routine initializes the boundary conditions and builds the actual nl_operator_oct_m::nl_operator_t objects for the derivative operators.

The stencil weights are computed by imposing that the action of the discrete Laplacian or gradient is exact on a set of polynomials. The set of polynomials needs to be chosen such that it yields linearly independent vectors when evaluated on the points of the stencil.

More specifically, the weights are the solution of the equation

\[ mat * weights = rhs, \]

where \( mat_{i,j} \) is the value of the \(i\)-th polynomial on the \(j\)-the point of the stencil and \(rhs\) is the solution of applying the operator to the polynomial and evaluating it at 0.

Let \(u_1,u_2,u_3\) be the primitive coordinates and \(F=BB^T\), with \(B\) the change-of-coordinates matrix (see Natan et al. (2008), PRB 78, 075109, eqs. 10 and 11). The polynomials are given as \(u_1^{\alpha_1}u_2^{\alpha_2}u_3^{\alpha_3}\), and the right-hand side for the gradient is

  • 1 if \(\alpha_i = 1, \alpha_j = 0, j\ne i\)
  • 0 otherwise and for the Laplacian
  • \(2 F_{i,i}\) if \(\alpha_i = 2, \alpha_j = 0, j\ne i\)
  • \(F_{i,j} + F_{j,i}\) if \(\alpha_i = 1, \alpha_j = 1, \alpha_k = 0, k\ne i, k \ne j\)
  • 0 otherwise The polynomials need to include the cases for which the right-hand-side is non-zero.

The method has been tested for the default and cube stencils on all 14 Bravais lattices in 3D and yields acceptable errors for the derivatives.

Parameters
[in]spacespace (spatial and periodic dimensions)
[in]meshthe underlying mesh
[in]qvectormomentum transfer for spiral BC (pass through to boundaries_oct_m::boundaries_init())

Definition at line 579 of file derivatives.F90.

◆ get_rhs_lapl()

subroutine derivatives_oct_m::get_rhs_lapl ( type(derivatives_t), intent(in)  der,
integer, dimension(:,:), intent(in)  polynomials,
real(real64), dimension(:), intent(out)  rhs 
)
private

Definition at line 738 of file derivatives.F90.

◆ get_rhs_grad()

subroutine derivatives_oct_m::get_rhs_grad ( type(derivatives_t), intent(in)  der,
integer, dimension(:,:), intent(in)  polynomials,
integer, intent(in)  dir,
real(real64), dimension(:), intent(out)  rhs 
)
private

Definition at line 806 of file derivatives.F90.

◆ derivatives_make_discretization()

subroutine derivatives_oct_m::derivatives_make_discretization ( type(namespace_t), intent(in)  namespace,
integer, intent(in)  dim,
integer, intent(in)  periodic_dim,
type(mesh_t), intent(in)  mesh,
real(real64), dimension(:), intent(in)  masses,
integer, dimension(:,:), intent(in)  pol,
real(real64), dimension(:,:), intent(inout), contiguous  rhs,
integer, intent(in)  nderiv,
type(nl_operator_t), dimension(:), intent(inout)  op,
character(len=32), intent(in)  name,
logical, intent(in), optional  verbose 
)
private

Definition at line 833 of file derivatives.F90.

◆ derivatives_overlap()

logical function derivatives_oct_m::derivatives_overlap ( type(derivatives_t), intent(in)  this)
private

Definition at line 952 of file derivatives.F90.

◆ derivatives_get_lapl()

subroutine, public derivatives_oct_m::derivatives_get_lapl ( type(derivatives_t), intent(in)  this,
type(namespace_t), intent(in)  namespace,
type(nl_operator_t), dimension(:), intent(inout)  op,
class(space_t), intent(in)  space,
character(len=32), intent(in)  name,
integer, intent(in)  order 
)

Definition at line 964 of file derivatives.F90.

◆ derivatives_get_inner_boundary_mask()

logical function, dimension(1:this%mesh%np), public derivatives_oct_m::derivatives_get_inner_boundary_mask ( type(derivatives_t), intent(in)  this)

This function tells whether a point in the grid is contained in a layer of the width of the stencil between the last row of points in the grid.

E.g. if stencil = 2, then: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 1 1 1 1 0 0 0 1 1 1 1 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 So the innermost points of the grid will not be masked, while the one between the innermost and the boundary will be masked

Returns
mask that tells which points are

Definition at line 1016 of file derivatives.F90.

◆ derivatives_lapl_get_max_eigenvalue()

real(real64) function, public derivatives_oct_m::derivatives_lapl_get_max_eigenvalue ( type(derivatives_t), intent(in)  this)

Get maximum eigenvalue of discrete Laplacian. For the star and star_general stencils, use the Fourier transform of the stencil evaluated at the maximum phase to get an upper bound on the spectrum. For all other stencils, use the upper bound from the continuum.

Definition at line 1044 of file derivatives.F90.

◆ dderivatives_perform()

subroutine, public derivatives_oct_m::dderivatives_perform ( type(nl_operator_t), intent(in), target  op,
type(derivatives_t), intent(in)  der,
real(real64), dimension(:), intent(inout), contiguous  ff,
real(real64), dimension(:), intent(out), contiguous  op_ff,
logical, intent(in), optional  ghost_update,
logical, intent(in), optional  set_bc,
real(real64), intent(in), optional  factor 
)

apply a nl_operator to a mesh function

Note
the initial mesh function needs to be defined including ghost and boundary points! As the ghost points are updated, the initial mesh function needs to be declared intent(inout).
Parameters
[in]opoperator to apply
[in]derthe derivatives object
[in,out]ffinitial mesh function (1:dermeshnp_part)
[out]op_fffinal mesh function (1:dermeshnp)
[in]ghost_updateflag whether to perform the ghost update (default .true.)
[in]set_bcflag whether to apply the boundary conditions (default .true.)
[in]factoroptional scaling factor

Definition at line 1153 of file derivatives.F90.

◆ dderivatives_lapl()

subroutine, public derivatives_oct_m::dderivatives_lapl ( type(derivatives_t), intent(in)  der,
real(real64), dimension(:), intent(inout), contiguous  ff,
real(real64), dimension(:), intent(out), contiguous  op_ff,
logical, intent(in), optional  ghost_update,
logical, intent(in), optional  set_bc,
real(real64), intent(in), optional  factor 
)

apply the Laplacian to a mesh function

Note
the initial mesh function needs to be defined including ghost and boundary points! As the ghost points are updated, the initial mesh function needs to be declared intent(inout).
Parameters
[in]derderivatives object
[in,out]ffinitial mesh function (1:dermeshnp_part)
[out]op_fffinal mesh function (1:dermeshnp)
[in]ghost_updateflag whether to perform the ghost update (default .true.)
[in]set_bcflag whether to apply the boundary conditions (default .true.)
[in]factoroptional scaling factor

Definition at line 1191 of file derivatives.F90.

◆ dderivatives_grad()

subroutine, public derivatives_oct_m::dderivatives_grad ( type(derivatives_t), intent(in)  der,
real(real64), dimension(:), intent(inout), contiguous  ff,
real(real64), dimension(:, :), intent(out), contiguous  op_ff,
logical, intent(in), optional  ghost_update,
logical, intent(in), optional  set_bc,
logical, intent(in), optional  to_cartesian 
)

apply the gradient to a mesh function

Note
the initial mesh function needs to be defined including ghost and boundary points! As the ghost points are updated, the initial mesh function needs to be declared intent(inout).
Parameters
[in]derderivatives object
[in,out]ffinitial mesh function ff(1:dermeshnp_part)
[out]op_fffinal mesh function op_ff(1:dermeshnp, 1:derdim)
[in]ghost_updateflag whether to perform the ghost update (default .true.)
[in]set_bcflag whether to apply the boundary conditions (default .true.)
[in]to_cartesianflag whether conversion to cartesian coords in needed

Definition at line 1213 of file derivatives.F90.

◆ dderivatives_partial()

subroutine, public derivatives_oct_m::dderivatives_partial ( type(derivatives_t), intent(in)  der,
real(real64), dimension(:), intent(inout), contiguous  ff,
real(real64), dimension(:), intent(out), contiguous  op_ff,
integer, intent(in)  dir,
logical, intent(in), optional  ghost_update,
logical, intent(in), optional  set_bc 
)

apply the partial derivative along dir to a mesh function

Note
the initial mesh function needs to be defined including ghost and boundary points! As the ghost points are updated, the initial mesh function needs to be declared intent(inout).
Parameters
[in]derderivatives object
[in,out]ffinitial mesh function (1:dermeshnp_part)
[out]op_fffinal mesh function (1:dermeshnp)
[in]dirdirection along which to calculate the partial derivative
[in]ghost_updateflag whether to perform the ghost update (default .true.)
[in]set_bcflag whether to set the boundary conditions (default .true.)

Definition at line 1256 of file derivatives.F90.

◆ dderivatives_div()

subroutine, public derivatives_oct_m::dderivatives_div ( type(derivatives_t), intent(in)  der,
real(real64), dimension(:,:), intent(inout), target, contiguous  ff,
real(real64), dimension(:), intent(out), contiguous  op_ff,
logical, intent(in), optional  ghost_update,
logical, intent(in), optional  set_bc,
logical, intent(in), optional  to_cartesian 
)

apply the divergence operator to a vector of mesh functions

Note
the initial mesh function needs to be defined including ghost and boundary points! As the ghost points are updated, the initial mesh function needs to be declared intent(inout).
Parameters
[in]derderivatives object
[in,out]ffinitial mesh function vector ff(1:dermeshnp_part, 1:derdim)
[out]op_fffinal mesh function op_ff(1:dermeshnp)
[in]ghost_updateflag whether to perform the ghost update (default .true.)
[in]set_bcflag whether to apply the boundary conditions (default .true.)
[in]to_cartesianflag whether conversion to cartesian coords in needed

Definition at line 1283 of file derivatives.F90.

◆ dderivatives_curl()

subroutine, public derivatives_oct_m::dderivatives_curl ( type(derivatives_t), intent(in)  der,
real(real64), dimension(:,:), intent(inout), contiguous  ff,
real(real64), dimension(:,:), intent(out), contiguous  op_ff,
logical, intent(in), optional  ghost_update,
logical, intent(in), optional  set_bc 
)

apply the curl operator to a vector of mesh functions

Note
the initial mesh function needs to be defined including ghost and boundary points! As the ghost points are updated, the initial mesh function needs to be declared intent(inout).
Parameters
[in]derderivatives object
[in,out]ffinitial mesh function vector ff(1:dermeshnp_part, 1:derdim)
[out]op_fffinal mesh function vector op_ff(1:dermeshnp, 1:derdim)
[in]ghost_updateflag whether to perform the ghost update (default .true.)
[in]set_bcflag whether to apply the boundary conditions (default .true.)

Definition at line 1350 of file derivatives.F90.

◆ dderivatives_test()

subroutine, public derivatives_oct_m::dderivatives_test ( type(derivatives_t), intent(in)  this,
type(namespace_t), intent(in)  namespace,
integer, intent(in)  repetitions,
integer, intent(in)  min_blocksize,
integer, intent(in)  max_blocksize 
)

unit test for derivatives

This will be called from the test run mode.

Definition at line 1432 of file derivatives.F90.

◆ dderivatives_batch_start()

subroutine, public derivatives_oct_m::dderivatives_batch_start ( type(nl_operator_t), intent(in), target  op,
type(derivatives_t), intent(in), target  der,
class(batch_t), intent(inout), target  ff,
class(batch_t), intent(inout), target  opff,
type(derivatives_handle_batch_t), intent(out)  handle,
logical, intent(in), optional  ghost_update,
logical, intent(in), optional  set_bc,
real(real64), intent(in), optional  factor 
)

apply a non-local operator to a batch (1st part)

This 1st part stores important data in the handle, sets the boundaries (if requested) and starts the communication for the ghost update (if requested)

Parameters
[in]opthe operator to be applied
[in]derthe derivatives object
[in,out]ffinitial batch
[in,out]opfffinial batch (after application of the operator)
[out]handlehandle for start/finish calls
[in]ghost_updatewhether to perform ghost updates (default=.true.)
[in]set_bcwhether to set the boundary conditions (default=.true.)
[in]factoroptional scaling factor

Definition at line 1699 of file derivatives.F90.

◆ dderivatives_batch_finish()

subroutine, public derivatives_oct_m::dderivatives_batch_finish ( type(derivatives_handle_batch_t), intent(inout)  handle,
logical, intent(in), optional  async 
)

apply a non-local operator to a batch (2nd part)

This 2nd part finished the communication and applies the operator. Here, the operator is applied to the inner points before the communication is finished, to overlap calculation and communication, if possible. After the communication is complete, the operator is applied to the outer points.

Definition at line 1752 of file derivatives.F90.

◆ dderivatives_batch_perform()

subroutine, public derivatives_oct_m::dderivatives_batch_perform ( type(nl_operator_t), intent(in)  op,
type(derivatives_t), intent(in)  der,
class(batch_t), intent(inout)  ff,
class(batch_t), intent(inout)  opff,
logical, intent(in), optional  ghost_update,
logical, intent(in), optional  set_bc,
real(real64), intent(in), optional  factor,
logical, intent(in), optional  async 
)

apply an operator to a bach of mesh functions

This is a wrapper of the corresponding start and finish routines.

Parameters
[in]opthe operator to be applied
[in]derthe derivatives object
[in,out]ffinitial batch
[in,out]opfffinial batch (after application of the operator)
[in]ghost_updatewhether to perform ghost updates (default=.true.)
[in]set_bcwhether to set the boundary conditions (default=.true.)
[in]factoroptional scaling factor

Definition at line 1803 of file derivatives.F90.

◆ dderivatives_batch_grad()

subroutine, public derivatives_oct_m::dderivatives_batch_grad ( type(derivatives_t), intent(in)  der,
class(batch_t), intent(inout)  ffb,
class(batch_t), dimension(:), intent(inout)  opffb,
logical, intent(in), optional  ghost_update,
logical, intent(in), optional  set_bc,
logical, intent(in), optional  to_cartesian,
real(real64), dimension(:,:), intent(in), optional  metric,
real(real64), intent(in), optional  factor 
)

apply the gradient to a batch of mesh functions

Parameters
[in]derderivatives object
[in,out]ffbinitial batch
[in,out]opffbfinal vector of batches
[in]ghost_updateoptional flag whether to perform the ghost update (default .true.)
[in]set_bcoptional flag whether to set the boundary conditions (default .true.)
[in]to_cartesianoptional flag whether to convert to cartesian coods (currently unused!)
[in]metricoptional metric for affine coordinate systems
[in]factoroptional scaling factor

Definition at line 1830 of file derivatives.F90.

◆ dbatch_vector_uvw_to_xyz()

subroutine derivatives_oct_m::dbatch_vector_uvw_to_xyz ( type(derivatives_t), intent(in)  der,
type(affine_coordinates_t), intent(in), target  coord_system,
class(batch_t), dimension(:), intent(inout), target  uvw,
class(batch_t), dimension(:), intent(inout), optional, target  xyz,
real(real64), dimension(:,:), intent(in), optional, target  metric 
)
private

transform a vector of batches from affine to cartesian coordinates

Parameters
[in]metricTranspose of the matrix

Definition at line 1872 of file derivatives.F90.

◆ dderivatives_batch_curl()

subroutine, public derivatives_oct_m::dderivatives_batch_curl ( type(derivatives_t), intent(in)  der,
class(batch_t), intent(inout)  ffb,
logical, intent(in), optional  ghost_update,
logical, intent(in), optional  set_bc 
)

apply the curl to a batch of mesh functions

This routine computes first a gradient. If the gradient is known, consider using derivatives_batch_curl_from_gradient instead.

Parameters
[in]derthe derivatives object
[in,out]ffbthe initial batch; ffb will be overwritten by its curl
[in]ghost_updateoptional flag whether to perform the ghost update (default .true.)
[in]set_bcoptional flag whether to set the boundary conditions (default .true.)

Definition at line 2007 of file derivatives.F90.

◆ dderivatives_batch_curl_from_gradient()

subroutine, public derivatives_oct_m::dderivatives_batch_curl_from_gradient ( type(derivatives_t), intent(in)  der,
class(batch_t), intent(inout)  ffb,
class(batch_t), dimension(:), intent(in)  gradb 
)

calculate the curl from a batch and its gradient

If the gradient of the batch already has been calculated, this routine is reuses it to get the curl

Parameters
[in]derthe derivatives object
[in,out]ffbon output: batch of the curl
[in]gradbbatch of the gradients of the mesh functions

Definition at line 2037 of file derivatives.F90.

◆ dderivatives_batch_div()

subroutine, public derivatives_oct_m::dderivatives_batch_div ( type(derivatives_t), intent(in)  der,
class(batch_t), dimension(:), intent(inout)  ffb,
class(batch_t), intent(inout)  opffb,
logical, intent(in), optional  ghost_update,
logical, intent(in), optional  set_bc,
logical, intent(in), optional  to_cartesian 
)

calculate the divergence of a vector of batches

Parameters
[in]derthe derivatives object
[in,out]ffbvector of initial batches
[in,out]opffbbatch containing the divergence
[in]ghost_updateoptional flag whether to perform the ghost update (default .true.)
[in]set_bcoptional flag whether to set the boundary conditions (default .true.)
[in]to_cartesianoptional flag whether to convert to cartesian coords (default .true.)

Definition at line 2102 of file derivatives.F90.

◆ zderivatives_perform()

subroutine, public derivatives_oct_m::zderivatives_perform ( type(nl_operator_t), intent(in), target  op,
type(derivatives_t), intent(in)  der,
complex(real64), dimension(:), intent(inout), contiguous  ff,
complex(real64), dimension(:), intent(out), contiguous  op_ff,
logical, intent(in), optional  ghost_update,
logical, intent(in), optional  set_bc,
real(real64), intent(in), optional  factor 
)

apply a nl_operator to a mesh function

Note
the initial mesh function needs to be defined including ghost and boundary points! As the ghost points are updated, the initial mesh function needs to be declared intent(inout).
Parameters
[in]opoperator to apply
[in]derthe derivatives object
[in,out]ffinitial mesh function (1:dermeshnp_part)
[out]op_fffinal mesh function (1:dermeshnp)
[in]ghost_updateflag whether to perform the ghost update (default .true.)
[in]set_bcflag whether to apply the boundary conditions (default .true.)
[in]factoroptional scaling factor

Definition at line 2235 of file derivatives.F90.

◆ zderivatives_lapl()

subroutine, public derivatives_oct_m::zderivatives_lapl ( type(derivatives_t), intent(in)  der,
complex(real64), dimension(:), intent(inout), contiguous  ff,
complex(real64), dimension(:), intent(out), contiguous  op_ff,
logical, intent(in), optional  ghost_update,
logical, intent(in), optional  set_bc,
real(real64), intent(in), optional  factor 
)

apply the Laplacian to a mesh function

Note
the initial mesh function needs to be defined including ghost and boundary points! As the ghost points are updated, the initial mesh function needs to be declared intent(inout).
Parameters
[in]derderivatives object
[in,out]ffinitial mesh function (1:dermeshnp_part)
[out]op_fffinal mesh function (1:dermeshnp)
[in]ghost_updateflag whether to perform the ghost update (default .true.)
[in]set_bcflag whether to apply the boundary conditions (default .true.)
[in]factoroptional scaling factor

Definition at line 2273 of file derivatives.F90.

◆ zderivatives_grad()

subroutine, public derivatives_oct_m::zderivatives_grad ( type(derivatives_t), intent(in)  der,
complex(real64), dimension(:), intent(inout), contiguous  ff,
complex(real64), dimension(:, :), intent(out), contiguous  op_ff,
logical, intent(in), optional  ghost_update,
logical, intent(in), optional  set_bc,
logical, intent(in), optional  to_cartesian 
)

apply the gradient to a mesh function

Note
the initial mesh function needs to be defined including ghost and boundary points! As the ghost points are updated, the initial mesh function needs to be declared intent(inout).
Parameters
[in]derderivatives object
[in,out]ffinitial mesh function ff(1:dermeshnp_part)
[out]op_fffinal mesh function op_ff(1:dermeshnp, 1:derdim)
[in]ghost_updateflag whether to perform the ghost update (default .true.)
[in]set_bcflag whether to apply the boundary conditions (default .true.)
[in]to_cartesianflag whether conversion to cartesian coords in needed

Definition at line 2295 of file derivatives.F90.

◆ zderivatives_partial()

subroutine, public derivatives_oct_m::zderivatives_partial ( type(derivatives_t), intent(in)  der,
complex(real64), dimension(:), intent(inout), contiguous  ff,
complex(real64), dimension(:), intent(out), contiguous  op_ff,
integer, intent(in)  dir,
logical, intent(in), optional  ghost_update,
logical, intent(in), optional  set_bc 
)

apply the partial derivative along dir to a mesh function

Note
the initial mesh function needs to be defined including ghost and boundary points! As the ghost points are updated, the initial mesh function needs to be declared intent(inout).
Parameters
[in]derderivatives object
[in,out]ffinitial mesh function (1:dermeshnp_part)
[out]op_fffinal mesh function (1:dermeshnp)
[in]dirdirection along which to calculate the partial derivative
[in]ghost_updateflag whether to perform the ghost update (default .true.)
[in]set_bcflag whether to set the boundary conditions (default .true.)

Definition at line 2338 of file derivatives.F90.

◆ zderivatives_div()

subroutine, public derivatives_oct_m::zderivatives_div ( type(derivatives_t), intent(in)  der,
complex(real64), dimension(:,:), intent(inout), target, contiguous  ff,
complex(real64), dimension(:), intent(out), contiguous  op_ff,
logical, intent(in), optional  ghost_update,
logical, intent(in), optional  set_bc,
logical, intent(in), optional  to_cartesian 
)

apply the divergence operator to a vector of mesh functions

Note
the initial mesh function needs to be defined including ghost and boundary points! As the ghost points are updated, the initial mesh function needs to be declared intent(inout).
Parameters
[in]derderivatives object
[in,out]ffinitial mesh function vector ff(1:dermeshnp_part, 1:derdim)
[out]op_fffinal mesh function op_ff(1:dermeshnp)
[in]ghost_updateflag whether to perform the ghost update (default .true.)
[in]set_bcflag whether to apply the boundary conditions (default .true.)
[in]to_cartesianflag whether conversion to cartesian coords in needed

Definition at line 2365 of file derivatives.F90.

◆ zderivatives_curl()

subroutine, public derivatives_oct_m::zderivatives_curl ( type(derivatives_t), intent(in)  der,
complex(real64), dimension(:,:), intent(inout), contiguous  ff,
complex(real64), dimension(:,:), intent(out), contiguous  op_ff,
logical, intent(in), optional  ghost_update,
logical, intent(in), optional  set_bc 
)

apply the curl operator to a vector of mesh functions

Note
the initial mesh function needs to be defined including ghost and boundary points! As the ghost points are updated, the initial mesh function needs to be declared intent(inout).
Parameters
[in]derderivatives object
[in,out]ffinitial mesh function vector ff(1:dermeshnp_part, 1:derdim)
[out]op_fffinal mesh function vector op_ff(1:dermeshnp, 1:derdim)
[in]ghost_updateflag whether to perform the ghost update (default .true.)
[in]set_bcflag whether to apply the boundary conditions (default .true.)

Definition at line 2432 of file derivatives.F90.

◆ zderivatives_test()

subroutine, public derivatives_oct_m::zderivatives_test ( type(derivatives_t), intent(in)  this,
type(namespace_t), intent(in)  namespace,
integer, intent(in)  repetitions,
integer, intent(in)  min_blocksize,
integer, intent(in)  max_blocksize 
)

unit test for derivatives

This will be called from the test run mode.

Definition at line 2514 of file derivatives.F90.

◆ zderivatives_batch_start()

subroutine, public derivatives_oct_m::zderivatives_batch_start ( type(nl_operator_t), intent(in), target  op,
type(derivatives_t), intent(in), target  der,
class(batch_t), intent(inout), target  ff,
class(batch_t), intent(inout), target  opff,
type(derivatives_handle_batch_t), intent(out)  handle,
logical, intent(in), optional  ghost_update,
logical, intent(in), optional  set_bc,
real(real64), intent(in), optional  factor 
)

apply a non-local operator to a batch (1st part)

This 1st part stores important data in the handle, sets the boundaries (if requested) and starts the communication for the ghost update (if requested)

Parameters
[in]opthe operator to be applied
[in]derthe derivatives object
[in,out]ffinitial batch
[in,out]opfffinial batch (after application of the operator)
[out]handlehandle for start/finish calls
[in]ghost_updatewhether to perform ghost updates (default=.true.)
[in]set_bcwhether to set the boundary conditions (default=.true.)
[in]factoroptional scaling factor

Definition at line 2789 of file derivatives.F90.

◆ zderivatives_batch_finish()

subroutine, public derivatives_oct_m::zderivatives_batch_finish ( type(derivatives_handle_batch_t), intent(inout)  handle,
logical, intent(in), optional  async 
)

apply a non-local operator to a batch (2nd part)

This 2nd part finished the communication and applies the operator. Here, the operator is applied to the inner points before the communication is finished, to overlap calculation and communication, if possible. After the communication is complete, the operator is applied to the outer points.

Definition at line 2842 of file derivatives.F90.

◆ zderivatives_batch_perform()

subroutine, public derivatives_oct_m::zderivatives_batch_perform ( type(nl_operator_t), intent(in)  op,
type(derivatives_t), intent(in)  der,
class(batch_t), intent(inout)  ff,
class(batch_t), intent(inout)  opff,
logical, intent(in), optional  ghost_update,
logical, intent(in), optional  set_bc,
real(real64), intent(in), optional  factor,
logical, intent(in), optional  async 
)

apply an operator to a bach of mesh functions

This is a wrapper of the corresponding start and finish routines.

Parameters
[in]opthe operator to be applied
[in]derthe derivatives object
[in,out]ffinitial batch
[in,out]opfffinial batch (after application of the operator)
[in]ghost_updatewhether to perform ghost updates (default=.true.)
[in]set_bcwhether to set the boundary conditions (default=.true.)
[in]factoroptional scaling factor

Definition at line 2893 of file derivatives.F90.

◆ zderivatives_batch_grad()

subroutine, public derivatives_oct_m::zderivatives_batch_grad ( type(derivatives_t), intent(in)  der,
class(batch_t), intent(inout)  ffb,
class(batch_t), dimension(:), intent(inout)  opffb,
logical, intent(in), optional  ghost_update,
logical, intent(in), optional  set_bc,
logical, intent(in), optional  to_cartesian,
real(real64), dimension(:,:), intent(in), optional  metric,
real(real64), intent(in), optional  factor 
)

apply the gradient to a batch of mesh functions

Parameters
[in]derderivatives object
[in,out]ffbinitial batch
[in,out]opffbfinal vector of batches
[in]ghost_updateoptional flag whether to perform the ghost update (default .true.)
[in]set_bcoptional flag whether to set the boundary conditions (default .true.)
[in]to_cartesianoptional flag whether to convert to cartesian coods (currently unused!)
[in]metricoptional metric for affine coordinate systems
[in]factoroptional scaling factor

Definition at line 2920 of file derivatives.F90.

◆ zbatch_vector_uvw_to_xyz()

subroutine derivatives_oct_m::zbatch_vector_uvw_to_xyz ( type(derivatives_t), intent(in)  der,
type(affine_coordinates_t), intent(in), target  coord_system,
class(batch_t), dimension(:), intent(inout), target  uvw,
class(batch_t), dimension(:), intent(inout), optional, target  xyz,
real(real64), dimension(:,:), intent(in), optional, target  metric 
)
private

transform a vector of batches from affine to cartesian coordinates

Parameters
[in]metricTranspose of the matrix

Definition at line 2962 of file derivatives.F90.

◆ zderivatives_batch_curl()

subroutine, public derivatives_oct_m::zderivatives_batch_curl ( type(derivatives_t), intent(in)  der,
class(batch_t), intent(inout)  ffb,
logical, intent(in), optional  ghost_update,
logical, intent(in), optional  set_bc 
)

apply the curl to a batch of mesh functions

This routine computes first a gradient. If the gradient is known, consider using derivatives_batch_curl_from_gradient instead.

Parameters
[in]derthe derivatives object
[in,out]ffbthe initial batch; ffb will be overwritten by its curl
[in]ghost_updateoptional flag whether to perform the ghost update (default .true.)
[in]set_bcoptional flag whether to set the boundary conditions (default .true.)

Definition at line 3097 of file derivatives.F90.

◆ zderivatives_batch_curl_from_gradient()

subroutine, public derivatives_oct_m::zderivatives_batch_curl_from_gradient ( type(derivatives_t), intent(in)  der,
class(batch_t), intent(inout)  ffb,
class(batch_t), dimension(:), intent(in)  gradb 
)

calculate the curl from a batch and its gradient

If the gradient of the batch already has been calculated, this routine is reuses it to get the curl

Parameters
[in]derthe derivatives object
[in,out]ffbon output: batch of the curl
[in]gradbbatch of the gradients of the mesh functions

Definition at line 3127 of file derivatives.F90.

◆ zderivatives_batch_div()

subroutine, public derivatives_oct_m::zderivatives_batch_div ( type(derivatives_t), intent(in)  der,
class(batch_t), dimension(:), intent(inout)  ffb,
class(batch_t), intent(inout)  opffb,
logical, intent(in), optional  ghost_update,
logical, intent(in), optional  set_bc,
logical, intent(in), optional  to_cartesian 
)

calculate the divergence of a vector of batches

Parameters
[in]derthe derivatives object
[in,out]ffbvector of initial batches
[in,out]opffbbatch containing the divergence
[in]ghost_updateoptional flag whether to perform the ghost update (default .true.)
[in]set_bcoptional flag whether to set the boundary conditions (default .true.)
[in]to_cartesianoptional flag whether to convert to cartesian coords (default .true.)

Definition at line 3192 of file derivatives.F90.

Variable Documentation

◆ der_bc_zero_f

integer, parameter derivatives_oct_m::der_bc_zero_f = 0
private

function is zero at the boundaries

Definition at line 210 of file derivatives.F90.

◆ der_bc_zero_df

integer, parameter derivatives_oct_m::der_bc_zero_df = 1
private

first derivative of the function is zero

Definition at line 210 of file derivatives.F90.

◆ der_bc_period

integer, parameter derivatives_oct_m::der_bc_period = 2
private

boundary is periodic

Definition at line 210 of file derivatives.F90.

◆ der_star

integer, parameter, public derivatives_oct_m::der_star = 1

Definition at line 215 of file derivatives.F90.

◆ der_variational

integer, parameter, public derivatives_oct_m::der_variational = 2

Definition at line 215 of file derivatives.F90.

◆ der_cube

integer, parameter, public derivatives_oct_m::der_cube = 3

Definition at line 215 of file derivatives.F90.

◆ der_starplus

integer, parameter, public derivatives_oct_m::der_starplus = 4

Definition at line 215 of file derivatives.F90.

◆ der_stargeneral

integer, parameter, public derivatives_oct_m::der_stargeneral = 5

Definition at line 215 of file derivatives.F90.

◆ blocking

integer, parameter derivatives_oct_m::blocking = 1
private

Definition at line 222 of file derivatives.F90.

◆ non_blocking

integer, parameter derivatives_oct_m::non_blocking = 2
private

Definition at line 222 of file derivatives.F90.

◆ kernel_uvw_xyz

type(accel_kernel_t) derivatives_oct_m::kernel_uvw_xyz
private

Definition at line 273 of file derivatives.F90.

◆ kernel_dcurl

type(accel_kernel_t) derivatives_oct_m::kernel_dcurl
private

Definition at line 273 of file derivatives.F90.

◆ kernel_zcurl

type(accel_kernel_t) derivatives_oct_m::kernel_zcurl
private

Definition at line 273 of file derivatives.F90.