OGS 6.2.0-244-g47b8a9a9d
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(MeshLib::Mesh& mesh,
49  std::unique_ptr<AbstractJacobianAssembler>&& jacobian_assembler,
50  std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const&
51  parameters,
52  unsigned const integration_order,
53  std::vector<std::vector<std::reference_wrapper<ProcessVariable>>>&&
54  process_variables,
55  SecondaryVariableCollection&& secondary_variables,
56  NumLib::NamedFunctionCaller&& named_function_caller,
57  const bool use_monolithic_scheme = true);
58 
60  void preTimestep(GlobalVector const& x, const double t,
61  const double delta_t, const int process_id);
62 
64  void postTimestep(GlobalVector const& x, const double t,
65  const double delta_t, int const process_id);
66 
69  void postNonLinearSolver(GlobalVector const& x, const double t,
70  int const process_id);
71 
72  void preIteration(const unsigned iter, GlobalVector const& x) final;
73 
75  void computeSecondaryVariable(const double t, GlobalVector const& x,
76  int const process_id);
77 
78  NumLib::IterationResult postIteration(GlobalVector const& x) final;
79 
80  void initialize();
81 
82  void setInitialConditions(const int process_id, const double t,
83  GlobalVector& x);
84 
85  MathLib::MatrixSpecifications getMatrixSpecifications(
86  const int process_id) const override;
87 
89  CoupledSolutionsForStaggeredScheme* const coupled_solutions)
90  {
91  _coupled_solutions = coupled_solutions;
92  }
93 
94  void updateDeactivatedSubdomains(double const time, const int process_id);
95 
96  bool isMonolithicSchemeUsed() const { return _use_monolithic_scheme; }
98  void preAssemble(const double t, GlobalVector const& x) final;
99  void assemble(const double t, GlobalVector const& x, GlobalMatrix& M,
100  GlobalMatrix& K, GlobalVector& b) final;
101 
102  void assembleWithJacobian(const double t, GlobalVector const& x,
103  GlobalVector const& xdot, const double dxdot_dx,
104  const double dx_dx, GlobalMatrix& M,
105  GlobalMatrix& K, GlobalVector& b,
106  GlobalMatrix& Jac) final;
107 
108  std::vector<NumLib::IndexValueVector<GlobalIndexType>> const*
109  getKnownSolutions(double const t, GlobalVector const& x) const final
110  {
111  const auto pcs_id =
112  (_coupled_solutions) ? _coupled_solutions->process_id : 0;
113  return _boundary_conditions[pcs_id].getKnownSolutions(t, x);
114  }
115 
117  const int /*process_id*/) const
118  {
119  return *_local_to_global_index_map;
120  }
121 
122  MeshLib::Mesh& getMesh() const { return _mesh; }
123  std::vector<std::reference_wrapper<ProcessVariable>> const&
124  getProcessVariables(const int process_id) const
125  {
126  return _process_variables[process_id];
127  }
128 
130  {
131  return _secondary_variables;
132  }
133 
134  std::vector<std::unique_ptr<IntegrationPointWriter>> const&
136  {
137  return _integration_point_writer;
138  }
139 
140  // Used as a call back for CalculateSurfaceFlux process.
141 
142  virtual Eigen::Vector3d getFlux(std::size_t /*element_id*/,
143  MathLib::Point3d const& /*p*/,
144  double const /*t*/,
145  GlobalVector const& /*x*/) const
146  {
147  return Eigen::Vector3d{};
148  }
149 
150 protected:
152  {
153  return _extrapolator_data.getExtrapolator();
154  }
155 
157  {
158  return _extrapolator_data.getDOFTable();
159  }
160 
166  void initializeProcessBoundaryConditionsAndSourceTerms(
167  const NumLib::LocalToGlobalIndexMap& dof_table, const int process_id);
168 
169 private:
171  virtual void initializeConcreteProcess(
172  NumLib::LocalToGlobalIndexMap const& dof_table,
173  MeshLib::Mesh const& mesh,
174  unsigned const integration_order) = 0;
175 
178  virtual void initializeBoundaryConditions();
179 
180  virtual void setInitialConditionsConcreteProcess(GlobalVector const& /*x*/,
181  double const /*t*/)
182  {
183  }
184 
185  virtual void preAssembleConcreteProcess(const double /*t*/,
186  GlobalVector const& /*x*/)
187  {
188  }
189 
190  virtual void assembleConcreteProcess(const double t, GlobalVector const& x,
191  GlobalMatrix& M, GlobalMatrix& K,
192  GlobalVector& b) = 0;
193 
194  virtual void assembleWithJacobianConcreteProcess(
195  const double t, GlobalVector const& x, GlobalVector const& xdot,
196  const double dxdot_dx, const double dx_dx, GlobalMatrix& M,
197  GlobalMatrix& K, GlobalVector& b, GlobalMatrix& Jac) = 0;
198 
199  virtual void preTimestepConcreteProcess(GlobalVector const& /*x*/,
200  const double /*t*/,
201  const double /*delta_t*/,
202  const int /*process_id*/)
203  {
204  }
205 
206  virtual void postTimestepConcreteProcess(GlobalVector const& /*x*/,
207  const double /*t*/,
208  const double /*delta_t*/,
209  int const /*process_id*/)
210  {
211  }
212 
213  virtual void postNonLinearSolverConcreteProcess(GlobalVector const& /*x*/,
214  const double /*t*/,
215  int const /*process_id*/)
216  {
217  }
218 
219  virtual void preIterationConcreteProcess(const unsigned /*iter*/,
220  GlobalVector const& /*x*/)
221  {
222  }
223 
224  virtual void computeSecondaryVariableConcrete(const double /*t*/,
225  GlobalVector const& /*x*/,
226  int const /*process_id*/)
227  {
228  }
229 
231  GlobalVector const& /*x*/)
232  {
234  }
235 
236 protected:
237  virtual void constructDofTable();
238 
247  virtual std::tuple<NumLib::LocalToGlobalIndexMap*, bool>
248  getDOFTableForExtrapolatorData() const;
249 
250 private:
251  void initializeExtrapolator();
252 
255  void finishNamedFunctionsInitialization();
256 
259  void computeSparsityPattern();
260 
261 protected:
263  std::unique_ptr<MeshLib::MeshSubset const> _mesh_subset_all_nodes;
264 
265  std::unique_ptr<NumLib::LocalToGlobalIndexMap> _local_to_global_index_map;
266 
268 
270  std::vector<std::unique_ptr<CachedSecondaryVariable>>
273 
275 
277 
281 
285  unsigned const _integration_order;
286 
290  std::vector<std::unique_ptr<IntegrationPointWriter>>
292 
294 
295 protected:
300  std::vector<std::vector<std::reference_wrapper<ProcessVariable>>>
302 
306  std::vector<BoundaryConditionCollection> _boundary_conditions;
307 
308 private:
312  std::vector<SourceTermCollection> _source_term_collections;
313 
315 };
316 
317 } // namespace ProcessLib
std::vector< NumLib::IndexValueVector< GlobalIndexType > > const * getKnownSolutions(double const t, GlobalVector const &x) const final
Definition: Process.h:109
MeshLib::Mesh & _mesh
Definition: Process.h:262
virtual NumLib::LocalToGlobalIndexMap const & getDOFTable(const int) const
Definition: Process.h:116
SecondaryVariableCollection const & getSecondaryVariables() const
Definition: Process.h:129
std::vector< SourceTermCollection > _source_term_collections
Definition: Process.h:312
virtual void computeSecondaryVariableConcrete(const double, GlobalVector const &, int const)
Definition: Process.h:224
std::vector< std::unique_ptr< CachedSecondaryVariable > > _cached_secondary_variables
Definition: Process.h:271
MathLib::SparsityPattern< GlobalIndexType > GlobalSparsityPattern
std::unique_ptr< MeshLib::MeshSubset const > _mesh_subset_all_nodes
Definition: Process.h:263
std::vector< std::unique_ptr< IntegrationPointWriter > > const & getIntegrationPointWriter() const
Definition: Process.h:135
NumLib::NamedFunctionCaller _named_function_caller
Definition: Process.h:269
std::vector< std::reference_wrapper< ProcessVariable > > const & getProcessVariables(const int process_id) const
Definition: Process.h:124
virtual NumLib::IterationResult postIterationConcreteProcess(GlobalVector const &)
Definition: Process.h:230
unsigned const _integration_order
Definition: Process.h:285
virtual void setInitialConditionsConcreteProcess(GlobalVector const &, double const)
Definition: Process.h:180
std::vector< GlobalVector * > setInitialConditions(double const t0, std::vector< std::unique_ptr< ProcessData >> const &per_process_data)
Definition: TimeLoop.cpp:122
std::vector< std::vector< std::reference_wrapper< ProcessVariable > > > _process_variables
Definition: Process.h:301
virtual void preAssembleConcreteProcess(const double, GlobalVector const &)
Definition: Process.h:185
ExtrapolatorData _extrapolator_data
Definition: Process.h:314
void setCoupledSolutionsForStaggeredScheme(CoupledSolutionsForStaggeredScheme *const coupled_solutions)
Definition: Process.h:88
std::vector< BoundaryConditionCollection > _boundary_conditions
Definition: Process.h:306
bool isMonolithicSchemeUsed() const
Definition: Process.h:96
NumLib::Extrapolator & getExtrapolator() const
Definition: Process.h:151
virtual void postNonLinearSolverConcreteProcess(GlobalVector const &, const double, int const)
Definition: Process.h:213
std::unique_ptr< NumLib::LocalToGlobalIndexMap > _local_to_global_index_map
Definition: Process.h:265
IterationResult
Status flags telling the NonlinearSolver if an iteration succeeded.
virtual void setCoupledTermForTheStaggeredSchemeToLocalAssemblers()
Definition: Process.h:97
Builds expression trees of named functions dynamically at runtime.
SecondaryVariableCollection _secondary_variables
Definition: Process.h:267
virtual void preIterationConcreteProcess(const unsigned, GlobalVector const &)
Definition: Process.h:219
virtual void postTimestepConcreteProcess(GlobalVector const &, const double, const double, int const)
Definition: Process.h:206
virtual Eigen::Vector3d getFlux(std::size_t, MathLib::Point3d const &, double const, GlobalVector const &) const
Definition: Process.h:142
Interface for heuristic search length strategy.
Definition: ProjectData.h:29
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:272
virtual void preTimestepConcreteProcess(GlobalVector const &, const double, const double, const int)
Definition: Process.h:199
CoupledSolutionsForStaggeredScheme * _coupled_solutions
Definition: Process.h:280
Handles configuration of several secondary variables from the project file.
NumLib::LocalToGlobalIndexMap const & getSingleComponentDOFTable() const
Definition: Process.h:156
MeshLib::Mesh & getMesh() const
Definition: Process.h:122
std::vector< std::unique_ptr< IntegrationPointWriter > > _integration_point_writer
Definition: Process.h:291
const bool _use_monolithic_scheme
Definition: Process.h:276
GlobalSparsityPattern _sparsity_pattern
Definition: Process.h:293
VectorMatrixAssembler _global_assembler
Definition: Process.h:274