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
48 type(field_list_t) :: adjoint
50 procedure, pass(this) :: sample => adjoint_output_sample
54 module procedure adjoint_output_init
59 function adjoint_output_init(precision, adjoint, scalar, name, path) &
61 integer,
intent(inout) :: precision
64 character(len=*),
intent(in),
optional :: name
65 character(len=*),
intent(in),
optional :: path
67 character(len=1024) :: fname
69 if (
present(name) .and.
present(path))
then
70 fname = trim(path) // trim(name) //
'.fld'
71 else if (
present(name))
then
72 fname = trim(name) //
'.fld'
73 else if (
present(path))
then
74 fname = trim(path) //
'adjoint.fld'
79 call this%init_base(fname, precision)
81 if (
present(scalar))
then
82 call this%adjoint%init(5)
84 call this%adjoint%init(4)
87 call this%adjoint%assign(1, adjoint%p_adj)
88 call this%adjoint%assign(2, adjoint%u_adj)
89 call this%adjoint%assign(3, adjoint%v_adj)
90 call this%adjoint%assign(4, adjoint%w_adj)
92 if (
present(scalar))
then
93 call this%adjoint%assign(5, scalar%s_adj)
96 end function adjoint_output_init
99 subroutine adjoint_output_sample(this, t)
101 real(kind=rp),
intent(in) :: t
104 if (neko_bcknd_device .eq. 1)
then
106 associate(fields => this%adjoint%items)
107 do i = 1,
size(fields)
108 call device_memcpy(fields(i)%ptr%x, fields(i)%ptr%x_d, &
109 fields(i)%ptr%dof%size(), device_to_host, &
110 sync = (i .eq.
size(fields)))
116 call this%file_%write(this%adjoint, t)
118 end subroutine adjoint_output_sample
Defines an output for a adjoint.
Contains the adjoint_scalar_scheme_t type.
Base type of all fluid formulations.
Base type for a scalar advection-diffusion solver.