Neko-TOP
A portable framework for high-order spectral element flow toplogy optimization.
Loading...
Searching...
No Matches
user_setup.f90
Go to the documentation of this file.
1
5
7module user
8 use neko
9 use math, only: cfill_mask
10 use device_math, only: device_cfill_mask
11
12 use, intrinsic :: iso_c_binding, only: c_ptr, c_null_ptr
13
14 implicit none
15
16contains
17
19 subroutine user_setup(usr)
20 type(user_t), intent(inout) :: usr
21 usr%fluid_user_ic => cylinder_ic
22 ! usr%material_properties => set_material_properties
23 end subroutine user_setup
24
26 subroutine set_material_properties(t, tstep, rho, mu, cp, lambda, params)
27 real(kind=rp), intent(in) :: t
28 integer, intent(in) :: tstep
29 real(kind=rp), intent(inout) :: rho, mu, cp, lambda
30 type(json_file), intent(inout) :: params
31
32 real(kind=rp) :: re
33
34 call json_get(params, "case.fluid.Re", re)
35 mu = 1.0_rp/re
36 lambda = 1.0_rp
37 rho = 1.0_rp
38 cp = 1.0_rp
39 end subroutine set_material_properties
40
50 subroutine cylinder_ic(u, v, w, p, params)
51 type(field_t), intent(inout) :: u, v, w, p
52 type(json_file), intent(inout) :: params
53
54 class(point_zone_t), pointer :: cylinder
55 real(kind=rp) :: noise, noise_scale
56 integer :: i
57
58 ! Set a uniform flow field.
59 call cfill(u%x, 1.0_rp, u%dof%size())
60 call cfill(v%x, 0.0_rp, v%dof%size())
61 call cfill(w%x, 0.0_rp, w%dof%size())
62
63 ! Apply a random perturbation to the initial condition.
64 noise = 0.0_rp
65 noise_scale = 1e-2_rp
66 do i = 1, u%dof%size()
67 call random_number(noise)
68 u%x(i, 1, 1, 1) = u%x(i, 1, 1, 1) + noise_scale * noise
69 call random_number(noise)
70 v%x(i, 1, 1, 1) = v%x(i, 1, 1, 1) + noise_scale * noise
71 call random_number(noise)
72 w%x(i, 1, 1, 1) = w%x(i, 1, 1, 1) + noise_scale * noise
73 end do
74
75 ! Set flow to zero in the cylinder.
76 if (neko_point_zone_registry%point_zone_exists("cylinder")) then
77 cylinder => neko_point_zone_registry%get_point_zone("cylinder")
78
79 call cfill_mask(u%x, 0.0_rp, u%dof%size(), cylinder%mask, cylinder%size)
80 end if
81
82 end subroutine cylinder_ic
83end module user
User defined user region.
Definition user.f90:2
subroutine user_setup(user)
Register user defined functions (see nekos user_intf.f90)
Definition user.f90:22
subroutine set_material_properties(t, tstep, rho, mu, cp, lambda, params)
Read the material properties from the JSON file.
subroutine cylinder_ic(u, v, w, p, params)
Set the initial condition.