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
56 procedure, pass(this) :: free => adjoint_output_free
58 procedure, pass(this) :: sample => adjoint_output_sample
74 integer,
intent(in) :: precision
77 character(len=*),
intent(in),
optional :: name
78 character(len=*),
intent(in),
optional :: path
79 character(len=1024) :: fname
80 integer :: i, n_scalars
84 if (
present(name) .and.
present(path))
then
85 fname = trim(path) // trim(name) //
'.fld'
86 else if (
present(name))
then
87 fname = trim(name) //
'.fld'
88 else if (
present(path))
then
89 fname = trim(path) //
'adjoint.fld'
94 call this%init_base(fname, precision)
103 call this%adjoint%init(4 + n_scalars)
105 call this%adjoint%assign(1, adjoint%p_adj)
106 call this%adjoint%assign(2, adjoint%u_adj)
107 call this%adjoint%assign(3, adjoint%v_adj)
108 call this%adjoint%assign(4, adjoint%w_adj)
113 call this%adjoint%assign(4 + i, &
121 subroutine adjoint_output_free(this)
124 call this%free_base()
125 call this%adjoint%free()
127 end subroutine adjoint_output_free
132 subroutine adjoint_output_sample(this, t)
134 real(kind=rp),
intent(in) :: t
137 if (neko_bcknd_device .eq. 1)
then
139 associate(fields => this%adjoint%items)
140 do i = 1,
size(fields)
141 call device_memcpy(fields(i)%ptr%x, fields(i)%ptr%x_d, &
142 fields(i)%ptr%dof%size(), device_to_host, &
143 sync = (i .eq.
size(fields)))
149 call this%file_%write(this%adjoint, t)
151 end subroutine adjoint_output_sample
Defines an output for a adjoint.
subroutine adjoint_output_init(this, precision, adjoint, adjoint_scalars, name, path)
Constructor.
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.