HArD::Core2D
Hybrid Arbitrary Degree::Core 2D - Library to implement 2D schemes with edge and cell polynomials as unknowns
local_static_condensation.hpp
Go to the documentation of this file.
1 // Structure to store information for and perform local static condensation
2 
3 #ifndef LOCAL_STATIC_CONDENSATION_HPP
4 #define LOCAL_STATIC_CONDENSATION_HPP
5 
6 #include <Eigen/Dense>
7 
8 namespace HArDCore2D
9 {
10 
17 
25  {
28  const Eigen::MatrixXd & Perm,
29  const std::vector<size_t> & globalDOFs_gl,
30  const std::vector<size_t> & globalDOFs_sc
31  )
32  : m_Perm(Perm),
35  m_dim_gl(globalDOFs_gl.size()),
36  m_dim_sc(globalDOFs_sc.size())
37  {
38  // do nothing
39  };
40 
42 
43  std::tuple<Eigen::MatrixXd, Eigen::VectorXd, Eigen::MatrixXd, Eigen::VectorXd>
44  compute(const std::pair<Eigen::MatrixXd, Eigen::VectorXd> & lsT)
45  {
46  // We permute the DOFs that are statically condensed
47  Eigen::MatrixXd AT = m_Perm * lsT.first * m_Perm.transpose();
48  Eigen::VectorXd bT = m_Perm * lsT.second;
49 
50  Eigen::MatrixXd AT_gl, AT_sc;
51  Eigen::VectorXd bT_gl, bT_sc;
52 
53  if (m_dim_sc > 0){
54  // Extract 4 blocks of AT, bT for static condensation
55  Eigen::MatrixXd A11 = AT.topLeftCorner(m_dim_gl, m_dim_gl);
56  Eigen::MatrixXd A12 = AT.topRightCorner(m_dim_gl, m_dim_sc);
57  Eigen::MatrixXd A21 = AT.bottomLeftCorner(m_dim_sc, m_dim_gl);
58  Eigen::MatrixXd A22 = AT.bottomRightCorner(m_dim_sc, m_dim_sc);
59  Eigen::VectorXd b1 = bT.head(m_dim_gl);
60  Eigen::VectorXd b2 = bT.tail(m_dim_sc);
61  // Create condensed system (AT_reduced, bT_reduced) and SC recovery operator (RT, cT)
62  // Eigen::PartialPivLU<Eigen::MatrixXd> A22pivlu(A22);
63  Eigen::FullPivLU<Eigen::MatrixXd> A22pivlu(A22);
64  if( !A22pivlu.isInvertible() ) {
65  std::cout << "[LocalStaticCondensation] Found non invertible local matrix" << std::endl;
66  exit(1);
67  } // if
68  Eigen::MatrixXd A22inv_A21 = A22pivlu.solve(A21);
69  Eigen::VectorXd A22inv_b2 = A22pivlu.solve(b2);
70  AT_gl = A11 - A12 * A22inv_A21;
71  bT_gl = b1 - A12 * A22inv_b2;
72  AT_sc = -A22inv_A21;
73  bT_sc = A22inv_b2;
74  }else{
75  // No static condensation
76  AT_gl = AT;
77  bT_gl = bT;
78  AT_sc = Eigen::MatrixXd::Zero(0,0);
79  bT_sc = Eigen::VectorXd::Zero(0);
80  }
81 
82  return std::make_tuple(AT_gl, bT_gl, AT_sc, bT_sc);
83  };
84 
86  inline std::vector<size_t> globalDOFs_gl() { return m_globalDOFs_gl;};
88  inline size_t dim_gl() { return m_dim_gl;};
89 
91  inline std::vector<size_t> globalDOFs_sys() { return m_globalDOFs_gl;};
92  inline size_t dim_sys() { return m_dim_gl;};
93 
94 
96  inline std::vector<size_t> globalDOFs_sc() { return m_globalDOFs_sc;};
98  inline size_t dim_sc() { return m_dim_sc;};
99 
100  // Members
101  Eigen::MatrixXd m_Perm;
102  std::vector<size_t> m_globalDOFs_gl;
103  std::vector<size_t> m_globalDOFs_sc;
104  size_t m_dim_gl;
105  size_t m_dim_sc;
106  };
107 
108 
110 
111 } // end of namespace HArDCore2D
112 
113 #endif
std::vector< size_t > m_globalDOFs_sc
Definition: local_static_condensation.hpp:103
std::vector< size_t > globalDOFs_gl()
Returns global DOFs that are not statically condensend.
Definition: local_static_condensation.hpp:86
std::tuple< Eigen::MatrixXd, Eigen::VectorXd, Eigen::MatrixXd, Eigen::VectorXd > compute(const std::pair< Eigen::MatrixXd, Eigen::VectorXd > &lsT)
Compute the local static condensation.
Definition: local_static_condensation.hpp:44
size_t dim_gl()
Returns the number of DOFs that are not statically condensed.
Definition: local_static_condensation.hpp:88
size_t m_dim_sc
Definition: local_static_condensation.hpp:105
size_t dim_sc()
Returns the number of DOFs that are statically condensed.
Definition: local_static_condensation.hpp:98
size_t m_dim_gl
Definition: local_static_condensation.hpp:104
std::vector< size_t > globalDOFs_sc()
Returns global DOFs that are statically condensend.
Definition: local_static_condensation.hpp:96
std::vector< size_t > globalDOFs_sys()
Definition: local_static_condensation.hpp:91
size_t dim_sys()
Definition: local_static_condensation.hpp:92
std::vector< size_t > m_globalDOFs_gl
Definition: local_static_condensation.hpp:102
LocalStaticCondensation(const Eigen::MatrixXd &Perm, const std::vector< size_t > &globalDOFs_gl, const std::vector< size_t > &globalDOFs_sc)
Constructor.
Definition: local_static_condensation.hpp:27
Eigen::MatrixXd m_Perm
Definition: local_static_condensation.hpp:98
Definition: ddr-klplate.hpp:27
Structure to store information for, and perform, local static condensation.
Definition: local_static_condensation.hpp:25