User defined simulation components.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34module simcomp_example
36 use json_module, only : json_file
39 implicit none
40 private
41
42
43
45
46 contains
47
48 procedure, pass(this) :: init => simcomp_test_init_from_json
49
50 procedure, pass(this) :: init_from_attributes => &
51 simcomp_test_init_from_attributes
52
53 procedure, pass(this) :: free => simcomp_test_free
54
55 procedure, pass(this) :: compute_ => simcomp_test_compute
56 end type user_simcomp_t
57
58contains
59
60
61 subroutine simcomp_test_init_from_json(this, json, case)
62 class(user_simcomp_t), intent(inout) :: this
63 type(json_file), intent(inout) :: json
64 class(case_t), intent(inout), target :: case
65
66 call this%init_from_attributes()
67 call this%init_base(json,
case)
68
69 end subroutine simcomp_test_init_from_json
70
71
72 subroutine simcomp_test_init_from_attributes(this)
73 class(user_simcomp_t), intent(inout) :: this
74
75 write(*,*) "Initializing simcomp_test field"
76 end subroutine simcomp_test_init_from_attributes
77
78
79 subroutine simcomp_test_free(this)
80 class(user_simcomp_t), intent(inout) :: this
81
82 write(*,*) "Freeing simcomp_test field"
83 call this%free_base()
84 end subroutine simcomp_test_free
85
86
87 subroutine simcomp_test_compute(this, t, tstep)
88 class(user_simcomp_t), intent(inout) :: this
89 real(kind=
rp),
intent(in) :: t
90 integer, intent(in) :: tstep
91
92 write(*,*) "Computing simcomp_test field"
93
94 end subroutine simcomp_test_compute
95
96end module simcomp_example
97
98
99
100module user
102 use simcomp_example, only: user_simcomp_t
103 implicit none
104
105contains
106
107
108 subroutine user_setup(user)
109 type(user_t), intent(inout) :: user
110 user%init_user_simcomp => user_simcomp
111 user%fluid_user_ic => user_ic
112 end subroutine user_setup
113
114 subroutine user_simcomp(params)
115 type(json_file), intent(inout) :: params
116 type(user_simcomp_t), allocatable :: my_simcomp
117 type(json_file) :: simcomp_settings
118
119
120 allocate(my_simcomp)
121 simcomp_settings = simulation_component_user_settings("my_comp", params)
122
123 call neko_simcomps%add_user_simcomp(my_simcomp, simcomp_settings)
124
125 end subroutine user_simcomp
126
127
128 subroutine user_ic(u, v, w, p, params)
129 type(field_t), intent(inout) :: u
130 type(field_t), intent(inout) :: v
131 type(field_t), intent(inout) :: w
132 type(field_t), intent(inout) :: p
133 type(json_file), intent(inout) :: params
134 integer :: i, ntot
135 real(kind=rp) :: uvw(3)
136
137
138 ntot = u%dof%size()
139 do i = 1, ntot
140 uvw = tgv_ic(u%dof%x(i,1,1,1),u%dof%y(i,1,1,1),u%dof%z(i,1,1,1))
141 u%x(i,1,1,1) = uvw(1)
142 v%x(i,1,1,1) = uvw(2)
143 w%x(i,1,1,1) = uvw(3)
144 end do
145 p = 0._rp
146 end subroutine user_ic
147
148 function tgv_ic(x, y, z) result(uvw)
149 real(kind=rp) :: x, y, z
150 real(kind=rp) :: ux, uy, uz
151 real(kind=rp) :: uvw(3)
152
153 uvw(1) = sin(x)*cos(y)*cos(z)
154 uvw(2) = -cos(x)*sin(y)*cos(z)
155 uvw(3) = 0._rp
156 end function tgv_ic
157end module user
Defines a simulation case.
integer, parameter, public rp
Global precision used in computations.
Simulation components are objects that encapsulate functionality that can be fit to a particular comp...
Base abstract class for simulation components.