Skip to content
Snippets Groups Projects
Commit 4e63aea5 authored by wenqing's avatar wenqing Committed by Dmitri Naumov
Browse files

[CreateTimeLoop] Use the creator of StaggeredCoupling

parent a1ec2404
No related branches found
No related tags found
No related merge requests found
...@@ -10,9 +10,13 @@ ...@@ -10,9 +10,13 @@
#include "CreateTimeLoop.h" #include "CreateTimeLoop.h"
#include <algorithm>
#include <range/v3/algorithm/any_of.hpp> #include <range/v3/algorithm/any_of.hpp>
#include <string>
#include "BaseLib/ConfigTree.h" #include "BaseLib/ConfigTree.h"
#include "NumLib/StaggeredCoupling/CreateStaggeredCoupling.h"
#include "NumLib/StaggeredCoupling/StaggeredCoupling.h"
#include "ProcessLib/CreateProcessData.h" #include "ProcessLib/CreateProcessData.h"
#include "ProcessLib/Output/CreateOutput.h" #include "ProcessLib/Output/CreateOutput.h"
#include "ProcessLib/Output/Output.h" #include "ProcessLib/Output/Output.h"
...@@ -29,78 +33,6 @@ std::unique_ptr<TimeLoop> createTimeLoop( ...@@ -29,78 +33,6 @@ std::unique_ptr<TimeLoop> createTimeLoop(
std::vector<std::unique_ptr<MeshLib::Mesh>>& meshes, std::vector<std::unique_ptr<MeshLib::Mesh>>& meshes,
bool const compensate_non_equilibrium_initial_residuum) bool const compensate_non_equilibrium_initial_residuum)
{ {
auto const& coupling_config
//! \ogs_file_param{prj__time_loop__global_process_coupling}
= config.getConfigSubtreeOptional("global_process_coupling");
std::vector<std::unique_ptr<NumLib::ConvergenceCriterion>>
global_coupling_conv_criteria;
std::map<std::string, int> local_coupling_processes;
int max_coupling_iterations = 1;
if (coupling_config)
{
max_coupling_iterations
//! \ogs_file_param{prj__time_loop__global_process_coupling__max_iter}
= coupling_config->getConfigParameter<int>("max_iter");
auto const& coupling_convergence_criteria_config =
//! \ogs_file_param{prj__time_loop__global_process_coupling__convergence_criteria}
coupling_config->getConfigSubtree("convergence_criteria");
auto coupling_convergence_criterion_config =
//! \ogs_file_param{prj__time_loop__global_process_coupling__convergence_criteria__convergence_criterion}
coupling_convergence_criteria_config.getConfigSubtreeList(
"convergence_criterion");
std::transform(coupling_convergence_criterion_config.begin(),
coupling_convergence_criterion_config.end(),
std::back_inserter(global_coupling_conv_criteria),
[](BaseLib::ConfigTree const& c)
{ return NumLib::createConvergenceCriterion(c); });
auto const& local_coupling_processes_config =
coupling_config
//! \ogs_file_param{prj__time_loop__global_process_coupling__local_coupling_processes}
->getConfigSubtreeOptional("local_coupling_processes");
if (local_coupling_processes_config)
{
for (
auto name :
local_coupling_processes_config
//! \ogs_file_param{prj__time_loop__global_process_coupling__local_coupling_processes__process_name}
->getConfigParameterList<std::string>("process_name"))
{
BaseLib::insertIfKeyUniqueElseError(
local_coupling_processes, name, -1,
"The name of locally coupled process is not unique.");
}
static std::string const error_info =
"Please check the number of elements in the tag "
"'time_loop/global_process_coupling/"
"local_coupling_processes' in the project file.";
if (local_coupling_processes.size() >
global_coupling_conv_criteria.size() - 1)
{
OGS_FATAL(
"The number of the locally coupled processes is greater "
"than or equal to the number of total coupled processes. "
"{}",
error_info);
}
INFO("There are {:d} locally coupled processes.",
local_coupling_processes.size());
if (local_coupling_processes.size() < 2)
{
OGS_FATAL(
"At least two locally coupled processes are required for "
"the local iteration solution! {} ",
error_info);
}
}
}
//! \ogs_file_param{prj__time_loop__output} //! \ogs_file_param{prj__time_loop__output}
auto output_config_tree = config.getConfigSubtreeOptional("output"); auto output_config_tree = config.getConfigSubtreeOptional("output");
if (!output_config_tree) if (!output_config_tree)
...@@ -157,25 +89,22 @@ std::unique_ptr<TimeLoop> createTimeLoop( ...@@ -157,25 +89,22 @@ std::unique_ptr<TimeLoop> createTimeLoop(
[](auto const& process) [](auto const& process)
{ return !(process->isMonolithicSchemeUsed()); }); { return !(process->isMonolithicSchemeUsed()); });
if (!use_staggered_scheme && per_process_data.size() > 1) std::unique_ptr<NumLib::StaggeredCoupling> staggered_coupling = nullptr;
if (use_staggered_scheme)
{ {
OGS_FATAL( staggered_coupling = NumLib::createStaggeredCoupling<ProcessData>(
"The monolithic scheme is used. However more than one process data " config, per_process_data);
"tags (by name \"process\") inside tag \"time_loop\" are defined "
"for the staggered scheme. If you want to use staggered scheme, "
"please set the element of tag \"<coupling_scheme>\" to "
"\"staggered\".");
} }
else
if (coupling_config)
{ {
if (global_coupling_conv_criteria.size() != per_process_data.size()) if (per_process_data.size() > 1)
{ {
OGS_FATAL( OGS_FATAL(
"The number of convergence criteria of the global staggered " "The monolithic scheme is used. However more than one "
"coupling loop is not identical to the number of the " "process data tags (by name \"process\") inside tag "
"processes! Please check the element by tag " "\"time_loop\" are defined for the staggered scheme. If you "
"global_process_coupling in the project file."); "want to use staggered scheme, please set the element of tag "
"\"<coupling_scheme>\" to \"staggered\".");
} }
} }
...@@ -196,7 +125,6 @@ std::unique_ptr<TimeLoop> createTimeLoop( ...@@ -196,7 +125,6 @@ std::unique_ptr<TimeLoop> createTimeLoop(
return std::make_unique<TimeLoop>( return std::make_unique<TimeLoop>(
std::move(outputs), std::move(per_process_data), std::move(outputs), std::move(per_process_data),
max_coupling_iterations, std::move(global_coupling_conv_criteria), std::move(staggered_coupling), start_time, end_time);
std::move(local_coupling_processes), start_time, end_time);
} }
} // namespace ProcessLib } // namespace ProcessLib
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