Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion components/driver/source/driver_mesh_mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ module driver_mesh_mod
log_scratch_space, &
log_level_debug, &
log_level_error
use panel_decomposition_mod, only: panel_decomposition_type
use panel_decomposition_mod, only: panel_decomposition_type, &
calc_mapping_factor
use partition_mod, only: partitioner_interface

use runtime_partition_lfric_mod, only: get_partition_parameters
Expand Down Expand Up @@ -138,6 +139,9 @@ subroutine init_mesh( config, &
character(str_def), allocatable :: tmp_mesh_names(:)
character(str_max_filename) :: input_mesh_file
integer(i_def), allocatable :: stencil_depths(:)
integer(i_def), allocatable :: mapping_factors(:)

type(global_mesh_type), pointer :: global_mesh

procedure(partitioner_interface), pointer :: partitioner_ptr

Expand All @@ -147,6 +151,9 @@ subroutine init_mesh( config, &

integer(i_def) :: i, n_digit

nullify(global_mesh)
nullify(partitioner_ptr)

!============================================================================
! Extract configuration variables
!============================================================================
Expand Down Expand Up @@ -314,6 +321,13 @@ subroutine init_mesh( config, &
!===========================================================
call check_global_mesh( config, mesh_names )

allocate(mapping_factors(size(mesh_names)))
do i=1, size(mesh_names)
global_mesh => global_mesh_collection%get_global_mesh(mesh_names(i))
mapping_factors(i) = calc_mapping_factor(global_mesh, &
global_mesh_collection)
end do

! 2.2e Partition the global meshes
!===========================================================
call create_local_mesh( mesh_names, &
Expand All @@ -322,6 +336,7 @@ subroutine init_mesh( config, &
stencil_depths, &
generate_inner_halos, &
partitioner_ptr, &
mapping_factors, &
enforce_constraints=check_partitions )


Expand Down
87 changes: 34 additions & 53 deletions components/driver/source/mesh/add_mesh_map_mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,20 @@ module add_mesh_map_mod
use constants_mod, only: i_def, str_def, cmdi
use log_mod, only: log_event, &
log_scratch_space, &
LOG_LEVEL_ERROR, &
LOG_LEVEL_INFO
log_level_error, &
log_level_info


use extrusion_mod, only: extrusion_type, &
uniform_extrusion_type, &
geometric_extrusion_type, &
quadratic_extrusion_type
use local_mesh_mod, only: local_mesh_type
use mesh_collection_mod, only: mesh_collection
use mesh_mod, only: mesh_type
use sci_query_mod, only: check_lbc
use ugrid_mesh_data_mod, only: ugrid_mesh_data_type


use local_mesh_collection_mod, only: local_mesh_collection
use mesh_collection_mod, only: mesh_collection

implicit none

private
Expand All @@ -54,11 +51,16 @@ subroutine assign_mesh_maps( mesh_names )
character(str_def), allocatable :: target_mesh_names(:)
character(str_def), allocatable :: local_mesh_names(:)

type(mesh_type), pointer :: mesh => null()
type(local_mesh_type), pointer :: local_mesh => null()
type(mesh_type), pointer :: mesh
type(local_mesh_type), pointer :: local_mesh

type(mesh_type), pointer :: mesh_A
type(mesh_type), pointer :: mesh_B

integer(i_def) :: i, j, k

nullify( mesh, mesh_A, mesh_B, local_mesh )

if (size(mesh_names) > 1) then

!============================================================================
Expand Down Expand Up @@ -122,7 +124,9 @@ subroutine assign_mesh_maps( mesh_names )
end do

if (mesh_name_B /= cmdi) then
call add_mesh_map( mesh_name_A, mesh_name_B )
mesh_A => mesh_collection%get_mesh(mesh_name_A)
mesh_B => mesh_collection%get_mesh(mesh_name_B)
call add_mesh_map( mesh_A, mesh_B )
end if
end do

Expand All @@ -136,55 +140,32 @@ end subroutine assign_mesh_maps


!> @brief Creates integrid map between two mesh_type objects.
!> @description The meshes should be contain valid local mesh integrid maps.
!> @param[in] source_mesh_name Name of source_mesh in the
!! application mesh collection.
!> @param[in] target_mesh_name Name of source_mesh in the
!! application mesh collection
subroutine add_mesh_map( source_mesh_name, &
target_mesh_name )
!> @description The meshes should contain valid local mesh integrid maps.
!> @param[in] source_mesh Soure mesh object
!> @param[in] target_mesh Target mesh object
subroutine add_mesh_map( source_mesh, target_mesh )

implicit none

character(len=str_def), intent(in) :: source_mesh_name
character(len=str_def), intent(in) :: target_mesh_name

type(mesh_type), pointer :: source_mesh => null()
type(mesh_type), pointer :: target_mesh => null()


source_mesh => mesh_collection % get_mesh( source_mesh_name )
target_mesh => mesh_collection % get_mesh( target_mesh_name )

if ( associated(source_mesh) .and. &
associated(target_mesh) ) then

! Mesh tag names may be different but "could point to the same mesh
! So check the IDs are not the same
if (source_mesh%get_id() == target_mesh%get_id()) then
write(log_scratch_space,'(A)') &
'Unable to create intergrid map: Source('// &
trim(source_mesh_name)//' and target('// &
trim(target_mesh_name)//') mesh IDs are the same'
call log_event( log_scratch_space, LOG_LEVEL_ERROR )
end if

call source_mesh % add_mesh_map (target_mesh)
write(log_scratch_space,'(A,I0,A)') &
'Adding intergrid map "'// &
trim(source_mesh_name)//'"-->"'// &
trim(target_mesh_name)//'"'
call log_event( log_scratch_space, LOG_LEVEL_INFO )
else
write(log_scratch_space,'(A,I0,A)') &
'Unable to create mesh map between "'// &
trim(source_mesh_name)//'"-"'// &
trim(target_mesh_name)//'"'
call log_event( log_scratch_space, LOG_LEVEL_ERROR )
type(mesh_type), intent(inout) :: source_mesh
type(mesh_type), intent(inout) :: target_mesh

! Mesh tag names may be different but "could point to the same mesh
! So check the IDs are not the same
if (source_mesh%get_id() == target_mesh%get_id()) then
write(log_scratch_space,'(A)') &
'Unable to create intergrid map: Source('// &
trim(source_mesh%get_mesh_name())//' and target('// &
trim(target_mesh%get_mesh_name())//') mesh IDs are the same'
call log_event( log_scratch_space, log_level_error )
end if

nullify(source_mesh)
nullify(target_mesh)
call source_mesh % add_mesh_map (target_mesh)
write(log_scratch_space,'(a,i0,a)') &
'Adding intergrid map "'// &
trim(source_mesh%get_mesh_name())//'"-->"'// &
trim(target_mesh%get_mesh_name())//'"'
call log_event( log_scratch_space, log_level_info )

return
end subroutine add_mesh_map
Expand Down
46 changes: 37 additions & 9 deletions components/driver/source/mesh/load_global_mesh_mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ module load_global_mesh_mod
LOG_LEVEL_INFO
use ugrid_mesh_data_mod, only: ugrid_mesh_data_type


use global_mesh_collection_mod, only: global_mesh_collection
use global_mesh_collection_mod, only: global_mesh_collection_type, &
global_mesh_collection

implicit none

Expand All @@ -37,18 +37,34 @@ module load_global_mesh_mod
!> @param[in] mesh_names The names of the global meshes to load
!> from the <input_mesh_file>.
subroutine load_global_mesh_multiple( input_mesh_file, &
mesh_names )
mesh_names, &
rename_to )


implicit none

character(str_max_filename), intent(in) :: input_mesh_file
character(str_def), intent(in) :: mesh_names(:)

character(str_def), optional :: rename_to(:)

character(str_def), allocatable :: names(:)

integer(i_def) :: i


allocate(names, source=mesh_names)

if ( present(rename_to) ) then
if (size(rename_to) == size(mesh_names)) then
deallocate(names)
allocate(names, source=rename_to)
end if
end if

do i=1, size(mesh_names)
call load_global_mesh_single( input_mesh_file, &
mesh_names(i) )
mesh_names(i), rename_to=names(i) )
end do

end subroutine load_global_mesh_multiple
Expand All @@ -61,17 +77,29 @@ end subroutine load_global_mesh_multiple
!> @param[in] mesh_name The name of the global mesh to load
!> from the <input_mesh_file>.
subroutine load_global_mesh_single( input_mesh_file, &
mesh_name )
mesh_name, rename_to )

implicit none

character(str_max_filename), intent(in) :: input_mesh_file
character(str_def), intent(in) :: mesh_name
character(*), intent(in) :: input_mesh_file
character(*), intent(in) :: mesh_name

character(*), optional, intent(in) :: rename_to


type(ugrid_mesh_data_type) :: ugrid_mesh_data
type(global_mesh_type) :: global_mesh

if (.not. global_mesh_collection%check_for(mesh_name)) then
character(str_def) :: name


if ( present(rename_to) ) then
name=rename_to
else
name=mesh_name
end if

if (.not. global_mesh_collection%check_for(name)) then

write(log_scratch_space,'(A)') &
'Reading global mesh: "'//trim(mesh_name)//'"'
Expand All @@ -81,7 +109,7 @@ subroutine load_global_mesh_single( input_mesh_file, &
call ugrid_mesh_data%read_from_file( trim(input_mesh_file), &
mesh_name )

global_mesh = global_mesh_type( ugrid_mesh_data )
global_mesh = global_mesh_type( ugrid_mesh_data, rename_to=name )
call ugrid_mesh_data%clear()

call global_mesh_collection%add_new_global_mesh ( global_mesh )
Expand Down
Loading
Loading