31 const std::vector<std::unique_ptr<Process>>& processes,
32 const std::map<std::string, std::unique_ptr<NumLib::NonlinearSolverBase>>&
34 std::vector<std::unique_ptr<MeshLib::Mesh>>& meshes,
35 bool const compensate_non_equilibrium_initial_residuum)
39 if (!output_config_tree)
41 INFO(
"No output section found.");
45 ?
createOutput(*output_config_tree, output_directory, meshes)
48 output_directory, meshes);
49 auto const fixed_times_for_output =
52 if (
auto const submesh_residuum_output_config_tree =
55 submesh_residuum_output_config_tree)
58 *submesh_residuum_output_config_tree, output_directory, meshes);
60 for (
auto& process : processes)
62 auto const& residuum_vector_names =
63 process->initializeAssemblyOnSubmeshes(smroc.meshes);
65 for (
auto const& name : residuum_vector_names | ranges::views::join)
67 smroc.output.doNotProjectFromBulkMeshToSubmeshes(
72 outputs.push_back(std::move(smroc.output));
77 for (
auto& process : processes)
79 process->initializeAssemblyOnSubmeshes({});
86 compensate_non_equilibrium_initial_residuum, fixed_times_for_output);
88 const bool use_staggered_scheme =
89 ranges::any_of(processes.begin(), processes.end(),
90 [](
auto const& process)
91 { return !(process->isMonolithicSchemeUsed()); });
93 std::unique_ptr<NumLib::StaggeredCoupling> staggered_coupling =
nullptr;
94 if (use_staggered_scheme)
97 config, per_process_data);
101 if (per_process_data.size() > 1)
104 "The monolithic scheme is used. However more than one "
105 "process data tags (by name \"process\") inside tag "
106 "\"time_loop\" are defined for the staggered scheme. If you "
107 "want to use staggered scheme, please set the element of tag "
108 "\"<coupling_scheme>\" to \"staggered\".");
112 const auto minmax_iter =
113 std::minmax_element(per_process_data.begin(),
114 per_process_data.end(),
115 [](std::unique_ptr<ProcessData>
const& a,
116 std::unique_ptr<ProcessData>
const& b) {
117 return (a->timestep_algorithm->end() <
118 b->timestep_algorithm->end());
120 auto const start_time =
121 per_process_data[minmax_iter.first - per_process_data.begin()]
122 ->timestep_algorithm->begin();
123 auto const end_time =
124 per_process_data[minmax_iter.second - per_process_data.begin()]
125 ->timestep_algorithm->end();
127 return std::make_unique<TimeLoop>(
128 std::move(outputs), std::move(per_process_data),
129 std::move(staggered_coupling), start_time, end_time);
std::vector< std::unique_ptr< ProcessData > > createPerProcessData(BaseLib::ConfigTree const &config, std::vector< std::unique_ptr< Process > > const &processes, std::map< std::string, std::unique_ptr< NumLib::NonlinearSolverBase > > const &nonlinear_solvers, bool const compensate_non_equilibrium_initial_residuum, std::vector< double > const &fixed_times_for_output)
std::unique_ptr< TimeLoop > createTimeLoop(BaseLib::ConfigTree const &config, std::string const &output_directory, const std::vector< std::unique_ptr< Process > > &processes, const std::map< std::string, std::unique_ptr< NumLib::NonlinearSolverBase > > &nonlinear_solvers, std::vector< std::unique_ptr< MeshLib::Mesh > > &meshes, bool const compensate_non_equilibrium_initial_residuum)
Builds a TimeLoop from the given configuration.