Documentation for module pw_spline_utils

different utils that are useful to manipulate splines on the regular grid of a pw

source: pw_spline_utils.F
Loading...

public Types:

pw_spline_precond_type
stores information for the preconditioner used to calculate the coeffs of splines

public Subroutines/Functions:

low level function that adds a coarse grid to a fine grid. If pbc is true periodic boundary conditions are applied
low level function that adds a coarse grid (without boundary) to a fine grid.
FUNCTION
REAL(dp)
eval_d_interp_spl3_pbc (vec, pw)
Evaluates the derivatives of the PBC interpolated Spline (pw) function on the generic input vector (vec)
FUNCTION
REAL(dp)
eval_interp_spl3_pbc (vec, pw)
Evaluates the PBC interpolated Spline (pw) function on the generic input vector (vec)
solves iteratively (CG) a systmes of linear equations linOp(coeffs)=values (for example those needed to find the coefficents of a spline) Returns true if the it succeded to acheive the requested accuracy
calculates a nearest neighbor central derivative. for the x dir: pw_out%cr3d(i,j,k)=( pw_in(i+1,j,k)-pw_in(i-1,j,k) )*coeff(1)+ ( pw_in(i+1,j(+-)1,k)-pw_in(i-1,j(+-)1,k)+ pw_in(i+1,j,k(+-)1)-pw_in(i-1,j,k(+-)1) )*coeff(2)+ ( pw_in(i+1,j(+-)1,k(+-)1)-pw_in(i-1,j(+-)1,k(+-)1)+ pw_in(i+1,j(+-)1,k(-+)1)-pw_in(i-1,j(+-)1,k(-+)1) )*coeff(3) periodic boundary conditions are applied
calculates the values of a nearest neighbor smearing
calculates the FFT of the values of the x,y,z (idir=1,2,3) derivative of the quadratic spline
calculates the FFT of the coefficents of the quadratic spline that interpolates the given values
calculates the FFT of the values of the x,y,z (idir=1,2,3) derivative of the cubic spline
calculates the FFT of the coefficents of the2 cubic spline that interpolates the given values
applies the preconditioner to the system of equations to find the coefficents of the spline
...
releases the preconditioner
switches the types of precoditioner to use
rescales the derivatives from gridspacing=1 to the real derivatives
SUBROUTINE
spl3_nopbc (pw_in, pw_out)
...
SUBROUTINE
spl3_nopbct (pw_in, pw_out)
...
SUBROUTINE
spl3_pbc (pw_in, pw_out)
...

Parameters:

REAL(dp)
:: nn10_coeffs(4) = (/125._dp/216._dp,25._dp/432._dp,5._dp/864._dp,1._dp/1728._dp/)
REAL(dp)
:: nn10_deriv_coeffs(3) = (/25._dp/72._dp,5._dp/144,1._dp/288._dp/)
REAL(dp)
:: nn50_coeffs(4) = (/15625._dp/17576._dp,625._dp/35152._dp,25._dp/70304._dp,1._dp/140608._dp/)
REAL(dp)
:: nn50_deriv_coeffs(3) = (/625._dp/1352._dp,25._dp/2704._dp,1._dp/5408._dp/)
INTEGER
:: no_precond = 0
INTEGER
:: precond_spl3_1 = 2
INTEGER
:: precond_spl3_2 = 4
INTEGER
:: precond_spl3_3 = 5
INTEGER
:: precond_spl3_aint = 1
INTEGER
:: precond_spl3_aint2 = 3
REAL(dp)
:: spl3_1d_coeffs0(3) = (/1._dp/6_dp,2._dp/3._dp,1._dp/6._dp/)
REAL(dp)
:: spl3_1d_transf_border1(3) = (/0.517977704_dp,0.464044595_dp,0.17977701e-1_dp/)
REAL(dp)
:: spl3_1d_transf_coeffs(4) = (/2._dp/3._dp,23._dp/48._dp,1._dp/6._dp,1._dp/48._dp/)
REAL(dp)
:: spl3_aint_coeff(4) = (/46._dp/27._dp,-2._dp/(27._dp),-1._dp/(27._dp*2._dp),-1._dp/(27._dp*8._dp)/)
REAL(dp)
:: spl3_precond1_coeff(4) = (/64._dp/3._dp,-8._dp/3._dp,-1._dp/3._dp,-1._dp/24._dp/)
REAL(dp)
:: spline2_coeffs(4) = (/27._dp/(64._dp),9._dp/(64._dp*2_dp),3._dp/(64._dp*4._dp),1._dp/(64._dp*8._dp)/)
REAL(dp)
:: spline2_deriv_coeffs(3) = (/9.0_dp/32.0_dp,3.0_dp/64.0_dp,1.0_dp/128.0_dp/)
REAL(dp)
:: spline3_coeffs(4) = (/8._dp/(27._dp),2._dp/(27._dp),1._dp/(27._dp*2._dp),1._dp/(27._dp*8._dp)/)
REAL(dp)
:: spline3_deriv_coeffs(3) = (/2.0_dp/9.0_dp,1.0_dp/18.0_dp,1.0_dp/72.0_dp/)

public Types:

TYPE :: pw_spline_precond_type

stores information for the preconditioner used to calculate the coeffs of splines


INTEGER
:: ref_count ...
INTEGER
:: id_nr ...
INTEGER
:: kind ...
REAL(dp),
DIMENSION(4) :: coeffs ...
REAL(dp),
DIMENSION(3) :: coeffs_1d ...
LOGICAL
:: sharpen ...
LOGICAL
:: normalize ...
LOGICAL
:: pbc ...
LOGICAL
:: transpose ...
POINTER :: pool ...

SUBROUTINEadd_coarse2fine(coarse_coeffs_pw, fine_values_pw, weights_1d, w_border0, w_border1, pbc, safe_computation)

low level function that adds a coarse grid to a fine grid. If pbc is true periodic boundary conditions are applied

Arguments:
TYPE(pw_type),
POINTER
:: coarse_coeffs_pw the values of the coefficients
TYPE(pw_type),
POINTER
:: fine_values_pw where to add the values due to the coarse coeffs
REAL(dp),
INTENT(in)
:: weights_1d(4) the weights of the 1d smearing
REAL(dp),
INTENT(in)
:: w_border0 the 1d weight at the border (when pbc is false)
REAL(dp),
INTENT(in)
:: w_border1(3) the 1d weights for a point one off the border (w_border1(1) is the weight of the coefficent at the border) (used if pbc is false)
LOGICAL,
INTENT(in)
:: pbc if periodic boundary conditions should be applied
LOGICAL,
INTENT(in),
OPTIONAL
:: safe_computation ...

SUBROUTINEadd_fine2coarse(fine_values_pw, coarse_coeffs_pw, weights_1d, w_border0, w_border1, pbc, safe_computation)

low level function that adds a coarse grid (without boundary) to a fine grid.

Arguments:
TYPE(pw_type),
POINTER
:: fine_values_pw 3d array where to add the values due to the coarse coeffs
TYPE(pw_type),
POINTER
:: coarse_coeffs_pw 3d array with boundary of size 1 with the values of the coefficients
REAL(dp),
INTENT(in)
:: weights_1d(4) the weights of the 1d smearing
REAL(dp),
INTENT(in)
:: w_border0 the 1d weight at the border
REAL(dp),
INTENT(in)
:: w_border1(3) the 1d weights for a point one off the border (w_border1(1) is the weight of the coefficent at the border)
LOGICAL,
INTENT(in)
:: pbc ...
LOGICAL,
INTENT(in),
OPTIONAL
:: safe_computation ...

FUNCTIONeval_d_interp_spl3_pbc(vec, pw)

Evaluates the derivatives of the PBC interpolated Spline (pw) function on the generic input vector (vec)

Return Value ::
REAL(dp)
Arguments:
REAL(dp),
INTENT(in)
:: vec(3) ...
TYPE(pw_type),
POINTER
:: pw ...

FUNCTIONeval_interp_spl3_pbc(vec, pw)

Evaluates the PBC interpolated Spline (pw) function on the generic input vector (vec)

Return Value ::
REAL(dp)
Arguments:
REAL(dp),
INTENT(in)
:: vec(3) ...
TYPE(pw_type),
POINTER
:: pw ...

FUNCTIONfind_coeffs(values, coeffs, linop, preconditioner, pool, eps_r, eps_x, max_iter)

solves iteratively (CG) a systmes of linear equations linOp(coeffs)=values (for example those needed to find the coefficents of a spline) Returns true if the it succeded to acheive the requested accuracy

Return Value ::
LOGICAL
Arguments:
TYPE(pw_type),
POINTER
:: values the right hand side of the system
TYPE(pw_type),
POINTER
:: coeffs will contain the solution of the system (and on entry it contains the starting point)
PROCEDURE,
subroutine
:: linop the linear operator to be inverted
POINTER
:: preconditioner the preconditioner to apply
POINTER
:: pool a pool of grids (for the temporary objects)
REAL(dp),
INTENT(in)
:: eps_r the requested precision on the residual
REAL(dp),
INTENT(in)
:: eps_x the requested precision on the solution
INTEGER,
INTENT(in)
:: max_iter maximum number of iteration allowed

SUBROUTINEpw_nn_deriv_r(pw_in, pw_out, coeffs, idir)

calculates a nearest neighbor central derivative. for the x dir: pw_out%cr3d(i,j,k)=( pw_in(i+1,j,k)-pw_in(i-1,j,k) )*coeff(1)+ ( pw_in(i+1,j(+-)1,k)-pw_in(i-1,j(+-)1,k)+ pw_in(i+1,j,k(+-)1)-pw_in(i-1,j,k(+-)1) )*coeff(2)+ ( pw_in(i+1,j(+-)1,k(+-)1)-pw_in(i-1,j(+-)1,k(+-)1)+ pw_in(i+1,j(+-)1,k(-+)1)-pw_in(i-1,j(+-)1,k(-+)1) )*coeff(3) periodic boundary conditions are applied

Arguments:
TYPE(pw_type),
POINTER
:: pw_in the argument for the linear operator
TYPE(pw_type),
POINTER
:: pw_out place where the smeared values should be added
REAL(dp),
INTENT(in)
:: coeffs(3) array with the coefficent of the front (positive) plane of the central derivative, ordered with the distance from the center: coeffs(1) the coeff of the central element, coeffs(2) the coeff of the 4 element with distance 1, coeff(3) the coeff of the 4 elements at distance sqrt(2)
INTEGER
:: idir ...

SUBROUTINEpw_nn_smear_r(pw_in, pw_out, coeffs)

calculates the values of a nearest neighbor smearing

Arguments:
TYPE(pw_type),
POINTER
:: pw_in the argument for the linear operator
TYPE(pw_type),
POINTER
:: pw_out place where the smeared values should be added
REAL(dp),
INTENT(in)
:: coeffs(4) array with the coefficent of the smearing, ordered with the distance from the center: coeffs(1) the coeff of the central element, coeffs(2) the coeff of the 6 element with distance 1, coeff(3) the coeff of the 12 elements at distance sqrt(2), coeff(4) the coeff of the 8 elements at distance sqrt(3).

SUBROUTINEpw_spline2_deriv_g(spline_g, idir)

calculates the FFT of the values of the x,y,z (idir=1,2,3) derivative of the quadratic spline

Arguments:
TYPE(pw_type),
POINTER
:: spline_g on entry the FFT of the coefficents of the spline will contain the FFT of the derivative
INTEGER,
INTENT(in)
:: idir direction of the derivative

SUBROUTINEpw_spline2_interpolate_values_g(spline_g)

calculates the FFT of the coefficents of the quadratic spline that interpolates the given values

Arguments:
TYPE(pw_type),
POINTER
:: spline_g on entry the FFT of the values to interpolate as cc, will contain the FFT of the coefficents of the spline

SUBROUTINEpw_spline3_deriv_g(spline_g, idir)

calculates the FFT of the values of the x,y,z (idir=1,2,3) derivative of the cubic spline

Arguments:
TYPE(pw_type),
POINTER
:: spline_g on entry the FFT of the coefficents of the spline will contain the FFT of the derivative
INTEGER,
INTENT(in)
:: idir direction of the derivative

SUBROUTINEpw_spline3_interpolate_values_g(spline_g)

calculates the FFT of the coefficents of the2 cubic spline that interpolates the given values

Arguments:
TYPE(pw_type),
POINTER
:: spline_g on entry the FFT of the values to interpolate as cc, will contain the FFT of the coefficents of the spline

SUBROUTINEpw_spline_do_precond(preconditioner, in_v, out_v)

applies the preconditioner to the system of equations to find the coefficents of the spline

Arguments:
POINTER
:: preconditioner the preconditioner to apply
TYPE(pw_type),
POINTER
:: in_v the grid on which the preconditioner should be applied
TYPE(pw_type),
POINTER
:: out_v place to store the preconditioner applied on v_out

SUBROUTINEpw_spline_precond_create(preconditioner, precond_kind, pool, pbc, transpose)

...

Arguments:
POINTER
:: preconditioner the preconditioner to create
INTEGER,
INTENT(in)
:: precond_kind the kind of preconditioner to use
POINTER
:: pool a pool with grids of the same type as the elements to precondition
LOGICAL,
INTENT(in)
:: pbc if periodic boundary conditions should be applied
LOGICAL,
INTENT(in)
:: transpose ...

SUBROUTINEpw_spline_precond_release(preconditioner)

releases the preconditioner

Arguments:
POINTER
:: preconditioner the preconditioner to release

SUBROUTINEpw_spline_precond_set_kind(preconditioner, precond_kind, pbc, transpose)

switches the types of precoditioner to use

Arguments:
POINTER
:: preconditioner the preconditioner to be changed
INTEGER,
INTENT(in)
:: precond_kind the new kind of preconditioner to use
LOGICAL,
INTENT(in),
OPTIONAL
:: pbc ...
LOGICAL,
INTENT(in),
OPTIONAL
:: transpose ...

SUBROUTINEpw_spline_scale_deriv(deriv_vals_r, transpose, scale)

rescales the derivatives from gridspacing=1 to the real derivatives

Arguments:
TYPE(pw_p_type)
:: deriv_vals_r(3) an array of x,y,z derivatives
LOGICAL,
INTENT(in),
OPTIONAL
:: transpose if true applies the transpose of the map (defaults to false)
REAL(dp),
INTENT(in),
OPTIONAL
:: scale a scaling factor (defaults to 1.0)

SUBROUTINEspl3_nopbc(pw_in, pw_out)

...

Arguments:
TYPE(pw_type),
POINTER
:: pw_in ...
TYPE(pw_type),
POINTER
:: pw_out ...

SUBROUTINEspl3_nopbct(pw_in, pw_out)

...

Arguments:
TYPE(pw_type),
POINTER
:: pw_in ...
TYPE(pw_type),
POINTER
:: pw_out ...

SUBROUTINEspl3_pbc(pw_in, pw_out)

...

Arguments:
TYPE(pw_type),
POINTER
:: pw_in ...
TYPE(pw_type),
POINTER
:: pw_out ...