55 type(case_t),
intent(inout) :: neko_case
57 integer :: i, n_scalars
58 character(len=:),
allocatable :: string_val
59 logical :: has_scalar, freezeflow
60 type(field_t),
pointer :: u, v, w, p, s
61 type(json_file) :: json_subdict, scalar_params
67 u => neko_case%fluid%u
68 v => neko_case%fluid%v
69 w => neko_case%fluid%w
70 p => neko_case%fluid%p
71 if (
allocated(neko_case%scalars))
then
72 s => neko_case%scalars%scalar_fields(1)%s
83 neko_case%time%tstep = 0
86 neko_case%time%tlag = t
87 neko_case%time%dtlag = neko_case%time%dt
88 do i = 1,
size(neko_case%time%tlag)
89 neko_case%time%tlag(i) = t - i*neko_case%time%dtlag(i)
93 call neko_case%output_controller%set_counter(neko_case%time)
96 call neko_case%fluid%restart(neko_case%chkp)
97 if (
allocated(neko_case%scalars))
then
98 call neko_case%scalars%restart(neko_case%chkp)
102 do i = 1,
size(neko_case%time%dtlag)
103 call neko_case%fluid%ext_bdf%set_coeffs(neko_case%time%dtlag)
107 call neko_simcomps%restart(neko_case%time)
113 call json_get(neko_case%params, &
114 'case.fluid.initial_condition.type', string_val)
115 call json_extract_object(neko_case%params,
'case.fluid.initial_condition', &
118 if (trim(string_val) .ne.
'user')
then
119 call set_flow_ic(u, v, w, p, &
120 neko_case%fluid%c_Xh, neko_case%fluid%gs_Xh, &
121 string_val, json_subdict)
123 call set_flow_ic(u, v, w, p, &
124 neko_case%fluid%c_Xh, neko_case%fluid%gs_Xh, &
125 neko_case%user%fluid_user_ic, neko_case%params)
132 call json_get_or_default(neko_case%params, &
133 'case.scalar.enabled', has_scalar, .false.)
136 if (neko_case%params%valid_path(
'case.adjoint_scalar'))
then
138 call json_get(neko_case%params, &
139 'case.adjoint_scalar.initial_condition.type', string_val)
140 call json_extract_object(neko_case%params, &
141 'case.adjoint_scalar.initial_condition', json_subdict)
145 if (trim(string_val) .ne.
'user')
then
146 call set_scalar_ic(neko_case%scalars%scalar_fields(1)%s, &
147 neko_case%fluid%c_Xh, neko_case%fluid%gs_Xh, string_val, &
150 call neko_error(
"user defined ICs not implemented for " // &
161 call neko_case%params%info(
'case.scalars', n_children = n_scalars)
164 call json_extract_item(neko_case%params,
'case.adjoint_scalars', &
166 call json_get(scalar_params,
'initial_condition.type', string_val)
167 call json_extract_object(scalar_params,
'initial_condition', &
170 if (trim(string_val) .ne.
'user')
then
171 call set_scalar_ic(neko_case%scalars%scalar_fields(i)%s, &
172 neko_case%scalars%scalar_fields(i)%c_Xh, &
173 neko_case%scalars%scalar_fields(i)%gs_Xh, string_val, &
176 call neko_error(
"user defined ICs not implemented for " // &
187 call json_get_or_default(neko_case%params, &
188 'case.fluid.freeze_flow', freezeflow, .false.)
190 neko_case%fluid%freeze = freezeflow
203 type(case_t),
intent(inout) :: neko_case
204 integer,
intent(in) :: iter
206 character(len=:),
allocatable :: dirname
207 character(len=80) :: file_name
209 if (iter .ne. 1)
then
210 call reset(neko_case)
213 call json_get_or_default(neko_case%params, &
214 'case.output_directory', dirname,
'./')
216 write (file_name,
'(a,a,i5.5,a)') &
217 trim(adjustl(dirname)),
'/topopt_', iter,
'_.fld'
219 neko_case%f_out%output_t%file_%file_type%fname = trim(file_name)
220 neko_case%f_out%output_t%file_%file_type%counter = 0
221 neko_case%f_out%output_t%file_%file_type%start_counter = 0
222 call neko_case%output_controller%execute(neko_case%time, .true.)
283 adjoint_scalars, primal_name)
284 integer,
intent(out) :: i_primal
285 integer,
intent(out) :: i_adjoint
286 type(scalars_t),
intent(inout) :: scalars
288 character(len=*),
intent(in) :: primal_name
289 integer :: i, n_primal_scalars, n_adjoint_scalars
294 n_primal_scalars =
size(scalars%scalar_fields)
296 if ((n_adjoint_scalars .eq. 1) .and. (n_primal_scalars .eq. 1))
then
302 do i = 1, n_adjoint_scalars
304 .eq. primal_name)
then
310 do i = 1, n_primal_scalars
311 if (scalars%scalar_fields(i)%name .eq. primal_name)
then
317 if (i_primal .le. 0 .or. i_adjoint .le. 0)
then
318 call neko_error(
'could not find matching primal and adjoint' // &