From 21380d779821693c30ffe4366a213568747a7a44 Mon Sep 17 00:00:00 2001 From: Victor Baconnet Date: Thu, 11 Jul 2024 12:43:47 +0200 Subject: [PATCH 01/67] add some stuff --- src/fluid/flow_ic.f90 | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/src/fluid/flow_ic.f90 b/src/fluid/flow_ic.f90 index 8d821ab8982..471f857c65e 100644 --- a/src/fluid/flow_ic.f90 +++ b/src/fluid/flow_ic.f90 @@ -39,7 +39,7 @@ module flow_ic blasius_quadratic, blasius_quartic, blasius_sin use device, only: device_memcpy, HOST_TO_DEVICE use field, only : field_t - use utils, only : neko_error + use utils, only : neko_error, filename_suffix, filename_chsuffix use coefs, only : coef_t use math, only : col2, cfill, cfill_mask use device_math, only : device_col2, device_cfill, device_cfill_mask @@ -48,6 +48,8 @@ module flow_ic use json_utils, only: json_get use point_zone, only: point_zone_t use point_zone_registry, only: neko_point_zone_registry + use fld_file_data, only: fld_file_data_t + use file, only: file_t implicit none private @@ -72,8 +74,10 @@ subroutine set_flow_ic_int(u, v, w, p, coef, gs, type, params) real(kind=rp) :: delta real(kind=rp), allocatable :: uinf(:) real(kind=rp), allocatable :: zone_value(:) - character(len=:), allocatable :: blasius_approximation - character(len=:), allocatable :: zone_name + character(len=:), allocatable :: read_str + character(len=80) :: suffix + character(len=1024) :: new_fname + integer :: n_sample if (trim(type) .eq. 'uniform') then call json_get(params, 'case.fluid.initial_condition.value', uinf) @@ -81,16 +85,30 @@ subroutine set_flow_ic_int(u, v, w, p, coef, gs, type, params) else if (trim(type) .eq. 'blasius') then call json_get(params, 'case.fluid.blasius.delta', delta) call json_get(params, 'case.fluid.blasius.approximation', & - blasius_approximation) + read_str) call json_get(params, 'case.fluid.blasius.freestream_velocity', uinf) - call set_flow_ic_blasius(u, v, w, delta, uinf, blasius_approximation) + call set_flow_ic_blasius(u, v, w, delta, uinf, read_str) else if (trim(type) .eq. 'point_zone') then call json_get(params, 'case.fluid.initial_condition.base_value', uinf) call json_get(params, 'case.fluid.initial_condition.zone_name', & - zone_name) + read_str) call json_get(params, 'case.fluid.initial_condition.zone_value', & zone_value) - call set_flow_ic_point_zone(u, v, w, uinf, zone_name, zone_value) + call set_flow_ic_point_zone(u, v, w, uinf, read_str, zone_value) + else if (trim(type) .eq. 'field') then + call json_get(params, 'case.fluid.initial_condition.filename', read_str) + + call filename_suffix(read_str, suffix) + + if (trim(suffix) .eq. "nek5000") then + call filename_chsuffix(read_str, new_fname, 'fld') + end if + + if (trim(suffix) .eq. "fld") then + call json_get_or_default(params, & + 'case.fluid.initial_condition.sample', n_sample, -1) + end if + else call neko_error('Invalid initial condition') end if From a916cbb34175d4e97d270049eccf631213ef63de Mon Sep 17 00:00:00 2001 From: Victor Baconnet Date: Mon, 15 Jul 2024 10:54:55 +0200 Subject: [PATCH 02/67] initial commit --- src/fluid/flow_ic.f90 | 46 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 5 deletions(-) diff --git a/src/fluid/flow_ic.f90 b/src/fluid/flow_ic.f90 index 471f857c65e..74b5a0846ec 100644 --- a/src/fluid/flow_ic.f90 +++ b/src/fluid/flow_ic.f90 @@ -95,20 +95,25 @@ subroutine set_flow_ic_int(u, v, w, p, coef, gs, type, params) call json_get(params, 'case.fluid.initial_condition.zone_value', & zone_value) call set_flow_ic_point_zone(u, v, w, uinf, read_str, zone_value) + else if (trim(type) .eq. 'field') then - call json_get(params, 'case.fluid.initial_condition.filename', read_str) + call json_get(params, 'case.fluid.initial_condition.filename', read_str) call filename_suffix(read_str, suffix) - if (trim(suffix) .eq. "nek5000") then - call filename_chsuffix(read_str, new_fname, 'fld') - end if + if (trim(suffix) .eq. "chkp") then + call set_flow_ic_chkp(u, v, w, p, read_str) + else + + ! If it's not chkp or fld assume it's .nek5000 or .fld + if (trim(suffix) .ne. "fld") call filename_chsuffix(read_str, new_fname, 'fld') - if (trim(suffix) .eq. "fld") then call json_get_or_default(params, & 'case.fluid.initial_condition.sample', n_sample, -1) end if + call set_flow_ic_fld(u, v, w, p, read_str, n_sample) + else call neko_error('Invalid initial condition') end if @@ -274,4 +279,35 @@ subroutine set_flow_ic_point_zone(u, v, w, base_value, zone_name, zone_value) end subroutine set_flow_ic_point_zone + !> Set the initial condition of the flow based on a point zone. + !! @details The initial condition is set to the base value and then the + !! zone is filled with the zone value. + !! @param u The x-component of the velocity field. + !! @param v The y-component of the velocity field. + !! @param w The z-component of the velocity field. + !! @param zone_name The name of the point zone. + subroutine set_flow_ic_fld(u, v, w, file_name, sample_idx) + type(field_t), intent(inout) :: u + type(field_t), intent(inout) :: v + type(field_t), intent(inout) :: w + character(len=*), intent(in) :: file_name + integer, intent(in) :: sample_idx + + end subroutine set_flow_ic_fld + + !> Set the initial condition of the flow based on a point zone. + !! @details The initial condition is set to the base value and then the + !! zone is filled with the zone value. + !! @param u The x-component of the velocity field. + !! @param v The y-component of the velocity field. + !! @param w The z-component of the velocity field. + !! @param zone_name The name of the point zone. + subroutine set_flow_ic_chkp(u, v, w, file_name) + type(field_t), intent(inout) :: u + type(field_t), intent(inout) :: v + type(field_t), intent(inout) :: w + character(len=*), intent(in) :: file_name + + end subroutine set_flow_ic_chkp + end module flow_ic From e7349e7ffa4229f3986be89aee8617d38019a23c Mon Sep 17 00:00:00 2001 From: Victor Baconnet Date: Tue, 16 Jul 2024 12:05:14 +0200 Subject: [PATCH 03/67] Add field initial condition --- src/fluid/flow_ic.f90 | 188 ++++++++++++++++++++++++++++++++---- src/scalar/scalar_ic.f90 | 204 +++++++++++++++++++++++++++++++++++++-- 2 files changed, 364 insertions(+), 28 deletions(-) diff --git a/src/fluid/flow_ic.f90 b/src/fluid/flow_ic.f90 index 74b5a0846ec..6491f08f898 100644 --- a/src/fluid/flow_ic.f90 +++ b/src/fluid/flow_ic.f90 @@ -33,22 +33,24 @@ !> Initial flow condition module flow_ic use num_types, only : rp + use logger, only: neko_log, LOG_SIZE use gather_scatter, only : gs_t, GS_OP_ADD use neko_config, only : NEKO_BCKND_DEVICE use flow_profile, only : blasius_profile, blasius_linear, blasius_cubic, & blasius_quadratic, blasius_quartic, blasius_sin use device, only: device_memcpy, HOST_TO_DEVICE use field, only : field_t - use utils, only : neko_error, filename_suffix, filename_chsuffix + use utils, only : neko_error, filename_suffix, filename_chsuffix, neko_warning use coefs, only : coef_t - use math, only : col2, cfill, cfill_mask + use math, only : col2, cfill, cfill_mask, copy use device_math, only : device_col2, device_cfill, device_cfill_mask use user_intf, only : useric use json_module, only : json_file - use json_utils, only: json_get + use json_utils, only: json_get, json_get_or_default use point_zone, only: point_zone_t use point_zone_registry, only: neko_point_zone_registry use fld_file_data, only: fld_file_data_t + use checkpoint, only: chkp_t use file, only: file_t implicit none private @@ -71,48 +73,116 @@ subroutine set_flow_ic_int(u, v, w, p, coef, gs, type, params) type(gs_t), intent(inout) :: gs character(len=*) :: type type(json_file), intent(inout) :: params - real(kind=rp) :: delta + real(kind=rp) :: delta, tol real(kind=rp), allocatable :: uinf(:) real(kind=rp), allocatable :: zone_value(:) - character(len=:), allocatable :: read_str + character(len=:), allocatable :: read_str, prev_mesh character(len=80) :: suffix character(len=1024) :: new_fname - integer :: n_sample + integer :: sample_idx, fpos + logical :: found + character(len=LOG_SIZE) :: log_buf if (trim(type) .eq. 'uniform') then + call json_get(params, 'case.fluid.initial_condition.value', uinf) call set_flow_ic_uniform(u, v, w, uinf) + write (log_buf, '(A,"[",2(F10.6,","),F10.6,"]")') "Value: ", uinf(1), uinf(2), uinf(3) + call neko_log%message(log_buf) + else if (trim(type) .eq. 'blasius') then + call json_get(params, 'case.fluid.blasius.delta', delta) call json_get(params, 'case.fluid.blasius.approximation', & read_str) call json_get(params, 'case.fluid.blasius.freestream_velocity', uinf) + + write (log_buf, '(A,F10.6)') "delta : ", delta + call neko_log%message(log_buf) + call neko_log%message( "Approximation : " // trim(read_str)) + write (log_buf, '(A,F10.6)') "Free-stream velocity: ", uinf + call neko_log%message(log_buf) + call set_flow_ic_blasius(u, v, w, delta, uinf, read_str) + else if (trim(type) .eq. 'point_zone') then + call json_get(params, 'case.fluid.initial_condition.base_value', uinf) call json_get(params, 'case.fluid.initial_condition.zone_name', & read_str) call json_get(params, 'case.fluid.initial_condition.zone_value', & - zone_value) + zone_value) + + write (log_buf, '(A,F10.6)') "Base value: ", uinf + call neko_log%message(log_buf) + call neko_log%message( "Zone name : " // trim(read_str)) + write (log_buf, '(A,F10.6)') "Zone value: ", zone_value + call neko_log%message(log_buf) + call set_flow_ic_point_zone(u, v, w, uinf, read_str, zone_value) else if (trim(type) .eq. 'field') then - call json_get(params, 'case.fluid.initial_condition.filename', read_str) + call json_get(params, 'case.fluid.initial_condition.file_name', & + read_str) call filename_suffix(read_str, suffix) + call neko_log%message("File name: " // trim(read_str)) if (trim(suffix) .eq. "chkp") then - call set_flow_ic_chkp(u, v, w, p, read_str) - else - ! If it's not chkp or fld assume it's .nek5000 or .fld - if (trim(suffix) .ne. "fld") call filename_chsuffix(read_str, new_fname, 'fld') + call params%get("case.fluid.initial_condition.previous_mesh", & + prev_mesh, found) + + if (found) then + + call neko_log%message("Previous mesh: " // trim(prev_mesh)) + call params%get('case.fluid.initial_condition.tolerance', tol, & + found) + if (found) then + write (log_buf, '(A,F10.6)') "Tolerance : ", tol + call neko_log%message(log_buf) + call set_flow_ic_chkp(u, v, w, p, read_str, prev_mesh, tol) + else + call set_flow_ic_chkp(u, v, w, p, read_str, prev_mesh) + end if + + ! In this case no mesh interpolation but potential for interpolation + ! between different polynomial orders + else + call set_flow_ic_chkp(u, v, w, p, read_str) + end if + + else !if it's not a chkp we assume it's a fld file + + ! Get the index of the file to sample call json_get_or_default(params, & - 'case.fluid.initial_condition.sample', n_sample, -1) - end if + 'case.fluid.initial_condition.sample_index', sample_idx, -1) + + if (sample_idx .ne. -1) then + write (log_buf, '(A,I5.5)') "Sample index: ", sample_idx + call neko_log%message(log_buf) + end if + + ! If it's not chkp or fld assume it's either .nek5000 or .f00* + if (trim(suffix) .ne. "fld") then - call set_flow_ic_fld(u, v, w, p, read_str, n_sample) + ! Check if the suffix is of type "f000*", and if so extract + ! the index e.g. "f00035" --> 35 + ! NOTE: overwrites whatever is in sampled_index + fpos = scan(suffix, 'f') + if (fpos .eq. 1) then + if (sample_idx .ne. -1) & + call neko_warning("Overwriting sample index!") + read (suffix(2:), "(I5.5)") sample_idx + end if + + call filename_chsuffix(read_str, read_str, 'fld') + + end if + + call set_flow_ic_fld(u, v, w, p, read_str, sample_idx) + end if else call neko_error('Invalid initial condition') @@ -285,14 +355,64 @@ end subroutine set_flow_ic_point_zone !! @param u The x-component of the velocity field. !! @param v The y-component of the velocity field. !! @param w The z-component of the velocity field. - !! @param zone_name The name of the point zone. - subroutine set_flow_ic_fld(u, v, w, file_name, sample_idx) + !! @param p The pressure field. + !! @param file_name The name of the "fld" file series. + !! @param sample_idx index of the field file .f000* to read, default is + !! -1.. + subroutine set_flow_ic_fld(u, v, w, p, file_name, sample_idx) type(field_t), intent(inout) :: u type(field_t), intent(inout) :: v type(field_t), intent(inout) :: w + type(field_t), intent(inout) :: p character(len=*), intent(in) :: file_name integer, intent(in) :: sample_idx + type(fld_file_data_t) :: fld_data + type(file_t) :: f + + ! Should this init be init(u%msh%nelv, u%msh%offset_el)? + call fld_data%init + + f = file_t(trim(file_name)) + + ! Set the counter if not the default value + if (sample_idx .ne. -1) then + call f%set_counter(sample_idx) + call f%read(fld_data) + else + ! If we default to the last file of the series we need to call + ! read once to get the # of samples etc + call f%read(fld_data) + + if (fld_data%meta_nsamples .gt. 0) then + call f%set_counter(fld_data%meta_nsamples + & + fld_data%meta_start_counter - 1) + call f%read(fld_data) + end if + end if + + ! + ! Check if the data in the fld file matches the current case. + ! Note that this is a safeguard and there are corner cases where + ! two different meshes have the same dimension, same # of elements + ! and same polynomial orders but this should be enough to cover most cases. + ! + if ( (fld_data%gdim .ne. u%msh%gdim) .or. & + (fld_data%glb_nelv .ne. u%msh%glb_nelv) .or. & + (fld_data%lx .ne. u%dof%Xh%lx) .or. & + (fld_data%ly .ne. u%dof%Xh%ly) .or. & + (fld_data%lz .ne. u%dof%Xh%lz)) then + call neko_error("The fld file must match the current mesh") + end if + + ! Note: we do not copy on the GPU since `set_flow_ic_common` does the copy for us + call copy(u%x, fld_data%u%x, u%dof%size()) + call copy(v%x, fld_data%v%x, v%dof%size()) + call copy(w%x, fld_data%w%x, w%dof%size()) + call copy(p%x, fld_data%p%x, p%dof%size()) + + call fld_data%free + end subroutine set_flow_ic_fld !> Set the initial condition of the flow based on a point zone. @@ -301,12 +421,42 @@ end subroutine set_flow_ic_fld !! @param u The x-component of the velocity field. !! @param v The y-component of the velocity field. !! @param w The z-component of the velocity field. - !! @param zone_name The name of the point zone. - subroutine set_flow_ic_chkp(u, v, w, file_name) + !! @param p The pressure field. + !! @param file_name The name of the checkpoint file. + !! @param previous_mesh If specified, the name of the previouos mesh from + !! which to interpolate. + !! @param tol If specified, tolerance to use for the mesh interpolation. + subroutine set_flow_ic_chkp(u, v, w, p, file_name, previous_mesh, tol) type(field_t), intent(inout) :: u type(field_t), intent(inout) :: v type(field_t), intent(inout) :: w + type(field_t), intent(inout) :: p character(len=*), intent(in) :: file_name + character(len=*), intent(in), optional :: previous_mesh + real(kind=rp), intent(in), optional :: tol + + type(chkp_t) :: chkp_data + type(file_t) :: f, meshf + + call chkp_data%init(u, v, w, p) + + ! Mesh interpolation if specified + if (present(previous_mesh)) then + meshf = file_t(trim(previous_mesh)) + call meshf%read(chkp_data%previous_mesh) + end if + + ! Tolerance is by default 1d-6 + if (present(tol)) chkp_data%mesh2mesh_tol = tol + + ! Read the chkp and perform interpolation + f = file_t(trim(file_name)) + call f%read(chkp_data) + + call copy(u%x, chkp_data%u%x, u%dof%size()) + call copy(v%x, chkp_data%v%x, v%dof%size()) + call copy(w%x, chkp_data%w%x, w%dof%size()) + call copy(p%x, chkp_data%p%x, p%dof%size()) end subroutine set_flow_ic_chkp diff --git a/src/scalar/scalar_ic.f90 b/src/scalar/scalar_ic.f90 index 644bbf4f973..0f421912fcd 100644 --- a/src/scalar/scalar_ic.f90 +++ b/src/scalar/scalar_ic.f90 @@ -38,14 +38,19 @@ module scalar_ic use device_math, only : device_col2 use device, only : device_memcpy, HOST_TO_DEVICE use field, only : field_t - use utils, only : neko_error + use utils, only : neko_error, filename_chsuffix, filename_suffix, neko_warning use coefs, only : coef_t - use math, only : col2, cfill, cfill_mask + use math, only : col2, cfill, cfill_mask, copy use user_intf, only : useric_scalar use json_module, only : json_file - use json_utils, only: json_get + use json_utils, only: json_get, json_get_or_default use point_zone, only: point_zone_t use point_zone_registry, only: neko_point_zone_registry + use field_registry, only: neko_field_registry + use logger, only: neko_log, LOG_SIZE + use fld_file_data, only: fld_file_data_t + use checkpoint, only: chkp_t + use file, only: file_t implicit none private @@ -75,20 +80,100 @@ subroutine set_scalar_ic_int(s, coef, gs, type, params) ! Variables for retrieving JSON parameters real(kind=rp) :: ic_value - character(len=:), allocatable :: zone_name - real(kind=rp) :: zone_value + character(len=:), allocatable :: read_str, prev_mesh + character(len=80) :: suffix + real(kind=rp) :: zone_value, tol + logical :: found + integer :: sample_idx, fpos + character(len=LOG_SIZE) :: log_buf if (trim(type) .eq. 'uniform') then + call json_get(params, 'case.scalar.initial_condition.value', ic_value) + write (log_buf, '(A,F10.6)') "Value: ", ic_value + call neko_log%message(log_buf) + call set_scalar_ic_uniform(s, ic_value) + else if (trim(type) .eq. 'point_zone') then + call json_get(params, 'case.scalar.initial_condition.base_value', & - ic_value) + ic_value) call json_get(params, 'case.scalar.initial_condition.zone_name', & - zone_name) + read_str) call json_get(params, 'case.scalar.initial_condition.zone_value', & - zone_value) - call set_scalar_ic_point_zone(s, ic_value, zone_name, zone_value) + zone_value) + + write (log_buf, '(A,F10.6)') "Base value: ", ic_value + call neko_log%message(log_buf) + call neko_log%message( "Zone name : " // trim(read_str)) + write (log_buf, '(A,F10.6)') "Zone value: ", zone_value + call neko_log%message(log_buf) + + call set_scalar_ic_point_zone(s, ic_value, read_str, zone_value) + + else if (trim(type) .eq. 'field') then + + call json_get(params, 'case.scalar.initial_condition.file_name', & + read_str) + call filename_suffix(read_str, suffix) + call neko_log%message("File name: " // trim(read_str)) + + if (trim(suffix) .eq. "chkp") then + + call params%get("case.scalar.initial_condition.previous_mesh", & + prev_mesh, found) + + if (found) then + + call neko_log%message("Previous mesh: " // trim(prev_mesh)) + call params%get('case.scalar.initial_condition.tolerance', tol, & + found) + + if (found) then + write (log_buf, '(A,F10.6)') "Tolerance : ", tol + call neko_log%message(log_buf) + call set_scalar_ic_chkp(s, read_str, prev_mesh, tol) + else + call set_scalar_ic_chkp(s, read_str, prev_mesh) + end if + + ! In this case no mesh interpolation but potential for + ! interpolation between different polynomial orders + else + call set_scalar_ic_chkp(s, read_str) + end if + + else !if it's not a chkp we assume it's a fld file + + ! Get the index of the file to sample + call json_get_or_default(params, & + 'case.scalar.initial_condition.sample_index', sample_idx, -1) + + if (sample_idx .ne. -1) then + write (log_buf, '(A,I5.5)') "Sample index: ", sample_idx + call neko_log%message(log_buf) + end if + + ! If it's not chkp or fld assume it's either .nek5000 or .f00* + if (trim(suffix) .ne. "fld") then + + ! Check if the suffix is of type "f000*", and if so extract + ! the index e.g. "f00035" --> 35 + ! NOTE: overwrites whatever is in sampled_index + fpos = scan(suffix, 'f') + if (fpos .eq. 1) then + if (sample_idx .ne. -1) & + call neko_warning("Overwriting sample index!") + read (suffix(2:), "(I5.5)") sample_idx + end if + + call filename_chsuffix(read_str, read_str, 'fld') + + end if + + call set_scalar_ic_fld(s, read_str, sample_idx) + end if else call neko_error('Invalid initial condition') end if @@ -187,4 +272,105 @@ subroutine set_scalar_ic_point_zone(s, base_value, zone_name, zone_value) end subroutine set_scalar_ic_point_zone + !> Set the initial condition of the flow based on a point zone. + !! @details The initial condition is set to the base value and then the + !! zone is filled with the zone value. + !! @param s The scalar field. + !! @param file_name The name of the "fld" file series. + !! @param sample_idx index of the field file .f000* to read, default is + !! -1.. + subroutine set_scalar_ic_fld(s, file_name, sample_idx) + type(field_t), intent(inout) :: s + character(len=*), intent(in) :: file_name + integer, intent(in) :: sample_idx + + type(fld_file_data_t) :: fld_data + type(file_t) :: f + + ! Should this init be init(u%msh%nelv, u%msh%offset_el)? + call fld_data%init + + f = file_t(trim(file_name)) + + ! Set the counter if not the default value + if (sample_idx .ne. -1) then + call f%set_counter(sample_idx) + call f%read(fld_data) + else + ! If we default to the last file of the series we need to call + ! read once to get the # of samples etc + call f%read(fld_data) + + if (fld_data%meta_nsamples .gt. 0) then + call f%set_counter(fld_data%meta_nsamples + & + fld_data%meta_start_counter - 1) + call f%read(fld_data) + end if + end if + + ! + ! Check if the data in the fld file matches the current case. + ! Note that this is a safeguard and there are corner cases where + ! two different meshes have the same dimension, same # of elements + ! and same polynomial orders but this should be enough to cover most cases. + ! + if ( (fld_data%gdim .ne. s%msh%gdim) .or. & + (fld_data%glb_nelv .ne. s%msh%glb_nelv) .or. & + (fld_data%lx .ne. s%dof%Xh%lx) .or. & + (fld_data%ly .ne. s%dof%Xh%ly) .or. & + (fld_data%lz .ne. s%dof%Xh%lz)) then + call neko_error("The fld file must match the current mesh") + end if + + ! Note: we do not copy on the GPU since `set_flow_ic_common` does the copy for us + call copy(s%x, fld_data%t%x, s%dof%size()) + + call fld_data%free + + end subroutine set_scalar_ic_fld + + !> Set the initial condition of the flow based on a point zone. + !! @details The initial condition is set to the base value and then the + !! zone is filled with the zone value. + !! @param s The scalar field. + !! @param file_name The name of the checkpoint file. + !! @param previous_mesh If specified, the name of the previouos mesh from + !! which to interpolate. + !! @param tol If specified, tolerance to use for the mesh interpolation. + subroutine set_scalar_ic_chkp(s, file_name, previous_mesh, tol) + type(field_t), intent(inout) :: s + character(len=*), intent(in) :: file_name + character(len=*), intent(in), optional :: previous_mesh + real(kind=rp), intent(in), optional :: tol + + type(field_t), pointer :: u,v,w,p + type(chkp_t) :: chkp_data + type(file_t) :: f, meshf + + u => neko_field_registry%get_field("u") + v => neko_field_registry%get_field("v") + w => neko_field_registry%get_field("w") + p => neko_field_registry%get_field("p") + + ! Could we also init with chkp_data%init(s,s,s,s) for simplicity? + call chkp_data%init(u,v,w,p) + call chkp_data%add_scalar(s) + + ! Mesh interpolation if specified + if (present(previous_mesh)) then + meshf = file_t(trim(previous_mesh)) + call meshf%read(chkp_data%previous_mesh) + end if + + ! Tolerance is by default 1d-6 + if (present(tol)) chkp_data%mesh2mesh_tol = tol + + ! Read the chkp and perform interpolation + f = file_t(trim(file_name)) + call f%read(chkp_data) + + call copy(s%x, chkp_data%s%x, s%dof%size()) + + end subroutine set_scalar_ic_chkp + end module scalar_ic From 43b8a41a30afcef760665c0ed42c9c4b0fe12a71 Mon Sep 17 00:00:00 2001 From: Victor Baconnet Date: Tue, 16 Jul 2024 12:06:03 +0200 Subject: [PATCH 04/67] fix imports and bug that removed file path when reading meta file --- src/io/fld_file.f90 | 68 ++++++++++++++++++++++++++++++++------------- 1 file changed, 48 insertions(+), 20 deletions(-) diff --git a/src/io/fld_file.f90 b/src/io/fld_file.f90 index 75147c74671..7d886b65cc1 100644 --- a/src/io/fld_file.f90 +++ b/src/io/fld_file.f90 @@ -33,24 +33,29 @@ !> NEKTON fld file format !! @details this module defines interface to write NEKTON's fld fields module fld_file - use generic_file - use field - use field_list - use dofmap - use space + use num_types, only: dp, sp, rp, i8 + use generic_file, only: generic_file_t + use field, only: field_t + use field_list, only: field_list_t + use dofmap, only: dofmap_t + use space, only: space_t use structs, only: array_ptr_t - use vector - use fld_file_data - use mean_flow - use mean_sqr_flow + use vector, only: vector_t + use fld_file_data, only: fld_file_data_t + use mean_flow, only: mean_flow_t + use mean_sqr_flow, only: mean_sqr_flow_t use vector, only : vector_t use space, only : space_t use mesh, only : mesh_t - use utils - use comm - use datadist + use utils, only: neko_error, filename_chsuffix, filename_suffix_pos, & + filename_tslash_pos + use comm, only: NEKO_COMM, MPI_REAL_PRECISION, pe_rank, pe_size + use mpi_f08 + use datadist, only: linear_dist_t + use logger, only: neko_log, LOG_SIZE use math, only : vlmin, vlmax - use neko_mpi_types + use neko_mpi_types, only: MPI_DOUBLE_PRECISION_SIZE, MPI_REAL_SIZE, & + MPI_CHARACTER_SIZE, MPI_INTEGER_SIZE implicit none private @@ -626,10 +631,11 @@ subroutine fld_file_read(this, data) class(fld_file_t) :: this class(*), target, intent(inout) :: data character(len=132) :: hdr - integer :: ierr, suffix_pos, i, j + integer :: ierr, suffix_pos, slsh_pos, i, j, leading_space_pos type(MPI_File) :: fh type(MPI_Status) :: status - character(len=1024) :: fname, meta_fname, string + character(len=1024) :: fname, meta_fname, string, path + character(len=LOG_SIZE) :: log_buf logical :: meta_file, read_mesh, read_velocity, read_pressure logical :: read_temp character(len=6) :: id_str @@ -646,13 +652,24 @@ subroutine fld_file_read(this, data) type is (fld_file_data_t) call filename_chsuffix(this%fname, meta_fname,'nek5000') + ! Extract file path + slsh_pos = filename_tslash_pos(this%fname) + path = "none" + if (slsh_pos .ne. 0) path = this%fname(1:slsh_pos) + inquire(file=trim(meta_fname), exist=meta_file) if (meta_file .and. data%meta_nsamples .eq. 0) then if (pe_rank .eq. 0) then open(unit=9, file=trim(meta_fname)) read(9, fmt='(A)') string read(string(14:),fmt='(A)') string - string = trim(string) + + ! Remove leading whitespaces + ! from something like " field%01d.f%05d" to + ! "field%01d.f%05d" + leading_space_pos = scan(trim(string), " ", back = .true.) + string = trim(string(leading_space_pos + 1:)) + data%fld_series_fname = string(:scan(trim(string), '%')-1) data%fld_series_fname = trim(data%fld_series_fname)//'0' read(9, fmt='(A)') string @@ -661,14 +678,18 @@ subroutine fld_file_read(this, data) read(string(scan(string,':')+1:),*) data%meta_nsamples close(9) - write(*,*) 'Reading meta file for fld series' - write(*,*) 'Name: ', trim(data%fld_series_fname) - write(*,*) 'Start counter: ', data%meta_start_counter, 'Nsamples: ', data%meta_nsamples + call neko_log%message('Reading meta file for fld series') + call neko_log%message('Name: ' // trim(data%fld_series_fname)) + write (log_buf,'(A,I7)') 'Start counter : ', data%meta_start_counter + call neko_log%message(log_buf) + write (log_buf,'(A,I7)') 'Number of samples: ', data%meta_nsamples + call neko_log%message(log_buf) + end if call MPI_Bcast(data%fld_series_fname, 1024, MPI_CHARACTER, 0, NEKO_COMM, ierr) call MPI_Bcast(data%meta_start_counter, 1, MPI_INTEGER, 0, NEKO_COMM, ierr) call MPI_Bcast(data%meta_nsamples, 1, MPI_INTEGER, 0, NEKO_COMM, ierr) - if(this%counter .eq. 0) this%counter = data%meta_start_counter + if (this%counter .eq. 0) this%counter = data%meta_start_counter end if if (meta_file) then @@ -677,16 +698,23 @@ subroutine fld_file_read(this, data) if (this%counter .ge. data%meta_nsamples+data%meta_start_counter) then call neko_error('Trying to read more fld files than exist') end if + + ! Reappend path to the file series name since we lose it during the meta + ! file reading + if (trim(path) .ne. "none") fname = trim(path) // trim(fname) else suffix_pos = filename_suffix_pos(this%fname) write(id_str, '(a,i5.5)') 'f', this%counter fname = trim(this%fname(1:suffix_pos-1))//'.'//id_str end if + call MPI_File_open(NEKO_COMM, trim(fname), & MPI_MODE_RDONLY, MPI_INFO_NULL, fh, ierr) if (ierr .ne. 0) call neko_error("Could not read "//trim(fname)) + call neko_log%message("Reading fld file " // trim(fname)) + call MPI_File_read_all(fh, hdr, 132, MPI_CHARACTER, status, ierr) !This read can prorbably be done wihtout the temp variables, temp_str, i, j From 5038cd92b8e3623c4bf8b8ba2613be372e57ccdc Mon Sep 17 00:00:00 2001 From: Victor Baconnet Date: Tue, 16 Jul 2024 12:06:22 +0200 Subject: [PATCH 05/67] fix imports --- src/io/fld_file_data.f90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/io/fld_file_data.f90 b/src/io/fld_file_data.f90 index 638402a31d4..ae999bc2c7b 100644 --- a/src/io/fld_file_data.f90 +++ b/src/io/fld_file_data.f90 @@ -6,7 +6,7 @@ !! Martin Karp 1/2-2023 module fld_file_data use num_types, only : rp - use math + use math, only: cmult, add2 use vector, only : vector_t, vector_ptr_t implicit none private From 6819f2a8143cd1c8221ed22242798242bf6a41a3 Mon Sep 17 00:00:00 2001 From: Victor Baconnet Date: Tue, 16 Jul 2024 12:06:31 +0200 Subject: [PATCH 06/67] Add initial condition log --- src/case.f90 | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/case.f90 b/src/case.f90 index 2ad77dd71da..f3de8af286e 100644 --- a/src/case.f90 +++ b/src/case.f90 @@ -274,6 +274,10 @@ subroutine case_init_common(C) ! call json_get(C%params, 'case.fluid.initial_condition.type',& string_val) + + call neko_log%section("Fluid initial condition ") + call neko_log%message("Type: " // trim(string_val)) + if (trim(string_val) .ne. 'user') then call set_flow_ic(C%fluid%u, C%fluid%v, C%fluid%w, C%fluid%p, & C%fluid%c_Xh, C%fluid%gs_Xh, string_val, C%params) @@ -282,7 +286,13 @@ subroutine case_init_common(C) C%fluid%c_Xh, C%fluid%gs_Xh, C%usr%fluid_user_ic, C%params) end if + call neko_log%end_section() + if (scalar) then + + call neko_log%section("Scalar initial condition ") + call neko_log%message("Type: " // trim(string_val)) + call json_get(C%params, 'case.scalar.initial_condition.type', string_val) if (trim(string_val) .ne. 'user') then call set_scalar_ic(C%scalar%s, & @@ -291,6 +301,9 @@ subroutine case_init_common(C) call set_scalar_ic(C%scalar%s, & C%scalar%c_Xh, C%scalar%gs_Xh, C%usr%scalar_user_ic, C%params) end if + + call neko_log%end_section() + end if ! Add initial conditions to BDF scheme (if present) From eb7df4f23e4812f7b87b6f041fcf62dd4885ae11 Mon Sep 17 00:00:00 2001 From: Victor Baconnet Date: Tue, 16 Jul 2024 12:06:42 +0200 Subject: [PATCH 07/67] Add doc --- doc/pages/user-guide/case-file.md | 53 +++++++++++++++++++++++-------- 1 file changed, 40 insertions(+), 13 deletions(-) diff --git a/doc/pages/user-guide/case-file.md b/doc/pages/user-guide/case-file.md index d7de2049aa5..c692d0b8982 100644 --- a/doc/pages/user-guide/case-file.md +++ b/doc/pages/user-guide/case-file.md @@ -214,6 +214,25 @@ The means of prescribing the values are controlled via the `type` keyword: `base_value` keyword, and then assigned a zone value inside a point zone. The point zone is specified by the `name` keyword, and should be defined in the `case.point_zones` object. See more about point zones @ref point-zones.md. +5. `field`, where the initial condition is retrieved from an output field file + provided by the `file_name` keyword. Supported + file types are: + - `.chkp`, with mesh to mesh interpolation where the mesh from which to + interpolate is given by the `previous_mesh` keyword (and tolerance for + interpolation by the keyword `tolerance`). + - `.fld`, `.nek5000` that refer to a series of `.f*****` files, where the + index of the file to use is provided by the `sample_index` keyword. For + example, in a series of 3 files `field0.f00000, field0.f00001, + field0.f00002`, `sample_index` can take values `0`,`1` or `2`. In this + case we would set `"file_name" = "field0.fld"`. If no `sample_index` is + provided, and a `field0.nek5000` file exists, the last field file in the + series will be used by default. + - `.f*****` which refers to a single `field0.f*****` file. In this case + the sample index will be extracted from the file extension, e.g. `f00012` + means a sample index of `12`. + +@note Currently interpolation is only supported with `chkp` files. `fld` files +that are loaded must match with the mesh that you are using. ### Blasius profile The `blasius` object is used to specify the Blasius profile that can be used for the @@ -423,8 +442,12 @@ that can be described concisely directly in the table. | `output_value` | The frequency of sampling in terms of `output_control`. | Positive real or integer | - | | `inflow_condition.type` | Velocity inflow condition type. | `user`, `uniform`, `blasius` | - | | `inflow_condition.value` | Value of the inflow velocity. | Vector of 3 reals | - | -| `initial_condition.type` | Initial condition type. | `user`, `uniform`, `blasius` | - | +| `initial_condition.type` | Initial condition type. | `user`, `uniform`, `blasius`, `field` | - | | `initial_condition.value` | Value of the velocity initial condition. | Vector of 3 reals | - | +| `initial_condition.file_name` | If `"type" = "field"`, the path to the field file to read from. | String ending with `.fld`, `.chkp`, `.nek5000` or `f*****`. | - | +| `initial_condition.sample_index` | If `"type" = "field"`, and file type is `fld` or `nek5000`, the index of the file to sampled. | Positive integer. | -1 | +| `initial_condition.previous_mesh` | If `"type" = "field"`, and file type is `chkp`, the previous mesh from which to interpolate. | String ending with `.nmsh`. | - | +| `initial_condition.tolerance` | If `"type" = "field"`, and file type is `chkp`, tolerance to use for mesh interpolation. | Positive real. | 1e-6 | | `blasius.delta` | Boundary layer thickness in the Blasius profile. | Positive real | - | | `blasius.freestream_velocity` | Free-stream velocity in the Blasius profile. | Vector of 3 reals | - | | `blasius.approximation` | Numerical approximation of the Blasius profile. | `linear`, `quadratic`, `cubic`, `quartic`, `sin` | - | @@ -474,18 +497,22 @@ example case. The configuration of source terms is the same as for the fluid. A demonstration of using source terms for the scalar can be found in the `scalar_mms` example. -| Name | Description | Admissible values | Default value | -| ------------------------- | -------------------------------------------------------- | ------------------------------- | ------------- | -| `enabled` | Whether to enable the scalar computation. | `true` or `false` | `true` | -| `Pe` | The Peclet number. | Positive real | - | -| `cp` | Specific heat cpacity. | Positive real | - | -| `lambda` | Thermal conductivity. | Positive real | - | -| `nut_field` | Name of the turbulent kinematic viscosity field. | String | Empty string | -| `Pr_t` | Turbulent Prandtl number | Positive real | - | -| `boundary_types` | Boundary types/conditions labels. | Array of strings | - | -| `initial_condition.type` | Initial condition type. | `user`, `uniform`, `point_zone` | - | -| `initial_condition.value` | Value of the velocity initial condition. | Real | - | -| `source_terms` | Array of JSON objects, defining additional source terms. | See list of source terms above | - | +| Name | Description | Admissible values | Default value | +| --------------------------------- | --------------------------------------------------------------------------------------------- | ---------------------------------------- | ------------- | +| `enabled` | Whether to enable the scalar computation. | `true` or `false` | `true` | +| `Pe` | The Peclet number. | Positive real | - | +| `cp` | Specific heat cpacity. | Positive real | - | +| `lambda` | Thermal conductivity. | Positive real | - | +| `nut_field` | Name of the turbulent kinematic viscosity field. | String | Empty string | +| `Pr_t` | Turbulent Prandtl number | Positive real | - | +| `boundary_types` | Boundary types/conditions labels. | Array of strings | - | +| `initial_condition.type` | Initial condition type. | `user`, `uniform`, `point_zone`, `field` | - | +| `initial_condition.value` | Value of the velocity initial condition. | Real | - | +| `initial_condition.file_name` | If `"type" = "field"`, the path to the field file to read from. | String ending with `.fld`, `.chkp`, `.nek5000` or `f*****`. | - | +| `initial_condition.sample_index` | If `"type" = "field"`, and file type is `fld` or `nek5000`, the index of the file to sampled. | Positive integer. | -1 | +| `initial_condition.previous_mesh` | If `"type" = "field"`, and file type is `chkp`, the previous mesh from which to interpolate. | String ending with `.nmsh`. | - | +| `initial_condition.tolerance` | If `"type" = "field"`, and file type is `chkp`, tolerance to use for mesh interpolation. | Positive real. | 1e-6 | +| `source_terms` | Array of JSON objects, defining additional source terms. | See list of source terms above | - | ## Statistics From 8c9971e15647a59f74e451c2f7925da1e7b405fa Mon Sep 17 00:00:00 2001 From: Victor Baconnet Date: Tue, 16 Jul 2024 12:06:51 +0200 Subject: [PATCH 08/67] update depedns --- src/.depends | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/.depends b/src/.depends index 15f0a14559a..0adc9aff65e 100644 --- a/src/.depends +++ b/src/.depends @@ -105,7 +105,7 @@ io/generic_file.o : io/generic_file.f90 comm/comm.o common/utils.o config/num_ty io/map_file.o : io/map_file.f90 io/format/map.o comm/comm.o common/utils.o io/generic_file.o io/re2_file.o : io/re2_file.f90 common/log.o adt/htable.o io/map_file.o io/format/map.o io/format/re2.o common/datadist.o comm/mpi_types.o comm/comm.o mesh/point.o mesh/mesh.o common/utils.o config/num_types.o io/generic_file.o io/rea_file.o : io/rea_file.f90 common/log.o adt/htable.o common/datadist.o comm/comm.o io/map_file.o io/re2_file.o io/format/rea.o io/format/map.o mesh/point.o mesh/mesh.o common/utils.o config/num_types.o io/generic_file.o -io/fld_file.o : io/fld_file.f90 comm/mpi_types.o math/math.o common/datadist.o comm/comm.o common/utils.o mesh/mesh.o fluid/mean_sqr_flow.o fluid/mean_flow.o io/fld_file_data.o math/vector.o common/structs.o sem/space.o sem/dofmap.o field/field_list.o field/field.o io/generic_file.o +io/fld_file.o : io/fld_file.f90 comm/mpi_types.o math/math.o common/log.o common/datadist.o comm/comm.o common/utils.o mesh/mesh.o fluid/mean_sqr_flow.o fluid/mean_flow.o io/fld_file_data.o math/vector.o common/structs.o sem/space.o sem/dofmap.o field/field_list.o field/field.o io/generic_file.o config/num_types.o io/fld_file_data.o : io/fld_file_data.f90 math/vector.o math/math.o config/num_types.o io/vtk_file.o : io/vtk_file.f90 comm/comm.o common/log.o mesh/tri_mesh.o mesh/tet_mesh.o field/mesh_field.o sem/dofmap.o field/field.o mesh/mesh.o common/utils.o io/generic_file.o config/num_types.o io/stl_file.o : io/stl_file.f90 io/format/stl.o comm/comm.o common/utils.o comm/mpi_types.o mesh/point.o common/log.o mesh/tri_mesh.o io/generic_file.o config/num_types.o @@ -194,7 +194,7 @@ fluid/mean_flow.o : fluid/mean_flow.f90 field/field.o field/mean_field.o fluid/fluid_stats.o : fluid/fluid_stats.f90 common/utils.o config/neko_config.o device/device.o common/stats_quant.o gs/gather_scatter.o field/field_list.o field/field_registry.o field/field.o sem/coef.o math/operators.o math/math.o math/mathops.o math/bcknd/device/device_mathops.o math/bcknd/device/device_math.o field/mean_field.o fluid/mean_sqr_flow.o : fluid/mean_sqr_flow.f90 field/field.o field/mean_sqr_field.o fluid/flow_profile.o : fluid/flow_profile.f90 config/num_types.o -fluid/flow_ic.o : fluid/flow_ic.f90 mesh/point_zone_registry.o mesh/point_zone.o common/json_utils.o common/user_intf.o math/bcknd/device/device_math.o math/math.o sem/coef.o common/utils.o field/field.o device/device.o fluid/flow_profile.o config/neko_config.o gs/gather_scatter.o config/num_types.o +fluid/flow_ic.o : fluid/flow_ic.f90 io/file.o common/checkpoint.o io/fld_file_data.o mesh/point_zone_registry.o mesh/point_zone.o common/json_utils.o common/user_intf.o math/bcknd/device/device_math.o math/math.o sem/coef.o common/utils.o field/field.o device/device.o fluid/flow_profile.o config/neko_config.o gs/gather_scatter.o common/log.o config/num_types.o fluid/advection.o : fluid/advection.f90 sem/coef.o field/field.o sem/space.o config/num_types.o fluid/advection_fctry.o : fluid/advection_fctry.f90 fluid/bcknd/advection/adv_no_dealias.o fluid/bcknd/advection/adv_dealias.o fluid/advection.o common/json_utils.o sem/coef.o fluid/bcknd/advection/adv_dealias.o : fluid/bcknd/advection/adv_dealias.f90 device/device.o sem/interpolation.o math/operators.o config/neko_config.o math/bcknd/device/device_math.o sem/coef.o field/field.o sem/space.o math/math.o config/num_types.o fluid/advection.o @@ -252,7 +252,7 @@ scalar/scalar_pnpn.o : scalar/scalar_pnpn.f90 field/scratch_registry.o common/ti scalar/scalar_aux.o : scalar/scalar_aux.f90 krylov/krylov.o config/num_types.o common/log.o scalar/scalar_residual.o : scalar/scalar_residual.f90 config/num_types.o mesh/mesh.o sem/space.o bc/facet_normal.o scalar/source_scalar.o sem/coef.o field/field.o math/ax.o gs/gather_scatter.o scalar/scalar_residual_fctry.o : scalar/scalar_residual_fctry.f90 scalar/bcknd/sx/scalar_residual_sx.o scalar/bcknd/cpu/scalar_residual_cpu.o scalar/bcknd/device/scalar_residual_device.o scalar/scalar_residual.o config/neko_config.o -scalar/scalar_ic.o : scalar/scalar_ic.f90 mesh/point_zone_registry.o mesh/point_zone.o common/json_utils.o common/user_intf.o math/math.o sem/coef.o common/utils.o field/field.o device/device.o math/bcknd/device/device_math.o config/num_types.o config/neko_config.o gs/gather_scatter.o +scalar/scalar_ic.o : scalar/scalar_ic.f90 io/file.o common/checkpoint.o io/fld_file_data.o common/log.o field/field_registry.o mesh/point_zone_registry.o mesh/point_zone.o common/json_utils.o common/user_intf.o math/math.o sem/coef.o common/utils.o field/field.o device/device.o math/bcknd/device/device_math.o config/num_types.o config/neko_config.o gs/gather_scatter.o scalar/scalar_source_term.o : scalar/scalar_source_term.f90 common/utils.o common/user_intf.o sem/coef.o common/json_utils.o field/field_list.o field/field.o source_terms/source_term_fctry.o source_terms/source_term.o scalar/scalar_user_source_term.o config/num_types.o config/neko_config.o scalar/scalar_user_source_term.o : scalar/scalar_user_source_term.f90 sem/dofmap.o math/math.o math/bcknd/device/device_math.o device/device.o sem/coef.o field/field_list.o source_terms/source_term.o common/utils.o config/num_types.o config/neko_config.o scalar/bcknd/cpu/scalar_residual_cpu.o : scalar/bcknd/cpu/scalar_residual_cpu.f90 math/math.o math/operators.o scalar/scalar_residual.o gs/gather_scatter.o From 81b951d3a4d543ba9ea6174fd9fc73b9c1936a5d Mon Sep 17 00:00:00 2001 From: Victor Baconnet Date: Tue, 16 Jul 2024 12:50:54 +0200 Subject: [PATCH 09/67] Fix printing --- src/fluid/flow_ic.f90 | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/fluid/flow_ic.f90 b/src/fluid/flow_ic.f90 index 6491f08f898..e13f68296d1 100644 --- a/src/fluid/flow_ic.f90 +++ b/src/fluid/flow_ic.f90 @@ -97,10 +97,10 @@ subroutine set_flow_ic_int(u, v, w, p, coef, gs, type, params) read_str) call json_get(params, 'case.fluid.blasius.freestream_velocity', uinf) - write (log_buf, '(A,F10.6)') "delta : ", delta + write (log_buf, '(A,F10.6)') "delta : ", delta call neko_log%message(log_buf) - call neko_log%message( "Approximation : " // trim(read_str)) - write (log_buf, '(A,F10.6)') "Free-stream velocity: ", uinf + call neko_log%message( "Approximation: " // trim(read_str)) + write (log_buf, '(A,"[",2(F10.6,","),F10.6,"]")') "Value: ", uinf(1), uinf(2), uinf(3) call neko_log%message(log_buf) call set_flow_ic_blasius(u, v, w, delta, uinf, read_str) @@ -116,7 +116,8 @@ subroutine set_flow_ic_int(u, v, w, p, coef, gs, type, params) write (log_buf, '(A,F10.6)') "Base value: ", uinf call neko_log%message(log_buf) call neko_log%message( "Zone name : " // trim(read_str)) - write (log_buf, '(A,F10.6)') "Zone value: ", zone_value + write (log_buf, '(A,"[",2(F10.6,","),F10.6,"]")') "Value: ", & + zone_value(1), zone_value(2), zone_value(3) call neko_log%message(log_buf) call set_flow_ic_point_zone(u, v, w, uinf, read_str, zone_value) From a81271831fe9042c6ef61aaa676939387eeac26c Mon Sep 17 00:00:00 2001 From: Victor Baconnet Date: Tue, 16 Jul 2024 13:13:32 +0200 Subject: [PATCH 10/67] Add memcpy for pressure --- src/fluid/flow_ic.f90 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/fluid/flow_ic.f90 b/src/fluid/flow_ic.f90 index e13f68296d1..75b6a166de2 100644 --- a/src/fluid/flow_ic.f90 +++ b/src/fluid/flow_ic.f90 @@ -406,12 +406,16 @@ subroutine set_flow_ic_fld(u, v, w, p, file_name, sample_idx) call neko_error("The fld file must match the current mesh") end if - ! Note: we do not copy on the GPU since `set_flow_ic_common` does the copy for us + ! Note: we do not copy on the GPU since `set_flow_ic_common` does the + ! copy for us, except for the pressure call copy(u%x, fld_data%u%x, u%dof%size()) call copy(v%x, fld_data%v%x, v%dof%size()) call copy(w%x, fld_data%w%x, w%dof%size()) call copy(p%x, fld_data%p%x, p%dof%size()) + if (NEKO_BCKND_DEVICE .eq. 1) call device_memcpy(p%x, p%x_d, p%dof%size(), & + HOST_TO_DEVICE, sync = .false.) + call fld_data%free end subroutine set_flow_ic_fld From 876626bafc68829a3c65a021c89ca03db81bb215 Mon Sep 17 00:00:00 2001 From: Victor Baconnet Date: Tue, 16 Jul 2024 13:14:48 +0200 Subject: [PATCH 11/67] Add memcpy in chkp too --- src/fluid/flow_ic.f90 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/fluid/flow_ic.f90 b/src/fluid/flow_ic.f90 index 75b6a166de2..68d29e64654 100644 --- a/src/fluid/flow_ic.f90 +++ b/src/fluid/flow_ic.f90 @@ -463,6 +463,9 @@ subroutine set_flow_ic_chkp(u, v, w, p, file_name, previous_mesh, tol) call copy(w%x, chkp_data%w%x, w%dof%size()) call copy(p%x, chkp_data%p%x, p%dof%size()) + if (NEKO_BCKND_DEVICE .eq. 1) call device_memcpy(p%x, p%x_d, p%dof%size(), & + HOST_TO_DEVICE, sync = .false.) + end subroutine set_flow_ic_chkp end module flow_ic From cc7e4fccea6d9725b715c117a8e712548cd29506 Mon Sep 17 00:00:00 2001 From: Victor Baconnet Date: Wed, 17 Jul 2024 14:45:42 +0200 Subject: [PATCH 12/67] Preliminary interpolation, UNTESTED --- src/fluid/flow_ic.f90 | 189 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 155 insertions(+), 34 deletions(-) diff --git a/src/fluid/flow_ic.f90 b/src/fluid/flow_ic.f90 index 68d29e64654..cedde1973a7 100644 --- a/src/fluid/flow_ic.f90 +++ b/src/fluid/flow_ic.f90 @@ -52,6 +52,10 @@ module flow_ic use fld_file_data, only: fld_file_data_t use checkpoint, only: chkp_t use file, only: file_t + use mesh, only: mesh_t + use dofmap, only: dofmap_t + use global_interpolation, only: global_interpolation_t + use interpolation, only: interpolator_t implicit none private @@ -80,9 +84,12 @@ subroutine set_flow_ic_int(u, v, w, p, coef, gs, type, params) character(len=80) :: suffix character(len=1024) :: new_fname integer :: sample_idx, fpos - logical :: found + logical :: found_tol, found_previous_mesh, interpolate character(len=LOG_SIZE) :: log_buf + ! + ! Uniform (Uinf, Vinf, Winf) + ! if (trim(type) .eq. 'uniform') then call json_get(params, 'case.fluid.initial_condition.value', uinf) @@ -90,6 +97,9 @@ subroutine set_flow_ic_int(u, v, w, p, coef, gs, type, params) write (log_buf, '(A,"[",2(F10.6,","),F10.6,"]")') "Value: ", uinf(1), uinf(2), uinf(3) call neko_log%message(log_buf) + ! + ! Blasius boundary layer + ! else if (trim(type) .eq. 'blasius') then call json_get(params, 'case.fluid.blasius.delta', delta) @@ -105,6 +115,9 @@ subroutine set_flow_ic_int(u, v, w, p, coef, gs, type, params) call set_flow_ic_blasius(u, v, w, delta, uinf, read_str) + ! + ! Point zone initial condition + ! else if (trim(type) .eq. 'point_zone') then call json_get(params, 'case.fluid.initial_condition.base_value', uinf) @@ -122,6 +135,9 @@ subroutine set_flow_ic_int(u, v, w, p, coef, gs, type, params) call set_flow_ic_point_zone(u, v, w, uinf, read_str, zone_value) + ! + ! Field initial condition (from chkp or fld file) + ! else if (trim(type) .eq. 'field') then call json_get(params, 'case.fluid.initial_condition.file_name', & @@ -129,28 +145,35 @@ subroutine set_flow_ic_int(u, v, w, p, coef, gs, type, params) call filename_suffix(read_str, suffix) call neko_log%message("File name: " // trim(read_str)) - if (trim(suffix) .eq. "chkp") then + ! Look for parameters for interpolation + call params%get("case.fluid.initial_condition.previous_mesh", & + prev_mesh, found_previous_mesh) - call params%get("case.fluid.initial_condition.previous_mesh", & - prev_mesh, found) - - if (found) then + if (found_previous_mesh) then + call neko_log%message("Previous mesh: " // trim(prev_mesh)) + interpolate = .true. + else + call json_get_or_default(params, & + "case.fluid.initial_condition.interpolate", interpolate, .false.) + end if - call neko_log%message("Previous mesh: " // trim(prev_mesh)) - call params%get('case.fluid.initial_condition.tolerance', tol, & - found) + if (interpolate) then + call neko_log%message("Interpolation: yes") + call json_get_or_default(params, & + 'case.fluid.initial_condition.tolerance', tol, 1d-6) + write (log_buf, '(A,F10.6)') "Tolerance : ", tol + call neko_log%message(log_buf) + else + call neko_log%message("Interpolation: no") + end if - if (found) then - write (log_buf, '(A,F10.6)') "Tolerance : ", tol - call neko_log%message(log_buf) - call set_flow_ic_chkp(u, v, w, p, read_str, prev_mesh, tol) - else - call set_flow_ic_chkp(u, v, w, p, read_str, prev_mesh) - end if + if (trim(suffix) .eq. "chkp") then - ! In this case no mesh interpolation but potential for interpolation - ! between different polynomial orders + if (found_previous_mesh) then + call set_flow_ic_chkp(u, v, w, p, read_str, prev_mesh, tol) else + ! In this case no mesh interpolation but potential for interpolation + ! between different polynomial orders call set_flow_ic_chkp(u, v, w, p, read_str) end if @@ -182,7 +205,17 @@ subroutine set_flow_ic_int(u, v, w, p, coef, gs, type, params) end if - call set_flow_ic_fld(u, v, w, p, read_str, sample_idx) + if (interpolate) then + + if (found_previous_mesh) then + call set_flow_ic_fld(u, v, w, p, read_str, sample_idx, & + prev_mesh, tol) + else + ! In this case no mesh interpolation but potential for interpolation + ! between different polynomial orders + call set_flow_ic_fld(u, v, w, p, read_str, sample_idx) + end if + end if end if else @@ -360,16 +393,35 @@ end subroutine set_flow_ic_point_zone !! @param file_name The name of the "fld" file series. !! @param sample_idx index of the field file .f000* to read, default is !! -1.. - subroutine set_flow_ic_fld(u, v, w, p, file_name, sample_idx) + subroutine set_flow_ic_fld(u, v, w, p, file_name, sample_idx, & + interpolate, previous_mesh_fname, tolerance) type(field_t), intent(inout) :: u type(field_t), intent(inout) :: v type(field_t), intent(inout) :: w type(field_t), intent(inout) :: p character(len=*), intent(in) :: file_name integer, intent(in) :: sample_idx + logical, intent(in) :: interpolate + character(len=*), intent(in), optional :: previous_mesh_fname + real(kind=rp), intent(in), optional :: tolerance type(fld_file_data_t) :: fld_data - type(file_t) :: f + type(mesh_t) :: prev_mesh + type(file_t) :: f, meshf + type(dofmap_t) :: dof + real(kind=rp) :: tol + + ! ---- For the mesh to mesh interpolation + integer :: e, i + real(kind=rp) :: center_x, center_y, center_z + real(kind=rp), allocatable :: x_coords(:,:,:,:), y_coords(:,:,:,:), & + z_coords(:,:,:,:) + type(global_interpolation_t) :: global_interp + ! ----- + + ! ---- For space to space interpolation + type(interpolator_t) :: space_interp + ! ---- ! Should this init be init(u%msh%nelv, u%msh%offset_el)? call fld_data%init @@ -402,16 +454,85 @@ subroutine set_flow_ic_fld(u, v, w, p, file_name, sample_idx) (fld_data%glb_nelv .ne. u%msh%glb_nelv) .or. & (fld_data%lx .ne. u%dof%Xh%lx) .or. & (fld_data%ly .ne. u%dof%Xh%ly) .or. & - (fld_data%lz .ne. u%dof%Xh%lz)) then - call neko_error("The fld file must match the current mesh") + (fld_data%lz .ne. u%dof%Xh%lz) .and. & + (.not. interpolate)) then + call neko_error("The fld file must match the current mesh! & +&Use 'interpolate': 'true' to enable interpolation.") end if - ! Note: we do not copy on the GPU since `set_flow_ic_common` does the - ! copy for us, except for the pressure - call copy(u%x, fld_data%u%x, u%dof%size()) - call copy(v%x, fld_data%v%x, v%dof%size()) - call copy(w%x, fld_data%w%x, w%dof%size()) - call copy(p%x, fld_data%p%x, p%dof%size()) + ! Mesh interpolation if specified + if (interpolate) then + + tol = 1d-6 + if (present(tolerance)) tol = tolerance + + ! These are the coordinates of our current mesh + ! that we use for the interpolation + allocate(x_coord(u%Xh%lx,u%Xh%ly,u%Xh%lz,u%msh%nelv)) + allocate(y_coord(u%Xh%lx,u%Xh%ly,u%Xh%lz,u%msh%nelv)) + allocate(z_coord(u%Xh%lx,u%Xh%ly,u%Xh%lz,u%msh%nelv)) + + if (present(previous_mesh_fname)) then ! Interpolate based on previous mesh + + meshf = file_t(trim(previous_mesh_fname)) + call meshf%read(prev_mesh) + dof = dofmap_t(msh, this%chkp_Xh) + + !> To ensure that each point is within an element + !! Remedies issue with points on the boundary + !! Technically gives each point a slightly different value + !! but still within the specified tolerance + do e = 1, u%dof%msh%nelv + center_x = 0d0 + center_y = 0d0 + center_z = 0d0 + do i = 1,u%dof%Xh%lxyz + center_x = center_x + u%dof%x(i,1,1,e) + center_y = center_y + u%dof%y(i,1,1,e) + center_z = center_z + u%dof%z(i,1,1,e) + end do + center_x = center_x/u%Xh%lxyz + center_y = center_y/u%Xh%lxyz + center_z = center_z/u%Xh%lxyz + do i = 1,u%dof%Xh%lxyz + x_coord(i,1,1,e) = u%dof%x(i,1,1,e) - tol*(u%dof%x(i,1,1,e)-center_x) + y_coord(i,1,1,e) = u%dof%y(i,1,1,e) - tol*(u%dof%y(i,1,1,e)-center_y) + z_coord(i,1,1,e) = u%dof%z(i,1,1,e) - tol*(u%dof%z(i,1,1,e)-center_z) + end do + end do + call global_interp%init(dof,tol=tol) + call global_interp%find_points(x_coord,y_coord,z_coord,u%dof%size()) + + call global_interp%evaluate(u%x, fld_data%u%x) + call global_interp%evaluate(v%x, fld_data%v%x) + call global_interp%evaluate(w%x, fld_data%w%x) + call global_interp%evaluate(p%x, fld_data%p%x) + + else ! Interpolate based on the points in the fld file + + call neko_error("Interp based on fld file is not supported yet") + + end if + + deallocate(x_coord) + deallocate(y_coord) + deallocate(z_coord) + call global_interp%free + + else ! No interpolation + + !call space_interp%init(u%Xh, Yh) + + ! Note: we do not copy on the GPU since `set_flow_ic_common` does the + ! copy for us, except for the pressure + call copy(u%x, fld_data%u%x, u%dof%size()) + call copy(v%x, fld_data%v%x, v%dof%size()) + call copy(w%x, fld_data%w%x, w%dof%size()) + call copy(p%x, fld_data%p%x, p%dof%size()) + + !call space_interp%free + + end if if (NEKO_BCKND_DEVICE .eq. 1) call device_memcpy(p%x, p%x_d, p%dof%size(), & HOST_TO_DEVICE, sync = .false.) @@ -428,16 +549,16 @@ end subroutine set_flow_ic_fld !! @param w The z-component of the velocity field. !! @param p The pressure field. !! @param file_name The name of the checkpoint file. - !! @param previous_mesh If specified, the name of the previouos mesh from + !! @param previous_mesh_fname If specified, the name of the previouos mesh from !! which to interpolate. !! @param tol If specified, tolerance to use for the mesh interpolation. - subroutine set_flow_ic_chkp(u, v, w, p, file_name, previous_mesh, tol) + subroutine set_flow_ic_chkp(u, v, w, p, file_name, previous_mesh_fname, tol) type(field_t), intent(inout) :: u type(field_t), intent(inout) :: v type(field_t), intent(inout) :: w type(field_t), intent(inout) :: p character(len=*), intent(in) :: file_name - character(len=*), intent(in), optional :: previous_mesh + character(len=*), intent(in), optional :: previous_mesh_fname real(kind=rp), intent(in), optional :: tol type(chkp_t) :: chkp_data @@ -446,8 +567,8 @@ subroutine set_flow_ic_chkp(u, v, w, p, file_name, previous_mesh, tol) call chkp_data%init(u, v, w, p) ! Mesh interpolation if specified - if (present(previous_mesh)) then - meshf = file_t(trim(previous_mesh)) + if (present(previous_mesh_fname)) then + meshf = file_t(trim(previous_mesh_fname)) call meshf%read(chkp_data%previous_mesh) end if From 9c0492cc4c408bcd8be77f75e313fc9e49c32e2c Mon Sep 17 00:00:00 2001 From: Victor Baconnet Date: Wed, 17 Jul 2024 14:49:53 +0200 Subject: [PATCH 13/67] fix bugs --- src/fluid/flow_ic.f90 | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/fluid/flow_ic.f90 b/src/fluid/flow_ic.f90 index cedde1973a7..1ad32d20f99 100644 --- a/src/fluid/flow_ic.f90 +++ b/src/fluid/flow_ic.f90 @@ -209,11 +209,12 @@ subroutine set_flow_ic_int(u, v, w, p, coef, gs, type, params) if (found_previous_mesh) then call set_flow_ic_fld(u, v, w, p, read_str, sample_idx, & - prev_mesh, tol) + interpolate, prev_mesh, tol) else ! In this case no mesh interpolation but potential for interpolation ! between different polynomial orders - call set_flow_ic_fld(u, v, w, p, read_str, sample_idx) + call set_flow_ic_fld(u, v, w, p, read_str, sample_idx, & + interpolate, tolerance=tol) end if end if end if @@ -468,15 +469,15 @@ subroutine set_flow_ic_fld(u, v, w, p, file_name, sample_idx, & ! These are the coordinates of our current mesh ! that we use for the interpolation - allocate(x_coord(u%Xh%lx,u%Xh%ly,u%Xh%lz,u%msh%nelv)) - allocate(y_coord(u%Xh%lx,u%Xh%ly,u%Xh%lz,u%msh%nelv)) - allocate(z_coord(u%Xh%lx,u%Xh%ly,u%Xh%lz,u%msh%nelv)) + allocate(x_coords(u%Xh%lx,u%Xh%ly,u%Xh%lz,u%msh%nelv)) + allocate(y_coords(u%Xh%lx,u%Xh%ly,u%Xh%lz,u%msh%nelv)) + allocate(z_coords(u%Xh%lx,u%Xh%ly,u%Xh%lz,u%msh%nelv)) if (present(previous_mesh_fname)) then ! Interpolate based on previous mesh meshf = file_t(trim(previous_mesh_fname)) call meshf%read(prev_mesh) - dof = dofmap_t(msh, this%chkp_Xh) + dof = dofmap_t(prev_mesh, u%Xh) !> To ensure that each point is within an element !! Remedies issue with points on the boundary @@ -495,13 +496,13 @@ subroutine set_flow_ic_fld(u, v, w, p, file_name, sample_idx, & center_y = center_y/u%Xh%lxyz center_z = center_z/u%Xh%lxyz do i = 1,u%dof%Xh%lxyz - x_coord(i,1,1,e) = u%dof%x(i,1,1,e) - tol*(u%dof%x(i,1,1,e)-center_x) - y_coord(i,1,1,e) = u%dof%y(i,1,1,e) - tol*(u%dof%y(i,1,1,e)-center_y) - z_coord(i,1,1,e) = u%dof%z(i,1,1,e) - tol*(u%dof%z(i,1,1,e)-center_z) + x_coords(i,1,1,e) = u%dof%x(i,1,1,e) - tol*(u%dof%x(i,1,1,e)-center_x) + y_coords(i,1,1,e) = u%dof%y(i,1,1,e) - tol*(u%dof%y(i,1,1,e)-center_y) + z_coords(i,1,1,e) = u%dof%z(i,1,1,e) - tol*(u%dof%z(i,1,1,e)-center_z) end do end do call global_interp%init(dof,tol=tol) - call global_interp%find_points(x_coord,y_coord,z_coord,u%dof%size()) + call global_interp%find_points(x_coords,y_coords,z_coords,u%dof%size()) call global_interp%evaluate(u%x, fld_data%u%x) call global_interp%evaluate(v%x, fld_data%v%x) @@ -514,9 +515,9 @@ subroutine set_flow_ic_fld(u, v, w, p, file_name, sample_idx, & end if - deallocate(x_coord) - deallocate(y_coord) - deallocate(z_coord) + deallocate(x_coords) + deallocate(y_coords) + deallocate(z_coords) call global_interp%free else ! No interpolation From 9cf15eaecf99814835143c32b2a5ed3c1e7ff0a3 Mon Sep 17 00:00:00 2001 From: Victor Baconnet Date: Thu, 18 Jul 2024 17:02:01 +0200 Subject: [PATCH 14/67] rewrite some logic --- src/fluid/flow_ic.f90 | 70 +++++++++++++++++++++---------------------- 1 file changed, 34 insertions(+), 36 deletions(-) diff --git a/src/fluid/flow_ic.f90 b/src/fluid/flow_ic.f90 index 1ad32d20f99..0ce815308f1 100644 --- a/src/fluid/flow_ic.f90 +++ b/src/fluid/flow_ic.f90 @@ -56,6 +56,7 @@ module flow_ic use dofmap, only: dofmap_t use global_interpolation, only: global_interpolation_t use interpolation, only: interpolator_t + use space, only: space_t, GLL implicit none private @@ -83,7 +84,7 @@ subroutine set_flow_ic_int(u, v, w, p, coef, gs, type, params) character(len=:), allocatable :: read_str, prev_mesh character(len=80) :: suffix character(len=1024) :: new_fname - integer :: sample_idx, fpos + integer :: sample_idx, fpos, sample_mesh_idx logical :: found_tol, found_previous_mesh, interpolate character(len=LOG_SIZE) :: log_buf @@ -145,31 +146,19 @@ subroutine set_flow_ic_int(u, v, w, p, coef, gs, type, params) call filename_suffix(read_str, suffix) call neko_log%message("File name: " // trim(read_str)) - ! Look for parameters for interpolation - call params%get("case.fluid.initial_condition.previous_mesh", & - prev_mesh, found_previous_mesh) + if (trim(suffix) .eq. "chkp") then - if (found_previous_mesh) then + ! Look for parameters for interpolation + call params%get("case.fluid.initial_condition.previous_mesh", & + prev_mesh, found_previous_mesh) call neko_log%message("Previous mesh: " // trim(prev_mesh)) - interpolate = .true. - else - call json_get_or_default(params, & - "case.fluid.initial_condition.interpolate", interpolate, .false.) - end if - - if (interpolate) then - call neko_log%message("Interpolation: yes") - call json_get_or_default(params, & - 'case.fluid.initial_condition.tolerance', tol, 1d-6) - write (log_buf, '(A,F10.6)') "Tolerance : ", tol - call neko_log%message(log_buf) - else - call neko_log%message("Interpolation: no") - end if - - if (trim(suffix) .eq. "chkp") then if (found_previous_mesh) then + call json_get_or_default(params, & + 'case.fluid.initial_condition.tolerance', tol, 1d-6) + write (log_buf, '(A,F10.6)') "Tolerance : ", tol + call neko_log%message(log_buf) + call set_flow_ic_chkp(u, v, w, p, read_str, prev_mesh, tol) else ! In this case no mesh interpolation but potential for interpolation @@ -205,17 +194,23 @@ subroutine set_flow_ic_int(u, v, w, p, coef, gs, type, params) end if + ! Check if we want to interpolate our field, default is no + call json_get_or_default(params, & + 'case.fluid.initial_condition.interpolate', interpolate, & + .false.) + if (interpolate) then - if (found_previous_mesh) then - call set_flow_ic_fld(u, v, w, p, read_str, sample_idx, & - interpolate, prev_mesh, tol) - else - ! In this case no mesh interpolation but potential for interpolation - ! between different polynomial orders - call set_flow_ic_fld(u, v, w, p, read_str, sample_idx, & - interpolate, tolerance=tol) - end if + ! Get the index of the file that contains the mesh + call json_get_or_default(params, & + 'case.fluid.initial_condition.sample_mesh_index', & + sample_mesh_idx, 0) + + call set_flow_ic_fld(u, v, w, p, read_str, sample_idx, & + interpolate, tol, sample_mesh_idx) + else + call set_flow_ic_fld(u, v, w, p, read_str, sample_idx, & + interpolate) end if end if @@ -395,7 +390,7 @@ end subroutine set_flow_ic_point_zone !! @param sample_idx index of the field file .f000* to read, default is !! -1.. subroutine set_flow_ic_fld(u, v, w, p, file_name, sample_idx, & - interpolate, previous_mesh_fname, tolerance) + interpolate, previous_mesh_fname, tolerance, sample_mesh_idx) type(field_t), intent(inout) :: u type(field_t), intent(inout) :: v type(field_t), intent(inout) :: w @@ -405,15 +400,17 @@ subroutine set_flow_ic_fld(u, v, w, p, file_name, sample_idx, & logical, intent(in) :: interpolate character(len=*), intent(in), optional :: previous_mesh_fname real(kind=rp), intent(in), optional :: tolerance + integer, intent(in), optional :: sample_mesh_idx type(fld_file_data_t) :: fld_data - type(mesh_t) :: prev_mesh type(file_t) :: f, meshf type(dofmap_t) :: dof real(kind=rp) :: tol ! ---- For the mesh to mesh interpolation integer :: e, i + type(mesh_t) :: prev_mesh + type(space_t) :: prev_Xh real(kind=rp) :: center_x, center_y, center_z real(kind=rp), allocatable :: x_coords(:,:,:,:), y_coords(:,:,:,:), & z_coords(:,:,:,:) @@ -475,9 +472,10 @@ subroutine set_flow_ic_fld(u, v, w, p, file_name, sample_idx, & if (present(previous_mesh_fname)) then ! Interpolate based on previous mesh - meshf = file_t(trim(previous_mesh_fname)) - call meshf%read(prev_mesh) - dof = dofmap_t(prev_mesh, u%Xh) + ! Initialize an "empty" mesh and construct a dof object based on that + call prev_mesh%init(fld_data%gdim, fld_data%nelv) + call prev_Xh%init(GLL, fld_data%lx, fld_data%ly, fld_data%lz) + dof = dofmap_t(prev_mesh, prev_Xh) !> To ensure that each point is within an element !! Remedies issue with points on the boundary From 34140add19ff8f382eb221027e6fff69227d18a5 Mon Sep 17 00:00:00 2001 From: Victor Baconnet Date: Fri, 19 Jul 2024 00:10:25 +0200 Subject: [PATCH 15/67] wrap interpolation in fld_file_data --- src/.depends | 4 +- src/fluid/flow_ic.f90 | 150 +++++++++++++++----------------------- src/io/fld_file_data.f90 | 114 ++++++++++++++++++++++++++++- src/scalar/scalar_ic.f90 | 152 ++++++++++++++++++++++++++++----------- src/sem/dofmap.f90 | 43 ++++++++++- 5 files changed, 324 insertions(+), 139 deletions(-) diff --git a/src/.depends b/src/.depends index 0adc9aff65e..5ac967e6818 100644 --- a/src/.depends +++ b/src/.depends @@ -106,7 +106,7 @@ io/map_file.o : io/map_file.f90 io/format/map.o comm/comm.o common/utils.o io/ge io/re2_file.o : io/re2_file.f90 common/log.o adt/htable.o io/map_file.o io/format/map.o io/format/re2.o common/datadist.o comm/mpi_types.o comm/comm.o mesh/point.o mesh/mesh.o common/utils.o config/num_types.o io/generic_file.o io/rea_file.o : io/rea_file.f90 common/log.o adt/htable.o common/datadist.o comm/comm.o io/map_file.o io/re2_file.o io/format/rea.o io/format/map.o mesh/point.o mesh/mesh.o common/utils.o config/num_types.o io/generic_file.o io/fld_file.o : io/fld_file.f90 comm/mpi_types.o math/math.o common/log.o common/datadist.o comm/comm.o common/utils.o mesh/mesh.o fluid/mean_sqr_flow.o fluid/mean_flow.o io/fld_file_data.o math/vector.o common/structs.o sem/space.o sem/dofmap.o field/field_list.o field/field.o io/generic_file.o config/num_types.o -io/fld_file_data.o : io/fld_file_data.f90 math/vector.o math/math.o config/num_types.o +io/fld_file_data.o : io/fld_file_data.f90 mesh/mesh.o common/utils.o common/global_interpolation.o sem/space.o sem/dofmap.o field/field.o math/vector.o math/math.o config/num_types.o io/vtk_file.o : io/vtk_file.f90 comm/comm.o common/log.o mesh/tri_mesh.o mesh/tet_mesh.o field/mesh_field.o sem/dofmap.o field/field.o mesh/mesh.o common/utils.o io/generic_file.o config/num_types.o io/stl_file.o : io/stl_file.f90 io/format/stl.o comm/comm.o common/utils.o comm/mpi_types.o mesh/point.o common/log.o mesh/tri_mesh.o io/generic_file.o config/num_types.o io/nmsh_file.o : io/nmsh_file.f90 common/log.o comm/mpi_types.o common/datadist.o mesh/element.o io/format/nmsh.o adt/tuple.o mesh/point.o common/utils.o mesh/mesh.o comm/comm.o io/generic_file.o @@ -194,7 +194,7 @@ fluid/mean_flow.o : fluid/mean_flow.f90 field/field.o field/mean_field.o fluid/fluid_stats.o : fluid/fluid_stats.f90 common/utils.o config/neko_config.o device/device.o common/stats_quant.o gs/gather_scatter.o field/field_list.o field/field_registry.o field/field.o sem/coef.o math/operators.o math/math.o math/mathops.o math/bcknd/device/device_mathops.o math/bcknd/device/device_math.o field/mean_field.o fluid/mean_sqr_flow.o : fluid/mean_sqr_flow.f90 field/field.o field/mean_sqr_field.o fluid/flow_profile.o : fluid/flow_profile.f90 config/num_types.o -fluid/flow_ic.o : fluid/flow_ic.f90 io/file.o common/checkpoint.o io/fld_file_data.o mesh/point_zone_registry.o mesh/point_zone.o common/json_utils.o common/user_intf.o math/bcknd/device/device_math.o math/math.o sem/coef.o common/utils.o field/field.o device/device.o fluid/flow_profile.o config/neko_config.o gs/gather_scatter.o common/log.o config/num_types.o +fluid/flow_ic.o : fluid/flow_ic.f90 sem/space.o sem/interpolation.o common/global_interpolation.o sem/dofmap.o mesh/mesh.o io/file.o common/checkpoint.o io/fld_file_data.o mesh/point_zone_registry.o mesh/point_zone.o common/json_utils.o common/user_intf.o math/bcknd/device/device_math.o math/math.o sem/coef.o common/utils.o field/field.o device/device.o fluid/flow_profile.o config/neko_config.o gs/gather_scatter.o common/log.o config/num_types.o fluid/advection.o : fluid/advection.f90 sem/coef.o field/field.o sem/space.o config/num_types.o fluid/advection_fctry.o : fluid/advection_fctry.f90 fluid/bcknd/advection/adv_no_dealias.o fluid/bcknd/advection/adv_dealias.o fluid/advection.o common/json_utils.o sem/coef.o fluid/bcknd/advection/adv_dealias.o : fluid/bcknd/advection/adv_dealias.f90 device/device.o sem/interpolation.o math/operators.o config/neko_config.o math/bcknd/device/device_math.o sem/coef.o field/field.o sem/space.o math/math.o config/num_types.o fluid/advection.o diff --git a/src/fluid/flow_ic.f90 b/src/fluid/flow_ic.f90 index 0ce815308f1..aa3b105a475 100644 --- a/src/fluid/flow_ic.f90 +++ b/src/fluid/flow_ic.f90 @@ -52,8 +52,6 @@ module flow_ic use fld_file_data, only: fld_file_data_t use checkpoint, only: chkp_t use file, only: file_t - use mesh, only: mesh_t - use dofmap, only: dofmap_t use global_interpolation, only: global_interpolation_t use interpolation, only: interpolator_t use space, only: space_t, GLL @@ -201,6 +199,11 @@ subroutine set_flow_ic_int(u, v, w, p, coef, gs, type, params) if (interpolate) then + call json_get_or_default(params, & + 'case.fluid.initial_condition.tolerance', tol, 1d-6) + write (log_buf, '(A,F10.6)') "Tolerance : ", tol + call neko_log%message(log_buf) + ! Get the index of the file that contains the mesh call json_get_or_default(params, & 'case.fluid.initial_condition.sample_mesh_index', & @@ -390,7 +393,7 @@ end subroutine set_flow_ic_point_zone !! @param sample_idx index of the field file .f000* to read, default is !! -1.. subroutine set_flow_ic_fld(u, v, w, p, file_name, sample_idx, & - interpolate, previous_mesh_fname, tolerance, sample_mesh_idx) + interpolate, tolerance, sample_mesh_idx) type(field_t), intent(inout) :: u type(field_t), intent(inout) :: v type(field_t), intent(inout) :: w @@ -398,141 +401,104 @@ subroutine set_flow_ic_fld(u, v, w, p, file_name, sample_idx, & character(len=*), intent(in) :: file_name integer, intent(in) :: sample_idx logical, intent(in) :: interpolate - character(len=*), intent(in), optional :: previous_mesh_fname real(kind=rp), intent(in), optional :: tolerance integer, intent(in), optional :: sample_mesh_idx type(fld_file_data_t) :: fld_data - type(file_t) :: f, meshf - type(dofmap_t) :: dof - real(kind=rp) :: tol + type(file_t) :: f ! ---- For the mesh to mesh interpolation - integer :: e, i - type(mesh_t) :: prev_mesh - type(space_t) :: prev_Xh - real(kind=rp) :: center_x, center_y, center_z - real(kind=rp), allocatable :: x_coords(:,:,:,:), y_coords(:,:,:,:), & - z_coords(:,:,:,:) type(global_interpolation_t) :: global_interp ! ----- ! ---- For space to space interpolation + type(space_t) :: prev_Xh type(interpolator_t) :: space_interp ! ---- - ! Should this init be init(u%msh%nelv, u%msh%offset_el)? call fld_data%init - f = file_t(trim(file_name)) - ! Set the counter if not the default value - if (sample_idx .ne. -1) then - call f%set_counter(sample_idx) - call f%read(fld_data) - else - ! If we default to the last file of the series we need to call - ! read once to get the # of samples etc + ! If no sample is specified, we read as a classic fld series + ! with the mesh located at index 0 + if (sample_idx .eq. -1) then + + ! Read one time to get all information about the fld series + ! and read the first file in the series. call f%read(fld_data) - if (fld_data%meta_nsamples .gt. 0) then + ! If there is more than one file, read the last one in the series. + if (fld_data%meta_nsamples .gt. 1) then call f%set_counter(fld_data%meta_nsamples + & fld_data%meta_start_counter - 1) call f%read(fld_data) end if - end if + + else + ! in this case we specify an fld file to read, so we + ! read only that file except if we need to interpolate. + ! Interpolation requires to first read the file that contains + ! x,y,z values, which is assumed to be the file with index 0 + ! unless specified. The existence of x,y,z coordinates will + ! be checked later anyways as a safeguard. + if (interpolate .and. sample_mesh_idx .ne. sample_idx) then + call f%set_counter(sample_mesh_idx) + call f%read(fld_data) + end if + + call f%set_counter(sample_idx) + call f%read(fld_data) + + end if ! sample_idx .eq. -1 ! ! Check if the data in the fld file matches the current case. ! Note that this is a safeguard and there are corner cases where - ! two different meshes have the same dimension, same # of elements - ! and same polynomial orders but this should be enough to cover most cases. + ! two different meshes have the same dimension and same # of elements + ! but this should be enough to cover the most obvious cases. ! - if ( (fld_data%gdim .ne. u%msh%gdim) .or. & - (fld_data%glb_nelv .ne. u%msh%glb_nelv) .or. & - (fld_data%lx .ne. u%dof%Xh%lx) .or. & - (fld_data%ly .ne. u%dof%Xh%ly) .or. & - (fld_data%lz .ne. u%dof%Xh%lz) .and. & + if ( ((fld_data%gdim .ne. u%msh%gdim) .or. & + (fld_data%glb_nelv .ne. u%msh%glb_nelv)) .and. & (.not. interpolate)) then call neko_error("The fld file must match the current mesh! & &Use 'interpolate': 'true' to enable interpolation.") + else if (interpolate) then + call neko_log%warning("You have activated interpolation but you may & +&still be using the same mesh.") + call neko_log%message("(do not take this into account if this & +&was done on purpose)") end if ! Mesh interpolation if specified if (interpolate) then - tol = 1d-6 - if (present(tolerance)) tol = tolerance - - ! These are the coordinates of our current mesh - ! that we use for the interpolation - allocate(x_coords(u%Xh%lx,u%Xh%ly,u%Xh%lz,u%msh%nelv)) - allocate(y_coords(u%Xh%lx,u%Xh%ly,u%Xh%lz,u%msh%nelv)) - allocate(z_coords(u%Xh%lx,u%Xh%ly,u%Xh%lz,u%msh%nelv)) - - if (present(previous_mesh_fname)) then ! Interpolate based on previous mesh - - ! Initialize an "empty" mesh and construct a dof object based on that - call prev_mesh%init(fld_data%gdim, fld_data%nelv) - call prev_Xh%init(GLL, fld_data%lx, fld_data%ly, fld_data%lz) - dof = dofmap_t(prev_mesh, prev_Xh) - - !> To ensure that each point is within an element - !! Remedies issue with points on the boundary - !! Technically gives each point a slightly different value - !! but still within the specified tolerance - do e = 1, u%dof%msh%nelv - center_x = 0d0 - center_y = 0d0 - center_z = 0d0 - do i = 1,u%dof%Xh%lxyz - center_x = center_x + u%dof%x(i,1,1,e) - center_y = center_y + u%dof%y(i,1,1,e) - center_z = center_z + u%dof%z(i,1,1,e) - end do - center_x = center_x/u%Xh%lxyz - center_y = center_y/u%Xh%lxyz - center_z = center_z/u%Xh%lxyz - do i = 1,u%dof%Xh%lxyz - x_coords(i,1,1,e) = u%dof%x(i,1,1,e) - tol*(u%dof%x(i,1,1,e)-center_x) - y_coords(i,1,1,e) = u%dof%y(i,1,1,e) - tol*(u%dof%y(i,1,1,e)-center_y) - z_coords(i,1,1,e) = u%dof%z(i,1,1,e) - tol*(u%dof%z(i,1,1,e)-center_z) - end do - end do - call global_interp%init(dof,tol=tol) - call global_interp%find_points(x_coords,y_coords,z_coords,u%dof%size()) - - call global_interp%evaluate(u%x, fld_data%u%x) - call global_interp%evaluate(v%x, fld_data%v%x) - call global_interp%evaluate(w%x, fld_data%w%x) - call global_interp%evaluate(p%x, fld_data%p%x) - - else ! Interpolate based on the points in the fld file - - call neko_error("Interp based on fld file is not supported yet") + global_interp = fld_data%generate_interpolator(u%dof, u%msh, tolerance) - end if + ! Evaluate velocities and pressure + call global_interp%evaluate(u%x, fld_data%u%x) + call global_interp%evaluate(v%x, fld_data%v%x) + call global_interp%evaluate(w%x, fld_data%w%x) + call global_interp%evaluate(p%x, fld_data%p%x) - deallocate(x_coords) - deallocate(y_coords) - deallocate(z_coords) call global_interp%free else ! No interpolation - !call space_interp%init(u%Xh, Yh) + ! Build a space_t object from the data in the fld file + call prev_Xh%init(GLL, fld_data%lx, fld_data%ly, fld_data%lz) + call space_interp%init(u%Xh, prev_Xh) - ! Note: we do not copy on the GPU since `set_flow_ic_common` does the - ! copy for us, except for the pressure - call copy(u%x, fld_data%u%x, u%dof%size()) - call copy(v%x, fld_data%v%x, v%dof%size()) - call copy(w%x, fld_data%w%x, w%dof%size()) - call copy(p%x, fld_data%p%x, p%dof%size()) + call space_interp%map_host(u%x, fld_data%u%x, fld_data%nelv, u%Xh) + call space_interp%map_host(v%x, fld_data%v%x, fld_data%nelv, u%Xh) + call space_interp%map_host(w%x, fld_data%w%x, fld_data%nelv, u%Xh) + call space_interp%map_host(p%x, fld_data%p%x, fld_data%nelv, u%Xh) - !call space_interp%free + call space_interp%free end if + ! Note: we do not copy on the GPU since `set_flow_ic_common` does the + ! copy for us, except for the pressure if (NEKO_BCKND_DEVICE .eq. 1) call device_memcpy(p%x, p%x_d, p%dof%size(), & HOST_TO_DEVICE, sync = .false.) diff --git a/src/io/fld_file_data.f90 b/src/io/fld_file_data.f90 index ae999bc2c7b..2c4f5c0e26b 100644 --- a/src/io/fld_file_data.f90 +++ b/src/io/fld_file_data.f90 @@ -8,6 +8,12 @@ module fld_file_data use num_types, only : rp use math, only: cmult, add2 use vector, only : vector_t, vector_ptr_t + use field, only: field_t + use dofmap, only: dofmap_t + use space, only: space_t, GLL + use global_interpolation, only: global_interpolation_t + use utils, only: neko_error + use mesh, only: mesh_t implicit none private @@ -42,7 +48,10 @@ module fld_file_data procedure, pass(this) :: scale => fld_file_data_scale procedure, pass(this) :: add => fld_file_data_add procedure, pass(this) :: size => fld_file_data_size - procedure, pass(this) :: get_list => fld_file_get_list + procedure, pass(this) :: get_list => fld_file_data_get_list + !> Generates a global_interpolation object to interpolate the fld data. + procedure, pass(this) :: generate_interpolator => & + fld_file_data_generate_interpolator end type fld_file_data_t contains @@ -51,6 +60,7 @@ module fld_file_data subroutine fld_file_data_init(this, nelv, offset_el) class(fld_file_data_t), intent(inout) :: this integer, intent(in), optional :: nelv, offset_el + call this%free() if (present(nelv)) this%nelv = nelv if (present(offset_el)) this%offset_el = offset_el @@ -71,7 +81,7 @@ function fld_file_data_size(this) result(i) end function fld_file_data_size !> Get a list with pointers to the fields in the fld file - subroutine fld_file_get_list(this, ptr_list, n) + subroutine fld_file_data_get_list(this, ptr_list, n) class(fld_file_data_t), target, intent(in) :: this integer, intent(in) :: n integer :: i, j @@ -102,7 +112,7 @@ subroutine fld_file_get_list(this, ptr_list, n) i = i +1 end do - end subroutine fld_file_get_list + end subroutine fld_file_data_get_list @@ -171,4 +181,102 @@ subroutine fld_file_data_free(this) this%meta_start_counter = 0 end subroutine fld_file_data_free + !> Generates a global_interpolation object to interpolate the fld data. + !! @param to_dof Dofmap on which to interpolate. + !! @param to_msh Mesh on which to interpolate. + !! @param tolerance Tolerance for the newton iterations. + function fld_file_data_generate_interpolator(this, to_dof, & + to_msh, tolerance) result(global_interp) + class(fld_file_data_t), intent(in) :: this + type(dofmap_t), intent(in), target :: to_dof + type(mesh_t), intent(in), target :: to_msh + real(kind=rp), intent(in), optional :: tolerance + + type(global_interpolation_t) :: global_interp + + ! --- variables for interpolation + type(dofmap_t) :: fld_dof + type(space_t) :: fld_Xh + type(mesh_t) :: fld_empty_mesh + real(kind=rp), allocatable :: x_coords(:,:,:,:), y_coords(:,:,:,:), & + z_coords(:,:,:,:) + real(kind=rp) :: center_x, center_y, center_z + integer :: e, i + real(kind=rp) :: tol + ! --- + + type(space_t), pointer :: to_Xh + to_Xh => to_dof%Xh + + ! Safeguard in case we didn't read mesh information + if (.not. allocated(this%x%x) .or. & + .not. allocated(this%y%x) .or. & + .not. allocated(this%z%x)) call neko_error("Unable to retrieve & +&mesh information from fld data.") + + ! Same tolerance as for chkp + tol = 1d-6 + if (present(tolerance)) tol = tolerance + + ! Create a space based on the fld data + call fld_Xh%init(GLL, this%lx, this%ly, this%lz) + + ! Initialize an "empty" mesh and construct a "stripped down" + ! dofmap that only has x,y,z coordinates. This is because + ! global_interpolator needs a dofmap in its init but in practice + ! only uses dof%x, dof%y, dof%z + call fld_empty_mesh%init(this%gdim, this%nelv) + fld_dof = dofmap_t(this%x%x, this%y%x, this%z%x, & + this%nelv, this%lx, this%ly, this%lz) + + ! These are the coordinates of our current dofmap + ! that we use for the interpolation + allocate(x_coords(to_Xh%lx, to_Xh%ly, to_Xh%lz, to_msh%nelv)) + allocate(y_coords(to_Xh%lx, to_Xh%ly, to_Xh%lz, to_msh%nelv)) + allocate(z_coords(to_Xh%lx, to_Xh%ly, to_Xh%lz, to_msh%nelv)) + + !> To ensure that each point is within an element + !! Remedies issue with points on the boundary + !! Technically gives each point a slightly different value + !! but still within the specified tolerance + do e = 1, to_msh%nelv + center_x = 0d0 + center_y = 0d0 + center_z = 0d0 + do i = 1, to_Xh%lxyz + center_x = center_x + to_dof%x(i, 1, 1, e) + center_y = center_y + to_dof%y(i, 1, 1, e) + center_z = center_z + to_dof%z(i, 1, 1, e) + end do + center_x = center_x / to_Xh%lxyz + center_y = center_y / to_Xh%lxyz + center_z = center_z / to_Xh%lxyz + do i = 1, to_Xh%lxyz + x_coords(i, 1, 1, e) = to_dof%x(i, 1, 1, e) - & + tol * (to_dof%x(i, 1, 1, e) - center_x) + y_coords(i, 1, 1, e) = to_dof%y(i, 1, 1, e) - & + tol*(to_dof%y(i, 1, 1, e)-center_y) + z_coords(i, 1, 1, e) = to_dof%z(i, 1, 1, e) - & + tol*(to_dof%z(i, 1, 1, e)-center_z) + end do + end do + + ! The initialization is done based on the variables created from + ! fld data + call global_interp%init(fld_dof, tol = tol, Xh = fld_Xh, & + msh = fld_empty_mesh) + + ! Note that to_dof%size() should be equal to + ! to_msh%nelv * to_Xh%lxyz + if (to_dof%size() .ne. to_msh%nelv*to_Xh%lxyz) & + call neko_error("something weird happening") + call global_interp%find_points(x_coords, y_coords, z_coords, & + to_dof%size()) + + deallocate(x_coords) + deallocate(y_coords) + deallocate(z_coords) + + end function fld_file_data_generate_interpolator + end module fld_file_data diff --git a/src/scalar/scalar_ic.f90 b/src/scalar/scalar_ic.f90 index 0f421912fcd..cfa49de9d3e 100644 --- a/src/scalar/scalar_ic.f90 +++ b/src/scalar/scalar_ic.f90 @@ -51,6 +51,9 @@ module scalar_ic use fld_file_data, only: fld_file_data_t use checkpoint, only: chkp_t use file, only: file_t + use global_interpolation, only: global_interpolation_t + use interpolation, only: interpolator_t + use space, only: space_t, GLL implicit none private @@ -83,8 +86,8 @@ subroutine set_scalar_ic_int(s, coef, gs, type, params) character(len=:), allocatable :: read_str, prev_mesh character(len=80) :: suffix real(kind=rp) :: zone_value, tol - logical :: found - integer :: sample_idx, fpos + logical :: found, found_previous_mesh, interpolate + integer :: sample_idx, fpos, sample_mesh_idx character(len=LOG_SIZE) :: log_buf if (trim(type) .eq. 'uniform') then @@ -121,26 +124,21 @@ subroutine set_scalar_ic_int(s, coef, gs, type, params) if (trim(suffix) .eq. "chkp") then + ! Look for parameters for interpolation call params%get("case.scalar.initial_condition.previous_mesh", & - prev_mesh, found) + prev_mesh, found_previous_mesh) + call neko_log%message("Previous mesh: " // trim(prev_mesh)) - if (found) then - - call neko_log%message("Previous mesh: " // trim(prev_mesh)) - call params%get('case.scalar.initial_condition.tolerance', tol, & - found) - - if (found) then - write (log_buf, '(A,F10.6)') "Tolerance : ", tol - call neko_log%message(log_buf) - call set_scalar_ic_chkp(s, read_str, prev_mesh, tol) - else - call set_scalar_ic_chkp(s, read_str, prev_mesh) - end if + if (found_previous_mesh) then + call json_get_or_default(params, & + 'case.scalar.initial_condition.tolerance', tol, 1d-6) + write (log_buf, '(A,F10.6)') "Tolerance : ", tol + call neko_log%message(log_buf) - ! In this case no mesh interpolation but potential for - ! interpolation between different polynomial orders + call set_scalar_ic_chkp(s, read_str, prev_mesh, tol) else + ! In this case no mesh interpolation but potential for interpolation + ! between different polynomial orders call set_scalar_ic_chkp(s, read_str) end if @@ -172,8 +170,31 @@ subroutine set_scalar_ic_int(s, coef, gs, type, params) end if - call set_scalar_ic_fld(s, read_str, sample_idx) + ! Check if we want to interpolate our field, default is no + call json_get_or_default(params, & + 'case.scalar.initial_condition.interpolate', interpolate, & + .false.) + + if (interpolate) then + + call json_get_or_default(params, & + 'case.scalar.initial_condition.tolerance', tol, 1d-6) + write (log_buf, '(A,F10.6)') "Tolerance : ", tol + call neko_log%message(log_buf) + + ! Get the index of the file that contains the mesh + call json_get_or_default(params, & + 'case.scalar.initial_condition.sample_mesh_index', & + sample_mesh_idx, 0) + + call set_scalar_ic_fld(s, read_str, sample_idx, & + interpolate, tol, sample_mesh_idx) + else + call set_scalar_ic_fld(s, read_str, sample_idx, & + interpolate) + end if end if + else call neko_error('Invalid initial condition') end if @@ -279,51 +300,100 @@ end subroutine set_scalar_ic_point_zone !! @param file_name The name of the "fld" file series. !! @param sample_idx index of the field file .f000* to read, default is !! -1.. - subroutine set_scalar_ic_fld(s, file_name, sample_idx) + subroutine set_scalar_ic_fld(s, file_name, sample_idx, & + interpolate, tolerance, sample_mesh_idx) type(field_t), intent(inout) :: s character(len=*), intent(in) :: file_name integer, intent(in) :: sample_idx + logical, intent(in) :: interpolate + real(kind=rp), intent(in), optional :: tolerance + integer, intent(in), optional :: sample_mesh_idx type(fld_file_data_t) :: fld_data type(file_t) :: f - ! Should this init be init(u%msh%nelv, u%msh%offset_el)? - call fld_data%init + ! ---- For the mesh to mesh interpolation + type(global_interpolation_t) :: global_interp + ! ----- + + ! ---- For space to space interpolation + type(space_t) :: prev_Xh + type(interpolator_t) :: space_interp + ! ---- + call fld_data%init f = file_t(trim(file_name)) - ! Set the counter if not the default value - if (sample_idx .ne. -1) then - call f%set_counter(sample_idx) - call f%read(fld_data) - else - ! If we default to the last file of the series we need to call - ! read once to get the # of samples etc + ! If no sample is specified, we read as a classic fld series + ! with the mesh located at index 0 + if (sample_idx .eq. -1) then + + ! Read one time to get all information about the fld series + ! and read the first file in the series. call f%read(fld_data) - if (fld_data%meta_nsamples .gt. 0) then + ! If there is more than one file, read the last one in the series. + if (fld_data%meta_nsamples .gt. 1) then call f%set_counter(fld_data%meta_nsamples + & fld_data%meta_start_counter - 1) call f%read(fld_data) end if - end if + + else + ! in this case we specify an fld file to read, so we + ! read only that file except if we need to interpolate. + ! Interpolation requires to first read the file that contains + ! x,y,z values, which is assumed to be the file with index 0 + ! unless specified. The existence of x,y,z coordinates will + ! be checked later anyways as a safeguard. + if (interpolate .and. sample_mesh_idx .ne. sample_idx) then + call f%set_counter(sample_mesh_idx) + call f%read(fld_data) + end if + + call f%set_counter(sample_idx) + call f%read(fld_data) + + end if ! sample_idx .eq. -1 ! ! Check if the data in the fld file matches the current case. ! Note that this is a safeguard and there are corner cases where - ! two different meshes have the same dimension, same # of elements - ! and same polynomial orders but this should be enough to cover most cases. + ! two different meshes have the same dimension and same # of elements + ! but this should be enough to cover the most obvious cases. ! - if ( (fld_data%gdim .ne. s%msh%gdim) .or. & - (fld_data%glb_nelv .ne. s%msh%glb_nelv) .or. & - (fld_data%lx .ne. s%dof%Xh%lx) .or. & - (fld_data%ly .ne. s%dof%Xh%ly) .or. & - (fld_data%lz .ne. s%dof%Xh%lz)) then - call neko_error("The fld file must match the current mesh") + if ( ((fld_data%gdim .ne. u%msh%gdim) .or. & + (fld_data%glb_nelv .ne. u%msh%glb_nelv)) .and. & + (.not. interpolate)) then + call neko_error("The fld file must match the current mesh! & +&Use 'interpolate': 'true' to enable interpolation.") + else if (interpolate) then + call neko_log%warning("You have activated interpolation but you may & +&still be using the same mesh.") + call neko_log%message("(do not take this into account if this & +&was done on purpose)") end if - ! Note: we do not copy on the GPU since `set_flow_ic_common` does the copy for us - call copy(s%x, fld_data%t%x, s%dof%size()) + ! Mesh interpolation if specified + if (interpolate) then + + global_interp = fld_data%generate_interpolator(s%dof, s%msh, tolerance) + + ! Evaluate scalar + call global_interp%evaluate(s%x, fld_data%t%x) + call global_interp%free + + else ! No interpolation + + ! Build a space_t object from the data in the fld file + call prev_Xh%init(GLL, fld_data%lx, fld_data%ly, fld_data%lz) + call space_interp%init(s%Xh, prev_Xh) + + call space_interp%map_host(s%x, fld_data%t%x, fld_data%nelv, s%Xh) + + call space_interp%free + + end if call fld_data%free diff --git a/src/sem/dofmap.f90 b/src/sem/dofmap.f90 index 16f4e0b4018..c6aa5d4b735 100644 --- a/src/sem/dofmap.f90 +++ b/src/sem/dofmap.f90 @@ -74,11 +74,52 @@ module dofmap end type dofmap_t interface dofmap_t - module procedure dofmap_init + module procedure dofmap_init, dofmap_init_from_coords end interface dofmap_t contains + !> Initialize a stripped-down version of a dofmap object, with only + !! x,y,z coordinates. + function dofmap_init_from_coords(x, y, z, nelv, lx, ly, lz) result(this) + real(kind=rp), intent(in) :: x(nelv*lx*ly*lz) + real(kind=rp), intent(in) :: y(nelv*lx*ly*lz) + real(kind=rp), intent(in) :: z(nelv*lx*ly*lz) + integer, intent(in) :: nelv + integer, intent(in) :: lx + integer, intent(in) :: ly + integer, intent(in) :: lz + type(dofmap_t) :: this + + integer :: n + + call dofmap_free(this) + + this%ntot = lx * ly * lz * nelv + + allocate(this%x(lx, ly, lz, nelv)) + allocate(this%y(lx, ly, lz, nelv)) + allocate(this%z(lx, ly, lz, nelv)) + + call copy(this%x, x, this%ntot) + call copy(this%y, y, this%ntot) + call copy(this%z, z, this%ntot) + + if (NEKO_BCKND_DEVICE .eq. 1) then + call device_map(this%x, this%x_d, this%ntot) + call device_map(this%y, this%y_d, this%ntot) + call device_map(this%z, this%z_d, this%ntot) + + call device_memcpy(this%x, this%x_d, this%ntot, & + HOST_TO_DEVICE, sync=.false.) + call device_memcpy(this%y, this%y_d, this%ntot, & + HOST_TO_DEVICE, sync=.false.) + call device_memcpy(this%z, this%z_d, this%ntot, & + HOST_TO_DEVICE, sync=.false.) + end if + + end function dofmap_init_from_coords + function dofmap_init(msh, Xh) result(this) type(mesh_t), target, intent(inout) :: msh !< Mesh type(space_t), target, intent(inout) :: Xh !< Function space \f$ X_h \f$ From f591eb7ca2c1162cecbdfd36ddc442b201ffc90b Mon Sep 17 00:00:00 2001 From: Victor Baconnet Date: Fri, 19 Jul 2024 00:32:49 +0200 Subject: [PATCH 16/67] fix some bugs --- src/common/global_interpolation.F90 | 25 ++++++++++++++++++++----- src/scalar/scalar_ic.f90 | 4 ++-- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/common/global_interpolation.F90 b/src/common/global_interpolation.F90 index 5d9e703182b..9abac1b7d6b 100644 --- a/src/common/global_interpolation.F90 +++ b/src/common/global_interpolation.F90 @@ -106,20 +106,35 @@ module global_interpolation !> Evaluate only local points end type global_interpolation_t - contains - !> Initialize user defined variables. + + !> Initialize the global interpolation object on a dofmap. !! @param dof Dofmap on which the interpolation is to be carried out. !! @param tol Tolerance for Newton iterations. - subroutine global_interpolation_init(this, dof, tol) + !! @param Xh Space on which to interpolate. + !! @param msh Mesh on which to interp + subroutine global_interpolation_init(this, dof, tol, Xh, msh) class(global_interpolation_t), intent(inout) :: this type(dofmap_t), target :: dof real(kind=rp), optional :: tol + type(space_t), intent(in), target, optional :: Xh + type(mesh_t), intent(in), target, optional :: msh integer :: lx, ly, lz, nelv, max_pts_per_iter this%dof => dof - this%Xh => dof%Xh - this%mesh => dof%msh + + if (present(Xh)) then + this%Xh => Xh + else + this%Xh => dof%Xh + end if + + if (present(msh)) then + this%mesh => msh + else + this%mesh => dof%msh + end if + if(present(tol)) this%tol = tol #ifdef HAVE_GSLIB diff --git a/src/scalar/scalar_ic.f90 b/src/scalar/scalar_ic.f90 index cfa49de9d3e..0ab77929763 100644 --- a/src/scalar/scalar_ic.f90 +++ b/src/scalar/scalar_ic.f90 @@ -362,8 +362,8 @@ subroutine set_scalar_ic_fld(s, file_name, sample_idx, & ! two different meshes have the same dimension and same # of elements ! but this should be enough to cover the most obvious cases. ! - if ( ((fld_data%gdim .ne. u%msh%gdim) .or. & - (fld_data%glb_nelv .ne. u%msh%glb_nelv)) .and. & + if ( ((fld_data%gdim .ne. s%msh%gdim) .or. & + (fld_data%glb_nelv .ne. s%msh%glb_nelv)) .and. & (.not. interpolate)) then call neko_error("The fld file must match the current mesh! & &Use 'interpolate': 'true' to enable interpolation.") From 3c3aa13745ab0b7b66f8297f75d69f6c71975b33 Mon Sep 17 00:00:00 2001 From: Victor Baconnet Date: Mon, 22 Jul 2024 12:37:28 +0200 Subject: [PATCH 17/67] reformat a bit --- src/common/global_interpolation.F90 | 2 +- src/fluid/flow_ic.f90 | 65 ++++++++++++++++------------- src/io/fld_file_data.f90 | 15 +++---- 3 files changed, 43 insertions(+), 39 deletions(-) diff --git a/src/common/global_interpolation.F90 b/src/common/global_interpolation.F90 index 9abac1b7d6b..22889bb36f0 100644 --- a/src/common/global_interpolation.F90 +++ b/src/common/global_interpolation.F90 @@ -116,7 +116,7 @@ module global_interpolation subroutine global_interpolation_init(this, dof, tol, Xh, msh) class(global_interpolation_t), intent(inout) :: this type(dofmap_t), target :: dof - real(kind=rp), optional :: tol + real(kind=rp), intent(in), optional :: tol type(space_t), intent(in), target, optional :: Xh type(mesh_t), intent(in), target, optional :: msh integer :: lx, ly, lz, nelv, max_pts_per_iter diff --git a/src/fluid/flow_ic.f90 b/src/fluid/flow_ic.f90 index aa3b105a475..c4a744800b2 100644 --- a/src/fluid/flow_ic.f90 +++ b/src/fluid/flow_ic.f90 @@ -83,7 +83,7 @@ subroutine set_flow_ic_int(u, v, w, p, coef, gs, type, params) character(len=80) :: suffix character(len=1024) :: new_fname integer :: sample_idx, fpos, sample_mesh_idx - logical :: found_tol, found_previous_mesh, interpolate + logical :: found_previous_mesh, interpolate character(len=LOG_SIZE) :: log_buf ! @@ -149,18 +149,20 @@ subroutine set_flow_ic_int(u, v, w, p, coef, gs, type, params) ! Look for parameters for interpolation call params%get("case.fluid.initial_condition.previous_mesh", & prev_mesh, found_previous_mesh) - call neko_log%message("Previous mesh: " // trim(prev_mesh)) + ! Get tolerance for potential interpolation + call json_get_or_default(params, & + 'case.fluid.initial_condition.tolerance', tol, 1d-6) if (found_previous_mesh) then - call json_get_or_default(params, & - 'case.fluid.initial_condition.tolerance', tol, 1d-6) - write (log_buf, '(A,F10.6)') "Tolerance : ", tol + call neko_log%message( "Previous mesh: " // trim(prev_mesh)) + write (log_buf, '(A,E15.7)') "Tolerance : ", tol call neko_log%message(log_buf) + end if - call set_flow_ic_chkp(u, v, w, p, read_str, prev_mesh, tol) + if (found_previous_mesh) then + call set_flow_ic_chkp(u, v, w, p, read_str, & + previous_mesh_fname = prev_mesh, tol = tol) else - ! In this case no mesh interpolation but potential for interpolation - ! between different polynomial orders call set_flow_ic_chkp(u, v, w, p, read_str) end if @@ -171,7 +173,7 @@ subroutine set_flow_ic_int(u, v, w, p, coef, gs, type, params) 'case.fluid.initial_condition.sample_index', sample_idx, -1) if (sample_idx .ne. -1) then - write (log_buf, '(A,I5.5)') "Sample index: ", sample_idx + write (log_buf, '(A,I5)') "Sample index: ", sample_idx call neko_log%message(log_buf) end if @@ -197,25 +199,29 @@ subroutine set_flow_ic_int(u, v, w, p, coef, gs, type, params) 'case.fluid.initial_condition.interpolate', interpolate, & .false.) - if (interpolate) then + ! Get the tolerance for potential interpolationm defaults to + ! the same value as for interpolation in chkp_t + call json_get_or_default(params, & + 'case.fluid.initial_condition.tolerance', tol, 1d-6) + + ! Get the index of the file that contains the mesh + call json_get_or_default(params, & + 'case.fluid.initial_condition.sample_mesh_index', & + sample_mesh_idx, 0) - call json_get_or_default(params, & - 'case.fluid.initial_condition.tolerance', tol, 1d-6) - write (log_buf, '(A,F10.6)') "Tolerance : ", tol + if (interpolate) then + call neko_log%message( "Interpolation : yes") + write (log_buf, '(A,E15.7)') "Tolerance : ", tol + call neko_log%message(log_buf) + write (log_buf, '(A,I5)') "Mesh sample index: ", & + sample_mesh_idx call neko_log%message(log_buf) + end if - ! Get the index of the file that contains the mesh - call json_get_or_default(params, & - 'case.fluid.initial_condition.sample_mesh_index', & - sample_mesh_idx, 0) + call set_flow_ic_fld(u, v, w, p, read_str, sample_idx, interpolate, & + tolerance=tol, sample_mesh_idx=sample_mesh_idx) - call set_flow_ic_fld(u, v, w, p, read_str, sample_idx, & - interpolate, tol, sample_mesh_idx) - else - call set_flow_ic_fld(u, v, w, p, read_str, sample_idx, & - interpolate) - end if - end if + end if ! if suffix .eq. chkp else call neko_error('Invalid initial condition') @@ -457,9 +463,8 @@ subroutine set_flow_ic_fld(u, v, w, p, file_name, sample_idx, & ! two different meshes have the same dimension and same # of elements ! but this should be enough to cover the most obvious cases. ! - if ( ((fld_data%gdim .ne. u%msh%gdim) .or. & - (fld_data%glb_nelv .ne. u%msh%glb_nelv)) .and. & - (.not. interpolate)) then + if ( fld_data%glb_nelv .ne. u%msh%glb_nelv .and. & + .not. interpolate) then call neko_error("The fld file must match the current mesh! & &Use 'interpolate': 'true' to enable interpolation.") else if (interpolate) then @@ -472,7 +477,11 @@ subroutine set_flow_ic_fld(u, v, w, p, file_name, sample_idx, & ! Mesh interpolation if specified if (interpolate) then - global_interp = fld_data%generate_interpolator(u%dof, u%msh, tolerance) + if (present(tolerance)) then + global_interp = fld_data%generate_interpolator(u%dof, u%msh, tolerance) + else + global_interp = fld_data%generate_interpolator(u%dof, u%msh, 1d-6) + end if ! Evaluate velocities and pressure call global_interp%evaluate(u%x, fld_data%u%x) diff --git a/src/io/fld_file_data.f90 b/src/io/fld_file_data.f90 index 2c4f5c0e26b..feb4510636a 100644 --- a/src/io/fld_file_data.f90 +++ b/src/io/fld_file_data.f90 @@ -190,7 +190,7 @@ function fld_file_data_generate_interpolator(this, to_dof, & class(fld_file_data_t), intent(in) :: this type(dofmap_t), intent(in), target :: to_dof type(mesh_t), intent(in), target :: to_msh - real(kind=rp), intent(in), optional :: tolerance + real(kind=rp), intent(in) :: tolerance type(global_interpolation_t) :: global_interp @@ -202,7 +202,6 @@ function fld_file_data_generate_interpolator(this, to_dof, & z_coords(:,:,:,:) real(kind=rp) :: center_x, center_y, center_z integer :: e, i - real(kind=rp) :: tol ! --- type(space_t), pointer :: to_Xh @@ -214,10 +213,6 @@ function fld_file_data_generate_interpolator(this, to_dof, & .not. allocated(this%z%x)) call neko_error("Unable to retrieve & &mesh information from fld data.") - ! Same tolerance as for chkp - tol = 1d-6 - if (present(tolerance)) tol = tolerance - ! Create a space based on the fld data call fld_Xh%init(GLL, this%lx, this%ly, this%lz) @@ -253,17 +248,17 @@ function fld_file_data_generate_interpolator(this, to_dof, & center_z = center_z / to_Xh%lxyz do i = 1, to_Xh%lxyz x_coords(i, 1, 1, e) = to_dof%x(i, 1, 1, e) - & - tol * (to_dof%x(i, 1, 1, e) - center_x) + tolerance * (to_dof%x(i, 1, 1, e) - center_x) y_coords(i, 1, 1, e) = to_dof%y(i, 1, 1, e) - & - tol*(to_dof%y(i, 1, 1, e)-center_y) + tolerance*(to_dof%y(i, 1, 1, e)-center_y) z_coords(i, 1, 1, e) = to_dof%z(i, 1, 1, e) - & - tol*(to_dof%z(i, 1, 1, e)-center_z) + tolerance*(to_dof%z(i, 1, 1, e)-center_z) end do end do ! The initialization is done based on the variables created from ! fld data - call global_interp%init(fld_dof, tol = tol, Xh = fld_Xh, & + call global_interp%init(fld_dof, tol = tolerance, Xh = fld_Xh, & msh = fld_empty_mesh) ! Note that to_dof%size() should be equal to From a1f606db83cbd1667a657493bb431ea1ab83ee5a Mon Sep 17 00:00:00 2001 From: Victor Baconnet Date: Mon, 22 Jul 2024 12:59:42 +0200 Subject: [PATCH 18/67] reformat scalar --- src/scalar/scalar_ic.f90 | 65 +++++++++++++++++++++++----------------- 1 file changed, 37 insertions(+), 28 deletions(-) diff --git a/src/scalar/scalar_ic.f90 b/src/scalar/scalar_ic.f90 index 0ab77929763..7b57e91adc6 100644 --- a/src/scalar/scalar_ic.f90 +++ b/src/scalar/scalar_ic.f90 @@ -127,19 +127,21 @@ subroutine set_scalar_ic_int(s, coef, gs, type, params) ! Look for parameters for interpolation call params%get("case.scalar.initial_condition.previous_mesh", & prev_mesh, found_previous_mesh) - call neko_log%message("Previous mesh: " // trim(prev_mesh)) + ! Get tolerance for potential interpolation + call json_get_or_default(params, & + 'case.scalar.initial_condition.tolerance', tol, 1d-6) if (found_previous_mesh) then - call json_get_or_default(params, & - 'case.scalar.initial_condition.tolerance', tol, 1d-6) - write (log_buf, '(A,F10.6)') "Tolerance : ", tol + call neko_log%message( "Previous mesh: " // trim(prev_mesh)) + write (log_buf, '(A,E15.7)') "Tolerance : ", tol call neko_log%message(log_buf) + end if - call set_scalar_ic_chkp(s, read_str, prev_mesh, tol) + if (found_previous_mesh) then + call set_flow_ic_chkp(s, read_str, & + previous_mesh_fname = prev_mesh, tol = tol) else - ! In this case no mesh interpolation but potential for interpolation - ! between different polynomial orders - call set_scalar_ic_chkp(s, read_str) + call set_flow_ic_chkp(s, read_str) end if else !if it's not a chkp we assume it's a fld file @@ -149,7 +151,7 @@ subroutine set_scalar_ic_int(s, coef, gs, type, params) 'case.scalar.initial_condition.sample_index', sample_idx, -1) if (sample_idx .ne. -1) then - write (log_buf, '(A,I5.5)') "Sample index: ", sample_idx + write (log_buf, '(A,I5)') "Sample index: ", sample_idx call neko_log%message(log_buf) end if @@ -175,25 +177,29 @@ subroutine set_scalar_ic_int(s, coef, gs, type, params) 'case.scalar.initial_condition.interpolate', interpolate, & .false.) - if (interpolate) then + ! Get the tolerance for potential interpolationm defaults to + ! the same value as for interpolation in chkp_t + call json_get_or_default(params, & + 'case.scalar.initial_condition.tolerance', tol, 1d-6) + + ! Get the index of the file that contains the mesh + call json_get_or_default(params, & + 'case.scalar.initial_condition.sample_mesh_index', & + sample_mesh_idx, 0) - call json_get_or_default(params, & - 'case.scalar.initial_condition.tolerance', tol, 1d-6) - write (log_buf, '(A,F10.6)') "Tolerance : ", tol + if (interpolate) then + call neko_log%message( "Interpolation : yes") + write (log_buf, '(A,E15.7)') "Tolerance : ", tol + call neko_log%message(log_buf) + write (log_buf, '(A,I5)') "Mesh sample index: ", & + sample_mesh_idx call neko_log%message(log_buf) + end if - ! Get the index of the file that contains the mesh - call json_get_or_default(params, & - 'case.scalar.initial_condition.sample_mesh_index', & - sample_mesh_idx, 0) + call set_scalar_ic_fld(s, read_str, sample_idx, interpolate, & + tolerance=tol, sample_mesh_idx=sample_mesh_idx) - call set_scalar_ic_fld(s, read_str, sample_idx, & - interpolate, tol, sample_mesh_idx) - else - call set_scalar_ic_fld(s, read_str, sample_idx, & - interpolate) - end if - end if + end if ! if suffix .eq. chkp else call neko_error('Invalid initial condition') @@ -362,9 +368,8 @@ subroutine set_scalar_ic_fld(s, file_name, sample_idx, & ! two different meshes have the same dimension and same # of elements ! but this should be enough to cover the most obvious cases. ! - if ( ((fld_data%gdim .ne. s%msh%gdim) .or. & - (fld_data%glb_nelv .ne. s%msh%glb_nelv)) .and. & - (.not. interpolate)) then + if ( fld_data%glb_nelv .ne. u%msh%glb_nelv .and. & + .not. interpolate) then call neko_error("The fld file must match the current mesh! & &Use 'interpolate': 'true' to enable interpolation.") else if (interpolate) then @@ -377,7 +382,11 @@ subroutine set_scalar_ic_fld(s, file_name, sample_idx, & ! Mesh interpolation if specified if (interpolate) then - global_interp = fld_data%generate_interpolator(s%dof, s%msh, tolerance) + if (present(tolerance)) then + global_interp = fld_data%generate_interpolator(u%dof, u%msh, tolerance) + else + global_interp = fld_data%generate_interpolator(u%dof, u%msh, 1d-6) + end if ! Evaluate scalar call global_interp%evaluate(s%x, fld_data%t%x) From 4387045c41d6a469915c2e86feeaa8bb81bfb15e Mon Sep 17 00:00:00 2001 From: Victor Baconnet Date: Mon, 22 Jul 2024 13:19:16 +0200 Subject: [PATCH 19/67] fix scalar --- src/scalar/scalar_ic.f90 | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/scalar/scalar_ic.f90 b/src/scalar/scalar_ic.f90 index 7b57e91adc6..a0b014e137e 100644 --- a/src/scalar/scalar_ic.f90 +++ b/src/scalar/scalar_ic.f90 @@ -138,10 +138,10 @@ subroutine set_scalar_ic_int(s, coef, gs, type, params) end if if (found_previous_mesh) then - call set_flow_ic_chkp(s, read_str, & + call set_scalar_ic_chkp(s, read_str, & previous_mesh_fname = prev_mesh, tol = tol) else - call set_flow_ic_chkp(s, read_str) + call set_scalar_ic_chkp(s, read_str) end if else !if it's not a chkp we assume it's a fld file @@ -368,7 +368,7 @@ subroutine set_scalar_ic_fld(s, file_name, sample_idx, & ! two different meshes have the same dimension and same # of elements ! but this should be enough to cover the most obvious cases. ! - if ( fld_data%glb_nelv .ne. u%msh%glb_nelv .and. & + if ( fld_data%glb_nelv .ne. s%msh%glb_nelv .and. & .not. interpolate) then call neko_error("The fld file must match the current mesh! & &Use 'interpolate': 'true' to enable interpolation.") @@ -383,9 +383,9 @@ subroutine set_scalar_ic_fld(s, file_name, sample_idx, & if (interpolate) then if (present(tolerance)) then - global_interp = fld_data%generate_interpolator(u%dof, u%msh, tolerance) + global_interp = fld_data%generate_interpolator(s%dof, s%msh, tolerance) else - global_interp = fld_data%generate_interpolator(u%dof, u%msh, 1d-6) + global_interp = fld_data%generate_interpolator(s%dof, s%msh, 1d-6) end if ! Evaluate scalar @@ -416,10 +416,10 @@ end subroutine set_scalar_ic_fld !! @param previous_mesh If specified, the name of the previouos mesh from !! which to interpolate. !! @param tol If specified, tolerance to use for the mesh interpolation. - subroutine set_scalar_ic_chkp(s, file_name, previous_mesh, tol) + subroutine set_scalar_ic_chkp(s, file_name, previous_mesh_fname, tol) type(field_t), intent(inout) :: s character(len=*), intent(in) :: file_name - character(len=*), intent(in), optional :: previous_mesh + character(len=*), intent(in), optional :: previous_mesh_fname real(kind=rp), intent(in), optional :: tol type(field_t), pointer :: u,v,w,p @@ -436,8 +436,8 @@ subroutine set_scalar_ic_chkp(s, file_name, previous_mesh, tol) call chkp_data%add_scalar(s) ! Mesh interpolation if specified - if (present(previous_mesh)) then - meshf = file_t(trim(previous_mesh)) + if (present(previous_mesh_fname)) then + meshf = file_t(trim(previous_mesh_fname)) call meshf%read(chkp_data%previous_mesh) end if From cb00e6f9e4c2dc2424462b2f584c5df914fd1b98 Mon Sep 17 00:00:00 2001 From: Victor Baconnet Date: Mon, 22 Jul 2024 14:19:31 +0200 Subject: [PATCH 20/67] reformat --- src/fluid/flow_ic.f90 | 2 +- src/io/fld_file_data.f90 | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/fluid/flow_ic.f90 b/src/fluid/flow_ic.f90 index c4a744800b2..5848686383c 100644 --- a/src/fluid/flow_ic.f90 +++ b/src/fluid/flow_ic.f90 @@ -480,7 +480,7 @@ subroutine set_flow_ic_fld(u, v, w, p, file_name, sample_idx, & if (present(tolerance)) then global_interp = fld_data%generate_interpolator(u%dof, u%msh, tolerance) else - global_interp = fld_data%generate_interpolator(u%dof, u%msh, 1d-6) + call neko_error("No tolerance provided for interpolation!") end if ! Evaluate velocities and pressure diff --git a/src/io/fld_file_data.f90 b/src/io/fld_file_data.f90 index feb4510636a..dc1d2fb1842 100644 --- a/src/io/fld_file_data.f90 +++ b/src/io/fld_file_data.f90 @@ -250,9 +250,9 @@ function fld_file_data_generate_interpolator(this, to_dof, & x_coords(i, 1, 1, e) = to_dof%x(i, 1, 1, e) - & tolerance * (to_dof%x(i, 1, 1, e) - center_x) y_coords(i, 1, 1, e) = to_dof%y(i, 1, 1, e) - & - tolerance*(to_dof%y(i, 1, 1, e)-center_y) + tolerance * (to_dof%y(i, 1, 1, e) - center_y) z_coords(i, 1, 1, e) = to_dof%z(i, 1, 1, e) - & - tolerance*(to_dof%z(i, 1, 1, e)-center_z) + tolerance * (to_dof%z(i, 1, 1, e) - center_z) end do end do From 7b825553ec260706d7af20b78a4c648e970a8b37 Mon Sep 17 00:00:00 2001 From: Victor Baconnet Date: Mon, 22 Jul 2024 15:03:13 +0200 Subject: [PATCH 21/67] change e to d --- src/common/global_interpolation.F90 | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/common/global_interpolation.F90 b/src/common/global_interpolation.F90 index 22889bb36f0..ba8d8bd34bb 100644 --- a/src/common/global_interpolation.F90 +++ b/src/common/global_interpolation.F90 @@ -85,7 +85,7 @@ module global_interpolation !> Error code for each point, needed for gslib integer, allocatable :: error_code(:) !> Tolerance for distance squared between original and interpolated point - real(kind=rp) :: tol = 5e-13 + real(kind=rp) :: tol = 5d-13 contains !> Initialize the global interpolation object on a dofmap. procedure, pass(this) :: init => global_interpolation_init @@ -277,7 +277,6 @@ subroutine global_interpolation_find_common(this) this%rst, this%mesh%gdim, & this%n_points, this%dof%z) - do i=1,this%n_points ! From 13cdc59ce0156ceb3dffb8ca8d0658d2eeeab58d Mon Sep 17 00:00:00 2001 From: Victor Baconnet Date: Mon, 22 Jul 2024 15:35:22 +0200 Subject: [PATCH 22/67] linter --- src/common/global_interpolation.F90 | 76 ++++++++++++++------------ src/fluid/flow_ic.f90 | 43 ++++++++------- src/io/fld_file.f90 | 85 +++++++++++++++-------------- 3 files changed, 106 insertions(+), 98 deletions(-) diff --git a/src/common/global_interpolation.F90 b/src/common/global_interpolation.F90 index ba8d8bd34bb..8efff2d909c 100644 --- a/src/common/global_interpolation.F90 +++ b/src/common/global_interpolation.F90 @@ -98,7 +98,8 @@ module global_interpolation !> Finds the process owner, global element number, !! and local rst coordinates for each point. !! Sets up correct values to be able to evalute the points - procedure, pass(this) :: find_points_coords => global_interpolation_find_coords + procedure, pass(this) :: find_points_coords => & + global_interpolation_find_coords procedure, pass(this) :: find_points_xyz => global_interpolation_find_xyz generic :: find_points => find_points_xyz, find_points_coords !> Evaluate the value of the field in each point. @@ -135,7 +136,7 @@ subroutine global_interpolation_init(this, dof, tol, Xh, msh) this%mesh => dof%msh end if - if(present(tol)) this%tol = tol + if (present(tol)) this%tol = tol #ifdef HAVE_GSLIB @@ -189,11 +190,11 @@ subroutine global_interpolation_free_points(this) this%n_points = 0 this%all_points_local = .false. - if (allocated(this%xyz)) deallocate(this%xyz) - if (allocated(this%rst)) deallocate(this%rst) + if (allocated(this%xyz)) deallocate(this%xyz) + if (allocated(this%rst)) deallocate(this%rst) if (allocated(this%proc_owner)) deallocate(this%proc_owner) - if (allocated(this%el_owner)) deallocate(this%el_owner) - if (allocated(this%dist2)) deallocate(this%dist2) + if (allocated(this%el_owner)) deallocate(this%el_owner) + if (allocated(this%dist2)) deallocate(this%dist2) if (allocated(this%error_code)) deallocate(this%error_code) if (c_associated(this%el_owner_d)) then @@ -228,7 +229,7 @@ subroutine global_interpolation_find_common(this) this%xyz(2,1), this%mesh%gdim, & this%xyz(3,1), this%mesh%gdim, this%n_points) - do i=1,this%n_points + do i = 1 , this%n_points ! ! Check validity of points @@ -251,7 +252,8 @@ subroutine global_interpolation_find_common(this) ' Interpolation on these points will return 0.0. dist2: ', & this%dist2(i),& 'el_owner, rst coords, pe: ',& - this%el_owner(i), this%rst(1,i), this%rst(2,i), this%rst(3,i), pe_rank + this%el_owner(i), this%rst(1,i), this%rst(2,i), & + this%rst(3,i), pe_rank end do @@ -277,7 +279,7 @@ subroutine global_interpolation_find_common(this) this%rst, this%mesh%gdim, & this%n_points, this%dof%z) - do i=1,this%n_points + do i = 1 , this%n_points ! ! Check validity of points @@ -291,11 +293,11 @@ subroutine global_interpolation_find_common(this) if ( zdiff .gt. this%tol) isdiff = .true. if (isdiff) then - write(*,*) 'Points with coords: ',& - this%xyz(1,i),this%xyz(2,i),this%xyz(3,i), & - 'Differ from interpolated coords: ',& - x_check(i), y_check(i), z_check(i),& - 'Distance squared: ',& + write(*,*) 'Points with coords: ', & + this%xyz(1, i), this%xyz(2, i), this%xyz(3, i), & + 'Differ from interpolated coords: ', & + x_check(i), y_check(i), z_check(i), & + 'Distance squared: ', & xdiff, ydiff, zdiff end if @@ -344,9 +346,9 @@ subroutine global_interpolation_find_coords(this, x, y, z, n_points) call global_interpolation_init_point_arrays(this) do i = 1, n_points - this%xyz(1,i) = x(i,1,1,1) - this%xyz(2,i) = y(i,1,1,1) - this%xyz(3,i) = z(i,1,1,1) + this%xyz(1, i) = x(i,1,1,1) + this%xyz(2, i) = y(i,1,1,1) + this%xyz(3, i) = z(i,1,1,1) end do call global_interpolation_find_common(this) @@ -356,15 +358,15 @@ end subroutine global_interpolation_find_coords subroutine global_interpolation_init_point_arrays(this) class(global_interpolation_t) :: this - allocate(this%xyz(3,this%n_points)) - allocate(this%rst(3,this%n_points)) + allocate(this%xyz(3, this%n_points)) + allocate(this%rst(3, this%n_points)) allocate(this%proc_owner(this%n_points)) allocate(this%el_owner(this%n_points)) allocate(this%dist2(this%n_points)) allocate(this%error_code(this%n_points)) if (NEKO_BCKND_DEVICE .eq. 1) & - call device_map(this%el_owner, this%el_owner_d,this%n_points) + call device_map(this%el_owner, this%el_owner_d, this%n_points) end subroutine global_interpolation_init_point_arrays @@ -382,7 +384,7 @@ subroutine global_interpolation_find_xyz(this, xyz, n_points) class(global_interpolation_t), intent(inout) :: this integer, intent(in) :: n_points !!Perhaps this should be kind dp - real(kind=rp), intent(inout) :: xyz(3,n_points) + real(kind=rp), intent(inout) :: xyz(3, n_points) call this%free_points() @@ -392,7 +394,7 @@ subroutine global_interpolation_find_xyz(this, xyz, n_points) call global_interpolation_init_point_arrays(this) !> make deep copy incase xyz goes out of scope or deallocated - call copy(this%xyz,xyz,3*n_points) + call copy(this%xyz, xyz, 3 * n_points) call global_interpolation_find_common(this) @@ -422,7 +424,7 @@ subroutine global_interpolation_find_and_redist(this, xyz, n_points) call global_interpolation_init_point_arrays(this) !> make deep copy incase xyz goes out of scope or deallocated - call copy(this%xyz,xyz,3*n_points) + call copy(this%xyz, xyz, 3 * n_points) call global_interpolation_find_common(this) !> Sets new points and redistributes them @@ -431,17 +433,17 @@ subroutine global_interpolation_find_and_redist(this, xyz, n_points) do i = 1, this%n_points if (this%proc_owner(i) .ne. pe_rank) then - write(*,*) 'Redistribution failed on rank: ', pe_rank,& + write(*,*) 'Redistribution failed on rank: ', pe_rank, & 'for point with coord: ', & - this%xyz(1,i),this%xyz(2,i),this%xyz(3,i) + this%xyz(1, i), this%xyz(2, i), this%xyz(3, i) exit end if end do n_points = this%n_points deallocate(xyz) - allocate(xyz(3,n_points)) - call copy(xyz,this%xyz,3*n_points) + allocate(xyz(3, n_points)) + call copy(xyz, this%xyz, 3*n_points) call this%local_interp%init(this%Xh, this%rst(1,:),& this%rst(2,:), this%rst(3,:), n_points) @@ -466,28 +468,30 @@ subroutine global_interpolation_redist(this) n_points_per_pe = 0 n_points_from_pe = 0 !> Calculate which processes this proc has points on - do i = 1,this%n_points - n_points_per_pe(this%proc_owner(i)) = n_points_per_pe(this%proc_owner(i)) + 1 + do i = 1, this%n_points + n_points_per_pe(this%proc_owner(i)) = & + n_points_per_pe(this%proc_owner(i)) + 1 end do !> Sum number of points on all pes to compute n_new_points !! Store how many points to receive from each pe - do i = 0,(pe_size-1) - call MPI_Reduce(n_points_per_pe(i),n_new_points,1,MPI_INTEGER,MPI_SUM, i, NEKO_COMM, ierr) + do i = 0, (pe_size - 1) + call MPI_Reduce(n_points_per_pe(i), n_new_points, 1, MPI_INTEGER, & + MPI_SUM, i, NEKO_COMM, ierr) call MPI_Gather(n_points_per_pe(i), 1, MPI_INTEGER,& n_points_from_pe, 1, MPI_INTEGER, i, NEKO_COMM, ierr) end do allocate(n_point_offset_from_pe(0:(pe_size-1))) n_point_offset_from_pe(0) = 0 - do i = 1,(pe_size-1) + do i = 1, (pe_size - 1) n_point_offset_from_pe(i) = n_points_from_pe(i-1)& + n_point_offset_from_pe(i-1) end do - allocate(new_xyz(3,n_new_points)) + allocate(new_xyz(3, n_new_points)) max_n_points_to_send = maxval(n_points_per_pe) - allocate(xyz_send_to_pe(3,max_n_points_to_send)) - do i = 0, (pe_size-1) + allocate(xyz_send_to_pe(3, max_n_points_to_send)) + do i = 0, (pe_size - 1) !> This could be avoided by adding all indices to a list k = 0 do j = 1, this%n_points @@ -513,7 +517,7 @@ subroutine global_interpolation_redist(this) this%n_points = n_new_points call global_interpolation_init_point_arrays(this) - call copy(this%xyz,new_xyz,3*n_new_points) + call copy(this%xyz, new_xyz, 3 * n_new_points) deallocate(n_point_offset_from_pe) deallocate(n_points_from_pe) diff --git a/src/fluid/flow_ic.f90 b/src/fluid/flow_ic.f90 index 5848686383c..eb5255d7e25 100644 --- a/src/fluid/flow_ic.f90 +++ b/src/fluid/flow_ic.f90 @@ -93,7 +93,8 @@ subroutine set_flow_ic_int(u, v, w, p, coef, gs, type, params) call json_get(params, 'case.fluid.initial_condition.value', uinf) call set_flow_ic_uniform(u, v, w, uinf) - write (log_buf, '(A,"[",2(F10.6,","),F10.6,"]")') "Value: ", uinf(1), uinf(2), uinf(3) + write (log_buf, '(A,"[",2(F10.6,","),F10.6,"]")') "Value: ", uinf(1), & + uinf(2), uinf(3) call neko_log%message(log_buf) ! @@ -108,8 +109,9 @@ subroutine set_flow_ic_int(u, v, w, p, coef, gs, type, params) write (log_buf, '(A,F10.6)') "delta : ", delta call neko_log%message(log_buf) - call neko_log%message( "Approximation: " // trim(read_str)) - write (log_buf, '(A,"[",2(F10.6,","),F10.6,"]")') "Value: ", uinf(1), uinf(2), uinf(3) + call neko_log%message("Approximation: " // trim(read_str)) + write (log_buf, '(A,"[",2(F10.6,","),F10.6,"]")') "Value: ", uinf(1), & + uinf(2), uinf(3) call neko_log%message(log_buf) call set_flow_ic_blasius(u, v, w, delta, uinf, read_str) @@ -127,7 +129,7 @@ subroutine set_flow_ic_int(u, v, w, p, coef, gs, type, params) write (log_buf, '(A,F10.6)') "Base value: ", uinf call neko_log%message(log_buf) - call neko_log%message( "Zone name : " // trim(read_str)) + call neko_log%message("Zone name : " // trim(read_str)) write (log_buf, '(A,"[",2(F10.6,","),F10.6,"]")') "Value: ", & zone_value(1), zone_value(2), zone_value(3) call neko_log%message(log_buf) @@ -154,7 +156,7 @@ subroutine set_flow_ic_int(u, v, w, p, coef, gs, type, params) 'case.fluid.initial_condition.tolerance', tol, 1d-6) if (found_previous_mesh) then - call neko_log%message( "Previous mesh: " // trim(prev_mesh)) + call neko_log%message("Previous mesh: " // trim(prev_mesh)) write (log_buf, '(A,E15.7)') "Tolerance : ", tol call neko_log%message(log_buf) end if @@ -186,7 +188,7 @@ subroutine set_flow_ic_int(u, v, w, p, coef, gs, type, params) fpos = scan(suffix, 'f') if (fpos .eq. 1) then if (sample_idx .ne. -1) & - call neko_warning("Overwriting sample index!") + call neko_warning("Overwriting sample index") read (suffix(2:), "(I5.5)") sample_idx end if @@ -210,16 +212,16 @@ subroutine set_flow_ic_int(u, v, w, p, coef, gs, type, params) sample_mesh_idx, 0) if (interpolate) then - call neko_log%message( "Interpolation : yes") + call neko_log%message("Interpolation : yes") write (log_buf, '(A,E15.7)') "Tolerance : ", tol call neko_log%message(log_buf) - write (log_buf, '(A,I5)') "Mesh sample index: ", & + write (log_buf, '(A,I5)') "Mesh sample index: ", & sample_mesh_idx call neko_log%message(log_buf) end if call set_flow_ic_fld(u, v, w, p, read_str, sample_idx, interpolate, & - tolerance=tol, sample_mesh_idx=sample_mesh_idx) + tolerance = tol, sample_mesh_idx = sample_mesh_idx) end if ! if suffix .eq. chkp @@ -261,11 +263,11 @@ subroutine set_flow_ic_common(u, v, w, p, coef, gs) if (NEKO_BCKND_DEVICE .eq. 1) then call device_memcpy(u%x, u%x_d, n, & - HOST_TO_DEVICE, sync=.false.) + HOST_TO_DEVICE, sync = .false.) call device_memcpy(v%x, v%x_d, n, & - HOST_TO_DEVICE, sync=.false.) + HOST_TO_DEVICE, sync = .false.) call device_memcpy(w%x, w%x_d, n, & - HOST_TO_DEVICE, sync=.false.) + HOST_TO_DEVICE, sync = .false.) end if ! Ensure continuity across elements for initial conditions @@ -316,16 +318,16 @@ subroutine set_flow_ic_blasius(u, v, w, delta, uinf, type) procedure(blasius_profile), pointer :: bla => null() integer :: i - select case(trim(type)) - case('linear') + select case (trim(type)) + case ('linear') bla => blasius_linear - case('quadratic') + case ('quadratic') bla => blasius_quadratic - case('cubic') + case ('cubic') bla => blasius_cubic - case('quartic') + case ('quartic') bla => blasius_quartic - case('sin') + case ('sin') bla => blasius_sin case default call neko_error('Invalid Blasius approximation') @@ -478,9 +480,10 @@ subroutine set_flow_ic_fld(u, v, w, p, file_name, sample_idx, & if (interpolate) then if (present(tolerance)) then - global_interp = fld_data%generate_interpolator(u%dof, u%msh, tolerance) + global_interp = fld_data%generate_interpolator(u%dof, u%msh, & + tolerance) else - call neko_error("No tolerance provided for interpolation!") + call neko_error("No tolerance provided for interpolation.") end if ! Evaluate velocities and pressure diff --git a/src/io/fld_file.f90 b/src/io/fld_file.f90 index 7d886b65cc1..84673b90fe6 100644 --- a/src/io/fld_file.f90 +++ b/src/io/fld_file.f90 @@ -102,7 +102,7 @@ subroutine fld_file_write(this, data, t) integer :: FLD_DATA_SIZE, n_scalar_fields if (present(t)) then - time = real(t,dp) + time = real(t, dp) else time = 0d0 end if @@ -115,7 +115,7 @@ subroutine fld_file_write(this, data, t) write_velocity = .false. write_temperature = .false. - select type(data) + select type (data) type is (fld_file_data_t) if (data%x%n .gt. 0) x%ptr => data%x%x if (data%y%n .gt. 0) y%ptr => data%y%x @@ -187,7 +187,7 @@ subroutine fld_file_write(this, data, t) tem%ptr => data%items(5)%ptr%x(:,1,1,1) n_scalar_fields = data%size() - 5 allocate(scalar_fields(n_scalar_fields)) - do i = 1,n_scalar_fields + do i = 1, n_scalar_fields scalar_fields(i)%ptr => data%items(i+5)%ptr%x(:,1,1,1) end do write_pressure = .true. @@ -296,10 +296,10 @@ subroutine fld_file_write(this, data, t) end if !> @todo fix support for single precision output? - write(hdr, 1) FLD_DATA_SIZE, lx, ly, lz,glb_nelv,glb_nelv,& - time, this%counter, 1, 1, (rdcode(i),i=1,10) -1 format('#std',1x,i1,1x,i2,1x,i2,1x,i2,1x,i10,1x,i10,1x,e20.13,& - 1x,i9,1x,i6,1x,i6,1x,10a) + write(hdr, 1) FLD_DATA_SIZE, lx, ly, lz, glb_nelv, glb_nelv, & + time, this%counter, 1, 1, (rdcode(i), i = 1, 10) +1 format('#std', 1x, i1, 1x, i2, 1x, i2, 1x, i2, 1x, i10, 1x, i10, 1x, & + e20.13, 1x, i9, 1x, i6, 1x, i6, 1x, 10a) ! Change to NEKTON's fld file format suffix_pos = filename_suffix_pos(this%fname) @@ -372,15 +372,15 @@ subroutine fld_file_write(this, data, t) do i = 1, n_scalar_fields !Without this redundant if statement, Cray optimizes this loop to Oblivion if (i .eq. 2) then - mpi_offset = int(temp_offset,i8) + int(1_i8*glb_nelv, i8) * & + mpi_offset = int(temp_offset, i8) + int(1_i8*glb_nelv, i8) * & (int(lxyz, i8) * & int(FLD_DATA_SIZE, i8)) end if - byte_offset = int(mpi_offset,i8) + int(offset_el, i8) * & + byte_offset = int(mpi_offset, i8) + int(offset_el, i8) * & (int((lxyz), i8) * & int(FLD_DATA_SIZE, i8)) call fld_file_write_field(this, fh, byte_offset, scalar_fields(i)%ptr, n) - mpi_offset = int(mpi_offset,i8) + int(glb_nelv, i8) * & + mpi_offset = int(mpi_offset, i8) + int(glb_nelv, i8) * & (int(lxyz, i8) * & int(FLD_DATA_SIZE, i8)) end do @@ -389,13 +389,13 @@ subroutine fld_file_write(this, data, t) !> Include metadata with bounding boxes (Just copying from nek5000) if (write_mesh) then !The offset is: mpioff + element_off*2(min max value)*4(single precision)*gdim(dimensions) - byte_offset = int(mpi_offset,i8) + & + byte_offset = int(mpi_offset, i8) + & int(offset_el, i8) * & int(2, i8) * & int(MPI_REAL_SIZE, i8) * & int(gdim, i8) call fld_file_write_metadata_vector(this, fh, byte_offset, x%ptr, y%ptr, z%ptr, gdim, lxyz, nelv) - mpi_offset = int(mpi_offset,i8) + & + mpi_offset = int(mpi_offset, i8) + & int(glb_nelv, i8) * & int(2, i8) * & int(MPI_REAL_SIZE, i8) * & @@ -403,13 +403,13 @@ subroutine fld_file_write(this, data, t) end if if (write_velocity) then - byte_offset = int(mpi_offset,i8) + & + byte_offset = int(mpi_offset, i8) + & int(offset_el, i8) * & int(2, i8) * & int(MPI_REAL_SIZE, i8) * & int(gdim, i8) call fld_file_write_metadata_vector(this, fh, byte_offset, u%ptr, v%ptr, w%ptr, gdim, lxyz, nelv) - mpi_offset = int(mpi_offset,i8) + & + mpi_offset = int(mpi_offset, i8) + & int(glb_nelv, i8) * & int(2, i8) * & int(MPI_REAL_SIZE, i8) * & @@ -418,12 +418,12 @@ subroutine fld_file_write(this, data, t) end if if (write_pressure) then - byte_offset = int(mpi_offset,i8) + & + byte_offset = int(mpi_offset, i8) + & int(offset_el, i8) * & int(2, i8) * & int(MPI_REAL_SIZE, i8) call fld_file_write_metadata_scalar(this, fh, byte_offset, p%ptr, lxyz, nelv) - mpi_offset = int(mpi_offset,i8) + & + mpi_offset = int(mpi_offset, i8) + & int(glb_nelv, i8) * & int(2, i8) * & int(MPI_REAL_SIZE, i8) @@ -431,12 +431,12 @@ subroutine fld_file_write(this, data, t) end if if (write_temperature) then - byte_offset = int(mpi_offset,i8) + & + byte_offset = int(mpi_offset, i8) + & int(offset_el, i8) * & int(2, i8) * & int(MPI_REAL_SIZE, i8) call fld_file_write_metadata_scalar(this, fh, byte_offset, tem%ptr, lxyz, nelv) - mpi_offset = int(mpi_offset,i8) + & + mpi_offset = int(mpi_offset, i8) + & int(glb_nelv, i8) * & int(2, i8) * & int(MPI_REAL_SIZE, i8) @@ -450,18 +450,18 @@ subroutine fld_file_write(this, data, t) do i = 1, n_scalar_fields !Without this redundant if statement, Cray optimizes this loop to Oblivion if (i .eq. 2) then - mpi_offset = int(temp_offset,i8) + & + mpi_offset = int(temp_offset, i8) + & int(1_i8*glb_nelv, i8) * & int(2, i8) * & int(MPI_REAL_SIZE, i8) end if - byte_offset = int(mpi_offset,i8) + & + byte_offset = int(mpi_offset, i8) + & int(offset_el, i8) * & int(2, i8) * & int(MPI_REAL_SIZE, i8) call fld_file_write_metadata_scalar(this, fh, byte_offset, scalar_fields(i)%ptr, lxyz, nelv) - mpi_offset = int(mpi_offset,i8) + & + mpi_offset = int(mpi_offset, i8) + & int(glb_nelv, i8) * & int(2, i8) * & int(MPI_REAL_SIZE, i8) @@ -474,14 +474,15 @@ subroutine fld_file_write(this, data, t) ! Write metadata file if (pe_rank .eq. 0) then tslash_pos = filename_tslash_pos(this%fname) - write(start_field,"(I5,A8)") this%start_counter,'.nek5000' - open(unit=9, file=trim(this%fname(1:suffix_pos-1))//trim(adjustl(start_field)), & - status='replace') - write(9, fmt='(A,A,A)') 'filetemplate: ', & + write(start_field, "(I5,A8)") this%start_counter, '.nek5000' + open(unit = 9, file = trim(this%fname(1:suffix_pos-1)) // & + trim(adjustl(start_field)), status = 'replace') + write(9, fmt = '(A,A,A)') 'filetemplate: ', & this%fname(tslash_pos+1:suffix_pos-1),'%01d.f%05d' - write(9, fmt='(A,i5)') 'firsttimestep: ', this%start_counter - write(9, fmt='(A,i5)') 'numtimesteps: ', (this%counter + 1)-this%start_counter - write(9, fmt='(A)') 'type: binary' + write(9, fmt = '(A,i5)') 'firsttimestep: ', this%start_counter + write(9, fmt = '(A,i5)') 'numtimesteps: ', (this%counter + 1) - & + this%start_counter + write(9, fmt = '(A)') 'type: binary' close(9) end if @@ -557,7 +558,7 @@ subroutine fld_file_write_field(this, fh, byte_offset, p, n) if ( this%dp_precision) then do i = 1, n - tmp_dp(i) = real(p(i),dp) + tmp_dp(i) = real(p(i), dp) end do call MPI_File_write_at_all(fh, byte_offset, tmp_dp, n, & @@ -585,16 +586,16 @@ subroutine fld_file_write_vector_field(this, fh, byte_offset, x, y, z, n, gdim, i = 1 do el = 1, nelv do j = 1, lxyz - tmp_dp(i) = real(x(j,el),dp) + tmp_dp(i) = real(x(j,el), dp) i = i +1 end do do j = 1, lxyz - tmp_dp(i) = real(y(j,el),dp) + tmp_dp(i) = real(y(j,el), dp) i = i +1 end do if (gdim .eq. 3) then do j = 1, lxyz - tmp_dp(i) = real(z(j,el),dp) + tmp_dp(i) = real(z(j,el), dp) i = i +1 end do end if @@ -648,7 +649,7 @@ subroutine fld_file_read(this, data) real(kind=sp), parameter :: test_pattern = 6.54321 character :: rdcode(10),temp_str(4) - select type(data) + select type (data) type is (fld_file_data_t) call filename_chsuffix(this%fname, meta_fname,'nek5000') @@ -657,12 +658,12 @@ subroutine fld_file_read(this, data) path = "none" if (slsh_pos .ne. 0) path = this%fname(1:slsh_pos) - inquire(file=trim(meta_fname), exist=meta_file) + inquire(file = trim(meta_fname), exist = meta_file) if (meta_file .and. data%meta_nsamples .eq. 0) then if (pe_rank .eq. 0) then - open(unit=9, file=trim(meta_fname)) - read(9, fmt='(A)') string - read(string(14:),fmt='(A)') string + open(unit = 9, file = trim(meta_fname)) + read(9, fmt = '(A)') string + read(string(14:),fmt = '(A)') string ! Remove leading whitespaces ! from something like " field%01d.f%05d" to @@ -671,10 +672,10 @@ subroutine fld_file_read(this, data) string = trim(string(leading_space_pos + 1:)) data%fld_series_fname = string(:scan(trim(string), '%')-1) - data%fld_series_fname = trim(data%fld_series_fname)//'0' - read(9, fmt='(A)') string + data%fld_series_fname = trim(data%fld_series_fname) // '0' + read(9, fmt = '(A)') string read(string(scan(string,':')+1:),*) data%meta_start_counter - read(9, fmt='(A)') string + read(9, fmt = '(A)') string read(string(scan(string,':')+1:),*) data%meta_nsamples close(9) @@ -694,7 +695,7 @@ subroutine fld_file_read(this, data) if (meta_file) then write(id_str, '(a,i5.5)') 'f', this%counter - fname = trim(data%fld_series_fname)//'.'//id_str + fname = trim(data%fld_series_fname) // '.'//id_str if (this%counter .ge. data%meta_nsamples+data%meta_start_counter) then call neko_error('Trying to read more fld files than exist') end if @@ -705,7 +706,7 @@ subroutine fld_file_read(this, data) else suffix_pos = filename_suffix_pos(this%fname) write(id_str, '(a,i5.5)') 'f', this%counter - fname = trim(this%fname(1:suffix_pos-1))//'.'//id_str + fname = trim(this%fname(1:suffix_pos-1)) // '.'//id_str end if call MPI_File_open(NEKO_COMM, trim(fname), & From 083d6c926af84f82b9cd119d4ca40c309f78fb33 Mon Sep 17 00:00:00 2001 From: Victor Baconnet Date: Mon, 22 Jul 2024 15:51:59 +0200 Subject: [PATCH 23/67] linter --- src/case.f90 | 34 +++--- src/io/fld_file.f90 | 238 +++++++++++++++++++++------------------ src/io/fld_file_data.f90 | 63 ++++++----- src/scalar/scalar_ic.f90 | 18 +-- src/sem/dofmap.f90 | 44 ++++---- 5 files changed, 210 insertions(+), 187 deletions(-) diff --git a/src/case.f90 b/src/case.f90 index f3de8af286e..cd55e19007d 100644 --- a/src/case.f90 +++ b/src/case.f90 @@ -55,7 +55,7 @@ module case use comm use time_scheme_controller, only : time_scheme_controller_t use logger, only : neko_log, NEKO_LOG_QUIET, LOG_SIZE - use jobctrl, only : jobctrl_set_time_limit + use jobctrl, only : jobctrl_set_time_limit use user_intf, only : user_t use scalar_pnpn, only : scalar_pnpn_t use json_module, only : json_file, json_core, json_value @@ -83,7 +83,7 @@ module case type(user_t) :: usr class(fluid_scheme_t), allocatable :: fluid type(scalar_pnpn_t), allocatable :: scalar - type(material_properties_t):: material_properties + type(material_properties_t) :: material_properties end type case_t interface case_init @@ -106,13 +106,13 @@ subroutine case_init_from_file(C, case_file) NEKO_LOG_QUIET) if (pe_rank .eq. 0) then - call C%params%load_file(filename=trim(case_file)) + call C%params%load_file(filename = trim(case_file)) call C%params%print_to_string(json_buffer) integer_val = len(json_buffer) end if call MPI_Bcast(integer_val, 1, MPI_INTEGER, 0, NEKO_COMM, ierr) - if (pe_rank .ne. 0) allocate(character(len=integer_val)::json_buffer) + if (pe_rank .ne. 0) allocate(character(len = integer_val) :: json_buffer) call MPI_Bcast(json_buffer, integer_val, MPI_CHARACTER, 0, NEKO_COMM, ierr) call C%params%load_from_string(json_buffer) @@ -139,7 +139,7 @@ end subroutine case_init_from_json !> Initialize a case from its (loaded) params object subroutine case_init_common(C) type(case_t), target, intent(inout) :: C - character(len=:), allocatable :: output_directory + character(len = :), allocatable :: output_directory integer :: lx = 0 logical :: scalar = .false. type(file_t) :: msh_file, bdry_file, part_file @@ -147,9 +147,9 @@ subroutine case_init_common(C) logical :: found, logical_val integer :: integer_val real(kind=rp) :: real_val - character(len=:), allocatable :: string_val + character(len = :), allocatable :: string_val real(kind=rp) :: stats_start_time, stats_output_val - integer :: stats_sampling_interval + integer :: stats_sampling_interval integer :: output_dir_len integer :: precision @@ -218,8 +218,8 @@ subroutine case_init_common(C) call C%fluid%init(C%msh, lx, C%params, C%usr, C%material_properties) C%fluid%chkp%tlag => C%tlag C%fluid%chkp%dtlag => C%dtlag - select type(f => C%fluid) - type is(fluid_pnpn_t) + select type (f => C%fluid) + type is (fluid_pnpn_t) f%chkp%abx1 => f%abx1 f%chkp%abx2 => f%abx2 f%chkp%aby1 => f%aby1 @@ -307,8 +307,8 @@ subroutine case_init_common(C) end if ! Add initial conditions to BDF scheme (if present) - select type(f => C%fluid) - type is(fluid_pnpn_t) + select type (f => C%fluid) + type is (fluid_pnpn_t) call f%ulag%set(f%u) call f%vlag%set(f%v) call f%wlag%set(f%w) @@ -387,10 +387,10 @@ subroutine case_init_common(C) call C%s%init(C%end_time) if (scalar) then C%f_out = fluid_output_t(precision, C%fluid, C%scalar, & - path=trim(output_directory)) + path = trim(output_directory)) else C%f_out = fluid_output_t(precision, C%fluid, & - path=trim(output_directory)) + path = trim(output_directory)) end if call json_get_or_default(C%params, 'case.fluid.output_control',& @@ -418,7 +418,7 @@ subroutine case_init_common(C) if (logical_val) then call json_get_or_default(C%params, 'case.checkpoint_format', & string_val, "chkp") - C%f_chkp = chkp_output_t(C%fluid%chkp, path=output_directory, & + C%f_chkp = chkp_output_t(C%fluid%chkp, path = output_directory, & fmt=trim(string_val)) call json_get_or_default(C%params, 'case.checkpoint_control', & string_val, "simulationtime") @@ -455,7 +455,7 @@ subroutine case_init_common(C) call C%q%add(C%fluid%mean%p) C%f_mf = mean_flow_output_t(C%fluid%mean, stats_start_time, & - path=output_directory) + path = output_directory) call json_get(C%params, 'case.statistics.output_control', & string_val) @@ -466,7 +466,7 @@ subroutine case_init_common(C) call C%q%add(C%fluid%stats) C%f_stats_output = fluid_stats_output_t(C%fluid%stats, & - stats_start_time, path=output_directory) + stats_start_time, path = output_directory) call C%s%add(C%f_stats_output, stats_output_val, string_val) end if end if @@ -480,7 +480,7 @@ subroutine case_init_common(C) ! if (C%params%output_mean_sqr_flow) then ! C%f_msqrf = mean_sqr_flow_output_t(C%fluid%mean_sqr, & ! C%params%stats_begin, & -! path=output_directory) +! path = output_directory) ! call C%s%add(C%f_msqrf, C%params%stats_write_par, & ! C%params%stats_write_control) ! end if diff --git a/src/io/fld_file.f90 b/src/io/fld_file.f90 index 84673b90fe6..7c0aed71afc 100644 --- a/src/io/fld_file.f90 +++ b/src/io/fld_file.f90 @@ -152,43 +152,43 @@ subroutine fld_file_write(this, data, t) idx(i) = data%idx(i) end do type is (field_t) - p%ptr => data%x(:,1,1,1) + p%ptr => data%x(:, 1, 1, 1) dof => data%dof write_pressure = .true. write_velocity = .false. type is (field_list_t) select case (data%size()) case (1) - p%ptr => data%items(1)%ptr%x(:,1,1,1) + p%ptr => data%items(1)%ptr%x(:, 1, 1, 1) write_pressure = .true. write_velocity = .false. case (2) - p%ptr => data%items(1)%ptr%x(:,1,1,1) - tem%ptr => data%items(2)%ptr%x(:,1,1,1) + p%ptr => data%items(1)%ptr%x(:, 1, 1, 1) + tem%ptr => data%items(2)%ptr%x(:, 1, 1, 1) write_pressure = .true. write_temperature = .true. case (3) - u%ptr => data%items(1)%ptr%x(:,1,1,1) - v%ptr => data%items(2)%ptr%x(:,1,1,1) - w%ptr => data%items(3)%ptr%x(:,1,1,1) + u%ptr => data%items(1)%ptr%x(:, 1, 1, 1) + v%ptr => data%items(2)%ptr%x(:, 1, 1, 1) + w%ptr => data%items(3)%ptr%x(:, 1, 1, 1) write_velocity = .true. case (4) - p%ptr => data%items(1)%ptr%x(:,1,1,1) - u%ptr => data%items(2)%ptr%x(:,1,1,1) - v%ptr => data%items(3)%ptr%x(:,1,1,1) - w%ptr => data%items(4)%ptr%x(:,1,1,1) + p%ptr => data%items(1)%ptr%x(:, 1, 1, 1) + u%ptr => data%items(2)%ptr%x(:, 1, 1, 1) + v%ptr => data%items(3)%ptr%x(:, 1, 1, 1) + w%ptr => data%items(4)%ptr%x(:, 1, 1, 1) write_pressure = .true. write_velocity = .true. case (5:99) - p%ptr => data%items(1)%ptr%x(:,1,1,1) - u%ptr => data%items(2)%ptr%x(:,1,1,1) - v%ptr => data%items(3)%ptr%x(:,1,1,1) - w%ptr => data%items(4)%ptr%x(:,1,1,1) - tem%ptr => data%items(5)%ptr%x(:,1,1,1) + p%ptr => data%items(1)%ptr%x(:, 1, 1, 1) + u%ptr => data%items(2)%ptr%x(:, 1, 1, 1) + v%ptr => data%items(3)%ptr%x(:, 1, 1, 1) + w%ptr => data%items(4)%ptr%x(:, 1, 1, 1) + tem%ptr => data%items(5)%ptr%x(:, 1, 1, 1) n_scalar_fields = data%size() - 5 allocate(scalar_fields(n_scalar_fields)) do i = 1, n_scalar_fields - scalar_fields(i)%ptr => data%items(i+5)%ptr%x(:,1,1,1) + scalar_fields(i)%ptr => data%items(i+5)%ptr%x(:, 1, 1, 1) end do write_pressure = .true. write_velocity = .true. @@ -199,18 +199,18 @@ subroutine fld_file_write(this, data, t) dof => data%dof(1) type is (mean_flow_t) - u%ptr => data%u%mf%x(:,1,1,1) - v%ptr => data%v%mf%x(:,1,1,1) - w%ptr => data%w%mf%x(:,1,1,1) - p%ptr => data%p%mf%x(:,1,1,1) + u%ptr => data%u%mf%x(:, 1, 1, 1) + v%ptr => data%v%mf%x(:, 1, 1, 1) + w%ptr => data%w%mf%x(:, 1, 1, 1) + p%ptr => data%p%mf%x(:, 1, 1, 1) dof => data%u%mf%dof write_pressure = .true. write_velocity = .true. type is (mean_sqr_flow_t) - u%ptr => data%uu%mf%x(:,1,1,1) - v%ptr => data%vv%mf%x(:,1,1,1) - w%ptr => data%ww%mf%x(:,1,1,1) - p%ptr => data%pp%mf%x(:,1,1,1) + u%ptr => data%uu%mf%x(:, 1, 1, 1) + v%ptr => data%vv%mf%x(:, 1, 1, 1) + w%ptr => data%ww%mf%x(:, 1, 1, 1) + p%ptr => data%pp%mf%x(:, 1, 1, 1) dof => data%pp%mf%dof write_pressure = .true. write_velocity = .true. @@ -219,9 +219,9 @@ subroutine fld_file_write(this, data, t) end select ! Fix things for pointers that do not exist in all data types... if (associated(dof)) then - x%ptr => dof%x(:,1,1,1) - y%ptr => dof%y(:,1,1,1) - z%ptr => dof%z(:,1,1,1) + x%ptr => dof%x(:, 1, 1, 1) + y%ptr => dof%y(:, 1, 1, 1) + z%ptr => dof%z(:, 1, 1, 1) msh => dof%msh Xh => dof%Xh end if @@ -329,7 +329,8 @@ subroutine fld_file_write(this, data, t) (int(gdim*lxyz, i8) * & int(FLD_DATA_SIZE, i8)) - call fld_file_write_vector_field(this, fh, byte_offset, x%ptr, y%ptr, z%ptr, n, gdim, lxyz, nelv) + call fld_file_write_vector_field(this, fh, byte_offset, x%ptr, y%ptr, & + z%ptr, n, gdim, lxyz, nelv) mpi_offset = mpi_offset + int(glb_nelv, i8) * & (int(gdim *lxyz, i8) * & int(FLD_DATA_SIZE, i8)) @@ -339,7 +340,8 @@ subroutine fld_file_write(this, data, t) byte_offset = mpi_offset + int(offset_el, i8) * & (int(gdim * (lxyz), i8) * & int(FLD_DATA_SIZE, i8)) - call fld_file_write_vector_field(this, fh, byte_offset, u%ptr, v%ptr, w%ptr, n, gdim, lxyz, nelv) + call fld_file_write_vector_field(this, fh, byte_offset, u%ptr, v%ptr, & + w%ptr, n, gdim, lxyz, nelv) mpi_offset = mpi_offset + int(glb_nelv, i8) * & (int(gdim * (lxyz), i8) * & @@ -394,7 +396,8 @@ subroutine fld_file_write(this, data, t) int(2, i8) * & int(MPI_REAL_SIZE, i8) * & int(gdim, i8) - call fld_file_write_metadata_vector(this, fh, byte_offset, x%ptr, y%ptr, z%ptr, gdim, lxyz, nelv) + call fld_file_write_metadata_vector(this, fh, byte_offset, x%ptr, & + y%ptr, z%ptr, gdim, lxyz, nelv) mpi_offset = int(mpi_offset, i8) + & int(glb_nelv, i8) * & int(2, i8) * & @@ -408,7 +411,8 @@ subroutine fld_file_write(this, data, t) int(2, i8) * & int(MPI_REAL_SIZE, i8) * & int(gdim, i8) - call fld_file_write_metadata_vector(this, fh, byte_offset, u%ptr, v%ptr, w%ptr, gdim, lxyz, nelv) + call fld_file_write_metadata_vector(this, fh, byte_offset, u%ptr, & + v%ptr, w%ptr, gdim, lxyz, nelv) mpi_offset = int(mpi_offset, i8) + & int(glb_nelv, i8) * & int(2, i8) * & @@ -422,7 +426,8 @@ subroutine fld_file_write(this, data, t) int(offset_el, i8) * & int(2, i8) * & int(MPI_REAL_SIZE, i8) - call fld_file_write_metadata_scalar(this, fh, byte_offset, p%ptr, lxyz, nelv) + call fld_file_write_metadata_scalar(this, fh, byte_offset, p%ptr, & + lxyz, nelv) mpi_offset = int(mpi_offset, i8) + & int(glb_nelv, i8) * & int(2, i8) * & @@ -435,7 +440,8 @@ subroutine fld_file_write(this, data, t) int(offset_el, i8) * & int(2, i8) * & int(MPI_REAL_SIZE, i8) - call fld_file_write_metadata_scalar(this, fh, byte_offset, tem%ptr, lxyz, nelv) + call fld_file_write_metadata_scalar(this, fh, byte_offset, tem%ptr, & + lxyz, nelv) mpi_offset = int(mpi_offset, i8) + & int(glb_nelv, i8) * & int(2, i8) * & @@ -460,7 +466,8 @@ subroutine fld_file_write(this, data, t) int(offset_el, i8) * & int(2, i8) * & int(MPI_REAL_SIZE, i8) - call fld_file_write_metadata_scalar(this, fh, byte_offset, scalar_fields(i)%ptr, lxyz, nelv) + call fld_file_write_metadata_scalar(this, fh, byte_offset, & + scalar_fields(i)%ptr, lxyz, nelv) mpi_offset = int(mpi_offset, i8) + & int(glb_nelv, i8) * & int(2, i8) * & @@ -492,25 +499,26 @@ subroutine fld_file_write(this, data, t) if (allocated(tmp_sp)) deallocate(tmp_sp) end subroutine fld_file_write - subroutine fld_file_write_metadata_vector(this, fh, byte_offset, x, y, z, gdim, lxyz, nelv) + subroutine fld_file_write_metadata_vector(this, fh, byte_offset, x, y, z, & + gdim, lxyz, nelv) class(fld_file_t), intent(inout) :: this type(MPI_File), intent(inout) :: fh integer, intent(in) :: gdim, lxyz, nelv - real(kind=rp), intent(in) :: x(lxyz,nelv), y(lxyz,nelv), z(lxyz,nelv) + real(kind=rp), intent(in) :: x(lxyz, nelv), y(lxyz, nelv), z(lxyz, nelv) integer (kind=MPI_OFFSET_KIND), intent(in) :: byte_offset integer :: el, j, ierr, nout type(MPI_Status) :: status real(kind=sp) :: buffer(2*gdim*nelv) j = 1 - do el=1,nelv - buffer(j+0) = real(vlmin(x(1,el),lxyz),sp) - buffer(j+1) = real(vlmax(x(1,el),lxyz),sp) - buffer(j+2) = real(vlmin(y(1,el),lxyz) ,sp) - buffer(j+3) = real(vlmax(y(1,el),lxyz),sp) + do el = 1, nelv + buffer(j + 0) = real(vlmin(x(1, el), lxyz), sp) + buffer(j + 1) = real(vlmax(x(1, el), lxyz), sp) + buffer(j + 2) = real(vlmin(y(1, el), lxyz), sp) + buffer(j + 3) = real(vlmax(y(1, el), lxyz), sp) j = j + 4 - buffer(j+0) = real(vlmin(z(1,el),lxyz) ,sp) - buffer(j+1) = real(vlmax(z(1,el),lxyz),sp) + buffer(j + 0) = real(vlmin(z(1, el), lxyz), sp) + buffer(j + 1) = real(vlmax(z(1, el), lxyz), sp) j = j + 2 enddo @@ -522,25 +530,26 @@ subroutine fld_file_write_metadata_vector(this, fh, byte_offset, x, y, z, gdim, end subroutine fld_file_write_metadata_vector - subroutine fld_file_write_metadata_scalar(this, fh, byte_offset, x, lxyz, nelv) + subroutine fld_file_write_metadata_scalar(this, fh, byte_offset, x, lxyz, & + nelv) class(fld_file_t), intent(inout) :: this type(MPI_File), intent(inout) :: fh integer, intent(in) :: lxyz, nelv - real(kind=rp), intent(in) :: x(lxyz,nelv) + real(kind=rp), intent(in) :: x(lxyz, nelv) integer (kind=MPI_OFFSET_KIND), intent(in) :: byte_offset integer :: el, j, ierr, nout type(MPI_Status) :: status real(kind=sp) :: buffer(2*nelv) j = 1 - do el=1,nelv - buffer(j+0) = real(vlmin(x(1,el),lxyz),sp) - buffer(j+1) = real(vlmax(x(1,el),lxyz),sp) + do el = 1, nelv + buffer(j + 0) = real(vlmin(x(1, el), lxyz), sp) + buffer(j + 1) = real(vlmax(x(1, el), lxyz), sp) j = j + 2 enddo ! write out data - nout = 2*nelv + nout = 2 * nelv call MPI_File_write_at_all(fh, byte_offset, buffer, nout, & MPI_REAL, status, ierr) @@ -565,7 +574,7 @@ subroutine fld_file_write_field(this, fh, byte_offset, p, n) MPI_DOUBLE_PRECISION, status, ierr) else do i = 1, n - tmp_sp(i) = real(p(i),sp) + tmp_sp(i) = real(p(i), sp) end do call MPI_File_write_at_all(fh, byte_offset, tmp_sp, n, & MPI_REAL, status, ierr) @@ -573,11 +582,12 @@ subroutine fld_file_write_field(this, fh, byte_offset, p, n) end subroutine fld_file_write_field - subroutine fld_file_write_vector_field(this, fh, byte_offset, x, y, z, n, gdim, lxyz, nelv) + subroutine fld_file_write_vector_field(this, fh, byte_offset, x, y, z, n, & + gdim, lxyz, nelv) class(fld_file_t), intent(inout) :: this type(MPI_File), intent(inout) :: fh integer, intent(in) :: n, gdim, lxyz, nelv - real(kind=rp), intent(in) :: x(lxyz,nelv), y(lxyz,nelv), z(lxyz,nelv) + real(kind=rp), intent(in) :: x(lxyz, nelv), y(lxyz, nelv), z(lxyz, nelv) integer (kind=MPI_OFFSET_KIND), intent(in) :: byte_offset integer :: i, el, j, ierr type(MPI_Status) :: status @@ -586,41 +596,41 @@ subroutine fld_file_write_vector_field(this, fh, byte_offset, x, y, z, n, gdim, i = 1 do el = 1, nelv do j = 1, lxyz - tmp_dp(i) = real(x(j,el), dp) + tmp_dp(i) = real(x(j, el), dp) i = i +1 end do do j = 1, lxyz - tmp_dp(i) = real(y(j,el), dp) + tmp_dp(i) = real(y(j, el), dp) i = i +1 end do if (gdim .eq. 3) then do j = 1, lxyz - tmp_dp(i) = real(z(j,el), dp) - i = i +1 + tmp_dp(i) = real(z(j, el), dp) + i = i + 1 end do end if end do - call MPI_File_write_at_all(fh, byte_offset, tmp_dp, gdim*n, & + call MPI_File_write_at_all(fh, byte_offset, tmp_dp, gdim * n, & MPI_DOUBLE_PRECISION, status, ierr) else i = 1 do el = 1, nelv do j = 1, lxyz - tmp_sp(i) = real(x(j,el),sp) - i = i +1 + tmp_sp(i) = real(x(j, el), sp) + i = i + 1 end do do j = 1, lxyz - tmp_sp(i) = real(y(j,el),sp) - i = i +1 + tmp_sp(i) = real(y(j, el), sp) + i = i + 1 end do if (gdim .eq. 3) then do j = 1, lxyz - tmp_sp(i) = real(z(j,el),sp) - i = i +1 + tmp_sp(i) = real(z(j, el), sp) + i = i + 1 end do end if end do - call MPI_File_write_at_all(fh, byte_offset, tmp_sp, gdim*n, & + call MPI_File_write_at_all(fh, byte_offset, tmp_sp, gdim * n, & MPI_REAL, status, ierr) end if @@ -647,11 +657,11 @@ subroutine fld_file_read(this, data) real(kind=sp) :: temp type(linear_dist_t) :: dist real(kind=sp), parameter :: test_pattern = 6.54321 - character :: rdcode(10),temp_str(4) + character :: rdcode(10), temp_str(4) select type (data) type is (fld_file_data_t) - call filename_chsuffix(this%fname, meta_fname,'nek5000') + call filename_chsuffix(this%fname, meta_fname, 'nek5000') ! Extract file path slsh_pos = filename_tslash_pos(this%fname) @@ -663,7 +673,7 @@ subroutine fld_file_read(this, data) if (pe_rank .eq. 0) then open(unit = 9, file = trim(meta_fname)) read(9, fmt = '(A)') string - read(string(14:),fmt = '(A)') string + read(string(14:), fmt = '(A)') string ! Remove leading whitespaces ! from something like " field%01d.f%05d" to @@ -671,42 +681,48 @@ subroutine fld_file_read(this, data) leading_space_pos = scan(trim(string), " ", back = .true.) string = trim(string(leading_space_pos + 1:)) - data%fld_series_fname = string(:scan(trim(string), '%')-1) + data%fld_series_fname = string(:scan(trim(string), '%') - 1) data%fld_series_fname = trim(data%fld_series_fname) // '0' read(9, fmt = '(A)') string - read(string(scan(string,':')+1:),*) data%meta_start_counter + read(string(scan(string,':') + 1:), *) data%meta_start_counter read(9, fmt = '(A)') string - read(string(scan(string,':')+1:),*) data%meta_nsamples + read(string(scan(string,':') + 1:), *) data%meta_nsamples close(9) call neko_log%message('Reading meta file for fld series') call neko_log%message('Name: ' // trim(data%fld_series_fname)) - write (log_buf,'(A,I7)') 'Start counter : ', data%meta_start_counter + write (log_buf,'(A,I7)') 'Start counter : ', & + data%meta_start_counter call neko_log%message(log_buf) - write (log_buf,'(A,I7)') 'Number of samples: ', data%meta_nsamples + write (log_buf,'(A,I7)') 'Number of samples: ', & + data%meta_nsamples call neko_log%message(log_buf) end if - call MPI_Bcast(data%fld_series_fname, 1024, MPI_CHARACTER, 0, NEKO_COMM, ierr) - call MPI_Bcast(data%meta_start_counter, 1, MPI_INTEGER, 0, NEKO_COMM, ierr) - call MPI_Bcast(data%meta_nsamples, 1, MPI_INTEGER, 0, NEKO_COMM, ierr) + call MPI_Bcast(data%fld_series_fname, 1024, MPI_CHARACTER, 0, & + NEKO_COMM, ierr) + call MPI_Bcast(data%meta_start_counter, 1, MPI_INTEGER, 0, & + NEKO_COMM, ierr) + call MPI_Bcast(data%meta_nsamples, 1, MPI_INTEGER, 0, NEKO_COMM, & + ierr) if (this%counter .eq. 0) this%counter = data%meta_start_counter end if if (meta_file) then write(id_str, '(a,i5.5)') 'f', this%counter fname = trim(data%fld_series_fname) // '.'//id_str - if (this%counter .ge. data%meta_nsamples+data%meta_start_counter) then + if (this%counter .ge. & + data%meta_nsamples + data%meta_start_counter) then call neko_error('Trying to read more fld files than exist') end if - ! Reappend path to the file series name since we lose it during the meta - ! file reading + ! Reappend path to the file series name since we lose it during the + ! meta file reading if (trim(path) .ne. "none") fname = trim(path) // trim(fname) else suffix_pos = filename_suffix_pos(this%fname) write(id_str, '(a,i5.5)') 'f', this%counter - fname = trim(this%fname(1:suffix_pos-1)) // '.'//id_str + fname = trim(this%fname(1:suffix_pos - 1)) // '.'//id_str end if call MPI_File_open(NEKO_COMM, trim(fname), & @@ -717,12 +733,12 @@ subroutine fld_file_read(this, data) call neko_log%message("Reading fld file " // trim(fname)) call MPI_File_read_all(fh, hdr, 132, MPI_CHARACTER, status, ierr) - !This read can prorbably be done wihtout the temp variables, temp_str, i, j + !This read can prorbably be done wihtout the temp variables,temp_str,i,j read(hdr, 1) temp_str,FLD_DATA_SIZE, lx, ly, lz, glb_nelv, glb_nelv,& - time, counter, i, j, (rdcode(i),i=1,10) -1 format(4a,1x,i1,1x,i2,1x,i2,1x,i2,1x,i10,1x,i10,1x,e20.13,& - 1x,i9,1x,i6,1x,i6,1x,10a) + time, counter, i, j, (rdcode(i), i = 1, 10) +1 format(4a, 1x, i1, 1x, i2, 1x, i2, 1x, i2, 1x, i10, 1x, i10, 1x, & + e20.13, 1x, i9, 1x, i6, 1x, i6, 1x, 10a) if (data%nelv .eq. 0) then dist = linear_dist_t(glb_nelv, pe_rank, pe_size, NEKO_COMM) data%nelv = dist%num_local() @@ -750,9 +766,9 @@ subroutine fld_file_read(this, data) this%dp_precision = .false. end if if (this%dp_precision) then - allocate(tmp_dp(data%gdim*n)) + allocate(tmp_dp(data%gdim * n)) else - allocate(tmp_sp(data%gdim*n)) + allocate(tmp_sp(data%gdim * n)) end if @@ -788,10 +804,10 @@ subroutine fld_file_read(this, data) n_scalars = 0 if (rdcode(i) .eq. 'S') then i = i + 1 - read(rdcode(i),*) n_scalars + read(rdcode(i), *) n_scalars n_scalars = n_scalars*10 i = i + 1 - read(rdcode(i),*) j + read(rdcode(i), *) j n_scalars = n_scalars+j i = i + 1 if (allocated(data%s)) then @@ -820,7 +836,8 @@ subroutine fld_file_read(this, data) call MPI_File_read_at_all(fh, mpi_offset, temp, 1, & MPI_REAL, status, ierr) if (temp .ne. test_pattern) then - call neko_error('Incorrect format for fld file, test pattern does not match.') + call neko_error('Incorrect format for fld file, test pattern does & +¬ match.') end if mpi_offset = mpi_offset + MPI_REAL_SIZE @@ -840,13 +857,15 @@ subroutine fld_file_read(this, data) call MPI_File_read_at_all(fh, byte_offset, data%idx, data%nelv, & MPI_INTEGER, status, ierr) - mpi_offset = mpi_offset + int(data%glb_nelv, i8) * int(MPI_INTEGER_SIZE, i8) + mpi_offset = mpi_offset + int(data%glb_nelv, i8) * & + int(MPI_INTEGER_SIZE, i8) if (read_mesh) then byte_offset = mpi_offset + int(data%offset_el, i8) * & (int(data%gdim*lxyz, i8) * & int(FLD_DATA_SIZE, i8)) - call fld_file_read_vector_field(this, fh, byte_offset, data%x, data%y, data%z, data) + call fld_file_read_vector_field(this, fh, byte_offset, data%x, & + data%y, data%z, data) mpi_offset = mpi_offset + int(data%glb_nelv, i8) * & (int(data%gdim *lxyz, i8) * & int(FLD_DATA_SIZE, i8)) @@ -856,7 +875,8 @@ subroutine fld_file_read(this, data) byte_offset = mpi_offset + int(data%offset_el, i8) * & (int(data%gdim*lxyz, i8) * & int(FLD_DATA_SIZE, i8)) - call fld_file_read_vector_field(this, fh, byte_offset, data%u, data%v, data%w, data) + call fld_file_read_vector_field(this, fh, byte_offset, data%u, & + data%v, data%w, data) mpi_offset = mpi_offset + int(data%glb_nelv, i8) * & (int(data%gdim *lxyz, i8) * & int(FLD_DATA_SIZE, i8)) @@ -897,7 +917,8 @@ subroutine fld_file_read(this, data) if (allocated(tmp_dp)) deallocate(tmp_dp) if (allocated(tmp_sp)) deallocate(tmp_sp) class default - call neko_error('Currently we only read into fld_file_data_t, please use that data structure instead.') + call neko_error('Currently we only read into fld_file_data_t, please & +&use that data structure instead.') end select end subroutine fld_file_read @@ -936,7 +957,8 @@ subroutine fld_file_read_field(this, fh, byte_offset, x, fld_data) end subroutine fld_file_read_field - subroutine fld_file_read_vector_field(this, fh, byte_offset, x, y, z, fld_data) + subroutine fld_file_read_vector_field(this, fh, byte_offset, x, y, z, & + fld_data) class(fld_file_t), intent(inout) :: this type(vector_t), intent(inout) :: x, y, z type(fld_file_data_t) :: fld_data @@ -946,8 +968,8 @@ subroutine fld_file_read_vector_field(this, fh, byte_offset, x, y, z, fld_data) integer :: n, ierr, lxyz, i, j, e, nd n = x%n - nd = n*fld_data%gdim - lxyz = fld_data%lx*fld_data%ly*fld_data%lz + nd = n * fld_data%gdim + lxyz = fld_data%lx * fld_data%ly * fld_data%lz if (this%dp_precision) then call MPI_File_read_at_all(fh, byte_offset, tmp_dp, nd, & @@ -962,17 +984,17 @@ subroutine fld_file_read_vector_field(this, fh, byte_offset, x, y, z, fld_data) i = 1 do e = 1, fld_data%nelv do j = 1, lxyz - x%x((e-1)*lxyz+j) = tmp_dp(i) - i = i +1 + x%x((e - 1)*lxyz+j) = tmp_dp(i) + i = i + 1 end do do j = 1, lxyz - y%x((e-1)*lxyz+j) = tmp_dp(i) - i = i +1 + y%x((e - 1)*lxyz+j) = tmp_dp(i) + i = i + 1 end do if (fld_data%gdim .eq. 3) then do j = 1, lxyz - z%x((e-1)*lxyz+j) = tmp_dp(i) - i = i +1 + z%x((e - 1)*lxyz+j) = tmp_dp(i) + i = i + 1 end do end if end do @@ -980,17 +1002,17 @@ subroutine fld_file_read_vector_field(this, fh, byte_offset, x, y, z, fld_data) i = 1 do e = 1, fld_data%nelv do j = 1, lxyz - x%x((e-1)*lxyz+j) = tmp_sp(i) - i = i +1 + x%x((e - 1)*lxyz+j) = tmp_sp(i) + i = i + 1 end do do j = 1, lxyz - y%x((e-1)*lxyz+j) = tmp_sp(i) - i = i +1 + y%x((e - 1)*lxyz+j) = tmp_sp(i) + i = i + 1 end do if (fld_data%gdim .eq. 3) then do j = 1, lxyz - z%x((e-1)*lxyz+j) = tmp_sp(i) - i = i +1 + z%x((e - 1)*lxyz+j) = tmp_sp(i) + i = i + 1 end do end if end do diff --git a/src/io/fld_file_data.f90 b/src/io/fld_file_data.f90 index dc1d2fb1842..73ee3dc91a9 100644 --- a/src/io/fld_file_data.f90 +++ b/src/io/fld_file_data.f90 @@ -71,11 +71,11 @@ function fld_file_data_size(this) result(i) class(fld_file_data_t) :: this integer :: i i = 0 - if(this%u%n .gt. 0) i = i + 1 - if(this%v%n .gt. 0) i = i + 1 - if(this%w%n .gt. 0) i = i + 1 - if(this%p%n .gt. 0) i = i + 1 - if(this%t%n .gt. 0) i = i + 1 + if (this%u%n .gt. 0) i = i + 1 + if (this%v%n .gt. 0) i = i + 1 + if (this%w%n .gt. 0) i = i + 1 + if (this%p%n .gt. 0) i = i + 1 + if (this%t%n .gt. 0) i = i + 1 i = i + this%n_scalars end function fld_file_data_size @@ -87,23 +87,23 @@ subroutine fld_file_data_get_list(this, ptr_list, n) integer :: i, j type(vector_ptr_t), intent(inout) :: ptr_list(n) i = 1 - if(this%u%n .gt. 0) then + if (this%u%n .gt. 0) then ptr_list(i)%ptr => this%u i = i + 1 end if - if(this%v%n .gt. 0) then + if (this%v%n .gt. 0) then ptr_list(i)%ptr => this%v i = i + 1 end if - if(this%w%n .gt. 0) then + if (this%w%n .gt. 0) then ptr_list(i)%ptr => this%w i = i + 1 end if - if(this%p%n .gt. 0) then + if (this%p%n .gt. 0) then ptr_list(i)%ptr => this%p i = i + 1 end if - if(this%t%n .gt. 0) then + if (this%t%n .gt. 0) then ptr_list(i)%ptr => this%t i = i + 1 end if @@ -122,14 +122,14 @@ subroutine fld_file_data_scale(this, c) real(kind=rp), intent(in) :: c integer :: i - if(this%u%n .gt. 0) call cmult(this%u%x,c,this%u%n) - if(this%v%n .gt. 0) call cmult(this%v%x,c,this%v%n) - if(this%w%n .gt. 0) call cmult(this%w%x,c,this%w%n) - if(this%p%n .gt. 0) call cmult(this%p%x,c,this%p%n) - if(this%t%n .gt. 0) call cmult(this%t%x,c,this%t%n) + if (this%u%n .gt. 0) call cmult(this%u%x, c, this%u%n) + if (this%v%n .gt. 0) call cmult(this%v%x, c, this%v%n) + if (this%w%n .gt. 0) call cmult(this%w%x, c, this%w%n) + if (this%p%n .gt. 0) call cmult(this%p%x, c, this%p%n) + if (this%t%n .gt. 0) call cmult(this%t%x, c, this%t%n) do i = 1, this%n_scalars - if(this%s(i)%n .gt. 0) call cmult(this%s(i)%x,c,this%s(i)%n) + if (this%s(i)%n .gt. 0) call cmult(this%s(i)%x, c, this%s(i)%n) end do end subroutine fld_file_data_scale @@ -140,14 +140,15 @@ subroutine fld_file_data_add(this, fld_data_add) class(fld_file_data_t), intent(in) :: fld_data_add integer :: i - if(this%u%n .gt. 0) call add2(this%u%x,fld_data_add%u%x,this%u%n) - if(this%v%n .gt. 0) call add2(this%v%x,fld_data_add%v%x,this%v%n) - if(this%w%n .gt. 0) call add2(this%w%x,fld_data_add%w%x,this%w%n) - if(this%p%n .gt. 0) call add2(this%p%x,fld_data_add%p%x,this%p%n) - if(this%t%n .gt. 0) call add2(this%t%x,fld_data_add%t%x,this%t%n) + if (this%u%n .gt. 0) call add2(this%u%x, fld_data_add%u%x, this%u%n) + if (this%v%n .gt. 0) call add2(this%v%x, fld_data_add%v%x, this%v%n) + if (this%w%n .gt. 0) call add2(this%w%x, fld_data_add%w%x, this%w%n) + if (this%p%n .gt. 0) call add2(this%p%x, fld_data_add%p%x, this%p%n) + if (this%t%n .gt. 0) call add2(this%t%x, fld_data_add%t%x, this%t%n) do i = 1, this%n_scalars - if(this%s(i)%n .gt. 0) call add2(this%s(i)%x,fld_data_add%s(i)%x,this%s(i)%n) + if (this%s(i)%n .gt. 0) call add2(this%s(i)%x, fld_data_add%s(i)%x, & + this%s(i)%n) end do end subroutine fld_file_data_add @@ -200,7 +201,7 @@ function fld_file_data_generate_interpolator(this, to_dof, & type(mesh_t) :: fld_empty_mesh real(kind=rp), allocatable :: x_coords(:,:,:,:), y_coords(:,:,:,:), & z_coords(:,:,:,:) - real(kind=rp) :: center_x, center_y, center_z + real(kind=rp) :: center_x, center_y, center_z integer :: e, i ! --- @@ -214,21 +215,21 @@ function fld_file_data_generate_interpolator(this, to_dof, & &mesh information from fld data.") ! Create a space based on the fld data - call fld_Xh%init(GLL, this%lx, this%ly, this%lz) + call fld_Xh%init(GLL, this%lx, this%ly, this%lz) ! Initialize an "empty" mesh and construct a "stripped down" - ! dofmap that only has x,y,z coordinates. This is because + ! dofmap that only has x, y,z coordinates. This is because ! global_interpolator needs a dofmap in its init but in practice - ! only uses dof%x, dof%y, dof%z + ! only uses dof%x, dof%y, dof%z call fld_empty_mesh%init(this%gdim, this%nelv) - fld_dof = dofmap_t(this%x%x, this%y%x, this%z%x, & - this%nelv, this%lx, this%ly, this%lz) + fld_dof = dofmap_t(this%x%x, this%y%x, this%z%x, & + this%nelv, this%lx, this%ly, this%lz) ! These are the coordinates of our current dofmap ! that we use for the interpolation - allocate(x_coords(to_Xh%lx, to_Xh%ly, to_Xh%lz, to_msh%nelv)) - allocate(y_coords(to_Xh%lx, to_Xh%ly, to_Xh%lz, to_msh%nelv)) - allocate(z_coords(to_Xh%lx, to_Xh%ly, to_Xh%lz, to_msh%nelv)) + allocate(x_coords(to_Xh%lx, to_Xh%ly, to_Xh%lz, to_msh%nelv)) + allocate(y_coords(to_Xh%lx, to_Xh%ly, to_Xh%lz, to_msh%nelv)) + allocate(z_coords(to_Xh%lx, to_Xh%ly, to_Xh%lz, to_msh%nelv)) !> To ensure that each point is within an element !! Remedies issue with points on the boundary diff --git a/src/scalar/scalar_ic.f90 b/src/scalar/scalar_ic.f90 index a0b014e137e..5518d8f9b2d 100644 --- a/src/scalar/scalar_ic.f90 +++ b/src/scalar/scalar_ic.f90 @@ -109,7 +109,7 @@ subroutine set_scalar_ic_int(s, coef, gs, type, params) write (log_buf, '(A,F10.6)') "Base value: ", ic_value call neko_log%message(log_buf) - call neko_log%message( "Zone name : " // trim(read_str)) + call neko_log%message("Zone name : " // trim(read_str)) write (log_buf, '(A,F10.6)') "Zone value: ", zone_value call neko_log%message(log_buf) @@ -132,7 +132,7 @@ subroutine set_scalar_ic_int(s, coef, gs, type, params) 'case.scalar.initial_condition.tolerance', tol, 1d-6) if (found_previous_mesh) then - call neko_log%message( "Previous mesh: " // trim(prev_mesh)) + call neko_log%message("Previous mesh: " // trim(prev_mesh)) write (log_buf, '(A,E15.7)') "Tolerance : ", tol call neko_log%message(log_buf) end if @@ -164,7 +164,7 @@ subroutine set_scalar_ic_int(s, coef, gs, type, params) fpos = scan(suffix, 'f') if (fpos .eq. 1) then if (sample_idx .ne. -1) & - call neko_warning("Overwriting sample index!") + call neko_warning("Overwriting sample index.") read (suffix(2:), "(I5.5)") sample_idx end if @@ -188,16 +188,16 @@ subroutine set_scalar_ic_int(s, coef, gs, type, params) sample_mesh_idx, 0) if (interpolate) then - call neko_log%message( "Interpolation : yes") + call neko_log%message("Interpolation : yes") write (log_buf, '(A,E15.7)') "Tolerance : ", tol call neko_log%message(log_buf) - write (log_buf, '(A,I5)') "Mesh sample index: ", & + write (log_buf, '(A,I5)') "Mesh sample index: ", & sample_mesh_idx call neko_log%message(log_buf) end if call set_scalar_ic_fld(s, read_str, sample_idx, interpolate, & - tolerance=tol, sample_mesh_idx=sample_mesh_idx) + tolerance = tol, sample_mesh_idx = sample_mesh_idx) end if ! if suffix .eq. chkp @@ -244,7 +244,7 @@ subroutine set_scalar_ic_common(s, coef, gs) n = s%dof%size() if (NEKO_BCKND_DEVICE .eq. 1) then call device_memcpy(s%x, s%x_d, n, & - HOST_TO_DEVICE, sync=.false.) + HOST_TO_DEVICE, sync = .false.) end if ! Ensure continuity across elements for initial conditions @@ -283,7 +283,7 @@ end subroutine set_scalar_ic_uniform !! @param zone_value Desired value of the scalar field in the point zone. subroutine set_scalar_ic_point_zone(s, base_value, zone_name, zone_value) type(field_t), intent(inout) :: s - real(kind=rp), intent(in):: base_value + real(kind=rp), intent(in) :: base_value character(len=*), intent(in) :: zone_name real(kind=rp), intent(in) :: zone_value @@ -385,7 +385,7 @@ subroutine set_scalar_ic_fld(s, file_name, sample_idx, & if (present(tolerance)) then global_interp = fld_data%generate_interpolator(s%dof, s%msh, tolerance) else - global_interp = fld_data%generate_interpolator(s%dof, s%msh, 1d-6) + call neko_error("No tolerance provided for the interpolation.") end if ! Evaluate scalar diff --git a/src/sem/dofmap.f90 b/src/sem/dofmap.f90 index c6aa5d4b735..4c1d9a491b6 100644 --- a/src/sem/dofmap.f90 +++ b/src/sem/dofmap.f90 @@ -51,12 +51,12 @@ module dofmap private type, public :: dofmap_t - integer(kind=i8), allocatable :: dof(:,:,:,:) !< Mapping to unique dof - logical, allocatable :: shared_dof(:,:,:,:) !< True if the dof is shared - real(kind=rp), allocatable :: x(:,:,:,:) !< Mapping to x-coordinates - real(kind=rp), allocatable :: y(:,:,:,:) !< Mapping to y-coordinates - real(kind=rp), allocatable :: z(:,:,:,:) !< Mapping to z-coordinates - integer, private :: ntot !< Total number of dofs + integer(kind=i8), allocatable :: dof(:, :, :, :) !< Mapping to unique dof + logical, allocatable :: shared_dof(:, :, :, :) !< True if the dof is shared + real(kind=rp), allocatable :: x(:, :, :, :) !< Mapping to x-coordinates + real(kind=rp), allocatable :: y(:, :, :, :) !< Mapping to y-coordinates + real(kind=rp), allocatable :: z(:, :, :, :) !< Mapping to z-coordinates + integer, private :: ntot !< Total number of dofs type(mesh_t), pointer :: msh type(space_t), pointer :: Xh @@ -82,9 +82,9 @@ module dofmap !> Initialize a stripped-down version of a dofmap object, with only !! x,y,z coordinates. function dofmap_init_from_coords(x, y, z, nelv, lx, ly, lz) result(this) - real(kind=rp), intent(in) :: x(nelv*lx*ly*lz) - real(kind=rp), intent(in) :: y(nelv*lx*ly*lz) - real(kind=rp), intent(in) :: z(nelv*lx*ly*lz) + real(kind=rp), intent(in) :: x(nelv * lx * ly * lz) + real(kind=rp), intent(in) :: y(nelv * lx * ly * lz) + real(kind=rp), intent(in) :: z(nelv * lx * ly * lz) integer, intent(in) :: nelv integer, intent(in) :: lx integer, intent(in) :: ly @@ -111,11 +111,11 @@ function dofmap_init_from_coords(x, y, z, nelv, lx, ly, lz) result(this) call device_map(this%z, this%z_d, this%ntot) call device_memcpy(this%x, this%x_d, this%ntot, & - HOST_TO_DEVICE, sync=.false.) + HOST_TO_DEVICE, sync = .false.) call device_memcpy(this%y, this%y_d, this%ntot, & - HOST_TO_DEVICE, sync=.false.) + HOST_TO_DEVICE, sync = .false.) call device_memcpy(this%z, this%z_d, this%ntot, & - HOST_TO_DEVICE, sync=.false.) + HOST_TO_DEVICE, sync = .false.) end if end function dofmap_init_from_coords @@ -179,11 +179,11 @@ function dofmap_init(msh, Xh) result(this) call device_map(this%z, this%z_d, this%ntot) call device_memcpy(this%x, this%x_d, this%ntot, & - HOST_TO_DEVICE, sync=.false.) + HOST_TO_DEVICE, sync = .false.) call device_memcpy(this%y, this%y_d, this%ntot, & - HOST_TO_DEVICE, sync=.false.) + HOST_TO_DEVICE, sync = .false.) call device_memcpy(this%z, this%z_d, this%ntot, & - HOST_TO_DEVICE, sync=.false.) + HOST_TO_DEVICE, sync = .false.) end if end function dofmap_init @@ -696,7 +696,7 @@ subroutine dofmap_generate_xyz(this) call dofmap_xyzlin(Xh, msh, msh%elements(i)%e, this%x(1,1,1,i), & this%y(1,1,1,i), this%z(1,1,1,i)) end do - do i =1, msh%curve%size + do i = 1, msh%curve%size midpoint = .false. el_idx = msh%curve%curve_el(i)%el_idx curve_type = msh%curve%curve_el(i)%curve_type @@ -712,7 +712,7 @@ subroutine dofmap_generate_xyz(this) this%z(1,1,1,el_idx),curve_type, curve_data_tot) end if end do - do i =1, msh%curve%size + do i = 1, msh%curve%size el_idx = msh%curve%curve_el(i)%el_idx do j = 1, 8 if (msh%curve%curve_el(i)%curve_type(j) .eq. 3) then @@ -854,7 +854,7 @@ subroutine dofmap_xyzquad(Xh, msh, element, x, y, z, curve_type, curve_data) call gh_face_extend_2d(x3,zg,3,2,w(1,1),w(1,2)) ! 2 --> edge extend call gh_face_extend_2d(y3,zg,3,2,w(1,1),w(1,2)) end if - k =1 + k = 1 do j = 1, Xh%lx call fd_weights_full(Xh%zg(j,1),zquad,2,0,jxt(k)) call fd_weights_full(Xh%zg(j,2),zquad,2,0,jyt(k)) @@ -1044,7 +1044,7 @@ subroutine gh_face_extend_2d(x, zg, n, gh_type, e, v) !Build vertex interpolant - ntot=n*n + ntot = n * n call rzero(v,ntot) do jj = 1, n, n-1 do ii = 1, n, n-1 @@ -1148,9 +1148,9 @@ subroutine arc_surface(isid, curve_data, x, y, z, Xh, element, gdim) isid1 = mod(isid+4-1, 4)+1 call compute_h(h, Xh%zg, gdim, Xh%lx) if (radius < 0.0) dtheta = -dtheta - do ix=1,Xh%lx - ixt=ix - if (isid1.gt.2) ixt=Xh%lx+1-ix + do ix = 1, Xh%lx + ixt = ix + if (isid1.gt.2) ixt = Xh%lx + 1 - ix r=Xh%zg(ix,1) xcrved(ixt) = xcenn + abs(radius) * cos(theta0 + r*dtheta) & - ( h(ix,1,1)*pt1x + h(ix,1,2)*pt2x ) From 864a168bfb3a0050d1474966ab2de12c1d7e2fa5 Mon Sep 17 00:00:00 2001 From: Victor Baconnet Date: Tue, 23 Jul 2024 14:44:54 +0200 Subject: [PATCH 24/67] add some logic to account for skipping lag arrays --- src/common/checkpoint.f90 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/common/checkpoint.f90 b/src/common/checkpoint.f90 index 6df5c4ab9d9..e0dc5261950 100644 --- a/src/common/checkpoint.f90 +++ b/src/common/checkpoint.f90 @@ -88,6 +88,8 @@ module checkpoint final :: chkp_free end type chkp_t + public :: chkp_free + contains !> Initialize checkpoint structure with mandatory data From 944357b55753036bdbf0b9ef580ee95a7790b872 Mon Sep 17 00:00:00 2001 From: Victor Baconnet Date: Tue, 23 Jul 2024 14:46:24 +0200 Subject: [PATCH 25/67] add logic for skipping lag arrays --- src/io/chkp_file.f90 | 52 +++++++++++++++++++++++++++++++------------- 1 file changed, 37 insertions(+), 15 deletions(-) diff --git a/src/io/chkp_file.f90 b/src/io/chkp_file.f90 index 475e40000d9..a7e9097bf57 100644 --- a/src/io/chkp_file.f90 +++ b/src/io/chkp_file.f90 @@ -373,7 +373,7 @@ subroutine chkp_file_read(this, data) logical :: read_lag, read_scalar, read_dtlag, read_abvel, read_scalarlag real(kind=rp) :: tol real(kind=rp) :: center_x, center_y, center_z - integer :: i, e + integer :: i, e, size_lag type(dofmap_t) :: dof call this%check_exists() @@ -499,9 +499,12 @@ subroutine chkp_file_read(this, data) center_y = center_y/u%Xh%lxyz center_z = center_z/u%Xh%lxyz do i = 1,u%dof%Xh%lxyz - x_coord(i,1,1,e) = u%dof%x(i,1,1,e) - tol*(u%dof%x(i,1,1,e)-center_x) - y_coord(i,1,1,e) = u%dof%y(i,1,1,e) - tol*(u%dof%y(i,1,1,e)-center_y) - z_coord(i,1,1,e) = u%dof%z(i,1,1,e) - tol*(u%dof%z(i,1,1,e)-center_z) + x_coord(i,1,1,e) = u%dof%x(i,1,1,e) - tol * (u%dof%x(i,1,1,e) - & + center_x) + y_coord(i,1,1,e) = u%dof%y(i,1,1,e) - tol * (u%dof%y(i,1,1,e) - & + center_y) + z_coord(i,1,1,e) = u%dof%z(i,1,1,e) - tol * (u%dof%z(i,1,1,e) - & + center_z) end do end do call this%global_interp%init(dof,tol=tol) @@ -519,11 +522,13 @@ subroutine chkp_file_read(this, data) ! Read mandatory checkpoint data ! - byte_offset = 4_i8 * int(MPI_INTEGER_SIZE,i8) + int(MPI_DOUBLE_PRECISION_SIZE,i8) + byte_offset = 4_i8 * int(MPI_INTEGER_SIZE,i8) + & + int(MPI_DOUBLE_PRECISION_SIZE,i8) byte_offset = byte_offset + & dof_offset * int(MPI_REAL_PREC_SIZE, i8) call this%read_field(fh, byte_offset, u%x, nel) - mpi_offset = 4_i8 * int(MPI_INTEGER_SIZE,i8) + int(MPI_DOUBLE_PRECISION_SIZE,i8) + mpi_offset = 4_i8 * int(MPI_INTEGER_SIZE,i8) + & + int(MPI_DOUBLE_PRECISION_SIZE,i8) mpi_offset = mpi_offset +& n_glb_dofs * int(MPI_REAL_PREC_SIZE, i8) @@ -545,26 +550,41 @@ subroutine chkp_file_read(this, data) ! ! Read optional payload ! + if (have_lag .eq. 1) then - if (read_lag) then - do i = 1, ulag%size() + ! If we have a lag, use its size, otherwise guess the size from + ! how it is currently initialized in `fluid` + if (read_lag) size_lag = ulag%size() + size_lag = 2 + + do i = 1, size_lag byte_offset = mpi_offset + & dof_offset * int(MPI_REAL_PREC_SIZE, i8) - call this%read_field(fh, byte_offset, ulag%lf(i)%x, nel) + if (read_lag) call this%read_field(fh, byte_offset, ulag%lf(i)%x, nel) mpi_offset = mpi_offset + n_glb_dofs * int(MPI_REAL_PREC_SIZE, i8) end do - do i = 1, vlag%size() + ! If we have a lag, use its size, otherwise guess the size from + ! how it is currently initialized in `fluid` + if (read_lag) size_lag = vlag%size() + size_lag = 2 + + do i = 1, size_lag byte_offset = mpi_offset + & dof_offset * int(MPI_REAL_PREC_SIZE, i8) - call this%read_field(fh, byte_offset, vlag%lf(i)%x, nel) + if (read_lag) call this%read_field(fh, byte_offset, vlag%lf(i)%x, nel) mpi_offset = mpi_offset + n_glb_dofs * int(MPI_REAL_PREC_SIZE, i8) end do - do i = 1, wlag%size() + ! If we have a lag, use its size, otherwise guess the size from + ! how it is currently initialized in `fluid` + if (read_lag) size_lag = wlag%size() + size_lag = 2 + + do i = 1, size_lag byte_offset = mpi_offset + & dof_offset * int(MPI_REAL_PREC_SIZE, i8) - call this%read_field(fh, byte_offset, wlag%lf(i)%x, nel) + if (read_lag) call this%read_field(fh, byte_offset, wlag%lf(i)%x, nel) mpi_offset = mpi_offset + n_glb_dofs * int(MPI_REAL_PREC_SIZE, i8) end do end if @@ -577,9 +597,11 @@ subroutine chkp_file_read(this, data) end if if (read_dtlag .and. have_dtlag .eq. 1) then - call MPI_File_read_at_all(fh, mpi_offset, tlag, 10, MPI_REAL_PRECISION, status, ierr) + call MPI_File_read_at_all(fh, mpi_offset, tlag, 10, & + MPI_REAL_PRECISION, status, ierr) mpi_offset = mpi_offset + 10_i8 * int(MPI_REAL_PREC_SIZE, i8) - call MPI_File_read_at_all(fh, mpi_offset, dtlag, 10, MPI_REAL_PRECISION, status, ierr) + call MPI_File_read_at_all(fh, mpi_offset, dtlag, 10, & + MPI_REAL_PRECISION, status, ierr) mpi_offset = mpi_offset + 10_i8 * int(MPI_REAL_PREC_SIZE, i8) end if From 45f59a9c71707ab3c3a842beea768915d92543f5 Mon Sep 17 00:00:00 2001 From: Victor Baconnet Date: Tue, 23 Jul 2024 14:46:47 +0200 Subject: [PATCH 26/67] print in the proper order --- src/case.f90 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/case.f90 b/src/case.f90 index cd55e19007d..13d7e186dc1 100644 --- a/src/case.f90 +++ b/src/case.f90 @@ -290,10 +290,11 @@ subroutine case_init_common(C) if (scalar) then + call json_get(C%params, 'case.scalar.initial_condition.type', string_val) + call neko_log%section("Scalar initial condition ") call neko_log%message("Type: " // trim(string_val)) - call json_get(C%params, 'case.scalar.initial_condition.type', string_val) if (trim(string_val) .ne. 'user') then call set_scalar_ic(C%scalar%s, & C%scalar%c_Xh, C%scalar%gs_Xh, string_val, C%params) From c91394fa70083d3fa95db564d492c80391a79d8e Mon Sep 17 00:00:00 2001 From: Victor Baconnet Date: Tue, 23 Jul 2024 14:46:59 +0200 Subject: [PATCH 27/67] Do not copy the fields, chkp act on them directly --- src/fluid/flow_ic.f90 | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/fluid/flow_ic.f90 b/src/fluid/flow_ic.f90 index eb5255d7e25..0dfc99b7c88 100644 --- a/src/fluid/flow_ic.f90 +++ b/src/fluid/flow_ic.f90 @@ -556,11 +556,6 @@ subroutine set_flow_ic_chkp(u, v, w, p, file_name, previous_mesh_fname, tol) f = file_t(trim(file_name)) call f%read(chkp_data) - call copy(u%x, chkp_data%u%x, u%dof%size()) - call copy(v%x, chkp_data%v%x, v%dof%size()) - call copy(w%x, chkp_data%w%x, w%dof%size()) - call copy(p%x, chkp_data%p%x, p%dof%size()) - if (NEKO_BCKND_DEVICE .eq. 1) call device_memcpy(p%x, p%x_d, p%dof%size(), & HOST_TO_DEVICE, sync = .false.) From f5b375ef0d81d50ad8199d8167b2057445a0d315 Mon Sep 17 00:00:00 2001 From: Victor Baconnet Date: Tue, 23 Jul 2024 14:47:20 +0200 Subject: [PATCH 28/67] Init with init(s,s,s,s) and do not copy --- src/scalar/scalar_ic.f90 | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/scalar/scalar_ic.f90 b/src/scalar/scalar_ic.f90 index 5518d8f9b2d..aab9aeb9792 100644 --- a/src/scalar/scalar_ic.f90 +++ b/src/scalar/scalar_ic.f90 @@ -422,17 +422,10 @@ subroutine set_scalar_ic_chkp(s, file_name, previous_mesh_fname, tol) character(len=*), intent(in), optional :: previous_mesh_fname real(kind=rp), intent(in), optional :: tol - type(field_t), pointer :: u,v,w,p type(chkp_t) :: chkp_data type(file_t) :: f, meshf - u => neko_field_registry%get_field("u") - v => neko_field_registry%get_field("v") - w => neko_field_registry%get_field("w") - p => neko_field_registry%get_field("p") - - ! Could we also init with chkp_data%init(s,s,s,s) for simplicity? - call chkp_data%init(u,v,w,p) + call chkp_data%init(s,s,s,s) call chkp_data%add_scalar(s) ! Mesh interpolation if specified @@ -448,8 +441,6 @@ subroutine set_scalar_ic_chkp(s, file_name, previous_mesh_fname, tol) f = file_t(trim(file_name)) call f%read(chkp_data) - call copy(s%x, chkp_data%s%x, s%dof%size()) - end subroutine set_scalar_ic_chkp end module scalar_ic From b0f4c175fecacfb80818fed8252802857b231b98 Mon Sep 17 00:00:00 2001 From: Victor Baconnet Date: Tue, 23 Jul 2024 14:47:37 +0200 Subject: [PATCH 29/67] update depends --- src/.depends | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/.depends b/src/.depends index 47933f86b7f..dd4ca816f46 100644 --- a/src/.depends +++ b/src/.depends @@ -195,7 +195,7 @@ fluid/mean_flow.o : fluid/mean_flow.f90 field/field.o field/mean_field.o fluid/fluid_stats.o : fluid/fluid_stats.f90 common/utils.o config/neko_config.o device/device.o common/stats_quant.o gs/gather_scatter.o field/field_list.o field/field_registry.o field/field.o sem/coef.o math/operators.o math/math.o math/mathops.o math/bcknd/device/device_mathops.o math/bcknd/device/device_math.o field/mean_field.o fluid/mean_sqr_flow.o : fluid/mean_sqr_flow.f90 field/field.o field/mean_sqr_field.o fluid/flow_profile.o : fluid/flow_profile.f90 config/num_types.o -fluid/flow_ic.o : fluid/flow_ic.f90 sem/space.o sem/interpolation.o common/global_interpolation.o sem/dofmap.o mesh/mesh.o io/file.o common/checkpoint.o io/fld_file_data.o mesh/point_zone_registry.o mesh/point_zone.o common/json_utils.o common/user_intf.o math/bcknd/device/device_math.o math/math.o sem/coef.o common/utils.o field/field.o device/device.o fluid/flow_profile.o config/neko_config.o gs/gather_scatter.o common/log.o config/num_types.o +fluid/flow_ic.o : fluid/flow_ic.f90 sem/space.o sem/interpolation.o common/global_interpolation.o io/file.o common/checkpoint.o io/fld_file_data.o mesh/point_zone_registry.o mesh/point_zone.o common/json_utils.o common/user_intf.o math/bcknd/device/device_math.o math/math.o sem/coef.o common/utils.o field/field.o device/device.o fluid/flow_profile.o config/neko_config.o gs/gather_scatter.o common/log.o config/num_types.o fluid/advection.o : fluid/advection.f90 sem/coef.o field/field.o sem/space.o config/num_types.o fluid/advection_fctry.o : fluid/advection_fctry.f90 fluid/bcknd/advection/adv_no_dealias.o fluid/bcknd/advection/adv_dealias.o fluid/advection.o common/json_utils.o sem/coef.o fluid/bcknd/advection/adv_dealias.o : fluid/bcknd/advection/adv_dealias.f90 device/device.o sem/interpolation.o math/operators.o config/neko_config.o math/bcknd/device/device_math.o sem/coef.o field/field.o sem/space.o math/math.o config/num_types.o fluid/advection.o @@ -253,7 +253,7 @@ scalar/scalar_pnpn.o : scalar/scalar_pnpn.f90 field/scratch_registry.o common/ti scalar/scalar_aux.o : scalar/scalar_aux.f90 krylov/krylov.o config/num_types.o common/log.o scalar/scalar_residual.o : scalar/scalar_residual.f90 config/num_types.o mesh/mesh.o sem/space.o bc/facet_normal.o scalar/source_scalar.o sem/coef.o field/field.o math/ax.o gs/gather_scatter.o scalar/scalar_residual_fctry.o : scalar/scalar_residual_fctry.f90 scalar/bcknd/sx/scalar_residual_sx.o scalar/bcknd/cpu/scalar_residual_cpu.o scalar/bcknd/device/scalar_residual_device.o scalar/scalar_residual.o config/neko_config.o -scalar/scalar_ic.o : scalar/scalar_ic.f90 io/file.o common/checkpoint.o io/fld_file_data.o common/log.o field/field_registry.o mesh/point_zone_registry.o mesh/point_zone.o common/json_utils.o common/user_intf.o math/math.o sem/coef.o common/utils.o field/field.o device/device.o math/bcknd/device/device_math.o config/num_types.o config/neko_config.o gs/gather_scatter.o +scalar/scalar_ic.o : scalar/scalar_ic.f90 sem/space.o sem/interpolation.o common/global_interpolation.o io/file.o common/checkpoint.o io/fld_file_data.o common/log.o field/field_registry.o mesh/point_zone_registry.o mesh/point_zone.o common/json_utils.o common/user_intf.o math/math.o sem/coef.o common/utils.o field/field.o device/device.o math/bcknd/device/device_math.o config/num_types.o config/neko_config.o gs/gather_scatter.o scalar/scalar_source_term.o : scalar/scalar_source_term.f90 common/utils.o common/user_intf.o sem/coef.o common/json_utils.o field/field_list.o field/field.o source_terms/source_term_fctry.o source_terms/source_term.o scalar/scalar_user_source_term.o config/num_types.o config/neko_config.o scalar/scalar_user_source_term.o : scalar/scalar_user_source_term.f90 sem/dofmap.o math/math.o math/bcknd/device/device_math.o device/device.o sem/coef.o field/field_list.o source_terms/source_term.o common/utils.o config/num_types.o config/neko_config.o scalar/bcknd/cpu/scalar_residual_cpu.o : scalar/bcknd/cpu/scalar_residual_cpu.f90 math/math.o math/operators.o scalar/scalar_residual.o gs/gather_scatter.o From 8773a6d856e94968410a6d5680f955a14593f882 Mon Sep 17 00:00:00 2001 From: Victor Baconnet Date: Tue, 23 Jul 2024 15:17:10 +0200 Subject: [PATCH 30/67] Add warning --- doc/pages/user-guide/case-file.md | 19 ++++++++++++++++--- src/fluid/flow_ic.f90 | 17 +++++++++++++++-- src/scalar/scalar_ic.f90 | 17 +++++++++++++++-- 3 files changed, 46 insertions(+), 7 deletions(-) diff --git a/doc/pages/user-guide/case-file.md b/doc/pages/user-guide/case-file.md index 703a9b65fa5..a4618493e82 100644 --- a/doc/pages/user-guide/case-file.md +++ b/doc/pages/user-guide/case-file.md @@ -230,10 +230,23 @@ The means of prescribing the values are controlled via the `type` keyword: - `.f*****` which refers to a single `field0.f*****` file. In this case the sample index will be extracted from the file extension, e.g. `f00012` means a sample index of `12`. + - Interpolation is supported for both `chkp` and `fld` files: + - To activate interpolation for `chkp` files, you must provide the path to + the mesh from which to interpolate with the keyword `previous_mesh`. + - To ativate interpolation for `chkp` files, you must set + `interpolate: true`. + - The default tolerance for the interpolation is `1e-6` for both file + types. + +@note When interpolating, it is recommended to use files in double precision, +which includes any `chkp` file or `fld` files that were written in double +precision. +@note To check if your `fld` file was written in double precision, run +the command `head -1 field0.f00000`. `#std 4 ...` indicates single precision, +whereas `#std 8 ...` indicates double precision. +@note To write your files in double precision, set `case.output_precision` to +`"double"`. -@note Currently interpolation is only supported with `chkp` files. `fld` files -that are loaded must match with the mesh that you are using. - ### Blasius profile The `blasius` object is used to specify the Blasius profile that can be used for the initial and inflow condition. diff --git a/src/fluid/flow_ic.f90 b/src/fluid/flow_ic.f90 index 0dfc99b7c88..1efaf6cb9f7 100644 --- a/src/fluid/flow_ic.f90 +++ b/src/fluid/flow_ic.f90 @@ -50,6 +50,7 @@ module flow_ic use point_zone, only: point_zone_t use point_zone_registry, only: neko_point_zone_registry use fld_file_data, only: fld_file_data_t + use fld_file, only: fld_file_t use checkpoint, only: chkp_t use file, only: file_t use global_interpolation, only: global_interpolation_t @@ -472,13 +473,25 @@ subroutine set_flow_ic_fld(u, v, w, p, file_name, sample_idx, & else if (interpolate) then call neko_log%warning("You have activated interpolation but you may & &still be using the same mesh.") - call neko_log%message("(do not take this into account if this & -&was done on purpose)") + call neko_log%message("(disregard if this was done on purpose)") end if ! Mesh interpolation if specified if (interpolate) then + ! Issue a warning if the mesh is in single precision + select type (ft => f%file_type) + type is (fld_file_t) + if (.not. ft%dp_precision) then + call neko_warning("Your mesh is in single precision.") + call neko_log%message("It is recommended to use a mesh in double & + &precision for better interpolation results.") + call neko_log%message("Reduce the tolerance if the interpolation & + &does not work.") + end if + class default + end select + if (present(tolerance)) then global_interp = fld_data%generate_interpolator(u%dof, u%msh, & tolerance) diff --git a/src/scalar/scalar_ic.f90 b/src/scalar/scalar_ic.f90 index aab9aeb9792..c7dcbbb49b5 100644 --- a/src/scalar/scalar_ic.f90 +++ b/src/scalar/scalar_ic.f90 @@ -49,6 +49,7 @@ module scalar_ic use field_registry, only: neko_field_registry use logger, only: neko_log, LOG_SIZE use fld_file_data, only: fld_file_data_t + use fld_file, only: fld_file_t use checkpoint, only: chkp_t use file, only: file_t use global_interpolation, only: global_interpolation_t @@ -375,13 +376,25 @@ subroutine set_scalar_ic_fld(s, file_name, sample_idx, & else if (interpolate) then call neko_log%warning("You have activated interpolation but you may & &still be using the same mesh.") - call neko_log%message("(do not take this into account if this & -&was done on purpose)") + call neko_log%message("(disregard if this was done on purpose)") end if ! Mesh interpolation if specified if (interpolate) then + ! Issue a warning if the mesh is in single precision + select type (ft => f%file_type) + type is (fld_file_t) + if (.not. ft%dp_precision) then + call neko_warning("Your mesh is in single precision.") + call neko_log%message("It is recommended to use a mesh in double & + &precision for better interpolation results.") + call neko_log%message("Reduce the tolerance if the interpolation & + &does not work.") + end if + class default + end select + if (present(tolerance)) then global_interp = fld_data%generate_interpolator(s%dof, s%msh, tolerance) else From 79b2e01e88e9ea244ae21a67587c5b8be568ece8 Mon Sep 17 00:00:00 2001 From: Victor Baconnet Date: Tue, 23 Jul 2024 17:27:01 +0200 Subject: [PATCH 31/67] reformat to use mesh file path directly --- doc/pages/user-guide/case-file.md | 54 +++++----- src/fluid/flow_ic.f90 | 97 ++++++++++++------ src/scalar/scalar_ic.f90 | 162 +++++++++++++++++++----------- 3 files changed, 200 insertions(+), 113 deletions(-) diff --git a/doc/pages/user-guide/case-file.md b/doc/pages/user-guide/case-file.md index a4618493e82..92427873449 100644 --- a/doc/pages/user-guide/case-file.md +++ b/doc/pages/user-guide/case-file.md @@ -217,35 +217,39 @@ The means of prescribing the values are controlled via the `type` keyword: 5. `field`, where the initial condition is retrieved from an output field file provided by the `file_name` keyword. Supported file types are: - - `.chkp`, with mesh to mesh interpolation where the mesh from which to - interpolate is given by the `previous_mesh` keyword (and tolerance for - interpolation by the keyword `tolerance`). + - `.chkp` files. To interpolate a `chkp` file, use the `previous_mesh` + keyword to provide the mesh from which to interpolate. - `.fld`, `.nek5000` that refer to a series of `.f*****` files, where the - index of the file to use is provided by the `sample_index` keyword. For - example, in a series of 3 files `field0.f00000, field0.f00001, - field0.f00002`, `sample_index` can take values `0`,`1` or `2`. In this - case we would set `"file_name" = "field0.fld"`. If no `sample_index` is - provided, and a `field0.nek5000` file exists, the last field file in the - series will be used by default. + index of the file to use is provided by the `sample_index` keyword. + - For example, in a series of 3 files `field0.f00000, field0.f00001, + field0.f00002`, `sample_index` can take values `0`,`1` or `2`. In this + case we would set `"file_name" = "field0.fld"`. + - If no `sample_index` is + provided, and a `field0.nek5000` file exists, the last field file in the + series will be used by default. - `.f*****` which refers to a single `field0.f*****` file. In this case the sample index will be extracted from the file extension, e.g. `f00012` means a sample index of `12`. - - Interpolation is supported for both `chkp` and `fld` files: - - To activate interpolation for `chkp` files, you must provide the path to - the mesh from which to interpolate with the keyword `previous_mesh`. - - To ativate interpolation for `chkp` files, you must set - `interpolate: true`. - - The default tolerance for the interpolation is `1e-6` for both file - types. - -@note When interpolating, it is recommended to use files in double precision, -which includes any `chkp` file or `fld` files that were written in double -precision. -@note To check if your `fld` file was written in double precision, run -the command `head -1 field0.f00000`. `#std 4 ...` indicates single precision, -whereas `#std 8 ...` indicates double precision. -@note To write your files in double precision, set `case.output_precision` to -`"double"`. + - **Interpolation** for `fld`, `nek5000` and `f*****` files is activated by + setting the keyword `interpolate` to `true`. + - Note that the tolerance + for interpolation defaults to `1e-6`, but can otherwise be changed by the + keyword `tolerance`. + - The coordinates are retrieved by default from the first file in the + `fld` series. If the coordinates are located in another file, you can + indicate the path to that file with `mesh_file_name`. If the coordinates + are located at a different index in the `fld` series, you can indicate + that index with `sample_mesh_index`. Note that `mesh_file_name` takes + precedence over `sample_mesh_index`. + + @note When interpolating, it is recommended to use files in double precision, + which includes any `chkp` file or `fld` files that were written in double + precision. To check if your `fld` file was written in double precision, run + the command `head -1 field0.f00000`. `#std 4 ...` indicates single precision, + whereas `#std 8 ...` indicates double precision. + @attention Neko write single precision `fld` files by default. To write your + files in double precision, set `case.output_precision` to + `"double"`. ### Blasius profile The `blasius` object is used to specify the Blasius profile that can be used for the diff --git a/src/fluid/flow_ic.f90 b/src/fluid/flow_ic.f90 index 1efaf6cb9f7..d2e95e94273 100644 --- a/src/fluid/flow_ic.f90 +++ b/src/fluid/flow_ic.f90 @@ -40,7 +40,8 @@ module flow_ic blasius_quadratic, blasius_quartic, blasius_sin use device, only: device_memcpy, HOST_TO_DEVICE use field, only : field_t - use utils, only : neko_error, filename_suffix, filename_chsuffix, neko_warning + use utils, only : neko_error, filename_suffix, filename_chsuffix, & + neko_warning, NEKO_FNAME_LEN use coefs, only : coef_t use math, only : col2, cfill, cfill_mask, copy use device_math, only : device_col2, device_cfill, device_cfill_mask @@ -80,9 +81,9 @@ subroutine set_flow_ic_int(u, v, w, p, coef, gs, type, params) real(kind=rp) :: delta, tol real(kind=rp), allocatable :: uinf(:) real(kind=rp), allocatable :: zone_value(:) - character(len=:), allocatable :: read_str, prev_mesh + character(len=:), allocatable :: read_str character(len=80) :: suffix - character(len=1024) :: new_fname + character(len=NEKO_FNAME_LEN) :: fname, prev_mesh integer :: sample_idx, fpos, sample_mesh_idx logical :: found_previous_mesh, interpolate character(len=LOG_SIZE) :: log_buf @@ -144,29 +145,32 @@ subroutine set_flow_ic_int(u, v, w, p, coef, gs, type, params) call json_get(params, 'case.fluid.initial_condition.file_name', & read_str) - call filename_suffix(read_str, suffix) - call neko_log%message("File name: " // trim(read_str)) + fname = trim(read_str) + call filename_suffix(fname, suffix) + call neko_log%message("File name: " // trim(fname)) if (trim(suffix) .eq. "chkp") then ! Look for parameters for interpolation call params%get("case.fluid.initial_condition.previous_mesh", & - prev_mesh, found_previous_mesh) + read_str, found_previous_mesh) + ! Get tolerance for potential interpolation call json_get_or_default(params, & 'case.fluid.initial_condition.tolerance', tol, 1d-6) if (found_previous_mesh) then + prev_mesh = trim(read_str) call neko_log%message("Previous mesh: " // trim(prev_mesh)) write (log_buf, '(A,E15.7)') "Tolerance : ", tol call neko_log%message(log_buf) end if if (found_previous_mesh) then - call set_flow_ic_chkp(u, v, w, p, read_str, & + call set_flow_ic_chkp(u, v, w, p, fname, & previous_mesh_fname = prev_mesh, tol = tol) else - call set_flow_ic_chkp(u, v, w, p, read_str) + call set_flow_ic_chkp(u, v, w, p, fname) end if else !if it's not a chkp we assume it's a fld file @@ -193,7 +197,7 @@ subroutine set_flow_ic_int(u, v, w, p, coef, gs, type, params) read (suffix(2:), "(I5.5)") sample_idx end if - call filename_chsuffix(read_str, read_str, 'fld') + call filename_chsuffix(fname, fname, 'fld') end if @@ -207,22 +211,51 @@ subroutine set_flow_ic_int(u, v, w, p, coef, gs, type, params) call json_get_or_default(params, & 'case.fluid.initial_condition.tolerance', tol, 1d-6) - ! Get the index of the file that contains the mesh + ! Attempt to find a path to where the coordinates are written call json_get_or_default(params, & - 'case.fluid.initial_condition.sample_mesh_index', & - sample_mesh_idx, 0) + 'case.fluid.initial_condition.mesh_file_name', read_str, & + "none") + + if (trim(read_str) .eq. "none") then + ! If no mesh file is provided, try to get the index of the + ! file that contains the mesh + call json_get_or_default(params, & + 'case.fluid.initial_condition.sample_mesh_index', & + sample_mesh_idx, 0) + + prev_mesh = trim(fname) + + else + + prev_mesh = trim(read_str) + + ! If we gave a mesh file, we extract the sample index + call filename_suffix(prev_mesh, suffix) + if (trim(suffix) .eq. "fld" .or. trim(suffix) .eq. "nek5000") & + call neko_error("The field file with the mesh must be in & +&the format .f*****") + + fpos = scan(suffix, 'f') + if (fpos .eq. 1) then + read (suffix(2:), "(I5.5)") sample_mesh_idx + else + call neko_error("The mesh file must be of type .f*****") + end if + + call filename_chsuffix(prev_mesh, prev_mesh, 'fld') + end if if (interpolate) then - call neko_log%message("Interpolation : yes") - write (log_buf, '(A,E15.7)') "Tolerance : ", tol - call neko_log%message(log_buf) - write (log_buf, '(A,I5)') "Mesh sample index: ", & - sample_mesh_idx + call neko_log%message("Interpolation : yes") + write (log_buf, '(A,E15.7)') "Tolerance : ", tol call neko_log%message(log_buf) + call neko_log%message("Coordinates file : " // & + trim(prev_mesh)) end if - call set_flow_ic_fld(u, v, w, p, read_str, sample_idx, interpolate, & - tolerance = tol, sample_mesh_idx = sample_mesh_idx) + call set_flow_ic_fld(u, v, w, p, fname, sample_idx, interpolate, & + tolerance = tol, sample_mesh_idx = sample_mesh_idx, & + previous_mesh_file_name = prev_mesh) end if ! if suffix .eq. chkp @@ -402,7 +435,7 @@ end subroutine set_flow_ic_point_zone !! @param sample_idx index of the field file .f000* to read, default is !! -1.. subroutine set_flow_ic_fld(u, v, w, p, file_name, sample_idx, & - interpolate, tolerance, sample_mesh_idx) + interpolate, tolerance, sample_mesh_idx, previous_mesh_file_name) type(field_t), intent(inout) :: u type(field_t), intent(inout) :: v type(field_t), intent(inout) :: w @@ -412,6 +445,7 @@ subroutine set_flow_ic_fld(u, v, w, p, file_name, sample_idx, & logical, intent(in) :: interpolate real(kind=rp), intent(in), optional :: tolerance integer, intent(in), optional :: sample_mesh_idx + character(len=*), intent(in), optional :: previous_mesh_file_name type(fld_file_data_t) :: fld_data type(file_t) :: f @@ -444,15 +478,19 @@ subroutine set_flow_ic_fld(u, v, w, p, file_name, sample_idx, & end if else - ! in this case we specify an fld file to read, so we - ! read only that file except if we need to interpolate. - ! Interpolation requires to first read the file that contains - ! x,y,z values, which is assumed to be the file with index 0 - ! unless specified. The existence of x,y,z coordinates will - ! be checked later anyways as a safeguard. - if (interpolate .and. sample_mesh_idx .ne. sample_idx) then - call f%set_counter(sample_mesh_idx) + + if (interpolate) then + + f = file_t(trim(previous_mesh_file_name)) + + ! Only set the counter if its not the exact same file, this + ! is to prevent reading the same file twice + if (trim(previous_mesh_file_name) .eq. trim(file_name) .and. & + sample_mesh_idx .ne. sample_idx) & + call f%set_counter(sample_mesh_idx) + call f%read(fld_data) + f = file_t(trim(file_name)) end if call f%set_counter(sample_idx) @@ -483,7 +521,8 @@ subroutine set_flow_ic_fld(u, v, w, p, file_name, sample_idx, & select type (ft => f%file_type) type is (fld_file_t) if (.not. ft%dp_precision) then - call neko_warning("Your mesh is in single precision.") + call neko_warning("The coordinates read from the field file are & +&in single precision.") call neko_log%message("It is recommended to use a mesh in double & &precision for better interpolation results.") call neko_log%message("Reduce the tolerance if the interpolation & diff --git a/src/scalar/scalar_ic.f90 b/src/scalar/scalar_ic.f90 index c7dcbbb49b5..7be561e67d2 100644 --- a/src/scalar/scalar_ic.f90 +++ b/src/scalar/scalar_ic.f90 @@ -38,7 +38,8 @@ module scalar_ic use device_math, only : device_col2 use device, only : device_memcpy, HOST_TO_DEVICE use field, only : field_t - use utils, only : neko_error, filename_chsuffix, filename_suffix, neko_warning + use utils, only : neko_error, filename_chsuffix, filename_suffix, & + neko_warning, NEKO_FNAME_LEN use coefs, only : coef_t use math, only : col2, cfill, cfill_mask, copy use user_intf, only : useric_scalar @@ -84,8 +85,9 @@ subroutine set_scalar_ic_int(s, coef, gs, type, params) ! Variables for retrieving JSON parameters real(kind=rp) :: ic_value - character(len=:), allocatable :: read_str, prev_mesh + character(len=:), allocatable :: read_str character(len=80) :: suffix + character(len=NEKO_FNAME_LEN) :: fname, prev_mesh real(kind=rp) :: zone_value, tol logical :: found, found_previous_mesh, interpolate integer :: sample_idx, fpos, sample_mesh_idx @@ -120,29 +122,32 @@ subroutine set_scalar_ic_int(s, coef, gs, type, params) call json_get(params, 'case.scalar.initial_condition.file_name', & read_str) - call filename_suffix(read_str, suffix) - call neko_log%message("File name: " // trim(read_str)) + fname = trim(read_str) + call filename_suffix(fname, suffix) + call neko_log%message("File name: " // trim(fname)) if (trim(suffix) .eq. "chkp") then ! Look for parameters for interpolation call params%get("case.scalar.initial_condition.previous_mesh", & - prev_mesh, found_previous_mesh) + read_str, found_previous_mesh) + ! Get tolerance for potential interpolation call json_get_or_default(params, & 'case.scalar.initial_condition.tolerance', tol, 1d-6) if (found_previous_mesh) then + prev_mesh = trim(read_str) call neko_log%message("Previous mesh: " // trim(prev_mesh)) write (log_buf, '(A,E15.7)') "Tolerance : ", tol call neko_log%message(log_buf) end if if (found_previous_mesh) then - call set_scalar_ic_chkp(s, read_str, & + call set_scalar_ic_chkp(s, fname, & previous_mesh_fname = prev_mesh, tol = tol) else - call set_scalar_ic_chkp(s, read_str) + call set_scalar_ic_chkp(s, fname) end if else !if it's not a chkp we assume it's a fld file @@ -169,7 +174,7 @@ subroutine set_scalar_ic_int(s, coef, gs, type, params) read (suffix(2:), "(I5.5)") sample_idx end if - call filename_chsuffix(read_str, read_str, 'fld') + call filename_chsuffix(fname, fname, 'fld') end if @@ -188,17 +193,51 @@ subroutine set_scalar_ic_int(s, coef, gs, type, params) 'case.scalar.initial_condition.sample_mesh_index', & sample_mesh_idx, 0) + ! Attempt to find a path to where the coordinates are written + call json_get_or_default(params, & + 'case.scalar.initial_condition.mesh_file_name', read_str, & + "none") + + if (trim(read_str) .eq. "none") then + ! If no mesh file is provided, try to get the index of the + ! file that contains the mesh + call json_get_or_default(params, & + 'case.scalar.initial_condition.sample_mesh_index', & + sample_mesh_idx, 0) + + prev_mesh = trim(fname) + + else + + prev_mesh = trim(read_str) + + ! If we gave a mesh file, we extract the sample index + call filename_suffix(prev_mesh, suffix) + if (trim(suffix) .eq. "fld" .or. trim(suffix) .eq. "nek5000") & + call neko_error("The field file with the mesh must be in & +&the format .f*****") + + fpos = scan(suffix, 'f') + if (fpos .eq. 1) then + read (suffix(2:), "(I5.5)") sample_mesh_idx + else + call neko_error("The mesh file must be of type .f*****") + end if + + call filename_chsuffix(prev_mesh, prev_mesh, 'fld') + end if + if (interpolate) then call neko_log%message("Interpolation : yes") write (log_buf, '(A,E15.7)') "Tolerance : ", tol call neko_log%message(log_buf) - write (log_buf, '(A,I5)') "Mesh sample index: ", & - sample_mesh_idx - call neko_log%message(log_buf) + call neko_log%message("Coordinates file:" // & + trim(prev_mesh)) end if - call set_scalar_ic_fld(s, read_str, sample_idx, interpolate, & - tolerance = tol, sample_mesh_idx = sample_mesh_idx) + call set_scalar_ic_fld(s, fname, sample_idx, interpolate, & + tolerance = tol, sample_mesh_idx = sample_mesh_idx, & + previous_mesh_file_name = prev_mesh) end if ! if suffix .eq. chkp @@ -308,13 +347,14 @@ end subroutine set_scalar_ic_point_zone !! @param sample_idx index of the field file .f000* to read, default is !! -1.. subroutine set_scalar_ic_fld(s, file_name, sample_idx, & - interpolate, tolerance, sample_mesh_idx) + interpolate, tolerance, sample_mesh_idx, previous_mesh_file_name) type(field_t), intent(inout) :: s character(len=*), intent(in) :: file_name integer, intent(in) :: sample_idx logical, intent(in) :: interpolate real(kind=rp), intent(in), optional :: tolerance integer, intent(in), optional :: sample_mesh_idx + character(len=*), intent(in), optional :: previous_mesh_file_name type(fld_file_data_t) :: fld_data type(file_t) :: f @@ -347,16 +387,20 @@ subroutine set_scalar_ic_fld(s, file_name, sample_idx, & end if else - ! in this case we specify an fld file to read, so we - ! read only that file except if we need to interpolate. - ! Interpolation requires to first read the file that contains - ! x,y,z values, which is assumed to be the file with index 0 - ! unless specified. The existence of x,y,z coordinates will - ! be checked later anyways as a safeguard. - if (interpolate .and. sample_mesh_idx .ne. sample_idx) then - call f%set_counter(sample_mesh_idx) + + if (interpolate) then + + f = file_t(trim(previous_mesh_file_name)) + + ! Only set the counter if its not the exact same file, this + ! is to prevent reading the same file twice + if (trim(previous_mesh_file_name) .eq. trim(file_name) .and. & + sample_mesh_idx .ne. sample_idx) & + call f%set_counter(sample_mesh_idx) + call f%read(fld_data) - end if + f = file_t(trim(file_name)) + end if ! interpolate call f%set_counter(sample_idx) call f%read(fld_data) @@ -372,21 +416,21 @@ subroutine set_scalar_ic_fld(s, file_name, sample_idx, & if ( fld_data%glb_nelv .ne. s%msh%glb_nelv .and. & .not. interpolate) then call neko_error("The fld file must match the current mesh! & -&Use 'interpolate': 'true' to enable interpolation.") + &Use 'interpolate': 'true' to enable interpolation.") else if (interpolate) then call neko_log%warning("You have activated interpolation but you may & -&still be using the same mesh.") + &still be using the same mesh.") call neko_log%message("(disregard if this was done on purpose)") end if ! Mesh interpolation if specified if (interpolate) then - ! Issue a warning if the mesh is in single precision select type (ft => f%file_type) type is (fld_file_t) if (.not. ft%dp_precision) then - call neko_warning("Your mesh is in single precision.") + call neko_warning("The coordinates read from the field file are & + &in single precision.") call neko_log%message("It is recommended to use a mesh in double & &precision for better interpolation results.") call neko_log%message("Reduce the tolerance if the interpolation & @@ -395,48 +439,48 @@ subroutine set_scalar_ic_fld(s, file_name, sample_idx, & class default end select - if (present(tolerance)) then - global_interp = fld_data%generate_interpolator(s%dof, s%msh, tolerance) - else - call neko_error("No tolerance provided for the interpolation.") - end if + if (present(tolerance)) then + global_interp = fld_data%generate_interpolator(s%dof, s%msh, tolerance) + else + call neko_error("No tolerance provided for the interpolation.") + end if - ! Evaluate scalar - call global_interp%evaluate(s%x, fld_data%t%x) - call global_interp%free + ! Evaluate scalar + call global_interp%evaluate(s%x, fld_data%t%x) + call global_interp%free - else ! No interpolation + else ! No interpolation - ! Build a space_t object from the data in the fld file - call prev_Xh%init(GLL, fld_data%lx, fld_data%ly, fld_data%lz) - call space_interp%init(s%Xh, prev_Xh) + ! Build a space_t object from the data in the fld file + call prev_Xh%init(GLL, fld_data%lx, fld_data%ly, fld_data%lz) + call space_interp%init(s%Xh, prev_Xh) - call space_interp%map_host(s%x, fld_data%t%x, fld_data%nelv, s%Xh) + call space_interp%map_host(s%x, fld_data%t%x, fld_data%nelv, s%Xh) - call space_interp%free + call space_interp%free - end if + end if - call fld_data%free + call fld_data%free - end subroutine set_scalar_ic_fld +end subroutine set_scalar_ic_fld - !> Set the initial condition of the flow based on a point zone. - !! @details The initial condition is set to the base value and then the - !! zone is filled with the zone value. - !! @param s The scalar field. - !! @param file_name The name of the checkpoint file. - !! @param previous_mesh If specified, the name of the previouos mesh from - !! which to interpolate. - !! @param tol If specified, tolerance to use for the mesh interpolation. - subroutine set_scalar_ic_chkp(s, file_name, previous_mesh_fname, tol) - type(field_t), intent(inout) :: s - character(len=*), intent(in) :: file_name - character(len=*), intent(in), optional :: previous_mesh_fname - real(kind=rp), intent(in), optional :: tol +!> Set the initial condition of the flow based on a point zone. +!! @details The initial condition is set to the base value and then the +!! zone is filled with the zone value. +!! @param s The scalar field. +!! @param file_name The name of the checkpoint file. +!! @param previous_mesh If specified, the name of the previouos mesh from +!! which to interpolate. +!! @param tol If specified, tolerance to use for the mesh interpolation. +subroutine set_scalar_ic_chkp(s, file_name, previous_mesh_fname, tol) + type(field_t), intent(inout) :: s + character(len=*), intent(in) :: file_name + character(len=*), intent(in), optional :: previous_mesh_fname + real(kind=rp), intent(in), optional :: tol - type(chkp_t) :: chkp_data - type(file_t) :: f, meshf + type(chkp_t) :: chkp_data + type(file_t) :: f, meshf call chkp_data%init(s,s,s,s) call chkp_data%add_scalar(s) From 4777d23be07294490946956f274b121520103271 Mon Sep 17 00:00:00 2001 From: Victor Baconnet Date: Tue, 23 Jul 2024 17:31:06 +0200 Subject: [PATCH 32/67] remove call to neko error --- src/io/fld_file_data.f90 | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/io/fld_file_data.f90 b/src/io/fld_file_data.f90 index 73ee3dc91a9..98f2cd1fedf 100644 --- a/src/io/fld_file_data.f90 +++ b/src/io/fld_file_data.f90 @@ -262,10 +262,6 @@ function fld_file_data_generate_interpolator(this, to_dof, & call global_interp%init(fld_dof, tol = tolerance, Xh = fld_Xh, & msh = fld_empty_mesh) - ! Note that to_dof%size() should be equal to - ! to_msh%nelv * to_Xh%lxyz - if (to_dof%size() .ne. to_msh%nelv*to_Xh%lxyz) & - call neko_error("something weird happening") call global_interp%find_points(x_coords, y_coords, z_coords, & to_dof%size()) From 3b6a59bc6a7d4ece65c99bc33c60db8ddfb5a0f7 Mon Sep 17 00:00:00 2001 From: Victor Baconnet Date: Mon, 29 Jul 2024 11:56:35 +0200 Subject: [PATCH 33/67] move to xyz instead of dof --- src/simulation_components/probes.F90 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/simulation_components/probes.F90 b/src/simulation_components/probes.F90 index 90456873c93..bde534694f9 100644 --- a/src/simulation_components/probes.F90 +++ b/src/simulation_components/probes.F90 @@ -470,7 +470,8 @@ subroutine probes_init_from_attributes(this, dof, output_file) type(matrix_t) :: mat_coords !> Init interpolator - call this%global_interp%init(dof) + call this%global_interp%init(dof%x(:,1,1,1), dof%y(:,1,1,1), & + dof%z(:,1,1,1), dof%msh%gdim, dof%msh%nelv, dof%Xh) !> find probes and redistribute them call this%global_interp%find_points_and_redist(this%xyz, this%n_local_probes) From 15e25565a9b1e16d77424af5690b157d539dac93 Mon Sep 17 00:00:00 2001 From: Victor Baconnet Date: Mon, 29 Jul 2024 12:31:15 +0200 Subject: [PATCH 34/67] move away from dof in glb interp --- src/.depends | 6 +- src/common/global_interpolation.F90 | 101 ++++++++++++++------------- src/io/chkp_file.f90 | 3 +- src/io/fld_file_data.f90 | 15 +--- src/sem/dofmap.f90 | 43 +----------- src/simulation_components/probes.F90 | 2 +- 6 files changed, 61 insertions(+), 109 deletions(-) diff --git a/src/.depends b/src/.depends index dd4ca816f46..766c8f42659 100644 --- a/src/.depends +++ b/src/.depends @@ -123,7 +123,7 @@ io/fluid_stats_output.o : io/fluid_stats_output.f90 io/output.o device/device.o io/mean_sqr_flow_output.o : io/mean_sqr_flow_output.f90 io/output.o config/num_types.o fluid/mean_sqr_flow.o io/data_streamer.o : io/data_streamer.F90 config/neko_config.o comm/mpi_types.o comm/comm.o device/device.o common/utils.o sem/coef.o field/field.o config/num_types.o common/sampler.o : common/sampler.f90 common/time_based_controller.o config/num_types.o common/profiler.o common/utils.o common/log.o comm/comm.o io/fld_file.o io/output.o -common/global_interpolation.o : common/global_interpolation.F90 comm/mpi_types.o math/math.o comm/comm.o sem/local_interpolation.o common/utils.o common/log.o mesh/mesh.o sem/dofmap.o sem/space.o config/num_types.o +common/global_interpolation.o : common/global_interpolation.F90 common/structs.o comm/mpi_types.o math/math.o comm/comm.o sem/local_interpolation.o common/utils.o common/log.o sem/space.o config/num_types.o common/profiler.o : common/profiler.F90 common/craypat.o device/hip/roctx.o device/cuda/nvtx.o device/device.o config/neko_config.o common/craypat.o : common/craypat.F90 common/utils.o adt/stack.o bc/bc.o : bc/bc.f90 common/utils.o adt/tuple.o adt/stack.o mesh/facet_zone.o mesh/mesh.o sem/space.o sem/coef.o sem/dofmap.o device/device.o config/num_types.o config/neko_config.o @@ -195,7 +195,7 @@ fluid/mean_flow.o : fluid/mean_flow.f90 field/field.o field/mean_field.o fluid/fluid_stats.o : fluid/fluid_stats.f90 common/utils.o config/neko_config.o device/device.o common/stats_quant.o gs/gather_scatter.o field/field_list.o field/field_registry.o field/field.o sem/coef.o math/operators.o math/math.o math/mathops.o math/bcknd/device/device_mathops.o math/bcknd/device/device_math.o field/mean_field.o fluid/mean_sqr_flow.o : fluid/mean_sqr_flow.f90 field/field.o field/mean_sqr_field.o fluid/flow_profile.o : fluid/flow_profile.f90 config/num_types.o -fluid/flow_ic.o : fluid/flow_ic.f90 sem/space.o sem/interpolation.o common/global_interpolation.o io/file.o common/checkpoint.o io/fld_file_data.o mesh/point_zone_registry.o mesh/point_zone.o common/json_utils.o common/user_intf.o math/bcknd/device/device_math.o math/math.o sem/coef.o common/utils.o field/field.o device/device.o fluid/flow_profile.o config/neko_config.o gs/gather_scatter.o common/log.o config/num_types.o +fluid/flow_ic.o : fluid/flow_ic.f90 sem/space.o sem/interpolation.o common/global_interpolation.o io/file.o common/checkpoint.o io/fld_file.o io/fld_file_data.o mesh/point_zone_registry.o mesh/point_zone.o common/json_utils.o common/user_intf.o math/bcknd/device/device_math.o math/math.o sem/coef.o common/utils.o field/field.o device/device.o fluid/flow_profile.o config/neko_config.o gs/gather_scatter.o common/log.o config/num_types.o fluid/advection.o : fluid/advection.f90 sem/coef.o field/field.o sem/space.o config/num_types.o fluid/advection_fctry.o : fluid/advection_fctry.f90 fluid/bcknd/advection/adv_no_dealias.o fluid/bcknd/advection/adv_dealias.o fluid/advection.o common/json_utils.o sem/coef.o fluid/bcknd/advection/adv_dealias.o : fluid/bcknd/advection/adv_dealias.f90 device/device.o sem/interpolation.o math/operators.o config/neko_config.o math/bcknd/device/device_math.o sem/coef.o field/field.o sem/space.o math/math.o config/num_types.o fluid/advection.o @@ -253,7 +253,7 @@ scalar/scalar_pnpn.o : scalar/scalar_pnpn.f90 field/scratch_registry.o common/ti scalar/scalar_aux.o : scalar/scalar_aux.f90 krylov/krylov.o config/num_types.o common/log.o scalar/scalar_residual.o : scalar/scalar_residual.f90 config/num_types.o mesh/mesh.o sem/space.o bc/facet_normal.o scalar/source_scalar.o sem/coef.o field/field.o math/ax.o gs/gather_scatter.o scalar/scalar_residual_fctry.o : scalar/scalar_residual_fctry.f90 scalar/bcknd/sx/scalar_residual_sx.o scalar/bcknd/cpu/scalar_residual_cpu.o scalar/bcknd/device/scalar_residual_device.o scalar/scalar_residual.o config/neko_config.o -scalar/scalar_ic.o : scalar/scalar_ic.f90 sem/space.o sem/interpolation.o common/global_interpolation.o io/file.o common/checkpoint.o io/fld_file_data.o common/log.o field/field_registry.o mesh/point_zone_registry.o mesh/point_zone.o common/json_utils.o common/user_intf.o math/math.o sem/coef.o common/utils.o field/field.o device/device.o math/bcknd/device/device_math.o config/num_types.o config/neko_config.o gs/gather_scatter.o +scalar/scalar_ic.o : scalar/scalar_ic.f90 sem/space.o sem/interpolation.o common/global_interpolation.o io/file.o common/checkpoint.o io/fld_file.o io/fld_file_data.o common/log.o field/field_registry.o mesh/point_zone_registry.o mesh/point_zone.o common/json_utils.o common/user_intf.o math/math.o sem/coef.o common/utils.o field/field.o device/device.o math/bcknd/device/device_math.o config/num_types.o config/neko_config.o gs/gather_scatter.o scalar/scalar_source_term.o : scalar/scalar_source_term.f90 common/utils.o common/user_intf.o sem/coef.o common/json_utils.o field/field_list.o field/field.o source_terms/source_term_fctry.o source_terms/source_term.o scalar/scalar_user_source_term.o config/num_types.o config/neko_config.o scalar/scalar_user_source_term.o : scalar/scalar_user_source_term.f90 sem/dofmap.o math/math.o math/bcknd/device/device_math.o device/device.o sem/coef.o field/field_list.o source_terms/source_term.o common/utils.o config/num_types.o config/neko_config.o scalar/bcknd/cpu/scalar_residual_cpu.o : scalar/bcknd/cpu/scalar_residual_cpu.f90 math/math.o math/operators.o scalar/scalar_residual.o gs/gather_scatter.o diff --git a/src/common/global_interpolation.F90 b/src/common/global_interpolation.F90 index 8efff2d909c..8c0e15617f3 100644 --- a/src/common/global_interpolation.F90 +++ b/src/common/global_interpolation.F90 @@ -38,24 +38,29 @@ module global_interpolation use num_types, only: rp use space, only: space_t - use dofmap, only: dofmap_t - use mesh, only: mesh_t use logger, only: neko_log, LOG_SIZE use utils, only: neko_error, neko_warning use local_interpolation use comm use math, only: copy use neko_mpi_types + use structs, only: array_ptr_t use, intrinsic :: iso_c_binding implicit none private !> Implements global interpolation for arbitrary points in the domain. type, public :: global_interpolation_t - !> Dofmap from which we interpolate the points - type(dofmap_t), pointer :: dof - !> Mesh on which we interpolate - type(mesh_t), pointer :: mesh - !> Space + !> X coordinates from which to interpolate + type(array_ptr_t) :: x + !> Y coordinates from which to interpolate + type(array_ptr_t) :: y + !> Z coordinates from which to interpolate + type(array_ptr_t) :: z + !> Geometric dimension of the simulation + integer :: gdim + !> Number of elements + integer :: nelv + !> Space from which to interpolate type(space_t), pointer :: Xh !> Interpolator for local points type(local_interpolator_t) :: local_interp @@ -114,43 +119,37 @@ module global_interpolation !! @param tol Tolerance for Newton iterations. !! @param Xh Space on which to interpolate. !! @param msh Mesh on which to interp - subroutine global_interpolation_init(this, dof, tol, Xh, msh) + subroutine global_interpolation_init(this, x, y, z, gdim, nelv, Xh, tol) class(global_interpolation_t), intent(inout) :: this - type(dofmap_t), target :: dof + real(kind=rp), intent(in), target :: x(:) + real(kind=rp), intent(in), target :: y(:) + real(kind=rp), intent(in), target :: z(:) + integer, intent(in) :: gdim + integer, intent(in) :: nelv + type(space_t), intent(in), target :: Xh real(kind=rp), intent(in), optional :: tol - type(space_t), intent(in), target, optional :: Xh - type(mesh_t), intent(in), target, optional :: msh - integer :: lx, ly, lz, nelv, max_pts_per_iter + integer :: lx, ly, lz, max_pts_per_iter - this%dof => dof - - if (present(Xh)) then - this%Xh => Xh - else - this%Xh => dof%Xh - end if - - if (present(msh)) then - this%mesh => msh - else - this%mesh => dof%msh - end if +#ifdef HAVE_GSLIB + this%x%ptr => x + this%y%ptr => y + this%z%ptr => z + this%gdim = gdim + this%nelv = nelv + this%Xh => Xh if (present(tol)) this%tol = tol -#ifdef HAVE_GSLIB - - lx = this%Xh%lx - ly = this%Xh%ly - lz = this%Xh%lz - nelv = this%mesh%nelv - !Number of points to iterate on simultaneosuly + ! Number of points to iterate on simultaneosuly max_pts_per_iter = 128 + lx = Xh%lx + ly = Xh%ly + lz = Xh%lz call fgslib_findpts_setup(this%gs_handle, & NEKO_COMM, pe_size, & - this%mesh%gdim, & - dof%x, dof%y, dof%z, & ! Physical nodal values + this%gdim, & + this%x%ptr, this%y%ptr, this%z%ptr, & ! Physical nodal values lx, ly, lz, nelv, & ! Mesh dimensions 2*lx, 2*ly, 2*lz, & ! Mesh size for bounding box computation 0.01, & ! relative size to expand bounding boxes by @@ -168,10 +167,14 @@ end subroutine global_interpolation_init subroutine global_interpolation_free(this) class(global_interpolation_t), intent(inout) :: this - nullify(this%mesh) - nullify(this%dof) + nullify(this%x%ptr) + nullify(this%y%ptr) + nullify(this%z%ptr) nullify(this%Xh) + this%nelv = 0 + this%gdim = 0 + call this%free_points() #ifdef HAVE_GSLIB @@ -223,11 +226,11 @@ subroutine global_interpolation_find_common(this) this%error_code, 1, & this%proc_owner, 1, & this%el_owner, 1, & - this%rst, this%mesh%gdim, & + this%rst, this%gdim, & this%dist2, 1, & - this%xyz(1,1), this%mesh%gdim, & - this%xyz(2,1), this%mesh%gdim, & - this%xyz(3,1), this%mesh%gdim, this%n_points) + this%xyz(1,1), this%gdim, & + this%xyz(2,1), this%gdim, & + this%xyz(3,1), this%gdim, this%n_points) do i = 1 , this%n_points @@ -264,20 +267,20 @@ subroutine global_interpolation_find_common(this) call fgslib_findpts_eval(this%gs_handle, x_check, & 1, this%error_code, 1, & this%proc_owner, 1, this%el_owner, 1, & - this%rst, this%mesh%gdim, & - this%n_points, this%dof%x) + this%rst, this%gdim, & + this%n_points, this%x%ptr) call fgslib_findpts_eval(this%gs_handle, y_check, & 1, this%error_code, 1, & this%proc_owner, 1, this%el_owner, 1, & - this%rst, this%mesh%gdim, & - this%n_points, this%dof%y) + this%rst, this%gdim, & + this%n_points, this%y%ptr) call fgslib_findpts_eval(this%gs_handle, z_check, & 1, this%error_code, 1, & this%proc_owner, 1, this%el_owner, 1, & - this%rst, this%mesh%gdim, & - this%n_points, this%dof%z) + this%rst, this%gdim, & + this%n_points, this%z%ptr) do i = 1 , this%n_points @@ -534,19 +537,19 @@ end subroutine global_interpolation_redist subroutine global_interpolation_evaluate(this, interp_values, field) class(global_interpolation_t), intent(inout) :: this real(kind=rp), intent(inout) :: interp_values(this%n_points) - real(kind=rp), intent(inout) :: field(this%dof%size()) + real(kind=rp), intent(inout) :: field(this%nelv*this%Xh%lxyz) #ifdef HAVE_GSLIB if (.not. this%all_points_local) then call fgslib_findpts_eval(this%gs_handle, interp_values, & 1, this%error_code, 1, & this%proc_owner, 1, this%el_owner, 1, & - this%rst, this%mesh%gdim, & + this%rst, this%gdim, & this%n_points, field) else if (this%n_points .gt. 0) & call this%local_interp%evaluate(interp_values, this%el_owner,& - field, this%mesh%nelv) + field, this%nelv) end if #else call neko_error('Neko needs to be built with GSLIB support') diff --git a/src/io/chkp_file.f90 b/src/io/chkp_file.f90 index a7e9097bf57..1f31ace3a0b 100644 --- a/src/io/chkp_file.f90 +++ b/src/io/chkp_file.f90 @@ -507,7 +507,8 @@ subroutine chkp_file_read(this, data) center_z) end do end do - call this%global_interp%init(dof,tol=tol) + call this%global_interp%init(dof%x(:,1,1,1), dof%y(:,1,1,1), & + dof%z(:,1,1,1), dof%msh%gdim, dof%msh%nelv, dof%Xh, tol=tol) call this%global_interp%find_points(x_coord,y_coord,z_coord,u%dof%size()) deallocate(x_coord) deallocate(y_coord) diff --git a/src/io/fld_file_data.f90 b/src/io/fld_file_data.f90 index 98f2cd1fedf..14121646509 100644 --- a/src/io/fld_file_data.f90 +++ b/src/io/fld_file_data.f90 @@ -196,9 +196,7 @@ function fld_file_data_generate_interpolator(this, to_dof, & type(global_interpolation_t) :: global_interp ! --- variables for interpolation - type(dofmap_t) :: fld_dof type(space_t) :: fld_Xh - type(mesh_t) :: fld_empty_mesh real(kind=rp), allocatable :: x_coords(:,:,:,:), y_coords(:,:,:,:), & z_coords(:,:,:,:) real(kind=rp) :: center_x, center_y, center_z @@ -217,14 +215,6 @@ function fld_file_data_generate_interpolator(this, to_dof, & ! Create a space based on the fld data call fld_Xh%init(GLL, this%lx, this%ly, this%lz) - ! Initialize an "empty" mesh and construct a "stripped down" - ! dofmap that only has x, y,z coordinates. This is because - ! global_interpolator needs a dofmap in its init but in practice - ! only uses dof%x, dof%y, dof%z - call fld_empty_mesh%init(this%gdim, this%nelv) - fld_dof = dofmap_t(this%x%x, this%y%x, this%z%x, & - this%nelv, this%lx, this%ly, this%lz) - ! These are the coordinates of our current dofmap ! that we use for the interpolation allocate(x_coords(to_Xh%lx, to_Xh%ly, to_Xh%lz, to_msh%nelv)) @@ -259,9 +249,8 @@ function fld_file_data_generate_interpolator(this, to_dof, & ! The initialization is done based on the variables created from ! fld data - call global_interp%init(fld_dof, tol = tolerance, Xh = fld_Xh, & - msh = fld_empty_mesh) - + call global_interp%init(this%x%x, this%y%x, this%z%x, this%gdim, & + this%nelv, fld_Xh, tol = tolerance) call global_interp%find_points(x_coords, y_coords, z_coords, & to_dof%size()) diff --git a/src/sem/dofmap.f90 b/src/sem/dofmap.f90 index 4c1d9a491b6..95a7e805b18 100644 --- a/src/sem/dofmap.f90 +++ b/src/sem/dofmap.f90 @@ -74,52 +74,11 @@ module dofmap end type dofmap_t interface dofmap_t - module procedure dofmap_init, dofmap_init_from_coords + module procedure dofmap_init end interface dofmap_t contains - !> Initialize a stripped-down version of a dofmap object, with only - !! x,y,z coordinates. - function dofmap_init_from_coords(x, y, z, nelv, lx, ly, lz) result(this) - real(kind=rp), intent(in) :: x(nelv * lx * ly * lz) - real(kind=rp), intent(in) :: y(nelv * lx * ly * lz) - real(kind=rp), intent(in) :: z(nelv * lx * ly * lz) - integer, intent(in) :: nelv - integer, intent(in) :: lx - integer, intent(in) :: ly - integer, intent(in) :: lz - type(dofmap_t) :: this - - integer :: n - - call dofmap_free(this) - - this%ntot = lx * ly * lz * nelv - - allocate(this%x(lx, ly, lz, nelv)) - allocate(this%y(lx, ly, lz, nelv)) - allocate(this%z(lx, ly, lz, nelv)) - - call copy(this%x, x, this%ntot) - call copy(this%y, y, this%ntot) - call copy(this%z, z, this%ntot) - - if (NEKO_BCKND_DEVICE .eq. 1) then - call device_map(this%x, this%x_d, this%ntot) - call device_map(this%y, this%y_d, this%ntot) - call device_map(this%z, this%z_d, this%ntot) - - call device_memcpy(this%x, this%x_d, this%ntot, & - HOST_TO_DEVICE, sync = .false.) - call device_memcpy(this%y, this%y_d, this%ntot, & - HOST_TO_DEVICE, sync = .false.) - call device_memcpy(this%z, this%z_d, this%ntot, & - HOST_TO_DEVICE, sync = .false.) - end if - - end function dofmap_init_from_coords - function dofmap_init(msh, Xh) result(this) type(mesh_t), target, intent(inout) :: msh !< Mesh type(space_t), target, intent(inout) :: Xh !< Function space \f$ X_h \f$ diff --git a/src/simulation_components/probes.F90 b/src/simulation_components/probes.F90 index 660eb07789f..c36fbf50100 100644 --- a/src/simulation_components/probes.F90 +++ b/src/simulation_components/probes.F90 @@ -246,7 +246,7 @@ subroutine read_point(this, json) ! Ensure only rank 0 reads the coordinates. if (pe_rank .ne. 0) return - call json_get(json, 'coordinates', rp_list_reader) + call json%get('coordinates', rp_list_reader, found) ! Check if the coordinates were found and were valid if (.not. found) then From c6d9438f2f275b8b2f018691d45423244eb90505 Mon Sep 17 00:00:00 2001 From: Victor Baconnet Date: Mon, 29 Jul 2024 13:48:57 +0200 Subject: [PATCH 35/67] use generic init for glb interp --- src/common/global_interpolation.F90 | 64 +++++++++++++++++++++++++--- src/io/chkp_file.f90 | 3 +- src/simulation_components/probes.F90 | 17 +++----- 3 files changed, 67 insertions(+), 17 deletions(-) diff --git a/src/common/global_interpolation.F90 b/src/common/global_interpolation.F90 index 8c0e15617f3..65cc6dbbd6a 100644 --- a/src/common/global_interpolation.F90 +++ b/src/common/global_interpolation.F90 @@ -42,6 +42,8 @@ module global_interpolation use utils, only: neko_error, neko_warning use local_interpolation use comm + use dofmap, only: dofmap_t + use mesh, only: mesh_t use math, only: copy use neko_mpi_types use structs, only: array_ptr_t @@ -60,7 +62,7 @@ module global_interpolation integer :: gdim !> Number of elements integer :: nelv - !> Space from which to interpolate + !> Space type(space_t), pointer :: Xh !> Interpolator for local points type(local_interpolator_t) :: local_interp @@ -93,7 +95,8 @@ module global_interpolation real(kind=rp) :: tol = 5d-13 contains !> Initialize the global interpolation object on a dofmap. - procedure, pass(this) :: init => global_interpolation_init + procedure, pass(this) :: init_xyz => global_interpolation_init_xyz + procedure, pass(this) :: init_dof => global_interpolation_init_dof !> Destructor procedure, pass(this) :: free => global_interpolation_free !> Destructor for arrays related to evaluation points @@ -109,7 +112,10 @@ module global_interpolation generic :: find_points => find_points_xyz, find_points_coords !> Evaluate the value of the field in each point. procedure, pass(this) :: evaluate => global_interpolation_evaluate - !> Evaluate only local points + + !> Generic constructor + generic :: init => init_dof, init_xyz + end type global_interpolation_t contains @@ -119,7 +125,55 @@ module global_interpolation !! @param tol Tolerance for Newton iterations. !! @param Xh Space on which to interpolate. !! @param msh Mesh on which to interp - subroutine global_interpolation_init(this, x, y, z, gdim, nelv, Xh, tol) + subroutine global_interpolation_init_dof(this, dof, tol) + class(global_interpolation_t), intent(inout) :: this + type(dofmap_t), target :: dof + real(kind=rp), optional :: tol + integer :: lx, ly, lz, nelv, max_pts_per_iter + + +#ifdef HAVE_GSLIB + + this%x%ptr => dof%x(:,1,1,1) + this%y%ptr => dof%y(:,1,1,1) + this%z%ptr => dof%z(:,1,1,1) + + this%Xh => dof%Xh + if(present(tol)) this%tol = tol + + lx = this%Xh%lx + ly = this%Xh%ly + lz = this%Xh%lz + this%gdim = dof%msh%gdim + this%nelv = dof%msh%nelv + !Number of points to iterate on simultaneosuly + max_pts_per_iter = 128 + + call fgslib_findpts_setup(this%gs_handle, & + NEKO_COMM, pe_size, & + dof%msh%gdim, & + dof%x, dof%y, dof%z, & ! Physical nodal values + lx, ly, lz, nelv, & ! Mesh dimensions + 2*lx, 2*ly, 2*lz, & ! Mesh size for bounding box computation + 0.01, & ! relative size to expand bounding boxes by + lx*ly*lz*nelv, lx*ly*lz*nelv, & ! local/global hash mesh sizes + max_pts_per_iter, this%tol) + this%gs_init = .true. +#else + call neko_error('Neko needs to be built with GSLIB support') +#endif + + end subroutine global_interpolation_init_dof + + !> Initialize the global interpolation object on a set of coordinates. + !! @param x x-coordinates. + !! @param y y-coordinates. + !! @param z z-coordinates. + !! @param gdim Geometric dimension. + !! @param nelv Number of elements. + !! @param Xh Space on which to interpolate. + !! @param tol Tolerance for Newton iterations. + subroutine global_interpolation_init_xyz(this, x, y, z, gdim, nelv, Xh, tol) class(global_interpolation_t), intent(inout) :: this real(kind=rp), intent(in), target :: x(:) real(kind=rp), intent(in), target :: y(:) @@ -160,7 +214,7 @@ subroutine global_interpolation_init(this, x, y, z, gdim, nelv, Xh, tol) call neko_error('Neko needs to be built with GSLIB support') #endif - end subroutine global_interpolation_init + end subroutine global_interpolation_init_xyz !> Destructor diff --git a/src/io/chkp_file.f90 b/src/io/chkp_file.f90 index 1f31ace3a0b..50aa0151bc1 100644 --- a/src/io/chkp_file.f90 +++ b/src/io/chkp_file.f90 @@ -507,8 +507,7 @@ subroutine chkp_file_read(this, data) center_z) end do end do - call this%global_interp%init(dof%x(:,1,1,1), dof%y(:,1,1,1), & - dof%z(:,1,1,1), dof%msh%gdim, dof%msh%nelv, dof%Xh, tol=tol) + call this%global_interp%init(dof, tol = tol) call this%global_interp%find_points(x_coord,y_coord,z_coord,u%dof%size()) deallocate(x_coord) deallocate(y_coord) diff --git a/src/simulation_components/probes.F90 b/src/simulation_components/probes.F90 index c36fbf50100..067e93072aa 100644 --- a/src/simulation_components/probes.F90 +++ b/src/simulation_components/probes.F90 @@ -180,7 +180,7 @@ subroutine probes_init_from_json(this, json, case) case ('file') call this%read_file(json_point) - case ('point') + case ('points') call this%read_point(json_point) case ('line') call this%read_line(json_point) @@ -188,10 +188,8 @@ subroutine probes_init_from_json(this, json, case) call neko_error('Plane probes not implemented yet.') case ('circle') call this%read_circle(json_point) - case ('point_zone') call this%read_point_zone(json_point, case%fluid%dm_Xh) - case ('none') call json_point%print() call neko_error('No point type specified.') @@ -223,7 +221,7 @@ subroutine read_file(this, json) integer :: n_local, n_global - if (pe_rank .ne. 0) return + !if (pe_rank .ne. 0) return call json_get(json, 'file_name', input_file) @@ -245,7 +243,7 @@ subroutine read_point(this, json) logical :: found ! Ensure only rank 0 reads the coordinates. - if (pe_rank .ne. 0) return + !if (pe_rank .ne. 0) return call json%get('coordinates', rp_list_reader, found) ! Check if the coordinates were found and were valid @@ -279,7 +277,7 @@ subroutine read_line(this, json) integer :: n_points, i ! Ensure only rank 0 reads the coordinates. - if (pe_rank .ne. 0) return + !if (pe_rank .ne. 0) return call json_get(json, "start", start) call json_get(json, "end", end) call json_get(json, "amount", n_points) @@ -326,7 +324,7 @@ subroutine read_circle(this, json) real(kind=rp) :: pi ! Ensure only rank 0 reads the coordinates. - if (pe_rank .ne. 0) return + !if (pe_rank .ne. 0) return call json_get(json, "center", center) call json_get(json, "normal", normal) call json_get(json, "radius", radius) @@ -399,7 +397,7 @@ subroutine read_point_zone(this, json, dof) real(kind=rp) :: x, y, z ! Ensure only rank 0 reads the coordinates. - if (pe_rank .ne. 0) return + !if (pe_rank .ne. 0) return call json_get(json, "name", point_zone_name) zone => neko_point_zone_registry%get_point_zone(point_zone_name) @@ -470,8 +468,7 @@ subroutine probes_init_from_attributes(this, dof, output_file) type(matrix_t) :: mat_coords !> Init interpolator - call this%global_interp%init(dof%x(:,1,1,1), dof%y(:,1,1,1), & - dof%z(:,1,1,1), dof%msh%gdim, dof%msh%nelv, dof%Xh) + call this%global_interp%init(dof) !> find probes and redistribute them call this%global_interp%find_points_and_redist(this%xyz, & From 5ff95f7c1cf2aeea75b07f56060f84df518f117b Mon Sep 17 00:00:00 2001 From: Victor Baconnet Date: Mon, 29 Jul 2024 16:19:07 +0200 Subject: [PATCH 36/67] reformat init --- src/.depends | 2 +- src/common/global_interpolation.F90 | 34 ++--------------------------- 2 files changed, 3 insertions(+), 33 deletions(-) diff --git a/src/.depends b/src/.depends index 766c8f42659..18000392b24 100644 --- a/src/.depends +++ b/src/.depends @@ -123,7 +123,7 @@ io/fluid_stats_output.o : io/fluid_stats_output.f90 io/output.o device/device.o io/mean_sqr_flow_output.o : io/mean_sqr_flow_output.f90 io/output.o config/num_types.o fluid/mean_sqr_flow.o io/data_streamer.o : io/data_streamer.F90 config/neko_config.o comm/mpi_types.o comm/comm.o device/device.o common/utils.o sem/coef.o field/field.o config/num_types.o common/sampler.o : common/sampler.f90 common/time_based_controller.o config/num_types.o common/profiler.o common/utils.o common/log.o comm/comm.o io/fld_file.o io/output.o -common/global_interpolation.o : common/global_interpolation.F90 common/structs.o comm/mpi_types.o math/math.o comm/comm.o sem/local_interpolation.o common/utils.o common/log.o sem/space.o config/num_types.o +common/global_interpolation.o : common/global_interpolation.F90 common/structs.o comm/mpi_types.o math/math.o mesh/mesh.o sem/dofmap.o comm/comm.o sem/local_interpolation.o common/utils.o common/log.o sem/space.o config/num_types.o common/profiler.o : common/profiler.F90 common/craypat.o device/hip/roctx.o device/cuda/nvtx.o device/device.o config/neko_config.o common/craypat.o : common/craypat.F90 common/utils.o adt/stack.o bc/bc.o : bc/bc.f90 common/utils.o adt/tuple.o adt/stack.o mesh/facet_zone.o mesh/mesh.o sem/space.o sem/coef.o sem/dofmap.o device/device.o config/num_types.o config/neko_config.o diff --git a/src/common/global_interpolation.F90 b/src/common/global_interpolation.F90 index 65cc6dbbd6a..620e6dc1e14 100644 --- a/src/common/global_interpolation.F90 +++ b/src/common/global_interpolation.F90 @@ -129,39 +129,9 @@ subroutine global_interpolation_init_dof(this, dof, tol) class(global_interpolation_t), intent(inout) :: this type(dofmap_t), target :: dof real(kind=rp), optional :: tol - integer :: lx, ly, lz, nelv, max_pts_per_iter - -#ifdef HAVE_GSLIB - - this%x%ptr => dof%x(:,1,1,1) - this%y%ptr => dof%y(:,1,1,1) - this%z%ptr => dof%z(:,1,1,1) - - this%Xh => dof%Xh - if(present(tol)) this%tol = tol - - lx = this%Xh%lx - ly = this%Xh%ly - lz = this%Xh%lz - this%gdim = dof%msh%gdim - this%nelv = dof%msh%nelv - !Number of points to iterate on simultaneosuly - max_pts_per_iter = 128 - - call fgslib_findpts_setup(this%gs_handle, & - NEKO_COMM, pe_size, & - dof%msh%gdim, & - dof%x, dof%y, dof%z, & ! Physical nodal values - lx, ly, lz, nelv, & ! Mesh dimensions - 2*lx, 2*ly, 2*lz, & ! Mesh size for bounding box computation - 0.01, & ! relative size to expand bounding boxes by - lx*ly*lz*nelv, lx*ly*lz*nelv, & ! local/global hash mesh sizes - max_pts_per_iter, this%tol) - this%gs_init = .true. -#else - call neko_error('Neko needs to be built with GSLIB support') -#endif + call this%init_xyz(dof%x(:,1,1,1), dof%y(:,1,1,1), dof%z(:,1,1,1), & + dof%msh%gdim, dof%msh%nelv, dof%Xh, tol=tol) end subroutine global_interpolation_init_dof From 85176e763cd3fb07a6f2c08764b8f15dfa28edb9 Mon Sep 17 00:00:00 2001 From: Tim Felle Olsen Date: Wed, 31 Jul 2024 11:57:57 +0200 Subject: [PATCH 37/67] Linter update --- src/case.f90 | 2 +- src/common/checkpoint.f90 | 108 +++++++++--------- src/common/global_interpolation.F90 | 2 +- src/io/chkp_file.f90 | 104 +++++++++-------- src/io/fld_file.f90 | 6 +- src/sem/dofmap.f90 | 168 ++++++++++++++-------------- 6 files changed, 205 insertions(+), 185 deletions(-) diff --git a/src/case.f90 b/src/case.f90 index 13d7e186dc1..9e0db68baa0 100644 --- a/src/case.f90 +++ b/src/case.f90 @@ -420,7 +420,7 @@ subroutine case_init_common(C) call json_get_or_default(C%params, 'case.checkpoint_format', & string_val, "chkp") C%f_chkp = chkp_output_t(C%fluid%chkp, path = output_directory, & - fmt=trim(string_val)) + fmt = trim(string_val)) call json_get_or_default(C%params, 'case.checkpoint_control', & string_val, "simulationtime") call json_get_or_default(C%params, 'case.checkpoint_value', real_val,& diff --git a/src/common/checkpoint.f90 b/src/common/checkpoint.f90 index e0dc5261950..ac62b55a166 100644 --- a/src/common/checkpoint.f90 +++ b/src/common/checkpoint.f90 @@ -141,58 +141,62 @@ subroutine chkp_sync_host(this) class(chkp_t), intent(inout) :: this if (NEKO_BCKND_DEVICE .eq. 1) then - associate(u=>this%u, v=>this%v, w=>this%w, & - ulag=>this%ulag, vlag=>this%vlag, wlag=>this%wlag, & - p=>this%p) + associate(u => this%u, v => this%v, w => this%w, & + ulag => this%ulag, vlag => this%vlag, wlag => this%wlag, & + p => this%p) if (associated(this%u) .and. associated(this%v) .and. & associated(this%w) .and. associated(this%p)) then - call device_memcpy(u%x, u%x_d, u%dof%size(), DEVICE_TO_HOST, sync=.false.) - call device_memcpy(v%x, v%x_d, v%dof%size(), DEVICE_TO_HOST, sync=.false.) - call device_memcpy(w%x, w%x_d, w%dof%size(), DEVICE_TO_HOST, sync=.false.) - call device_memcpy(p%x, p%x_d, p%dof%size(), DEVICE_TO_HOST, sync=.false.) + call device_memcpy(u%x, u%x_d, u%size(), DEVICE_TO_HOST, & + sync = .false.) + call device_memcpy(v%x, v%x_d, v%size(), DEVICE_TO_HOST, & + sync = .false.) + call device_memcpy(w%x, w%x_d, w%size(), DEVICE_TO_HOST, & + sync = .false.) + call device_memcpy(p%x, p%x_d, p%size(), DEVICE_TO_HOST, & + sync = .false.) end if if (associated(this%ulag) .and. associated(this%vlag) .and. & associated(this%wlag)) then call device_memcpy(ulag%lf(1)%x, ulag%lf(1)%x_d, & - u%dof%size(), DEVICE_TO_HOST, sync=.false.) + u%size(), DEVICE_TO_HOST, sync = .false.) call device_memcpy(ulag%lf(2)%x, ulag%lf(2)%x_d, & - u%dof%size(), DEVICE_TO_HOST, sync=.false.) + u%size(), DEVICE_TO_HOST, sync = .false.) call device_memcpy(vlag%lf(1)%x, vlag%lf(1)%x_d, & - v%dof%size(), DEVICE_TO_HOST, sync=.false.) + v%size(), DEVICE_TO_HOST, sync = .false.) call device_memcpy(vlag%lf(2)%x, vlag%lf(2)%x_d, & - v%dof%size(), DEVICE_TO_HOST, sync=.false.) + v%size(), DEVICE_TO_HOST, sync = .false.) call device_memcpy(wlag%lf(1)%x, wlag%lf(1)%x_d, & - w%dof%size(), DEVICE_TO_HOST, sync=.false.) + w%size(), DEVICE_TO_HOST, sync = .false.) call device_memcpy(wlag%lf(2)%x, wlag%lf(2)%x_d, & - w%dof%size(), DEVICE_TO_HOST, sync=.false.) + w%size(), DEVICE_TO_HOST, sync = .false.) call device_memcpy(this%abx1%x, this%abx1%x_d, & - w%dof%size(), DEVICE_TO_HOST, sync=.false.) + w%size(), DEVICE_TO_HOST, sync = .false.) call device_memcpy(this%abx2%x, this%abx2%x_d, & - w%dof%size(), DEVICE_TO_HOST, sync=.false.) + w%size(), DEVICE_TO_HOST, sync = .false.) call device_memcpy(this%aby1%x, this%aby1%x_d, & - w%dof%size(), DEVICE_TO_HOST, sync=.false.) + w%size(), DEVICE_TO_HOST, sync = .false.) call device_memcpy(this%aby2%x, this%aby2%x_d, & - w%dof%size(), DEVICE_TO_HOST, sync=.false.) + w%size(), DEVICE_TO_HOST, sync = .false.) call device_memcpy(this%abz1%x, this%abz1%x_d, & - w%dof%size(), DEVICE_TO_HOST, sync=.false.) + w%size(), DEVICE_TO_HOST, sync = .false.) call device_memcpy(this%abz2%x, this%abz2%x_d, & - w%dof%size(), DEVICE_TO_HOST, sync=.false.) + w%size(), DEVICE_TO_HOST, sync = .false.) end if if (associated(this%s)) then call device_memcpy(this%s%x, this%s%x_d, & - this%s%dof%size(), DEVICE_TO_HOST, sync=.false.) + this%s%size(), DEVICE_TO_HOST, sync = .false.) call device_memcpy(this%slag%lf(1)%x, this%slag%lf(1)%x_d, & - this%s%dof%size(), DEVICE_TO_HOST, sync=.false.) + this%s%size(), DEVICE_TO_HOST, sync = .false.) call device_memcpy(this%slag%lf(2)%x, this%slag%lf(2)%x_d, & - this%s%dof%size(), DEVICE_TO_HOST, sync=.false.) + this%s%size(), DEVICE_TO_HOST, sync = .false.) call device_memcpy(this%abs1%x, this%abs1%x_d, & - w%dof%size(), DEVICE_TO_HOST, sync=.false.) + w%size(), DEVICE_TO_HOST, sync = .false.) call device_memcpy(this%abs2%x, this%abs2%x_d, & - w%dof%size(), DEVICE_TO_HOST, sync=.false.) + w%size(), DEVICE_TO_HOST, sync = .false.) end if end associate call device_sync(glb_cmd_queue) @@ -211,45 +215,45 @@ subroutine chkp_sync_device(this) if (associated(this%u) .and. associated(this%v) .and. & associated(this%w)) then - call device_memcpy(u%x, u%x_d, u%dof%size(), & - HOST_TO_DEVICE, sync=.false.) - call device_memcpy(v%x, v%x_d, v%dof%size(), & - HOST_TO_DEVICE, sync=.false.) - call device_memcpy(w%x, w%x_d, w%dof%size(), & - HOST_TO_DEVICE, sync=.false.) - call device_memcpy(p%x, p%x_d, p%dof%size(), & - HOST_TO_DEVICE, sync=.false.) + call device_memcpy(u%x, u%x_d, u%size(), & + HOST_TO_DEVICE, sync = .false.) + call device_memcpy(v%x, v%x_d, v%size(), & + HOST_TO_DEVICE, sync = .false.) + call device_memcpy(w%x, w%x_d, w%size(), & + HOST_TO_DEVICE, sync = .false.) + call device_memcpy(p%x, p%x_d, p%size(), & + HOST_TO_DEVICE, sync = .false.) end if if (associated(this%ulag) .and. associated(this%vlag) .and. & associated(this%wlag)) then - call device_memcpy(ulag%lf(1)%x, ulag%lf(1)%x_d, u%dof%size(), & - HOST_TO_DEVICE, sync=.false.) - call device_memcpy(ulag%lf(2)%x, ulag%lf(2)%x_d, u%dof%size(), & - HOST_TO_DEVICE, sync=.false.) - - call device_memcpy(vlag%lf(1)%x, vlag%lf(1)%x_d, v%dof%size(), & - HOST_TO_DEVICE, sync=.false.) - call device_memcpy(vlag%lf(2)%x, vlag%lf(2)%x_d, v%dof%size(), & - HOST_TO_DEVICE, sync=.false.) - - call device_memcpy(wlag%lf(1)%x, wlag%lf(1)%x_d, w%dof%size(), & - HOST_TO_DEVICE, sync=.false.) - call device_memcpy(wlag%lf(2)%x, wlag%lf(2)%x_d, w%dof%size(), & - HOST_TO_DEVICE, sync=.false.) + call device_memcpy(ulag%lf(1)%x, ulag%lf(1)%x_d, u%size(), & + HOST_TO_DEVICE, sync = .false.) + call device_memcpy(ulag%lf(2)%x, ulag%lf(2)%x_d, u%size(), & + HOST_TO_DEVICE, sync = .false.) + + call device_memcpy(vlag%lf(1)%x, vlag%lf(1)%x_d, v%size(), & + HOST_TO_DEVICE, sync = .false.) + call device_memcpy(vlag%lf(2)%x, vlag%lf(2)%x_d, v%size(), & + HOST_TO_DEVICE, sync = .false.) + + call device_memcpy(wlag%lf(1)%x, wlag%lf(1)%x_d, w%size(), & + HOST_TO_DEVICE, sync = .false.) + call device_memcpy(wlag%lf(2)%x, wlag%lf(2)%x_d, w%size(), & + HOST_TO_DEVICE, sync = .false.) end if if (associated(this%s)) then - call device_memcpy(this%s%x, this%s%x_d, this%s%dof%size(), & - HOST_TO_DEVICE, sync=.false.) + call device_memcpy(this%s%x, this%s%x_d, this%s%size(), & + HOST_TO_DEVICE, sync = .false.) call device_memcpy(this%slag%lf(1)%x, this%slag%lf(1)%x_d, & - this%s%dof%size(), HOST_TO_DEVICE, sync=.false.) + this%s%size(), HOST_TO_DEVICE, sync = .false.) call device_memcpy(this%slag%lf(2)%x, this%slag%lf(2)%x_d, & - this%s%dof%size(), HOST_TO_DEVICE, sync=.false.) + this%s%size(), HOST_TO_DEVICE, sync = .false.) call device_memcpy(this%abs1%x, this%abs1%x_d, & - w%dof%size(), HOST_TO_DEVICE, sync=.false.) + w%size(), HOST_TO_DEVICE, sync = .false.) call device_memcpy(this%abs2%x, this%abs2%x_d, & - w%dof%size(), HOST_TO_DEVICE, sync=.false.) + w%size(), HOST_TO_DEVICE, sync = .false.) end if end associate end if diff --git a/src/common/global_interpolation.F90 b/src/common/global_interpolation.F90 index 620e6dc1e14..d7bc8980746 100644 --- a/src/common/global_interpolation.F90 +++ b/src/common/global_interpolation.F90 @@ -131,7 +131,7 @@ subroutine global_interpolation_init_dof(this, dof, tol) real(kind=rp), optional :: tol call this%init_xyz(dof%x(:,1,1,1), dof%y(:,1,1,1), dof%z(:,1,1,1), & - dof%msh%gdim, dof%msh%nelv, dof%Xh, tol=tol) + dof%msh%gdim, dof%msh%nelv, dof%Xh, tol = tol) end subroutine global_interpolation_init_dof diff --git a/src/io/chkp_file.f90 b/src/io/chkp_file.f90 index 50aa0151bc1..20bfdba83fa 100644 --- a/src/io/chkp_file.f90 +++ b/src/io/chkp_file.f90 @@ -53,11 +53,16 @@ module chkp_file !> Interface for Neko checkpoint files type, public, extends(generic_file_t) :: chkp_file_t - type(space_t) :: chkp_Xh !< Function space in the loaded checkpoint file - type(space_t), pointer :: sim_Xh !< Function space used in the simulation - type(interpolator_t) :: space_interp !< Interpolation when only changing lx - type(global_interpolation_t) :: global_interp !< Interpolation for different meshes - logical :: mesh2mesh !< Flag if previous mesh difers from current. + !> Function space in the loaded checkpoint file + type(space_t) :: chkp_Xh + !> Function space used in the simulation + type(space_t), pointer :: sim_Xh + !> Interpolation when only changing lx + type(interpolator_t) :: space_interp + !> Interpolation for different meshes + type(global_interpolation_t) :: global_interp + !> Flag if previous mesh difers from current. + logical :: mesh2mesh contains procedure :: read => chkp_file_read procedure :: read_field => chkp_read_field @@ -76,10 +81,10 @@ subroutine chkp_file_write(this, data, t) character(len=1024) :: fname integer :: ierr, suffix_pos, optional_fields type(field_t), pointer :: u, v, w, p, s - type(field_t), pointer :: abx1,abx2 - type(field_t), pointer :: aby1,aby2 - type(field_t), pointer :: abz1,abz2 - type(field_t), pointer :: abs1,abs2 + type(field_t), pointer :: abx1, abx2 + type(field_t), pointer :: aby1, aby2 + type(field_t), pointer :: abz1, abz2 + type(field_t), pointer :: abs1, abs2 type(field_series_t), pointer :: ulag => null() type(field_series_t), pointer :: vlag => null() type(field_series_t), pointer :: wlag => null() @@ -90,16 +95,17 @@ subroutine chkp_file_write(this, data, t) type(MPI_File) :: fh integer (kind=MPI_OFFSET_KIND) :: mpi_offset, byte_offset integer(kind=i8) :: n_glb_dofs, dof_offset - logical :: write_lag, write_scalar, write_dtlag, write_scalarlag, write_abvel + logical :: write_lag, write_scalar, write_dtlag, write_scalarlag + logical :: write_abvel integer :: i if (present(t)) then - time = real(t,dp) + time = real(t, dp) else time = 0d0 end if - select type(data) + select type (data) type is (chkp_t) if ( .not. associated(data%u) .or. & @@ -188,30 +194,32 @@ subroutine chkp_file_write(this, data, t) ! Dump mandatory checkpoint data ! - byte_offset = 4_i8 * int(MPI_INTEGER_SIZE,i8) + int(MPI_DOUBLE_PRECISION_SIZE,i8) + byte_offset = 4_i8 * int(MPI_INTEGER_SIZE, i8) + & + int(MPI_DOUBLE_PRECISION_SIZE, i8) byte_offset = byte_offset + & dof_offset * int(MPI_REAL_PREC_SIZE, i8) - call MPI_File_write_at_all(fh, byte_offset,u%x, u%dof%size(), & + call MPI_File_write_at_all(fh, byte_offset,u%x, u%size(), & MPI_REAL_PRECISION, status, ierr) - mpi_offset = 4_i8 * int(MPI_INTEGER_SIZE,i8) + int(MPI_DOUBLE_PRECISION_SIZE,i8) + mpi_offset = 4_i8 * int(MPI_INTEGER_SIZE, i8) + & + int(MPI_DOUBLE_PRECISION_SIZE, i8) mpi_offset = mpi_offset +& n_glb_dofs * int(MPI_REAL_PREC_SIZE, i8) byte_offset = mpi_offset + & dof_offset * int(MPI_REAL_PREC_SIZE, i8) - call MPI_File_write_at_all(fh, byte_offset, v%x, v%dof%size(), & + call MPI_File_write_at_all(fh, byte_offset, v%x, v%size(), & MPI_REAL_PRECISION, status, ierr) mpi_offset = mpi_offset + n_glb_dofs * int(MPI_REAL_PREC_SIZE, i8) byte_offset = mpi_offset + & dof_offset * int(MPI_REAL_PREC_SIZE, i8) - call MPI_File_write_at_all(fh, byte_offset, w%x, w%dof%size(), & + call MPI_File_write_at_all(fh, byte_offset, w%x, w%size(), & MPI_REAL_PRECISION, status, ierr) mpi_offset = mpi_offset + n_glb_dofs * int(MPI_REAL_PREC_SIZE, i8) byte_offset = mpi_offset + & dof_offset * int(MPI_REAL_PREC_SIZE, i8) - call MPI_File_write_at_all(fh, byte_offset, p%x, p%dof%size(), & + call MPI_File_write_at_all(fh, byte_offset, p%x, p%size(), & MPI_REAL_PRECISION, status, ierr) mpi_offset = mpi_offset + n_glb_dofs * int(MPI_REAL_PREC_SIZE, i8) @@ -229,7 +237,7 @@ subroutine chkp_file_write(this, data, t) ! ICE with NAG. associate (x => ulag%lf(i)%x) call MPI_File_write_at_all(fh, byte_offset, x, & - ulag%lf(i)%dof%size(), MPI_REAL_PRECISION, status, ierr) + ulag%lf(i)%size(), MPI_REAL_PRECISION, status, ierr) end associate mpi_offset = mpi_offset + n_glb_dofs * int(MPI_REAL_PREC_SIZE, i8) end do @@ -242,7 +250,7 @@ subroutine chkp_file_write(this, data, t) ! ICE with NAG. associate (x => vlag%lf(i)%x) call MPI_File_write_at_all(fh, byte_offset, x, & - vlag%lf(i)%dof%size(), MPI_REAL_PRECISION, status, ierr) + vlag%lf(i)%size(), MPI_REAL_PRECISION, status, ierr) end associate mpi_offset = mpi_offset + n_glb_dofs * int(MPI_REAL_PREC_SIZE, i8) end do @@ -255,7 +263,7 @@ subroutine chkp_file_write(this, data, t) ! ICE with NAG. associate (x => wlag%lf(i)%x) call MPI_File_write_at_all(fh, byte_offset, x, & - wlag%lf(i)%dof%size(), MPI_REAL_PRECISION, status, ierr) + wlag%lf(i)%size(), MPI_REAL_PRECISION, status, ierr) end associate mpi_offset = mpi_offset + n_glb_dofs * int(MPI_REAL_PREC_SIZE, i8) end do @@ -265,47 +273,49 @@ subroutine chkp_file_write(this, data, t) if (write_scalar) then byte_offset = mpi_offset + & dof_offset * int(MPI_REAL_PREC_SIZE, i8) - call MPI_File_write_at_all(fh, byte_offset, s%x, p%dof%size(), & + call MPI_File_write_at_all(fh, byte_offset, s%x, p%size(), & MPI_REAL_PRECISION, status, ierr) mpi_offset = mpi_offset + n_glb_dofs * int(MPI_REAL_PREC_SIZE, i8) end if if (write_dtlag) then - call MPI_File_write_at_all(fh, mpi_offset, tlag, 10, MPI_REAL_PRECISION, status, ierr) + call MPI_File_write_at_all(fh, mpi_offset, tlag, 10, & + MPI_REAL_PRECISION, status, ierr) mpi_offset = mpi_offset + 10_i8 * int(MPI_REAL_PREC_SIZE, i8) - call MPI_File_write_at_all(fh, mpi_offset, dtlag, 10, MPI_REAL_PRECISION, status, ierr) + call MPI_File_write_at_all(fh, mpi_offset, dtlag, 10, & + MPI_REAL_PRECISION, status, ierr) mpi_offset = mpi_offset + 10_i8 * int(MPI_REAL_PREC_SIZE, i8) end if if (write_abvel) then byte_offset = mpi_offset + & dof_offset * int(MPI_REAL_PREC_SIZE, i8) - call MPI_File_write_at_all(fh, byte_offset, abx1%x, abx1%dof%size(), & + call MPI_File_write_at_all(fh, byte_offset, abx1%x, abx1%size(), & MPI_REAL_PRECISION, status, ierr) mpi_offset = mpi_offset + n_glb_dofs * int(MPI_REAL_PREC_SIZE, i8) byte_offset = mpi_offset + & dof_offset * int(MPI_REAL_PREC_SIZE, i8) - call MPI_File_write_at_all(fh, byte_offset, abx2%x, abx1%dof%size(), & + call MPI_File_write_at_all(fh, byte_offset, abx2%x, abx1%size(), & MPI_REAL_PRECISION, status, ierr) mpi_offset = mpi_offset + n_glb_dofs * int(MPI_REAL_PREC_SIZE, i8) byte_offset = mpi_offset + & dof_offset * int(MPI_REAL_PREC_SIZE, i8) - call MPI_File_write_at_all(fh, byte_offset, aby1%x, abx1%dof%size(), & + call MPI_File_write_at_all(fh, byte_offset, aby1%x, abx1%size(), & MPI_REAL_PRECISION, status, ierr) mpi_offset = mpi_offset + n_glb_dofs * int(MPI_REAL_PREC_SIZE, i8) byte_offset = mpi_offset + & dof_offset * int(MPI_REAL_PREC_SIZE, i8) - call MPI_File_write_at_all(fh, byte_offset, aby2%x, abx1%dof%size(), & + call MPI_File_write_at_all(fh, byte_offset, aby2%x, abx1%size(), & MPI_REAL_PRECISION, status, ierr) mpi_offset = mpi_offset + n_glb_dofs * int(MPI_REAL_PREC_SIZE, i8) byte_offset = mpi_offset + & dof_offset * int(MPI_REAL_PREC_SIZE, i8) - call MPI_File_write_at_all(fh, byte_offset, abz1%x, abx1%dof%size(), & + call MPI_File_write_at_all(fh, byte_offset, abz1%x, abx1%size(), & MPI_REAL_PRECISION, status, ierr) mpi_offset = mpi_offset + n_glb_dofs * int(MPI_REAL_PREC_SIZE, i8) byte_offset = mpi_offset + & dof_offset * int(MPI_REAL_PREC_SIZE, i8) - call MPI_File_write_at_all(fh, byte_offset, abz2%x, abx1%dof%size(), & + call MPI_File_write_at_all(fh, byte_offset, abz2%x, abx1%size(), & MPI_REAL_PRECISION, status, ierr) mpi_offset = mpi_offset + n_glb_dofs * int(MPI_REAL_PREC_SIZE, i8) end if @@ -319,19 +329,19 @@ subroutine chkp_file_write(this, data, t) ! ICE with NAG. associate (x => slag%lf(i)%x) call MPI_File_write_at_all(fh, byte_offset, x, & - slag%lf(i)%dof%size(), MPI_REAL_PRECISION, status, ierr) + slag%lf(i)%size(), MPI_REAL_PRECISION, status, ierr) end associate mpi_offset = mpi_offset + n_glb_dofs * int(MPI_REAL_PREC_SIZE, i8) end do byte_offset = mpi_offset + & dof_offset * int(MPI_REAL_PREC_SIZE, i8) - call MPI_File_write_at_all(fh, byte_offset, abs1%x, abx1%dof%size(), & + call MPI_File_write_at_all(fh, byte_offset, abs1%x, abx1%size(), & MPI_REAL_PRECISION, status, ierr) mpi_offset = mpi_offset + n_glb_dofs * int(MPI_REAL_PREC_SIZE, i8) byte_offset = mpi_offset + & dof_offset * int(MPI_REAL_PREC_SIZE, i8) - call MPI_File_write_at_all(fh, byte_offset, abs2%x, abx1%dof%size(), & + call MPI_File_write_at_all(fh, byte_offset, abs2%x, abx1%size(), & MPI_REAL_PRECISION, status, ierr) mpi_offset = mpi_offset + n_glb_dofs * int(MPI_REAL_PREC_SIZE, i8) end if @@ -358,18 +368,18 @@ subroutine chkp_file_read(this, data) type(mesh_t), pointer :: msh type(MPI_Status) :: status type(MPI_File) :: fh - type(field_t), pointer :: abx1,abx2 - type(field_t), pointer :: aby1,aby2 - type(field_t), pointer :: abz1,abz2 - type(field_t), pointer :: abs1,abs2 + type(field_t), pointer :: abx1, abx2 + type(field_t), pointer :: aby1, aby2 + type(field_t), pointer :: abz1, abz2 + type(field_t), pointer :: abs1, abs2 real(kind=rp), allocatable :: x_coord(:,:,:,:) real(kind=rp), allocatable :: y_coord(:,:,:,:) real(kind=rp), allocatable :: z_coord(:,:,:,:) real(kind=rp), pointer :: dtlag(:), tlag(:) integer (kind=MPI_OFFSET_KIND) :: mpi_offset, byte_offset integer(kind=i8) :: n_glb_dofs, dof_offset - integer :: glb_nelv, gdim, lx, have_lag, have_scalar, nel, optional_fields, have_dtlag - integer :: have_abvel, have_scalarlag + integer :: glb_nelv, gdim, lx, have_lag, have_scalar, nel, optional_fields + integer :: have_dtlag, have_abvel, have_scalarlag logical :: read_lag, read_scalar, read_dtlag, read_abvel, read_scalarlag real(kind=rp) :: tol real(kind=rp) :: center_x, center_y, center_z @@ -378,7 +388,7 @@ subroutine chkp_file_read(this, data) call this%check_exists() - select type(data) + select type (data) type is (chkp_t) if ( .not. associated(data%u) .or. & @@ -508,7 +518,7 @@ subroutine chkp_file_read(this, data) end do end do call this%global_interp%init(dof, tol = tol) - call this%global_interp%find_points(x_coord,y_coord,z_coord,u%dof%size()) + call this%global_interp%find_points(x_coord, y_coord, z_coord,u%size()) deallocate(x_coord) deallocate(y_coord) deallocate(z_coord) @@ -522,13 +532,13 @@ subroutine chkp_file_read(this, data) ! Read mandatory checkpoint data ! - byte_offset = 4_i8 * int(MPI_INTEGER_SIZE,i8) + & - int(MPI_DOUBLE_PRECISION_SIZE,i8) + byte_offset = 4_i8 * int(MPI_INTEGER_SIZE, i8) + & + int(MPI_DOUBLE_PRECISION_SIZE, i8) byte_offset = byte_offset + & dof_offset * int(MPI_REAL_PREC_SIZE, i8) call this%read_field(fh, byte_offset, u%x, nel) - mpi_offset = 4_i8 * int(MPI_INTEGER_SIZE,i8) + & - int(MPI_DOUBLE_PRECISION_SIZE,i8) + mpi_offset = 4_i8 * int(MPI_INTEGER_SIZE, i8) + & + int(MPI_DOUBLE_PRECISION_SIZE, i8) mpi_offset = mpi_offset +& n_glb_dofs * int(MPI_REAL_PREC_SIZE, i8) @@ -668,12 +678,12 @@ subroutine chkp_read_field(this, fh, byte_offset, x, nel) allocate(read_array(this%chkp_Xh%lxyz*nel)) - call rzero(read_array,this%chkp_xh%lxyz*nel) + call rzero(read_array, this%chkp_xh%lxyz*nel) call MPI_File_read_at_all(fh, byte_offset, read_array, & nel*this%chkp_Xh%lxyz, MPI_REAL_PRECISION, status, ierr) if (this%mesh2mesh) then x = 0.0_rp - call this%global_interp%evaluate(x,read_array) + call this%global_interp%evaluate(x, read_array) else call this%space_interp%map_host(x, read_array, nel, this%sim_Xh) diff --git a/src/io/fld_file.f90 b/src/io/fld_file.f90 index 7c0aed71afc..0f67a856876 100644 --- a/src/io/fld_file.f90 +++ b/src/io/fld_file.f90 @@ -520,7 +520,7 @@ subroutine fld_file_write_metadata_vector(this, fh, byte_offset, x, y, z, & buffer(j + 0) = real(vlmin(z(1, el), lxyz), sp) buffer(j + 1) = real(vlmax(z(1, el), lxyz), sp) j = j + 2 - enddo + end do ! write out data nout = 2*gdim*nelv @@ -546,7 +546,7 @@ subroutine fld_file_write_metadata_scalar(this, fh, byte_offset, x, lxyz, & buffer(j + 0) = real(vlmin(x(1, el), lxyz), sp) buffer(j + 1) = real(vlmax(x(1, el), lxyz), sp) j = j + 2 - enddo + end do ! write out data nout = 2 * nelv @@ -735,7 +735,7 @@ subroutine fld_file_read(this, data) call MPI_File_read_all(fh, hdr, 132, MPI_CHARACTER, status, ierr) !This read can prorbably be done wihtout the temp variables,temp_str,i,j - read(hdr, 1) temp_str,FLD_DATA_SIZE, lx, ly, lz, glb_nelv, glb_nelv,& + read(hdr, 1) temp_str, FLD_DATA_SIZE, lx, ly, lz, glb_nelv, glb_nelv,& time, counter, i, j, (rdcode(i), i = 1, 10) 1 format(4a, 1x, i1, 1x, i2, 1x, i2, 1x, i2, 1x, i10, 1x, i10, 1x, & e20.13, 1x, i9, 1x, i6, 1x, i6, 1x, 10a) diff --git a/src/sem/dofmap.f90 b/src/sem/dofmap.f90 index 95a7e805b18..4179e2d082b 100644 --- a/src/sem/dofmap.f90 +++ b/src/sem/dofmap.f90 @@ -239,10 +239,10 @@ subroutine dofmap_number_edges(this) num_dofs_edges(2) = int(Xh%ly - 2, i8) num_dofs_edges(3) = int(Xh%lz - 2, i8) edge_offset = int(msh%glb_mpts, i8) + int(1, 4) - + do i = 1, msh%nelv - select type(ep=>msh%elements(i)%e) + select type (ep => msh%elements(i)%e) type is (hex_t) ! ! Number edges in r-direction @@ -254,7 +254,7 @@ subroutine dofmap_number_edges(this) !Reverse order of tranversal if edge is reversed do j = 2, Xh%lx - 1 k = j - if(int(edge%x(1), i8) .ne. this%dof(1,1,1,i)) k = Xh%lx+1-j + if (int(edge%x(1), i8) .ne. this%dof(1,1,1,i)) k = Xh%lx+1-j this%dof(k, 1, 1, i) = edge_id this%shared_dof(k, 1, 1, i) = shared_dof edge_id = edge_id + 1 @@ -266,7 +266,7 @@ subroutine dofmap_number_edges(this) edge_id = edge_offset + int((global_id - 1), i8) * num_dofs_edges(1) do j = 2, Xh%lx - 1 k = j - if(int(edge%x(1), i8) .ne. this%dof(1,1,Xh%lz,i)) k = Xh%lx+1-j + if (int(edge%x(1), i8) .ne. this%dof(1,1, Xh%lz,i)) k = Xh%lx+1-j this%dof(k, 1, Xh%lz, i) = edge_id this%shared_dof(k, 1, Xh%lz, i) = shared_dof edge_id = edge_id + 1 @@ -278,7 +278,7 @@ subroutine dofmap_number_edges(this) edge_id = edge_offset + int((global_id - 1), i8) * num_dofs_edges(1) do j = 2, Xh%lx - 1 k = j - if(int(edge%x(1), i8) .ne. this%dof(1,Xh%ly,1,i)) k = Xh%lx+1-j + if (int(edge%x(1), i8) .ne. this%dof(1, Xh%ly,1,i)) k = Xh%lx+1-j this%dof(k, Xh%ly, 1, i) = edge_id this%shared_dof(k, Xh%ly, 1, i) = shared_dof edge_id = edge_id + 1 @@ -290,7 +290,9 @@ subroutine dofmap_number_edges(this) edge_id = edge_offset + int((global_id - 1), i8) * num_dofs_edges(1) do j = 2, Xh%lx - 1 k = j - if(int(edge%x(1), i8) .ne. this%dof(1,Xh%ly,Xh%lz,i)) k = Xh%lx+1-j + if (int(edge%x(1), i8) .ne. this%dof(1, Xh%ly, Xh%lz,i)) then + k = Xh%lx+1-j + end if this%dof(k, Xh%ly, Xh%lz, i) = edge_id this%shared_dof(k, Xh%ly, Xh%lz, i) = shared_dof edge_id = edge_id + 1 @@ -306,7 +308,7 @@ subroutine dofmap_number_edges(this) edge_id = edge_offset + int((global_id - 1), i8) * num_dofs_edges(2) do j = 2, Xh%ly - 1 k = j - if(int(edge%x(1), i8) .ne. this%dof(1,1,1,i)) k = Xh%ly+1-j + if (int(edge%x(1), i8) .ne. this%dof(1,1,1,i)) k = Xh%ly+1-j this%dof(1, k, 1, i) = edge_id this%shared_dof(1, k, 1, i) = shared_dof edge_id = edge_id + 1 @@ -318,7 +320,7 @@ subroutine dofmap_number_edges(this) edge_id = edge_offset + int((global_id - 1), i8) * num_dofs_edges(2) do j = 2, Xh%ly - 1 k = j - if(int(edge%x(1), i8) .ne. this%dof(1,1,Xh%lz,i)) k = Xh%ly+1-j + if (int(edge%x(1), i8) .ne. this%dof(1,1, Xh%lz,i)) k = Xh%ly+1-j this%dof(1, k, Xh%lz, i) = edge_id this%shared_dof(1, k, Xh%lz, i) = shared_dof edge_id = edge_id + 1 @@ -330,7 +332,7 @@ subroutine dofmap_number_edges(this) edge_id = edge_offset + int((global_id - 1), i8) * num_dofs_edges(2) do j = 2, Xh%ly - 1 k = j - if(int(edge%x(1), i8) .ne. this%dof(Xh%lx,1,1,i)) k = Xh%ly+1-j + if (int(edge%x(1), i8) .ne. this%dof(Xh%lx,1,1,i)) k = Xh%ly+1-j this%dof(Xh%lx, k, 1, i) = edge_id this%shared_dof(Xh%lx, k, 1, i) = shared_dof edge_id = edge_id + 1 @@ -342,7 +344,9 @@ subroutine dofmap_number_edges(this) edge_id = edge_offset + int((global_id - 1), i8) * num_dofs_edges(2) do j = 2, Xh%ly - 1 k = j - if(int(edge%x(1), i8) .ne. this%dof(Xh%lx,1,Xh%lz,i)) k = Xh%lz+1-j + if (int(edge%x(1), i8) .ne. this%dof(Xh%lx,1, Xh%lz,i)) then + k = Xh%lz+1-j + end if this%dof(Xh%lx, k, Xh%lz, i) = edge_id this%shared_dof(Xh%lx, k, Xh%lz, i) = shared_dof edge_id = edge_id + 1 @@ -357,7 +361,7 @@ subroutine dofmap_number_edges(this) edge_id = edge_offset + int((global_id - 1), i8) * num_dofs_edges(3) do j = 2, Xh%lz - 1 k = j - if(int(edge%x(1), i8) .ne. this%dof(1,1,1,i)) k = Xh%lz+1-j + if (int(edge%x(1), i8) .ne. this%dof(1,1,1,i)) k = Xh%lz+1-j this%dof(1, 1, k, i) = edge_id this%shared_dof(1, 1, k, i) = shared_dof edge_id = edge_id + 1 @@ -369,7 +373,7 @@ subroutine dofmap_number_edges(this) edge_id = edge_offset + int((global_id - 1), i8) * num_dofs_edges(3) do j = 2, Xh%lz - 1 k = j - if(int(edge%x(1), i8) .ne. this%dof(Xh%lx,1,1,i)) k = Xh%lz+1-j + if (int(edge%x(1), i8) .ne. this%dof(Xh%lx,1,1,i)) k = Xh%lz+1-j this%dof(Xh%lx, 1, k, i) = edge_id this%shared_dof(Xh%lx, 1, k, i) = shared_dof edge_id = edge_id + 1 @@ -381,7 +385,7 @@ subroutine dofmap_number_edges(this) edge_id = edge_offset + int((global_id - 1), i8) * num_dofs_edges(3) do j = 2, Xh%lz - 1 k = j - if(int(edge%x(1), i8) .ne. this%dof(1,Xh%ly,1,i)) k = Xh%lz+1-j + if (int(edge%x(1), i8) .ne. this%dof(1, Xh%ly,1,i)) k = Xh%lz+1-j this%dof(1, Xh%ly, k, i) = edge_id this%shared_dof(1, Xh%ly, k, i) = shared_dof edge_id = edge_id + 1 @@ -393,7 +397,9 @@ subroutine dofmap_number_edges(this) edge_id = edge_offset + int((global_id - 1), i8) * num_dofs_edges(3) do j = 2, Xh%lz - 1 k = j - if(int(edge%x(1), i8) .ne. this%dof(Xh%lx,Xh%ly,1,i)) k = Xh%lz+1-j + if (int(edge%x(1), i8) .ne. this%dof(Xh%lx, Xh%ly,1,i)) then + k = Xh%lz+1-j + end if this%dof(Xh%lx, Xh%ly, k, i) = edge_id this%shared_dof(Xh%lx, Xh%ly, k, i) = shared_dof edge_id = edge_id + 1 @@ -409,7 +415,7 @@ subroutine dofmap_number_edges(this) !Reverse order of tranversal if edge is reversed do j = 2, Xh%lx - 1 k = j - if(int(edge%x(1), i8) .ne. this%dof(1,1,1,i)) k = Xh%lx+1-j + if (int(edge%x(1), i8) .ne. this%dof(1,1,1,i)) k = Xh%lx+1-j this%dof(k, 1, 1, i) = edge_id this%shared_dof(k, 1, 1, i) = shared_dof edge_id = edge_id + 1 @@ -421,7 +427,7 @@ subroutine dofmap_number_edges(this) edge_id = edge_offset + int((global_id - 1), i8) * num_dofs_edges(1) do j = 2, Xh%lx - 1 k = j - if(int(edge%x(1), i8) .ne. this%dof(1,Xh%ly,1,i)) k = Xh%lx+1-j + if (int(edge%x(1), i8) .ne. this%dof(1, Xh%ly,1,i)) k = Xh%lx+1-j this%dof(k, Xh%ly, 1, i) = edge_id this%shared_dof(k, Xh%ly, 1, i) = shared_dof edge_id = edge_id + 1 @@ -436,7 +442,7 @@ subroutine dofmap_number_edges(this) edge_id = edge_offset + int((global_id - 1), i8) * num_dofs_edges(2) do j = 2, Xh%ly - 1 k = j - if(int(edge%x(1), i8) .ne. this%dof(1,1,1,i)) k = Xh%ly+1-j + if (int(edge%x(1), i8) .ne. this%dof(1,1,1,i)) k = Xh%ly+1-j this%dof(1, k, 1, i) = edge_id this%shared_dof(1, k, 1, i) = shared_dof edge_id = edge_id + 1 @@ -448,7 +454,7 @@ subroutine dofmap_number_edges(this) edge_id = edge_offset + int((global_id - 1), i8) * num_dofs_edges(2) do j = 2, Xh%ly - 1 k = j - if(int(edge%x(1), i8) .ne. this%dof(Xh%lx,1,1,i)) k = Xh%ly+1-j + if (int(edge%x(1), i8) .ne. this%dof(Xh%lx,1,1,i)) k = Xh%ly+1-j this%dof(Xh%lx, k, 1, i) = edge_id this%shared_dof(Xh%lx, k, 1, i) = shared_dof edge_id = edge_id + 1 @@ -496,7 +502,7 @@ subroutine dofmap_number_faces(this) do k = 2, Xh%lz -1 do j = 2, Xh%ly - 1 this%dof(1, j, k, i) = & - dofmap_facetidx(face_order,face,facet_id,j,k,Xh%lz,Xh%ly) + dofmap_facetidx(face_order, face, facet_id,j,k, Xh%lz, Xh%ly) this%shared_dof(1, j, k, i) = shared_dof end do end do @@ -509,7 +515,7 @@ subroutine dofmap_number_faces(this) do k = 2, Xh%lz -1 do j = 2, Xh%ly - 1 this%dof(Xh%lx, j, k, i) = & - dofmap_facetidx(face_order,face,facet_id,j,k,Xh%lz,Xh%ly) + dofmap_facetidx(face_order, face, facet_id,j,k, Xh%lz, Xh%ly) this%shared_dof(Xh%lx, j, k, i) = shared_dof end do end do @@ -526,7 +532,7 @@ subroutine dofmap_number_faces(this) do k = 2, Xh%lz - 1 do j = 2, Xh%lx - 1 this%dof(j, 1, k, i) = & - dofmap_facetidx(face_order,face,facet_id,k,j,Xh%lz,Xh%lx) + dofmap_facetidx(face_order, face, facet_id,k,j, Xh%lz, Xh%lx) this%shared_dof(j, 1, k, i) = shared_dof end do end do @@ -539,7 +545,7 @@ subroutine dofmap_number_faces(this) do k = 2, Xh%lz - 1 do j = 2, Xh%lx - 1 this%dof(j, Xh%ly, k, i) = & - dofmap_facetidx(face_order,face,facet_id,k,j,Xh%lz,Xh%lx) + dofmap_facetidx(face_order, face, facet_id,k,j, Xh%lz, Xh%lx) this%shared_dof(j, Xh%ly, k, i) = shared_dof end do end do @@ -556,7 +562,7 @@ subroutine dofmap_number_faces(this) do k = 2, Xh%ly - 1 do j = 2, Xh%lx - 1 this%dof(j, k, 1, i) = & - dofmap_facetidx(face_order,face,facet_id,k,j,Xh%ly,Xh%lx) + dofmap_facetidx(face_order, face, facet_id,k,j, Xh%ly, Xh%lx) this%shared_dof(j, k, 1, i) = shared_dof end do end do @@ -569,7 +575,7 @@ subroutine dofmap_number_faces(this) do k = 2, Xh%ly - 1 do j = 2, Xh%lx - 1 this%dof(j, k, Xh%lz, i) = & - dofmap_facetidx(face_order,face,facet_id,k,j,Xh%lz,Xh%lx) + dofmap_facetidx(face_order, face, facet_id,k,j, Xh%lz, Xh%lx) this%shared_dof(j, k, Xh%lz, i) = shared_dof end do end do @@ -578,11 +584,12 @@ subroutine dofmap_number_faces(this) end subroutine dofmap_number_faces !> Get idx for GLL point on face depending on face ordering k and j - function dofmap_facetidx(face_order, face, facet_id, k1, j1, lk1, lj1) result(facet_idx) + function dofmap_facetidx(face_order, face, facet_id, k1, j1, lk1, lj1) & + result(facet_idx) type(tuple4_i4_t) :: face_order, face integer(kind=i8) :: facet_idx, facet_id integer :: k1, j1, lk1, lj1 - integer :: k,j,lk,lj + integer :: k, j, lk, lj k = k1 - 2 j = j1 - 2 @@ -603,26 +610,26 @@ function dofmap_facetidx(face_order, face, facet_id, k1, j1, lk1, lj1) result(fa ! 1 -------- 2 0--->j - if(face_order%x(1) .eq. face%x(1)) then - if(face_order%x(2) .lt. face_order%x(4)) then + if (face_order%x(1) .eq. face%x(1)) then + if (face_order%x(2) .lt. face_order%x(4)) then facet_idx = facet_id + j + k*lj else facet_idx = facet_id + j*lk + k end if - else if(face_order%x(2) .eq. face%x(1)) then - if(face_order%x(3) .lt. face_order%x(1)) then + else if (face_order%x(2) .eq. face%x(1)) then + if (face_order%x(3) .lt. face_order%x(1)) then facet_idx = facet_id + lk*(lj-1-j) + k else facet_idx = facet_id + (lj-1-j) + k*lj end if - else if(face_order%x(3) .eq. face%x(1)) then - if(face_order%x(4) .lt. face_order%x(2)) then + else if (face_order%x(3) .eq. face%x(1)) then + if (face_order%x(4) .lt. face_order%x(2)) then facet_idx = facet_id + (lj-1-j) + lj*(lk-1-k) else facet_idx = facet_id + lk*(lj-1-j) + (lk-1-k) end if - else if(face_order%x(4) .eq. face%x(1)) then - if(face_order%x(1) .lt. face_order%x(3)) then + else if (face_order%x(4) .eq. face%x(1)) then + if (face_order%x(1) .lt. face_order%x(3)) then facet_idx = facet_id + lk*j + (lk-1-k) else facet_idx = facet_id + j + lj*(lk-1-k) @@ -667,8 +674,8 @@ subroutine dofmap_generate_xyz(this) end do if (midpoint .and. Xh%lx .gt. 2) then call dofmap_xyzquad(Xh, msh, msh%elements(el_idx)%e, & - this%x(1,1,1,el_idx), this%y(1,1,1,el_idx),& - this%z(1,1,1,el_idx),curve_type, curve_data_tot) + this%x(1,1,1, el_idx), this%y(1,1,1, el_idx),& + this%z(1,1,1, el_idx),curve_type, curve_data_tot) end if end do do i = 1, msh%curve%size @@ -677,8 +684,8 @@ subroutine dofmap_generate_xyz(this) if (msh%curve%curve_el(i)%curve_type(j) .eq. 3) then rp_curve_data = msh%curve%curve_el(i)%curve_data(1:5,j) call arc_surface(j, rp_curve_data, & - this%x(1,1,1,el_idx), & - this%y(1,1,1,el_idx), & + this%x(1,1,1, el_idx), & + this%y(1,1,1, el_idx), & this%z(1,1,1, el_idx), & Xh, msh%elements(el_idx)%e, msh%gdim) end if @@ -775,7 +782,7 @@ subroutine dofmap_xyzquad(Xh, msh, element, x, y, z, curve_type, curve_data) type(space_t), target :: Xh3 real(kind=rp), dimension(3), parameter :: zquad = (/-1d0, 0d0,1d0/) real(kind=rp) :: zg(3) - real(kind=rp), dimension(Xh%lx,Xh%lx,Xh%lx) :: tmp + real(kind=rp), dimension(Xh%lx, Xh%lx, Xh%lx) :: tmp real(kind=rp) :: jx(Xh%lx*3) real(kind=rp) :: jxt(Xh%lx*3), jyt(Xh%lx*3), jzt(Xh%lx*3) real(kind=rp) :: w(4*Xh%lxyz,2) @@ -805,20 +812,20 @@ subroutine dofmap_xyzquad(Xh, msh, element, x, y, z, curve_type, curve_data) zg(2) = 0 zg(3) = 1 if (msh%gdim .eq. 3) then - call gh_face_extend_3d(x3,zg,3,2,w(1,1),w(1,2)) ! 2 --> edge extend - call gh_face_extend_3d(y3,zg,3,2,w(1,1),w(1,2)) - call gh_face_extend_3d(z3,zg,3,2,w(1,1),w(1,2)) + call gh_face_extend_3d(x3, zg,3,2,w(1,1),w(1,2)) ! 2 --> edge extend + call gh_face_extend_3d(y3, zg,3,2,w(1,1),w(1,2)) + call gh_face_extend_3d(z3, zg,3,2,w(1,1),w(1,2)) else call neko_warning(' m deformation not supported for 2d yet') - call gh_face_extend_2d(x3,zg,3,2,w(1,1),w(1,2)) ! 2 --> edge extend - call gh_face_extend_2d(y3,zg,3,2,w(1,1),w(1,2)) + call gh_face_extend_2d(x3, zg,3,2,w(1,1),w(1,2)) ! 2 --> edge extend + call gh_face_extend_2d(y3, zg,3,2,w(1,1),w(1,2)) end if k = 1 do j = 1, Xh%lx - call fd_weights_full(Xh%zg(j,1),zquad,2,0,jxt(k)) - call fd_weights_full(Xh%zg(j,2),zquad,2,0,jyt(k)) + call fd_weights_full(Xh%zg(j,1), zquad,2,0,jxt(k)) + call fd_weights_full(Xh%zg(j,2), zquad,2,0,jyt(k)) if (msh%gdim .gt. 2) then - call fd_weights_full(Xh%zg(j,3),zquad,2,0,jzt(k)) + call fd_weights_full(Xh%zg(j,3), zquad,2,0,jzt(k)) end if k = k + 3 end do @@ -868,7 +875,7 @@ subroutine gh_face_extend_3d(x, zg, n, gh_type, e, v) si = 0.5*((n-ii)*(1-zg(i))+(ii-1)*(1+zg(i)))/(n-1) sj = 0.5*((n-jj)*(1-zg(j))+(jj-1)*(1+zg(j)))/(n-1) sk = 0.5*((n-kk)*(1-zg(k))+(kk-1)*(1+zg(k)))/(n-1) - v(i,j,k) = v(i,j,k) + si*sj*sk*x(ii,jj,kk) + v(i,j,k) = v(i,j,k) + si*sj*sk*x(ii, jj, kk) end do end do end do @@ -894,7 +901,7 @@ subroutine gh_face_extend_3d(x, zg, n, gh_type, e, v) do i = 1, n hj = 0.5*((n-jj)*(1-zg(j))+(jj-1)*(1+zg(j)))/(n-1) hk = 0.5*((n-kk)*(1-zg(k))+(kk-1)*(1+zg(k)))/(n-1) - e(i,j,k) = e(i,j,k) + hj*hk*(x(i,jj,kk)-v(i,jj,kk)) + e(i,j,k) = e(i,j,k) + hj*hk*(x(i, jj, kk)-v(i, jj, kk)) end do end do end do @@ -910,7 +917,7 @@ subroutine gh_face_extend_3d(x, zg, n, gh_type, e, v) do i = 1, n hi = 0.5*((n-ii)*(1-zg(i))+(ii-1)*(1+zg(i)))/(n-1) hk = 0.5*((n-kk)*(1-zg(k))+(kk-1)*(1+zg(k)))/(n-1) - e(i,j,k) = e(i,j,k) + hi*hk*(x(ii,j,kk)-v(ii,j,kk)) + e(i,j,k) = e(i,j,k) + hi*hk*(x(ii,j, kk)-v(ii,j, kk)) end do end do end do @@ -926,7 +933,7 @@ subroutine gh_face_extend_3d(x, zg, n, gh_type, e, v) do i = 1, n hi = 0.5*((n-ii)*(1-zg(i))+(ii-1)*(1+zg(i)))/(n-1) hj = 0.5*((n-jj)*(1-zg(j))+(jj-1)*(1+zg(j)))/(n-1) - e(i,j,k) = e(i,j,k) + hi*hj*(x(ii,jj,k)-v(ii,jj,k)) + e(i,j,k) = e(i,j,k) + hi*hj*(x(ii, jj,k)-v(ii, jj,k)) end do end do end do @@ -964,7 +971,7 @@ subroutine gh_face_extend_3d(x, zg, n, gh_type, e, v) do j = 1, n do i = 1, n hj = 0.5*((n-jj)*(1-zg(j))+(jj-1)*(1+zg(j)))/(n-1) - v(i,j,k) = v(i,j,k) + hj*(x(i,jj,k)-e(i,jj,k)) + v(i,j,k) = v(i,j,k) + hj*(x(i, jj,k)-e(i, jj,k)) end do end do end do @@ -977,7 +984,7 @@ subroutine gh_face_extend_3d(x, zg, n, gh_type, e, v) do j = 1, n do i = 1, n hk = 0.5*((n-kk)*(1-zg(k))+(kk-1)*(1+zg(k)))/(n-1) - v(i,j,k) = v(i,j,k) + hk*(x(i,j,kk)-e(i,j,kk)) + v(i,j,k) = v(i,j,k) + hk*(x(i,j, kk)-e(i,j, kk)) end do end do end do @@ -1011,7 +1018,7 @@ subroutine gh_face_extend_2d(x, zg, n, gh_type, e, v) do i = 1, n si = 0.5*((n-ii)*(1-zg(i))+(ii-1)*(1+zg(i)))/(n-1) sj = 0.5*((n-jj)*(1-zg(j))+(jj-1)*(1+zg(j)))/(n-1) - v(i,j) = v(i,j) + si*sj*x(ii,jj) + v(i,j) = v(i,j) + si*sj*x(ii, jj) end do end do end do @@ -1030,7 +1037,7 @@ subroutine gh_face_extend_2d(x, zg, n, gh_type, e, v) do j = 1, n do i = 1, n hj = 0.5*((n-jj)*(1-zg(j))+(jj-1)*(1+zg(j)))/(n-1) - e(i,j) = e(i,j) + hj*(x(i,jj)-v(i,jj)) + e(i,j) = e(i,j) + hj*(x(i, jj)-v(i, jj)) end do end do end do @@ -1063,11 +1070,14 @@ subroutine arc_surface(isid, curve_data, x, y, z, Xh, element, gdim) real(kind=rp) :: theta0, xcenn, ycenn, h(Xh%lx, 3, 2) real(kind=rp) :: xcrved(Xh%lx), ycrved(Xh%lx), xs, ys integer :: isid1, ixt, iyt, izt, ix, itmp - integer(i4), dimension(6), parameter :: fcyc_to_sym = (/3, 2, 4, 1, 5, 6/) ! cyclic to symmetric face mapping - integer(i4), dimension(12), parameter :: ecyc_to_sym = (/1, 6, 2, 5, 3, 8, & - & 4, 7, 9, 10, 12, 11/) ! cyclic to symmetric edge mapping - integer, parameter, dimension(2, 12) :: edge_nodes = reshape((/1, 2, 3, 4, 5, 6, & - & 7, 8, 1, 3, 2, 4, 5, 7, 6, 8, 1, 5, 2, 6, 3, 7, 4, 8/), (/2,12/)) ! symmetric edge to vertex mapping + ! cyclic to symmetric face mapping + integer(i4), dimension(6), parameter :: fcyc_to_sym = (/3, 2, 4, 1, 5, 6/) + ! cyclic to symmetric edge mapping + integer(i4), dimension(12), parameter :: ecyc_to_sym = (/1, 6, 2, 5, 3, 8,& + & 4, 7, 9, 10, 12, 11/) + ! symmetric edge to vertex mapping + integer, parameter, dimension(2, 12) :: edge_nodes = reshape((/1, 2, 3, 4, & + & 5, 6, 7, 8, 1, 3, 2, 4, 5, 7, 6, 8, 1, 5, 2, 6, 3, 7, 4, 8/), (/2,12/)) ! copy from hex as this has private attribute there ! this subroutine is a mess of symmetric and cyclic edge/face numberring and @@ -1075,17 +1085,17 @@ subroutine arc_surface(isid, curve_data, x, y, z, Xh, element, gdim) ! a cyclic edge number) ! following according to cyclic edge numbering and orientation itmp = ecyc_to_sym(isid) - select case(isid) - case(1:2,5:6) - pt1x = element%pts(edge_nodes(1,itmp))%p%x(1) - pt1y = element%pts(edge_nodes(1,itmp))%p%x(2) - pt2x = element%pts(edge_nodes(2,itmp))%p%x(1) - pt2y = element%pts(edge_nodes(2,itmp))%p%x(2) - case(3:4,7:8) - pt1x = element%pts(edge_nodes(2,itmp))%p%x(1) - pt1y = element%pts(edge_nodes(2,itmp))%p%x(2) - pt2x = element%pts(edge_nodes(1,itmp))%p%x(1) - pt2y = element%pts(edge_nodes(1,itmp))%p%x(2) + select case (isid) + case (1:2,5:6) + pt1x = element%pts(edge_nodes(1, itmp))%p%x(1) + pt1y = element%pts(edge_nodes(1, itmp))%p%x(2) + pt2x = element%pts(edge_nodes(2, itmp))%p%x(1) + pt2y = element%pts(edge_nodes(2, itmp))%p%x(2) + case (3:4,7:8) + pt1x = element%pts(edge_nodes(2, itmp))%p%x(1) + pt1y = element%pts(edge_nodes(2, itmp))%p%x(2) + pt2x = element%pts(edge_nodes(1, itmp))%p%x(1) + pt2y = element%pts(edge_nodes(1, itmp))%p%x(2) end select ! find slope of perpendicular radius = curve_data(1) @@ -1109,8 +1119,8 @@ subroutine arc_surface(isid, curve_data, x, y, z, Xh, element, gdim) if (radius < 0.0) dtheta = -dtheta do ix = 1, Xh%lx ixt = ix - if (isid1.gt.2) ixt = Xh%lx + 1 - ix - r=Xh%zg(ix,1) + if (isid1 .gt. 2) ixt = Xh%lx + 1 - ix + r = Xh%zg(ix,1) xcrved(ixt) = xcenn + abs(radius) * cos(theta0 + r*dtheta) & - ( h(ix,1,1)*pt1x + h(ix,1,2)*pt2x ) ycrved(ixt) = ycenn + abs(radius) * sin(theta0 + r*dtheta) & @@ -1124,15 +1134,11 @@ subroutine arc_surface(isid, curve_data, x, y, z, Xh, element, gdim) iyt = isid1-2 ixt = isid1 if (isid1 .le. 2) then - call addtnsr(x, h(1,1,ixt), xcrved, h(1,3,izt) & - ,Xh%lx, Xh%ly, Xh%lz) - call addtnsr(y, h(1,1,ixt), ycrved, h(1,3,izt) & - ,Xh%lx, Xh%ly, Xh%lz) + call addtnsr(x, h(1,1,ixt), xcrved, h(1,3,izt), Xh%lx, Xh%ly, Xh%lz) + call addtnsr(y, h(1,1,ixt), ycrved, h(1,3,izt), Xh%lx, Xh%ly, Xh%lz) else - call addtnsr(x, xcrved, h(1,2,iyt), h(1,3,izt) & - ,Xh%lx, Xh%ly, Xh%lz) - call addtnsr(y, ycrved, h(1,2,iyt), h(1,3,izt) & - ,Xh%lx, Xh%ly, Xh%lz) + call addtnsr(x, xcrved, h(1,2,iyt), h(1,3,izt), Xh%lx, Xh%ly, Xh%lz) + call addtnsr(y, ycrved, h(1,2,iyt), h(1,3,izt), Xh%lx, Xh%ly, Xh%lz) end if end subroutine arc_surface From 79ea8106d8ab0c1073d2f2831faadfa19ecb9679 Mon Sep 17 00:00:00 2001 From: Tim Felle Olsen Date: Wed, 31 Jul 2024 12:49:02 +0200 Subject: [PATCH 38/67] Remove trailing whitespace --- src/io/chkp_file.f90 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/io/chkp_file.f90 b/src/io/chkp_file.f90 index 20bfdba83fa..1cbdc92b3a1 100644 --- a/src/io/chkp_file.f90 +++ b/src/io/chkp_file.f90 @@ -54,15 +54,15 @@ module chkp_file !> Interface for Neko checkpoint files type, public, extends(generic_file_t) :: chkp_file_t !> Function space in the loaded checkpoint file - type(space_t) :: chkp_Xh + type(space_t) :: chkp_Xh !> Function space used in the simulation - type(space_t), pointer :: sim_Xh + type(space_t), pointer :: sim_Xh !> Interpolation when only changing lx - type(interpolator_t) :: space_interp + type(interpolator_t) :: space_interp !> Interpolation for different meshes - type(global_interpolation_t) :: global_interp + type(global_interpolation_t) :: global_interp !> Flag if previous mesh difers from current. - logical :: mesh2mesh + logical :: mesh2mesh contains procedure :: read => chkp_file_read procedure :: read_field => chkp_read_field From 1a5610ec97997c066950119f029a1613f369bed9 Mon Sep 17 00:00:00 2001 From: Tim Felle Olsen Date: Wed, 31 Jul 2024 12:50:04 +0200 Subject: [PATCH 39/67] add missing spaces --- src/common/checkpoint.f90 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/common/checkpoint.f90 b/src/common/checkpoint.f90 index ac62b55a166..4688deca309 100644 --- a/src/common/checkpoint.f90 +++ b/src/common/checkpoint.f90 @@ -209,9 +209,9 @@ subroutine chkp_sync_device(this) class(chkp_t), intent(inout) :: this if (NEKO_BCKND_DEVICE .eq. 1) then - associate(u=>this%u, v=>this%v, w=>this%w, & - ulag=>this%ulag, vlag=>this%vlag, wlag=>this%wlag,& - p=>this%p) + associate(u => this%u, v => this%v, w => this%w, & + ulag => this%ulag, vlag => this%vlag, wlag => this%wlag, & + p => this%p) if (associated(this%u) .and. associated(this%v) .and. & associated(this%w)) then From 4e2a1ac753c16597bab612ec4d3e16a5b6b13979 Mon Sep 17 00:00:00 2001 From: Tim Felle Olsen Date: Wed, 31 Jul 2024 12:54:45 +0200 Subject: [PATCH 40/67] add missing spaces --- src/sem/dofmap.f90 | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/sem/dofmap.f90 b/src/sem/dofmap.f90 index 4179e2d082b..9ac29842049 100644 --- a/src/sem/dofmap.f90 +++ b/src/sem/dofmap.f90 @@ -675,7 +675,7 @@ subroutine dofmap_generate_xyz(this) if (midpoint .and. Xh%lx .gt. 2) then call dofmap_xyzquad(Xh, msh, msh%elements(el_idx)%e, & this%x(1,1,1, el_idx), this%y(1,1,1, el_idx),& - this%z(1,1,1, el_idx),curve_type, curve_data_tot) + this%z(1,1,1, el_idx), curve_type, curve_data_tot) end if end do do i = 1, msh%curve%size @@ -787,9 +787,9 @@ subroutine dofmap_xyzquad(Xh, msh, element, x, y, z, curve_type, curve_data) real(kind=rp) :: jxt(Xh%lx*3), jyt(Xh%lx*3), jzt(Xh%lx*3) real(kind=rp) :: w(4*Xh%lxyz,2) integer :: j, k, n_edges - eindx = (/2 , 6 , 8 , 4, & - 20 , 24 , 26 , 22, & - 10 , 12 , 18 , 16 /) + eindx = (/ 2, 6, 8, 4, & + 20, 24, 26, 22, & + 10, 12, 18, 16 /) w = 0d0 if (msh%gdim .eq. 3) then @@ -822,8 +822,8 @@ subroutine dofmap_xyzquad(Xh, msh, element, x, y, z, curve_type, curve_data) end if k = 1 do j = 1, Xh%lx - call fd_weights_full(Xh%zg(j,1), zquad,2,0,jxt(k)) - call fd_weights_full(Xh%zg(j,2), zquad,2,0,jyt(k)) + call fd_weights_full(Xh%zg(j,1), zquad,2,0, jxt(k)) + call fd_weights_full(Xh%zg(j,2), zquad,2,0, jyt(k)) if (msh%gdim .gt. 2) then call fd_weights_full(Xh%zg(j,3), zquad,2,0,jzt(k)) end if @@ -979,7 +979,7 @@ subroutine gh_face_extend_3d(x, zg, n, gh_type, e, v) ! ! z-edges ! - do kk= 1 , n, n-1 + do kk= 1, n, n-1 do k = 1, n do j = 1, n do i = 1, n @@ -991,7 +991,7 @@ subroutine gh_face_extend_3d(x, zg, n, gh_type, e, v) end do call add2(v, e, ntot) - call copy(x, v ,ntot) + call copy(x, v, ntot) end subroutine gh_face_extend_3d @@ -1005,13 +1005,13 @@ subroutine gh_face_extend_2d(x, zg, n, gh_type, e, v) real(kind=rp), intent(inout) :: e(n, n) real(kind=rp), intent(inout) :: v(n, n) integer, intent(in) :: gh_type - integer :: i,j , jj, ii, ntot + integer :: i,j, jj, ii, ntot real(kind=rp) :: si, sj, hi, hj !Build vertex interpolant ntot = n * n - call rzero(v,ntot) + call rzero(v, ntot) do jj = 1, n, n-1 do ii = 1, n, n-1 do j = 1, n @@ -1024,12 +1024,12 @@ subroutine gh_face_extend_2d(x, zg, n, gh_type, e, v) end do end do if (gh_type .eq. 1) then - call copy(x,v,ntot) + call copy(x,v, ntot) return end if !Extend 4 edges - call rzero(e,ntot) + call rzero(e, ntot) !x-edges @@ -1134,14 +1134,14 @@ subroutine arc_surface(isid, curve_data, x, y, z, Xh, element, gdim) iyt = isid1-2 ixt = isid1 if (isid1 .le. 2) then - call addtnsr(x, h(1,1,ixt), xcrved, h(1,3,izt), Xh%lx, Xh%ly, Xh%lz) - call addtnsr(y, h(1,1,ixt), ycrved, h(1,3,izt), Xh%lx, Xh%ly, Xh%lz) + call addtnsr(x, h(1,1, ixt), xcrved, h(1,3, izt), Xh%lx, Xh%ly, Xh%lz) + call addtnsr(y, h(1,1, ixt), ycrved, h(1,3, izt), Xh%lx, Xh%ly, Xh%lz) else - call addtnsr(x, xcrved, h(1,2,iyt), h(1,3,izt), Xh%lx, Xh%ly, Xh%lz) - call addtnsr(y, ycrved, h(1,2,iyt), h(1,3,izt), Xh%lx, Xh%ly, Xh%lz) + call addtnsr(x, xcrved, h(1,2, iyt), h(1,3, izt), Xh%lx, Xh%ly, Xh%lz) + call addtnsr(y, ycrved, h(1,2, iyt), h(1,3, izt), Xh%lx, Xh%ly, Xh%lz) end if end subroutine arc_surface - +, subroutine compute_h(h, zgml, gdim, lx) integer, intent(in) :: lx, gdim real(kind=rp), intent(inout) :: h(lx, 3, 2) From dbf2280bebf1935413d42855c748d72120f38a40 Mon Sep 17 00:00:00 2001 From: Tim Felle Olsen Date: Wed, 31 Jul 2024 12:57:14 +0200 Subject: [PATCH 41/67] add missing space --- src/sem/dofmap.f90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sem/dofmap.f90 b/src/sem/dofmap.f90 index 9ac29842049..e628e3b6ad0 100644 --- a/src/sem/dofmap.f90 +++ b/src/sem/dofmap.f90 @@ -825,7 +825,7 @@ subroutine dofmap_xyzquad(Xh, msh, element, x, y, z, curve_type, curve_data) call fd_weights_full(Xh%zg(j,1), zquad,2,0, jxt(k)) call fd_weights_full(Xh%zg(j,2), zquad,2,0, jyt(k)) if (msh%gdim .gt. 2) then - call fd_weights_full(Xh%zg(j,3), zquad,2,0,jzt(k)) + call fd_weights_full(Xh%zg(j,3), zquad,2,0, jzt(k)) end if k = k + 3 end do From 276252a5cadc175eb9b372ef964fbca98350a7d0 Mon Sep 17 00:00:00 2001 From: Victor Baconnet Date: Tue, 20 Aug 2024 11:45:50 +0200 Subject: [PATCH 42/67] linter --- src/case.f90 | 2 +- src/common/global_interpolation.F90 | 12 ++++++------ src/io/fld_file.f90 | 10 +++++----- src/sem/dofmap.f90 | 6 +++--- src/simulation_components/probes.F90 | 10 +++++----- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/case.f90 b/src/case.f90 index ad07ebbe50f..e54cb5e9aca 100644 --- a/src/case.f90 +++ b/src/case.f90 @@ -112,7 +112,7 @@ subroutine case_init_from_file(C, case_file) end if call MPI_Bcast(integer_val, 1, MPI_INTEGER, 0, NEKO_COMM, ierr) - if (pe_rank .ne. 0) allocate(character(len=integer_val) :: json_buffer) + if (pe_rank .ne. 0) allocate(character(len = integer_val) :: json_buffer) call MPI_Bcast(json_buffer, integer_val, MPI_CHARACTER, 0, NEKO_COMM, ierr) call C%params%load_from_string(json_buffer) diff --git a/src/common/global_interpolation.F90 b/src/common/global_interpolation.F90 index d7bc8980746..8329c7e8649 100644 --- a/src/common/global_interpolation.F90 +++ b/src/common/global_interpolation.F90 @@ -528,14 +528,14 @@ subroutine global_interpolation_redist(this) end if end do if (k .ne. n_points_per_pe(i)) then - write(*,*) 'PE: ', pe_rank, ' has k= ', k,& - 'points for PE:', i,' but should have: ',& + write(*,*) 'PE: ', pe_rank, ' has k= ', k, & + 'points for PE:', i,' but should have: ', & n_points_per_pe(i) call neko_error('Error in redistribution of points') end if - call MPI_Gatherv(xyz_send_to_pe,3*n_points_per_pe(i),& - MPI_DOUBLE_PRECISION, new_xyz,3*n_points_from_pe,& - 3*n_point_offset_from_pe,& + call MPI_Gatherv(xyz_send_to_pe,3*n_points_per_pe(i), & + MPI_DOUBLE_PRECISION, new_xyz,3*n_points_from_pe, & + 3*n_point_offset_from_pe, & MPI_DOUBLE_PRECISION, i, NEKO_COMM, ierr) end do @@ -572,7 +572,7 @@ subroutine global_interpolation_evaluate(this, interp_values, field) this%n_points, field) else if (this%n_points .gt. 0) & - call this%local_interp%evaluate(interp_values, this%el_owner,& + call this%local_interp%evaluate(interp_values, this%el_owner, & field, this%nelv) end if #else diff --git a/src/io/fld_file.f90 b/src/io/fld_file.f90 index 0f67a856876..8740f791995 100644 --- a/src/io/fld_file.f90 +++ b/src/io/fld_file.f90 @@ -485,7 +485,7 @@ subroutine fld_file_write(this, data, t) open(unit = 9, file = trim(this%fname(1:suffix_pos-1)) // & trim(adjustl(start_field)), status = 'replace') write(9, fmt = '(A,A,A)') 'filetemplate: ', & - this%fname(tslash_pos+1:suffix_pos-1),'%01d.f%05d' + this%fname(tslash_pos+1:suffix_pos-1), '%01d.f%05d' write(9, fmt = '(A,i5)') 'firsttimestep: ', this%start_counter write(9, fmt = '(A,i5)') 'numtimesteps: ', (this%counter + 1) - & this%start_counter @@ -684,17 +684,17 @@ subroutine fld_file_read(this, data) data%fld_series_fname = string(:scan(trim(string), '%') - 1) data%fld_series_fname = trim(data%fld_series_fname) // '0' read(9, fmt = '(A)') string - read(string(scan(string,':') + 1:), *) data%meta_start_counter + read(string(scan(string, ':') + 1:), *) data%meta_start_counter read(9, fmt = '(A)') string - read(string(scan(string,':') + 1:), *) data%meta_nsamples + read(string(scan(string, ':') + 1:), *) data%meta_nsamples close(9) call neko_log%message('Reading meta file for fld series') call neko_log%message('Name: ' // trim(data%fld_series_fname)) - write (log_buf,'(A,I7)') 'Start counter : ', & + write (log_buf, '(A,I7)') 'Start counter : ', & data%meta_start_counter call neko_log%message(log_buf) - write (log_buf,'(A,I7)') 'Number of samples: ', & + write (log_buf, '(A,I7)') 'Number of samples: ', & data%meta_nsamples call neko_log%message(log_buf) diff --git a/src/sem/dofmap.f90 b/src/sem/dofmap.f90 index e628e3b6ad0..13cd5e61791 100644 --- a/src/sem/dofmap.f90 +++ b/src/sem/dofmap.f90 @@ -979,7 +979,7 @@ subroutine gh_face_extend_3d(x, zg, n, gh_type, e, v) ! ! z-edges ! - do kk= 1, n, n-1 + do kk = 1, n, n-1 do k = 1, n do j = 1, n do i = 1, n @@ -1104,7 +1104,7 @@ subroutine arc_surface(isid, curve_data, x, y, z, Xh, element, gdim) ! make length radius xys = sqrt(xs**2 + ys**2) ! sanity check - if (abs(2.0 * radius) <= xys * 1.00001) & + if (abs(2.0 * radius) .le. xys * 1.00001) & & call neko_error('Radius to small for arced element surface') ! find center dtheta = abs(asin(0.5*xys/radius)) @@ -1141,7 +1141,7 @@ subroutine arc_surface(isid, curve_data, x, y, z, Xh, element, gdim) call addtnsr(y, ycrved, h(1,2, iyt), h(1,3, izt), Xh%lx, Xh%ly, Xh%lz) end if end subroutine arc_surface -, + subroutine compute_h(h, zgml, gdim, lx) integer, intent(in) :: lx, gdim real(kind=rp), intent(inout) :: h(lx, 3, 2) diff --git a/src/simulation_components/probes.F90 b/src/simulation_components/probes.F90 index 423d3c07202..1945bf6eadd 100644 --- a/src/simulation_components/probes.F90 +++ b/src/simulation_components/probes.F90 @@ -282,7 +282,7 @@ subroutine read_line(this, json) call json_get(json, "amount", n_points) ! If either start or end is not of length 3, error out - if (size(start) /= 3 .or. size(end) /= 3) then + if (size(start) .ne. 3 .or. size(end) .ne. 3) then call neko_error('Invalid start or end coordinates.') end if @@ -331,16 +331,16 @@ subroutine read_circle(this, json) call json_get(json, "axis", axis) ! If either center or normal is not of length 3, error out - if (size(center) /= 3 .or. size(normal) /= 3) then + if (size(center) .ne. 3 .or. size(normal) .ne. 3) then call neko_error('Invalid center or normal coordinates.') end if - if (axis /= 'x' .and. axis /= 'y' .and. axis /= 'z') then + if (axis .ne. 'x' .and. axis .ne. 'y' .and. axis .ne. 'z') then call neko_error('Invalid axis.') end if - if (radius <= 0) then + if (radius .le. 0) then call neko_error('Invalid radius.') end if - if (n_points <= 0) then + if (n_points .le. 0) then call neko_error('Invalid number of points.') end if From 086f85025863985baad68cbe1fed54a11abaecd8 Mon Sep 17 00:00:00 2001 From: Victor Baconnet Date: Tue, 10 Sep 2024 13:36:55 +0200 Subject: [PATCH 43/67] depends --- src/.depends | 56 ++++++++++++++++++++++++++-------------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/src/.depends b/src/.depends index 93a5bc80642..e08c2a65fd7 100644 --- a/src/.depends +++ b/src/.depends @@ -57,7 +57,7 @@ mesh/point_zones/sphere_point_zone.o : mesh/point_zones/sphere_point_zone.f90 ma mesh/point_zones/box_point_zone.o : mesh/point_zones/box_point_zone.f90 math/math.o common/json_utils.o config/num_types.o mesh/point_zone.o mesh/point_zones/cylinder_point_zone.o : mesh/point_zones/cylinder_point_zone.f90 common/utils.o common/json_utils.o config/num_types.o mesh/point_zone.o mesh/point_zones/combine_point_zone.o : mesh/point_zones/combine_point_zone.f90 common/log.o common/utils.o common/json_utils.o config/num_types.o mesh/point_zones/cylinder_point_zone.o mesh/point_zones/sphere_point_zone.o mesh/point_zones/box_point_zone.o mesh/point_zone.o -mesh/point_zone_fctry.o : mesh/point_zone_fctry.f90 common/utils.o common/json_utils.o mesh/point_zones/cylinder_point_zone.o mesh/point_zones/sphere_point_zone.o mesh/point_zones/box_point_zone.o +mesh/point_zone_fctry.o : mesh/point_zone_fctry.f90 common/utils.o common/json_utils.o mesh/point_zones/cylinder_point_zone.o mesh/point_zones/sphere_point_zone.o mesh/point_zones/box_point_zone.o mesh/point_zone.o mesh/point_zone_registry.o : mesh/point_zone_registry.f90 common/json_utils.o common/utils.o sem/space.o mesh/mesh.o sem/dofmap.o mesh/point_zones/combine_point_zone.o mesh/point_zone.o mesh/mesh.o : mesh/mesh.f90 common/log.o mesh/curve.o adt/uset.o math/math.o mesh/facet_zone.o comm/comm.o common/distdata.o common/datadist.o adt/htable.o adt/tuple.o adt/stack.o common/utils.o mesh/quad.o mesh/hex.o mesh/element.o mesh/point.o config/num_types.o mesh/octree.o : mesh/octree.f90 common/utils.o mesh/point.o config/num_types.o @@ -74,20 +74,20 @@ field/mesh_field.o : field/mesh_field.f90 mesh/mesh.o field/mean_field.o : field/mean_field.f90 math/field_math.o field/field.o config/num_types.o common/stats_quant.o config/neko_config.o field/mean_sqr_field.o : field/mean_sqr_field.f90 math/math.o math/bcknd/device/device_math.o field/mean_field.o config/neko_config.o config/num_types.o io/format/rea.o : io/format/rea.f90 mesh/mesh.o config/num_types.o -math/bcknd/cpu/cpu_cdtp.o : math/bcknd/cpu/cpu_cdtp.f90 -math/bcknd/cpu/cpu_conv1.o : math/bcknd/cpu/cpu_conv1.f90 -math/bcknd/cpu/cpu_dudxyz.o : math/bcknd/cpu/cpu_dudxyz.f90 -math/bcknd/cpu/cpu_opgrad.o : math/bcknd/cpu/cpu_opgrad.f90 -math/bcknd/cpu/convect_scalar.o : math/bcknd/cpu/convect_scalar.f90 math/math.o config/num_types.o -math/bcknd/cpu/set_convect_rst.o : math/bcknd/cpu/set_convect_rst.f90 config/num_types.o -math/bcknd/sx/sx_cdtp.o : math/bcknd/sx/sx_cdtp.f90 math/math.o -math/bcknd/sx/sx_conv1.o : math/bcknd/sx/sx_conv1.f90 -math/bcknd/sx/sx_dudxyz.o : math/bcknd/sx/sx_dudxyz.f90 math/math.o -math/bcknd/sx/sx_opgrad.o : math/bcknd/sx/sx_opgrad.f90 -math/bcknd/sx/sx_cfl.o : math/bcknd/sx/sx_cfl.f90 -math/bcknd/sx/sx_lambda2.o : math/bcknd/sx/sx_lambda2.f90 math/math.o -math/bcknd/sx/sx_convect_scalar.o : math/bcknd/sx/sx_convect_scalar.f90 math/math.o config/num_types.o -math/bcknd/sx/sx_set_convect_rst.o : math/bcknd/sx/sx_set_convect_rst.f90 config/num_types.o +math/bcknd/cpu/cpu_cdtp.o : math/bcknd/cpu/cpu_cdtp.f90 math/bcknd/cpu/opr_cpu.o +math/bcknd/cpu/cpu_conv1.o : math/bcknd/cpu/cpu_conv1.f90 math/bcknd/cpu/opr_cpu.o +math/bcknd/cpu/cpu_dudxyz.o : math/bcknd/cpu/cpu_dudxyz.f90 math/bcknd/cpu/opr_cpu.o +math/bcknd/cpu/cpu_opgrad.o : math/bcknd/cpu/cpu_opgrad.f90 math/bcknd/cpu/opr_cpu.o +math/bcknd/cpu/convect_scalar.o : math/bcknd/cpu/convect_scalar.f90 math/math.o config/num_types.o math/bcknd/cpu/opr_cpu.o +math/bcknd/cpu/set_convect_rst.o : math/bcknd/cpu/set_convect_rst.f90 config/num_types.o math/bcknd/cpu/opr_cpu.o +math/bcknd/sx/sx_cdtp.o : math/bcknd/sx/sx_cdtp.f90 math/math.o math/bcknd/sx/opr_sx.o +math/bcknd/sx/sx_conv1.o : math/bcknd/sx/sx_conv1.f90 math/bcknd/sx/opr_sx.o +math/bcknd/sx/sx_dudxyz.o : math/bcknd/sx/sx_dudxyz.f90 math/math.o math/bcknd/sx/opr_sx.o +math/bcknd/sx/sx_opgrad.o : math/bcknd/sx/sx_opgrad.f90 math/bcknd/sx/opr_sx.o +math/bcknd/sx/sx_cfl.o : math/bcknd/sx/sx_cfl.f90 math/bcknd/sx/opr_sx.o +math/bcknd/sx/sx_lambda2.o : math/bcknd/sx/sx_lambda2.f90 math/math.o math/bcknd/sx/opr_sx.o +math/bcknd/sx/sx_convect_scalar.o : math/bcknd/sx/sx_convect_scalar.f90 math/math.o config/num_types.o math/bcknd/sx/opr_sx.o +math/bcknd/sx/sx_set_convect_rst.o : math/bcknd/sx/sx_set_convect_rst.f90 config/num_types.o math/bcknd/sx/opr_sx.o math/operators.o : math/operators.f90 comm/comm.o field/scratch_registry.o math/bcknd/device/device_math.o device/device.o math/math.o sem/interpolation.o field/field.o sem/coef.o sem/space.o math/bcknd/device/opr_device.o math/bcknd/xsmm/opr_xsmm.o math/bcknd/sx/opr_sx.o math/bcknd/cpu/opr_cpu.o config/num_types.o config/neko_config.o math/bcknd/cpu/opr_cpu.o : math/bcknd/cpu/opr_cpu.f90 math/mathops.o sem/interpolation.o gs/gather_scatter.o field/field.o math/math.o sem/coef.o sem/space.o config/num_types.o math/bcknd/sx/opr_sx.o : math/bcknd/sx/opr_sx.f90 math/mathops.o field/field.o math/math.o sem/coef.o sem/space.o config/num_types.o sem/interpolation.o gs/gather_scatter.o @@ -150,8 +150,8 @@ bc/wall_model_bc.o : bc/wall_model_bc.f90 bc/shear_stress.o wall_models/spalding krylov/precon.o : krylov/precon.f90 config/num_types.o krylov/krylov.o : krylov/krylov.f90 config/neko_config.o krylov/bcknd/device/pc_identity_device.o krylov/pc_identity.o bc/bc.o common/utils.o field/field.o mesh/mesh.o sem/coef.o krylov/precon.o config/num_types.o math/ax.o gs/gather_scatter.o krylov/pc_identity.o : krylov/pc_identity.f90 config/num_types.o krylov/precon.o math/math.o -krylov/precon_fctry.o : krylov/precon_fctry.f90 config/neko_config.o common/utils.o krylov/pc_hsmg.o krylov/bcknd/device/pc_jacobi_device.o krylov/bcknd/sx/pc_jacobi_sx.o krylov/bcknd/cpu/pc_jacobi.o krylov/bcknd/device/pc_identity_device.o krylov/pc_identity.o -krylov/krylov_fctry.o : krylov/krylov_fctry.f90 config/neko_config.o common/utils.o krylov/precon.o config/num_types.o krylov/bcknd/device/gmres_device.o krylov/bcknd/sx/gmres_sx.o krylov/bcknd/device/cheby_device.o krylov/bcknd/cpu/cheby.o krylov/bcknd/cpu/gmres.o krylov/bcknd/cpu/bicgstab.o krylov/bcknd/device/fusedcg_cpld_device.o krylov/bcknd/device/fusedcg_device.o krylov/bcknd/device/pipecg_device.o krylov/bcknd/sx/pipecg_sx.o krylov/bcknd/cpu/pipecg.o krylov/bcknd/cpu/cacg.o krylov/bcknd/device/cg_device.o krylov/bcknd/cpu/cg_coupled.o krylov/bcknd/sx/cg_sx.o krylov/bcknd/cpu/cg.o +krylov/precon_fctry.o : krylov/precon_fctry.f90 config/neko_config.o common/utils.o krylov/pc_hsmg.o krylov/bcknd/device/pc_jacobi_device.o krylov/bcknd/sx/pc_jacobi_sx.o krylov/bcknd/cpu/pc_jacobi.o krylov/bcknd/device/pc_identity_device.o krylov/pc_identity.o krylov/precon.o +krylov/krylov_fctry.o : krylov/krylov_fctry.f90 config/neko_config.o common/utils.o krylov/precon.o config/num_types.o krylov/bcknd/device/gmres_device.o krylov/bcknd/sx/gmres_sx.o krylov/bcknd/device/cheby_device.o krylov/bcknd/cpu/cheby.o krylov/bcknd/cpu/gmres.o krylov/bcknd/cpu/bicgstab.o krylov/bcknd/device/fusedcg_cpld_device.o krylov/bcknd/device/fusedcg_device.o krylov/bcknd/device/pipecg_device.o krylov/bcknd/sx/pipecg_sx.o krylov/bcknd/cpu/pipecg.o krylov/bcknd/cpu/cacg.o krylov/bcknd/device/cg_device.o krylov/bcknd/cpu/cg_coupled.o krylov/bcknd/sx/cg_sx.o krylov/bcknd/cpu/cg.o krylov/krylov.o krylov/bcknd/cpu/cg.o : krylov/bcknd/cpu/cg.f90 comm/comm.o math/math.o bc/bc.o gs/gather_scatter.o sem/coef.o field/field.o math/ax.o krylov/precon.o krylov/krylov.o config/num_types.o krylov/bcknd/cpu/cacg.o : krylov/bcknd/cpu/cacg.f90 math/mxm_wrapper.o comm/comm.o common/utils.o math/math.o bc/bc.o gs/gather_scatter.o sem/coef.o field/field.o math/ax.o krylov/precon.o krylov/krylov.o config/num_types.o krylov/bcknd/cpu/cheby.o : krylov/bcknd/cpu/cheby.f90 comm/comm.o math/math.o bc/bc.o gs/gather_scatter.o sem/space.o mesh/mesh.o sem/coef.o field/field.o config/num_types.o math/ax.o krylov/precon.o krylov/krylov.o @@ -181,7 +181,7 @@ common/time_based_controller.o : common/time_based_controller.f90 common/utils.o common/stats_quant.o : common/stats_quant.f90 config/num_types.o common/statistics.o : common/statistics.f90 comm/comm.o common/log.o common/stats_quant.o config/num_types.o common/rhs_maker.o : common/rhs_maker.f90 field/field.o field/field_series.o config/num_types.o -common/rhs_maker_fctry.o : common/rhs_maker_fctry.f90 config/neko_config.o common/bcknd/device/rhs_maker_device.o common/bcknd/sx/rhs_maker_sx.o common/bcknd/cpu/rhs_maker_cpu.o +common/rhs_maker_fctry.o : common/rhs_maker_fctry.f90 config/neko_config.o common/bcknd/device/rhs_maker_device.o common/bcknd/sx/rhs_maker_sx.o common/bcknd/cpu/rhs_maker_cpu.o common/rhs_maker.o simulation_components/probes.o : simulation_components/probes.F90 case.o io/csv_file.o io/file.o device/device.o comm/comm.o mesh/point_zone_registry.o mesh/point_zone.o math/tensor.o common/global_interpolation.o common/json_utils.o sem/dofmap.o field/field_registry.o simulation_components/simulation_component.o field/field_list.o common/utils.o common/log.o math/matrix.o config/num_types.o simulation_components/field_writer.o : simulation_components/field_writer.f90 common/json_utils.o io/fld_file_output.o case.o math/operators.o field/field.o field/field_registry.o simulation_components/simulation_component.o config/num_types.o common/bcknd/cpu/rhs_maker_cpu.o : common/bcknd/cpu/rhs_maker_cpu.f90 field/scratch_registry.o config/num_types.o field/field.o field/field_series.o common/rhs_maker.o @@ -191,23 +191,23 @@ common/material_properties.o : common/material_properties.f90 comm/comm.o common config/neko_config.o : config/neko_config.f90 case.o : case.f90 common/material_properties.o mesh/point_zone_registry.o field/scratch_registry.o common/json_utils.o scalar/scalar_pnpn.o common/user_intf.o common/jobctrl.o common/log.o time_schemes/time_scheme_controller.o comm/comm.o mesh/mesh.o common/utils.o io/file.o common/statistics.o scalar/scalar_ic.o fluid/flow_ic.o common/sampler.o comm/redist.o comm/parmetis.o field/mesh_field.o io/fluid_stats_output.o io/mean_flow_output.o io/mean_sqr_flow_output.o io/chkp_output.o io/fluid_output.o fluid/fluid_scheme.o fluid/fluid_pnpn.o config/num_types.o common/user_intf.o : common/user_intf.f90 common/log.o common/utils.o common/json_utils.o config/num_types.o bc/field_dirichlet.o bc/usr_scalar.o bc/usr_inflow.o mesh/mesh.o bc/bc.o sem/coef.o scalar/scalar_user_source_term.o fluid/fluid_user_source_term.o field/field_list.o field/field.o -fluid/stress_formulation/pnpn_res_stress_fctry.o : fluid/stress_formulation/pnpn_res_stress_fctry.f90 fluid/stress_formulation/bcknd/device/pnpn_res_stress_device.o fluid/stress_formulation/bcknd/cpu/pnpn_res_stress_cpu.o config/neko_config.o +fluid/stress_formulation/pnpn_res_stress_fctry.o : fluid/stress_formulation/pnpn_res_stress_fctry.f90 fluid/stress_formulation/bcknd/device/pnpn_res_stress_device.o fluid/stress_formulation/bcknd/cpu/pnpn_res_stress_cpu.o config/neko_config.o fluid/pnpn_res.o fluid/stress_formulation/bcknd/cpu/pnpn_res_stress_cpu.o : fluid/stress_formulation/bcknd/cpu/pnpn_res_stress_cpu.f90 math/math.o sem/space.o config/num_types.o mesh/mesh.o field/scratch_registry.o fluid/pnpn_res.o bc/facet_normal.o sem/coef.o math/ax.o field/field.o math/operators.o gs/gather_scatter.o fluid/stress_formulation/bcknd/device/pnpn_res_stress_device.o : fluid/stress_formulation/bcknd/device/pnpn_res_stress_device.F90 math/bcknd/device/device_math.o math/bcknd/device/device_mathops.o sem/space.o config/num_types.o mesh/mesh.o field/scratch_registry.o fluid/pnpn_res.o bc/facet_normal.o sem/coef.o math/ax.o field/field.o math/operators.o common/utils.o gs/gather_scatter.o fluid/fluid_scheme.o : fluid/fluid_scheme.f90 math/field_math.o common/time_step_controller.o field/field_series.o common/material_properties.o common/utils.o common/user_intf.o field/scratch_registry.o common/json_utils.o field/field_registry.o common/log.o math/operators.o time_schemes/time_scheme_controller.o math/bcknd/device/device_math.o math/math.o mesh/mesh.o bc/bc.o fluid/fluid_stats.o krylov/precon.o krylov/pc_hsmg.o krylov/bcknd/device/pc_jacobi_device.o krylov/bcknd/sx/pc_jacobi_sx.o krylov/bcknd/cpu/pc_jacobi.o bc/field_dirichlet_vector.o bc/field_dirichlet.o bc/symmetry.o bc/dong_outflow.o bc/dirichlet.o bc/blasius.o bc/usr_inflow.o bc/inflow.o bc/wall.o sem/coef.o krylov/krylov.o sem/dofmap.o sem/space.o field/field.o fluid/fluid_source_term.o comm/comm.o config/num_types.o fluid/mean_flow.o common/checkpoint.o config/neko_config.o fluid/mean_sqr_flow.o gs/gather_scatter.o fluid/fluid_aux.o : fluid/fluid_aux.f90 krylov/krylov.o config/num_types.o common/log.o fluid/fluid_pnpn.o : fluid/fluid_pnpn.f90 math/field_math.o common/utils.o bc/bc.o math/mathops.o math/math.o config/neko_config.o gs/gs_ops.o common/time_step_controller.o common/user_intf.o mesh/mesh.o bc/non_normal.o bc/facet_normal.o bc/dirichlet.o field/field.o math/ax.o common/material_properties.o common/json_utils.o common/profiler.o fluid/advection.o device/device.o common/projection.o time_schemes/time_scheme_controller.o fluid/fluid_aux.o math/bcknd/device/device_mathops.o fluid/fluid_scheme.o fluid/fluid_volflow.o common/rhs_maker.o fluid/pnpn_res.o krylov/krylov.o config/num_types.o -fluid/fluid_fctry.o : fluid/fluid_fctry.f90 common/utils.o fluid/fluid_pnpn.o +fluid/fluid_fctry.o : fluid/fluid_fctry.f90 common/utils.o fluid/fluid_pnpn.o fluid/fluid_scheme.o fluid/fluid_volflow.o : fluid/fluid_volflow.f90 math/ax.o bc/bc.o field/scratch_registry.o common/json_utils.o gs/gather_scatter.o math/bcknd/device/device_mathops.o math/bcknd/device/device_math.o config/neko_config.o comm/comm.o math/math.o time_schemes/time_scheme_controller.o sem/coef.o field/field.o sem/dofmap.o krylov/precon.o krylov/krylov.o math/mathops.o config/num_types.o math/operators.o fluid/pnpn_res.o : fluid/pnpn_res.f90 config/num_types.o mesh/mesh.o sem/space.o bc/facet_normal.o sem/coef.o field/field.o math/ax.o gs/gather_scatter.o -fluid/pnpn_res_fctry.o : fluid/pnpn_res_fctry.f90 fluid/bcknd/sx/pnpn_res_sx.o fluid/bcknd/cpu/pnpn_res_cpu.o fluid/bcknd/device/pnpn_res_device.o config/neko_config.o +fluid/pnpn_res_fctry.o : fluid/pnpn_res_fctry.f90 fluid/bcknd/sx/pnpn_res_sx.o fluid/bcknd/cpu/pnpn_res_cpu.o fluid/bcknd/device/pnpn_res_device.o config/neko_config.o fluid/pnpn_res.o fluid/mean_flow.o : fluid/mean_flow.f90 field/field.o field/mean_field.o fluid/fluid_stats.o : fluid/fluid_stats.f90 common/utils.o config/neko_config.o device/device.o common/stats_quant.o field/field_list.o field/field.o sem/coef.o math/operators.o math/math.o config/num_types.o math/bcknd/device/device_math.o field/mean_field.o fluid/mean_sqr_flow.o : fluid/mean_sqr_flow.f90 field/field.o field/mean_sqr_field.o fluid/flow_profile.o : fluid/flow_profile.f90 config/num_types.o fluid/flow_ic.o : fluid/flow_ic.f90 sem/space.o sem/interpolation.o common/global_interpolation.o io/file.o common/checkpoint.o io/fld_file.o io/fld_file_data.o mesh/point_zone_registry.o mesh/point_zone.o common/json_utils.o common/user_intf.o math/bcknd/device/device_math.o math/math.o sem/coef.o common/utils.o field/field.o device/device.o fluid/flow_profile.o config/neko_config.o gs/gather_scatter.o common/log.o config/num_types.o fluid/advection.o : fluid/advection.f90 time_schemes/time_scheme_controller.o field/field_series.o sem/coef.o field/field.o sem/space.o config/num_types.o -fluid/advection_fctry.o : fluid/advection_fctry.f90 fluid/bcknd/advection/adv_oifs.o fluid/bcknd/advection/adv_no_dealias.o fluid/bcknd/advection/adv_dealias.o common/json_utils.o +fluid/advection_fctry.o : fluid/advection_fctry.f90 fluid/bcknd/advection/adv_oifs.o fluid/bcknd/advection/adv_no_dealias.o fluid/bcknd/advection/adv_dealias.o common/json_utils.o fluid/advection.o fluid/bcknd/advection/adv_dealias.o : fluid/bcknd/advection/adv_dealias.f90 device/device.o sem/interpolation.o math/operators.o config/neko_config.o math/bcknd/device/device_math.o sem/coef.o field/field.o sem/space.o math/math.o config/num_types.o fluid/advection.o fluid/bcknd/advection/adv_no_dealias.o : fluid/bcknd/advection/adv_no_dealias.f90 device/device.o math/operators.o config/neko_config.o math/bcknd/device/device_math.o sem/coef.o field/field.o sem/space.o math/math.o config/num_types.o fluid/advection.o fluid/bcknd/advection/adv_oifs.o : fluid/bcknd/advection/adv_oifs.f90 device/device.o time_schemes/time_scheme_controller.o field/field_series.o common/time_interpolator.o sem/interpolation.o config/neko_config.o math/operators.o math/math.o sem/coef.o field/field.o sem/space.o config/num_types.o fluid/advection.o @@ -218,7 +218,7 @@ fluid/fluid_user_source_term.o : fluid/fluid_user_source_term.f90 sem/dofmap.o m fluid/fluid_source_term.o : fluid/fluid_source_term.f90 common/utils.o common/user_intf.o sem/coef.o common/json_utils.o field/field_list.o field/field.o source_terms/source_term.o fluid/fluid_user_source_term.o config/num_types.o config/neko_config.o common/time_step_controller.o : common/time_step_controller.f90 common/json_utils.o common/log.o config/num_types.o simulation.o : simulation.f90 common/time_step_controller.o common/json_utils.o simulation_components/simcomp_executor.o common/profiler.o field/field.o common/jobctrl.o common/log.o io/file.o time_schemes/time_scheme_controller.o config/num_types.o case.o -math/ax_helm_fctry.o : math/ax_helm_fctry.f90 common/utils.o math/bcknd/cpu/ax_helm_full_cpu.o math/bcknd/cpu/ax_helm_cpu.o math/ax_helm.o math/bcknd/sx/ax_helm_sx.o math/bcknd/xsmm/ax_helm_xsmm.o math/bcknd/device/ax_helm_device.o config/neko_config.o +math/ax_helm_fctry.o : math/ax_helm_fctry.f90 common/utils.o math/bcknd/cpu/ax_helm_full_cpu.o math/bcknd/cpu/ax_helm_cpu.o math/ax_helm.o math/bcknd/sx/ax_helm_sx.o math/bcknd/xsmm/ax_helm_xsmm.o math/bcknd/device/ax_helm_device.o config/neko_config.o math/ax.o math/ax_helm.o : math/ax_helm.f90 math/math.o mesh/mesh.o sem/space.o sem/coef.o config/num_types.o math/ax.o math/ax_helm_full.o : math/ax_helm_full.f90 common/utils.o math/math.o mesh/mesh.o sem/space.o sem/coef.o config/num_types.o math/ax.o math/bcknd/cpu/ax_helm_cpu.o : math/bcknd/cpu/ax_helm_cpu.f90 math/math.o mesh/mesh.o sem/space.o sem/coef.o config/num_types.o math/ax_helm.o @@ -259,7 +259,7 @@ scalar/scalar_scheme.o : scalar/scalar_scheme.f90 common/time_step_controller.o scalar/scalar_pnpn.o : scalar/scalar_pnpn.f90 field/scratch_registry.o common/time_step_controller.o config/neko_config.o common/material_properties.o common/user_intf.o common/json_utils.o common/profiler.o fluid/advection.o common/log.o math/math.o common/projection.o time_schemes/time_scheme_controller.o scalar/scalar_aux.o math/bcknd/device/device_math.o krylov/krylov.o bc/facet_normal.o field/field_series.o math/ax.o scalar/scalar_residual.o gs/gather_scatter.o device/device.o sem/coef.o common/checkpoint.o mesh/mesh.o bc/bc.o field/field.o bc/neumann.o bc/dirichlet.o scalar/scalar_scheme.o common/rhs_maker.o config/num_types.o scalar/scalar_aux.o : scalar/scalar_aux.f90 krylov/krylov.o config/num_types.o common/log.o scalar/scalar_residual.o : scalar/scalar_residual.f90 config/num_types.o mesh/mesh.o sem/space.o bc/facet_normal.o scalar/source_scalar.o sem/coef.o field/field.o math/ax.o gs/gather_scatter.o -scalar/scalar_residual_fctry.o : scalar/scalar_residual_fctry.f90 scalar/bcknd/sx/scalar_residual_sx.o scalar/bcknd/cpu/scalar_residual_cpu.o scalar/bcknd/device/scalar_residual_device.o config/neko_config.o +scalar/scalar_residual_fctry.o : scalar/scalar_residual_fctry.f90 scalar/bcknd/sx/scalar_residual_sx.o scalar/bcknd/cpu/scalar_residual_cpu.o scalar/bcknd/device/scalar_residual_device.o config/neko_config.o scalar/scalar_residual.o scalar/scalar_ic.o : scalar/scalar_ic.f90 sem/space.o sem/interpolation.o common/global_interpolation.o io/file.o common/checkpoint.o io/fld_file.o io/fld_file_data.o common/log.o field/field_registry.o mesh/point_zone_registry.o mesh/point_zone.o common/json_utils.o common/user_intf.o math/math.o sem/coef.o common/utils.o field/field.o device/device.o math/bcknd/device/device_math.o config/num_types.o config/neko_config.o gs/gather_scatter.o scalar/scalar_source_term.o : scalar/scalar_source_term.f90 common/utils.o common/user_intf.o sem/coef.o common/json_utils.o field/field_list.o field/field.o source_terms/source_term.o scalar/scalar_user_source_term.o config/num_types.o config/neko_config.o scalar/scalar_user_source_term.o : scalar/scalar_user_source_term.f90 sem/dofmap.o math/math.o math/bcknd/device/device_math.o device/device.o sem/coef.o field/field_list.o source_terms/source_term.o common/utils.o config/num_types.o config/neko_config.o @@ -273,7 +273,7 @@ simulation_components/lambda2.o : simulation_components/lambda2.f90 device/devic simulation_components/weak_grad.o : simulation_components/weak_grad.f90 simulation_components/field_writer.o common/json_utils.o io/fld_file_output.o case.o math/operators.o field/field.o field/field_registry.o simulation_components/simulation_component.o config/num_types.o simulation_components/derivative.o : simulation_components/derivative.f90 common/utils.o simulation_components/field_writer.o common/json_utils.o io/fld_file_output.o case.o math/operators.o field/field.o field/field_registry.o simulation_components/simulation_component.o config/num_types.o simulation_components/les_simcomp.o : simulation_components/les_simcomp.f90 simulation_components/field_writer.o common/json_utils.o les/les_model.o case.o simulation_components/simulation_component.o config/num_types.o -simulation_components/simulation_component_fctry.o : simulation_components/simulation_component_fctry.f90 simulation_components/derivative.o simulation_components/weak_grad.o simulation_components/field_writer.o common/utils.o simulation_components/les_simcomp.o simulation_components/probes.o simulation_components/lambda2.o simulation_components/vorticity.o +simulation_components/simulation_component_fctry.o : simulation_components/simulation_component_fctry.f90 simulation_components/derivative.o simulation_components/weak_grad.o simulation_components/field_writer.o common/utils.o simulation_components/les_simcomp.o simulation_components/probes.o simulation_components/lambda2.o simulation_components/vorticity.o simulation_components/simulation_component.o source_terms/source_term.o : source_terms/source_term.f90 field/field_list.o sem/coef.o config/num_types.o source_terms/const_source_term.o : source_terms/const_source_term.f90 source_terms/bcknd/device/const_source_term_device.o source_terms/bcknd/cpu/const_source_term_cpu.o common/utils.o config/neko_config.o sem/coef.o source_terms/source_term.o common/json_utils.o field/field_list.o config/num_types.o source_terms/bcknd/cpu/const_source_term_cpu.o : source_terms/bcknd/cpu/const_source_term_cpu.f90 math/math.o field/field_list.o config/num_types.o @@ -281,12 +281,12 @@ source_terms/bcknd/device/const_source_term_device.o : source_terms/bcknd/device source_terms/boussinesq_source_term.o : source_terms/boussinesq_source_term.f90 field/field_registry.o source_terms/bcknd/device/boussinesq_source_term_device.o source_terms/bcknd/cpu/boussinesq_source_term_cpu.o common/utils.o config/neko_config.o sem/coef.o source_terms/source_term.o common/json_utils.o field/field.o field/field_list.o config/num_types.o source_terms/bcknd/cpu/boussinesq_source_term_cpu.o : source_terms/bcknd/cpu/boussinesq_source_term_cpu.f90 math/math.o field/field.o field/field_list.o config/num_types.o source_terms/bcknd/device/boussinesq_source_term_device.o : source_terms/bcknd/device/boussinesq_source_term_device.f90 math/bcknd/device/device_math.o field/field.o field/field_list.o config/num_types.o -source_terms/source_term_fctry.o : source_terms/source_term_fctry.f90 common/utils.o common/json_utils.o source_terms/brinkman_source_term.o source_terms/boussinesq_source_term.o source_terms/const_source_term.o +source_terms/source_term_fctry.o : source_terms/source_term_fctry.f90 common/utils.o common/json_utils.o source_terms/brinkman_source_term.o source_terms/boussinesq_source_term.o source_terms/const_source_term.o source_terms/source_term.o source_terms/brinkman_source_term.o : source_terms/brinkman_source_term.f90 mesh/point_zone_registry.o mesh/point_zone.o mesh/search_tree/aabb.o common/profiler.o math/signed_distance.o source_terms/brinkman/filters.o device/device.o mesh/tri_mesh.o io/file.o math/field_math.o common/utils.o config/neko_config.o sem/coef.o source_terms/source_term.o field/field_registry.o common/json_utils.o field/field_list.o field/field.o config/num_types.o source_terms/brinkman/filters.o : source_terms/brinkman/filters.f90 source_terms/bcknd/cpu/filters_cpu.o config/num_types.o field/field.o source_terms/bcknd/cpu/filters_cpu.o : source_terms/bcknd/cpu/filters_cpu.f90 config/num_types.o les/les_model.o : les/les_model.f90 math/bcknd/device/device_math.o math/math.o device/device.o config/neko_config.o gs/gs_ops.o sem/coef.o sem/dofmap.o field/field_registry.o field/field.o config/num_types.o -les/les_model_fctry.o : les/les_model_fctry.f90 common/utils.o les/sigma.o les/dynamic_smagorinsky.o les/smagorinsky.o les/vreman.o +les/les_model_fctry.o : les/les_model_fctry.f90 common/utils.o les/sigma.o les/dynamic_smagorinsky.o les/smagorinsky.o les/vreman.o les/les_model.o les/vreman.o : les/vreman.f90 sem/coef.o les/bcknd/cpu/vreman_cpu.o config/neko_config.o common/utils.o common/json_utils.o sem/dofmap.o les/les_model.o field/field.o config/num_types.o les/bcknd/cpu/vreman_cpu.o : les/bcknd/cpu/vreman_cpu.f90 gs/gs_ops.o sem/coef.o math/operators.o field/field.o field/field_registry.o field/scratch_registry.o math/math.o field/field_list.o config/num_types.o les/smagorinsky.o : les/smagorinsky.f90 sem/coef.o les/bcknd/cpu/smagorinsky_cpu.o config/neko_config.o common/utils.o common/json_utils.o sem/dofmap.o les/les_model.o field/field.o config/num_types.o @@ -300,6 +300,6 @@ les/bcknd/cpu/sigma_cpu.o : les/bcknd/cpu/sigma_cpu.f90 gs/gs_ops.o sem/coef.o m wall_models/wall_model.o : wall_models/wall_model.f90 common/log.o comm/comm.o math/math.o common/utils.o math/vector.o device/device.o config/neko_config.o sem/coef.o sem/dofmap.o field/field_registry.o field/field.o config/num_types.o wall_models/rough_log_law.o : wall_models/rough_log_law.f90 common/utils.o common/json_utils.o field/field_registry.o wall_models/wall_model.o config/neko_config.o sem/coef.o sem/dofmap.o config/num_types.o field/field.o wall_models/spalding.o : wall_models/spalding.f90 common/utils.o common/log.o common/json_utils.o field/field_registry.o wall_models/wall_model.o config/neko_config.o sem/coef.o sem/dofmap.o config/num_types.o field/field.o -wall_models/wall_model_fctry.o : wall_models/wall_model_fctry.f90 common/json_utils.o common/utils.o wall_models/rough_log_law.o wall_models/spalding.o les/vreman.o +wall_models/wall_model_fctry.o : wall_models/wall_model_fctry.f90 common/json_utils.o common/utils.o wall_models/rough_log_law.o wall_models/spalding.o les/vreman.o wall_models/wall_model.o neko.o : neko.f90 common/json_utils.o bc/field_dirichlet_vector.o bc/field_dirichlet.o mesh/point_zone_registry.o mesh/point_zones/sphere_point_zone.o mesh/point_zones/box_point_zone.o mesh/point_zone.o sem/point_interpolator.o common/time_interpolator.o io/data_streamer.o simulation_components/simcomp_executor.o field/scratch_registry.o field/field_registry.o qoi/drag_torque.o common/system.o sem/spectral_error_indicator.o simulation_components/probes.o simulation_components/simulation_component.o math/tensor.o math/matrix.o math/vector.o scalar/scalar_user_source_term.o fluid/fluid_user_source_term.o field/field_list.o fluid/fluid_stats.o sem/cpr.o sem/map_1d.o math/bcknd/device/device_math.o device/device.o common/jobctrl.o common/signal.o common/user_intf.o common/projection.o math/mathops.o math/operators.o simulation.o io/output.o common/sampler.o case.o config/neko_config.o comm/parmetis.o math/ax.o bc/dirichlet.o bc/wall.o bc/bc.o sem/coef.o gs/gather_scatter.o comm/mpi_types.o field/field.o io/file.o common/global_interpolation.o math/mxm_wrapper.o io/format/map.o field/mesh_field.o mesh/point.o mesh/mesh.o adt/tuple.o adt/stack.o adt/uset.o adt/htable.o sem/space.o sem/dofmap.o sem/speclib.o math/math.o common/log.o common/utils.o comm/comm.o config/num_types.o driver.o : driver.f90 neko.o From a87fd8e1dc7be9c50b1d468525decd272c9935f2 Mon Sep 17 00:00:00 2001 From: Victor Baconnet Date: Tue, 10 Sep 2024 13:37:38 +0200 Subject: [PATCH 44/67] fld file --- src/io/fld_file.f90 | 53 ++++++++++++++++++++------------------------- 1 file changed, 24 insertions(+), 29 deletions(-) diff --git a/src/io/fld_file.f90 b/src/io/fld_file.f90 index 7e9619b179d..0a204a826e7 100644 --- a/src/io/fld_file.f90 +++ b/src/io/fld_file.f90 @@ -229,9 +229,9 @@ subroutine fld_file_write(this, data, t) end select ! Fix things for pointers that do not exist in all data types... if (associated(dof)) then - x%ptr => dof%x(:, 1, 1, 1) - y%ptr => dof%y(:, 1, 1, 1) - z%ptr => dof%z(:, 1, 1, 1) + x%ptr => dof%x(:,1,1,1) + y%ptr => dof%y(:,1,1,1) + z%ptr => dof%z(:,1,1,1) msh => dof%msh Xh => dof%Xh end if @@ -637,7 +637,7 @@ subroutine fld_file_write_vector_field(this, fh, byte_offset, x, y, z, n, & end do end if end do - call MPI_File_write_at_all(fh, byte_offset, tmp_dp, gdim * n, & + call MPI_File_write_at_all(fh, byte_offset, tmp_dp, gdim*n, & MPI_DOUBLE_PRECISION, status, ierr) else i = 1 @@ -657,7 +657,7 @@ subroutine fld_file_write_vector_field(this, fh, byte_offset, x, y, z, n, & end do end if end do - call MPI_File_write_at_all(fh, byte_offset, tmp_sp, gdim * n, & + call MPI_File_write_at_all(fh, byte_offset, tmp_sp, gdim*n, & MPI_REAL, status, ierr) end if @@ -726,16 +726,11 @@ subroutine fld_file_read(this, data) if (this%counter .ge. data%meta_nsamples+data%meta_start_counter) then call neko_error('Trying to read more fld files than exist') end if - - ! Reappend path to the file series name since we lose it during the - ! meta file reading - if (trim(path) .ne. "none") fname = trim(path) // trim(fname) else suffix_pos = filename_suffix_pos(this%fname) write(id_str, '(a,i5.5)') 'f', this%counter - fname = trim(this%fname(1:suffix_pos - 1)) // '.'//id_str + fname = trim(this%fname(1:suffix_pos-1))//'.'//id_str end if - call MPI_File_open(NEKO_COMM, trim(fname), & MPI_MODE_RDONLY, MPI_INFO_NULL, fh, ierr) @@ -776,9 +771,9 @@ subroutine fld_file_read(this, data) this%dp_precision = .false. end if if (this%dp_precision) then - allocate(tmp_dp(data%gdim * n)) + allocate(tmp_dp(data%gdim*n)) else - allocate(tmp_sp(data%gdim * n)) + allocate(tmp_sp(data%gdim*n)) end if @@ -814,10 +809,10 @@ subroutine fld_file_read(this, data) n_scalars = 0 if (rdcode(i) .eq. 'S') then i = i + 1 - read(rdcode(i), *) n_scalars + read(rdcode(i),*) n_scalars n_scalars = n_scalars*10 i = i + 1 - read(rdcode(i), *) j + read(rdcode(i),*) j n_scalars = n_scalars+j i = i + 1 if (allocated(data%s)) then @@ -978,8 +973,8 @@ subroutine fld_file_read_vector_field(this, fh, byte_offset, & integer :: n, ierr, lxyz, i, j, e, nd n = x%n - nd = n * fld_data%gdim - lxyz = fld_data%lx * fld_data%ly * fld_data%lz + nd = n*fld_data%gdim + lxyz = fld_data%lx*fld_data%ly*fld_data%lz if (this%dp_precision) then call MPI_File_read_at_all(fh, byte_offset, tmp_dp, nd, & @@ -994,17 +989,17 @@ subroutine fld_file_read_vector_field(this, fh, byte_offset, & i = 1 do e = 1, fld_data%nelv do j = 1, lxyz - x%x((e - 1)*lxyz+j) = tmp_dp(i) - i = i + 1 + x%x((e-1)*lxyz+j) = tmp_dp(i) + i = i +1 end do do j = 1, lxyz - y%x((e - 1)*lxyz+j) = tmp_dp(i) - i = i + 1 + y%x((e-1)*lxyz+j) = tmp_dp(i) + i = i +1 end do if (fld_data%gdim .eq. 3) then do j = 1, lxyz - z%x((e - 1)*lxyz+j) = tmp_dp(i) - i = i + 1 + z%x((e-1)*lxyz+j) = tmp_dp(i) + i = i +1 end do end if end do @@ -1012,17 +1007,17 @@ subroutine fld_file_read_vector_field(this, fh, byte_offset, & i = 1 do e = 1, fld_data%nelv do j = 1, lxyz - x%x((e - 1)*lxyz+j) = tmp_sp(i) - i = i + 1 + x%x((e-1)*lxyz+j) = tmp_sp(i) + i = i +1 end do do j = 1, lxyz - y%x((e - 1)*lxyz+j) = tmp_sp(i) - i = i + 1 + y%x((e-1)*lxyz+j) = tmp_sp(i) + i = i +1 end do if (fld_data%gdim .eq. 3) then do j = 1, lxyz - z%x((e - 1)*lxyz+j) = tmp_sp(i) - i = i + 1 + z%x((e-1)*lxyz+j) = tmp_sp(i) + i = i +1 end do end if end do From 5ff35b64cb935541d35e456b4432dff38472fcae Mon Sep 17 00:00:00 2001 From: Victor Baconnet Date: Tue, 10 Sep 2024 13:46:45 +0200 Subject: [PATCH 45/67] revert dofmap --- src/sem/dofmap.f90 | 231 +++++++++++++++++++++++++-------------------- 1 file changed, 127 insertions(+), 104 deletions(-) diff --git a/src/sem/dofmap.f90 b/src/sem/dofmap.f90 index 92128ceac8a..b38cfb28ad8 100644 --- a/src/sem/dofmap.f90 +++ b/src/sem/dofmap.f90 @@ -51,12 +51,12 @@ module dofmap private type, public :: dofmap_t - integer(kind=i8), allocatable :: dof(:, :, :, :) !< Mapping to unique dof - logical, allocatable :: shared_dof(:, :, :, :) !< True if the dof is shared - real(kind=rp), allocatable :: x(:, :, :, :) !< Mapping to x-coordinates - real(kind=rp), allocatable :: y(:, :, :, :) !< Mapping to y-coordinates - real(kind=rp), allocatable :: z(:, :, :, :) !< Mapping to z-coordinates - integer, private :: ntot !< Total number of dofs + integer(kind=i8), allocatable :: dof(:,:,:,:) !< Mapping to unique dof + logical, allocatable :: shared_dof(:,:,:,:) !< True if the dof is shared + real(kind=rp), allocatable :: x(:,:,:,:) !< Mapping to x-coordinates + real(kind=rp), allocatable :: y(:,:,:,:) !< Mapping to y-coordinates + real(kind=rp), allocatable :: z(:,:,:,:) !< Mapping to z-coordinates + integer, private :: ntot !< Total number of dofs type(mesh_t), pointer :: msh type(space_t), pointer :: Xh @@ -138,11 +138,11 @@ function dofmap_init(msh, Xh) result(this) call device_map(this%z, this%z_d, this%ntot) call device_memcpy(this%x, this%x_d, this%ntot, & - HOST_TO_DEVICE, sync = .false.) + HOST_TO_DEVICE, sync=.false.) call device_memcpy(this%y, this%y_d, this%ntot, & - HOST_TO_DEVICE, sync = .false.) + HOST_TO_DEVICE, sync=.false.) call device_memcpy(this%z, this%z_d, this%ntot, & - HOST_TO_DEVICE, sync = .false.) + HOST_TO_DEVICE, sync=.false.) end if end function dofmap_init @@ -239,10 +239,10 @@ subroutine dofmap_number_edges(this) num_dofs_edges(2) = int(Xh%ly - 2, i8) num_dofs_edges(3) = int(Xh%lz - 2, i8) edge_offset = int(msh%glb_mpts, i8) + int(1, 4) - + do i = 1, msh%nelv - select type (ep => msh%elements(i)%e) + select type(ep=>msh%elements(i)%e) type is (hex_t) ! ! Number edges in r-direction @@ -288,27 +288,37 @@ subroutine dofmap_number_edges(this) shared_dof = msh%is_shared(edge) global_id = msh%get_global(edge) edge_id = edge_offset + int((global_id - 1), i8) * num_dofs_edges(1) - do j = 2, Xh%lx - 1 - k = j - if (int(edge%x(1), i8) .ne. this%dof(1, Xh%ly,1,i)) k = Xh%lx+1-j - this%dof(k, Xh%ly, 1, i) = edge_id - this%shared_dof(k, Xh%ly, 1, i) = shared_dof - edge_id = edge_id + 1 - end do - + if(int(edge%x(1), i8) .ne. this%dof(1,Xh%ly,1,i)) then + do concurrent (j = 2:Xh%lx - 1) + k = Xh%lx+1-j + this%dof(k, Xh%ly, 1, i) = edge_id + (j-2) + this%shared_dof(k, Xh%ly, 1, i) = shared_dof + end do + else + do concurrent (j = 2:Xh%lx - 1) + k = j + this%dof(k, Xh%ly, 1, i) = edge_id + (j-2) + this%shared_dof(k, Xh%ly, 1, i) = shared_dof + end do + end if + call ep%edge_id(edge, 4) shared_dof = msh%is_shared(edge) global_id = msh%get_global(edge) edge_id = edge_offset + int((global_id - 1), i8) * num_dofs_edges(1) - do j = 2, Xh%lx - 1 - k = j - if (int(edge%x(1), i8) .ne. this%dof(1, Xh%ly, Xh%lz,i)) then + if(int(edge%x(1), i8) .ne. this%dof(1,Xh%ly,Xh%lz,i)) then + do concurrent (j = 2:Xh%lx - 1) k = Xh%lx+1-j - end if - this%dof(k, Xh%ly, Xh%lz, i) = edge_id - this%shared_dof(k, Xh%ly, Xh%lz, i) = shared_dof - edge_id = edge_id + 1 - end do + this%dof(k, Xh%ly, Xh%lz, i) = edge_id + (j-2) + this%shared_dof(k, Xh%ly, Xh%lz, i) = shared_dof + end do + else + do concurrent (j = 2:Xh%lx - 1) + k = j + this%dof(k, Xh%ly, Xh%lz, i) = edge_id + (j-2) + this%shared_dof(k, Xh%ly, Xh%lz, i) = shared_dof + end do + end if ! @@ -318,25 +328,37 @@ subroutine dofmap_number_edges(this) shared_dof = msh%is_shared(edge) global_id = msh%get_global(edge) edge_id = edge_offset + int((global_id - 1), i8) * num_dofs_edges(2) - do j = 2, Xh%ly - 1 - k = j - if (int(edge%x(1), i8) .ne. this%dof(1,1,1,i)) k = Xh%ly+1-j - this%dof(1, k, 1, i) = edge_id - this%shared_dof(1, k, 1, i) = shared_dof - edge_id = edge_id + 1 - end do - + if(int(edge%x(1), i8) .ne. this%dof(1,1,1,i)) then + do concurrent (j = 2:Xh%ly - 1) + k = Xh%ly+1-j + this%dof(1, k, 1, i) = edge_id + (j-2) + this%shared_dof(1, k, 1, i) = shared_dof + end do + else + do concurrent (j = 2:Xh%ly - 1) + k = j + this%dof(1, k, 1, i) = edge_id + (j-2) + this%shared_dof(1, k, 1, i) = shared_dof + end do + end if + call ep%edge_id(edge, 7) shared_dof = msh%is_shared(edge) global_id = msh%get_global(edge) edge_id = edge_offset + int((global_id - 1), i8) * num_dofs_edges(2) - do j = 2, Xh%ly - 1 - k = j - if (int(edge%x(1), i8) .ne. this%dof(1,1, Xh%lz,i)) k = Xh%ly+1-j - this%dof(1, k, Xh%lz, i) = edge_id - this%shared_dof(1, k, Xh%lz, i) = shared_dof - edge_id = edge_id + 1 - end do + if(int(edge%x(1), i8) .ne. this%dof(1,1,Xh%lz,i)) then + do concurrent (j = 2:Xh%ly - 1) + k = Xh%ly+1-j + this%dof(1, k, Xh%lz, i) = edge_id + (j-2) + this%shared_dof(1, k, Xh%lz, i) = shared_dof + end do + else + do concurrent (j = 2:Xh%ly - 1) + k = j + this%dof(1, k, Xh%lz, i) = edge_id + (j-2) + this%shared_dof(1, k, Xh%lz, i) = shared_dof + end do + end if call ep%edge_id(edge, 6) shared_dof = msh%is_shared(edge) @@ -665,26 +687,26 @@ pure function dofmap_facetidx(face_order, face, facet_id, k1, j1, lk1, lj1) resu ! 1 -------- 2 0--->j - if (face_order%x(1) .eq. face%x(1)) then - if (face_order%x(2) .lt. face_order%x(4)) then + if(face_order%x(1) .eq. face%x(1)) then + if(face_order%x(2) .lt. face_order%x(4)) then facet_idx = facet_id + j + k*lj else facet_idx = facet_id + j*lk + k end if - else if (face_order%x(2) .eq. face%x(1)) then - if (face_order%x(3) .lt. face_order%x(1)) then + else if(face_order%x(2) .eq. face%x(1)) then + if(face_order%x(3) .lt. face_order%x(1)) then facet_idx = facet_id + lk*(lj-1-j) + k else facet_idx = facet_id + (lj-1-j) + k*lj end if - else if (face_order%x(3) .eq. face%x(1)) then - if (face_order%x(4) .lt. face_order%x(2)) then + else if(face_order%x(3) .eq. face%x(1)) then + if(face_order%x(4) .lt. face_order%x(2)) then facet_idx = facet_id + (lj-1-j) + lj*(lk-1-k) else facet_idx = facet_id + lk*(lj-1-j) + (lk-1-k) end if - else if (face_order%x(4) .eq. face%x(1)) then - if (face_order%x(1) .lt. face_order%x(3)) then + else if(face_order%x(4) .eq. face%x(1)) then + if(face_order%x(1) .lt. face_order%x(3)) then facet_idx = facet_id + lk*j + (lk-1-k) else facet_idx = facet_id + j + lj*(lk-1-k) @@ -717,7 +739,7 @@ subroutine dofmap_generate_xyz(this) call dofmap_xyzlin(Xh, msh, msh%elements(i)%e, this%x(1,1,1,i), & this%y(1,1,1,i), this%z(1,1,1,i)) end do - do i = 1, msh%curve%size + do i =1, msh%curve%size midpoint = .false. el_idx = msh%curve%curve_el(i)%el_idx curve_type = msh%curve%curve_el(i)%curve_type @@ -729,18 +751,18 @@ subroutine dofmap_generate_xyz(this) end do if (midpoint .and. Xh%lx .gt. 2) then call dofmap_xyzquad(Xh, msh, msh%elements(el_idx)%e, & - this%x(1,1,1, el_idx), this%y(1,1,1, el_idx),& - this%z(1,1,1, el_idx), curve_type, curve_data_tot) + this%x(1,1,1,el_idx), this%y(1,1,1,el_idx),& + this%z(1,1,1,el_idx),curve_type, curve_data_tot) end if end do - do i = 1, msh%curve%size + do i =1, msh%curve%size el_idx = msh%curve%curve_el(i)%el_idx do j = 1, 8 if (msh%curve%curve_el(i)%curve_type(j) .eq. 3) then rp_curve_data = msh%curve%curve_el(i)%curve_data(1:5,j) call arc_surface(j, rp_curve_data, & - this%x(1,1,1, el_idx), & - this%y(1,1,1, el_idx), & + this%x(1,1,1,el_idx), & + this%y(1,1,1,el_idx), & this%z(1,1,1, el_idx), & Xh, msh%elements(el_idx)%e, msh%gdim) end if @@ -844,14 +866,14 @@ subroutine dofmap_xyzquad(Xh, msh, element, x, y, z, curve_type, curve_data) type(space_t), target :: Xh3 real(kind=rp), dimension(3), parameter :: zquad = (/-1d0, 0d0,1d0/) real(kind=rp) :: zg(3) - real(kind=rp), dimension(Xh%lx, Xh%lx, Xh%lx) :: tmp + real(kind=rp), dimension(Xh%lx,Xh%lx,Xh%lx) :: tmp real(kind=rp) :: jx(Xh%lx*3) real(kind=rp) :: jxt(Xh%lx*3), jyt(Xh%lx*3), jzt(Xh%lx*3) real(kind=rp) :: w(4*Xh%lxyz,2) integer :: j, k, n_edges - eindx = (/ 2, 6, 8, 4, & - 20, 24, 26, 22, & - 10, 12, 18, 16 /) + eindx = (/2 , 6 , 8 , 4, & + 20 , 24 , 26 , 22, & + 10 , 12 , 18 , 16 /) w = 0d0 if (msh%gdim .eq. 3) then @@ -874,20 +896,20 @@ subroutine dofmap_xyzquad(Xh, msh, element, x, y, z, curve_type, curve_data) zg(2) = 0 zg(3) = 1 if (msh%gdim .eq. 3) then - call gh_face_extend_3d(x3, zg,3,2,w(1,1),w(1,2)) ! 2 --> edge extend - call gh_face_extend_3d(y3, zg,3,2,w(1,1),w(1,2)) - call gh_face_extend_3d(z3, zg,3,2,w(1,1),w(1,2)) + call gh_face_extend_3d(x3,zg,3,2,w(1,1),w(1,2)) ! 2 --> edge extend + call gh_face_extend_3d(y3,zg,3,2,w(1,1),w(1,2)) + call gh_face_extend_3d(z3,zg,3,2,w(1,1),w(1,2)) else call neko_warning(' m deformation not supported for 2d yet') - call gh_face_extend_2d(x3, zg,3,2,w(1,1),w(1,2)) ! 2 --> edge extend - call gh_face_extend_2d(y3, zg,3,2,w(1,1),w(1,2)) + call gh_face_extend_2d(x3,zg,3,2,w(1,1),w(1,2)) ! 2 --> edge extend + call gh_face_extend_2d(y3,zg,3,2,w(1,1),w(1,2)) end if - k = 1 + k =1 do j = 1, Xh%lx - call fd_weights_full(Xh%zg(j,1), zquad,2,0, jxt(k)) - call fd_weights_full(Xh%zg(j,2), zquad,2,0, jyt(k)) + call fd_weights_full(Xh%zg(j,1),zquad,2,0,jxt(k)) + call fd_weights_full(Xh%zg(j,2),zquad,2,0,jyt(k)) if (msh%gdim .gt. 2) then - call fd_weights_full(Xh%zg(j,3), zquad,2,0, jzt(k)) + call fd_weights_full(Xh%zg(j,3),zquad,2,0,jzt(k)) end if k = k + 3 end do @@ -1032,31 +1054,31 @@ subroutine gh_face_extend_2d(x, zg, n, gh_type, e, v) real(kind=rp), intent(inout) :: e(n, n) real(kind=rp), intent(inout) :: v(n, n) integer, intent(in) :: gh_type - integer :: i,j, jj, ii, ntot + integer :: i,j , jj, ii, ntot real(kind=rp) :: si, sj, hi, hj !Build vertex interpolant - ntot = n * n - call rzero(v, ntot) + ntot=n*n + call rzero(v,ntot) do jj = 1, n, n-1 do ii = 1, n, n-1 do j = 1, n do i = 1, n si = 0.5*((n-ii)*(1-zg(i))+(ii-1)*(1+zg(i)))/(n-1) sj = 0.5*((n-jj)*(1-zg(j))+(jj-1)*(1+zg(j)))/(n-1) - v(i,j) = v(i,j) + si*sj*x(ii, jj) + v(i,j) = v(i,j) + si*sj*x(ii,jj) end do end do end do end do if (gh_type .eq. 1) then - call copy(x,v, ntot) + call copy(x,v,ntot) return end if !Extend 4 edges - call rzero(e, ntot) + call rzero(e,ntot) !x-edges @@ -1064,7 +1086,7 @@ subroutine gh_face_extend_2d(x, zg, n, gh_type, e, v) do j = 1, n do i = 1, n hj = 0.5*((n-jj)*(1-zg(j))+(jj-1)*(1+zg(j)))/(n-1) - e(i,j) = e(i,j) + hj*(x(i, jj)-v(i, jj)) + e(i,j) = e(i,j) + hj*(x(i,jj)-v(i,jj)) end do end do end do @@ -1097,14 +1119,11 @@ subroutine arc_surface(isid, curve_data, x, y, z, Xh, element, gdim) real(kind=rp) :: theta0, xcenn, ycenn, h(Xh%lx, 3, 2) real(kind=rp) :: xcrved(Xh%lx), ycrved(Xh%lx), xs, ys integer :: isid1, ixt, iyt, izt, ix, itmp - ! cyclic to symmetric face mapping - integer(i4), dimension(6), parameter :: fcyc_to_sym = (/3, 2, 4, 1, 5, 6/) - ! cyclic to symmetric edge mapping - integer(i4), dimension(12), parameter :: ecyc_to_sym = (/1, 6, 2, 5, 3, 8,& - & 4, 7, 9, 10, 12, 11/) - ! symmetric edge to vertex mapping - integer, parameter, dimension(2, 12) :: edge_nodes = reshape((/1, 2, 3, 4, & - & 5, 6, 7, 8, 1, 3, 2, 4, 5, 7, 6, 8, 1, 5, 2, 6, 3, 7, 4, 8/), (/2,12/)) + integer(i4), dimension(6), parameter :: fcyc_to_sym = (/3, 2, 4, 1, 5, 6/) ! cyclic to symmetric face mapping + integer(i4), dimension(12), parameter :: ecyc_to_sym = (/1, 6, 2, 5, 3, 8, & + & 4, 7, 9, 10, 12, 11/) ! cyclic to symmetric edge mapping + integer, parameter, dimension(2, 12) :: edge_nodes = reshape((/1, 2, 3, 4, 5, 6, & + & 7, 8, 1, 3, 2, 4, 5, 7, 6, 8, 1, 5, 2, 6, 3, 7, 4, 8/), (/2,12/)) ! symmetric edge to vertex mapping ! copy from hex as this has private attribute there ! this subroutine is a mess of symmetric and cyclic edge/face numberring and @@ -1112,17 +1131,17 @@ subroutine arc_surface(isid, curve_data, x, y, z, Xh, element, gdim) ! a cyclic edge number) ! following according to cyclic edge numbering and orientation itmp = ecyc_to_sym(isid) - select case (isid) - case (1:2,5:6) - pt1x = element%pts(edge_nodes(1, itmp))%p%x(1) - pt1y = element%pts(edge_nodes(1, itmp))%p%x(2) - pt2x = element%pts(edge_nodes(2, itmp))%p%x(1) - pt2y = element%pts(edge_nodes(2, itmp))%p%x(2) - case (3:4,7:8) - pt1x = element%pts(edge_nodes(2, itmp))%p%x(1) - pt1y = element%pts(edge_nodes(2, itmp))%p%x(2) - pt2x = element%pts(edge_nodes(1, itmp))%p%x(1) - pt2y = element%pts(edge_nodes(1, itmp))%p%x(2) + select case(isid) + case(1:2,5:6) + pt1x = element%pts(edge_nodes(1,itmp))%p%x(1) + pt1y = element%pts(edge_nodes(1,itmp))%p%x(2) + pt2x = element%pts(edge_nodes(2,itmp))%p%x(1) + pt2y = element%pts(edge_nodes(2,itmp))%p%x(2) + case(3:4,7:8) + pt1x = element%pts(edge_nodes(2,itmp))%p%x(1) + pt1y = element%pts(edge_nodes(2,itmp))%p%x(2) + pt2x = element%pts(edge_nodes(1,itmp))%p%x(1) + pt2y = element%pts(edge_nodes(1,itmp))%p%x(2) end select ! find slope of perpendicular radius = curve_data(1) @@ -1131,7 +1150,7 @@ subroutine arc_surface(isid, curve_data, x, y, z, Xh, element, gdim) ! make length radius xys = sqrt(xs**2 + ys**2) ! sanity check - if (abs(2.0 * radius) .le. xys * 1.00001) & + if (abs(2.0 * radius) <= xys * 1.00001) & & call neko_error('Radius to small for arced element surface') ! find center dtheta = abs(asin(0.5*xys/radius)) @@ -1144,10 +1163,10 @@ subroutine arc_surface(isid, curve_data, x, y, z, Xh, element, gdim) isid1 = mod(isid+4-1, 4)+1 call compute_h(h, Xh%zg, gdim, Xh%lx) if (radius < 0.0) dtheta = -dtheta - do ix = 1, Xh%lx - ixt = ix - if (isid1 .gt. 2) ixt = Xh%lx + 1 - ix - r = Xh%zg(ix,1) + do ix=1,Xh%lx + ixt=ix + if (isid1.gt.2) ixt=Xh%lx+1-ix + r=Xh%zg(ix,1) xcrved(ixt) = xcenn + abs(radius) * cos(theta0 + r*dtheta) & - ( h(ix,1,1)*pt1x + h(ix,1,2)*pt2x ) ycrved(ixt) = ycenn + abs(radius) * sin(theta0 + r*dtheta) & @@ -1161,11 +1180,15 @@ subroutine arc_surface(isid, curve_data, x, y, z, Xh, element, gdim) iyt = isid1-2 ixt = isid1 if (isid1 .le. 2) then - call addtnsr(x, h(1,1, ixt), xcrved, h(1,3, izt), Xh%lx, Xh%ly, Xh%lz) - call addtnsr(y, h(1,1, ixt), ycrved, h(1,3, izt), Xh%lx, Xh%ly, Xh%lz) + call addtnsr(x, h(1,1,ixt), xcrved, h(1,3,izt) & + ,Xh%lx, Xh%ly, Xh%lz) + call addtnsr(y, h(1,1,ixt), ycrved, h(1,3,izt) & + ,Xh%lx, Xh%ly, Xh%lz) else - call addtnsr(x, xcrved, h(1,2, iyt), h(1,3, izt), Xh%lx, Xh%ly, Xh%lz) - call addtnsr(y, ycrved, h(1,2, iyt), h(1,3, izt), Xh%lx, Xh%ly, Xh%lz) + call addtnsr(x, xcrved, h(1,2,iyt), h(1,3,izt) & + ,Xh%lx, Xh%ly, Xh%lz) + call addtnsr(y, ycrved, h(1,2,iyt), h(1,3,izt) & + ,Xh%lx, Xh%ly, Xh%lz) end if end subroutine arc_surface From 4b9bc81d9980375e5efefb76826df69868d67e63 Mon Sep 17 00:00:00 2001 From: Victor Baconnet Date: Tue, 10 Sep 2024 13:50:28 +0200 Subject: [PATCH 46/67] revert checkpoint --- src/common/checkpoint.f90 | 116 ++++++++++++++++++-------------------- 1 file changed, 55 insertions(+), 61 deletions(-) diff --git a/src/common/checkpoint.f90 b/src/common/checkpoint.f90 index 4688deca309..6df5c4ab9d9 100644 --- a/src/common/checkpoint.f90 +++ b/src/common/checkpoint.f90 @@ -88,8 +88,6 @@ module checkpoint final :: chkp_free end type chkp_t - public :: chkp_free - contains !> Initialize checkpoint structure with mandatory data @@ -141,62 +139,58 @@ subroutine chkp_sync_host(this) class(chkp_t), intent(inout) :: this if (NEKO_BCKND_DEVICE .eq. 1) then - associate(u => this%u, v => this%v, w => this%w, & - ulag => this%ulag, vlag => this%vlag, wlag => this%wlag, & - p => this%p) + associate(u=>this%u, v=>this%v, w=>this%w, & + ulag=>this%ulag, vlag=>this%vlag, wlag=>this%wlag, & + p=>this%p) if (associated(this%u) .and. associated(this%v) .and. & associated(this%w) .and. associated(this%p)) then - call device_memcpy(u%x, u%x_d, u%size(), DEVICE_TO_HOST, & - sync = .false.) - call device_memcpy(v%x, v%x_d, v%size(), DEVICE_TO_HOST, & - sync = .false.) - call device_memcpy(w%x, w%x_d, w%size(), DEVICE_TO_HOST, & - sync = .false.) - call device_memcpy(p%x, p%x_d, p%size(), DEVICE_TO_HOST, & - sync = .false.) + call device_memcpy(u%x, u%x_d, u%dof%size(), DEVICE_TO_HOST, sync=.false.) + call device_memcpy(v%x, v%x_d, v%dof%size(), DEVICE_TO_HOST, sync=.false.) + call device_memcpy(w%x, w%x_d, w%dof%size(), DEVICE_TO_HOST, sync=.false.) + call device_memcpy(p%x, p%x_d, p%dof%size(), DEVICE_TO_HOST, sync=.false.) end if if (associated(this%ulag) .and. associated(this%vlag) .and. & associated(this%wlag)) then call device_memcpy(ulag%lf(1)%x, ulag%lf(1)%x_d, & - u%size(), DEVICE_TO_HOST, sync = .false.) + u%dof%size(), DEVICE_TO_HOST, sync=.false.) call device_memcpy(ulag%lf(2)%x, ulag%lf(2)%x_d, & - u%size(), DEVICE_TO_HOST, sync = .false.) + u%dof%size(), DEVICE_TO_HOST, sync=.false.) call device_memcpy(vlag%lf(1)%x, vlag%lf(1)%x_d, & - v%size(), DEVICE_TO_HOST, sync = .false.) + v%dof%size(), DEVICE_TO_HOST, sync=.false.) call device_memcpy(vlag%lf(2)%x, vlag%lf(2)%x_d, & - v%size(), DEVICE_TO_HOST, sync = .false.) + v%dof%size(), DEVICE_TO_HOST, sync=.false.) call device_memcpy(wlag%lf(1)%x, wlag%lf(1)%x_d, & - w%size(), DEVICE_TO_HOST, sync = .false.) + w%dof%size(), DEVICE_TO_HOST, sync=.false.) call device_memcpy(wlag%lf(2)%x, wlag%lf(2)%x_d, & - w%size(), DEVICE_TO_HOST, sync = .false.) + w%dof%size(), DEVICE_TO_HOST, sync=.false.) call device_memcpy(this%abx1%x, this%abx1%x_d, & - w%size(), DEVICE_TO_HOST, sync = .false.) + w%dof%size(), DEVICE_TO_HOST, sync=.false.) call device_memcpy(this%abx2%x, this%abx2%x_d, & - w%size(), DEVICE_TO_HOST, sync = .false.) + w%dof%size(), DEVICE_TO_HOST, sync=.false.) call device_memcpy(this%aby1%x, this%aby1%x_d, & - w%size(), DEVICE_TO_HOST, sync = .false.) + w%dof%size(), DEVICE_TO_HOST, sync=.false.) call device_memcpy(this%aby2%x, this%aby2%x_d, & - w%size(), DEVICE_TO_HOST, sync = .false.) + w%dof%size(), DEVICE_TO_HOST, sync=.false.) call device_memcpy(this%abz1%x, this%abz1%x_d, & - w%size(), DEVICE_TO_HOST, sync = .false.) + w%dof%size(), DEVICE_TO_HOST, sync=.false.) call device_memcpy(this%abz2%x, this%abz2%x_d, & - w%size(), DEVICE_TO_HOST, sync = .false.) + w%dof%size(), DEVICE_TO_HOST, sync=.false.) end if if (associated(this%s)) then call device_memcpy(this%s%x, this%s%x_d, & - this%s%size(), DEVICE_TO_HOST, sync = .false.) + this%s%dof%size(), DEVICE_TO_HOST, sync=.false.) call device_memcpy(this%slag%lf(1)%x, this%slag%lf(1)%x_d, & - this%s%size(), DEVICE_TO_HOST, sync = .false.) + this%s%dof%size(), DEVICE_TO_HOST, sync=.false.) call device_memcpy(this%slag%lf(2)%x, this%slag%lf(2)%x_d, & - this%s%size(), DEVICE_TO_HOST, sync = .false.) + this%s%dof%size(), DEVICE_TO_HOST, sync=.false.) call device_memcpy(this%abs1%x, this%abs1%x_d, & - w%size(), DEVICE_TO_HOST, sync = .false.) + w%dof%size(), DEVICE_TO_HOST, sync=.false.) call device_memcpy(this%abs2%x, this%abs2%x_d, & - w%size(), DEVICE_TO_HOST, sync = .false.) + w%dof%size(), DEVICE_TO_HOST, sync=.false.) end if end associate call device_sync(glb_cmd_queue) @@ -209,51 +203,51 @@ subroutine chkp_sync_device(this) class(chkp_t), intent(inout) :: this if (NEKO_BCKND_DEVICE .eq. 1) then - associate(u => this%u, v => this%v, w => this%w, & - ulag => this%ulag, vlag => this%vlag, wlag => this%wlag, & - p => this%p) + associate(u=>this%u, v=>this%v, w=>this%w, & + ulag=>this%ulag, vlag=>this%vlag, wlag=>this%wlag,& + p=>this%p) if (associated(this%u) .and. associated(this%v) .and. & associated(this%w)) then - call device_memcpy(u%x, u%x_d, u%size(), & - HOST_TO_DEVICE, sync = .false.) - call device_memcpy(v%x, v%x_d, v%size(), & - HOST_TO_DEVICE, sync = .false.) - call device_memcpy(w%x, w%x_d, w%size(), & - HOST_TO_DEVICE, sync = .false.) - call device_memcpy(p%x, p%x_d, p%size(), & - HOST_TO_DEVICE, sync = .false.) + call device_memcpy(u%x, u%x_d, u%dof%size(), & + HOST_TO_DEVICE, sync=.false.) + call device_memcpy(v%x, v%x_d, v%dof%size(), & + HOST_TO_DEVICE, sync=.false.) + call device_memcpy(w%x, w%x_d, w%dof%size(), & + HOST_TO_DEVICE, sync=.false.) + call device_memcpy(p%x, p%x_d, p%dof%size(), & + HOST_TO_DEVICE, sync=.false.) end if if (associated(this%ulag) .and. associated(this%vlag) .and. & associated(this%wlag)) then - call device_memcpy(ulag%lf(1)%x, ulag%lf(1)%x_d, u%size(), & - HOST_TO_DEVICE, sync = .false.) - call device_memcpy(ulag%lf(2)%x, ulag%lf(2)%x_d, u%size(), & - HOST_TO_DEVICE, sync = .false.) - - call device_memcpy(vlag%lf(1)%x, vlag%lf(1)%x_d, v%size(), & - HOST_TO_DEVICE, sync = .false.) - call device_memcpy(vlag%lf(2)%x, vlag%lf(2)%x_d, v%size(), & - HOST_TO_DEVICE, sync = .false.) - - call device_memcpy(wlag%lf(1)%x, wlag%lf(1)%x_d, w%size(), & - HOST_TO_DEVICE, sync = .false.) - call device_memcpy(wlag%lf(2)%x, wlag%lf(2)%x_d, w%size(), & - HOST_TO_DEVICE, sync = .false.) + call device_memcpy(ulag%lf(1)%x, ulag%lf(1)%x_d, u%dof%size(), & + HOST_TO_DEVICE, sync=.false.) + call device_memcpy(ulag%lf(2)%x, ulag%lf(2)%x_d, u%dof%size(), & + HOST_TO_DEVICE, sync=.false.) + + call device_memcpy(vlag%lf(1)%x, vlag%lf(1)%x_d, v%dof%size(), & + HOST_TO_DEVICE, sync=.false.) + call device_memcpy(vlag%lf(2)%x, vlag%lf(2)%x_d, v%dof%size(), & + HOST_TO_DEVICE, sync=.false.) + + call device_memcpy(wlag%lf(1)%x, wlag%lf(1)%x_d, w%dof%size(), & + HOST_TO_DEVICE, sync=.false.) + call device_memcpy(wlag%lf(2)%x, wlag%lf(2)%x_d, w%dof%size(), & + HOST_TO_DEVICE, sync=.false.) end if if (associated(this%s)) then - call device_memcpy(this%s%x, this%s%x_d, this%s%size(), & - HOST_TO_DEVICE, sync = .false.) + call device_memcpy(this%s%x, this%s%x_d, this%s%dof%size(), & + HOST_TO_DEVICE, sync=.false.) call device_memcpy(this%slag%lf(1)%x, this%slag%lf(1)%x_d, & - this%s%size(), HOST_TO_DEVICE, sync = .false.) + this%s%dof%size(), HOST_TO_DEVICE, sync=.false.) call device_memcpy(this%slag%lf(2)%x, this%slag%lf(2)%x_d, & - this%s%size(), HOST_TO_DEVICE, sync = .false.) + this%s%dof%size(), HOST_TO_DEVICE, sync=.false.) call device_memcpy(this%abs1%x, this%abs1%x_d, & - w%size(), HOST_TO_DEVICE, sync = .false.) + w%dof%size(), HOST_TO_DEVICE, sync=.false.) call device_memcpy(this%abs2%x, this%abs2%x_d, & - w%size(), HOST_TO_DEVICE, sync = .false.) + w%dof%size(), HOST_TO_DEVICE, sync=.false.) end if end associate end if From 6e728c44c218b811e77876430e436783b3a90aed Mon Sep 17 00:00:00 2001 From: Victor Baconnet Date: Wed, 11 Sep 2024 11:49:30 +0200 Subject: [PATCH 47/67] Fix sp compiler --- src/fluid/flow_ic.f90 | 10 ++++++---- src/scalar/scalar_ic.f90 | 8 +++++--- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/fluid/flow_ic.f90 b/src/fluid/flow_ic.f90 index d2e95e94273..c6303d319c6 100644 --- a/src/fluid/flow_ic.f90 +++ b/src/fluid/flow_ic.f90 @@ -157,7 +157,7 @@ subroutine set_flow_ic_int(u, v, w, p, coef, gs, type, params) ! Get tolerance for potential interpolation call json_get_or_default(params, & - 'case.fluid.initial_condition.tolerance', tol, 1d-6) + 'case.fluid.initial_condition.tolerance', tol, 0.000001_rp) if (found_previous_mesh) then prev_mesh = trim(read_str) @@ -209,7 +209,7 @@ subroutine set_flow_ic_int(u, v, w, p, coef, gs, type, params) ! Get the tolerance for potential interpolationm defaults to ! the same value as for interpolation in chkp_t call json_get_or_default(params, & - 'case.fluid.initial_condition.tolerance', tol, 1d-6) + 'case.fluid.initial_condition.tolerance', tol, 0.000001_rp) ! Attempt to find a path to where the coordinates are written call json_get_or_default(params, & @@ -483,8 +483,10 @@ subroutine set_flow_ic_fld(u, v, w, p, file_name, sample_idx, & f = file_t(trim(previous_mesh_file_name)) - ! Only set the counter if its not the exact same file, this - ! is to prevent reading the same file twice + ! Only set the counter if the previous mesh is located in a + ! different file or if the index of the mesh is different + ! from the sample index. + ! This is to prevent reading the same file twice if (trim(previous_mesh_file_name) .eq. trim(file_name) .and. & sample_mesh_idx .ne. sample_idx) & call f%set_counter(sample_mesh_idx) diff --git a/src/scalar/scalar_ic.f90 b/src/scalar/scalar_ic.f90 index 7be561e67d2..3089af9ef78 100644 --- a/src/scalar/scalar_ic.f90 +++ b/src/scalar/scalar_ic.f90 @@ -70,7 +70,9 @@ module scalar_ic !> Set scalar initial condition (builtin) !! @details Set scalar initial condition using one of the builtin types !! currently supported: - !! - uniform. + !! - uniform + !! - point zone + !! - field !! @param s Scalar field. !! @param coef Coefficient. !! @param gs Gather-Scatter object. @@ -134,7 +136,7 @@ subroutine set_scalar_ic_int(s, coef, gs, type, params) ! Get tolerance for potential interpolation call json_get_or_default(params, & - 'case.scalar.initial_condition.tolerance', tol, 1d-6) + 'case.scalar.initial_condition.tolerance', tol, 0.000001_rp) if (found_previous_mesh) then prev_mesh = trim(read_str) @@ -186,7 +188,7 @@ subroutine set_scalar_ic_int(s, coef, gs, type, params) ! Get the tolerance for potential interpolationm defaults to ! the same value as for interpolation in chkp_t call json_get_or_default(params, & - 'case.scalar.initial_condition.tolerance', tol, 1d-6) + 'case.scalar.initial_condition.tolerance', tol, 0.000001_rp) ! Get the index of the file that contains the mesh call json_get_or_default(params, & From 138ac2a691611b1d6891a70988cb77b17e3a14ef Mon Sep 17 00:00:00 2001 From: Victor Baconnet Date: Wed, 11 Sep 2024 16:19:16 +0200 Subject: [PATCH 48/67] Remove initial condition from chkp --- src/fluid/flow_ic.f90 | 257 +++++++++++++------------------------ src/scalar/scalar_ic.f90 | 266 ++++++++++++++------------------------- 2 files changed, 182 insertions(+), 341 deletions(-) diff --git a/src/fluid/flow_ic.f90 b/src/fluid/flow_ic.f90 index c6303d319c6..835a1a7b6e6 100644 --- a/src/fluid/flow_ic.f90 +++ b/src/fluid/flow_ic.f90 @@ -83,8 +83,8 @@ subroutine set_flow_ic_int(u, v, w, p, coef, gs, type, params) real(kind=rp), allocatable :: zone_value(:) character(len=:), allocatable :: read_str character(len=80) :: suffix - character(len=NEKO_FNAME_LEN) :: fname, prev_mesh - integer :: sample_idx, fpos, sample_mesh_idx + character(len=NEKO_FNAME_LEN) :: fname + integer :: sample_idx, fpos, sample_mesh_idx, default_sample_mesh_idx logical :: found_previous_mesh, interpolate character(len=LOG_SIZE) :: log_buf @@ -139,7 +139,7 @@ subroutine set_flow_ic_int(u, v, w, p, coef, gs, type, params) call set_flow_ic_point_zone(u, v, w, uinf, read_str, zone_value) ! - ! Field initial condition (from chkp or fld file) + ! Field initial condition (from fld file) ! else if (trim(type) .eq. 'field') then @@ -149,115 +149,70 @@ subroutine set_flow_ic_int(u, v, w, p, coef, gs, type, params) call filename_suffix(fname, suffix) call neko_log%message("File name: " // trim(fname)) - if (trim(suffix) .eq. "chkp") then + ! + ! Get the index of the file to sample + ! + call json_get_or_default(params, & + 'case.fluid.initial_condition.sample_index', sample_idx, -1) - ! Look for parameters for interpolation - call params%get("case.fluid.initial_condition.previous_mesh", & - read_str, found_previous_mesh) + ! In case we interpolate, the default index of the file in which to + ! look for the coordinates + default_sample_mesh_idx = 0 - ! Get tolerance for potential interpolation - call json_get_or_default(params, & - 'case.fluid.initial_condition.tolerance', tol, 0.000001_rp) - - if (found_previous_mesh) then - prev_mesh = trim(read_str) - call neko_log%message("Previous mesh: " // trim(prev_mesh)) - write (log_buf, '(A,E15.7)') "Tolerance : ", tol - call neko_log%message(log_buf) - end if - - if (found_previous_mesh) then - call set_flow_ic_chkp(u, v, w, p, fname, & - previous_mesh_fname = prev_mesh, tol = tol) - else - call set_flow_ic_chkp(u, v, w, p, fname) - end if - - else !if it's not a chkp we assume it's a fld file - - ! Get the index of the file to sample - call json_get_or_default(params, & - 'case.fluid.initial_condition.sample_index', sample_idx, -1) - - if (sample_idx .ne. -1) then - write (log_buf, '(A,I5)') "Sample index: ", sample_idx - call neko_log%message(log_buf) - end if - - ! If it's not chkp or fld assume it's either .nek5000 or .f00* - if (trim(suffix) .ne. "fld") then + if (sample_idx .ne. -1) then + write (log_buf, '(A,I5)') "Sample index: ", sample_idx + call neko_log%message(log_buf) + end if - ! Check if the suffix is of type "f000*", and if so extract - ! the index e.g. "f00035" --> 35 - ! NOTE: overwrites whatever is in sampled_index - fpos = scan(suffix, 'f') - if (fpos .eq. 1) then - if (sample_idx .ne. -1) & - call neko_warning("Overwriting sample index") - read (suffix(2:), "(I5.5)") sample_idx - end if + ! If it's not fld assume it's either .nek5000 or .f00* + if (trim(suffix) .ne. "fld") then - call filename_chsuffix(fname, fname, 'fld') + ! Check if the suffix is of type "f000*", and if so extract + ! the index e.g. "f00035" --> 35 + ! NOTE: overwrites whatever is in sampled_index + fpos = scan(suffix, 'f') + if (fpos .eq. 1) then + if (sample_idx .ne. -1) & + call neko_warning("Overwriting sample index") + read (suffix(2:), "(I5.5)") sample_idx + ! In case we interpolate we assume the mesh is also in this file + default_sample_mesh_idx = sample_idx end if - ! Check if we want to interpolate our field, default is no - call json_get_or_default(params, & - 'case.fluid.initial_condition.interpolate', interpolate, & - .false.) - - ! Get the tolerance for potential interpolationm defaults to - ! the same value as for interpolation in chkp_t - call json_get_or_default(params, & - 'case.fluid.initial_condition.tolerance', tol, 0.000001_rp) - - ! Attempt to find a path to where the coordinates are written - call json_get_or_default(params, & - 'case.fluid.initial_condition.mesh_file_name', read_str, & - "none") - - if (trim(read_str) .eq. "none") then - ! If no mesh file is provided, try to get the index of the - ! file that contains the mesh - call json_get_or_default(params, & - 'case.fluid.initial_condition.sample_mesh_index', & - sample_mesh_idx, 0) - - prev_mesh = trim(fname) - - else - - prev_mesh = trim(read_str) - - ! If we gave a mesh file, we extract the sample index - call filename_suffix(prev_mesh, suffix) - if (trim(suffix) .eq. "fld" .or. trim(suffix) .eq. "nek5000") & - call neko_error("The field file with the mesh must be in & -&the format .f*****") - - fpos = scan(suffix, 'f') - if (fpos .eq. 1) then - read (suffix(2:), "(I5.5)") sample_mesh_idx - else - call neko_error("The mesh file must be of type .f*****") - end if - - call filename_chsuffix(prev_mesh, prev_mesh, 'fld') - end if + call filename_chsuffix(fname, fname, 'fld') + end if - if (interpolate) then - call neko_log%message("Interpolation : yes") - write (log_buf, '(A,E15.7)') "Tolerance : ", tol - call neko_log%message(log_buf) - call neko_log%message("Coordinates file : " // & - trim(prev_mesh)) - end if + ! + ! Check if we want to interpolate from the field file, default is no + ! + call json_get_or_default(params, & + 'case.fluid.initial_condition.interpolate', interpolate, & + .false.) + + ! + ! Get the tolerance for potential interpolation, defaults to 1e-6 + ! + call json_get_or_default(params, & + 'case.fluid.initial_condition.tolerance', tol, 0.000001_rp) + + ! If no mesh file is provided, try to get the index of the + ! file that contains the mesh. + call json_get_or_default(params, & + 'case.fluid.initial_condition.sample_mesh_index', & + sample_mesh_idx, default_sample_mesh_idx) - call set_flow_ic_fld(u, v, w, p, fname, sample_idx, interpolate, & - tolerance = tol, sample_mesh_idx = sample_mesh_idx, & - previous_mesh_file_name = prev_mesh) + if (interpolate) then + call neko_log%message("Interpolation : yes") + write (log_buf, '(A,E15.7)') "Tolerance : ", tol + call neko_log%message(log_buf) + write (log_buf, '(A,I5.5)') "Coordinates at sample index : ", & + sample_mesh_idx + call neko_log%message(log_buf) + end if - end if ! if suffix .eq. chkp + call set_flow_ic_fld(u, v, w, p, fname, sample_idx, interpolate, & + tolerance = tol, sample_mesh_idx = sample_mesh_idx) else call neko_error('Invalid initial condition') @@ -435,7 +390,7 @@ end subroutine set_flow_ic_point_zone !! @param sample_idx index of the field file .f000* to read, default is !! -1.. subroutine set_flow_ic_fld(u, v, w, p, file_name, sample_idx, & - interpolate, tolerance, sample_mesh_idx, previous_mesh_file_name) + interpolate, tolerance, sample_mesh_idx) type(field_t), intent(inout) :: u type(field_t), intent(inout) :: v type(field_t), intent(inout) :: w @@ -443,10 +398,10 @@ subroutine set_flow_ic_fld(u, v, w, p, file_name, sample_idx, & character(len=*), intent(in) :: file_name integer, intent(in) :: sample_idx logical, intent(in) :: interpolate - real(kind=rp), intent(in), optional :: tolerance - integer, intent(in), optional :: sample_mesh_idx - character(len=*), intent(in), optional :: previous_mesh_file_name + real(kind=rp), intent(in) :: tolerance + integer, intent(in) :: sample_mesh_idx + integer :: last_index type(fld_file_data_t) :: fld_data type(file_t) :: f @@ -470,30 +425,37 @@ subroutine set_flow_ic_fld(u, v, w, p, file_name, sample_idx, & ! and read the first file in the series. call f%read(fld_data) + last_index = fld_data%meta_nsamples + fld_data%meta_start_counter - 1 + + if (interpolate) then + ! Read the coordinates if they are neither at index 0 or at the + ! last index + if (sample_mesh_idx .ne. 0 .and. & + sample_mesh_idx .ne. last_index) then + call f%set_counter(sample_mesh_idx) + call f%read(fld_data) + end if + end if ! interpolate + ! If there is more than one file, read the last one in the series. if (fld_data%meta_nsamples .gt. 1) then - call f%set_counter(fld_data%meta_nsamples + & - fld_data%meta_start_counter - 1) + call f%set_counter(last_index) call f%read(fld_data) end if - else + else ! In this case we have a specific sample to read in the fld series if (interpolate) then + ! Read the mesh coordinates if they are not in our fld file + if (sample_mesh_idx .ne. sample_idx) then + call f%set_counter(sample_mesh_idx) + call f%read(fld_data) + end if - f = file_t(trim(previous_mesh_file_name)) - - ! Only set the counter if the previous mesh is located in a - ! different file or if the index of the mesh is different - ! from the sample index. - ! This is to prevent reading the same file twice - if (trim(previous_mesh_file_name) .eq. trim(file_name) .and. & - sample_mesh_idx .ne. sample_idx) & - call f%set_counter(sample_mesh_idx) - + ! Read the actual fld file call f%read(fld_data) f = file_t(trim(file_name)) - end if + end if ! interpolate call f%set_counter(sample_idx) call f%read(fld_data) @@ -533,12 +495,8 @@ subroutine set_flow_ic_fld(u, v, w, p, file_name, sample_idx, & class default end select - if (present(tolerance)) then - global_interp = fld_data%generate_interpolator(u%dof, u%msh, & - tolerance) - else - call neko_error("No tolerance provided for interpolation.") - end if + global_interp = fld_data%generate_interpolator(u%dof, u%msh, & + tolerance) ! Evaluate velocities and pressure call global_interp%evaluate(u%x, fld_data%u%x) @@ -563,8 +521,8 @@ subroutine set_flow_ic_fld(u, v, w, p, file_name, sample_idx, & end if - ! Note: we do not copy on the GPU since `set_flow_ic_common` does the - ! copy for us, except for the pressure + ! NOTE: we do not copy (u,v,w) on the GPU since `set_flow_ic_common` does + ! the copy for us if (NEKO_BCKND_DEVICE .eq. 1) call device_memcpy(p%x, p%x_d, p%dof%size(), & HOST_TO_DEVICE, sync = .false.) @@ -572,47 +530,4 @@ subroutine set_flow_ic_fld(u, v, w, p, file_name, sample_idx, & end subroutine set_flow_ic_fld - !> Set the initial condition of the flow based on a point zone. - !! @details The initial condition is set to the base value and then the - !! zone is filled with the zone value. - !! @param u The x-component of the velocity field. - !! @param v The y-component of the velocity field. - !! @param w The z-component of the velocity field. - !! @param p The pressure field. - !! @param file_name The name of the checkpoint file. - !! @param previous_mesh_fname If specified, the name of the previouos mesh from - !! which to interpolate. - !! @param tol If specified, tolerance to use for the mesh interpolation. - subroutine set_flow_ic_chkp(u, v, w, p, file_name, previous_mesh_fname, tol) - type(field_t), intent(inout) :: u - type(field_t), intent(inout) :: v - type(field_t), intent(inout) :: w - type(field_t), intent(inout) :: p - character(len=*), intent(in) :: file_name - character(len=*), intent(in), optional :: previous_mesh_fname - real(kind=rp), intent(in), optional :: tol - - type(chkp_t) :: chkp_data - type(file_t) :: f, meshf - - call chkp_data%init(u, v, w, p) - - ! Mesh interpolation if specified - if (present(previous_mesh_fname)) then - meshf = file_t(trim(previous_mesh_fname)) - call meshf%read(chkp_data%previous_mesh) - end if - - ! Tolerance is by default 1d-6 - if (present(tol)) chkp_data%mesh2mesh_tol = tol - - ! Read the chkp and perform interpolation - f = file_t(trim(file_name)) - call f%read(chkp_data) - - if (NEKO_BCKND_DEVICE .eq. 1) call device_memcpy(p%x, p%x_d, p%dof%size(), & - HOST_TO_DEVICE, sync = .false.) - - end subroutine set_flow_ic_chkp - end module flow_ic diff --git a/src/scalar/scalar_ic.f90 b/src/scalar/scalar_ic.f90 index 3089af9ef78..e95ef662dda 100644 --- a/src/scalar/scalar_ic.f90 +++ b/src/scalar/scalar_ic.f90 @@ -89,10 +89,10 @@ subroutine set_scalar_ic_int(s, coef, gs, type, params) real(kind=rp) :: ic_value character(len=:), allocatable :: read_str character(len=80) :: suffix - character(len=NEKO_FNAME_LEN) :: fname, prev_mesh + character(len=NEKO_FNAME_LEN) :: fname real(kind=rp) :: zone_value, tol logical :: found, found_previous_mesh, interpolate - integer :: sample_idx, fpos, sample_mesh_idx + integer :: sample_idx, fpos, sample_mesh_idx, default_sample_mesh_idx character(len=LOG_SIZE) :: log_buf if (trim(type) .eq. 'uniform') then @@ -128,120 +128,76 @@ subroutine set_scalar_ic_int(s, coef, gs, type, params) call filename_suffix(fname, suffix) call neko_log%message("File name: " // trim(fname)) - if (trim(suffix) .eq. "chkp") then + ! + ! Get the index of the file to sample + ! + call json_get_or_default(params, & + 'case.fluid.initial_condition.sample_index', sample_idx, -1) - ! Look for parameters for interpolation - call params%get("case.scalar.initial_condition.previous_mesh", & - read_str, found_previous_mesh) + ! In case we interpolate, the default index of the file in which to + ! look for the coordinates + default_sample_mesh_idx = 0 - ! Get tolerance for potential interpolation - call json_get_or_default(params, & - 'case.scalar.initial_condition.tolerance', tol, 0.000001_rp) - - if (found_previous_mesh) then - prev_mesh = trim(read_str) - call neko_log%message("Previous mesh: " // trim(prev_mesh)) - write (log_buf, '(A,E15.7)') "Tolerance : ", tol - call neko_log%message(log_buf) - end if - - if (found_previous_mesh) then - call set_scalar_ic_chkp(s, fname, & - previous_mesh_fname = prev_mesh, tol = tol) - else - call set_scalar_ic_chkp(s, fname) - end if + if (sample_idx .ne. -1) then + write (log_buf, '(A,I5)') "Sample index: ", sample_idx + call neko_log%message(log_buf) + end if - else !if it's not a chkp we assume it's a fld file + ! If it's not fld assume it's either .nek5000 or .f00* + if (trim(suffix) .ne. "fld") then - ! Get the index of the file to sample - call json_get_or_default(params, & - 'case.scalar.initial_condition.sample_index', sample_idx, -1) + ! Check if the suffix is of type "f000*", and if so extract + ! the index e.g. "f00035" --> 35 + ! NOTE: overwrites whatever is in sampled_index + fpos = scan(suffix, 'f') + if (fpos .eq. 1) then + if (sample_idx .ne. -1) & + call neko_warning("Overwriting sample index.") + read (suffix(2:), "(I5.5)") sample_idx - if (sample_idx .ne. -1) then - write (log_buf, '(A,I5)') "Sample index: ", sample_idx - call neko_log%message(log_buf) + ! In case we interpolate we assume the mesh is also in this file + default_sample_mesh_idx = sample_idx end if - ! If it's not chkp or fld assume it's either .nek5000 or .f00* - if (trim(suffix) .ne. "fld") then - - ! Check if the suffix is of type "f000*", and if so extract - ! the index e.g. "f00035" --> 35 - ! NOTE: overwrites whatever is in sampled_index - fpos = scan(suffix, 'f') - if (fpos .eq. 1) then - if (sample_idx .ne. -1) & - call neko_warning("Overwriting sample index.") - read (suffix(2:), "(I5.5)") sample_idx - end if - - call filename_chsuffix(fname, fname, 'fld') - - end if + call filename_chsuffix(fname, fname, 'fld') - ! Check if we want to interpolate our field, default is no - call json_get_or_default(params, & - 'case.scalar.initial_condition.interpolate', interpolate, & - .false.) - - ! Get the tolerance for potential interpolationm defaults to - ! the same value as for interpolation in chkp_t - call json_get_or_default(params, & - 'case.scalar.initial_condition.tolerance', tol, 0.000001_rp) - - ! Get the index of the file that contains the mesh - call json_get_or_default(params, & - 'case.scalar.initial_condition.sample_mesh_index', & - sample_mesh_idx, 0) - - ! Attempt to find a path to where the coordinates are written - call json_get_or_default(params, & - 'case.scalar.initial_condition.mesh_file_name', read_str, & - "none") - - if (trim(read_str) .eq. "none") then - ! If no mesh file is provided, try to get the index of the - ! file that contains the mesh - call json_get_or_default(params, & - 'case.scalar.initial_condition.sample_mesh_index', & - sample_mesh_idx, 0) - - prev_mesh = trim(fname) - - else - - prev_mesh = trim(read_str) - - ! If we gave a mesh file, we extract the sample index - call filename_suffix(prev_mesh, suffix) - if (trim(suffix) .eq. "fld" .or. trim(suffix) .eq. "nek5000") & - call neko_error("The field file with the mesh must be in & -&the format .f*****") - - fpos = scan(suffix, 'f') - if (fpos .eq. 1) then - read (suffix(2:), "(I5.5)") sample_mesh_idx - else - call neko_error("The mesh file must be of type .f*****") - end if - - call filename_chsuffix(prev_mesh, prev_mesh, 'fld') - end if + end if - if (interpolate) then - call neko_log%message("Interpolation : yes") - write (log_buf, '(A,E15.7)') "Tolerance : ", tol - call neko_log%message(log_buf) - call neko_log%message("Coordinates file:" // & - trim(prev_mesh)) - end if + ! + ! Check if we want to interpolate from the field file, default is no + ! + call json_get_or_default(params, & + 'case.scalar.initial_condition.interpolate', interpolate, & + .false.) + + ! + ! Get the tolerance for potential interpolation, defaults to 1e-6 + ! + call json_get_or_default(params, & + 'case.scalar.initial_condition.tolerance', tol, 0.000001_rp) + + ! Get the index of the file that contains the mesh + call json_get_or_default(params, & + 'case.scalar.initial_condition.sample_mesh_index', & + sample_mesh_idx, 0) + + ! If no mesh file is provided, try to get the index of the + ! file that contains the mesh. + call json_get_or_default(params, & + 'case.scalar.initial_condition.sample_mesh_index', & + sample_mesh_idx, 0) - call set_scalar_ic_fld(s, fname, sample_idx, interpolate, & - tolerance = tol, sample_mesh_idx = sample_mesh_idx, & - previous_mesh_file_name = prev_mesh) + if (interpolate) then + call neko_log%message("Interpolation : yes") + write (log_buf, '(A,E15.7)') "Tolerance : ", tol + call neko_log%message(log_buf) + write (log_buf, '(A,I5.5)') "Coordinates at sample index : ", & + sample_mesh_idx + call neko_log%message(log_buf) + end if - end if ! if suffix .eq. chkp + call set_scalar_ic_fld(s, fname, sample_idx, interpolate, & + tolerance = tol, sample_mesh_idx = sample_mesh_idx) else call neko_error('Invalid initial condition') @@ -349,15 +305,15 @@ end subroutine set_scalar_ic_point_zone !! @param sample_idx index of the field file .f000* to read, default is !! -1.. subroutine set_scalar_ic_fld(s, file_name, sample_idx, & - interpolate, tolerance, sample_mesh_idx, previous_mesh_file_name) + interpolate, tolerance, sample_mesh_idx) type(field_t), intent(inout) :: s character(len=*), intent(in) :: file_name integer, intent(in) :: sample_idx logical, intent(in) :: interpolate - real(kind=rp), intent(in), optional :: tolerance - integer, intent(in), optional :: sample_mesh_idx - character(len=*), intent(in), optional :: previous_mesh_file_name + real(kind=rp), intent(in) :: tolerance + integer, intent(in) :: sample_mesh_idx + integer :: last_index type(fld_file_data_t) :: fld_data type(file_t) :: f @@ -381,25 +337,34 @@ subroutine set_scalar_ic_fld(s, file_name, sample_idx, & ! and read the first file in the series. call f%read(fld_data) + last_index = fld_data%meta_nsamples + fld_data%meta_start_counter - 1 + + if (interpolate) then + ! Read the coordinates if they are neither at index 0 or at the + ! last index + if (sample_mesh_idx .ne. 0 .and. & + sample_mesh_idx .ne. last_index) then + call f%set_counter(sample_mesh_idx) + call f%read(fld_data) + end if + end if ! interpolate + ! If there is more than one file, read the last one in the series. if (fld_data%meta_nsamples .gt. 1) then - call f%set_counter(fld_data%meta_nsamples + & - fld_data%meta_start_counter - 1) + call f%set_counter(last_index) call f%read(fld_data) end if - else + else ! In this case we have a specific sample to read in the fld series if (interpolate) then + ! Read the mesh coordinates if they are not in our fld file + if (sample_mesh_idx .ne. sample_idx) then + call f%set_counter(sample_mesh_idx) + call f%read(fld_data) + end if - f = file_t(trim(previous_mesh_file_name)) - - ! Only set the counter if its not the exact same file, this - ! is to prevent reading the same file twice - if (trim(previous_mesh_file_name) .eq. trim(file_name) .and. & - sample_mesh_idx .ne. sample_idx) & - call f%set_counter(sample_mesh_idx) - + ! Read the actual fld file call f%read(fld_data) f = file_t(trim(file_name)) end if ! interpolate @@ -441,65 +406,26 @@ subroutine set_scalar_ic_fld(s, file_name, sample_idx, & class default end select - if (present(tolerance)) then global_interp = fld_data%generate_interpolator(s%dof, s%msh, tolerance) - else - call neko_error("No tolerance provided for the interpolation.") - end if - - ! Evaluate scalar - call global_interp%evaluate(s%x, fld_data%t%x) - call global_interp%free - else ! No interpolation + ! Evaluate scalar + call global_interp%evaluate(s%x, fld_data%t%x) + call global_interp%free - ! Build a space_t object from the data in the fld file - call prev_Xh%init(GLL, fld_data%lx, fld_data%ly, fld_data%lz) - call space_interp%init(s%Xh, prev_Xh) + else ! No interpolation - call space_interp%map_host(s%x, fld_data%t%x, fld_data%nelv, s%Xh) + ! Build a space_t object from the data in the fld file + call prev_Xh%init(GLL, fld_data%lx, fld_data%ly, fld_data%lz) + call space_interp%init(s%Xh, prev_Xh) - call space_interp%free + call space_interp%map_host(s%x, fld_data%t%x, fld_data%nelv, s%Xh) - end if + call space_interp%free - call fld_data%free - -end subroutine set_scalar_ic_fld - -!> Set the initial condition of the flow based on a point zone. -!! @details The initial condition is set to the base value and then the -!! zone is filled with the zone value. -!! @param s The scalar field. -!! @param file_name The name of the checkpoint file. -!! @param previous_mesh If specified, the name of the previouos mesh from -!! which to interpolate. -!! @param tol If specified, tolerance to use for the mesh interpolation. -subroutine set_scalar_ic_chkp(s, file_name, previous_mesh_fname, tol) - type(field_t), intent(inout) :: s - character(len=*), intent(in) :: file_name - character(len=*), intent(in), optional :: previous_mesh_fname - real(kind=rp), intent(in), optional :: tol - - type(chkp_t) :: chkp_data - type(file_t) :: f, meshf - - call chkp_data%init(s,s,s,s) - call chkp_data%add_scalar(s) - - ! Mesh interpolation if specified - if (present(previous_mesh_fname)) then - meshf = file_t(trim(previous_mesh_fname)) - call meshf%read(chkp_data%previous_mesh) end if - ! Tolerance is by default 1d-6 - if (present(tol)) chkp_data%mesh2mesh_tol = tol - - ! Read the chkp and perform interpolation - f = file_t(trim(file_name)) - call f%read(chkp_data) + call fld_data%free - end subroutine set_scalar_ic_chkp + end subroutine set_scalar_ic_fld end module scalar_ic From 59e7634d00705c5e0c123e5ee9ce344d1f539e81 Mon Sep 17 00:00:00 2001 From: Victor Baconnet Date: Wed, 11 Sep 2024 17:03:39 +0200 Subject: [PATCH 49/67] rewrite doc --- doc/pages/user-guide/case-file.md | 59 +++++++++++++------------------ 1 file changed, 25 insertions(+), 34 deletions(-) diff --git a/doc/pages/user-guide/case-file.md b/doc/pages/user-guide/case-file.md index 92427873449..46b8b51b7a2 100644 --- a/doc/pages/user-guide/case-file.md +++ b/doc/pages/user-guide/case-file.md @@ -214,43 +214,34 @@ The means of prescribing the values are controlled via the `type` keyword: `base_value` keyword, and then assigned a zone value inside a point zone. The point zone is specified by the `name` keyword, and should be defined in the `case.point_zones` object. See more about point zones @ref point-zones.md. -5. `field`, where the initial condition is retrieved from an output field file - provided by the `file_name` keyword. Supported - file types are: - - `.chkp` files. To interpolate a `chkp` file, use the `previous_mesh` - keyword to provide the mesh from which to interpolate. - - `.fld`, `.nek5000` that refer to a series of `.f*****` files, where the - index of the file to use is provided by the `sample_index` keyword. - - For example, in a series of 3 files `field0.f00000, field0.f00001, - field0.f00002`, `sample_index` can take values `0`,`1` or `2`. In this - case we would set `"file_name" = "field0.fld"`. - - If no `sample_index` is - provided, and a `field0.nek5000` file exists, the last field file in the - series will be used by default. - - `.f*****` which refers to a single `field0.f*****` file. In this case - the sample index will be extracted from the file extension, e.g. `f00012` - means a sample index of `12`. - - **Interpolation** for `fld`, `nek5000` and `f*****` files is activated by - setting the keyword `interpolate` to `true`. - - Note that the tolerance - for interpolation defaults to `1e-6`, but can otherwise be changed by the - keyword `tolerance`. - - The coordinates are retrieved by default from the first file in the - `fld` series. If the coordinates are located in another file, you can - indicate the path to that file with `mesh_file_name`. If the coordinates - are located at a different index in the `fld` series, you can indicate - that index with `sample_mesh_index`. Note that `mesh_file_name` takes - precedence over `sample_mesh_index`. - - @note When interpolating, it is recommended to use files in double precision, - which includes any `chkp` file or `fld` files that were written in double - precision. To check if your `fld` file was written in double precision, run - the command `head -1 field0.f00000`. `#std 4 ...` indicates single precision, +5. `field`, where the initial condition is retrieved from a field file. + The following keywords can be used: + +| Name | Description | Admissible values | Default value | +| ------------------- | ---------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------- | ----------------------------------------- | +| `file_name` | Name of the field file (e.g. `field0.f00034`) or the field file series to use (e.g. `field0.fld` or `field0.nek5000`). | Strings ending with `.fld`, `.nek5000` or `f*****` | - | +| `sample_index` | In the case of a field series, the index of the field file to read. By default, reads the last file in the series. | Integer values | `-1`, i.e. the last sample in the series. | +| `interpolate` | Whether to interpolate the velocity and pressure fields from the field file onto the current mesh. | `true` or `false` | `false` | +| `sample_mesh_index` | If interpolation is enabled, the index of the field file that contains the coordinates. | Integer values | `0` for a field series. | + + @attention Neko does not detect wether interpolation is needed or not. + Interpolation will always be performed if `"interpolate"` is set + to `true` even if the field file matches with the current simulation. + + @note It is recommended to interpolate from `fld` files that were + written in double precision. + To check if your `fld` file was written in double precision, run + the command: + ~~~~~~~~~~~~~~~{.sh} + head -1 field0.f00000 + ~~~~~~~~~~~~~~~ + The output `#std 4 ...` indicates single precision, whereas `#std 8 ...` indicates double precision. - @attention Neko write single precision `fld` files by default. To write your + Neko write single precision `fld` files by default. To write your files in double precision, set `case.output_precision` to `"double"`. - + + ### Blasius profile The `blasius` object is used to specify the Blasius profile that can be used for the initial and inflow condition. From 89f4133474be68b8e3f7b82cb9c7fcfa50d76359 Mon Sep 17 00:00:00 2001 From: Victor Baconnet Date: Wed, 11 Sep 2024 17:10:16 +0200 Subject: [PATCH 50/67] add check on gdim for interpolation --- src/fluid/flow_ic.f90 | 8 ++++---- src/scalar/scalar_ic.f90 | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/fluid/flow_ic.f90 b/src/fluid/flow_ic.f90 index 835a1a7b6e6..56a4126cd10 100644 --- a/src/fluid/flow_ic.f90 +++ b/src/fluid/flow_ic.f90 @@ -468,14 +468,14 @@ subroutine set_flow_ic_fld(u, v, w, p, file_name, sample_idx, & ! two different meshes have the same dimension and same # of elements ! but this should be enough to cover the most obvious cases. ! - if ( fld_data%glb_nelv .ne. u%msh%glb_nelv .and. & + if ( fld_data%glb_nelv .ne. u%msh%glb_nelv .or. & + fld_data%gdim .ne. u%msh%gdim .and. & .not. interpolate) then call neko_error("The fld file must match the current mesh! & &Use 'interpolate': 'true' to enable interpolation.") else if (interpolate) then - call neko_log%warning("You have activated interpolation but you may & + call neko_log%warning("You have activated interpolation but you might & &still be using the same mesh.") - call neko_log%message("(disregard if this was done on purpose)") end if ! Mesh interpolation if specified @@ -506,7 +506,7 @@ subroutine set_flow_ic_fld(u, v, w, p, file_name, sample_idx, & call global_interp%free - else ! No interpolation + else ! No interpolation, but potentially just from different spaces ! Build a space_t object from the data in the fld file call prev_Xh%init(GLL, fld_data%lx, fld_data%ly, fld_data%lz) diff --git a/src/scalar/scalar_ic.f90 b/src/scalar/scalar_ic.f90 index e95ef662dda..2c9bf098d05 100644 --- a/src/scalar/scalar_ic.f90 +++ b/src/scalar/scalar_ic.f90 @@ -132,7 +132,7 @@ subroutine set_scalar_ic_int(s, coef, gs, type, params) ! Get the index of the file to sample ! call json_get_or_default(params, & - 'case.fluid.initial_condition.sample_index', sample_idx, -1) + 'case.scalar.initial_condition.sample_index', sample_idx, -1) ! In case we interpolate, the default index of the file in which to ! look for the coordinates @@ -380,14 +380,14 @@ subroutine set_scalar_ic_fld(s, file_name, sample_idx, & ! two different meshes have the same dimension and same # of elements ! but this should be enough to cover the most obvious cases. ! - if ( fld_data%glb_nelv .ne. s%msh%glb_nelv .and. & + if ( fld_data%glb_nelv .ne. s%msh%glb_nelv .or. & + fld_data%gdim .ne. s%msh%gdim .and. & .not. interpolate) then call neko_error("The fld file must match the current mesh! & &Use 'interpolate': 'true' to enable interpolation.") else if (interpolate) then - call neko_log%warning("You have activated interpolation but you may & + call neko_log%warning("You have activated interpolation but you might & &still be using the same mesh.") - call neko_log%message("(disregard if this was done on purpose)") end if ! Mesh interpolation if specified @@ -412,7 +412,7 @@ subroutine set_scalar_ic_fld(s, file_name, sample_idx, & call global_interp%evaluate(s%x, fld_data%t%x) call global_interp%free - else ! No interpolation + else ! No interpolation, just potentially from different spaces ! Build a space_t object from the data in the fld file call prev_Xh%init(GLL, fld_data%lx, fld_data%ly, fld_data%lz) From 1fe0e95035e17e226dd0075bd30e7a98c2d11e0e Mon Sep 17 00:00:00 2001 From: Victor Baconnet Date: Wed, 11 Sep 2024 17:16:00 +0200 Subject: [PATCH 51/67] update deps --- src/.depends | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/.depends b/src/.depends index f1d04c2ef2b..23d5b38ebf7 100644 --- a/src/.depends +++ b/src/.depends @@ -129,10 +129,10 @@ io/fluid_stats_output.o : io/fluid_stats_output.f90 io/output.o device/device.o io/mean_sqr_flow_output.o : io/mean_sqr_flow_output.f90 io/output.o config/num_types.o fluid/mean_sqr_flow.o io/data_streamer.o : io/data_streamer.F90 config/neko_config.o comm/mpi_types.o comm/comm.o device/device.o common/utils.o sem/coef.o field/field.o config/num_types.o common/sampler.o : common/sampler.f90 common/time_based_controller.o config/num_types.o common/profiler.o common/utils.o common/log.o comm/comm.o io/fld_file.o io/output.o -common/global_interpolation.o : common/global_interpolation.F90 comm/mpi_types.o math/math.o comm/comm.o sem/local_interpolation.o common/utils.o common/log.o mesh/mesh.o sem/dofmap.o sem/space.o config/num_types.o +common/global_interpolation.o : common/global_interpolation.F90 common/structs.o comm/mpi_types.o math/math.o mesh/mesh.o sem/dofmap.o comm/comm.o sem/local_interpolation.o common/utils.o common/log.o sem/space.o config/num_types.o common/profiler.o : common/profiler.F90 common/runtime_statistics.o common/craypat.o device/hip/roctx.o device/cuda/nvtx.o device/device.o config/neko_config.o common/craypat.o : common/craypat.F90 -bc/bc.o : bc/bc.f90 common/utils.o adt/tuple.o adt/stack.o mesh/facet_zone.o mesh/mesh.o sem/space.o sem/coef.o sem/dofmap.o device/device.o config/num_types.o config/neko_config.o +bc/bc.o : bc/bc.f90 common/utils.o adt/tuple.o adt/stack.o mesh/facet_zone.o mesh/mesh.o sem/space.o sem/coef.o sem/dofmap.o device/device.o config/num_types.o config/neko_config.o bc/dirichlet.o : bc/dirichlet.f90 bc/bc.o config/num_types.o bc/bcknd/device/device_dirichlet.o bc/neumann.o : bc/neumann.f90 math/math.o sem/coef.o common/utils.o bc/bc.o config/num_types.o bc/shear_stress.o : bc/shear_stress.f90 math/bcknd/device/device_math.o math/math.o bc/neumann.o bc/dirichlet.o sem/coef.o common/utils.o bc/bc.o config/num_types.o From f2421a19edb951bd73480a75895bb050314cd0e6 Mon Sep 17 00:00:00 2001 From: Victor Baconnet Date: Thu, 12 Sep 2024 14:38:59 +0200 Subject: [PATCH 52/67] Cleanup --- src/common/global_interpolation.F90 | 62 +++++------ src/fluid/flow_ic.f90 | 5 +- src/io/chkp_file.f90 | 150 +++++++++++---------------- src/io/fld_file_data.f90 | 9 +- src/scalar/scalar_ic.f90 | 4 +- src/simulation_components/probes.F90 | 10 +- 6 files changed, 106 insertions(+), 134 deletions(-) diff --git a/src/common/global_interpolation.F90 b/src/common/global_interpolation.F90 index 8329c7e8649..eb393cdf72d 100644 --- a/src/common/global_interpolation.F90 +++ b/src/common/global_interpolation.F90 @@ -38,12 +38,12 @@ module global_interpolation use num_types, only: rp use space, only: space_t + use dofmap, only: dofmap_t + use mesh, only: mesh_t use logger, only: neko_log, LOG_SIZE use utils, only: neko_error, neko_warning use local_interpolation use comm - use dofmap, only: dofmap_t - use mesh, only: mesh_t use math, only: copy use neko_mpi_types use structs, only: array_ptr_t @@ -52,46 +52,46 @@ module global_interpolation private !> Implements global interpolation for arbitrary points in the domain. type, public :: global_interpolation_t - !> X coordinates from which to interpolate + !> X coordinates from which to interpolate. type(array_ptr_t) :: x - !> Y coordinates from which to interpolate + !> Y coordinates from which to interpolate. type(array_ptr_t) :: y - !> Z coordinates from which to interpolate + !> Z coordinates from which to interpolate. type(array_ptr_t) :: z - !> Geometric dimension of the simulation + !> Geometric dimension of the simulation. integer :: gdim - !> Number of elements + !> Number of elements. integer :: nelv - !> Space + !> Space. type(space_t), pointer :: Xh - !> Interpolator for local points + !> Interpolator for local points. type(local_interpolator_t) :: local_interp - !> If all points are local on this PE + !> If all points are local on this PE. logical :: all_points_local = .false. - !! Gslib handle - !! @note: Remove when we remove gslib + !! Gslib handle. + !! @note: Remove when we remove gslib. integer :: gs_handle logical :: gs_init = .false. !> Components related to the points we want to evalute !> Number of points we want to evaluate integer :: n_points - !> x,y,z coordinates, findpts format + !> x,y,z coordinates, findpts format. !! @note: When replacing gs we can change format real(kind=rp), allocatable :: xyz(:,:) - !> List of owning processes + !> List of owning processes. integer, allocatable :: proc_owner(:) - !> List of owning elements + !> List of owning elements. integer, allocatable :: el_owner(:) type(c_ptr) :: el_owner_d = c_null_ptr - !> r,s,t coordinates findpts format + !> r,s,t coordinates findpts format. !! @note: When replacing gs we can change format real(kind=rp), allocatable :: rst(:,:) - !> Distance squared between original and interpolated point + !> Distance squared between original and interpolated point. !! (in xyz space) (according to gslib) real(kind=rp), allocatable :: dist2(:) - !> Error code for each point, needed for gslib + !> Error code for each point, needed for gslib. integer, allocatable :: error_code(:) - !> Tolerance for distance squared between original and interpolated point + !> Tolerance for distance squared between original and interpolated point. real(kind=rp) :: tol = 5d-13 contains !> Initialize the global interpolation object on a dofmap. @@ -123,8 +123,6 @@ module global_interpolation !> Initialize the global interpolation object on a dofmap. !! @param dof Dofmap on which the interpolation is to be carried out. !! @param tol Tolerance for Newton iterations. - !! @param Xh Space on which to interpolate. - !! @param msh Mesh on which to interp subroutine global_interpolation_init_dof(this, dof, tol) class(global_interpolation_t), intent(inout) :: this type(dofmap_t), target :: dof @@ -140,7 +138,8 @@ end subroutine global_interpolation_init_dof !! @param y y-coordinates. !! @param z z-coordinates. !! @param gdim Geometric dimension. - !! @param nelv Number of elements. + !! @param nelv Number of elements of the mesh in which to search for the + !! points. !! @param Xh Space on which to interpolate. !! @param tol Tolerance for Newton iterations. subroutine global_interpolation_init_xyz(this, x, y, z, gdim, nelv, Xh, tol) @@ -347,8 +346,8 @@ end subroutine global_interpolation_find_common !! in the correct global element as well as which process that owns the point. !! After this the values at these points can be evaluated. !! If the locations of the points change this must be called again. - !! - `error_code`: returns `0` if point found, `1` if closest point on a border - !! (check dist2), `2` if not found + !! - `error_code`: returns `0` if point found, `1` if closest point on a + !! border (check dist2), `2` if not found !! - `dist2`: distance squared (used to compare the points found by each !! processor) !! @param x The x-coordinates of the points. @@ -401,8 +400,8 @@ end subroutine global_interpolation_init_point_arrays !! in the correct global element as well as which process that owns the point. !! After this the values at these points can be evaluated. !! If the locations of the points change this must be called again. - !! - `error_code`: returns `0` if point found, `1` if closest point on a border - !! (check dist2), `2` if not found + !! - `error_code`: returns `0` if point found, `1` if closest point on a + !! border (check dist2), `2` if not found !! - `dist2`: distance squared (used to compare the points found by each !! processor) !! @param xyz The coordinates of the points. @@ -427,12 +426,13 @@ subroutine global_interpolation_find_xyz(this, xyz, n_points) end subroutine global_interpolation_find_xyz - !> Finds the corresponding r,s,t coordinates and redistributes the points to the owning rank - !! in the correct global element as well as which process that owns the point. + !> Finds the corresponding r,s,t coordinates and redistributes the points to + !! the owning rank in the correct global element as well as which process + !! that owns the point. !! After this the values at these points can be evaluated. !! If the locations of the points change this must be called again. - !! - `error_code`: returns `0` if point found, `1` if closest point on a border - !! (check dist2), `2` if not found + !! - `error_code`: returns `0` if point found, `1` if closest point on a + !! border (check dist2), `2` if not found. !! - `dist2`: distance squared (used to compare the points found by each !! processor) !! @param xyz The coordinates of the points. @@ -563,6 +563,8 @@ subroutine global_interpolation_evaluate(this, interp_values, field) real(kind=rp), intent(inout) :: interp_values(this%n_points) real(kind=rp), intent(inout) :: field(this%nelv*this%Xh%lxyz) + integer :: ioioi + #ifdef HAVE_GSLIB if (.not. this%all_points_local) then call fgslib_findpts_eval(this%gs_handle, interp_values, & diff --git a/src/fluid/flow_ic.f90 b/src/fluid/flow_ic.f90 index 56a4126cd10..675f1aa0838 100644 --- a/src/fluid/flow_ic.f90 +++ b/src/fluid/flow_ic.f90 @@ -43,7 +43,7 @@ module flow_ic use utils, only : neko_error, filename_suffix, filename_chsuffix, & neko_warning, NEKO_FNAME_LEN use coefs, only : coef_t - use math, only : col2, cfill, cfill_mask, copy + use math, only : col2, cfill, cfill_mask use device_math, only : device_col2, device_cfill, device_cfill_mask use user_intf, only : useric use json_module, only : json_file @@ -52,7 +52,6 @@ module flow_ic use point_zone_registry, only: neko_point_zone_registry use fld_file_data, only: fld_file_data_t use fld_file, only: fld_file_t - use checkpoint, only: chkp_t use file, only: file_t use global_interpolation, only: global_interpolation_t use interpolation, only: interpolator_t @@ -85,7 +84,7 @@ subroutine set_flow_ic_int(u, v, w, p, coef, gs, type, params) character(len=80) :: suffix character(len=NEKO_FNAME_LEN) :: fname integer :: sample_idx, fpos, sample_mesh_idx, default_sample_mesh_idx - logical :: found_previous_mesh, interpolate + logical :: interpolate character(len=LOG_SIZE) :: log_buf ! diff --git a/src/io/chkp_file.f90 b/src/io/chkp_file.f90 index 1cbdc92b3a1..475e40000d9 100644 --- a/src/io/chkp_file.f90 +++ b/src/io/chkp_file.f90 @@ -53,16 +53,11 @@ module chkp_file !> Interface for Neko checkpoint files type, public, extends(generic_file_t) :: chkp_file_t - !> Function space in the loaded checkpoint file - type(space_t) :: chkp_Xh - !> Function space used in the simulation - type(space_t), pointer :: sim_Xh - !> Interpolation when only changing lx - type(interpolator_t) :: space_interp - !> Interpolation for different meshes - type(global_interpolation_t) :: global_interp - !> Flag if previous mesh difers from current. - logical :: mesh2mesh + type(space_t) :: chkp_Xh !< Function space in the loaded checkpoint file + type(space_t), pointer :: sim_Xh !< Function space used in the simulation + type(interpolator_t) :: space_interp !< Interpolation when only changing lx + type(global_interpolation_t) :: global_interp !< Interpolation for different meshes + logical :: mesh2mesh !< Flag if previous mesh difers from current. contains procedure :: read => chkp_file_read procedure :: read_field => chkp_read_field @@ -81,10 +76,10 @@ subroutine chkp_file_write(this, data, t) character(len=1024) :: fname integer :: ierr, suffix_pos, optional_fields type(field_t), pointer :: u, v, w, p, s - type(field_t), pointer :: abx1, abx2 - type(field_t), pointer :: aby1, aby2 - type(field_t), pointer :: abz1, abz2 - type(field_t), pointer :: abs1, abs2 + type(field_t), pointer :: abx1,abx2 + type(field_t), pointer :: aby1,aby2 + type(field_t), pointer :: abz1,abz2 + type(field_t), pointer :: abs1,abs2 type(field_series_t), pointer :: ulag => null() type(field_series_t), pointer :: vlag => null() type(field_series_t), pointer :: wlag => null() @@ -95,17 +90,16 @@ subroutine chkp_file_write(this, data, t) type(MPI_File) :: fh integer (kind=MPI_OFFSET_KIND) :: mpi_offset, byte_offset integer(kind=i8) :: n_glb_dofs, dof_offset - logical :: write_lag, write_scalar, write_dtlag, write_scalarlag - logical :: write_abvel + logical :: write_lag, write_scalar, write_dtlag, write_scalarlag, write_abvel integer :: i if (present(t)) then - time = real(t, dp) + time = real(t,dp) else time = 0d0 end if - select type (data) + select type(data) type is (chkp_t) if ( .not. associated(data%u) .or. & @@ -194,32 +188,30 @@ subroutine chkp_file_write(this, data, t) ! Dump mandatory checkpoint data ! - byte_offset = 4_i8 * int(MPI_INTEGER_SIZE, i8) + & - int(MPI_DOUBLE_PRECISION_SIZE, i8) + byte_offset = 4_i8 * int(MPI_INTEGER_SIZE,i8) + int(MPI_DOUBLE_PRECISION_SIZE,i8) byte_offset = byte_offset + & dof_offset * int(MPI_REAL_PREC_SIZE, i8) - call MPI_File_write_at_all(fh, byte_offset,u%x, u%size(), & + call MPI_File_write_at_all(fh, byte_offset,u%x, u%dof%size(), & MPI_REAL_PRECISION, status, ierr) - mpi_offset = 4_i8 * int(MPI_INTEGER_SIZE, i8) + & - int(MPI_DOUBLE_PRECISION_SIZE, i8) + mpi_offset = 4_i8 * int(MPI_INTEGER_SIZE,i8) + int(MPI_DOUBLE_PRECISION_SIZE,i8) mpi_offset = mpi_offset +& n_glb_dofs * int(MPI_REAL_PREC_SIZE, i8) byte_offset = mpi_offset + & dof_offset * int(MPI_REAL_PREC_SIZE, i8) - call MPI_File_write_at_all(fh, byte_offset, v%x, v%size(), & + call MPI_File_write_at_all(fh, byte_offset, v%x, v%dof%size(), & MPI_REAL_PRECISION, status, ierr) mpi_offset = mpi_offset + n_glb_dofs * int(MPI_REAL_PREC_SIZE, i8) byte_offset = mpi_offset + & dof_offset * int(MPI_REAL_PREC_SIZE, i8) - call MPI_File_write_at_all(fh, byte_offset, w%x, w%size(), & + call MPI_File_write_at_all(fh, byte_offset, w%x, w%dof%size(), & MPI_REAL_PRECISION, status, ierr) mpi_offset = mpi_offset + n_glb_dofs * int(MPI_REAL_PREC_SIZE, i8) byte_offset = mpi_offset + & dof_offset * int(MPI_REAL_PREC_SIZE, i8) - call MPI_File_write_at_all(fh, byte_offset, p%x, p%size(), & + call MPI_File_write_at_all(fh, byte_offset, p%x, p%dof%size(), & MPI_REAL_PRECISION, status, ierr) mpi_offset = mpi_offset + n_glb_dofs * int(MPI_REAL_PREC_SIZE, i8) @@ -237,7 +229,7 @@ subroutine chkp_file_write(this, data, t) ! ICE with NAG. associate (x => ulag%lf(i)%x) call MPI_File_write_at_all(fh, byte_offset, x, & - ulag%lf(i)%size(), MPI_REAL_PRECISION, status, ierr) + ulag%lf(i)%dof%size(), MPI_REAL_PRECISION, status, ierr) end associate mpi_offset = mpi_offset + n_glb_dofs * int(MPI_REAL_PREC_SIZE, i8) end do @@ -250,7 +242,7 @@ subroutine chkp_file_write(this, data, t) ! ICE with NAG. associate (x => vlag%lf(i)%x) call MPI_File_write_at_all(fh, byte_offset, x, & - vlag%lf(i)%size(), MPI_REAL_PRECISION, status, ierr) + vlag%lf(i)%dof%size(), MPI_REAL_PRECISION, status, ierr) end associate mpi_offset = mpi_offset + n_glb_dofs * int(MPI_REAL_PREC_SIZE, i8) end do @@ -263,7 +255,7 @@ subroutine chkp_file_write(this, data, t) ! ICE with NAG. associate (x => wlag%lf(i)%x) call MPI_File_write_at_all(fh, byte_offset, x, & - wlag%lf(i)%size(), MPI_REAL_PRECISION, status, ierr) + wlag%lf(i)%dof%size(), MPI_REAL_PRECISION, status, ierr) end associate mpi_offset = mpi_offset + n_glb_dofs * int(MPI_REAL_PREC_SIZE, i8) end do @@ -273,49 +265,47 @@ subroutine chkp_file_write(this, data, t) if (write_scalar) then byte_offset = mpi_offset + & dof_offset * int(MPI_REAL_PREC_SIZE, i8) - call MPI_File_write_at_all(fh, byte_offset, s%x, p%size(), & + call MPI_File_write_at_all(fh, byte_offset, s%x, p%dof%size(), & MPI_REAL_PRECISION, status, ierr) mpi_offset = mpi_offset + n_glb_dofs * int(MPI_REAL_PREC_SIZE, i8) end if if (write_dtlag) then - call MPI_File_write_at_all(fh, mpi_offset, tlag, 10, & - MPI_REAL_PRECISION, status, ierr) + call MPI_File_write_at_all(fh, mpi_offset, tlag, 10, MPI_REAL_PRECISION, status, ierr) mpi_offset = mpi_offset + 10_i8 * int(MPI_REAL_PREC_SIZE, i8) - call MPI_File_write_at_all(fh, mpi_offset, dtlag, 10, & - MPI_REAL_PRECISION, status, ierr) + call MPI_File_write_at_all(fh, mpi_offset, dtlag, 10, MPI_REAL_PRECISION, status, ierr) mpi_offset = mpi_offset + 10_i8 * int(MPI_REAL_PREC_SIZE, i8) end if if (write_abvel) then byte_offset = mpi_offset + & dof_offset * int(MPI_REAL_PREC_SIZE, i8) - call MPI_File_write_at_all(fh, byte_offset, abx1%x, abx1%size(), & + call MPI_File_write_at_all(fh, byte_offset, abx1%x, abx1%dof%size(), & MPI_REAL_PRECISION, status, ierr) mpi_offset = mpi_offset + n_glb_dofs * int(MPI_REAL_PREC_SIZE, i8) byte_offset = mpi_offset + & dof_offset * int(MPI_REAL_PREC_SIZE, i8) - call MPI_File_write_at_all(fh, byte_offset, abx2%x, abx1%size(), & + call MPI_File_write_at_all(fh, byte_offset, abx2%x, abx1%dof%size(), & MPI_REAL_PRECISION, status, ierr) mpi_offset = mpi_offset + n_glb_dofs * int(MPI_REAL_PREC_SIZE, i8) byte_offset = mpi_offset + & dof_offset * int(MPI_REAL_PREC_SIZE, i8) - call MPI_File_write_at_all(fh, byte_offset, aby1%x, abx1%size(), & + call MPI_File_write_at_all(fh, byte_offset, aby1%x, abx1%dof%size(), & MPI_REAL_PRECISION, status, ierr) mpi_offset = mpi_offset + n_glb_dofs * int(MPI_REAL_PREC_SIZE, i8) byte_offset = mpi_offset + & dof_offset * int(MPI_REAL_PREC_SIZE, i8) - call MPI_File_write_at_all(fh, byte_offset, aby2%x, abx1%size(), & + call MPI_File_write_at_all(fh, byte_offset, aby2%x, abx1%dof%size(), & MPI_REAL_PRECISION, status, ierr) mpi_offset = mpi_offset + n_glb_dofs * int(MPI_REAL_PREC_SIZE, i8) byte_offset = mpi_offset + & dof_offset * int(MPI_REAL_PREC_SIZE, i8) - call MPI_File_write_at_all(fh, byte_offset, abz1%x, abx1%size(), & + call MPI_File_write_at_all(fh, byte_offset, abz1%x, abx1%dof%size(), & MPI_REAL_PRECISION, status, ierr) mpi_offset = mpi_offset + n_glb_dofs * int(MPI_REAL_PREC_SIZE, i8) byte_offset = mpi_offset + & dof_offset * int(MPI_REAL_PREC_SIZE, i8) - call MPI_File_write_at_all(fh, byte_offset, abz2%x, abx1%size(), & + call MPI_File_write_at_all(fh, byte_offset, abz2%x, abx1%dof%size(), & MPI_REAL_PRECISION, status, ierr) mpi_offset = mpi_offset + n_glb_dofs * int(MPI_REAL_PREC_SIZE, i8) end if @@ -329,19 +319,19 @@ subroutine chkp_file_write(this, data, t) ! ICE with NAG. associate (x => slag%lf(i)%x) call MPI_File_write_at_all(fh, byte_offset, x, & - slag%lf(i)%size(), MPI_REAL_PRECISION, status, ierr) + slag%lf(i)%dof%size(), MPI_REAL_PRECISION, status, ierr) end associate mpi_offset = mpi_offset + n_glb_dofs * int(MPI_REAL_PREC_SIZE, i8) end do byte_offset = mpi_offset + & dof_offset * int(MPI_REAL_PREC_SIZE, i8) - call MPI_File_write_at_all(fh, byte_offset, abs1%x, abx1%size(), & + call MPI_File_write_at_all(fh, byte_offset, abs1%x, abx1%dof%size(), & MPI_REAL_PRECISION, status, ierr) mpi_offset = mpi_offset + n_glb_dofs * int(MPI_REAL_PREC_SIZE, i8) byte_offset = mpi_offset + & dof_offset * int(MPI_REAL_PREC_SIZE, i8) - call MPI_File_write_at_all(fh, byte_offset, abs2%x, abx1%size(), & + call MPI_File_write_at_all(fh, byte_offset, abs2%x, abx1%dof%size(), & MPI_REAL_PRECISION, status, ierr) mpi_offset = mpi_offset + n_glb_dofs * int(MPI_REAL_PREC_SIZE, i8) end if @@ -368,27 +358,27 @@ subroutine chkp_file_read(this, data) type(mesh_t), pointer :: msh type(MPI_Status) :: status type(MPI_File) :: fh - type(field_t), pointer :: abx1, abx2 - type(field_t), pointer :: aby1, aby2 - type(field_t), pointer :: abz1, abz2 - type(field_t), pointer :: abs1, abs2 + type(field_t), pointer :: abx1,abx2 + type(field_t), pointer :: aby1,aby2 + type(field_t), pointer :: abz1,abz2 + type(field_t), pointer :: abs1,abs2 real(kind=rp), allocatable :: x_coord(:,:,:,:) real(kind=rp), allocatable :: y_coord(:,:,:,:) real(kind=rp), allocatable :: z_coord(:,:,:,:) real(kind=rp), pointer :: dtlag(:), tlag(:) integer (kind=MPI_OFFSET_KIND) :: mpi_offset, byte_offset integer(kind=i8) :: n_glb_dofs, dof_offset - integer :: glb_nelv, gdim, lx, have_lag, have_scalar, nel, optional_fields - integer :: have_dtlag, have_abvel, have_scalarlag + integer :: glb_nelv, gdim, lx, have_lag, have_scalar, nel, optional_fields, have_dtlag + integer :: have_abvel, have_scalarlag logical :: read_lag, read_scalar, read_dtlag, read_abvel, read_scalarlag real(kind=rp) :: tol real(kind=rp) :: center_x, center_y, center_z - integer :: i, e, size_lag + integer :: i, e type(dofmap_t) :: dof call this%check_exists() - select type (data) + select type(data) type is (chkp_t) if ( .not. associated(data%u) .or. & @@ -509,16 +499,13 @@ subroutine chkp_file_read(this, data) center_y = center_y/u%Xh%lxyz center_z = center_z/u%Xh%lxyz do i = 1,u%dof%Xh%lxyz - x_coord(i,1,1,e) = u%dof%x(i,1,1,e) - tol * (u%dof%x(i,1,1,e) - & - center_x) - y_coord(i,1,1,e) = u%dof%y(i,1,1,e) - tol * (u%dof%y(i,1,1,e) - & - center_y) - z_coord(i,1,1,e) = u%dof%z(i,1,1,e) - tol * (u%dof%z(i,1,1,e) - & - center_z) + x_coord(i,1,1,e) = u%dof%x(i,1,1,e) - tol*(u%dof%x(i,1,1,e)-center_x) + y_coord(i,1,1,e) = u%dof%y(i,1,1,e) - tol*(u%dof%y(i,1,1,e)-center_y) + z_coord(i,1,1,e) = u%dof%z(i,1,1,e) - tol*(u%dof%z(i,1,1,e)-center_z) end do end do - call this%global_interp%init(dof, tol = tol) - call this%global_interp%find_points(x_coord, y_coord, z_coord,u%size()) + call this%global_interp%init(dof,tol=tol) + call this%global_interp%find_points(x_coord,y_coord,z_coord,u%dof%size()) deallocate(x_coord) deallocate(y_coord) deallocate(z_coord) @@ -532,13 +519,11 @@ subroutine chkp_file_read(this, data) ! Read mandatory checkpoint data ! - byte_offset = 4_i8 * int(MPI_INTEGER_SIZE, i8) + & - int(MPI_DOUBLE_PRECISION_SIZE, i8) + byte_offset = 4_i8 * int(MPI_INTEGER_SIZE,i8) + int(MPI_DOUBLE_PRECISION_SIZE,i8) byte_offset = byte_offset + & dof_offset * int(MPI_REAL_PREC_SIZE, i8) call this%read_field(fh, byte_offset, u%x, nel) - mpi_offset = 4_i8 * int(MPI_INTEGER_SIZE, i8) + & - int(MPI_DOUBLE_PRECISION_SIZE, i8) + mpi_offset = 4_i8 * int(MPI_INTEGER_SIZE,i8) + int(MPI_DOUBLE_PRECISION_SIZE,i8) mpi_offset = mpi_offset +& n_glb_dofs * int(MPI_REAL_PREC_SIZE, i8) @@ -560,41 +545,26 @@ subroutine chkp_file_read(this, data) ! ! Read optional payload ! - if (have_lag .eq. 1) then - - ! If we have a lag, use its size, otherwise guess the size from - ! how it is currently initialized in `fluid` - if (read_lag) size_lag = ulag%size() - size_lag = 2 - do i = 1, size_lag + if (read_lag) then + do i = 1, ulag%size() byte_offset = mpi_offset + & dof_offset * int(MPI_REAL_PREC_SIZE, i8) - if (read_lag) call this%read_field(fh, byte_offset, ulag%lf(i)%x, nel) + call this%read_field(fh, byte_offset, ulag%lf(i)%x, nel) mpi_offset = mpi_offset + n_glb_dofs * int(MPI_REAL_PREC_SIZE, i8) end do - ! If we have a lag, use its size, otherwise guess the size from - ! how it is currently initialized in `fluid` - if (read_lag) size_lag = vlag%size() - size_lag = 2 - - do i = 1, size_lag + do i = 1, vlag%size() byte_offset = mpi_offset + & dof_offset * int(MPI_REAL_PREC_SIZE, i8) - if (read_lag) call this%read_field(fh, byte_offset, vlag%lf(i)%x, nel) + call this%read_field(fh, byte_offset, vlag%lf(i)%x, nel) mpi_offset = mpi_offset + n_glb_dofs * int(MPI_REAL_PREC_SIZE, i8) end do - ! If we have a lag, use its size, otherwise guess the size from - ! how it is currently initialized in `fluid` - if (read_lag) size_lag = wlag%size() - size_lag = 2 - - do i = 1, size_lag + do i = 1, wlag%size() byte_offset = mpi_offset + & dof_offset * int(MPI_REAL_PREC_SIZE, i8) - if (read_lag) call this%read_field(fh, byte_offset, wlag%lf(i)%x, nel) + call this%read_field(fh, byte_offset, wlag%lf(i)%x, nel) mpi_offset = mpi_offset + n_glb_dofs * int(MPI_REAL_PREC_SIZE, i8) end do end if @@ -607,11 +577,9 @@ subroutine chkp_file_read(this, data) end if if (read_dtlag .and. have_dtlag .eq. 1) then - call MPI_File_read_at_all(fh, mpi_offset, tlag, 10, & - MPI_REAL_PRECISION, status, ierr) + call MPI_File_read_at_all(fh, mpi_offset, tlag, 10, MPI_REAL_PRECISION, status, ierr) mpi_offset = mpi_offset + 10_i8 * int(MPI_REAL_PREC_SIZE, i8) - call MPI_File_read_at_all(fh, mpi_offset, dtlag, 10, & - MPI_REAL_PRECISION, status, ierr) + call MPI_File_read_at_all(fh, mpi_offset, dtlag, 10, MPI_REAL_PRECISION, status, ierr) mpi_offset = mpi_offset + 10_i8 * int(MPI_REAL_PREC_SIZE, i8) end if @@ -678,12 +646,12 @@ subroutine chkp_read_field(this, fh, byte_offset, x, nel) allocate(read_array(this%chkp_Xh%lxyz*nel)) - call rzero(read_array, this%chkp_xh%lxyz*nel) + call rzero(read_array,this%chkp_xh%lxyz*nel) call MPI_File_read_at_all(fh, byte_offset, read_array, & nel*this%chkp_Xh%lxyz, MPI_REAL_PRECISION, status, ierr) if (this%mesh2mesh) then x = 0.0_rp - call this%global_interp%evaluate(x, read_array) + call this%global_interp%evaluate(x,read_array) else call this%space_interp%map_host(x, read_array, nel, this%sim_Xh) diff --git a/src/io/fld_file_data.f90 b/src/io/fld_file_data.f90 index 14121646509..ccfe323ae0f 100644 --- a/src/io/fld_file_data.f90 +++ b/src/io/fld_file_data.f90 @@ -2,7 +2,8 @@ !! Provides an interface to the different fields sotred in a fld file !! Also provides simple functions to scale and add different fld files. !! An example of using this module is shown in contrib/average_fields.f90 -!! The fld_file_data_t should dynamically update each time one reads a new fld file +!! The fld_file_data_t should dynamically update each time one reads a new fld +!! file. !! Martin Karp 1/2-2023 module fld_file_data use num_types, only : rp @@ -39,9 +40,11 @@ module fld_file_data integer :: lz = 0 integer :: t_counter = 0 !< counter of samples ! meta file information (if any) - integer :: meta_nsamples = 0 !< number of samples specified in .nek5000 file + !> number of samples specified in .nek5000 file + integer :: meta_nsamples = 0 integer :: meta_start_counter = 0 !< number of first field - character(len=1024) :: fld_series_fname !< name of fld series as specified in .nek5000 (meta) file + !> name of fld series as specified in .nek5000 (meta) file + character(len=1024) :: fld_series_fname contains procedure, pass(this) :: init => fld_file_data_init procedure, pass(this) :: free => fld_file_data_free diff --git a/src/scalar/scalar_ic.f90 b/src/scalar/scalar_ic.f90 index 2c9bf098d05..fda7c90c589 100644 --- a/src/scalar/scalar_ic.f90 +++ b/src/scalar/scalar_ic.f90 @@ -41,7 +41,7 @@ module scalar_ic use utils, only : neko_error, filename_chsuffix, filename_suffix, & neko_warning, NEKO_FNAME_LEN use coefs, only : coef_t - use math, only : col2, cfill, cfill_mask, copy + use math, only : col2, cfill, cfill_mask use user_intf, only : useric_scalar use json_module, only : json_file use json_utils, only: json_get, json_get_or_default @@ -91,7 +91,7 @@ subroutine set_scalar_ic_int(s, coef, gs, type, params) character(len=80) :: suffix character(len=NEKO_FNAME_LEN) :: fname real(kind=rp) :: zone_value, tol - logical :: found, found_previous_mesh, interpolate + logical :: interpolate integer :: sample_idx, fpos, sample_mesh_idx, default_sample_mesh_idx character(len=LOG_SIZE) :: log_buf diff --git a/src/simulation_components/probes.F90 b/src/simulation_components/probes.F90 index 1945bf6eadd..423d3c07202 100644 --- a/src/simulation_components/probes.F90 +++ b/src/simulation_components/probes.F90 @@ -282,7 +282,7 @@ subroutine read_line(this, json) call json_get(json, "amount", n_points) ! If either start or end is not of length 3, error out - if (size(start) .ne. 3 .or. size(end) .ne. 3) then + if (size(start) /= 3 .or. size(end) /= 3) then call neko_error('Invalid start or end coordinates.') end if @@ -331,16 +331,16 @@ subroutine read_circle(this, json) call json_get(json, "axis", axis) ! If either center or normal is not of length 3, error out - if (size(center) .ne. 3 .or. size(normal) .ne. 3) then + if (size(center) /= 3 .or. size(normal) /= 3) then call neko_error('Invalid center or normal coordinates.') end if - if (axis .ne. 'x' .and. axis .ne. 'y' .and. axis .ne. 'z') then + if (axis /= 'x' .and. axis /= 'y' .and. axis /= 'z') then call neko_error('Invalid axis.') end if - if (radius .le. 0) then + if (radius <= 0) then call neko_error('Invalid radius.') end if - if (n_points .le. 0) then + if (n_points <= 0) then call neko_error('Invalid number of points.') end if From 05f9de1e6046a3af75c0b6267524dabfc0a0069f Mon Sep 17 00:00:00 2001 From: Victor Baconnet Date: Thu, 12 Sep 2024 14:42:56 +0200 Subject: [PATCH 53/67] depends --- src/.depends | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/.depends b/src/.depends index 23d5b38ebf7..ff7f573ac3c 100644 --- a/src/.depends +++ b/src/.depends @@ -129,7 +129,7 @@ io/fluid_stats_output.o : io/fluid_stats_output.f90 io/output.o device/device.o io/mean_sqr_flow_output.o : io/mean_sqr_flow_output.f90 io/output.o config/num_types.o fluid/mean_sqr_flow.o io/data_streamer.o : io/data_streamer.F90 config/neko_config.o comm/mpi_types.o comm/comm.o device/device.o common/utils.o sem/coef.o field/field.o config/num_types.o common/sampler.o : common/sampler.f90 common/time_based_controller.o config/num_types.o common/profiler.o common/utils.o common/log.o comm/comm.o io/fld_file.o io/output.o -common/global_interpolation.o : common/global_interpolation.F90 common/structs.o comm/mpi_types.o math/math.o mesh/mesh.o sem/dofmap.o comm/comm.o sem/local_interpolation.o common/utils.o common/log.o sem/space.o config/num_types.o +common/global_interpolation.o : common/global_interpolation.F90 common/structs.o comm/mpi_types.o math/math.o comm/comm.o sem/local_interpolation.o common/utils.o common/log.o mesh/mesh.o sem/dofmap.o sem/space.o config/num_types.o common/profiler.o : common/profiler.F90 common/runtime_statistics.o common/craypat.o device/hip/roctx.o device/cuda/nvtx.o device/device.o config/neko_config.o common/craypat.o : common/craypat.F90 bc/bc.o : bc/bc.f90 common/utils.o adt/tuple.o adt/stack.o mesh/facet_zone.o mesh/mesh.o sem/space.o sem/coef.o sem/dofmap.o device/device.o config/num_types.o config/neko_config.o @@ -206,7 +206,7 @@ fluid/mean_flow.o : fluid/mean_flow.f90 field/field.o field/mean_field.o fluid/fluid_stats.o : fluid/fluid_stats.f90 common/utils.o config/neko_config.o device/device.o common/stats_quant.o field/field_list.o field/field.o sem/coef.o math/operators.o math/math.o config/num_types.o math/bcknd/device/device_math.o field/mean_field.o fluid/mean_sqr_flow.o : fluid/mean_sqr_flow.f90 field/field.o field/mean_sqr_field.o fluid/flow_profile.o : fluid/flow_profile.f90 config/num_types.o -fluid/flow_ic.o : fluid/flow_ic.f90 sem/space.o sem/interpolation.o common/global_interpolation.o io/file.o common/checkpoint.o io/fld_file.o io/fld_file_data.o mesh/point_zone_registry.o mesh/point_zone.o common/json_utils.o common/user_intf.o math/bcknd/device/device_math.o math/math.o sem/coef.o common/utils.o field/field.o device/device.o fluid/flow_profile.o config/neko_config.o gs/gather_scatter.o common/log.o config/num_types.o +fluid/flow_ic.o : fluid/flow_ic.f90 sem/space.o sem/interpolation.o common/global_interpolation.o io/file.o io/fld_file.o io/fld_file_data.o mesh/point_zone_registry.o mesh/point_zone.o common/json_utils.o common/user_intf.o math/bcknd/device/device_math.o math/math.o sem/coef.o common/utils.o field/field.o device/device.o fluid/flow_profile.o config/neko_config.o gs/gather_scatter.o common/log.o config/num_types.o fluid/advection.o : fluid/advection.f90 time_schemes/time_scheme_controller.o field/field_series.o sem/coef.o field/field.o sem/space.o config/num_types.o fluid/advection_fctry.o : fluid/advection_fctry.f90 fluid/bcknd/advection/adv_oifs.o fluid/bcknd/advection/adv_no_dealias.o fluid/bcknd/advection/adv_dealias.o common/json_utils.o fluid/advection.o fluid/bcknd/advection/adv_dealias.o : fluid/bcknd/advection/adv_dealias.f90 device/device.o sem/interpolation.o math/operators.o config/neko_config.o math/bcknd/device/device_math.o sem/coef.o field/field.o sem/space.o math/math.o config/num_types.o fluid/advection.o From c5e0df93c22ebd2f3f4ffbce1d8de5936d82e23d Mon Sep 17 00:00:00 2001 From: Victor Baconnet Date: Thu, 12 Sep 2024 17:23:43 +0200 Subject: [PATCH 54/67] go back to original stuff in probes, possibly not working but out of scope for this PR --- src/simulation_components/probes.F90 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/simulation_components/probes.F90 b/src/simulation_components/probes.F90 index 423d3c07202..05f4d53d7ad 100644 --- a/src/simulation_components/probes.F90 +++ b/src/simulation_components/probes.F90 @@ -220,7 +220,7 @@ subroutine read_file(this, json) integer :: n_local, n_global - !if (pe_rank .ne. 0) return + if (pe_rank .ne. 0) return call json_get(json, 'file_name', input_file) @@ -242,7 +242,7 @@ subroutine read_point(this, json) logical :: found ! Ensure only rank 0 reads the coordinates. - !if (pe_rank .ne. 0) return + if (pe_rank .ne. 0) return call json%get('coordinates', rp_list_reader, found) ! Check if the coordinates were found and were valid @@ -276,7 +276,7 @@ subroutine read_line(this, json) integer :: n_points, i ! Ensure only rank 0 reads the coordinates. - !if (pe_rank .ne. 0) return + if (pe_rank .ne. 0) return call json_get(json, "start", start) call json_get(json, "end", end) call json_get(json, "amount", n_points) @@ -323,7 +323,7 @@ subroutine read_circle(this, json) real(kind=rp) :: pi ! Ensure only rank 0 reads the coordinates. - !if (pe_rank .ne. 0) return + if (pe_rank .ne. 0) return call json_get(json, "center", center) call json_get(json, "normal", normal) call json_get(json, "radius", radius) @@ -396,7 +396,7 @@ subroutine read_point_zone(this, json, dof) real(kind=rp) :: x, y, z ! Ensure only rank 0 reads the coordinates. - !if (pe_rank .ne. 0) return + if (pe_rank .ne. 0) return call json_get(json, "name", point_zone_name) zone => neko_point_zone_registry%get_point_zone(point_zone_name) From be3bda3ca824c09c0e785747d010dfa9d37c7d79 Mon Sep 17 00:00:00 2001 From: Victor Baconnet Date: Fri, 13 Sep 2024 11:47:06 +0200 Subject: [PATCH 55/67] cleanup and add doc --- doc/pages/user-guide/case-file.md | 57 +++++++++++++++++++++++++------ src/fluid/flow_ic.f90 | 34 +++++++++++------- src/scalar/scalar_ic.f90 | 34 +++++++++++------- 3 files changed, 88 insertions(+), 37 deletions(-) diff --git a/doc/pages/user-guide/case-file.md b/doc/pages/user-guide/case-file.md index 5c75479e192..0e357324954 100644 --- a/doc/pages/user-guide/case-file.md +++ b/doc/pages/user-guide/case-file.md @@ -218,17 +218,17 @@ file documentation. 5. `field`, where the initial condition is retrieved from a field file. The following keywords can be used: -| Name | Description | Admissible values | Default value | -| ------------------- | ---------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------- | ----------------------------------------- | -| `file_name` | Name of the field file (e.g. `field0.f00034`) or the field file series to use (e.g. `field0.fld` or `field0.nek5000`). | Strings ending with `.fld`, `.nek5000` or `f*****` | - | -| `sample_index` | In the case of a field series, the index of the field file to read. By default, reads the last file in the series. | Integer values | `-1`, i.e. the last sample in the series. | -| `interpolate` | Whether to interpolate the velocity and pressure fields from the field file onto the current mesh. | `true` or `false` | `false` | -| `sample_mesh_index` | If interpolation is enabled, the index of the field file that contains the coordinates. | Integer values | `0` for a field series. | - - @attention Neko does not detect wether interpolation is needed or not. - Interpolation will always be performed if `"interpolate"` is set - to `true` even if the field file matches with the current simulation. - +| Name | Description | Admissible values | Default value | +| ------------------- | ---------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------- | ------------------------------------------------- | +| `file_name` | Name of the field file (e.g. `field0.f00034`) or the field file series to use (e.g. `field0.fld` or `field0.nek5000`). | Strings ending with `.fld`, `.nek5000` or `f*****` | - | +| `sample_index` | In the case of a field series, the index of the field file to read. By default, reads the last file in the series. | Integer values | `-1`, i.e. the last sample in the series. | +| `interpolate` | Whether to interpolate the velocity and pressure fields from the field file onto the current mesh. | `true` or `false` | `false` | +| `sample_mesh_index` | If interpolation is enabled, the index of the field file that contains the coordinates. | Integer values | `0` for a field series, `sample_index` otherwise. | + + @attention Interpolating a field from the same mesh but different + polynomial order is performed implicitly and does not require to enable + interpolation. + @note It is recommended to interpolate from `fld` files that were written in double precision. To check if your `fld` file was written in double precision, run @@ -241,6 +241,11 @@ file documentation. Neko write single precision `fld` files by default. To write your files in double precision, set `case.output_precision` to `"double"`. + + @attention Neko does not detect wether interpolation is needed or not. + Interpolation will always be performed if `"interpolate"` is set + to `true` even if the field file matches with the current simulation. + ### Blasius profile @@ -530,6 +535,36 @@ file documentation. `base_value` keyword, and then assigned a zone value inside a point zone. The point zone is specified by the `name` keyword, and should be defined in the `case.point_zones` object. See more about point zones @ref point-zones.md. +4. `field`, where the initial condition is retrieved from a field file. + The following keywords can be used: + +| Name | Description | Admissible values | Default value | +| ------------------- | ---------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------- | ------------------------------------------------- | +| `file_name` | Name of the field file (e.g. `field0.f00034`) or the field file series to use (e.g. `field0.fld` or `field0.nek5000`). | Strings ending with `.fld`, `.nek5000` or `f*****` | - | +| `sample_index` | In the case of a field series, the index of the field file to read. By default, reads the last file in the series. | Integer values | `-1`, i.e. the last sample in the series. | +| `interpolate` | Whether to interpolate the velocity and pressure fields from the field file onto the current mesh. | `true` or `false` | `false` | +| `sample_mesh_index` | If interpolation is enabled, the index of the field file that contains the coordinates. | Integer values | `0` for a field series, `sample_index` otherwise. | + + @attention Interpolating a field from the same mesh but different + polynomial order is performed implicitly and does not require to enable + interpolation. + + @note It is recommended to interpolate from `fld` files that were + written in double precision. + To check if your `fld` file was written in double precision, run + the command: + ~~~~~~~~~~~~~~~{.sh} + head -1 field0.f00000 + ~~~~~~~~~~~~~~~ + The output `#std 4 ...` indicates single precision, + whereas `#std 8 ...` indicates double precision. + Neko write single precision `fld` files by default. To write your + files in double precision, set `case.output_precision` to + `"double"`. + + @attention Neko does not detect wether interpolation is needed or not. + Interpolation will always be performed if `"interpolate"` is set + to `true` even if the field file matches with the current simulation. ### Source terms diff --git a/src/fluid/flow_ic.f90 b/src/fluid/flow_ic.f90 index 675f1aa0838..43854d5ef88 100644 --- a/src/fluid/flow_ic.f90 +++ b/src/fluid/flow_ic.f90 @@ -195,8 +195,7 @@ subroutine set_flow_ic_int(u, v, w, p, coef, gs, type, params) call json_get_or_default(params, & 'case.fluid.initial_condition.tolerance', tol, 0.000001_rp) - ! If no mesh file is provided, try to get the index of the - ! file that contains the mesh. + ! Get the index of the file that contains the mesh. call json_get_or_default(params, & 'case.fluid.initial_condition.sample_mesh_index', & sample_mesh_idx, default_sample_mesh_idx) @@ -378,16 +377,23 @@ subroutine set_flow_ic_point_zone(u, v, w, base_value, zone_name, zone_value) end subroutine set_flow_ic_point_zone - !> Set the initial condition of the flow based on a point zone. - !! @details The initial condition is set to the base value and then the - !! zone is filled with the zone value. + !> Set the initial condition of the flow based on a field. + !! @detail The fields are read from an `fld` file. If enabled, interpolation + !! is also possible. In that case, the mesh coordinates can be read from + !! another field in the `fld` field series. !! @param u The x-component of the velocity field. !! @param v The y-component of the velocity field. !! @param w The z-component of the velocity field. !! @param p The pressure field. !! @param file_name The name of the "fld" file series. !! @param sample_idx index of the field file .f000* to read, default is - !! -1.. + !! -1. + !! @param interpolate Flag to indicate wether or not to interpolate the + !! values onto the current mesh. + !! @param tolerance If interpolation is enabled, tolerance for finding the + !! points in the mesh. + !! @param sample_mesh_idx If interpolation is enabled, index of the field + !! file where the mesh coordinates are located. subroutine set_flow_ic_fld(u, v, w, p, file_name, sample_idx, & interpolate, tolerance, sample_mesh_idx) type(field_t), intent(inout) :: u @@ -454,7 +460,7 @@ subroutine set_flow_ic_fld(u, v, w, p, file_name, sample_idx, & ! Read the actual fld file call f%read(fld_data) f = file_t(trim(file_name)) - end if ! interpolate + end if call f%set_counter(sample_idx) call f%read(fld_data) @@ -462,10 +468,10 @@ subroutine set_flow_ic_fld(u, v, w, p, file_name, sample_idx, & end if ! sample_idx .eq. -1 ! - ! Check if the data in the fld file matches the current case. + ! Check that the data in the fld file matches the current case. ! Note that this is a safeguard and there are corner cases where ! two different meshes have the same dimension and same # of elements - ! but this should be enough to cover the most obvious cases. + ! but this should be enough to cover obvious cases. ! if ( fld_data%glb_nelv .ne. u%msh%glb_nelv .or. & fld_data%gdim .ne. u%msh%gdim .and. & @@ -487,13 +493,14 @@ subroutine set_flow_ic_fld(u, v, w, p, file_name, sample_idx, & call neko_warning("The coordinates read from the field file are & &in single precision.") call neko_log%message("It is recommended to use a mesh in double & - &precision for better interpolation results.") - call neko_log%message("Reduce the tolerance if the interpolation & - &does not work.") +&precision for better interpolation results.") + call neko_log%message("If the interpolation does not work, you& +&can try to increase the tolerance.") end if class default end select + ! Generates an interpolator object and performs the point search global_interp = fld_data%generate_interpolator(u%dof, u%msh, & tolerance) @@ -511,6 +518,7 @@ subroutine set_flow_ic_fld(u, v, w, p, file_name, sample_idx, & call prev_Xh%init(GLL, fld_data%lx, fld_data%ly, fld_data%lz) call space_interp%init(u%Xh, prev_Xh) + ! Do the space-to-space interpolation call space_interp%map_host(u%x, fld_data%u%x, fld_data%nelv, u%Xh) call space_interp%map_host(v%x, fld_data%v%x, fld_data%nelv, u%Xh) call space_interp%map_host(w%x, fld_data%w%x, fld_data%nelv, u%Xh) @@ -520,7 +528,7 @@ subroutine set_flow_ic_fld(u, v, w, p, file_name, sample_idx, & end if - ! NOTE: we do not copy (u,v,w) on the GPU since `set_flow_ic_common` does + ! NOTE: we do not copy (u,v,w) to the GPU since `set_flow_ic_common` does ! the copy for us if (NEKO_BCKND_DEVICE .eq. 1) call device_memcpy(p%x, p%x_d, p%dof%size(), & HOST_TO_DEVICE, sync = .false.) diff --git a/src/scalar/scalar_ic.f90 b/src/scalar/scalar_ic.f90 index fda7c90c589..48b663fe726 100644 --- a/src/scalar/scalar_ic.f90 +++ b/src/scalar/scalar_ic.f90 @@ -181,8 +181,7 @@ subroutine set_scalar_ic_int(s, coef, gs, type, params) 'case.scalar.initial_condition.sample_mesh_index', & sample_mesh_idx, 0) - ! If no mesh file is provided, try to get the index of the - ! file that contains the mesh. + ! Get the index of the file that contains the mesh. call json_get_or_default(params, & 'case.scalar.initial_condition.sample_mesh_index', & sample_mesh_idx, 0) @@ -297,13 +296,20 @@ subroutine set_scalar_ic_point_zone(s, base_value, zone_name, zone_value) end subroutine set_scalar_ic_point_zone - !> Set the initial condition of the flow based on a point zone. - !! @details The initial condition is set to the base value and then the - !! zone is filled with the zone value. + !> Set the initial condition of the scalar based on a field. + !! @detail The field is read from an `fld` file. If enabled, interpolation + !! is also possible. In that case, the mesh coordinates can be read from + !! another file in the `fld` field series. !! @param s The scalar field. !! @param file_name The name of the "fld" file series. !! @param sample_idx index of the field file .f000* to read, default is - !! -1.. + !! -1. + !! @param interpolate Flag to indicate wether or not to interpolate the + !! values onto the current mesh. + !! @param tolerance If interpolation is enabled, tolerance for finding the + !! points in the mesh. + !! @param sample_mesh_idx If interpolation is enabled, index of the field + !! file where the mesh coordinates are located. subroutine set_scalar_ic_fld(s, file_name, sample_idx, & interpolate, tolerance, sample_mesh_idx) type(field_t), intent(inout) :: s @@ -367,7 +373,7 @@ subroutine set_scalar_ic_fld(s, file_name, sample_idx, & ! Read the actual fld file call f%read(fld_data) f = file_t(trim(file_name)) - end if ! interpolate + end if call f%set_counter(sample_idx) call f%read(fld_data) @@ -375,10 +381,10 @@ subroutine set_scalar_ic_fld(s, file_name, sample_idx, & end if ! sample_idx .eq. -1 ! - ! Check if the data in the fld file matches the current case. + ! Check that the data in the fld file matches the current case. ! Note that this is a safeguard and there are corner cases where ! two different meshes have the same dimension and same # of elements - ! but this should be enough to cover the most obvious cases. + ! but this should be enough to cover obvious cases. ! if ( fld_data%glb_nelv .ne. s%msh%glb_nelv .or. & fld_data%gdim .ne. s%msh%gdim .and. & @@ -397,15 +403,16 @@ subroutine set_scalar_ic_fld(s, file_name, sample_idx, & type is (fld_file_t) if (.not. ft%dp_precision) then call neko_warning("The coordinates read from the field file are & - &in single precision.") +&in single precision.") call neko_log%message("It is recommended to use a mesh in double & - &precision for better interpolation results.") - call neko_log%message("Reduce the tolerance if the interpolation & - &does not work.") +&precision for better interpolation results.") + call neko_log%message("If the interpolation does not work, you& +&can try to increase the tolerance.") end if class default end select + ! Generates an interpolator object and performs the point search global_interp = fld_data%generate_interpolator(s%dof, s%msh, tolerance) ! Evaluate scalar @@ -418,6 +425,7 @@ subroutine set_scalar_ic_fld(s, file_name, sample_idx, & call prev_Xh%init(GLL, fld_data%lx, fld_data%ly, fld_data%lz) call space_interp%init(s%Xh, prev_Xh) + ! Do the space-to-space interpolation call space_interp%map_host(s%x, fld_data%t%x, fld_data%nelv, s%Xh) call space_interp%free From a0b99ec95b8e343d5ce1618f4c817a94a5d95d4c Mon Sep 17 00:00:00 2001 From: Victor Baconnet Date: Thu, 19 Sep 2024 08:30:06 +0200 Subject: [PATCH 56/67] force user to give full file name and edit doc --- doc/pages/user-guide/case-file.md | 48 ++------- src/common/utils.f90 | 49 ++++++++- src/fluid/flow_ic.f90 | 153 +++++++++++----------------- src/scalar/scalar_ic.f90 | 159 +++++++++++------------------- 4 files changed, 172 insertions(+), 237 deletions(-) diff --git a/doc/pages/user-guide/case-file.md b/doc/pages/user-guide/case-file.md index 72a724f4cd1..99396faa2d1 100644 --- a/doc/pages/user-guide/case-file.md +++ b/doc/pages/user-guide/case-file.md @@ -218,12 +218,11 @@ file documentation. 5. `field`, where the initial condition is retrieved from a field file. The following keywords can be used: -| Name | Description | Admissible values | Default value | -| ------------------- | ---------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------- | ------------------------------------------------- | -| `file_name` | Name of the field file (e.g. `field0.f00034`) or the field file series to use (e.g. `field0.fld` or `field0.nek5000`). | Strings ending with `.fld`, `.nek5000` or `f*****` | - | -| `sample_index` | In the case of a field series, the index of the field file to read. By default, reads the last file in the series. | Integer values | `-1`, i.e. the last sample in the series. | -| `interpolate` | Whether to interpolate the velocity and pressure fields from the field file onto the current mesh. | `true` or `false` | `false` | -| `sample_mesh_index` | If interpolation is enabled, the index of the field file that contains the coordinates. | Integer values | `0` for a field series, `sample_index` otherwise. | +| Name | Description | Admissible values | Default value | +| ---------------- | -------------------------------------------------------------------------------------------------- | ---------------------------- | ------------- | +| `file_name` | Name of the field file to use (e.g. `myfield0.f00034`). | Strings ending with `f*****` | - | +| `interpolate` | Whether to interpolate the velocity and pressure fields from the field file onto the current mesh. | `true` or `false` | `false` | +| `mesh_file_name` | If interpolation is enabled, the name of the field file that contains the mesh coordinates. | Strings ending with `f*****` | `file_name` | @attention Interpolating a field from the same mesh but different polynomial order is performed implicitly and does not require to enable @@ -244,9 +243,7 @@ file documentation. @attention Neko does not detect wether interpolation is needed or not. Interpolation will always be performed if `"interpolate"` is set - to `true` even if the field file matches with the current simulation. - - + to `true` even if the field file matches with the current simulation. ### Blasius profile The `blasius` object is used to specify the Blasius profile that can be used for the @@ -538,37 +535,10 @@ file documentation. `base_value` keyword, and then assigned a zone value inside a point zone. The point zone is specified by the `name` keyword, and should be defined in the `case.point_zones` object. See more about point zones @ref point-zones.md. -4. `field`, where the initial condition is retrieved from a field file. - The following keywords can be used: - -| Name | Description | Admissible values | Default value | -| ------------------- | ---------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------- | ------------------------------------------------- | -| `file_name` | Name of the field file (e.g. `field0.f00034`) or the field file series to use (e.g. `field0.fld` or `field0.nek5000`). | Strings ending with `.fld`, `.nek5000` or `f*****` | - | -| `sample_index` | In the case of a field series, the index of the field file to read. By default, reads the last file in the series. | Integer values | `-1`, i.e. the last sample in the series. | -| `interpolate` | Whether to interpolate the velocity and pressure fields from the field file onto the current mesh. | `true` or `false` | `false` | -| `sample_mesh_index` | If interpolation is enabled, the index of the field file that contains the coordinates. | Integer values | `0` for a field series, `sample_index` otherwise. | - - @attention Interpolating a field from the same mesh but different - polynomial order is performed implicitly and does not require to enable - interpolation. - - @note It is recommended to interpolate from `fld` files that were - written in double precision. - To check if your `fld` file was written in double precision, run - the command: - ~~~~~~~~~~~~~~~{.sh} - head -1 field0.f00000 - ~~~~~~~~~~~~~~~ - The output `#std 4 ...` indicates single precision, - whereas `#std 8 ...` indicates double precision. - Neko write single precision `fld` files by default. To write your - files in double precision, set `case.output_precision` to - `"double"`. +4. `field`, where the initial condition is retrieved from a field file. Works + in the same way as for the fluid. See the + [fluid section](@ref case-file_fluid-ic) for detailed explanations. - @attention Neko does not detect wether interpolation is needed or not. - Interpolation will always be performed if `"interpolate"` is set - to `true` even if the field file matches with the current simulation. - ### Source terms The configuration of source terms is the same as for the fluid. A demonstration diff --git a/src/common/utils.f90 b/src/common/utils.f90 index 2524eb2e059..a14577671c2 100644 --- a/src/common/utils.f90 +++ b/src/common/utils.f90 @@ -45,7 +45,7 @@ module utils public :: neko_error, neko_warning, nonlinear_index, filename_chsuffix, & filename_suffix, filename_suffix_pos, filename_tslash_pos, & linear_index, split_string, NEKO_FNAME_LEN, index_is_on_facet, & - concat_string_array + concat_string_array, extract_fld_file_index contains @@ -83,6 +83,53 @@ subroutine filename_chsuffix(fname, new_fname, new_suffix) end subroutine filename_chsuffix + !> Extracts the index of a field file. For example, "myfield.f00045" + !! will return `45`. If the suffix of the file name is invalid, returns + !! a default index value. + !! @param fld_filename Name of the fld file, e.g. `myfield0.f00035`. + !! @param default_index The index to return in case the suffix of + !! `fld_filename` is invalid. + function extract_fld_file_index(fld_filename, default_index) result(index) + character(len=*), intent(inout) :: fld_filename + integer, intent(in) :: default_index + + character(len=80) :: suffix + integer :: index, fpos, i + logical :: valid + + call filename_suffix(fld_filename, suffix) + + valid = .true. + + ! This value will be modified when reading the file name extension + ! e.g. "field0.f00035" will set sample_idx = 35 + index = default_index + + ! + ! Try to extract the index of the field file from the suffix "fxxxxx" + ! + fpos = scan(trim(suffix), 'f') + if (fpos .eq. 1) then + + ! Make sure that the suffix only contains integers from 0 to 9 + do i = 2, len(trim(suffix)) + if (.not. (iachar(suffix(i:i)) >= iachar('0') & + .and. iachar(suffix(i:i)) <= iachar('9'))) then + valid = .false. + end if + end do + + ! Must be exactly "fxxxxx", i.e. an 'f' with 5 integers after + if (len(trim(suffix)) .ne. 6) valid = .false. + + else + valid = .false. + end if + + if (valid) read (suffix(2:), "(I5.5)") index + + end function extract_fld_file_index + !> Split a string based on delimiter (tokenizer) !! OBS: very hacky, this should really be improved, it is rather embarrasing code. function split_string(string, delimiter) result(split_str) diff --git a/src/fluid/flow_ic.f90 b/src/fluid/flow_ic.f90 index 43854d5ef88..6ec0eddb4f3 100644 --- a/src/fluid/flow_ic.f90 +++ b/src/fluid/flow_ic.f90 @@ -41,7 +41,7 @@ module flow_ic use device, only: device_memcpy, HOST_TO_DEVICE use field, only : field_t use utils, only : neko_error, filename_suffix, filename_chsuffix, & - neko_warning, NEKO_FNAME_LEN + neko_warning, NEKO_FNAME_LEN, extract_fld_file_index use coefs, only : coef_t use math, only : col2, cfill, cfill_mask use device_math, only : device_col2, device_cfill, device_cfill_mask @@ -81,9 +81,8 @@ subroutine set_flow_ic_int(u, v, w, p, coef, gs, type, params) real(kind=rp), allocatable :: uinf(:) real(kind=rp), allocatable :: zone_value(:) character(len=:), allocatable :: read_str - character(len=80) :: suffix - character(len=NEKO_FNAME_LEN) :: fname - integer :: sample_idx, fpos, sample_mesh_idx, default_sample_mesh_idx + character(len=NEKO_FNAME_LEN) :: fname, mesh_fname + integer :: sample_idx, sample_mesh_idx logical :: interpolate character(len=LOG_SIZE) :: log_buf @@ -144,69 +143,62 @@ subroutine set_flow_ic_int(u, v, w, p, coef, gs, type, params) call json_get(params, 'case.fluid.initial_condition.file_name', & read_str) + + ! Read field file fname = trim(read_str) - call filename_suffix(fname, suffix) call neko_log%message("File name: " // trim(fname)) - ! - ! Get the index of the file to sample - ! - call json_get_or_default(params, & - 'case.fluid.initial_condition.sample_index', sample_idx, -1) - - ! In case we interpolate, the default index of the file in which to - ! look for the coordinates - default_sample_mesh_idx = 0 - - if (sample_idx .ne. -1) then - write (log_buf, '(A,I5)') "Sample index: ", sample_idx - call neko_log%message(log_buf) - end if - - ! If it's not fld assume it's either .nek5000 or .f00* - if (trim(suffix) .ne. "fld") then + ! Get the sample index from the file name, e.g. "field0.f00015" will + ! return 15 + sample_idx = extract_fld_file_index(fname, -1) - ! Check if the suffix is of type "f000*", and if so extract - ! the index e.g. "f00035" --> 35 - ! NOTE: overwrites whatever is in sampled_index - fpos = scan(suffix, 'f') - if (fpos .eq. 1) then - if (sample_idx .ne. -1) & - call neko_warning("Overwriting sample index") - read (suffix(2:), "(I5.5)") sample_idx + if (sample_idx .eq. -1) & + call neko_error("Invalid file name for the initial condition. The& +& file format must be e.g. 'mean0.f00001'") - ! In case we interpolate we assume the mesh is also in this file - default_sample_mesh_idx = sample_idx - end if - - call filename_chsuffix(fname, fname, 'fld') - end if + ! Change from "field0.f000*" to "field0.fld" for the fld reader + call filename_chsuffix(fname, fname, 'fld') - ! ! Check if we want to interpolate from the field file, default is no - ! call json_get_or_default(params, & 'case.fluid.initial_condition.interpolate', interpolate, & .false.) - - ! ! Get the tolerance for potential interpolation, defaults to 1e-6 - ! call json_get_or_default(params, & 'case.fluid.initial_condition.tolerance', tol, 0.000001_rp) - ! Get the index of the file that contains the mesh. - call json_get_or_default(params, & - 'case.fluid.initial_condition.sample_mesh_index', & - sample_mesh_idx, default_sample_mesh_idx) - if (interpolate) then - call neko_log%message("Interpolation : yes") - write (log_buf, '(A,E15.7)') "Tolerance : ", tol - call neko_log%message(log_buf) - write (log_buf, '(A,I5.5)') "Coordinates at sample index : ", & - sample_mesh_idx + + call neko_log%message("Interpolation : yes") + write (log_buf, '(A,E15.7)') "Tolerance : ", tol call neko_log%message(log_buf) + + ! Get the index of the file that contains the mesh. + call json_get_or_default(params, & + 'case.fluid.initial_condition.mesh_file_name', read_str, & + "none") + + mesh_fname = trim(read_str) + + ! If no mesh file is specified, use the default file name + if (mesh_fname .eq. "none") then + mesh_fname = trim(fname) + sample_mesh_idx = sample_idx + else + ! Get the sample index from the mesh file name + sample_mesh_idx = extract_fld_file_index(mesh_fname, -1) + + if (sample_mesh_idx .eq. -1) & + call neko_error("Invalid file name for the initial condition. The& +& file format must be e.g. 'mean0.f00001'") + + write (log_buf, '(A,A)') "Coordinates file : ", & + trim(mesh_fname) + call neko_log%message(log_buf) + end if + + else ! if interpolate + call neko_log%message("Interpolation: no") end if call set_flow_ic_fld(u, v, w, p, fname, sample_idx, interpolate, & @@ -409,6 +401,7 @@ subroutine set_flow_ic_fld(u, v, w, p, file_name, sample_idx, & integer :: last_index type(fld_file_data_t) :: fld_data type(file_t) :: f + logical :: mesh_mismatch ! ---- For the mesh to mesh interpolation type(global_interpolation_t) :: global_interp @@ -422,50 +415,17 @@ subroutine set_flow_ic_fld(u, v, w, p, file_name, sample_idx, & call fld_data%init f = file_t(trim(file_name)) - ! If no sample is specified, we read as a classic fld series - ! with the mesh located at index 0 - if (sample_idx .eq. -1) then - - ! Read one time to get all information about the fld series - ! and read the first file in the series. - call f%read(fld_data) - - last_index = fld_data%meta_nsamples + fld_data%meta_start_counter - 1 - - if (interpolate) then - ! Read the coordinates if they are neither at index 0 or at the - ! last index - if (sample_mesh_idx .ne. 0 .and. & - sample_mesh_idx .ne. last_index) then - call f%set_counter(sample_mesh_idx) - call f%read(fld_data) - end if - end if ! interpolate - - ! If there is more than one file, read the last one in the series. - if (fld_data%meta_nsamples .gt. 1) then - call f%set_counter(last_index) - call f%read(fld_data) - end if - - else ! In this case we have a specific sample to read in the fld series - - if (interpolate) then - ! Read the mesh coordinates if they are not in our fld file - if (sample_mesh_idx .ne. sample_idx) then - call f%set_counter(sample_mesh_idx) - call f%read(fld_data) - end if - - ! Read the actual fld file + if (interpolate) then + ! Read the mesh coordinates if they are not in our fld file + if (sample_mesh_idx .ne. sample_idx) then + call f%set_counter(sample_mesh_idx) call f%read(fld_data) - f = file_t(trim(file_name)) end if + end if - call f%set_counter(sample_idx) - call f%read(fld_data) - - end if ! sample_idx .eq. -1 + ! Read the field file containing (u,v,w,p) + call f%set_counter(sample_idx) + call f%read(fld_data) ! ! Check that the data in the fld file matches the current case. @@ -473,12 +433,13 @@ subroutine set_flow_ic_fld(u, v, w, p, file_name, sample_idx, & ! two different meshes have the same dimension and same # of elements ! but this should be enough to cover obvious cases. ! - if ( fld_data%glb_nelv .ne. u%msh%glb_nelv .or. & - fld_data%gdim .ne. u%msh%gdim .and. & - .not. interpolate) then + mesh_mismatch = (fld_data%glb_nelv .ne. u%msh%glb_nelv .or. & + fld_data%gdim .ne. u%msh%gdim) + + if (mesh_mismatch .and. .not. interpolate) then call neko_error("The fld file must match the current mesh! & &Use 'interpolate': 'true' to enable interpolation.") - else if (interpolate) then + else if (.not. mesh_mismatch .and. interpolate) then call neko_log%warning("You have activated interpolation but you might & &still be using the same mesh.") end if diff --git a/src/scalar/scalar_ic.f90 b/src/scalar/scalar_ic.f90 index 48b663fe726..dca36c3607e 100644 --- a/src/scalar/scalar_ic.f90 +++ b/src/scalar/scalar_ic.f90 @@ -39,7 +39,7 @@ module scalar_ic use device, only : device_memcpy, HOST_TO_DEVICE use field, only : field_t use utils, only : neko_error, filename_chsuffix, filename_suffix, & - neko_warning, NEKO_FNAME_LEN + neko_warning, NEKO_FNAME_LEN, extract_fld_file_index use coefs, only : coef_t use math, only : col2, cfill, cfill_mask use user_intf, only : useric_scalar @@ -88,11 +88,10 @@ subroutine set_scalar_ic_int(s, coef, gs, type, params) ! Variables for retrieving JSON parameters real(kind=rp) :: ic_value character(len=:), allocatable :: read_str - character(len=80) :: suffix - character(len=NEKO_FNAME_LEN) :: fname + character(len=NEKO_FNAME_LEN) :: fname, mesh_fname real(kind=rp) :: zone_value, tol logical :: interpolate - integer :: sample_idx, fpos, sample_mesh_idx, default_sample_mesh_idx + integer :: sample_idx, sample_mesh_idx character(len=LOG_SIZE) :: log_buf if (trim(type) .eq. 'uniform') then @@ -124,75 +123,63 @@ subroutine set_scalar_ic_int(s, coef, gs, type, params) call json_get(params, 'case.scalar.initial_condition.file_name', & read_str) + + ! Read field file fname = trim(read_str) - call filename_suffix(fname, suffix) call neko_log%message("File name: " // trim(fname)) - ! - ! Get the index of the file to sample - ! - call json_get_or_default(params, & - 'case.scalar.initial_condition.sample_index', sample_idx, -1) - - ! In case we interpolate, the default index of the file in which to - ! look for the coordinates - default_sample_mesh_idx = 0 + ! Get the sample index from the file name, e.g. "field0.f00015" will + ! return 15 + sample_idx = extract_fld_file_index(fname, -1) - if (sample_idx .ne. -1) then - write (log_buf, '(A,I5)') "Sample index: ", sample_idx - call neko_log%message(log_buf) + if (sample_idx .eq. -1) then + call neko_error("Invalid file name for the initial condition. The& +& file format must be e.g. 'mean0.f00001'") end if - ! If it's not fld assume it's either .nek5000 or .f00* - if (trim(suffix) .ne. "fld") then - - ! Check if the suffix is of type "f000*", and if so extract - ! the index e.g. "f00035" --> 35 - ! NOTE: overwrites whatever is in sampled_index - fpos = scan(suffix, 'f') - if (fpos .eq. 1) then - if (sample_idx .ne. -1) & - call neko_warning("Overwriting sample index.") - read (suffix(2:), "(I5.5)") sample_idx - - ! In case we interpolate we assume the mesh is also in this file - default_sample_mesh_idx = sample_idx - end if - - call filename_chsuffix(fname, fname, 'fld') - - end if + call filename_chsuffix(fname, fname, 'fld') - ! ! Check if we want to interpolate from the field file, default is no - ! call json_get_or_default(params, & 'case.scalar.initial_condition.interpolate', interpolate, & .false.) - - ! ! Get the tolerance for potential interpolation, defaults to 1e-6 - ! call json_get_or_default(params, & 'case.scalar.initial_condition.tolerance', tol, 0.000001_rp) - ! Get the index of the file that contains the mesh - call json_get_or_default(params, & - 'case.scalar.initial_condition.sample_mesh_index', & - sample_mesh_idx, 0) - - ! Get the index of the file that contains the mesh. - call json_get_or_default(params, & - 'case.scalar.initial_condition.sample_mesh_index', & - sample_mesh_idx, 0) - if (interpolate) then + call neko_log%message("Interpolation : yes") write (log_buf, '(A,E15.7)') "Tolerance : ", tol call neko_log%message(log_buf) - write (log_buf, '(A,I5.5)') "Coordinates at sample index : ", & - sample_mesh_idx - call neko_log%message(log_buf) + + ! Get the index of the file that contains the mesh. + call json_get_or_default(params, & + 'case.scalar.initial_condition.mesh_file_name', read_str, & + "none") + + mesh_fname = trim(read_str) + + ! If no mesh file is specified, use the default file name + if (mesh_fname .eq. "none") then + mesh_fname = trim(fname) + sample_mesh_idx = sample_idx + else + ! Get the sample index from the mesh file name + sample_mesh_idx = extract_fld_file_index(mesh_fname, -1) + + if (sample_mesh_idx .eq. -1) then + call neko_error("Invalid file name for the initial condition. The& +& file format must be e.g. 'mean0.f00001'") + end if + + write (log_buf, '(A,A)') "Coordinates file : ", & + trim(mesh_fname) + call neko_log%message(log_buf) + end if + + else + call neko_log%message("Interpolation: no") end if call set_scalar_ic_fld(s, fname, sample_idx, interpolate, & @@ -322,6 +309,7 @@ subroutine set_scalar_ic_fld(s, file_name, sample_idx, & integer :: last_index type(fld_file_data_t) :: fld_data type(file_t) :: f + logical :: mesh_mismatch ! ---- For the mesh to mesh interpolation type(global_interpolation_t) :: global_interp @@ -335,50 +323,17 @@ subroutine set_scalar_ic_fld(s, file_name, sample_idx, & call fld_data%init f = file_t(trim(file_name)) - ! If no sample is specified, we read as a classic fld series - ! with the mesh located at index 0 - if (sample_idx .eq. -1) then - - ! Read one time to get all information about the fld series - ! and read the first file in the series. - call f%read(fld_data) - - last_index = fld_data%meta_nsamples + fld_data%meta_start_counter - 1 - - if (interpolate) then - ! Read the coordinates if they are neither at index 0 or at the - ! last index - if (sample_mesh_idx .ne. 0 .and. & - sample_mesh_idx .ne. last_index) then - call f%set_counter(sample_mesh_idx) - call f%read(fld_data) - end if - end if ! interpolate - - ! If there is more than one file, read the last one in the series. - if (fld_data%meta_nsamples .gt. 1) then - call f%set_counter(last_index) - call f%read(fld_data) - end if - - else ! In this case we have a specific sample to read in the fld series - - if (interpolate) then - ! Read the mesh coordinates if they are not in our fld file - if (sample_mesh_idx .ne. sample_idx) then - call f%set_counter(sample_mesh_idx) - call f%read(fld_data) - end if - - ! Read the actual fld file + if (interpolate) then + ! Read the mesh coordinates if they are not in our fld file + if (sample_mesh_idx .ne. sample_idx) then + call f%set_counter(sample_mesh_idx) call f%read(fld_data) - f = file_t(trim(file_name)) end if + end if - call f%set_counter(sample_idx) - call f%read(fld_data) - - end if ! sample_idx .eq. -1 + ! Read the field file containing (u,v,w,p) + call f%set_counter(sample_idx) + call f%read(fld_data) ! ! Check that the data in the fld file matches the current case. @@ -386,16 +341,18 @@ subroutine set_scalar_ic_fld(s, file_name, sample_idx, & ! two different meshes have the same dimension and same # of elements ! but this should be enough to cover obvious cases. ! - if ( fld_data%glb_nelv .ne. s%msh%glb_nelv .or. & - fld_data%gdim .ne. s%msh%gdim .and. & - .not. interpolate) then + mesh_mismatch = (fld_data%glb_nelv .ne. s%msh%glb_nelv .or. & + fld_data%gdim .ne. s%msh%gdim) + + if (mesh_mismatch .and. .not. interpolate) then call neko_error("The fld file must match the current mesh! & - &Use 'interpolate': 'true' to enable interpolation.") - else if (interpolate) then +&Use 'interpolate': 'true' to enable interpolation.") + else if (.not. mesh_mismatch .and. interpolate) then call neko_log%warning("You have activated interpolation but you might & - &still be using the same mesh.") +&still be using the same mesh.") end if + ! Mesh interpolation if specified if (interpolate) then ! Issue a warning if the mesh is in single precision From af33a3c22e55ba29fe9121995f898e89625e5a4e Mon Sep 17 00:00:00 2001 From: Victor Baconnet Date: Thu, 19 Sep 2024 08:35:27 +0200 Subject: [PATCH 57/67] Add note on passing down dof%x(:,1,1,1) to init_xyz for pointers --- src/common/global_interpolation.F90 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/common/global_interpolation.F90 b/src/common/global_interpolation.F90 index eb393cdf72d..e7e450f1b0e 100644 --- a/src/common/global_interpolation.F90 +++ b/src/common/global_interpolation.F90 @@ -128,6 +128,9 @@ subroutine global_interpolation_init_dof(this, dof, tol) type(dofmap_t), target :: dof real(kind=rp), optional :: tol + ! NOTE: Passing dof%x(:,1,1,1), etc in init_xyz passes down the entire + ! dof%x array and not a slice. It is done this way for + ! this%x%ptr to point to dof%x (see global_interpolation_init_xyz). call this%init_xyz(dof%x(:,1,1,1), dof%y(:,1,1,1), dof%z(:,1,1,1), & dof%msh%gdim, dof%msh%nelv, dof%Xh, tol = tol) From dc03e39b5d56e1d2f8b6618c9ebf38cbd8ef4628 Mon Sep 17 00:00:00 2001 From: Victor Baconnet Date: Thu, 19 Sep 2024 08:40:50 +0200 Subject: [PATCH 58/67] Rewrite extract_fld_file a bit --- src/common/utils.f90 | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/common/utils.f90 b/src/common/utils.f90 index a14577671c2..65b4dbf46a0 100644 --- a/src/common/utils.f90 +++ b/src/common/utils.f90 @@ -110,7 +110,6 @@ function extract_fld_file_index(fld_filename, default_index) result(index) ! fpos = scan(trim(suffix), 'f') if (fpos .eq. 1) then - ! Make sure that the suffix only contains integers from 0 to 9 do i = 2, len(trim(suffix)) if (.not. (iachar(suffix(i:i)) >= iachar('0') & @@ -118,14 +117,13 @@ function extract_fld_file_index(fld_filename, default_index) result(index) valid = .false. end if end do - - ! Must be exactly "fxxxxx", i.e. an 'f' with 5 integers after - if (len(trim(suffix)) .ne. 6) valid = .false. - else valid = .false. end if + ! Must be exactly 6 characters long, i.e. an 'f' with 5 integers after + if (len(trim(suffix)) .ne. 6) valid = .false. + if (valid) read (suffix(2:), "(I5.5)") index end function extract_fld_file_index From c67128ee09291a7423ba401ca1e6bf9bfc8ca95c Mon Sep 17 00:00:00 2001 From: Victor Baconnet Date: Thu, 19 Sep 2024 09:31:57 +0200 Subject: [PATCH 59/67] Update src/common/global_interpolation.F90 Co-authored-by: Tim Felle Olsen --- src/common/global_interpolation.F90 | 1 - 1 file changed, 1 deletion(-) diff --git a/src/common/global_interpolation.F90 b/src/common/global_interpolation.F90 index e7e450f1b0e..60d3710a102 100644 --- a/src/common/global_interpolation.F90 +++ b/src/common/global_interpolation.F90 @@ -566,7 +566,6 @@ subroutine global_interpolation_evaluate(this, interp_values, field) real(kind=rp), intent(inout) :: interp_values(this%n_points) real(kind=rp), intent(inout) :: field(this%nelv*this%Xh%lxyz) - integer :: ioioi #ifdef HAVE_GSLIB if (.not. this%all_points_local) then From 6ac121426eb51ed84a090fc143252dd93c360fa2 Mon Sep 17 00:00:00 2001 From: Victor Baconnet Date: Thu, 19 Sep 2024 09:45:22 +0200 Subject: [PATCH 60/67] Add doc for tolerance --- doc/pages/user-guide/case-file.md | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/pages/user-guide/case-file.md b/doc/pages/user-guide/case-file.md index 99396faa2d1..98ba90d1c75 100644 --- a/doc/pages/user-guide/case-file.md +++ b/doc/pages/user-guide/case-file.md @@ -222,6 +222,7 @@ file documentation. | ---------------- | -------------------------------------------------------------------------------------------------- | ---------------------------- | ------------- | | `file_name` | Name of the field file to use (e.g. `myfield0.f00034`). | Strings ending with `f*****` | - | | `interpolate` | Whether to interpolate the velocity and pressure fields from the field file onto the current mesh. | `true` or `false` | `false` | +| `tolerance` | Tolerance for the point search. | Positive real. | `1e-6` | | `mesh_file_name` | If interpolation is enabled, the name of the field file that contains the mesh coordinates. | Strings ending with `f*****` | `file_name` | @attention Interpolating a field from the same mesh but different From 9cad62869232fef1e5f15e368d8a0fb1c394eba4 Mon Sep 17 00:00:00 2001 From: Victor Baconnet Date: Wed, 25 Sep 2024 14:57:02 +0200 Subject: [PATCH 61/67] Move print inside set_flow_ic_* --- src/common/utils.f90 | 2 +- src/fluid/flow_ic.f90 | 152 +++++++++++++++++++-------------------- src/scalar/scalar_ic.f90 | 133 +++++++++++++++++----------------- 3 files changed, 141 insertions(+), 146 deletions(-) diff --git a/src/common/utils.f90 b/src/common/utils.f90 index 65b4dbf46a0..4b89f9e900b 100644 --- a/src/common/utils.f90 +++ b/src/common/utils.f90 @@ -90,7 +90,7 @@ end subroutine filename_chsuffix !! @param default_index The index to return in case the suffix of !! `fld_filename` is invalid. function extract_fld_file_index(fld_filename, default_index) result(index) - character(len=*), intent(inout) :: fld_filename + character(len=*), intent(in) :: fld_filename integer, intent(in) :: default_index character(len=80) :: suffix diff --git a/src/fluid/flow_ic.f90 b/src/fluid/flow_ic.f90 index 6ec0eddb4f3..230050678df 100644 --- a/src/fluid/flow_ic.f90 +++ b/src/fluid/flow_ic.f90 @@ -82,9 +82,8 @@ subroutine set_flow_ic_int(u, v, w, p, coef, gs, type, params) real(kind=rp), allocatable :: zone_value(:) character(len=:), allocatable :: read_str character(len=NEKO_FNAME_LEN) :: fname, mesh_fname - integer :: sample_idx, sample_mesh_idx logical :: interpolate - character(len=LOG_SIZE) :: log_buf + ! ! Uniform (Uinf, Vinf, Winf) @@ -93,9 +92,6 @@ subroutine set_flow_ic_int(u, v, w, p, coef, gs, type, params) call json_get(params, 'case.fluid.initial_condition.value', uinf) call set_flow_ic_uniform(u, v, w, uinf) - write (log_buf, '(A,"[",2(F10.6,","),F10.6,"]")') "Value: ", uinf(1), & - uinf(2), uinf(3) - call neko_log%message(log_buf) ! ! Blasius boundary layer @@ -107,13 +103,6 @@ subroutine set_flow_ic_int(u, v, w, p, coef, gs, type, params) read_str) call json_get(params, 'case.fluid.blasius.freestream_velocity', uinf) - write (log_buf, '(A,F10.6)') "delta : ", delta - call neko_log%message(log_buf) - call neko_log%message("Approximation: " // trim(read_str)) - write (log_buf, '(A,"[",2(F10.6,","),F10.6,"]")') "Value: ", uinf(1), & - uinf(2), uinf(3) - call neko_log%message(log_buf) - call set_flow_ic_blasius(u, v, w, delta, uinf, read_str) ! @@ -127,13 +116,6 @@ subroutine set_flow_ic_int(u, v, w, p, coef, gs, type, params) call json_get(params, 'case.fluid.initial_condition.zone_value', & zone_value) - write (log_buf, '(A,F10.6)') "Base value: ", uinf - call neko_log%message(log_buf) - call neko_log%message("Zone name : " // trim(read_str)) - write (log_buf, '(A,"[",2(F10.6,","),F10.6,"]")') "Value: ", & - zone_value(1), zone_value(2), zone_value(3) - call neko_log%message(log_buf) - call set_flow_ic_point_zone(u, v, w, uinf, read_str, zone_value) ! @@ -143,66 +125,18 @@ subroutine set_flow_ic_int(u, v, w, p, coef, gs, type, params) call json_get(params, 'case.fluid.initial_condition.file_name', & read_str) - - ! Read field file fname = trim(read_str) - call neko_log%message("File name: " // trim(fname)) - - ! Get the sample index from the file name, e.g. "field0.f00015" will - ! return 15 - sample_idx = extract_fld_file_index(fname, -1) - - if (sample_idx .eq. -1) & - call neko_error("Invalid file name for the initial condition. The& -& file format must be e.g. 'mean0.f00001'") - - ! Change from "field0.f000*" to "field0.fld" for the fld reader - call filename_chsuffix(fname, fname, 'fld') - - ! Check if we want to interpolate from the field file, default is no call json_get_or_default(params, & 'case.fluid.initial_condition.interpolate', interpolate, & .false.) - ! Get the tolerance for potential interpolation, defaults to 1e-6 call json_get_or_default(params, & 'case.fluid.initial_condition.tolerance', tol, 0.000001_rp) + call json_get_or_default(params, & + 'case.fluid.initial_condition.mesh_file_name', read_str, & + "none") + mesh_fname = trim(read_str) - if (interpolate) then - - call neko_log%message("Interpolation : yes") - write (log_buf, '(A,E15.7)') "Tolerance : ", tol - call neko_log%message(log_buf) - - ! Get the index of the file that contains the mesh. - call json_get_or_default(params, & - 'case.fluid.initial_condition.mesh_file_name', read_str, & - "none") - - mesh_fname = trim(read_str) - - ! If no mesh file is specified, use the default file name - if (mesh_fname .eq. "none") then - mesh_fname = trim(fname) - sample_mesh_idx = sample_idx - else - ! Get the sample index from the mesh file name - sample_mesh_idx = extract_fld_file_index(mesh_fname, -1) - - if (sample_mesh_idx .eq. -1) & - call neko_error("Invalid file name for the initial condition. The& -& file format must be e.g. 'mean0.f00001'") - - write (log_buf, '(A,A)') "Coordinates file : ", & - trim(mesh_fname) - call neko_log%message(log_buf) - end if - - else ! if interpolate - call neko_log%message("Interpolation: no") - end if - - call set_flow_ic_fld(u, v, w, p, fname, sample_idx, interpolate, & - tolerance = tol, sample_mesh_idx = sample_mesh_idx) + call set_flow_ic_fld(u, v, w, p, fname, interpolate, tol, mesh_fname) else call neko_error('Invalid initial condition') @@ -273,6 +207,13 @@ subroutine set_flow_ic_uniform(u, v, w, uinf) type(field_t), intent(inout) :: w real(kind=rp), intent(in) :: uinf(3) integer :: n + character(len=LOG_SIZE) :: log_buf + + call neko_log%message("Type : uniform") + write (log_buf, '(A,"[",2(F10.6,","),F10.6,"]")') "Value: ", uinf(1), & + uinf(2), uinf(3) + call neko_log%message(log_buf) + u = uinf(1) v = uinf(2) w = uinf(3) @@ -296,6 +237,15 @@ subroutine set_flow_ic_blasius(u, v, w, delta, uinf, type) character(len=*), intent(in) :: type procedure(blasius_profile), pointer :: bla => null() integer :: i + character(len=LOG_SIZE) :: log_buf + + call neko_log%message("Type : blasius") + write (log_buf, '(A,F10.6)') "delta : ", delta + call neko_log%message(log_buf) + call neko_log%message("Approximation : " // trim(type)) + write (log_buf, '(A,"[",2(F10.6,","),F10.6,"]")') "Value : ", & + uinf(1), uinf(2), uinf(3) + call neko_log%message(log_buf) select case (trim(type)) case ('linear') @@ -353,11 +303,20 @@ subroutine set_flow_ic_point_zone(u, v, w, base_value, zone_name, zone_value) real(kind=rp), intent(in), dimension(3) :: base_value character(len=*), intent(in) :: zone_name real(kind=rp), intent(in) :: zone_value(:) + character(len=LOG_SIZE) :: log_buf ! Internal variables class(point_zone_t), pointer :: zone integer :: size + call neko_log%message("Type : point_zone") + write (log_buf, '(A,F10.6)') "Base value : ", base_value + call neko_log%message(log_buf) + call neko_log%message("Zone name : " // trim(zone_name)) + write (log_buf, '(A,"[",2(F10.6,","),F10.6,"]")') "Value : ", & + zone_value(1), zone_value(2), zone_value(3) + call neko_log%message(log_buf) + call set_flow_ic_uniform(u, v, w, base_value) size = u%dof%size() @@ -386,18 +345,19 @@ end subroutine set_flow_ic_point_zone !! points in the mesh. !! @param sample_mesh_idx If interpolation is enabled, index of the field !! file where the mesh coordinates are located. - subroutine set_flow_ic_fld(u, v, w, p, file_name, sample_idx, & - interpolate, tolerance, sample_mesh_idx) + subroutine set_flow_ic_fld(u, v, w, p, file_name, & + interpolate, tolerance, mesh_file_name) type(field_t), intent(inout) :: u type(field_t), intent(inout) :: v type(field_t), intent(inout) :: w type(field_t), intent(inout) :: p character(len=*), intent(in) :: file_name - integer, intent(in) :: sample_idx logical, intent(in) :: interpolate real(kind=rp), intent(in) :: tolerance - integer, intent(in) :: sample_mesh_idx + character(len=*), intent(inout) :: mesh_file_name + character(len=LOG_SIZE) :: log_buf + integer :: sample_idx, sample_mesh_idx integer :: last_index type(fld_file_data_t) :: fld_data type(file_t) :: f @@ -412,15 +372,55 @@ subroutine set_flow_ic_fld(u, v, w, p, file_name, sample_idx, & type(interpolator_t) :: space_interp ! ---- + call neko_log%message("Type : field") + call neko_log%message("File name : " // trim(file_name)) + write (log_buf, '(A,L1)') "Interpolation : ", interpolate + call neko_log%message(log_buf) + if (interpolate) then + end if + + ! Extract sample index from the file name + sample_idx = extract_fld_file_index(file_name, -1) + + if (sample_idx .eq. -1) & + call neko_error("Invalid file name for the initial condition. The& + & file format must be e.g. 'mean0.f00001'") + + ! Change from "field0.f000*" to "field0.fld" for the fld reader + call filename_chsuffix(file_name, file_name, 'fld') + call fld_data%init f = file_t(trim(file_name)) if (interpolate) then + + ! If no mesh file is specified, use the default file name + if (mesh_file_name .eq. "none") then + mesh_file_name = trim(file_name) + sample_mesh_idx = sample_idx + else + + ! Extract sample index from the mesh file name + sample_mesh_idx = extract_fld_file_index(mesh_file_name, -1) + + if (sample_mesh_idx .eq. -1) & + call neko_error("Invalid file name for the initial condition. & +&The file format must be e.g. 'mean0.f00001'") + + write (log_buf, '(A,ES13.6)') "Tolerance :", tolerance + call neko_log%message(log_buf) + write (log_buf, '(A,A)') "Mesh file : ", & + trim(mesh_file_name) + call neko_log%message(log_buf) + + end if ! if mesh_file_name .eq. none + ! Read the mesh coordinates if they are not in our fld file if (sample_mesh_idx .ne. sample_idx) then call f%set_counter(sample_mesh_idx) call f%read(fld_data) end if + end if ! Read the field file containing (u,v,w,p) diff --git a/src/scalar/scalar_ic.f90 b/src/scalar/scalar_ic.f90 index dca36c3607e..7b41aa7b3dd 100644 --- a/src/scalar/scalar_ic.f90 +++ b/src/scalar/scalar_ic.f90 @@ -91,15 +91,10 @@ subroutine set_scalar_ic_int(s, coef, gs, type, params) character(len=NEKO_FNAME_LEN) :: fname, mesh_fname real(kind=rp) :: zone_value, tol logical :: interpolate - integer :: sample_idx, sample_mesh_idx - character(len=LOG_SIZE) :: log_buf if (trim(type) .eq. 'uniform') then call json_get(params, 'case.scalar.initial_condition.value', ic_value) - write (log_buf, '(A,F10.6)') "Value: ", ic_value - call neko_log%message(log_buf) - call set_scalar_ic_uniform(s, ic_value) else if (trim(type) .eq. 'point_zone') then @@ -111,79 +106,24 @@ subroutine set_scalar_ic_int(s, coef, gs, type, params) call json_get(params, 'case.scalar.initial_condition.zone_value', & zone_value) - write (log_buf, '(A,F10.6)') "Base value: ", ic_value - call neko_log%message(log_buf) - call neko_log%message("Zone name : " // trim(read_str)) - write (log_buf, '(A,F10.6)') "Zone value: ", zone_value - call neko_log%message(log_buf) - call set_scalar_ic_point_zone(s, ic_value, read_str, zone_value) else if (trim(type) .eq. 'field') then call json_get(params, 'case.scalar.initial_condition.file_name', & read_str) - - ! Read field file fname = trim(read_str) - call neko_log%message("File name: " // trim(fname)) - - ! Get the sample index from the file name, e.g. "field0.f00015" will - ! return 15 - sample_idx = extract_fld_file_index(fname, -1) - - if (sample_idx .eq. -1) then - call neko_error("Invalid file name for the initial condition. The& -& file format must be e.g. 'mean0.f00001'") - end if - - call filename_chsuffix(fname, fname, 'fld') - - ! Check if we want to interpolate from the field file, default is no call json_get_or_default(params, & 'case.scalar.initial_condition.interpolate', interpolate, & .false.) - ! Get the tolerance for potential interpolation, defaults to 1e-6 call json_get_or_default(params, & 'case.scalar.initial_condition.tolerance', tol, 0.000001_rp) + call json_get_or_default(params, & + 'case.scalar.initial_condition.mesh_file_name', read_str, & + "none") + mesh_fname = trim(read_str) - if (interpolate) then - - call neko_log%message("Interpolation : yes") - write (log_buf, '(A,E15.7)') "Tolerance : ", tol - call neko_log%message(log_buf) - - ! Get the index of the file that contains the mesh. - call json_get_or_default(params, & - 'case.scalar.initial_condition.mesh_file_name', read_str, & - "none") - - mesh_fname = trim(read_str) - - ! If no mesh file is specified, use the default file name - if (mesh_fname .eq. "none") then - mesh_fname = trim(fname) - sample_mesh_idx = sample_idx - else - ! Get the sample index from the mesh file name - sample_mesh_idx = extract_fld_file_index(mesh_fname, -1) - - if (sample_mesh_idx .eq. -1) then - call neko_error("Invalid file name for the initial condition. The& -& file format must be e.g. 'mean0.f00001'") - end if - - write (log_buf, '(A,A)') "Coordinates file : ", & - trim(mesh_fname) - call neko_log%message(log_buf) - end if - - else - call neko_log%message("Interpolation: no") - end if - - call set_scalar_ic_fld(s, fname, sample_idx, interpolate, & - tolerance = tol, sample_mesh_idx = sample_mesh_idx) + call set_scalar_ic_fld(s, fname, interpolate, tol, mesh_fname) else call neko_error('Invalid initial condition') @@ -250,6 +190,12 @@ subroutine set_scalar_ic_uniform(s, ic_value) type(field_t), intent(inout) :: s real(kind=rp), intent(in) :: ic_value integer :: n + character(len=LOG_SIZE) :: log_buf + + call neko_log%message("Type : uniform") + write (log_buf, '(A,F10.6)') "Value: ", ic_value + call neko_log%message(log_buf) + s = ic_value n = s%dof%size() if (NEKO_BCKND_DEVICE .eq. 1) then @@ -272,9 +218,17 @@ subroutine set_scalar_ic_point_zone(s, base_value, zone_name, zone_value) real(kind=rp), intent(in) :: zone_value ! Internal variables + character(len=LOG_SIZE) :: log_buf class(point_zone_t), pointer :: zone integer :: size + call neko_log%message("Type : point_zone") + write (log_buf, '(A,F10.6)') "Base value: ", base_value + call neko_log%message(log_buf) + call neko_log%message("Zone name : " // trim(zone_name)) + write (log_buf, '(A,F10.6)') "Zone value: ", zone_value + call neko_log%message(log_buf) + size = s%dof%size() zone => neko_point_zone_registry%get_point_zone(trim(zone_name)) @@ -297,15 +251,16 @@ end subroutine set_scalar_ic_point_zone !! points in the mesh. !! @param sample_mesh_idx If interpolation is enabled, index of the field !! file where the mesh coordinates are located. - subroutine set_scalar_ic_fld(s, file_name, sample_idx, & - interpolate, tolerance, sample_mesh_idx) + subroutine set_scalar_ic_fld(s, file_name, & + interpolate, tolerance, mesh_file_name) type(field_t), intent(inout) :: s character(len=*), intent(in) :: file_name - integer, intent(in) :: sample_idx logical, intent(in) :: interpolate real(kind=rp), intent(in) :: tolerance - integer, intent(in) :: sample_mesh_idx + character(len=*), intent(inout) :: mesh_file_name + character(len=LOG_SIZE) :: log_buf + integer :: sample_idx, sample_mesh_idx integer :: last_index type(fld_file_data_t) :: fld_data type(file_t) :: f @@ -320,15 +275,55 @@ subroutine set_scalar_ic_fld(s, file_name, sample_idx, & type(interpolator_t) :: space_interp ! ---- + call neko_log%message("Type : field") + call neko_log%message("File name : " // trim(file_name)) + write (log_buf, '(A,L1)') "Interpolation : ", interpolate + call neko_log%message(log_buf) + if (interpolate) then + end if + + ! Extract sample index from the file name + sample_idx = extract_fld_file_index(file_name, -1) + + if (sample_idx .eq. -1) & + call neko_error("Invalid file name for the initial condition. The& + & file format must be e.g. 'mean0.f00001'") + + ! Change from "field0.f000*" to "field0.fld" for the fld reader + call filename_chsuffix(file_name, file_name, 'fld') + call fld_data%init f = file_t(trim(file_name)) if (interpolate) then + + ! If no mesh file is specified, use the default file name + if (mesh_file_name .eq. "none") then + mesh_file_name = trim(file_name) + sample_mesh_idx = sample_idx + else + + ! Extract sample index from the mesh file name + sample_mesh_idx = extract_fld_file_index(mesh_file_name, -1) + + if (sample_mesh_idx .eq. -1) & + call neko_error("Invalid file name for the initial condition. & +&The file format must be e.g. 'mean0.f00001'") + + write (log_buf, '(A,ES13.6)') "Tolerance :", tolerance + call neko_log%message(log_buf) + write (log_buf, '(A,A)') "Mesh file : ", & + trim(mesh_file_name) + call neko_log%message(log_buf) + + end if ! if mesh_file_name .eq. none + ! Read the mesh coordinates if they are not in our fld file if (sample_mesh_idx .ne. sample_idx) then call f%set_counter(sample_mesh_idx) call f%read(fld_data) end if + end if ! Read the field file containing (u,v,w,p) From aae82312674d4a23ae5e58662d0421e668021664 Mon Sep 17 00:00:00 2001 From: Victor Baconnet Date: Wed, 25 Sep 2024 15:00:06 +0200 Subject: [PATCH 62/67] remove found flag --- src/simulation_components/probes.F90 | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/simulation_components/probes.F90 b/src/simulation_components/probes.F90 index 05f4d53d7ad..aea070a99e0 100644 --- a/src/simulation_components/probes.F90 +++ b/src/simulation_components/probes.F90 @@ -239,16 +239,10 @@ subroutine read_point(this, json) real(kind=rp), dimension(:,:), allocatable :: point_list real(kind=rp), dimension(:), allocatable :: rp_list_reader - logical :: found ! Ensure only rank 0 reads the coordinates. if (pe_rank .ne. 0) return - call json%get('coordinates', rp_list_reader, found) - - ! Check if the coordinates were found and were valid - if (.not. found) then - call neko_error('No coordinates found.') - end if + call json_get(json, 'coordinates', rp_list_reader) if (mod(size(rp_list_reader), 3) /= 0) then call neko_error('Invalid number of coordinates.') From a5cd670562ed4dc044999bb535be78a83ac3f3da Mon Sep 17 00:00:00 2001 From: Victor Baconnet Date: Thu, 26 Sep 2024 09:41:16 +0200 Subject: [PATCH 63/67] Revert "remove found flag" This reverts commit aae82312674d4a23ae5e58662d0421e668021664. --- src/simulation_components/probes.F90 | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/simulation_components/probes.F90 b/src/simulation_components/probes.F90 index aea070a99e0..05f4d53d7ad 100644 --- a/src/simulation_components/probes.F90 +++ b/src/simulation_components/probes.F90 @@ -239,10 +239,16 @@ subroutine read_point(this, json) real(kind=rp), dimension(:,:), allocatable :: point_list real(kind=rp), dimension(:), allocatable :: rp_list_reader + logical :: found ! Ensure only rank 0 reads the coordinates. if (pe_rank .ne. 0) return - call json_get(json, 'coordinates', rp_list_reader) + call json%get('coordinates', rp_list_reader, found) + + ! Check if the coordinates were found and were valid + if (.not. found) then + call neko_error('No coordinates found.') + end if if (mod(size(rp_list_reader), 3) /= 0) then call neko_error('Invalid number of coordinates.') From 9889dd05559c2df8824289ad9e3fa051528f7082 Mon Sep 17 00:00:00 2001 From: Victor Baconnet Date: Thu, 26 Sep 2024 09:42:28 +0200 Subject: [PATCH 64/67] remove found flag in probes --- src/simulation_components/probes.F90 | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/simulation_components/probes.F90 b/src/simulation_components/probes.F90 index 05f4d53d7ad..aea070a99e0 100644 --- a/src/simulation_components/probes.F90 +++ b/src/simulation_components/probes.F90 @@ -239,16 +239,10 @@ subroutine read_point(this, json) real(kind=rp), dimension(:,:), allocatable :: point_list real(kind=rp), dimension(:), allocatable :: rp_list_reader - logical :: found ! Ensure only rank 0 reads the coordinates. if (pe_rank .ne. 0) return - call json%get('coordinates', rp_list_reader, found) - - ! Check if the coordinates were found and were valid - if (.not. found) then - call neko_error('No coordinates found.') - end if + call json_get(json, 'coordinates', rp_list_reader) if (mod(size(rp_list_reader), 3) /= 0) then call neko_error('Invalid number of coordinates.') From 8583d1d7a2fe642f70a7d98055bc7232bc16ba2d Mon Sep 17 00:00:00 2001 From: Victor Baconnet Date: Thu, 26 Sep 2024 09:48:05 +0200 Subject: [PATCH 65/67] add "_data" to procedure names --- src/io/fld_file_data.f90 | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/io/fld_file_data.f90 b/src/io/fld_file_data.f90 index cb842742de5..16ddd87db5e 100644 --- a/src/io/fld_file_data.f90 +++ b/src/io/fld_file_data.f90 @@ -51,9 +51,9 @@ module fld_file_data procedure, pass(this) :: scale => fld_file_data_scale procedure, pass(this) :: add => fld_file_data_add procedure, pass(this) :: size => fld_file_data_size - procedure, pass(this) :: get_list => fld_file_get_list - procedure, pass(this) :: init_same => fld_file_init_same - procedure, pass(this) :: init_n_fields => fld_file_init_n_fields + procedure, pass(this) :: get_list => fld_file_data_get_list + procedure, pass(this) :: init_same => fld_file_data_init_same + procedure, pass(this) :: init_n_fields => fld_file_data_init_n_fields !> Generates a global_interpolation object to interpolate the fld data. procedure, pass(this) :: generate_interpolator => & fld_file_data_generate_interpolator @@ -86,7 +86,7 @@ function fld_file_data_size(this) result(i) end function fld_file_data_size !> Genereate same fields as in another fld_file - subroutine fld_file_init_same(this, fld_file, n) + subroutine fld_file_data_init_same(this, fld_file, n) class(fld_file_data_t), target, intent(inout) :: this class(fld_file_data_t), target, intent(in) :: fld_file integer, intent(in) :: n @@ -113,10 +113,10 @@ subroutine fld_file_init_same(this, fld_file, n) call this%s(j)%init(n) end do - end subroutine fld_file_init_same + end subroutine fld_file_data_init_same !> Genereate same fields as in another fld_file - subroutine fld_file_init_n_fields(this, n_fields, n) + subroutine fld_file_data_init_n_fields(this, n_fields, n) class(fld_file_data_t), target, intent(inout) :: this integer, intent(in) :: n, n_fields integer :: i, j @@ -145,10 +145,7 @@ subroutine fld_file_init_n_fields(this, n_fields, n) end do end if - end subroutine fld_file_init_n_fields - - - + end subroutine fld_file_data_init_n_fields !> Get a list with pointers to the fields in the fld file subroutine fld_file_data_get_list(this, ptr_list, n) From bdf47c48521d1042c60e8af0a87646d8345a5c99 Mon Sep 17 00:00:00 2001 From: Victor Baconnet Date: Fri, 4 Oct 2024 10:54:06 +0200 Subject: [PATCH 66/67] cleanup log output --- src/case.f90 | 2 -- src/fluid/flow_ic.f90 | 2 ++ src/scalar/scalar_ic.f90 | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/case.f90 b/src/case.f90 index 77b1227029f..dd0736c2d6e 100644 --- a/src/case.f90 +++ b/src/case.f90 @@ -272,7 +272,6 @@ subroutine case_init_common(C) string_val) call neko_log%section("Fluid initial condition ") - call neko_log%message("Type: " // trim(string_val)) if (trim(string_val) .ne. 'user') then call set_flow_ic(C%fluid%u, C%fluid%v, C%fluid%w, C%fluid%p, & @@ -289,7 +288,6 @@ subroutine case_init_common(C) call json_get(C%params, 'case.scalar.initial_condition.type', string_val) call neko_log%section("Scalar initial condition ") - call neko_log%message("Type: " // trim(string_val)) if (trim(string_val) .ne. 'user') then call set_scalar_ic(C%scalar%s, & diff --git a/src/fluid/flow_ic.f90 b/src/fluid/flow_ic.f90 index 230050678df..a4576bddcdd 100644 --- a/src/fluid/flow_ic.f90 +++ b/src/fluid/flow_ic.f90 @@ -157,6 +157,8 @@ subroutine set_flow_ic_usr(u, v, w, p, coef, gs, usr_ic, params) procedure(useric) :: usr_ic type(json_file), intent(inout) :: params + + call neko_log%message("Type: user") call usr_ic(u, v, w, p, params) call set_flow_ic_common(u, v, w, p, coef, gs) diff --git a/src/scalar/scalar_ic.f90 b/src/scalar/scalar_ic.f90 index 7b41aa7b3dd..bbd6a5371a2 100644 --- a/src/scalar/scalar_ic.f90 +++ b/src/scalar/scalar_ic.f90 @@ -147,6 +147,7 @@ subroutine set_scalar_ic_usr(s, coef, gs, usr_ic, params) procedure(useric_scalar) :: usr_ic type(json_file), intent(inout) :: params + call neko_log%message("Type: user") call usr_ic(s, params) call set_scalar_ic_common(s, coef, gs) From f5110983b677526544e619d118613a5cd08003f5 Mon Sep 17 00:00:00 2001 From: Victor Baconnet Date: Fri, 4 Oct 2024 11:18:35 +0200 Subject: [PATCH 67/67] Fix formatting --- src/fluid/flow_ic.f90 | 16 ++++++++-------- src/scalar/scalar_ic.f90 | 8 ++++---- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/fluid/flow_ic.f90 b/src/fluid/flow_ic.f90 index a4576bddcdd..e95a4eea65d 100644 --- a/src/fluid/flow_ic.f90 +++ b/src/fluid/flow_ic.f90 @@ -208,12 +208,12 @@ subroutine set_flow_ic_uniform(u, v, w, uinf) type(field_t), intent(inout) :: v type(field_t), intent(inout) :: w real(kind=rp), intent(in) :: uinf(3) - integer :: n + integer :: n, i character(len=LOG_SIZE) :: log_buf call neko_log%message("Type : uniform") - write (log_buf, '(A,"[",2(F10.6,","),F10.6,"]")') "Value: ", uinf(1), & - uinf(2), uinf(3) + write (log_buf, '(A, 3(ES12.6, A))') "Value: [", (uinf(i), ", ", i=1, 2), & + uinf(3), "]" call neko_log%message(log_buf) u = uinf(1) @@ -242,10 +242,10 @@ subroutine set_flow_ic_blasius(u, v, w, delta, uinf, type) character(len=LOG_SIZE) :: log_buf call neko_log%message("Type : blasius") - write (log_buf, '(A,F10.6)') "delta : ", delta + write (log_buf, '(A,ES12.6)') "delta : ", delta call neko_log%message(log_buf) call neko_log%message("Approximation : " // trim(type)) - write (log_buf, '(A,"[",2(F10.6,","),F10.6,"]")') "Value : ", & + write (log_buf, '(A,"[",2(ES12.6,","),ES12.6,"]")') "Value : ", & uinf(1), uinf(2), uinf(3) call neko_log%message(log_buf) @@ -312,10 +312,10 @@ subroutine set_flow_ic_point_zone(u, v, w, base_value, zone_name, zone_value) integer :: size call neko_log%message("Type : point_zone") - write (log_buf, '(A,F10.6)') "Base value : ", base_value + write (log_buf, '(A,ES12.6)') "Base value : ", base_value call neko_log%message(log_buf) call neko_log%message("Zone name : " // trim(zone_name)) - write (log_buf, '(A,"[",2(F10.6,","),F10.6,"]")') "Value : ", & + write (log_buf, '(A,"[",2(ES12.6,","),ES12.6," ]")') "Value : ", & zone_value(1), zone_value(2), zone_value(3) call neko_log%message(log_buf) @@ -409,7 +409,7 @@ subroutine set_flow_ic_fld(u, v, w, p, file_name, & call neko_error("Invalid file name for the initial condition. & &The file format must be e.g. 'mean0.f00001'") - write (log_buf, '(A,ES13.6)') "Tolerance :", tolerance + write (log_buf, '(A,ES12.6)') "Tolerance : ", tolerance call neko_log%message(log_buf) write (log_buf, '(A,A)') "Mesh file : ", & trim(mesh_file_name) diff --git a/src/scalar/scalar_ic.f90 b/src/scalar/scalar_ic.f90 index bbd6a5371a2..1ad26417943 100644 --- a/src/scalar/scalar_ic.f90 +++ b/src/scalar/scalar_ic.f90 @@ -194,7 +194,7 @@ subroutine set_scalar_ic_uniform(s, ic_value) character(len=LOG_SIZE) :: log_buf call neko_log%message("Type : uniform") - write (log_buf, '(A,F10.6)') "Value: ", ic_value + write (log_buf, '(A,ES12.6)') "Value: ", ic_value call neko_log%message(log_buf) s = ic_value @@ -224,10 +224,10 @@ subroutine set_scalar_ic_point_zone(s, base_value, zone_name, zone_value) integer :: size call neko_log%message("Type : point_zone") - write (log_buf, '(A,F10.6)') "Base value: ", base_value + write (log_buf, '(A,ES12.6)') "Base value: ", base_value call neko_log%message(log_buf) call neko_log%message("Zone name : " // trim(zone_name)) - write (log_buf, '(A,F10.6)') "Zone value: ", zone_value + write (log_buf, '(A,ES12.6)') "Zone value: ", zone_value call neko_log%message(log_buf) size = s%dof%size() @@ -311,7 +311,7 @@ subroutine set_scalar_ic_fld(s, file_name, & call neko_error("Invalid file name for the initial condition. & &The file format must be e.g. 'mean0.f00001'") - write (log_buf, '(A,ES13.6)') "Tolerance :", tolerance + write (log_buf, '(A,ES12.6)') "Tolerance : ", tolerance call neko_log%message(log_buf) write (log_buf, '(A,A)') "Mesh file : ", & trim(mesh_file_name)