8#include <compile_time_options.h>
12#include <deal.II/base/mpi.h>
13#include <deal.II/base/parameter_acceptor.h>
15#include <boost/signals2.hpp>
24 inline const std::string
dave =
25 "\nDave, this conversation can serve no purpose anymore. Goodbye.\n\n";
37 : ParameterAcceptor(
"B - Equation")
40 add_parameter(
"dimension", dimension_,
"The spatial dimension");
41 add_parameter(
"equation", equation_,
"The PDE system");
43 time_loop_executed_ =
false;
54 dave +
"No equation has been registered. Consequently, "
55 "there is nothing for us to do.\n"));
64 template <
typename Callable>
77 void dispatch(
const std::string ¶meter_file,
const MPI_Comm &mpi_comm)
79 ParameterAcceptor::prm.parse_input(parameter_file,
84 AssertThrow(dimension_ >= 1 && dimension_ <= 3,
85 dealii::ExcMessage(
dave +
86 "The dimension parameter needs to be "
87 "either 1, 2, or 3, but we encountered »" +
88 std::to_string(dimension_) +
"«\n"));
92 dave +
"No equation has been registered. Consequently, "
93 "there is nothing for us to do.\n"));
96 dimension_, equation_, parameter_file, mpi_comm, time_loop_executed_);
98 AssertThrow(time_loop_executed_ ==
true,
99 dealii::ExcMessage(
dave +
100 "No equation was dispatched "
101 "with the chosen equation parameter »" +
102 equation_ +
"«.\n"));
109 template <
typename Callable>
132 boost::signals2::signal<void(
int ,
133 const std::string & ,
134 const std::string & ,
154 std::string equation_;
158 bool time_loop_executed_;
167 template <
typename Description,
int dim,
typename Number>
169 bool write_detailed_description)
176 auto &prm = dealii::ParameterAcceptor::prm;
177 prm.enter_subsection(
"A - TimeLoop");
178 prm.declare_entry(
"basename",
"test");
179 prm.leave_subsection();
192 prm.enter_subsection(
"B - Equation");
193 prm.declare_entry(
"dimension",
195 dealii::Patterns::Integer(),
196 "The spatial dimension");
198 "equation", name, dealii::Patterns::Anything(),
"The PDE system");
199 prm.set(
"dimension", std::to_string(dim));
200 prm.set(
"equation", name);
201 prm.leave_subsection();
203 std::string base_name = name;
204 std::replace(base_name.begin(), base_name.end(),
' ',
'_');
205 base_name +=
"-" + std::to_string(dim) +
"d";
207 if (dealii::Utilities::MPI::this_mpi_process(MPI_COMM_SELF) == 0) {
208 const auto full_name =
209 "default_parameters-" + base_name +
"-description.prm";
210 if (write_detailed_description)
211 prm.print_parameters(
213 dealii::ParameterHandler::OutputStyle::KeepDeclarationOrder);
215 const auto short_name =
"default_parameters-" + base_name +
".prm";
216 prm.print_parameters(
218 dealii::ParameterHandler::OutputStyle::Short |
219 dealii::ParameterHandler::OutputStyle::KeepDeclarationOrder
227 dealii::ParameterAcceptor::clear();
235 template <
typename Description,
typename Number>
240 std::cout <<
"Dispatch<Description, Number>::Dispatch() for »" << name
245 create_prm_files<Description, 1, Number>(name,
false);
246 create_prm_files<Description, 2, Number>(name,
true);
247 create_prm_files<Description, 3, Number>(name,
false);
251 [name](
const int dimension,
252 const std::string &equation,
253 const std::string ¶meter_file,
254 const MPI_Comm &mpi_comm,
255 bool &time_loop_executed) {
256 if (equation != name)
259 if (dealii::Utilities::MPI::this_mpi_process(mpi_comm) == 0) {
260 std::cout <<
"[INFO] dispatching to driver »" << equation
261 <<
"« with dim=" << dimension << std::endl;
264 AssertThrow(time_loop_executed ==
false,
267 "Trying to execute more than one TimeLoop object "
268 "with the given equation parameter »" +
271 if (dimension == 1) {
273 dealii::ParameterAcceptor::initialize(parameter_file);
275 time_loop_executed =
true;
276 }
else if (dimension == 2) {
278 dealii::ParameterAcceptor::initialize(parameter_file);
280 time_loop_executed =
true;
281 }
else if (dimension == 3) {
283 dealii::ParameterAcceptor::initialize(parameter_file);
285 time_loop_executed =
true;
void dispatch(const std::string ¶meter_file, const MPI_Comm &mpi_comm)
static void register_create_parameter_files(const Callable &callable)
static void create_parameter_files()
static void register_dispatch(const Callable &callable)
void create_prm_files(const std::string &name, bool write_detailed_description)
Dispatch(const std::string &name)
boost::signals2::signal< void(int, const std::string &, const std::string &, const MPI_Comm &, bool &)> dispatch
boost::signals2::signal< void()> create_parameter_files