25 const std::vector<std::unique_ptr<Process>>& processes,
26 const std::map<std::string, std::unique_ptr<NumLib::NonlinearSolverBase>>&
28 std::vector<std::unique_ptr<MeshLib::Mesh>>& meshes,
29 bool const compensate_non_equilibrium_initial_residuum)
33 if (!output_config_tree)
35 INFO(
"No output section found.");
39 ?
createOutput(*output_config_tree, output_directory, meshes)
42 output_directory, meshes);
43 auto const fixed_times_for_output =
46 if (
auto const submesh_residuum_output_config_tree =
49 submesh_residuum_output_config_tree)
52 *submesh_residuum_output_config_tree, output_directory, meshes);
54 for (
auto& process : processes)
56 auto const& residuum_vector_names =
57 process->initializeAssemblyOnSubmeshes(smroc.meshes);
59 for (
auto const& name : residuum_vector_names | ranges::views::join)
61 smroc.output.doNotProjectFromBulkMeshToSubmeshes(
66 outputs.push_back(std::move(smroc.output));
71 for (
auto& process : processes)
73 process->initializeAssemblyOnSubmeshes({});
80 compensate_non_equilibrium_initial_residuum, fixed_times_for_output);
82 const bool use_staggered_scheme = ranges::any_of(
83 processes.begin(), processes.end(), [](
auto const& process)
84 { return !(process->isMonolithicSchemeUsed()); });
86 std::unique_ptr<NumLib::StaggeredCoupling> staggered_coupling =
nullptr;
87 if (use_staggered_scheme)
90 config, per_process_data);
94 if (per_process_data.size() > 1)
97 "The monolithic scheme is used. However more than one "
98 "process data tags (by name \"process\") inside tag "
99 "\"time_loop\" are defined for the staggered scheme. If you "
100 "want to use staggered scheme, please set the element of tag "
101 "\"<coupling_scheme>\" to \"staggered\".");
105 auto const& first_timestep_algorithm =
106 *per_process_data.front()->timestep_algorithm;
110 [t_initial = first_timestep_algorithm.begin()](
112 [](std::unique_ptr<ProcessData>
const& process_data)
113 { return process_data->timestep_algorithm->begin(); }))
115 OGS_FATAL(
"All processes must have the same start time.");
119 [t_end = first_timestep_algorithm.end()](
NumLib::Time const& t)
120 { return t == t_end; },
121 [](std::unique_ptr<ProcessData>
const& process_data)
122 { return process_data->timestep_algorithm->end(); }))
124 OGS_FATAL(
"All processes must have the same end time.");
127 const auto minmax_iter =
128 std::minmax_element(per_process_data.begin(),
129 per_process_data.end(),
130 [](std::unique_ptr<ProcessData>
const& a,
131 std::unique_ptr<ProcessData>
const& b)
133 return (a->timestep_algorithm->end() <
134 b->timestep_algorithm->end());
136 auto const start_time =
137 per_process_data[minmax_iter.first - per_process_data.begin()]
138 ->timestep_algorithm->begin();
139 auto const end_time =
140 per_process_data[minmax_iter.second - per_process_data.begin()]
141 ->timestep_algorithm->end();
143 return std::make_unique<TimeLoop>(
144 std::move(outputs), std::move(per_process_data),
145 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.