OGS
StaggeredCoupling.h
Go to the documentation of this file.
1
12#pragma once
13
14#include <functional>
15#include <memory>
16#include <tuple>
17#include <variant>
18#include <vector>
19
23
24namespace NumLib
25{
26class ConvergenceCriterion;
27
30{
31 std::string process_name;
32 std::unique_ptr<NumLib::ConvergenceCriterion> convergence_criterion;
35};
36
38{
40 using CouplingNodeVariant = std::variant<CouplingNode, RootCouplingNode>;
41 std::vector<CouplingNodeVariant> sub_coupling_nodes;
42};
43
47{
48 template <typename ProcessData, typename Output>
50 std::vector<GlobalVector*>& /*xs*/,
51 std::vector<GlobalVector*> const& /*xs_prev*/,
52 std::size_t const /*timestep*/, double const /*t*/,
53 double const /*delta_t*/, ProcessData const& /*process_data*/,
54 std::vector<Output> const& /*outputs*/)>;
55
56 using CouplingNodeVariant = std::variant<CouplingNode, RootCouplingNode>;
57
58public:
59 StaggeredCoupling(const int global_coupling_max_iterations,
60 std::vector<CouplingNodeVariant>&& coupling_nodes)
61 : global_coupling_max_iterations_(global_coupling_max_iterations),
62 coupling_nodes_(std::move(coupling_nodes))
63 {
64 }
65
67
75 std::vector<GlobalVector*> const& process_solutions);
76
81 template <typename ProcessData, typename Output>
83 const double t, const double dt, const std::size_t timestep_id,
84 std::vector<GlobalVector*>& process_solutions,
85 std::vector<GlobalVector*> const& process_solutions_prev,
86 std::vector<std::unique_ptr<ProcessData>> const& per_process_data,
87 std::vector<Output> const& outputs,
88 ProcessSolver<ProcessData, Output> const&
89 solve_one_time_step_one_process);
90
91private:
94
105 std::vector<CouplingNodeVariant> coupling_nodes_;
106
113 template <typename ProcessData, typename Output>
114 std::tuple<NumLib::NonlinearSolverStatus, bool> executeConcrete(
115 std::vector<CouplingNodeVariant>& coupling_nodes,
116 const int max_iterations, const double t, const double dt,
117 const std::size_t timestep_id,
118 std::vector<GlobalVector*>& process_solutions,
119 std::vector<GlobalVector*> const& process_solutions_prev,
120 std::vector<std::unique_ptr<ProcessData>> const& per_process_data,
121 std::vector<Output> const& outputs,
123 solve_one_time_step_one_process);
124
125 template <typename ProcessData, typename Output>
126 std::tuple<NumLib::NonlinearSolverStatus, bool> executeSubCoupling(
127 CouplingNodeVariant& coupling_node, const double t, const double dt,
128 const std::size_t timestep_id,
129 std::vector<GlobalVector*>& process_solutions,
130 std::vector<GlobalVector*> const& process_solutions_prev,
131 std::vector<std::unique_ptr<ProcessData>> const& per_process_data,
132 std::vector<Output> const& outputs,
134 solve_one_time_step_one_process);
135
136 template <typename ProcessData, typename Output>
138 int const global_coupling_iteration,
139 CouplingNode const& regular_coupling_node, const double t,
140 const double dt, const std::size_t timestep_id,
141 std::vector<GlobalVector*>& process_solutions,
142 std::vector<GlobalVector*> const& process_solutions_prev,
143 std::vector<std::unique_ptr<ProcessData>> const& per_process_data,
144 std::vector<Output> const& outputs,
146 solve_one_time_step_one_process);
147
150 std::vector<GlobalVector*> solutions_of_last_cpl_iteration_;
151
154 std::vector<CouplingNodeVariant> const& coupling_nodes);
155
157 std::vector<CouplingNodeVariant> const& coupling_nodes);
158
159 bool checkCouplingConvergence(const bool convergence_of_last_process,
160 CouplingNode const& coupling_node,
161 GlobalVector const& x) const;
162
163 void updatePreviousSolution(int const process_id, GlobalVector const& x);
164};
165
166} // namespace NumLib
167
Global vector based on Eigen vector.
Definition EigenVector.h:25
NumLib::NonlinearSolverStatus executeSingleIteration(int const global_coupling_iteration, CouplingNode const &regular_coupling_node, const double t, const double dt, const std::size_t timestep_id, std::vector< GlobalVector * > &process_solutions, std::vector< GlobalVector * > const &process_solutions_prev, std::vector< std::unique_ptr< ProcessData > > const &per_process_data, std::vector< Output > const &outputs, ProcessSolver< ProcessData, Output > const &solve_one_time_step_one_process)
void initializeCoupledSolutions(std::vector< GlobalVector * > const &process_solutions)
const int global_coupling_max_iterations_
Maximum iteration number of the coupling loop of the staggered scheme.
std::tuple< NumLib::NonlinearSolverStatus, bool > executeConcrete(std::vector< CouplingNodeVariant > &coupling_nodes, const int max_iterations, const double t, const double dt, const std::size_t timestep_id, std::vector< GlobalVector * > &process_solutions, std::vector< GlobalVector * > const &process_solutions_prev, std::vector< std::unique_ptr< ProcessData > > const &per_process_data, std::vector< Output > const &outputs, ProcessSolver< ProcessData, Output > const &solve_one_time_step_one_process)
void resetCouplingConvergenceCriteria(std::vector< CouplingNodeVariant > const &coupling_nodes)
std::vector< GlobalVector * > solutions_of_last_cpl_iteration_
void setFirstIterationIndicator(std::vector< CouplingNodeVariant > const &coupling_nodes)
Set the indicator of the first staggered coupling iteration be true.
std::vector< CouplingNodeVariant > coupling_nodes_
std::function< NumLib::NonlinearSolverStatus( std::vector< GlobalVector * > &, std::vector< GlobalVector * > const &, std::size_t const, double const, double const, ProcessData const &, std::vector< Output > const &)> ProcessSolver
StaggeredCoupling(const int global_coupling_max_iterations, std::vector< CouplingNodeVariant > &&coupling_nodes)
NumLib::NonlinearSolverStatus execute(const double t, const double dt, const std::size_t timestep_id, std::vector< GlobalVector * > &process_solutions, std::vector< GlobalVector * > const &process_solutions_prev, std::vector< std::unique_ptr< ProcessData > > const &per_process_data, std::vector< Output > const &outputs, ProcessSolver< ProcessData, Output > const &solve_one_time_step_one_process)
bool checkCouplingConvergence(const bool convergence_of_last_process, CouplingNode const &coupling_node, GlobalVector const &x) const
std::tuple< NumLib::NonlinearSolverStatus, bool > executeSubCoupling(CouplingNodeVariant &coupling_node, const double t, const double dt, const std::size_t timestep_id, std::vector< GlobalVector * > &process_solutions, std::vector< GlobalVector * > const &process_solutions_prev, std::vector< std::unique_ptr< ProcessData > > const &per_process_data, std::vector< Output > const &outputs, ProcessSolver< ProcessData, Output > const &solve_one_time_step_one_process)
void updatePreviousSolution(int const process_id, GlobalVector const &x)
std::variant< CouplingNode, RootCouplingNode > CouplingNodeVariant
Information of a coupling node.
std::unique_ptr< NumLib::ConvergenceCriterion > convergence_criterion
Status of the non-linear solver.
std::variant< CouplingNode, RootCouplingNode > CouplingNodeVariant
std::vector< CouplingNodeVariant > sub_coupling_nodes