ExaDG
Loading...
Searching...
No Matches
solver.h
1/* ______________________________________________________________________
2 *
3 * ExaDG - High-Order Discontinuous Galerkin for the Exa-Scale
4 *
5 * Copyright (C) 2023 by the ExaDG authors
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 * ______________________________________________________________________
20 */
21
22#ifndef INCLUDE_EXADG_AERO_ACOUSTIC_SOLVER_H_
23#define INCLUDE_EXADG_AERO_ACOUSTIC_SOLVER_H_
24
25// deal.II
26#include <deal.II/base/parameter_handler.h>
27
28// ExaDG
29#include <exadg/aero_acoustic/driver.h>
30#include <exadg/aero_acoustic/user_interface/declare_get_application.h>
31#include <exadg/utilities/enum_patterns.h>
32#include <exadg/utilities/general_parameters.h>
33
34namespace ExaDG
35{
36void
37create_input_file(std::string const & input_file)
38{
39 dealii::ParameterHandler prm;
40
41 GeneralParameters general;
42 general.add_parameters(prm);
43
44 // we have to assume a default dimension and default Number type
45 // for the automatic generation of a default input file
46 unsigned int const Dim = 2;
47 using Number = double;
48
49 auto app = AeroAcoustic::get_application<Dim, Number>(input_file, MPI_COMM_WORLD);
50 app->add_parameters(prm);
51
52 prm.print_parameters(input_file,
53 dealii::ParameterHandler::Short |
54 dealii::ParameterHandler::KeepDeclarationOrder);
55}
56
57template<int dim, typename Number>
58void
59run(std::string const & input_file, MPI_Comm const & mpi_comm, bool const is_test)
60{
61 dealii::Timer timer;
62 timer.restart();
63
64 auto application = AeroAcoustic::get_application<dim, Number>(input_file, mpi_comm);
65
66 auto driver = std::make_shared<AeroAcoustic::Driver<dim, Number>>(mpi_comm, application, is_test);
67
68 driver->setup();
69
70 driver->solve();
71
72 if(not(is_test))
73 driver->print_performance_results(timer.wall_time());
74}
75} // namespace ExaDG
76
77int
78main(int argc, char ** argv)
79{
80 dealii::Utilities::MPI::MPI_InitFinalize mpi(argc, argv, 1);
81
82 MPI_Comm mpi_comm(MPI_COMM_WORLD);
83
84 std::string input_file;
85
86 if(argc == 1)
87 {
88 if(dealii::Utilities::MPI::this_mpi_process(mpi_comm) == 0)
89 {
90 // clang-format off
91 std::cout << "To run the program, use: ./solver input_file" << std::endl
92 << "To setup the input file, use: ./solver input_file --help" << std::endl;
93 // clang-format on
94 }
95
96 return 0;
97 }
98 else if(argc >= 2)
99 {
100 input_file = std::string(argv[1]);
101
102 if(argc == 3 and std::string(argv[2]) == "--help")
103 {
104 if(dealii::Utilities::MPI::this_mpi_process(mpi_comm) == 0)
105 ExaDG::create_input_file(input_file);
106
107 return 0;
108 }
109 }
110
111 ExaDG::GeneralParameters general(input_file);
112
113 // run the simulation
114 if(general.dim == 2 and general.precision == "float")
115 {
116 ExaDG::run<2, float>(input_file, mpi_comm, general.is_test);
117 }
118 else if(general.dim == 2 and general.precision == "double")
119 {
120 ExaDG::run<2, double>(input_file, mpi_comm, general.is_test);
121 }
122 else if(general.dim == 3 and general.precision == "float")
123 {
124 ExaDG::run<3, float>(input_file, mpi_comm, general.is_test);
125 }
126 else if(general.dim == 3 and general.precision == "double")
127 {
128 ExaDG::run<3, double>(input_file, mpi_comm, general.is_test);
129 }
130 else
131 {
132 AssertThrow(false,
133 dealii::ExcMessage("Only dim = 2|3 and precision=float|double implemented."));
134 }
135
136 return 0;
137}
138
139#endif /* INCLUDE_EXADG_AERO_ACOUSTIC_SOLVER_H_ */
Definition driver.cpp:33
Definition general_parameters.h:32