Neko-TOP
A portable framework for high-order spectral element flow toplogy optimization.
Loading...
Searching...
No Matches
topopt-user.f90
1program topopt_user
3 use problem, only: problem_t
4 use optimizer, only: optimizer_t, optimizer_factory
5 use json_module, only: json_file
6 use json_utils, only: json_extract_object
7 use json_utils_ext, only: json_read_file
8 use utils, only: neko_error
9 use user, only: user_setup
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 type(problem_t) :: prob
30 class(design_t), allocatable :: des
32 class(optimizer_t), allocatable :: opt
33
34 ! -------------------------------------------------------------------------- !
35 ! Initialize the MPI environment
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 ! initialize the user additions for the forward (through the neko interface)
54 call user_setup(sim%neko_case%user)
55
56 ! initialize the simulation
57 call sim%init(parameters)
58
59 ! initialize the design
60 call design_factory(des, parameters, sim)
61
62 ! initialize the problem
63 call prob%init(parameters, des, sim)
64
65 ! initialize the optimizer
66 call optimizer_factory(opt, parameters, prob, des, sim)
67
68 ! -------------------------------------------------------------------------- !
69 ! Execute the optimization
70
71 call opt%run(prob, des, sim)
72
73 ! -------------------------------------------------------------------------- !
74 ! Clean up the components
75
76 call opt%free()
77 if (allocated(opt)) deallocate(opt)
78
79 call prob%free()
80 call des%free()
81 call sim%free()
82
83end program topopt_user
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