Neko-TOP
A portable framework for high-order spectral element flow toplogy optimization.
Loading...
Searching...
No Matches
design_simple.f90
Go to the documentation of this file.
1! Copyright (c) 2024, The Neko Authors
2! All rights reserved.
3!
4! Redistribution and use in source and binary forms, with or without
5! modification, are permitted provided that the following conditions
6! are met:
7!
8! * Redistributions of source code must retain the above copyright
9! notice, this list of conditions and the following disclaimer.
10!
11! * Redistributions in binary form must reproduce the above
12! copyright notice, this list of conditions and the following
13! disclaimer in the documentation and/or other materials provided
14! with the distribution.
15!
16! * Neither the name of the authors nor the names of its
17! contributors may be used to endorse or promote products derived
18! from this software without specific prior written permission.
19!
20! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21! "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23! FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24! COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25! INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26! BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27! LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28! CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29! LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30! ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31! POSSIBILITY OF SUCH DAMAGE.
32
33! Implements the `simple_design_t` type.
35 use num_types, only: rp, sp
36 use field, only: field_t
37 use json_module, only: json_file
38 use mapping, only: mapping_t
39 use pde_filter, only: pde_filter_t
41 use coefs, only: coef_t
42 use scratch_registry, only: neko_scratch_registry
43 use fld_file_output, only: fld_file_output_t
44 use point_zone_registry, only: neko_point_zone_registry
45 use point_zone, only: point_zone_t
47 use neko_config, only: neko_bcknd_device
48 use device, only: device_memcpy, host_to_device
49 use design, only: design_t
50 use math, only: rzero
51 use simulation, only: simulation_t
52 use json_module, only: json_file
53 use json_utils, only: json_get
55 use vector, only: vector_t
56 use math, only: copy
57 use field_registry, only: neko_field_registry
58 implicit none
59 private
60
62 type, extends(design_t), public :: simple_design_t
63 private
64
65 type(vector_t) :: x
66
67 contains
68
69 ! ----------------------------------------------------------------------- !
70 ! Initializations
71
73 generic, public :: init => init_from_json, init_from_components
75 procedure, pass(this) :: init_from_json => &
78 procedure, pass(this) :: init_from_components => &
80
82 procedure, pass(this) :: add_mapping => design_simple_add_mapping
83
85 procedure, pass(this) :: get_design => design_simple_get_design
86
88 procedure, pass(this) :: update_design => design_simple_update_design
89
91 procedure, pass(this) :: map_forward => design_simple_map_forward
92
94 procedure, pass(this) :: map_backward => design_simple_map_backward
95
97 procedure, pass(this) :: write => design_simple_write
98
100 procedure, pass(this) :: free => design_simple_free
101
102 end type simple_design_t
103
104contains
105
107 subroutine design_simple_init_from_json(this, parameters)
108 class(simple_design_t), intent(inout) :: this
109 type(json_file), intent(inout) :: parameters
110 integer :: n
111
112 call json_get(parameters, 'design.n', n)
113
114 call this%init_from_components(n)
115
116 end subroutine design_simple_init_from_json
117
119 subroutine design_simple_free(this)
120 class(simple_design_t), intent(inout) :: this
121
122 call this%free_base()
123 call this%x%free()
124
125 end subroutine design_simple_free
126
128 class(simple_design_t), intent(inout) :: this
129 integer, intent(in) :: n
130
131 call this%init_base(n)
132 call this%x%init(n)
133 this%x = 0.0_rp
134
136
138 subroutine design_simple_add_mapping(this, parameters, simulation)
139 class(simple_design_t), intent(inout) :: this
140 type(json_file), intent(inout) :: parameters
141 type(simulation_t), intent(inout) :: simulation
142
143 end subroutine design_simple_add_mapping
144
145
147 class(simple_design_t), intent(inout) :: this
148
149
150 end subroutine design_simple_map_forward
151
152 function design_simple_get_design(this) result(x)
153 class(simple_design_t), intent(in) :: this
154 type(vector_t) :: x
155
156 x = this%x
157 end function design_simple_get_design
158
159 subroutine design_simple_update_design(this, x)
160 class(simple_design_t), intent(inout) :: this
161 type(vector_t), intent(inout) :: x
162
163 this%x = x
164
165 end subroutine design_simple_update_design
166
167 subroutine design_simple_map_backward(this, sensitivity)
168 class(simple_design_t), intent(inout) :: this
169 type(vector_t), intent(in) :: sensitivity
170
171 end subroutine design_simple_map_backward
172
173 subroutine design_simple_write(this, idx)
174 class(simple_design_t), intent(inout) :: this
175 integer, intent(in) :: idx
176
177 end subroutine design_simple_write
178
179end module simple_design
Implements the design_t.
Definition design.f90:34
Mappings to be applied to a scalar field.
Definition mapping.f90:35
Some common Masking operations we may need.
Definition mask_ops.f90:34
A PDE based filter.
A RAMP mapping of coefficients.
Implements the simple_brinkman_source_term_t type.
subroutine design_simple_map_forward(this)
type(vector_t) function design_simple_get_design(this)
subroutine design_simple_init_from_json(this, parameters)
Initialize the design from a JSON file.
subroutine design_simple_init_from_components(this, n)
subroutine design_simple_update_design(this, x)
subroutine design_simple_add_mapping(this, parameters, simulation)
Add mappings to the design.
subroutine design_simple_write(this, idx)
subroutine design_simple_map_backward(this, sensitivity)
subroutine design_simple_free(this)
Free the design.
Implements the steady_problem_t type.
An abstract design type.
Definition design.f90:48
Base abstract class for mapping.
Definition mapping.f90:44
A PDE based filter mapping $\rho \mapsto \tilde{\rho}$, see Lazarov & O. Sigmund 2010,...
A RAMP mapping of coefficients This is the standard RAMP described in https://doi....
A topology optimization design variable.