35 use num_types,
only: rp
37 use scalar_scheme,
only: scalar_scheme_t
39 use field_list,
only: field_list_t
40 use neko_config,
only: neko_bcknd_device
41 use device,
only: device_memcpy, device_to_host
42 use output,
only: output_t
49 type(field_list_t) :: adjoint
51 procedure, pass(this) :: sample => adjoint_output_sample
55 module procedure adjoint_output_init
67 function adjoint_output_init(precision, adjoint, adjoint_scalars, &
68 name, path)
result(this)
69 integer,
intent(inout) :: precision
72 character(len=*),
intent(in),
optional :: name
73 character(len=*),
intent(in),
optional :: path
75 character(len=1024) :: fname
76 integer :: i, n_scalars
78 if (
present(name) .and.
present(path))
then
79 fname = trim(path) // trim(name) //
'.fld'
80 else if (
present(name))
then
81 fname = trim(name) //
'.fld'
82 else if (
present(path))
then
83 fname = trim(path) //
'adjoint.fld'
88 call this%init_base(fname, precision)
97 call this%adjoint%init(4 + n_scalars)
99 call this%adjoint%assign(1, adjoint%p_adj)
100 call this%adjoint%assign(2, adjoint%u_adj)
101 call this%adjoint%assign(3, adjoint%v_adj)
102 call this%adjoint%assign(4, adjoint%w_adj)
107 call this%adjoint%assign(4 + i, &
112 end function adjoint_output_init
117 subroutine adjoint_output_sample(this, t)
119 real(kind=rp),
intent(in) :: t
122 if (neko_bcknd_device .eq. 1)
then
124 associate(fields => this%adjoint%items)
125 do i = 1,
size(fields)
126 call device_memcpy(fields(i)%ptr%x, fields(i)%ptr%x_d, &
127 fields(i)%ptr%dof%size(), device_to_host, &
128 sync = (i .eq.
size(fields)))
134 call this%file_%write(this%adjoint, t)
136 end subroutine adjoint_output_sample
Defines an output for a adjoint.
Contains the adjoint_scalar_scheme_t type.
Contains the adjoint_scalars_t type that manages multiple scalar fields.
Base type of all fluid formulations.
Base type for a scalar advection-diffusion solver.
Type to manage multiple adjoint scalar transport equations.