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_extract_object
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 implicit none
15
16 ! JSON related arguments
17 integer :: argc
18 character(len=256) :: parameter_file
19 type(json_file) :: parameters, design_parameters
20
21 ! MPI parameters
22 integer :: ierr
23
25 type(simulation_t) :: sim
27 class(design_t), allocatable :: des
29 type(problem_t) :: prob
31 class(optimizer_t), allocatable :: opt
32
33 ! -------------------------------------------------------------------------- !
34 ! Initialize the MPI environment
35
36 call mpi_init(ierr)
37 call neko_top_register_types()
38
39 ! -------------------------------------------------------------------------- !
40 ! Read the parameters file as the first terminal argument
41
42 argc = command_argument_count()
43 if (argc .lt. 1) call neko_error('Missing parameter file')
44 call get_command_argument(1, parameter_file)
45
46 ! Read the parameters file
47 parameters = json_read_file(trim(parameter_file))
48 call json_extract_object(parameters, 'optimization.design', design_parameters)
49
50 ! -------------------------------------------------------------------------- !
51 ! Initialization of the components
52
53 call sim%init(parameters)
54 call design_factory(des, design_parameters, sim)
55 call prob%init(parameters, des, sim)
56 call optimizer_factory(opt, parameters, prob, des, sim)
57
58 ! -------------------------------------------------------------------------- !
59 ! Execute the optimization
60
61 call opt%run(prob, des, sim)
62
63 ! -------------------------------------------------------------------------- !
64 ! Clean up the components
65
66 call opt%free()
67 call prob%free()
68 call des%free()
69 call sim%free()
70
71 if (allocated(des)) deallocate(des)
72 if (allocated(opt)) deallocate(opt)
73
74end 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