Neko-TOP
A portable framework for high-order spectral element flow toplogy optimization.
Loading...
Searching...
No Matches
neko_top.f90
Go to the documentation of this file.
1module neko_top
2
3 ! External modules
4 use case, only: case_t
5 use neko, only: neko_init, neko_finalize
6 use simcomp_executor, only: simcomp_executor_t
7 use json_module, only: json_file, json_value, json_core
8 use comm, only: pe_rank
9 use utils, only: neko_error, filename_suffix
10 use user_intf, only: simulation_component_user_settings
11 use num_types, only: rp
12 use logger, only: neko_log
13 use neko, only: neko_solve
14 use neko_ext, only: setup_iteration
15 use json_utils, only: json_get_or_default
17
18 use design_module, only: design_t
19 use sensitivity, only: sensitivity_t
21
22 implicit none
23 private
25
26 type(simcomp_executor_t) :: topopt_components
27
28contains
29
31 subroutine neko_top_init(neko_case)
32 type(case_t), intent(inout) :: neko_case
33 type(json_file) :: design_params
34 type(design_t), allocatable :: design
35 type(json_value), pointer :: simcomp_object
36 type(json_file) :: comp_subdict
37 logical :: found
38 type(json_core) :: core
39
40 call neko_log%section('Initialize Topology Optimization')
41
42 ! ------------------------------------------------------------------------ !
43 ! Initialize the neko solver
44 ! ------------------------------------------------------------------------ !
45
46 call neko_log%section('Neko')
47
48 call neko_user_init(neko_case)
49 call neko_init(neko_case)
50
51 call neko_log%end()
52
53 ! ------------------------------------------------------------------------ !
54 ! Initialize the topopt components
55 ! ------------------------------------------------------------------------ !
56
57 call neko_log%section('Topology Optimization Components')
58
59 call topopt_components%init(neko_case, 'topology_optimization.components')
60
61 call neko_case%params%get_core(core)
62 call neko_case%params%get('topology_optimization.components', &
63 simcomp_object, found)
64 comp_subdict = json_file(simcomp_object)
65
66 ! Allocation of the design
67 allocate(design)
68 design_params = simulation_component_user_settings('design', comp_subdict)
69 call topopt_components%add_user_simcomp(design, design_params)
70
71 call neko_log%end()
72 end subroutine neko_top_init
73
74 subroutine neko_top_solve(neko_case)
75 type(case_t), intent(inout) :: neko_case
76
77 integer :: iter, max_iter
78
79 ! Convergence parameter
80 logical :: converged = .false.
81
82 call json_get_or_default(neko_case%params, &
83 'case.topology_optimization.max_iter', &
84 max_iter, 4)
85
86 do iter = 1, max_iter
87 call setup_iteration(neko_case, iter)
88
89 call topopt_components%preprocess(0.0_rp, 1)
90
91 ! Forward analysis
92 call neko_solve(neko_case)
93
94
95
96 ! If converged, exit the loop
97 if (converged) exit
98
99 ! Call the design update routine
100
101
102 call topopt_components%compute(0.0_rp, 1)
103
104 if (converged) exit
105 end do
106 end subroutine neko_top_solve
107
108 subroutine neko_top_finalize(neko_case)
109 type(case_t), intent(inout) :: neko_case
110
111 logical :: temperature_enabled
112
113 ! ---------------------------------------------------------------------- !
114 ! Compute the outlet area-weighted average temperature
115 ! ---------------------------------------------------------------------- !
116 ! Read the case file for options
117 call json_get_or_default(neko_case%params, 'case.scalar.enabled', &
118 temperature_enabled, .false.)
119
120 if (temperature_enabled) then
121 call estimate_temperature(neko_case)
122 end if
123
124 ! ---------------------------------------------------------------------- !
125 ! Save the design
126 ! ---------------------------------------------------------------------- !
127
128 call neko_finalize(neko_case)
129 call neko_log%end()
130
131 end subroutine neko_top_finalize
132
133end module neko_top
134
Implements the design_t.
Definition design.f90:34
subroutine estimate_temperature(neko_case)
Definition develop.f90:234
Contains extensions to the neko library required to run the topology optimization code.
Definition neko_ext.f90:9
subroutine, public setup_iteration(neko_case, iter)
Setup the iteration.
Definition neko_ext.f90:154
subroutine, public neko_top_init(neko_case)
Register user defined functions (see nekos user_intf.f90)
Definition neko_top.f90:32
subroutine, public neko_top_solve(neko_case)
Definition neko_top.f90:75
subroutine, public neko_top_finalize(neko_case)
Definition neko_top.f90:109
type(simcomp_executor_t) topopt_components
Definition neko_top.f90:26
Sensitivity module. This module contains the sensitivity computation of the topology optimization.
Module designed to setup the topology optimization user interface for Neko. This module should initia...
subroutine, public neko_user_init(neko_case)
Assign user conditions for the neko case.
The topology type, which is used to describe the designs in topology optimization.
Definition design.f90:59