Memosa-FVM  0.2
FluxJacobianMatrix.h
Go to the documentation of this file.
1 // This file os part of FVM
2 // Copyright (c) 2012 FVM Authors
3 // See LICENSE file for terms.
4 
5 #ifndef _FLUXJACOBIANMATRIX_H_
6 #define _FLUXJACOBIANMATRIX_H_
7 
8 #include "Matrix.h"
9 #include "CRConnectivity.h"
10 #include "Array.h"
11 #include "StorageSite.h"
12 
13 template<class OffDiag, class X>
14 class FluxJacobianMatrix : public Matrix
15 {
16 public:
18  typedef Array<X> XArray;
19 
21  Matrix(),
22  _conn(conn),
23  _coeffL(_conn.getRowDim()),
24  _coeffR(_conn.getRowDim())
25  {}
26 
27 
28  virtual ~FluxJacobianMatrix(){}
29 
30  DEFINE_TYPENAME("FluxJacobianMatrix<"
33  +">");
34 
35  virtual void multiply(IContainer& yB, const IContainer& xB) const
36  {
37  XArray& y = dynamic_cast<XArray&>(yB);
38  const XArray& x = dynamic_cast<const XArray&>(xB);
39 
40  const int nRows = _conn.getRowDim();
41  for(int nr=0; nr<nRows; nr++)
42  {
43  const int c0=_conn(nr,0);
44  const int c1=_conn(nr,1);
45 
46  y[nr] = _coeffL[nr]*x[c0] + _coeffR[nr]*x[c1];
47  }
48  }
49 
50  virtual void transpose() {}
51 
52  virtual void multiplyAndAdd(IContainer& yB, const IContainer& xB) const
53  {
54  XArray& y = dynamic_cast<XArray&>(yB);
55  const XArray& x = dynamic_cast<const XArray&>(xB);
56 
57  const int nRows = _conn.getRowDim();
58  for(int nr=0; nr<nRows; nr++)
59  {
60  const int c0=_conn(nr,0);
61  const int c1=_conn(nr,1);
62 
63  y[nr] += _coeffL[nr]*x[c0] + _coeffR[nr]*x[c1];
64  }
65  }
66 
67  void setCoeffL(const int f, const OffDiag& c) {_coeffL[f]=c;}
68  void setCoeffR(const int f, const OffDiag& c) {_coeffR[f]=c;}
69 
70  const OffDiag& getCoeffL(const int f) const {return _coeffL[f];}
71  const OffDiag& getCoeffR(const int f) const {return _coeffR[f];}
72 
73  const CRConnectivity& getConnectivity() const {return _conn;}
74 
75  virtual void initAssembly()
76  {
77  _coeffL.zero();
78  _coeffR.zero();
79  }
80 
81 private:
85 };
86 
87 #endif
virtual void zero()
Definition: Array.h:281
virtual void multiply(IContainer &yB, const IContainer &xB) const
const CRConnectivity & _conn
FluxJacobianMatrix(const CRConnectivity &conn)
virtual void initAssembly()
const OffDiag & getCoeffL(const int f) const
Array< OffDiag > _coeffL
void setCoeffR(const int f, const OffDiag &c)
Array< OffDiag > OffDiagArray
void setCoeffL(const int f, const OffDiag &c)
Definition: Matrix.h:16
const CRConnectivity & getConnectivity() const
DEFINE_TYPENAME("FluxJacobianMatrix<"+NumTypeTraits< OffDiag >::getTypeName()+","+NumTypeTraits< X >::getTypeName()+">")
const OffDiag & getCoeffR(const int f) const
Array< OffDiag > _coeffR
virtual void transpose()
virtual void multiplyAndAdd(IContainer &yB, const IContainer &xB) const
int getRowDim() const