OGS 6.2.1-76-gbb689931b
Process.h
Go to the documentation of this file.
1 
10 #pragma once
11 
12 #include <tuple>
13 
18 #include "ParameterLib/Parameter.h"
25 
27 #include "ProcessVariable.h"
28 #include "VectorMatrixAssembler.h"
29 
30 namespace MeshLib
31 {
32 class Mesh;
33 }
34 
35 namespace ProcessLib
36 {
37 struct CoupledSolutionsForStaggeredScheme;
38 
39 class Process
40  : public NumLib::ODESystem< // TODO: later on use a simpler ODE system
41  NumLib::ODESystemTag::FirstOrderImplicitQuasilinear,
42  NumLib::NonlinearSolverTag::Newton>
43 {
44 public:
47 
48  Process(std::string name_,
49  MeshLib::Mesh& mesh,
50  std::unique_ptr<AbstractJacobianAssembler>&& jacobian_assembler,
51  std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const&
52  parameters,
53  unsigned const integration_order,
54  std::vector<std::vector<std::reference_wrapper<ProcessVariable>>>&&
55  process_variables,
56  SecondaryVariableCollection&& secondary_variables,
57  NumLib::NamedFunctionCaller&& named_function_caller,
58  const bool use_monolithic_scheme = true);
59 
61  void preTimestep(GlobalVector const& x, const double t,
62  const double delta_t, const int process_id);
63 
65  void postTimestep(GlobalVector const& x, const double t,
66  const double delta_t, int const process_id);
67 
70  void postNonLinearSolver(GlobalVector const& x, const double t,
71  int const process_id);
72 
73  void preIteration(const unsigned iter, GlobalVector const& x) final;
74 
76  void computeSecondaryVariable(const double t, GlobalVector const& x,
77  int const process_id);
78 
79  NumLib::IterationResult postIteration(GlobalVector const& x) final;
80 
81  void initialize();
82 
83  void setInitialConditions(const int process_id, const double t,
84  GlobalVector& x);
85 
86  MathLib::MatrixSpecifications getMatrixSpecifications(
87  const int process_id) const override;
88 
90  CoupledSolutionsForStaggeredScheme* const coupled_solutions)
91  {
92  _coupled_solutions = coupled_solutions;
93  }
94 
95  void updateDeactivatedSubdomains(double const time, const int process_id);
96 
97  bool isMonolithicSchemeUsed() const { return _use_monolithic_scheme; }
99  void preAssemble(const double t, GlobalVector const& x) final;
100  void assemble(const double t, GlobalVector const& x, GlobalMatrix& M,
101  GlobalMatrix& K, GlobalVector& b) final;
102 
103  void assembleWithJacobian(const double t, GlobalVector const& x,
104  GlobalVector const& xdot, const double dxdot_dx,
105  const double dx_dx, GlobalMatrix& M,
106  GlobalMatrix& K, GlobalVector& b,
107  GlobalMatrix& Jac) final;
108 
109  std::vector<NumLib::IndexValueVector<GlobalIndexType>> const*
110  getKnownSolutions(double const t, GlobalVector const& x) const final
111  {
112  const auto pcs_id =
113  (_coupled_solutions) ? _coupled_solutions->process_id : 0;
114  return _boundary_conditions[pcs_id].getKnownSolutions(t, x);
115  }
116 
118  const int /*process_id*/) const
119  {
120  return *_local_to_global_index_map;
121  }
122 
123  MeshLib::Mesh& getMesh() const { return _mesh; }
124  std::vector<std::reference_wrapper<ProcessVariable>> const&
125  getProcessVariables(const int process_id) const
126  {
127  return _process_variables[process_id];
128  }
129 
131  {
132  return _secondary_variables;
133  }
134 
135  std::vector<std::unique_ptr<IntegrationPointWriter>> const&
137  {
138  return _integration_point_writer;
139  }
140 
141  // Used as a call back for CalculateSurfaceFlux process.
142 
143  virtual Eigen::Vector3d getFlux(std::size_t /*element_id*/,
144  MathLib::Point3d const& /*p*/,
145  double const /*t*/,
146  GlobalVector const& /*x*/) const
147  {
148  return Eigen::Vector3d{};
149  }
150 
151 protected:
153  {
154  return _extrapolator_data.getExtrapolator();
155  }
156 
158  {
159  return _extrapolator_data.getDOFTable();
160  }
161 
167  void initializeProcessBoundaryConditionsAndSourceTerms(
168  const NumLib::LocalToGlobalIndexMap& dof_table, const int process_id);
169 
170 private:
172  virtual void initializeConcreteProcess(
173  NumLib::LocalToGlobalIndexMap const& dof_table,
174  MeshLib::Mesh const& mesh,
175  unsigned const integration_order) = 0;
176 
179  virtual void initializeBoundaryConditions();
180 
181  virtual void setInitialConditionsConcreteProcess(GlobalVector const& /*x*/,
182  double const /*t*/)
183  {
184  }
185 
186  virtual void preAssembleConcreteProcess(const double /*t*/,
187  GlobalVector const& /*x*/)
188  {
189  }
190 
191  virtual void assembleConcreteProcess(const double t, GlobalVector const& x,
192  GlobalMatrix& M, GlobalMatrix& K,
193  GlobalVector& b) = 0;
194 
195  virtual void assembleWithJacobianConcreteProcess(
196  const double t, GlobalVector const& x, GlobalVector const& xdot,
197  const double dxdot_dx, const double dx_dx, GlobalMatrix& M,
198  GlobalMatrix& K, GlobalVector& b, GlobalMatrix& Jac) = 0;
199 
200  virtual void preTimestepConcreteProcess(GlobalVector const& /*x*/,
201  const double /*t*/,
202  const double /*delta_t*/,
203  const int /*process_id*/)
204  {
205  }
206 
207  virtual void postTimestepConcreteProcess(GlobalVector const& /*x*/,
208  const double /*t*/,
209  const double /*delta_t*/,
210  int const /*process_id*/)
211  {
212  }
213 
214  virtual void postNonLinearSolverConcreteProcess(GlobalVector const& /*x*/,
215  const double /*t*/,
216  int const /*process_id*/)
217  {
218  }
219 
220  virtual void preIterationConcreteProcess(const unsigned /*iter*/,
221  GlobalVector const& /*x*/)
222  {
223  }
224 
225  virtual void computeSecondaryVariableConcrete(const double /*t*/,
226  GlobalVector const& /*x*/,
227  int const /*process_id*/)
228  {
229  }
230 
232  GlobalVector const& /*x*/)
233  {
235  }
236 
237 protected:
244  virtual void constructDofTable();
245 
251  void constructMonolithicProcessDofTable();
252 
258  void constructDofTableOfSpecifiedProsessStaggerdScheme(
259  const int specified_prosess_id);
260 
269  virtual std::tuple<NumLib::LocalToGlobalIndexMap*, bool>
270  getDOFTableForExtrapolatorData() const;
271 
272 private:
273  void initializeExtrapolator();
274 
277  void finishNamedFunctionsInitialization();
278 
281  void computeSparsityPattern();
282 
283 public:
284  std::string const name;
285 
286 protected:
288  std::unique_ptr<MeshLib::MeshSubset const> _mesh_subset_all_nodes;
289 
290  std::unique_ptr<NumLib::LocalToGlobalIndexMap> _local_to_global_index_map;
291 
293 
295  std::vector<std::unique_ptr<CachedSecondaryVariable>>
298 
300 
302 
306 
310  unsigned const _integration_order;
311 
315  std::vector<std::unique_ptr<IntegrationPointWriter>>
317 
319 
320 protected:
325  std::vector<std::vector<std::reference_wrapper<ProcessVariable>>>
327 
331  std::vector<BoundaryConditionCollection> _boundary_conditions;
332 
333 private:
337  std::vector<SourceTermCollection> _source_term_collections;
338 
340 };
341 
342 } // namespace ProcessLib
std::vector< NumLib::IndexValueVector< GlobalIndexType > > const * getKnownSolutions(double const t, GlobalVector const &x) const final
Definition: Process.h:110
MeshLib::Mesh & _mesh
Definition: Process.h:287
virtual NumLib::LocalToGlobalIndexMap const & getDOFTable(const int) const
Definition: Process.h:117
SecondaryVariableCollection const & getSecondaryVariables() const
Definition: Process.h:130
std::vector< SourceTermCollection > _source_term_collections
Definition: Process.h:337
virtual void computeSecondaryVariableConcrete(const double, GlobalVector const &, int const)
Definition: Process.h:225
std::vector< std::unique_ptr< CachedSecondaryVariable > > _cached_secondary_variables
Definition: Process.h:296
MathLib::SparsityPattern< GlobalIndexType > GlobalSparsityPattern
std::unique_ptr< MeshLib::MeshSubset const > _mesh_subset_all_nodes
Definition: Process.h:288
std::vector< std::unique_ptr< IntegrationPointWriter > > const & getIntegrationPointWriter() const
Definition: Process.h:136
NumLib::NamedFunctionCaller _named_function_caller
Definition: Process.h:294
std::vector< std::reference_wrapper< ProcessVariable > > const & getProcessVariables(const int process_id) const
Definition: Process.h:125
virtual NumLib::IterationResult postIterationConcreteProcess(GlobalVector const &)
Definition: Process.h:231
unsigned const _integration_order
Definition: Process.h:310
virtual void setInitialConditionsConcreteProcess(GlobalVector const &, double const)
Definition: Process.h:181
std::vector< GlobalVector * > setInitialConditions(double const t0, std::vector< std::unique_ptr< ProcessData >> const &per_process_data)
Definition: TimeLoop.cpp:125
std::vector< std::vector< std::reference_wrapper< ProcessVariable > > > _process_variables
Definition: Process.h:326
virtual void preAssembleConcreteProcess(const double, GlobalVector const &)
Definition: Process.h:186
ExtrapolatorData _extrapolator_data
Definition: Process.h:339
void setCoupledSolutionsForStaggeredScheme(CoupledSolutionsForStaggeredScheme *const coupled_solutions)
Definition: Process.h:89
std::vector< BoundaryConditionCollection > _boundary_conditions
Definition: Process.h:331
bool isMonolithicSchemeUsed() const
Definition: Process.h:97
NumLib::Extrapolator & getExtrapolator() const
Definition: Process.h:152
virtual void postNonLinearSolverConcreteProcess(GlobalVector const &, const double, int const)
Definition: Process.h:214
std::unique_ptr< NumLib::LocalToGlobalIndexMap > _local_to_global_index_map
Definition: Process.h:290
IterationResult
Status flags telling the NonlinearSolver if an iteration succeeded.
virtual void setCoupledTermForTheStaggeredSchemeToLocalAssemblers()
Definition: Process.h:98
Builds expression trees of named functions dynamically at runtime.
SecondaryVariableCollection _secondary_variables
Definition: Process.h:292
virtual void preIterationConcreteProcess(const unsigned, GlobalVector const &)
Definition: Process.h:220
virtual void postTimestepConcreteProcess(GlobalVector const &, const double, const double, int const)
Definition: Process.h:207
virtual Eigen::Vector3d getFlux(std::size_t, MathLib::Point3d const &, double const, GlobalVector const &) const
Definition: Process.h:143
Interface for heuristic search length strategy.
Definition: ProjectData.h:30
GlobalSparsityPattern computeSparsityPattern(LocalToGlobalIndexMap const &dof_table, MeshLib::Mesh const &mesh)
Computes a sparsity pattern for the given inputs.
SecondaryVariableContext _secondary_variable_context
Definition: Process.h:297
virtual void preTimestepConcreteProcess(GlobalVector const &, const double, const double, const int)
Definition: Process.h:200
CoupledSolutionsForStaggeredScheme * _coupled_solutions
Definition: Process.h:305
Handles configuration of several secondary variables from the project file.
NumLib::LocalToGlobalIndexMap const & getSingleComponentDOFTable() const
Definition: Process.h:157
MeshLib::Mesh & getMesh() const
Definition: Process.h:123
std::vector< std::unique_ptr< IntegrationPointWriter > > _integration_point_writer
Definition: Process.h:316
const bool _use_monolithic_scheme
Definition: Process.h:301
GlobalSparsityPattern _sparsity_pattern
Definition: Process.h:318
VectorMatrixAssembler _global_assembler
Definition: Process.h:299
std::string const name
Definition: Process.h:284