36module simplefield_design
37 use num_types,
only: rp, sp
38 use field,
only: field_t
39 use json_module,
only: json_file
43 use coefs,
only: coef_t
44 use scratch_registry,
only: neko_scratch_registry
45 use point_zone_registry,
only: neko_point_zone_registry
46 use point_zone,
only: point_zone_t
48 use neko_config,
only: neko_bcknd_device
49 use device,
only: device_memcpy, host_to_device
50 use device_math,
only: device_copy
54 use json_module,
only: json_file
55 use json_utils,
only: json_get
57 use vector,
only: vector_t
59 use utils,
only: neko_error
61 use fld_file_output,
only: fld_file_output_t
70 type(field_t) :: designfield
71 type(vector_t) :: x_coord
72 type(vector_t) :: y_coord
73 type(vector_t) :: z_coord
76 type(fld_file_output_t) :: output
85 generic,
public :: init => init_from_components
87 procedure, pass(this) :: init_from_components => &
88 design_simple_init_from_components
91 procedure, pass(this) :: add_mapping => design_simple_add_mapping
94 procedure, pass(this) :: get_values => design_simple_get_values
97 procedure, pass(this) :: design_get_x => design_simple_get_x
98 procedure, pass(this) :: design_get_y => design_simple_get_y
99 procedure, pass(this) :: design_get_z => design_simple_get_z
102 procedure, pass(this) :: update_design => design_simple_update_design
105 procedure, pass(this) :: map_forward => design_simple_map_forward
108 procedure, pass(this) :: map_backward => design_simple_map_backward
111 procedure, pass(this) :: write => design_simple_write
114 procedure, pass(this) :: free => design_simple_free
121 subroutine design_simple_init_from_components(this, n, x, y, z, neko_field)
123 integer,
intent(in) :: n
124 type(vector_t),
intent(in) :: x, y, z
125 type(field_t) :: neko_field
127 call this%init_base(
'simplefield_design', n)
132 this%designfield = neko_field
133 call this%output%init(sp,
'design', 1)
134 call this%output%fields%assign_to_field(1, this%designfield)
135 end subroutine design_simple_init_from_components
138 subroutine design_simple_free(this)
141 call this%free_base()
142 call this%x_coord%free()
143 call this%y_coord%free()
144 call this%z_coord%free()
146 call this%designfield%free()
147 end subroutine design_simple_free
150 subroutine design_simple_add_mapping(this, parameters, simulation)
152 type(json_file),
intent(inout) :: parameters
155 end subroutine design_simple_add_mapping
158 subroutine design_simple_map_forward(this)
162 end subroutine design_simple_map_forward
164 subroutine design_simple_get_values(this, values)
166 type(vector_t),
intent(inout) :: values
170 if (neko_bcknd_device .eq. 1)
then
171 call device_copy(values%x_d, this%designfield%x_d, n)
173 call copy(values%x, this%designfield%x, n)
175 end subroutine design_simple_get_values
177 subroutine design_simple_get_x(this, x)
179 type(vector_t),
intent(inout) :: x
181 if (this%size() .ne. x%size())
then
182 call neko_error(
'Get x: size mismatch')
185 end subroutine design_simple_get_x
187 subroutine design_simple_get_y(this, y)
189 type(vector_t),
intent(inout) :: y
191 if (this%size() .ne. y%size())
then
192 call neko_error(
'Get y: size mismatch')
195 end subroutine design_simple_get_y
197 subroutine design_simple_get_z(this, z)
199 type(vector_t),
intent(inout) :: z
201 if (this%size() .ne. z%size())
then
202 call neko_error(
'Get z: size mismatch')
205 end subroutine design_simple_get_z
209 subroutine design_simple_update_design(this, values)
211 type(vector_t),
intent(inout) :: values
215 if (neko_bcknd_device .eq. 1)
then
216 call device_copy(this%designfield%x_d, values%x_d, n)
218 call copy(this%designfield%x, values%x, n)
220 end subroutine design_simple_update_design
222 subroutine design_simple_map_backward(this, sensitivity)
224 type(vector_t),
intent(in) :: sensitivity
226 end subroutine design_simple_map_backward
228 subroutine design_simple_write(this, idx)
230 integer,
intent(in) :: idx
231 call this%output%sample(real(idx, kind=rp))
232 end subroutine design_simple_write
234end module simplefield_design
Mappings to be applied to a scalar field.
Some common Masking operations we may need.
A RAMP mapping of coefficients.
Implements the simple_brinkman_source_term_t type.
Implements the steady_problem_t type.
Base abstract class for mapping.
A PDE based filter mapping , see Lazarov & O. Sigmund 2010, by solving an equation of the form .
A RAMP mapping of coefficients This is the standard RAMP described in https://doi....
A simple Brinkman source term.
A topology optimization design variable.