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 utils, only: neko_error
7 use json_utils_ext, only: json_read_file
8 use user, only: user_setup
10 use neko_top, only: neko_top_register_types
11
12 use mpi_f08, only: mpi_init
13
14 implicit none
15
16 ! JSON related arguments
17 integer :: argc
18 type(json_file) :: parameters
19 character(len=256) :: parameter_file
20
21 ! MPI parameters
22 integer :: ierr
23
25 type(simulation_t) :: sim
27 type(problem_t) :: prob
29 class(design_t), allocatable :: des
31 class(optimizer_t), allocatable :: opt
32
33 ! -------------------------------------------------------------------------- !
34 ! Initialize the MPI environment
35 call mpi_init(ierr)
36 call neko_top_register_types()
37
38 ! -------------------------------------------------------------------------- !
39 ! Read the parameters file as the first terminal argument
40
41 argc = command_argument_count()
42 if (argc .lt. 1) call neko_error('Missing parameter file')
43 call get_command_argument(1, parameter_file)
44
45 ! Read the parameters file
46 parameters = json_read_file(trim(parameter_file))
47
48 ! -------------------------------------------------------------------------- !
49 ! Initialization of the components
50
51 ! initialize the user additions for the forward (through the neko interface)
52 call user_setup(sim%neko_case%user)
53
54 ! initialize the simulation
55 call sim%init(parameters)
56
57 ! initialize the design
58 call design_factory(des, 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 if (allocated(opt)) deallocate(opt)
76
77 call prob%free()
78 call des%free()
79 call sim%free()
80
81end program topopt_user
Factory function for the design object.
Definition design.f90:136
Factory function for the optimizer.
Definition optimizer.f90:85
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:50
Abstract optimizer class.
Definition optimizer.f90:18
The abstract problem type.
Definition problem.f90:61