Neko-TOP
A portable framework for high-order spectral element flow toplogy optimization.
Loading...
Searching...
No Matches
topopt-user.f90
1program topopt_user
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 use user, only: user_setup
13
14 use mpi_f08, only: mpi_init
15
16 implicit none
17
18 ! JSON related arguments
19 integer :: argc
20 character(len=256) :: parameter_file
21 type(json_file) :: parameters, design_parameters
22
23 ! MPI parameters
24 integer :: ierr
25
27 type(simulation_t) :: sim
29 class(design_t), allocatable :: des
31 type(problem_t) :: prob
33 class(optimizer_t), allocatable :: opt
34
35 ! -------------------------------------------------------------------------- !
36 ! Initialize the MPI environment
37
38 call mpi_init(ierr)
39 call neko_top_register_types()
40
41 ! -------------------------------------------------------------------------- !
42 ! Read the parameters file as the first terminal argument
43
44 argc = command_argument_count()
45 if (argc .lt. 1) call neko_error('Missing parameter file')
46 call get_command_argument(1, parameter_file)
47
48 ! Read the parameters file
49 parameters = json_read_file(trim(parameter_file))
50 call json_get(parameters, 'optimization.design', design_parameters)
51
52 ! -------------------------------------------------------------------------- !
53 ! Initialization of the components
54
55 ! initialize the user additions for the forward (through the neko interface)
56 call user_setup(sim%neko_case%user)
57
58 ! initialize the simulation
59 call sim%init(parameters)
60
61 ! initialize the design
62 call design_factory(des, design_parameters, sim)
63
64 ! initialize the problem
65 call prob%init(parameters, des, sim)
66
67 ! initialize the optimizer
68 call optimizer_factory(opt, parameters, prob, des, sim)
69
70 ! -------------------------------------------------------------------------- !
71 ! Execute the optimization
72
73 call opt%run(prob, des, sim)
74
75 ! -------------------------------------------------------------------------- !
76 ! Clean up the components
77
78 call opt%free()
79 call prob%free()
80 call des%free()
81 call sim%free()
82
83 if (allocated(des)) deallocate(des)
84 if (allocated(opt)) deallocate(opt)
85
86end 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