37 use num_types,
only: rp
39 use scalar_scheme,
only: scalar_scheme_t
41 use field_list,
only: field_list_t
42 use neko_config,
only: neko_bcknd_device
43 use device,
only: device_memcpy, device_to_host
44 use output,
only: output_t
51 type(field_list_t) :: adjoint
53 procedure, pass(this) :: sample => adjoint_output_sample
57 module procedure adjoint_output_init
69 function adjoint_output_init(precision, adjoint, adjoint_scalars, &
70 name, path)
result(this)
71 integer,
intent(inout) :: precision
74 character(len=*),
intent(in),
optional :: name
75 character(len=*),
intent(in),
optional :: path
77 character(len=1024) :: fname
78 integer :: i, n_scalars
80 if (
present(name) .and.
present(path))
then
81 fname = trim(path) // trim(name) //
'.fld'
82 else if (
present(name))
then
83 fname = trim(name) //
'.fld'
84 else if (
present(path))
then
85 fname = trim(path) //
'adjoint.fld'
90 call this%init_base(fname, precision)
99 call this%adjoint%init(4 + n_scalars)
101 call this%adjoint%assign(1, adjoint%p_adj)
102 call this%adjoint%assign(2, adjoint%u_adj)
103 call this%adjoint%assign(3, adjoint%v_adj)
104 call this%adjoint%assign(4, adjoint%w_adj)
109 call this%adjoint%assign(4 + i, &
114 end function adjoint_output_init
119 subroutine adjoint_output_sample(this, t)
121 real(kind=rp),
intent(in) :: t
124 if (neko_bcknd_device .eq. 1)
then
126 associate(fields => this%adjoint%items)
127 do i = 1,
size(fields)
128 call device_memcpy(fields(i)%ptr%x, fields(i)%ptr%x_d, &
129 fields(i)%ptr%dof%size(), device_to_host, &
130 sync = (i .eq.
size(fields)))
136 call this%file_%write(this%adjoint, t)
138 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.