OGS
MatrixTranslator.h
Go to the documentation of this file.
1 
11 #pragma once
12 
13 #include <memory>
14 
15 #include "TimeDiscretization.h"
16 #include "Types.h"
17 
18 #include "MathLib/LinAlg/LinAlg.h"
19 
20 namespace NumLib
21 {
24 
31 template <ODESystemTag ODETag>
33 
39 template <>
41 {
42 public:
44  virtual void computeA(GlobalMatrix const& M, GlobalMatrix const& K,
45  GlobalMatrix& A) const = 0;
46 
48  virtual void computeRhs(const GlobalMatrix& M, const GlobalMatrix& K,
49  const GlobalVector& b, const GlobalVector& x_prev,
50  GlobalVector& rhs) const = 0;
51 
56  virtual void computeResidual(GlobalMatrix const& M, GlobalMatrix const& K,
57  GlobalVector const& b,
58  GlobalVector const& x_curr,
59  GlobalVector const& xdot,
60  GlobalVector& res) const = 0;
61 
63  virtual void computeJacobian(GlobalMatrix const& Jac_in,
64  GlobalMatrix& Jac_out) const = 0;
65 
66  virtual ~MatrixTranslator() = default;
67 };
68 
74 template <ODESystemTag ODETag>
76 
85 template <>
87  : public MatrixTranslator<ODESystemTag::FirstOrderImplicitQuasilinear>
88 {
89 public:
94  explicit MatrixTranslatorGeneral(TimeDiscretization const& timeDisc)
95  : _time_disc(timeDisc)
96  {
97  }
98 
100  void computeA(GlobalMatrix const& M, GlobalMatrix const& K,
101  GlobalMatrix& A) const override;
102 
104  void computeRhs(const GlobalMatrix& M, const GlobalMatrix& /*K*/,
105  const GlobalVector& b, const GlobalVector& x_prev,
106  GlobalVector& rhs) const override;
107 
109  void computeResidual(GlobalMatrix const& M, GlobalMatrix const& K,
110  GlobalVector const& b,
111  GlobalVector const& x_curr,
112  GlobalVector const& xdot,
113  GlobalVector& res) const override;
114 
117  void computeJacobian(GlobalMatrix const& Jac_in,
118  GlobalMatrix& Jac_out) const override;
119 
120 private:
121  TimeDiscretization const&
123 
125  mutable std::size_t _tmp_id = 0u;
126 };
127 
130 template <ODESystemTag ODETag>
131 std::unique_ptr<MatrixTranslator<ODETag>> createMatrixTranslator(
132  TimeDiscretization const& timeDisc)
133 {
134  return std::unique_ptr<MatrixTranslator<ODETag>>(
135  new MatrixTranslatorGeneral<ODETag>(timeDisc));
136 }
137 
139 } // namespace NumLib
Types.h
NumLib::MatrixTranslator
Definition: MatrixTranslator.h:32
NumLib::TimeDiscretization
Definition: TimeDiscretization.h:87
NumLib
Definition: ProjectData.h:35
NumLib::MatrixTranslatorGeneral
Definition: MatrixTranslator.h:75
NumLib::ODESystemTag
ODESystemTag
Tag used to specify the type of ODE.
Definition: Types.h:26
TimeDiscretization.h
NumLib::MatrixTranslatorGeneral< ODESystemTag::FirstOrderImplicitQuasilinear >::_time_disc
TimeDiscretization const & _time_disc
the time discretization used.
Definition: MatrixTranslator.h:122
NumLib::MatrixTranslatorGeneral< ODESystemTag::FirstOrderImplicitQuasilinear >::MatrixTranslatorGeneral
MatrixTranslatorGeneral(TimeDiscretization const &timeDisc)
Definition: MatrixTranslator.h:94
NumLib::ODESystemTag::FirstOrderImplicitQuasilinear
@ FirstOrderImplicitQuasilinear
NumLib::createMatrixTranslator
std::unique_ptr< MatrixTranslator< ODETag > > createMatrixTranslator(TimeDiscretization const &timeDisc)
Definition: MatrixTranslator.h:131
LinAlg.h