Neko-TOP
A portable framework for high-order spectral element flow toplogy optimization.
Loading...
Searching...
No Matches
topopt.f90
Go to the documentation of this file.
1
34
35program topopt
36 use simulation_m, only: simulation_t
38 use problem, only: problem_t
39 use optimizer, only: optimizer_t, optimizer_factory
40
41 use json_module, only: json_file
42 use json_utils, only: json_get
43 use utils, only: neko_error
44 use json_utils_ext, only: json_read_file
45 use neko_top, only: neko_top_register_types
46
47 use mpi_f08, only: mpi_init
48
49 implicit none
50
51 ! JSON related arguments
52 integer :: argc
53 character(len=256) :: parameter_file
54 type(json_file) :: parameters, design_parameters
55
56 ! MPI parameters
57 integer :: ierr
58
60 type(simulation_t) :: sim
62 class(design_t), allocatable :: des
64 type(problem_t) :: prob
66 class(optimizer_t), allocatable :: opt
67
68 ! -------------------------------------------------------------------------- !
69 ! Initialize the MPI environment
70
71 call mpi_init(ierr)
72 call neko_top_register_types()
73
74 ! -------------------------------------------------------------------------- !
75 ! Read the parameters file as the first terminal argument
76
77 argc = command_argument_count()
78 if (argc .lt. 1) call neko_error('Missing parameter file')
79 call get_command_argument(1, parameter_file)
80
81 ! Read the parameters file
82 parameters = json_read_file(trim(parameter_file))
83 call json_get(parameters, 'optimization.design', design_parameters)
84
85 ! -------------------------------------------------------------------------- !
86 ! Initialization of the components
87
88 ! initialize the simulation
89 call sim%init(parameters)
90
91 ! initialize the design
92 call design_factory(des, design_parameters, sim)
93
94 ! initialize the problem
95 call prob%init(parameters, des, sim)
96
97 ! initialize the optimizer
98 call optimizer_factory(opt, parameters, prob, des, sim)
99
100 ! -------------------------------------------------------------------------- !
101 ! Execute the optimization
102
103 call opt%run(prob, des, sim)
104
105 ! -------------------------------------------------------------------------- !
106 ! Clean up the components
107
108 call opt%free()
109 call prob%free()
110 call des%free()
111 call sim%free()
112
113 if (allocated(des)) deallocate(des)
114 if (allocated(opt)) deallocate(opt)
115
116end program topopt
Factory function for the design object.
Definition design.f90:157
Factory function for the optimizer.
Implements the design_t.
Definition design.f90:36
Module for handling the optimization problem.
Definition problem.f90:41
Implements the steady_problem_t type.
An abstract design type.
Definition design.f90:54
Abstract optimizer class.
Definition optimizer.f90:54
The abstract problem type.
Definition problem.f90:67