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