34module simplefield_design
35 use num_types,
only: rp, sp
36 use field,
only: field_t
37 use json_module,
only: json_file
41 use coefs,
only: coef_t
42 use scratch_registry,
only: neko_scratch_registry
43 use point_zone_registry,
only: neko_point_zone_registry
44 use point_zone,
only: point_zone_t
46 use neko_config,
only: neko_bcknd_device
47 use device,
only: device_memcpy, host_to_device
48 use device_math,
only: device_copy
52 use json_module,
only: json_file
53 use json_utils,
only: json_get
55 use vector,
only: vector_t
57 use field_registry,
only: neko_field_registry
59 use fld_file_output,
only: fld_file_output_t
68 type(field_t) :: designfield
69 type(vector_t) :: x_coord
70 type(vector_t) :: y_coord
71 type(vector_t) :: z_coord
74 type(fld_file_output_t) :: output
83 generic,
public :: init => init_from_components
85 procedure, pass(this) :: init_from_components => &
86 design_simple_init_from_components
89 procedure, pass(this) :: add_mapping => design_simple_add_mapping
92 procedure, pass(this) :: get_values => design_simple_get_values
95 procedure, pass(this) :: design_get_x => design_simple_get_x
96 procedure, pass(this) :: design_get_y => design_simple_get_y
97 procedure, pass(this) :: design_get_z => design_simple_get_z
100 procedure, pass(this) :: update_design => design_simple_update_design
103 procedure, pass(this) :: map_forward => design_simple_map_forward
106 procedure, pass(this) :: map_backward => design_simple_map_backward
109 procedure, pass(this) :: write => design_simple_write
112 procedure, pass(this) :: free => design_simple_free
119 subroutine design_simple_init_from_components(this, n, x, y, z, neko_field)
121 integer,
intent(in) :: n
122 type(vector_t),
intent(in) :: x, y, z
123 type(field_t) :: neko_field
125 call this%init_base(
'simplefield_design', n)
130 this%designfield = neko_field
131 call this%output%init(sp,
'design', 1)
132 call this%output%fields%assign_to_field(1, this%designfield)
133 end subroutine design_simple_init_from_components
136 subroutine design_simple_free(this)
139 call this%free_base()
140 call this%x_coord%free()
141 call this%y_coord%free()
142 call this%z_coord%free()
144 call this%designfield%free()
145 end subroutine design_simple_free
148 subroutine design_simple_add_mapping(this, parameters, simulation)
150 type(json_file),
intent(inout) :: parameters
153 end subroutine design_simple_add_mapping
156 subroutine design_simple_map_forward(this)
160 end subroutine design_simple_map_forward
162 subroutine design_simple_get_values(this, values)
164 type(vector_t),
intent(inout) :: values
168 if (neko_bcknd_device .eq. 1)
then
169 call device_copy(values%x_d, this%designfield%x_d, n)
171 call copy(values%x, this%designfield%x, n)
173 end subroutine design_simple_get_values
175 subroutine design_simple_get_x(this, x)
177 type(vector_t),
intent(inout) :: x
180 end subroutine design_simple_get_x
182 subroutine design_simple_get_y(this, y)
184 type(vector_t),
intent(inout) :: y
187 end subroutine design_simple_get_y
189 subroutine design_simple_get_z(this, z)
191 type(vector_t),
intent(inout) :: z
194 end subroutine design_simple_get_z
198 subroutine design_simple_update_design(this, values)
200 type(vector_t),
intent(inout) :: values
204 if (neko_bcknd_device .eq. 1)
then
205 call device_copy(this%designfield%x_d, values%x_d, n)
207 call copy(this%designfield%x, values%x, n)
209 end subroutine design_simple_update_design
211 subroutine design_simple_map_backward(this, sensitivity)
213 type(vector_t),
intent(in) :: sensitivity
215 end subroutine design_simple_map_backward
217 subroutine design_simple_write(this, idx)
219 integer,
intent(in) :: idx
220 call this%output%sample(real(idx, kind=rp))
221 end subroutine design_simple_write
223end 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.