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_FLUID_STRUCTURE_INTERACTION_SOLVER_H_
23#define INCLUDE_EXADG_FLUID_STRUCTURE_INTERACTION_SOLVER_H_
24
25// deal.II
26#include <deal.II/base/parameter_handler.h>
27
28// ExaDG
29#include <exadg/fluid_structure_interaction/driver.h>
30#include <exadg/fluid_structure_interaction/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 FSI::Parameters fsi_data;
45 fsi_data.add_parameters(prm);
46
47 // we have to assume a default dimension and default Number type
48 // for the automatic generation of a default input file
49 unsigned int const Dim = 2;
50 typedef double Number;
51
52 FSI::get_application<Dim, Number>(input_file, MPI_COMM_WORLD)->add_parameters(prm);
53
54 prm.print_parameters(input_file,
55 dealii::ParameterHandler::Short |
56 dealii::ParameterHandler::KeepDeclarationOrder);
57}
58
59template<int dim, typename Number>
60void
61run(std::string const & input_file, MPI_Comm const & mpi_comm, bool const is_test)
62{
63 dealii::Timer timer;
64 timer.restart();
65
66 std::shared_ptr<FSI::ApplicationBase<dim, Number>> application =
67 FSI::get_application<dim, Number>(input_file, mpi_comm);
68
69 std::shared_ptr<FSI::Driver<dim, Number>> driver =
70 std::make_shared<FSI::Driver<dim, Number>>(input_file, mpi_comm, application, is_test);
71
72 driver->setup();
73
74 driver->solve();
75
76 if(not(is_test))
77 driver->print_performance_results(timer.wall_time());
78}
79} // namespace ExaDG
80
81int
82main(int argc, char ** argv)
83{
84 dealii::Utilities::MPI::MPI_InitFinalize mpi(argc, argv, 1);
85
86 MPI_Comm mpi_comm(MPI_COMM_WORLD);
87
88 std::string input_file;
89
90 if(argc == 1)
91 {
92 if(dealii::Utilities::MPI::this_mpi_process(mpi_comm) == 0)
93 {
94 // clang-format off
95 std::cout << "To run the program, use: ./solver input_file" << std::endl
96 << "To setup the input file, use: ./solver input_file --help" << std::endl;
97 // clang-format on
98 }
99
100 return 0;
101 }
102 else if(argc >= 2)
103 {
104 input_file = std::string(argv[1]);
105
106 if(argc == 3 and std::string(argv[2]) == "--help")
107 {
108 if(dealii::Utilities::MPI::this_mpi_process(mpi_comm) == 0)
109 ExaDG::create_input_file(input_file);
110
111 return 0;
112 }
113 }
114
115 ExaDG::GeneralParameters general(input_file);
116
117 // run the simulation
118 if(general.dim == 2 and general.precision == "float")
119 {
120 ExaDG::run<2, float>(input_file, mpi_comm, general.is_test);
121 }
122 else if(general.dim == 2 and general.precision == "double")
123 {
124 ExaDG::run<2, double>(input_file, mpi_comm, general.is_test);
125 }
126 else if(general.dim == 3 and general.precision == "float")
127 {
128 ExaDG::run<3, float>(input_file, mpi_comm, general.is_test);
129 }
130 else if(general.dim == 3 and general.precision == "double")
131 {
132 ExaDG::run<3, double>(input_file, mpi_comm, general.is_test);
133 }
134 else
135 {
136 AssertThrow(false,
137 dealii::ExcMessage("Only dim = 2|3 and precision=float|double implemented."));
138 }
139
140 return 0;
141}
142
143#endif /* INCLUDE_EXADG_FLUID_STRUCTURE_INTERACTION_SOLVER_H_ */
Definition driver.cpp:33
Definition general_parameters.h:32