nonlinear_terms Module

FIXME : Add documentation



Contents


Variables

Type Visibility Attributes Name Initial
integer, private :: istep_last = 0
integer, private :: nonlinear_mode_switch
integer, private, parameter :: nonlinear_mode_none = 1
integer, private, parameter :: nonlinear_mode_on = 2
real, private, dimension (:,:), allocatable :: ba
real, private, dimension (:,:), allocatable :: gb
real, private, dimension (:,:), allocatable :: bracket
real, private, dimension (:,:,:), allocatable :: aba
real, private, dimension (:,:,:), allocatable :: agb
real, private, dimension (:,:,:), allocatable :: abracket
real, public :: cfl
real, private :: cflx
real, private :: cfly
real, private, dimension(3) :: max_vel_components

Data on maximum velocity of the nonlinear term, the reciprocal of the maximum timestep that satisfies the CFL condition. This currently has to be module level due to potential non-blocking reduction. Stores max_vel_x, max_vel_y and max_vel_error components to allow a max reduction over each element.

integer, public :: cfl_req_hand = mp_request_null
logical, private :: use_cfl_limit
logical, private :: use_2d_cfl
real, private :: error_target

Variables related to the order based error estimate -- see config documentation

integer, private :: istep_error_start
logical, private :: use_order_based_error
logical, public :: split_nonlinear
logical, private :: include_apar
logical, private :: include_bpar
logical, private :: include_phi
real, public :: time_add_explicit_terms(2) = 0.
real, public :: time_add_explicit_terms_mpi = 0.
real, public :: time_add_explicit_terms_field(2) = 0.
logical, public :: nonlin = .false.
logical, private :: initialized = .false.
logical, private :: initializing = .true.
logical, private :: alloc = .true.
logical, private :: zip = .false.
logical, private :: nl_forbid_force_zero = .true.
logical, public :: accelerated = .false.
logical, private :: exist = .false.
real, private, parameter :: dt_cfl_default_large = 1.e8

The "large" cfl time step limit to use when we don't have a valid cfl limit from the NL term.

type(nonlinear_terms_config_type), private :: nonlinear_terms_config

Derived Types

type, public ::  nonlinear_terms_testing

Public type allowing tests to access otherwise-private routines

Type-Bound Procedures

procedure , public , nopass :: add_nl Subroutine

type, public, extends(abstract_config_type) ::  nonlinear_terms_config_type

Used to represent the input configuration of nonlinear_terms

Components

Type Visibility Attributes Name Initial
logical, public :: exist = .false.

Does the related namelist exist in the target input file?

integer, public :: index = 0

Used to hold the specific index of numbered namelists

logical, public :: skip_read = .false.

Do we want to skip the read step in init?

logical, public :: skip_broadcast = .false.

Do we want to skip the broadcast step in init?

real, public :: cfl = 0.95

Scales the estimate CFL limit used to determine when the timestep should be changed. The maximum allowed timestep satisfies delt < cfl * min(Delta_perp/v_perp) where v_perp * delt is the maximum distance travelled in a single timestep.

real, public :: error_target = 0.1

Set the error threshold used to determine when the timestep should change if use_order_based_error is true.

logical, public :: include_apar = .true.

Flag for testing. If false do not include apar contribution to nonlinear term.

logical, public :: include_bpar = .true.

Flag for testing. If false do not include bpar contribution to nonlinear term.

logical, public :: include_phi = .true.

Flag for testing. If false do not include phi contribution to nonlinear term.

integer, public :: istep_error_start = 30

Set the first timestep for which the order based error checks are made if use_order_based_error is true.

logical, public :: nl_forbid_force_zero = .true.

If true (default) then forces the nonlinear source term to zero in the forbidden region.

character(len=20), public :: nonlinear_mode = 'default'

Determines if the nonlinear terms should be calculated. Must be one of:

Read more…
logical, public :: split_nonlinear = .false.

Do we evolve the nonlinear term separately from the linear terms (true) or include the nonlinear term as a source in the standard algorithm (false).

logical, public :: use_2d_cfl = .true.

If true then sum x and y cfl limiting velocities instead of taking the maximum.

logical, public :: use_cfl_limit = .true.

If true then use the cfl limit to set the maximum timestep allowed.

logical, public :: use_order_based_error = .false.

If true then use an error estimate from comparing the nonlinear source calculated using 2nd and 3rd order Adams-Bashforth schemes to control the timestep in use. This does not disable the CFL estimate.

logical, public :: zip = .false.

Not currently used, should consider removing. Original documentation was "Experts only (for secondary/tertiary calculations)." which suggests a close relation to the eqzip option of knobs.

Type-Bound Procedures

procedure , public , :: is_initialised => is_initialised_generic Function
procedure , public , :: init => init_generic Subroutine
procedure , public , :: setup => setup_generic Subroutine
procedure , public , :: write_namelist_header Subroutine
procedure , public , :: get_name => get_name_generic Function
procedure , public , :: get_requires_index => get_requires_index_generic Function
procedure , public , nopass :: write_namelist_footer Subroutine
generic, public , :: write_key_val => write_key_val_string, write_key_val_real, write_key_val_complex, write_key_val_integer, write_key_val_logical, write_key_val_real_array, write_key_val_complex_array, write_key_val_integer_array
procedure , public :: read => read_nonlinear_terms_config Subroutine
procedure , public :: write => write_nonlinear_terms_config Subroutine
procedure , public :: reset => reset_nonlinear_terms_config Subroutine
procedure , public :: broadcast => broadcast_nonlinear_terms_config Subroutine
procedure , public , nopass :: get_default_name => get_default_name_nonlinear_terms_config Function
procedure , public , nopass :: get_default_requires_index => get_default_requires_index_nonlinear_terms_config Function

Functions

private function estimate_error(g1, g2, g3) result(error)

Get an estimate of the error on the NL source term by comparing 2nd and 3rd order calculations of the source term.

Read more…

Arguments

Type IntentOptional Attributes Name
complex, intent(in), dimension(:, :, :) :: g1
complex, intent(in), dimension(:, :, :) :: g2
complex, intent(in), dimension(:, :, :) :: g3

Return Value real

private pure function get_max_vel(components) result(max_vel)

Given the max_vel_components array return the limiting max_vel

Arguments

Type IntentOptional Attributes Name
real, intent(in), dimension(3) :: components

Return Value real

Gets the default name for this namelist

Arguments

None

Return Value character(len=CONFIG_MAX_NAME_LEN)

Gets the default requires index for this namelist

Arguments

None

Return Value logical

public pure function get_nonlinear_terms_config()

Get the module level config instance

Arguments

None

Return Value type(nonlinear_terms_config_type)


Subroutines

public subroutine check_nonlinear_terms(report_unit, delt_adj)

FIXME : Add documentation

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: report_unit
real, intent(in) :: delt_adj

public subroutine wnml_nonlinear_terms(unit)

FIXME : Add documentation

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: unit

public subroutine init_nonlinear_terms(nonlinear_terms_config_in)

FIXME : Add documentation

Arguments

Type IntentOptional Attributes Name
type(nonlinear_terms_config_type), intent(in), optional :: nonlinear_terms_config_in

public subroutine read_parameters(nonlinear_terms_config_in)

FIXME : Add documentation

Arguments

Type IntentOptional Attributes Name
type(nonlinear_terms_config_type), intent(in), optional :: nonlinear_terms_config_in

public subroutine add_explicit_terms(g1, g2, g3, phi, apar, bpar, istep, bd)

FIXME : Add documentation

Arguments

Type IntentOptional Attributes Name
complex, intent(inout), dimension (-ntgrid:,:,g_lo%llim_proc:) :: g1
complex, intent(inout), dimension (-ntgrid:,:,g_lo%llim_proc:) :: g2
complex, intent(inout), dimension (-ntgrid:,:,g_lo%llim_proc:) :: g3
complex, intent(in), dimension (-ntgrid:,:,:) :: phi
complex, intent(in), dimension (-ntgrid:,:,:) :: apar
complex, intent(in), dimension (-ntgrid:,:,:) :: bpar
integer, intent(in) :: istep
real, intent(in) :: bd

private subroutine add_explicit(g1, g2, g3, phi, apar, bpar, istep, bd, nl)

FIXME : Add documentation

Arguments

Type IntentOptional Attributes Name
complex, intent(inout), dimension (-ntgrid:,:,g_lo%llim_proc:) :: g1
complex, intent(inout), dimension (-ntgrid:,:,g_lo%llim_proc:) :: g2
complex, intent(inout), dimension (-ntgrid:,:,g_lo%llim_proc:) :: g3
complex, intent(in), dimension (-ntgrid:,:,:) :: phi
complex, intent(in), dimension (-ntgrid:,:,:) :: apar
complex, intent(in), dimension (-ntgrid:,:,:) :: bpar
integer, intent(in) :: istep
real, intent(in) :: bd
logical, intent(in), optional :: nl

private subroutine nl_center(gtmp, bd)

Takes input array evaluated at theta grid points and overwrites it with array evaluated at cell centers note that there is an extra factor of 2 in output array

Arguments

Type IntentOptional Attributes Name
complex, intent(inout), dimension (-ntgrid:,:,g_lo%llim_proc:) :: gtmp
real, intent(in) :: bd

public subroutine calculate_current_nl_source_and_cfl_limit(g_in, g1, phi, apar, bpar, max_vel_local, need_to_adjust, calculate_cfl_limit)

Calculates the current nonlinear source term by calling add_nl and the associated cfl limit.

Arguments

Type IntentOptional Attributes Name
complex, intent(in), dimension (:,:,:) :: g_in
complex, intent(out), dimension (:,:,:) :: g1
complex, intent(in), dimension (:,:,:) :: phi
complex, intent(in), dimension (:,:,:) :: apar
complex, intent(in), dimension (:,:,:) :: bpar
real, intent(out) :: max_vel_local
logical, intent(in) :: need_to_adjust
logical, intent(in), optional :: calculate_cfl_limit

private subroutine add_nl(g_in, g1, phi, apar, bpar, adjust)

Calculate the nonlinear term and part of the corresponding CFL condition

Arguments

Type IntentOptional Attributes Name
complex, intent(in), dimension (-ntgrid:,:,g_lo%llim_proc:) :: g_in
complex, intent(out), dimension (-ntgrid:,:,g_lo%llim_proc:) :: g1
complex, intent(in), dimension (-ntgrid:,:,:) :: phi
complex, intent(in), dimension (-ntgrid:,:,:) :: apar
complex, intent(in), dimension (-ntgrid:,:,:) :: bpar
logical, intent(in), optional :: adjust

private subroutine load_kx_phi(g1, phi)

FIXME : Add documentation

Arguments

Type IntentOptional Attributes Name
complex, intent(inout), dimension (-ntgrid:,:,g_lo%llim_proc:) :: g1
complex, intent(in), dimension (-ntgrid:,:,:) :: phi

private subroutine load_ky_phi(g1, phi)

FIXME : Add documentation

Arguments

Type IntentOptional Attributes Name
complex, intent(inout), dimension (-ntgrid:,:,g_lo%llim_proc:) :: g1
complex, intent(in), dimension (-ntgrid:,:,:) :: phi

private subroutine load_kx_apar(g1, apar)

FIXME : Add documentation

Arguments

Type IntentOptional Attributes Name
complex, intent(inout), dimension (-ntgrid:,:,g_lo%llim_proc:) :: g1
complex, intent(in), dimension (-ntgrid:,:,:) :: apar

private subroutine load_ky_apar(g1, apar)

FIXME : Add documentation

Arguments

Type IntentOptional Attributes Name
complex, intent(inout), dimension (-ntgrid:,:,g_lo%llim_proc:) :: g1
complex, intent(in), dimension (-ntgrid:,:,:) :: apar

private subroutine load_kx_bpar(g1, bpar)

FIXME : Add documentation

Arguments

Type IntentOptional Attributes Name
complex, intent(inout), dimension (-ntgrid:,:,g_lo%llim_proc:) :: g1
complex, intent(in), dimension (-ntgrid:,:,:) :: bpar

private subroutine load_ky_bpar(g1, bpar)

FIXME : Add documentation

Arguments

Type IntentOptional Attributes Name
complex, intent(inout), dimension (-ntgrid:,:,g_lo%llim_proc:) :: g1
complex, intent(in), dimension (-ntgrid:,:,:) :: bpar

private subroutine calculate_bracket(is_first_term)

Calculate (d Chi /dx).(d g_wesson/dy) and store in bracket if is_first_term = .true. else calculate (d Chi /dy).(d g_wesson/dx) and subtract from bracket

Read more…

Arguments

Type IntentOptional Attributes Name
logical :: is_first_term

public subroutine nb_check_time_step_too_large()

Finish nonblocking calculation of the maximum velocity and set the cfl limit.

Arguments

None

Finish nonblocking calculation of the maximum velocity

Read more…

Arguments

None

Calculates the cfl limit from the module level max_vel value saves it using save_dt_cfl and then sets the reset flag based on checking if the current time step is too large.

Arguments

None

public subroutine reset_init()

FIXME : Add documentation

Arguments

None

public subroutine finish_init()

FIXME : Add documentation

Arguments

None

public subroutine finish_nonlinear_terms()

FIXME : Add documentation

Arguments

None

public subroutine set_nonlinear_terms_config(nonlinear_terms_config_in)

Set the module level config type Will abort if the module has already been initialised to avoid inconsistencies.

Arguments

Type IntentOptional Attributes Name
type(nonlinear_terms_config_type), intent(in), optional :: nonlinear_terms_config_in

private subroutine read_nonlinear_terms_config(self)

Reads in the nonlinear_terms_knobs namelist and populates the member variables

Arguments

Type IntentOptional Attributes Name
class(nonlinear_terms_config_type), intent(inout) :: self

private subroutine write_nonlinear_terms_config(self, unit)

Writes out a namelist representing the current state of the config object

Arguments

Type IntentOptional Attributes Name
class(nonlinear_terms_config_type), intent(in) :: self
integer, intent(in), optional :: unit

private subroutine reset_nonlinear_terms_config(self)

Resets the config object to the initial empty state

Arguments

Type IntentOptional Attributes Name
class(nonlinear_terms_config_type), intent(inout) :: self

private subroutine broadcast_nonlinear_terms_config(self)

Broadcasts all config parameters so object is populated identically on all processors

Arguments

Type IntentOptional Attributes Name
class(nonlinear_terms_config_type), intent(inout) :: self