Neko-TOP
A portable framework for high-order spectral element flow toplogy optimization.
Loading...
Searching...
No Matches
permeability_user.f90
Go to the documentation of this file.
1
5
7module user
8 use neko
9
10 use, intrinsic :: iso_c_binding, only: c_ptr, c_null_ptr
11
12 implicit none
13
14 real(kind=rp) :: perm = 0.0_rp
15 real(kind=rp), allocatable :: resistance(:)
16 type(c_ptr) :: resistance_d = c_null_ptr
17 logical :: is_initialized = .false.
18
19contains
20
22 subroutine user_setup(u)
23 type(user_t), intent(inout) :: u
24 u%fluid_user_f_vector => fluid_permeability
25 u%material_properties => set_material_properties
26 u%scalar_user_ic => initial_condition
27 end subroutine user_setup
28
30 subroutine set_material_properties(t, tstep, rho, mu, cp, lambda, params)
31 real(kind=rp), intent(in) :: t
32 integer, intent(in) :: tstep
33 real(kind=rp), intent(inout) :: rho, mu, cp, lambda
34 type(json_file), intent(inout) :: params
35
36 real(kind=rp) :: re, pe
37
38 call json_get(params, "case.fluid.Re", re)
39 call json_get(params, "case.fluid.perm", perm)
40 call json_get(params, "case.scalar.Pe", pe)
41
42 mu = 1.0_rp/re
43 lambda = 1.0_rp/pe
44 rho = 1.0_rp
45 cp = 1.0_rp
46 end subroutine set_material_properties
47
55 subroutine initial_condition(s, params)
56 type(field_t), intent(inout) :: s
57 type(json_file), intent(inout) :: params
58
59 real(kind=rp) :: z_value
60 integer :: i
61
62 do i = 1, s%dof%size()
63 z_value = s%dof%z(i, 1, 1, 1)
64
65 if (z_value > 0.0_rp) then
66 s%x(i, 1, 1, 1) = 0.0_rp
67 else
68 s%x(i, 1, 1, 1) = 1.0_rp
69 end if
70
71 end do
72
73 end subroutine initial_condition
74
76 subroutine fluid_permeability(f, t)
77 class(fluid_user_source_term_t), intent(inout) :: f
78 real(kind=rp), intent(in) :: t
79 type(field_t), pointer :: u, v, w, s
80
81 integer :: i
82 class(point_zone_t), pointer :: my_point_zone
83
84 if (.not. is_initialized) then
85 is_initialized = .true.
86
87 my_point_zone => neko_point_zone_registry%get_point_zone("lowperm")
88
89 allocate (resistance(f%dm%size()))
90 call rzero(resistance, f%dm%size())
91
92 do i = 1, my_point_zone%size
93 resistance(my_point_zone%mask(i)) = -perm
94 end do
95
96 ! Copy to device
97 if (neko_bcknd_device .eq. 1) then
98 call device_map(resistance, resistance_d, f%dm%size())
99 call device_memcpy(resistance, resistance_d, f%dm%size(), &
100 host_to_device, .true.)
101 end if
102 end if
103
104 u => neko_field_registry%get_field('u')
105 v => neko_field_registry%get_field('v')
106 w => neko_field_registry%get_field('w')
107
108 if (neko_bcknd_device .eq. 1) then
109 call device_col3(f%u_d, u%x_d, resistance_d, f%dm%size())
110 call device_col3(f%v_d, v%x_d, resistance_d, f%dm%size())
111 call device_col3(f%w_d, w%x_d, resistance_d, f%dm%size())
112 else
113 call col3(f%u, u%x, resistance, f%dm%size())
114 call col3(f%v, v%x, resistance, f%dm%size())
115 call col3(f%w, w%x, resistance, f%dm%size())
116 end if
117 end subroutine fluid_permeability
118end module user
User defined user region.
Definition user.f90:2
subroutine fluid_permeability(f, t)
Forcing.
real(kind=rp) perm
subroutine user_setup(user)
Register user defined functions (see nekos user_intf.f90)
Definition user.f90:22
real(kind=rp), dimension(:), allocatable resistance
subroutine set_material_properties(t, tstep, rho, mu, cp, lambda, params)
Read the material properties from the JSON file.
type(c_ptr) resistance_d
subroutine initial_condition(s, params)
Set the initial condition for the scalar field.
logical is_initialized
real(kind=rp) pe