ExaDG
Loading...
Searching...
No Matches
throughput.h
1/* ______________________________________________________________________
2 *
3 * ExaDG - High-Order Discontinuous Galerkin for the Exa-Scale
4 *
5 * Copyright (C) 2021 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 EXADG_INCOMPRESSIBLE_NAVIER_STOKES_THROUGHPUT_H_
23#define EXADG_INCOMPRESSIBLE_NAVIER_STOKES_THROUGHPUT_H_
24
25// likwid
26#ifdef EXADG_WITH_LIKWID
27# include <likwid.h>
28#endif
29
30// ExaDG
31#include <exadg/incompressible_navier_stokes/driver.h>
32#include <exadg/incompressible_navier_stokes/user_interface/declare_get_application.h>
33#include <exadg/operators/hypercube_resolution_parameters.h>
34#include <exadg/operators/throughput_parameters.h>
35#include <exadg/utilities/general_parameters.h>
36
37namespace ExaDG
38{
39void
40create_input_file(std::string const & input_file)
41{
42 dealii::ParameterHandler prm;
43
44 GeneralParameters general;
45 general.add_parameters(prm);
46
48 resolution.add_parameters(prm);
49
51 throughput.add_parameters(prm);
52
53 try
54 {
55 // we have to assume a default dimension and default Number type
56 // for the automatic generation of a default input file
57 unsigned int const Dim = 2;
58 typedef double Number;
59 IncNS::get_application<Dim, Number>(input_file, MPI_COMM_WORLD)->add_parameters(prm);
60 }
61 catch(...)
62 {
63 }
64
65 prm.print_parameters(input_file,
66 dealii::ParameterHandler::Short |
67 dealii::ParameterHandler::KeepDeclarationOrder);
68}
69
70template<int dim, typename Number>
71void
73 std::string const & input_file,
74 unsigned int const degree,
75 unsigned int const refine_space,
76 unsigned int const n_cells_1d,
77 MPI_Comm const & mpi_comm,
78 bool const is_test)
79{
80 std::shared_ptr<IncNS::ApplicationBase<dim, Number>> application =
81 IncNS::get_application<dim, Number>(input_file, mpi_comm);
82
83 application->set_parameters_throughput_study(degree, refine_space, n_cells_1d);
84
85 std::shared_ptr<IncNS::Driver<dim, Number>> driver =
86 std::make_shared<IncNS::Driver<dim, Number>>(mpi_comm, application, is_test, true);
87
88 driver->setup();
89
90 std::tuple<unsigned int, dealii::types::global_dof_index, double> wall_time =
91 driver->apply_operator(throughput.operator_type,
92 throughput.n_repetitions_inner,
93 throughput.n_repetitions_outer);
94
95 throughput.wall_times.push_back(wall_time);
96}
97} // namespace ExaDG
98
99int
100main(int argc, char ** argv)
101{
102#ifdef EXADG_WITH_LIKWID
103 LIKWID_MARKER_INIT;
104#endif
105
106 dealii::Utilities::MPI::MPI_InitFinalize mpi(argc, argv, 1);
107
108 MPI_Comm mpi_comm(MPI_COMM_WORLD);
109
110 std::string input_file;
111
112 if(argc == 1)
113 {
114 if(dealii::Utilities::MPI::this_mpi_process(mpi_comm) == 0)
115 {
116 // clang-format off
117 std::cout << "To run the program, use: ./throughput input_file" << std::endl
118 << "To setup the input file, use: ./throughput input_file --help" << std::endl;
119 // clang-format on
120 }
121
122 return 0;
123 }
124 else if(argc >= 2)
125 {
126 input_file = std::string(argv[1]);
127
128 if(argc == 3 and std::string(argv[2]) == "--help")
129 {
130 if(dealii::Utilities::MPI::this_mpi_process(mpi_comm) == 0)
131 ExaDG::create_input_file(input_file);
132
133 return 0;
134 }
135 }
136
137 ExaDG::GeneralParameters general(input_file);
138 ExaDG::HypercubeResolutionParameters resolution(input_file, general.dim);
140
141 ExaDG::IncNS::PressureDegree pressure_degree = ExaDG::IncNS::PressureDegree::MixedOrder;
142
143 dealii::ParameterHandler prm;
144
145 prm.enter_subsection("Throughput");
146 {
147 prm.add_parameter("PressureDegree",
148 pressure_degree,
149 "Degree of pressure shape functions.",
150 ExaDG::Patterns::Enum<ExaDG::IncNS::PressureDegree>(),
151 true);
152 }
153 prm.leave_subsection();
154
155 prm.parse_input(input_file, "", true, true);
156
157 auto const lambda_get_dofs_per_element =
158 [&](unsigned int const dim, unsigned int const degree, ExaDG::ElementType const element_type) {
159 return ExaDG::IncNS::get_dofs_per_element(
160 throughput.operator_type, pressure_degree, dim, degree, element_type);
161 };
162
163 // fill resolution vector depending on the operator_type
164 resolution.fill_resolution_vector(lambda_get_dofs_per_element);
165
166 // loop over resolutions vector and run simulations
167 for(auto iter = resolution.resolutions.begin(); iter != resolution.resolutions.end(); ++iter)
168 {
169 unsigned int const degree = std::get<0>(*iter);
170 unsigned int const refine_space = std::get<1>(*iter);
171 unsigned int const n_cells_1d = std::get<2>(*iter);
172
173 if(general.dim == 2 and general.precision == "float")
174 {
175 ExaDG::run<2, float>(
176 throughput, input_file, degree, refine_space, n_cells_1d, mpi_comm, general.is_test);
177 }
178 else if(general.dim == 2 and general.precision == "double")
179 {
180 ExaDG::run<2, double>(
181 throughput, input_file, degree, refine_space, n_cells_1d, mpi_comm, general.is_test);
182 }
183 else if(general.dim == 3 and general.precision == "float")
184 {
185 ExaDG::run<3, float>(
186 throughput, input_file, degree, refine_space, n_cells_1d, mpi_comm, general.is_test);
187 }
188 else if(general.dim == 3 and general.precision == "double")
189 {
190 ExaDG::run<3, double>(
191 throughput, input_file, degree, refine_space, n_cells_1d, mpi_comm, general.is_test);
192 }
193 else
194 {
195 AssertThrow(false,
196 dealii::ExcMessage("Only dim = 2|3 and precision=float|double implemented."));
197 }
198 }
199
200 if(not(general.is_test))
201 throughput.print_results(mpi_comm);
202
203#ifdef EXADG_WITH_LIKWID
204 LIKWID_MARKER_CLOSE;
205#endif
206
207 return 0;
208}
209
210#endif /* EXADG_INCOMPRESSIBLE_NAVIER_STOKES_THROUGHPUT_H_ */
Definition driver.cpp:33
Definition general_parameters.h:34
Definition hypercube_resolution_parameters.h:183
Definition throughput_parameters.h:91