OGS 6.1.0-1721-g6382411ad
CreateProcessData.cpp
Go to the documentation of this file.
1 
10 #include "BaseLib/Algorithm.h"
11 
14 
15 #include "CreateProcessData.h"
16 
17 namespace ProcessLib
18 {
19 static std::unique_ptr<ProcessData> makeProcessData(
20  std::unique_ptr<NumLib::TimeStepAlgorithm>&& timestepper,
21  NumLib::NonlinearSolverBase& nonlinear_solver,
22  Process& process,
23  std::unique_ptr<NumLib::TimeDiscretization>&& time_disc,
24  std::unique_ptr<NumLib::ConvergenceCriterion>&& conv_crit)
25 {
26  using Tag = NumLib::NonlinearSolverTag;
27 
28  if (auto* nonlinear_solver_picard =
30  &nonlinear_solver))
31  {
32  return std::make_unique<ProcessData>(
33  std::move(timestepper), *nonlinear_solver_picard,
34  std::move(conv_crit), std::move(time_disc), process);
35  }
36  if (auto* nonlinear_solver_newton =
38  &nonlinear_solver))
39  {
40  return std::make_unique<ProcessData>(
41  std::move(timestepper), *nonlinear_solver_newton,
42  std::move(conv_crit), std::move(time_disc), process);
43  }
44 
45  OGS_FATAL("Encountered unknown nonlinear solver type. Aborting");
46 }
47 
48 std::vector<std::unique_ptr<ProcessData>> createPerProcessData(
49  BaseLib::ConfigTree const& config,
50  const std::map<std::string, std::unique_ptr<Process>>& processes,
51  std::map<std::string, std::unique_ptr<NumLib::NonlinearSolverBase>> const&
52  nonlinear_solvers)
53 {
54  std::vector<std::unique_ptr<ProcessData>> per_process_data;
55 
57  for (auto pcs_config : config.getConfigSubtreeList("process"))
58  {
60  auto const pcs_name = pcs_config.getConfigAttribute<std::string>("ref");
61  auto& pcs = *BaseLib::getOrError(
62  processes, pcs_name,
63  "A process with the given name has not been defined.");
64 
65  auto const nl_slv_name =
67  pcs_config.getConfigParameter<std::string>("nonlinear_solver");
68  auto& nl_slv = *BaseLib::getOrError(
69  nonlinear_solvers, nl_slv_name,
70  "A nonlinear solver with the given name has not been defined.");
71 
72  auto time_disc = NumLib::createTimeDiscretization(
74  pcs_config.getConfigSubtree("time_discretization"));
75 
76  auto timestepper = NumLib::createTimeStepper(
78  pcs_config.getConfigSubtree("time_stepping"));
79 
80  auto conv_crit = NumLib::createConvergenceCriterion(
82  pcs_config.getConfigSubtree("convergence_criterion"));
83 
85  auto output = pcs_config.getConfigSubtreeOptional("output");
86  if (output)
87  {
88  OGS_FATAL(
89  "In order to make the specification of output in the project "
90  "file consistent, the variables output tags were moved from "
91  "xpath "
92  "'//OpenGeoSysProject/time_loop/processes/process/output' "
93  "to the global output section, i.e., to the xpath "
94  "'//OpenGeoSysProject/time_loop/output'. This has to be done "
95  "in the current project file!");
96  }
97 
98  per_process_data.emplace_back(makeProcessData(
99  std::move(timestepper), nl_slv, pcs, std::move(time_disc),
100  std::move(conv_crit)));
101  }
102 
103  if (per_process_data.size() != processes.size())
104  {
105  if (processes.size() > 1)
106  {
107  OGS_FATAL(
108  "Some processes have not been configured to be solved by this "
109  " time loop.");
110  }
111  else
112  {
113  INFO(
114  "The equations of the coupled processes will be solved by the "
115  "staggered scheme.");
116  }
117  }
118 
119  return per_process_data;
120 }
121 } // namespace ProcessLib
std::unique_ptr< TimeStepAlgorithm > createTimeStepper(BaseLib::ConfigTree const &config)
Map::mapped_type & getOrError(Map &map, Key const &key, std::string const &error_message)
Definition: Algorithm.h:147
NonlinearSolverTag
Tag used to specify which nonlinear solver will be used.
Definition: Types.h:19
std::vector< std::unique_ptr< ProcessData > > createPerProcessData(BaseLib::ConfigTree const &config, const std::map< std::string, std::unique_ptr< Process >> &processes, std::map< std::string, std::unique_ptr< NumLib::NonlinearSolverBase >> const &nonlinear_solvers)
Range< SubtreeIterator > getConfigSubtreeList(std::string const &root) const
Definition: ConfigTree.cpp:170
#define OGS_FATAL(fmt,...)
Definition: Error.h:71
static std::unique_ptr< ProcessData > makeProcessData(std::unique_ptr< NumLib::TimeStepAlgorithm > &&timestepper, NumLib::NonlinearSolverBase &nonlinear_solver, Process &process, std::unique_ptr< NumLib::TimeDiscretization > &&time_disc, std::unique_ptr< NumLib::ConvergenceCriterion > &&conv_crit)
std::unique_ptr< ConvergenceCriterion > createConvergenceCriterion(const BaseLib::ConfigTree &config)
Creates a convergence criterion from the given configuration.
std::unique_ptr< TimeDiscretization > createTimeDiscretization(BaseLib::ConfigTree const &config)