Skip to content

Commit

Permalink
Print parameters (lethe-fluid-matrix-free) (#1255)
Browse files Browse the repository at this point in the history
Print all relevant parameters at the end of the simulation. We can add a parameter to enable/disable this, but having the simulation output and the chosen parameters next to each other/in the same file is quite useful in my opinion. If you run too many parameter studies you loose the overview of the modified parameters.
  • Loading branch information
peterrum authored Aug 23, 2024
1 parent 03c3ede commit 4f256b3
Showing 1 changed file with 39 additions and 5 deletions.
44 changes: 39 additions & 5 deletions applications/lethe-fluid-matrix-free/fluid_dynamics_matrix_free.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,47 @@ main(int argc, char *argv[])
{
Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);

if (argc != 2)
if (argc == 1)
{
std::cout << "Usage:" << argv[0] << " input_file" << std::endl;
std::exit(1);
}

const unsigned int dim = get_dimension(argv[1]);

const std::string file_name(argv[argc - 1]);
const bool print_parameters =
(argc == 2) ? false : (std::string(argv[1]) == "--print-parameters");

const unsigned int dim = get_dimension(file_name);
const Parameters::SizeOfSubsections size_of_subsections =
Parameters::get_size_of_subsections(argv[1]);
Parameters::get_size_of_subsections(file_name);

ConditionalOStream pcout(std::cout,
(Utilities::MPI::this_mpi_process(
MPI_COMM_WORLD) == 0) &&
print_parameters);

if (dim == 2)
{
ParameterHandler prm;
SimulationParameters<2> NSparam;
NSparam.declare(prm, size_of_subsections);
// Parsing of the file
prm.parse_input(argv[1]);
prm.parse_input(file_name);
NSparam.parse(prm);

if (pcout.is_active())
prm.print_parameters(pcout.get_stream(),
ParameterHandler::OutputStyle::PRM |
ParameterHandler::OutputStyle::Short |
ParameterHandler::KeepDeclarationOrder
#if DEAL_II_VERSION_GTE(9, 7, 0)
|
ParameterHandler::KeepOnlyChanged
#endif
);
pcout << std::endl << std::endl;

FluidDynamicsMatrixFree<2> problem(NSparam);
problem.solve();
}
Expand All @@ -51,9 +73,21 @@ main(int argc, char *argv[])
SimulationParameters<3> NSparam;
NSparam.declare(prm, size_of_subsections);
// Parsing of the file
prm.parse_input(argv[1]);
prm.parse_input(file_name);
NSparam.parse(prm);

if (pcout.is_active())
prm.print_parameters(pcout.get_stream(),
ParameterHandler::OutputStyle::PRM |
ParameterHandler::OutputStyle::Short |
ParameterHandler::KeepDeclarationOrder
#if DEAL_II_VERSION_GTE(9, 7, 0)
|
ParameterHandler::KeepOnlyChanged
#endif
);
pcout << std::endl << std::endl;

FluidDynamicsMatrixFree<3> problem(NSparam);
problem.solve();
}
Expand Down

0 comments on commit 4f256b3

Please sign in to comment.