Neko-TOP
A portable framework for high-order spectral element flow toplogy optimization.
Loading...
Searching...
No Matches
design.f90
Go to the documentation of this file.
1! Copyright (c) 2024-2025, 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
34module design
35 use json_module, only: json_file
36 use simulation, only: simulation_t
37 use vector, only: vector_t
38 use utils, only: neko_error
39 implicit none
40 private
41
48 type, abstract :: design_t
49 private
50
52 integer :: n = 0
53
54 contains
55
56 ! ----------------------------------------------------------------------- !
57 ! Interfaces
58
68 procedure, pass(this) :: init_from_json_sim => design_init_from_json_sim
69
77 procedure, pass(this) :: init_from_json => design_init_from_json
78
80 procedure(design_free), public, pass(this), deferred :: free
81
83 procedure(design_get_design), public, pass(this), deferred :: get_design
85 procedure(design_update_design), public, pass(this), deferred :: &
86 update_design
87
89 procedure(design_map_forward), public, pass(this), deferred :: &
90 map_forward
92 procedure(design_map_backward), public, pass(this), deferred :: &
93 map_backward
95 procedure(design_write), public, pass(this), deferred :: write
96
97 ! ----------------------------------------------------------------------- !
98 ! Methods
99
101 procedure, pass(this) :: init_base => design_init_base
103 procedure, pass(this) :: free_base => design_free_base
105 procedure, public, pass(this) :: size => design_size
106
107 end type design_t
108
109 ! ========================================================================== !
110 ! Interface for the factory function
111
122 module subroutine design_factory(object, parameters, simulation)
123 class(design_t), allocatable, intent(inout) :: object
124 type(json_file), intent(inout) :: parameters
125 type(simulation_t), intent(inout), optional :: simulation
126 end subroutine design_factory
127 end interface design_factory
128
129
130 ! ========================================================================== !
131 ! Public interface for the deferred methods
132
133 abstract interface
134 subroutine design_free(this)
135 import design_t
136 class(design_t), intent(inout) :: this
137 end subroutine design_free
138
139 function design_get_design(this) result(x)
140 import design_t, vector_t
141 class(design_t), intent(in) :: this
142 type(vector_t) :: x
143 end function design_get_design
144
145 subroutine design_update_design(this, x)
146 import design_t, vector_t
147 class(design_t), intent(inout) :: this
148 type(vector_t), intent(inout) :: x
149 end subroutine design_update_design
150
151 subroutine design_map_forward(this)
152 import design_t
153 class(design_t), intent(inout) :: this
154 end subroutine design_map_forward
155
156 subroutine design_map_backward(this, sensitivity)
157 import design_t, vector_t
158 class(design_t), intent(inout) :: this
159 type(vector_t), intent(in) :: sensitivity
160 end subroutine design_map_backward
161
162 subroutine design_write(this, idx)
163 import design_t
164 class(design_t), intent(inout) :: this
165 integer, intent(in) :: idx
166 end subroutine design_write
167 end interface
168
169 public :: design_t, design_factory
170contains
171
173 subroutine design_init_from_json(this, parameters)
174 class(design_t), intent(inout) :: this
175 type(json_file), intent(inout) :: parameters
176
177 call neko_error("Design type does not support initialization &
178 &without simulation")
179 end subroutine design_init_from_json
180
182 subroutine design_init_from_json_sim(this, parameters, simulation)
183 class(design_t), intent(inout) :: this
184 type(json_file), intent(inout) :: parameters
185 type(simulation_t), intent(inout) :: simulation
186
187 call neko_error("Design type does not support initialization &
188 &with simulation")
189 end subroutine design_init_from_json_sim
190
192 subroutine design_init_base(this, n)
193 class(design_t), intent(inout) :: this
194 integer, intent(in) :: n
195 this%n = n
196 end subroutine design_init_base
197
199 subroutine design_free_base(this)
200 class(design_t), intent(inout) :: this
201 this%n = 0
202 end subroutine design_free_base
203
205 pure function design_size(this) result(n)
206 class(design_t), intent(in) :: this
207 integer :: n
208 n = this%n
209 end function design_size
210
211end module design
Factory function for the design object.
Definition design.f90:121
Implements the design_t.
Definition design.f90:34
pure integer function design_size(this)
Return the number of design variables.
Definition design.f90:206
subroutine design_init_from_json_sim(this, parameters, simulation)
Dummy initialization from JSON.
Definition design.f90:183
subroutine design_free_base(this)
Free the base design.
Definition design.f90:200
subroutine design_init_base(this, n)
Initialize the base design.
Definition design.f90:193
subroutine design_init_from_json(this, parameters)
Dummy initialization from JSON.
Definition design.f90:174
Implements the steady_problem_t type.
An abstract design type.
Definition design.f90:48