8#include <compile_time_options.h>
12#include <deal.II/base/mpi.h>
13#include <deal.II/base/parameter_acceptor.h>
16#include <boost/signals2.hpp>
25 inline const std::string
dave =
26 "\nDave, this conversation can serve no purpose anymore. Goodbye.\n\n";
57 : ParameterAcceptor(
"B - Equation")
60 add_parameter(
"dimension", dimension_,
"The spatial dimension");
61 add_parameter(
"equation", equation_,
"The PDE system");
63 time_loop_executed_ =
false;
74 dave +
"No equation has been registered. Consequently, "
75 "there is nothing for us to do.\n"));
85 template <
typename Callable>
98 void dispatch(
const std::string ¶meter_file,
const MPI_Comm &mpi_comm)
100 ParameterAcceptor::prm.parse_input(parameter_file,
105 AssertThrow(dimension_ >= 1 && dimension_ <= 3,
106 dealii::ExcMessage(
dave +
107 "The dimension parameter needs to be "
108 "either 1, 2, or 3, but we encountered »" +
109 std::to_string(dimension_) +
"«\n"));
111 AssertThrow(
signals !=
nullptr,
113 dave +
"No equation has been registered. Consequently, "
114 "there is nothing for us to do.\n"));
121 time_loop_executed_);
123 AssertThrow(time_loop_executed_ ==
true,
124 dealii::ExcMessage(
dave +
125 "No equation was dispatched "
126 "with the chosen equation parameter »" +
127 equation_ +
"«.\n"));
134 template <
typename Callable>
157 boost::signals2::signal<void(
int ,
158 const std::string & ,
159 const std::string & ,
179 std::string equation_;
183 bool time_loop_executed_;
192 template <
typename Description,
int dim,
typename Number>
194 bool write_detailed_description)
201 auto &prm = dealii::ParameterAcceptor::prm;
202 prm.enter_subsection(
"A - TimeLoop");
203 prm.declare_entry(
"basename",
"test");
204 prm.leave_subsection();
217 prm.enter_subsection(
"B - Equation");
218 prm.declare_entry(
"dimension",
220 dealii::Patterns::Integer(),
221 "The spatial dimension");
223 "equation", name, dealii::Patterns::Anything(),
"The PDE system");
224 prm.set(
"dimension", std::to_string(dim));
225 prm.set(
"equation", name);
226 prm.leave_subsection();
228 std::string base_name = name;
229 std::ranges::replace(base_name,
' ',
'_');
230 base_name +=
"-" + std::to_string(dim) +
"d";
232 if (dealii::Utilities::MPI::this_mpi_process(MPI_COMM_SELF) == 0) {
233 const auto full_name =
234 "default_parameters-" + base_name +
"-description.prm";
235 if (write_detailed_description)
236 prm.print_parameters(
238 dealii::ParameterHandler::OutputStyle::KeepDeclarationOrder);
240 const auto short_name =
"default_parameters-" + base_name +
".prm";
241 prm.print_parameters(
243 dealii::ParameterHandler::OutputStyle::Short |
244 dealii::ParameterHandler::OutputStyle::KeepDeclarationOrder
252 dealii::ParameterAcceptor::clear();
260 template <
typename Description,
typename Number>
265 std::cout <<
"Dispatch<Description, Number>::Dispatch() for »" << name
270 create_prm_files<Description, 1, Number>(name,
false);
271 create_prm_files<Description, 2, Number>(name,
true);
272 create_prm_files<Description, 3, Number>(name,
false);
276 [name](
const int dimension,
277 const std::string &equation,
278 const std::string ¶meter_file,
279 const MPI_Comm &mpi_comm,
280 bool &time_loop_executed) {
281 if (equation != name)
284 if (dealii::Utilities::MPI::this_mpi_process(mpi_comm) == 0) {
285 std::cout <<
"[INFO] dispatching to driver »" << equation
286 <<
"« with dim=" << dimension << std::endl;
289 AssertThrow(time_loop_executed ==
false,
292 "Trying to execute more than one TimeLoop object "
293 "with the given equation parameter »" +
296 if (dimension == 1) {
298 dealii::ParameterAcceptor::initialize(parameter_file);
300 time_loop_executed =
true;
301 }
else if (dimension == 2) {
303 dealii::ParameterAcceptor::initialize(parameter_file);
305 time_loop_executed =
true;
306 }
else if (dimension == 3) {
308 dealii::ParameterAcceptor::initialize(parameter_file);
310 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