Skip to content
Snippets Groups Projects
Commit a6100c00 authored by wenqing's avatar wenqing
Browse files

[Coupling] Other minor changed according to the comments by Christoph

parent f787d2ad
No related branches found
No related tags found
No related merge requests found
Defines the convergence criteria of the global un-coupling loop of the staggered Defines the convergence criteria of the global un-coupling loop of the staggered
scheme. scheme.
\ No newline at end of file
...@@ -364,10 +364,10 @@ std::unique_ptr<UncoupledProcessesTimeLoop> createUncoupledProcessesTimeLoop( ...@@ -364,10 +364,10 @@ std::unique_ptr<UncoupledProcessesTimeLoop> createUncoupledProcessesTimeLoop(
if (coupling_config) if (coupling_config)
{ {
max_coupling_iterations max_coupling_iterations
//! \ogs_file_param{prj__time_loop__global_process_coupling__max_iteration} //! \ogs_file_param{prj__time_loop__global_process_coupling__max_iter}
= coupling_config->getConfigParameter<unsigned>("max_iteration"); = coupling_config->getConfigParameter<unsigned>("max_iter");
coupling_conv_crit = NumLib::createConvergenceCriterion( coupling_conv_crit = NumLib::createConvergenceCriterion(
//! \ogs_file_param{prj__time_loop__global_process_coupling__max_iteration__convergence_criterion} //! \ogs_file_param{prj__time_loop__global_process_coupling__convergence_criterion}
coupling_config->getConfigSubtree("convergence_criterion")); coupling_config->getConfigSubtree("convergence_criterion"));
} }
...@@ -500,10 +500,10 @@ bool UncoupledProcessesTimeLoop::setCoupledSolutions() ...@@ -500,10 +500,10 @@ bool UncoupledProcessesTimeLoop::setCoupledSolutions()
{ {
auto const& coupled_processes = spd->coupled_processes; auto const& coupled_processes = spd->coupled_processes;
std::unordered_map<std::type_index, GlobalVector const&> coupled_xs; std::unordered_map<std::type_index, GlobalVector const&> coupled_xs;
for (auto const& coupled_process_map : coupled_processes) for (auto const& coupled_process_pair : coupled_processes)
{ {
ProcessLib::Process const& coupled_process = ProcessLib::Process const& coupled_process =
coupled_process_map.second; coupled_process_pair.second;
auto const found_item = std::find_if( auto const found_item = std::find_if(
_per_process_data.begin(), _per_process_data.begin(),
_per_process_data.end(), _per_process_data.end(),
...@@ -516,24 +516,24 @@ bool UncoupledProcessesTimeLoop::setCoupledSolutions() ...@@ -516,24 +516,24 @@ bool UncoupledProcessesTimeLoop::setCoupledSolutions()
if (found_item != _per_process_data.end()) if (found_item != _per_process_data.end())
{ {
// Id of the coupled process: // Id of the coupled process:
const std::size_t c_id = found_item - _per_process_data.begin(); const std::size_t c_id =
std::distance(_per_process_data.begin(), found_item);
BaseLib::insertIfTypeIndexKeyUniqueElseError( BaseLib::insertIfTypeIndexKeyUniqueElseError(
coupled_xs, coupled_process_map.first, coupled_xs, coupled_process_pair.first,
*_process_solutions[c_id], "global_coupled_x"); *_process_solutions[c_id], "global_coupled_x");
} }
} }
_solutions_of_coupled_processes.emplace_back(coupled_xs); _solutions_of_coupled_processes.emplace_back(coupled_xs);
const auto x = _process_solutions[pcs_idx]; auto const x = *_process_solutions[pcs_idx];
// Create a vector to store the solution of the last coupling iteration // Create a vector to store the solution of the last coupling iteration
auto x_coupling0 = auto& x_coupling0 = NumLib::GlobalVectorProvider::provider.getVector(x);
&NumLib::GlobalVectorProvider::provider.getVector(*x); MathLib::LinAlg::copy(x, x_coupling0);
MathLib::LinAlg::copy(*x, *x_coupling0);
// append a solution vector of suitable size // append a solution vector of suitable size
_solutions_of_last_cpl_iteration.emplace_back(x_coupling0); _solutions_of_last_cpl_iteration.emplace_back(&x_coupling0);
++pcs_idx; ++pcs_idx;
} // end of for (auto& spd : _per_process_data) } // end of for (auto& spd : _per_process_data)
...@@ -541,6 +541,15 @@ bool UncoupledProcessesTimeLoop::setCoupledSolutions() ...@@ -541,6 +541,15 @@ bool UncoupledProcessesTimeLoop::setCoupledSolutions()
return true; return true;
} }
/*
* TODO:
* Now we have a structure inside the time loop which is very similar to the
* nonlinear solver. And admittedly, the control flow inside the nonlinear
* solver is rather complicated. Maybe in the future con can introduce an
* abstraction that can do both the convergence checks of the coupling loop and
* of the nonlinear solver.
*
*/
bool UncoupledProcessesTimeLoop::loop() bool UncoupledProcessesTimeLoop::loop()
{ {
// initialize output, convergence criterion, etc. // initialize output, convergence criterion, etc.
......
...@@ -31,7 +31,9 @@ namespace ProcessLib ...@@ -31,7 +31,9 @@ namespace ProcessLib
{ {
struct SingleProcessData; struct SingleProcessData;
//! Time loop capable of time-integrating several uncoupled processes at once. /// Time loop capable of time-integrating several processes at once.
/// TODO: Rename to, e.g., TimeLoop, since it is not for purely uncoupled stuff
/// anymore.
class UncoupledProcessesTimeLoop class UncoupledProcessesTimeLoop
{ {
public: public:
......
...@@ -27,22 +27,22 @@ getPreviousLocalSolutionsOfCoupledProcesses( ...@@ -27,22 +27,22 @@ getPreviousLocalSolutionsOfCoupledProcesses(
std::unordered_map<std::type_index, const std::vector<double>> std::unordered_map<std::type_index, const std::vector<double>>
local_coupled_xs0; local_coupled_xs0;
for (auto const& coupled_process_map : coupling_term.coupled_processes) for (auto const& coupled_process_pair : coupling_term.coupled_processes)
{ {
auto const& coupled_pcs = coupled_process_map.second; auto const& coupled_pcs = coupled_process_pair.second;
auto const prevous_time_x = coupled_pcs.getPreviousTimeStepSolution(); auto const prevous_time_x = coupled_pcs.getPreviousTimeStepSolution();
if (prevous_time_x) if (prevous_time_x)
{ {
auto const local_coupled_x0 = prevous_time_x->get(indices); auto const local_coupled_x0 = prevous_time_x->get(indices);
BaseLib::insertIfTypeIndexKeyUniqueElseError( BaseLib::insertIfTypeIndexKeyUniqueElseError(
local_coupled_xs0, coupled_process_map.first, local_coupled_x0, local_coupled_xs0, coupled_process_pair.first, local_coupled_x0,
"local_coupled_x0"); "local_coupled_x0");
} }
else else
{ {
const std::vector<double> local_coupled_x0; const std::vector<double> local_coupled_x0;
BaseLib::insertIfTypeIndexKeyUniqueElseError( BaseLib::insertIfTypeIndexKeyUniqueElseError(
local_coupled_xs0, coupled_process_map.first, local_coupled_x0, local_coupled_xs0, coupled_process_pair.first, local_coupled_x0,
"local_coupled_x0"); "local_coupled_x0");
} }
} }
...@@ -58,12 +58,13 @@ getCurrentLocalSolutionsOfCoupledProcesses( ...@@ -58,12 +58,13 @@ getCurrentLocalSolutionsOfCoupledProcesses(
std::unordered_map<std::type_index, const std::vector<double>> std::unordered_map<std::type_index, const std::vector<double>>
local_coupled_xs; local_coupled_xs;
for (auto const& global_coupled_x_map : global_coupled_xs) // Get local nodal solutions of the coupled equations.
for (auto const& global_coupled_x_pair : global_coupled_xs)
{ {
auto const coupled_x = global_coupled_x_map.second; auto const& coupled_x = global_coupled_x_pair.second;
auto const local_coupled_x = coupled_x.get(indices); auto const local_coupled_x = coupled_x.get(indices);
BaseLib::insertIfTypeIndexKeyUniqueElseError( BaseLib::insertIfTypeIndexKeyUniqueElseError(
local_coupled_xs, global_coupled_x_map.first, local_coupled_x, local_coupled_xs, global_coupled_x_pair.first, local_coupled_x,
"local_coupled_x"); "local_coupled_x");
} }
return local_coupled_xs; return local_coupled_xs;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment