Multigrid for solving the Helmholtz problem
Sets up multigrids, i.e. - creates meshes on all levels - creates prolongation and restriction operators
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(multigrid_t), | intent(inout) | :: | self |
Instance of the type |
||
| class(equilibrium_t), | intent(inout) | :: | equi |
Equilibrium (not changed) |
||
| real(kind=FP), | intent(in) | :: | phi |
Toroidal angle |
||
| integer, | intent(in) | :: | nlvls |
Number of multigrid levels |
||
| real(kind=FP), | intent(inout) | :: | spacing_f |
Grid spacing on finest level (only adapted possibly for slab geometry) |
||
| integer, | intent(in) | :: | size_neighbor |
Number of neighbor points determined in each direction (for finest level, on coarser levels always 1) |
||
| integer, | intent(in) | :: | size_ghost_layer |
Depth of ghost point layer (for finest level, on coarser levels always 0) |
||
| type(mesh_cart_t), | intent(out), | target | :: | mesh_finest |
Finest mesh (lvl=1) that was created |
|
| integer, | intent(in), | optional, | dimension(nlvls) | :: | reorder_size |
Grid reordering for each level |
| logical, | intent(in) | :: | extend_beyond_wall |
If true, meshes are extend beyond the wall |
||
| integer, | intent(in), | optional | :: | dbgout |
Debug output level, default = 0, none |
Creates arrays containing information on number of points (total, boundary, and inner) for all mesh levels. The np_lvl arrays can be used for defining explicit-shape arrays; the first_idx_lvl arrays can be used for consecutively-stored mesh data.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(multigrid_t), | intent(inout), | target | :: | self |
Instance of the type |
Writes information of multigrid to netcdf file
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(multigrid_t), | intent(inout) | :: | self |
Instance of the type |
||
| integer, | intent(in) | :: | fgid |
File or group id number of existing Netcdf4 file |
Reads information of multigrid from netcdf file
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(multigrid_t), | intent(inout) | :: | self |
Instance of the type |
||
| integer, | intent(in) | :: | fgid |
File or group id number of existing Netcdf4 file |
||
| type(mesh_cart_t), | intent(out), | target | :: | mesh_finest |
Finest mesh (lvl=1) that was read from file |
Restricts quantity from fine grid to coarse grid
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(multigrid_t), | intent(in) | :: | self |
Instance of the type |
||
| integer, | intent(in) | :: | lvl_f |
Level of fine grid |
||
| real(kind=FP), | intent(in), | dimension(:) | :: | uf |
Quantity on fine grid |
|
| integer, | intent(in) | :: | lvl_c |
Level of coarse grid |
||
| real(kind=FP), | intent(out), | dimension(:) | :: | uc |
Quantity on coarse grid |
Restricts quantity defined only on inner grid points from fine grid to coarse grid
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(multigrid_t), | intent(inout) | :: | self |
Instance of the type |
||
| integer, | intent(in) | :: | lvl_f |
Level of fine grid |
||
| real(kind=FP), | intent(in), | dimension(:) | :: | uf |
Quantity on fine grid |
|
| integer, | intent(in) | :: | lvl_c |
Level of coarse grid |
||
| real(kind=FP), | intent(out), | dimension(:) | :: | uc |
Quantity on coarse grid |
Prolongs quantity from coarse grid to fine grid
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(multigrid_t), | intent(inout) | :: | self |
Instance of the type |
||
| integer, | intent(in) | :: | lvl_c |
Level of coarse grid |
||
| real(kind=FP), | intent(in), | dimension(:) | :: | uc |
Quantity on coarse grid |
|
| integer, | intent(in) | :: | lvl_f |
Level of fine grid |
||
| real(kind=FP), | intent(out), | dimension(:) | :: | uf |
Quantity on fine grid |
Extrapolates boundary points according to homegeneous Neumann boundary condition
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(multigrid_t), | intent(inout) | :: | self |
Instance of the type |
||
| integer, | intent(in) | :: | lvl |
Level of mesh |
||
| real(kind=FP), | intent(inout), | dimension(:) | :: | u |
Quantity |
Exposes multigrid data through multigrid_data object boundary condition
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(multigrid_t), | intent(in), | target | :: | self |
Instance of the type |
|
| type(multigrid_intermediate_data_t), | intent(out), | target | :: | intermediate_object |
Intermediate object, holds arrays of mesh_cart and csrmat "data" |
|
| type(multigrid_data_t), | intent(out) | :: | data_object |
Destination multigrid_data object |
Creates the restriction matrix mappings mrcsr between all consecutive mesh levels - Projection method based on wighted 9 point average is used - Only inner grid points are taken into account
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(multigrid_t), | intent(inout), | target | :: | self |
Instance of the type |
|
| integer, | intent(in) | :: | order |
Order of restriction 0: trivial restriction 1: weighted restriction (9-point stencil) |
||
| integer, | intent(in) | :: | dbgout |
Debug output level |
Creates restriction matrix mrcsr_inner purely based on inner grid points - Based on conventional restriction matrix previously created by create_mrcsr
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(multigrid_t), | intent(inout), | target | :: | self |
Instance of the type |
|
| integer, | intent(in) | :: | dbgout |
Debug output level |
Creates the prolongation matrix mappings mpcsr between all consecutive mesh levels - Based on bilinear interpolation - Only inner grid points can be set via resulting matrix
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(multigrid_t), | intent(inout), | target | :: | self |
Instance of the type |
|
| integer, | intent(in) | :: | dbgout |
Debug output level |
Data type used to expose multigrid_t data to C/C++
Please see multigrid_t for descriptions of individual
properties/members.
nlvls value is copied directly.
Arrays are exposed with pointers.
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer(kind=c_int32_t), | public | :: | nlvls | ||||
| type(c_ptr), | public | :: | mesh_finest_ptr | ||||
| type(c_ptr), | public | :: | mesh_coarse_array | ||||
| type(c_ptr), | public | :: | mrcsr | ||||
| type(c_ptr), | public | :: | mrcsr_inner | ||||
| type(c_ptr), | public | :: | mpcsr | ||||
| type(c_ptr), | public | :: | np_lvl | ||||
| type(c_ptr), | public | :: | np_boundary_lvl | ||||
| type(c_ptr), | public | :: | np_inner_lvl | ||||
| type(c_ptr), | public | :: | first_idx_lvl | ||||
| type(c_ptr), | public | :: | first_idx_boundary_lvl | ||||
| type(c_ptr), | public | :: | first_idx_inner_lvl |
Data type needed to expose multigrid_t data to C/C++.
Objects of this type shall hold arrays of types
mesh_cart_data_t and csrmat_data_t.
These are strictly required for the exposure (we cannot use
the arrays of type mesh_cart_t and csrmat_t that exist within
multigrid_t).
In princple this data type could be merged into multigrid_t,
but keeping it separate should simplify maintenance.
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| type(mesh_cart_data_t), | public | :: | mesh_finest_ptr_data | ||||
| type(mesh_cart_data_t), | public, | allocatable, dimension(:) | :: | mesh_coarse_array_data | |||
| type(csrmat_data_t), | public, | allocatable, dimension(:) | :: | mrcsr_data | |||
| type(csrmat_data_t), | public, | allocatable, dimension(:) | :: | mrcsr_inner_data | |||
| type(csrmat_data_t), | public, | allocatable, dimension(:) | :: | mpcsr_data |
| final :: destructor_multigrid_intermediate_data |
Object which contains the multigrid meshes for solving Helmholtz problems. This includes nlvl number of meshes of increasing coarseness, restriction and prolongation matrices.
| final :: destructor_multigrid |
| procedure, public :: init => initialize_multigrid | |
| procedure, public :: write_netcdf => multigrid_write_netcdf | |
| procedure, public :: read_netcdf => multigrid_read_netcdf | |
| procedure, public :: set_phi_coarse | |
| procedure, public :: copy | |
| procedure, public :: get_nlvls | |
| procedure, public :: get_np | |
| procedure, public :: get_np_boundary | |
| procedure, public :: get_np_inner | |
| procedure, public :: get_mesh_pointer | |
| procedure, public :: get_first_idx_lvl_pointer | |
| procedure, public :: get_first_idx | |
| procedure, public :: get_first_idx_boundary_lvl_pointer | |
| procedure, public :: get_first_idx_boundary | |
| procedure, public :: get_first_idx_inner_lvl_pointer | |
| procedure, public :: get_first_idx_inner | |
| procedure, public :: get_np_total | |
| procedure, public :: get_np_inner_total | |
| procedure, public :: restrict | |
| procedure, public :: restrict_inner | |
| procedure, public :: prolong | |
| procedure, public :: extrapolate_boundary_points | |
| procedure, public :: expose_data | |
| procedure, public :: get_mrcsr_pointer | |
| procedure, public :: get_mpcsr_pointer |
Returns mesh on desired level
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(multigrid_t), | intent(inout), | target | :: | self |
Instance of the type |
|
| integer, | intent(in) | :: | lvl |
Multigrid level of desired mesh |
Pointer to desired mesh
Returns nlvls
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(multigrid_t), | intent(in) | :: | self |
Instance of the type |
Returns the number of total mesh points at the given level
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(multigrid_t), | intent(in) | :: | self |
Instance of the type |
||
| integer, | intent(in) | :: | lvl |
Desired multigrid level |
Returns the number of boundary mesh points at the given level
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(multigrid_t), | intent(in) | :: | self |
Instance of the type |
||
| integer, | intent(in) | :: | lvl |
Desired multigrid level |
Returns the number of inner mesh points at the given level
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(multigrid_t), | intent(in) | :: | self |
Instance of the type |
||
| integer, | intent(in) | :: | lvl |
Desired multigrid level |
Returns a pointer to the first_idx_lvl array
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(multigrid_t), | intent(in), | target | :: | self |
Instance of the type |
Returns first_idx at lvl
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(multigrid_t), | intent(in) | :: | self |
Instance of the type |
||
| integer, | intent(in) | :: | lvl |
Level (up to nlvl+1) |
Returns a pointer to the first_idx_boundary_lvl array
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(multigrid_t), | intent(in), | target | :: | self |
Instance of the type |
Returns first_idx_boundary at lvl
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(multigrid_t), | intent(in) | :: | self |
Instance of the type |
||
| integer, | intent(in) | :: | lvl |
Level (up to nlvl+1) |
Returns a pointer to the first_idx_inner_lvl array
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(multigrid_t), | intent(in), | target | :: | self |
Instance of the type |
Returns first_idx_inner at lvl
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(multigrid_t), | intent(in) | :: | self |
Instance of the type |
||
| integer, | intent(in) | :: | lvl |
Level (up to nlvl+1) |
Returns number of mesh points sumed over all levels
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(multigrid_t), | intent(in) | :: | self |
Instance of the type |
Returns number of inner mesh points sumed over all levels
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(multigrid_t), | intent(in) | :: | self |
Instance of the type |
Returns pointer to restriction matrix
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(multigrid_t), | intent(in), | target | :: | self |
Instance of the type |
|
| integer, | intent(in) | :: | lvl_f |
Level of restriction matrix (from lvl_f to lvl_f+1) |
Helmholtz matrix for level lvl
Returns pointer to prolongation matrix
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(multigrid_t), | intent(in), | target | :: | self |
Instance of the type |
|
| integer, | intent(in) | :: | lvl_f |
Level of prolongation matrix (from lvl_f+1 to lvl_f) |
Helmholtz matrix for level lvl
Sets phi value on coarse meshes to a new value On finest mesh that is pointed to, needs to be set separately
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(multigrid_t), | intent(inout), | target | :: | self |
Instance of the type |
|
| real(kind=FP), | intent(in) | :: | new_phi |
New phi value |
Copies the type to multigrid_copy, setting the internal pointer to mesh_finest
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(multigrid_t), | intent(in) | :: | self |
Instance of the type |
||
| type(multigrid_t), | intent(out) | :: | multigrid_copy |
Copied multigrid |
||
| type(mesh_cart_t), | intent(in), | target | :: | mesh_finest |
Finest (lvl=1) mesh to point to |
Frees memory associated with multigrid
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(multigrid_t), | intent(inout) | :: | self |
Instance of the type |
Frees memory associated with multigrid_intermediate_data
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(multigrid_intermediate_data_t), | intent(inout) | :: | self |
Instance of the type |