35 use num_types,
only: rp, sp
36 use field,
only: field_t
40 use coefs,
only: coef_t
41 use scratch_registry,
only: neko_scratch_registry
42 use fld_file_output,
only: fld_file_output_t
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
51 use comm,
only: pe_size
52 use json_module,
only: json_file
53 use json_utils,
only: json_get, json_get_or_default
55 use vector,
only: vector_t
57 use field_registry,
only: neko_field_registry
58 use utils,
only:neko_error
66 type(vector_t) :: values
67 type(vector_t) :: x_coord
68 type(vector_t) :: y_coord
69 type(vector_t) :: z_coord
77 generic,
public :: init => init_from_json, init_from_components
79 procedure, pass(this) :: init_from_json => &
80 design_simple_init_from_json
82 procedure, pass(this) :: init_from_components => &
83 design_simple_init_from_components
86 procedure, pass(this) :: add_mapping => design_simple_add_mapping
89 procedure, pass(this) :: get_values => design_simple_get_values
91 procedure, pass(this) :: design_get_x => design_simple_get_x
93 procedure, pass(this) :: design_get_y => design_simple_get_y
95 procedure, pass(this) :: design_get_z => design_simple_get_z
98 procedure, pass(this) :: update_design => design_simple_update_design
101 procedure, pass(this) :: map_forward => design_simple_map_forward
104 procedure, pass(this) :: map_backward => design_simple_map_backward
107 procedure, pass(this) :: write => design_simple_write
110 procedure, pass(this) :: free => design_simple_free
117 subroutine design_simple_init_from_json(this, parameters)
119 type(json_file),
intent(inout) :: parameters
120 character(len=:),
allocatable ::
type, name
121 integer :: n, nx, ny, nz, i, j, k
122 real(kind=rp),
dimension(:),
allocatable :: limits
123 type(vector_t) :: x, y, z
125 call json_get(parameters,
'domain.type', type)
126 call json_get_or_default(parameters,
'name', name,
'Simple Design')
128 select case (trim(type))
130 call json_get(parameters,
'domain.nx', nx)
131 call json_get(parameters,
'domain.ny', ny)
132 call json_get(parameters,
'domain.nz', nz)
133 call json_get(parameters,
'domain.limits', limits)
143 x%x(i) = limits(1) + (limits(2) - limits(1)) * &
144 real(i - 1, kind=rp) / real(nx, kind=rp)
145 y%x(i) = limits(3) + (limits(4) - limits(3)) * &
146 real(j - 1, kind=rp) / real(ny, kind=rp)
147 z%x(i) = limits(5) + (limits(6) - limits(5)) * &
148 real(k - 1, kind=rp) / real(nz, kind=rp)
155 call this%init_from_components(name, n, x, y, z)
157 end subroutine design_simple_init_from_json
159 subroutine design_simple_init_from_components(this, name, n, x, y, z)
161 character(len=*),
intent(in) :: name
162 integer,
intent(in) :: n
163 type(vector_t),
intent(in) :: x, y, z
165 if (pe_size .ne. 1)
then
166 call neko_error(
"Simple design can only be used with a single MPI " // &
170 call this%init_base(name, n)
172 call this%values%init(n)
177 end subroutine design_simple_init_from_components
180 subroutine design_simple_free(this)
183 call this%free_base()
184 call this%values%free()
185 call this%x_coord%free()
186 call this%y_coord%free()
187 call this%z_coord%free()
189 end subroutine design_simple_free
192 subroutine design_simple_add_mapping(this, parameters, simulation)
194 type(json_file),
intent(inout) :: parameters
197 end subroutine design_simple_add_mapping
200 subroutine design_simple_map_forward(this)
204 end subroutine design_simple_map_forward
206 subroutine design_simple_get_values(this, values)
208 type(vector_t),
intent(inout) :: values
212 end subroutine design_simple_get_values
214 subroutine design_simple_get_x(this, x)
216 type(vector_t),
intent(inout) :: x
220 end subroutine design_simple_get_x
222 subroutine design_simple_get_y(this, y)
224 type(vector_t),
intent(inout) :: y
228 end subroutine design_simple_get_y
230 subroutine design_simple_get_z(this, z)
232 type(vector_t),
intent(inout) :: z
236 end subroutine design_simple_get_z
238 subroutine design_simple_update_design(this, values)
240 type(vector_t),
intent(inout) :: values
244 end subroutine design_simple_update_design
246 subroutine design_simple_map_backward(this, sensitivity)
248 type(vector_t),
intent(in) :: sensitivity
250 end subroutine design_simple_map_backward
252 subroutine design_simple_write(this, idx)
254 integer,
intent(in) :: idx
256 end subroutine design_simple_write
258end module simple_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.