Neko-TOP
A portable framework for high-order spectral element flow toplogy optimization.
Loading...
Searching...
No Matches
topopt.f90
1program topopt
4 use problem, only: problem_t
5 use optimizer, only: optimizer_t, optimizer_factory
6
7 use json_module, only: json_file
8 use json_utils, only: json_get
9 use utils, only: neko_error
10 use json_utils_ext, only: json_read_file
11 use neko_top, only: neko_top_register_types
12
13 use mpi_f08, only: mpi_init
14
15 implicit none
16
17 ! JSON related arguments
18 integer :: argc
19 character(len=256) :: parameter_file
20 type(json_file) :: parameters, design_parameters
21
22 ! MPI parameters
23 integer :: ierr
24
26 type(simulation_t) :: sim
28 class(design_t), allocatable :: des
30 type(problem_t) :: prob
32 class(optimizer_t), allocatable :: opt
33
34 ! -------------------------------------------------------------------------- !
35 ! Initialize the MPI environment
36
37 call mpi_init(ierr)
38 call neko_top_register_types()
39
40 ! -------------------------------------------------------------------------- !
41 ! Read the parameters file as the first terminal argument
42
43 argc = command_argument_count()
44 if (argc .lt. 1) call neko_error('Missing parameter file')
45 call get_command_argument(1, parameter_file)
46
47 ! Read the parameters file
48 parameters = json_read_file(trim(parameter_file))
49 call json_get(parameters, 'optimization.design', design_parameters)
50
51 ! -------------------------------------------------------------------------- !
52 ! Initialization of the components
53
54 ! initialize the simulation
55 call sim%init(parameters)
56
57 ! initialize the design
58 call design_factory(des, design_parameters, sim)
59
60 ! initialize the problem
61 call prob%init(parameters, des, sim)
62
63 ! initialize the optimizer
64 call optimizer_factory(opt, parameters, prob, des, sim)
65
66 ! -------------------------------------------------------------------------- !
67 ! Execute the optimization
68
69 call opt%run(prob, des, sim)
70
71 ! -------------------------------------------------------------------------- !
72 ! Clean up the components
73
74 call opt%free()
75 call prob%free()
76 call des%free()
77 call sim%free()
78
79 if (allocated(des)) deallocate(des)
80 if (allocated(opt)) deallocate(opt)
81
82end program topopt
Factory function for the design object.
Definition design.f90:155
Factory function for the optimizer.
Definition optimizer.f90:96
Implements the design_t.
Definition design.f90:34
Module for handling the optimization problem.
Definition problem.f90:35
Implements the steady_problem_t type.
An abstract design type.
Definition design.f90:52
Abstract optimizer class.
Definition optimizer.f90:18
The abstract problem type.
Definition problem.f90:61