OGS
MatrixTranslator.h
Go to the documentation of this file.
1
11#pragma once
12
13#include <memory>
14
16#include "TimeDiscretization.h"
17#include "Types.h"
18
19namespace NumLib
20{
23
30template <ODESystemTag ODETag>
32
39template <>
41{
42public:
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
54 virtual void normalizeAandRhs(GlobalMatrix& A, GlobalVector& b) const = 0;
55
60 virtual void computeResidual(GlobalMatrix const& M, GlobalMatrix const& K,
61 GlobalVector const& b, double dt,
62 GlobalVector const& x_curr,
63 GlobalVector const& x_prev,
64 GlobalVector& res) const = 0;
65
67 virtual void computeJacobian(GlobalMatrix const& Jac_in,
68 GlobalMatrix& Jac_out) const = 0;
69
70 virtual ~MatrixTranslator() = default;
71};
72
78template <ODESystemTag ODETag>
80
89template <>
91 : public MatrixTranslator<ODESystemTag::FirstOrderImplicitQuasilinear>
92{
93public:
99 : _time_disc(timeDisc)
100 {
101 }
102
104 void computeA(GlobalMatrix const& M, GlobalMatrix const& K,
105 GlobalMatrix& A) const override;
106
108 void computeRhs(const GlobalMatrix& M, const GlobalMatrix& /*K*/,
109 const GlobalVector& b, const GlobalVector& x_prev,
110 GlobalVector& rhs) const override;
111
114 void normalizeAandRhs(GlobalMatrix& A, GlobalVector& b) const override;
115
117 void computeResidual(GlobalMatrix const& M, GlobalMatrix const& K,
118 GlobalVector const& b, double dt,
119 GlobalVector const& x_curr, GlobalVector const& x_prev,
120 GlobalVector& res) const override;
121
124 void computeJacobian(GlobalMatrix const& Jac_in,
125 GlobalMatrix& Jac_out) const override;
126
127private:
129
131 mutable std::size_t _tmp_id = 0u;
132};
133
136template <ODESystemTag ODETag>
137std::unique_ptr<MatrixTranslator<ODETag>> createMatrixTranslator(
138 TimeDiscretization const& timeDisc)
139{
140 return std::unique_ptr<MatrixTranslator<ODETag>>(
141 new MatrixTranslatorGeneral<ODETag>(timeDisc));
142}
143
145} // namespace NumLib
Global vector based on Eigen vector.
Definition EigenVector.h:25
TimeDiscretization const & _time_disc
the time discretization used.
virtual void computeJacobian(GlobalMatrix const &Jac_in, GlobalMatrix &Jac_out) const =0
Computes the Jacobian of the residual and writes it to Jac_out.
virtual void computeA(GlobalMatrix const &M, GlobalMatrix const &K, GlobalMatrix &A) const =0
Computes A from M and K.
virtual void normalizeAandRhs(GlobalMatrix &A, GlobalVector &b) const =0
virtual void computeRhs(const GlobalMatrix &M, const GlobalMatrix &K, const GlobalVector &b, const GlobalVector &x_prev, GlobalVector &rhs) const =0
Computes rhs from M, K, b and x_prev.
virtual void computeResidual(GlobalMatrix const &M, GlobalMatrix const &K, GlobalVector const &b, double dt, GlobalVector const &x_curr, GlobalVector const &x_prev, GlobalVector &res) const =0
std::unique_ptr< MatrixTranslator< ODETag > > createMatrixTranslator(TimeDiscretization const &timeDisc)
ODESystemTag
Tag used to specify the type of ODE.
Definition Types.h:27