ExaDG
Loading...
Searching...
No Matches
solver.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_POISSON_OVERSET_GRIDS_SOLVER_H_
23#define EXADG_POISSON_OVERSET_GRIDS_SOLVER_H_
24
25// ExaDG
26#include <exadg/poisson/overset_grids/driver.h>
27#include <exadg/poisson/overset_grids/user_interface/declare_get_application.h>
28#include <exadg/utilities/general_parameters.h>
29
30namespace ExaDG
31{
32void
33create_input_file(std::string const & input_file)
34{
35 dealii::ParameterHandler prm;
36
37 GeneralParameters general;
38 general.add_parameters(prm);
39
40 // we have to assume a default dimension and default Number type
41 // for the automatic generation of a default input file
42 unsigned int const Dim = 2;
43 typedef double Number;
44 Poisson::OversetGrids::get_application_overset_grids<Dim, 1, Number>(input_file, MPI_COMM_WORLD)
45 ->add_parameters(prm);
46
47 prm.print_parameters(input_file,
48 dealii::ParameterHandler::Short |
49 dealii::ParameterHandler::KeepDeclarationOrder);
50}
51
52template<int dim, int n_components, typename Number>
53void
54run(std::string const & input_file, MPI_Comm const & mpi_comm)
55{
56 std::shared_ptr<Poisson::OversetGrids::ApplicationBase<dim, n_components, Number>> application =
57 Poisson::OversetGrids::get_application_overset_grids<dim, n_components, Number>(input_file,
58 mpi_comm);
59
60 std::shared_ptr<Poisson::OversetGrids::Driver<dim, n_components, Number>> driver =
61 std::make_shared<Poisson::OversetGrids::Driver<dim, n_components, Number>>(mpi_comm,
62 application);
63
64 driver->setup();
65
66 driver->solve();
67}
68} // namespace ExaDG
69
70int
71main(int argc, char ** argv)
72{
73 dealii::Utilities::MPI::MPI_InitFinalize mpi(argc, argv, 1);
74
75 MPI_Comm mpi_comm(MPI_COMM_WORLD);
76
77 std::string input_file;
78
79 if(argc == 1)
80 {
81 if(dealii::Utilities::MPI::this_mpi_process(mpi_comm) == 0)
82 {
83 std::cout << "To run the program, use: ./solver input_file" << std::endl
84 << "To setup the input file, use: ./solver input_file --help" << std::endl;
85 }
86
87 return 0;
88 }
89 else if(argc >= 2)
90 {
91 input_file = std::string(argv[1]);
92
93 if(argc == 3 and std::string(argv[2]) == "--help")
94 {
95 if(dealii::Utilities::MPI::this_mpi_process(mpi_comm) == 0)
96 ExaDG::create_input_file(input_file);
97
98 return 0;
99 }
100 }
101
102 ExaDG::GeneralParameters general(input_file);
103
104 if(general.dim == 2 and general.precision == "float")
105 ExaDG::run<2, 1, float>(input_file, mpi_comm);
106 else if(general.dim == 2 and general.precision == "double")
107 ExaDG::run<2, 1, double>(input_file, mpi_comm);
108 else if(general.dim == 3 and general.precision == "float")
109 ExaDG::run<3, 1, float>(input_file, mpi_comm);
110 else if(general.dim == 3 and general.precision == "double")
111 ExaDG::run<3, 1, double>(input_file, mpi_comm);
112 else
113 AssertThrow(false,
114 dealii::ExcMessage("Only dim = 2|3 and precision = float|double implemented."));
115
116 return 0;
117}
118
119#endif /* EXADG_POISSON_OVERSET_GRIDS_SOLVER_H_ */
Definition driver.cpp:33
Definition general_parameters.h:34