MFEM  v3.2
Finite element discretization library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
staticcond.hpp
Go to the documentation of this file.
1 // Copyright (c) 2010, Lawrence Livermore National Security, LLC. Produced at
2 // the Lawrence Livermore National Laboratory. LLNL-CODE-443211. All Rights
3 // reserved. See file COPYRIGHT for details.
4 //
5 // This file is part of the MFEM library. For more information and source code
6 // availability see http://mfem.org.
7 //
8 // MFEM is free software; you can redistribute it and/or modify it under the
9 // terms of the GNU Lesser General Public License (as published by the Free
10 // Software Foundation) version 2.1 dated February 1999.
11 
12 #ifndef MFEM_STATIC_CONDENSATION
13 #define MFEM_STATIC_CONDENSATION
14 
15 #include "../config/config.hpp"
16 #include "fespace.hpp"
17 
18 #ifdef MFEM_USE_MPI
19 #include "pfespace.hpp"
20 #endif
21 
22 namespace mfem
23 {
24 
66 {
67  FiniteElementSpace *fes, *tr_fes;
69  Table elem_pdof; // Element to private dof
70  int npdofs; // Number of private dofs
71  Array<int> rdof_edof; // Map from reduced dofs to exposed dofs
72 
73  // Schur complement: S = A_ee - A_ep (A_pp)^{-1} A_pe.
74  SparseMatrix *S, *S_e;
75 #ifdef MFEM_USE_MPI
76  ParFiniteElementSpace *pfes, *tr_pfes;
77  HypreParMatrix *pS, *pS_e;
78  bool Parallel() const { return (tr_pfes != NULL); }
79 #else
80  bool Parallel() const { return false; }
81 #endif
82 
83  bool symm; // TODO: handle the symmetric case correctly.
84  Array<int> A_offsets, A_ipiv_offsets;
85  double *A_data;
86  int *A_ipiv;
87 
88 public:
93 
95  int GetNPrDofs() const { return npdofs; }
97  int GetNExDofs() const { return tr_fes->GetVSize(); }
100  bool ReducesTrueVSize() const;
101 
104  void Init(bool symmetric, bool block_diagonal);
105 
107  FiniteElementSpace *GetTraceFESpace() { return tr_fes; }
108 
109 #ifdef MFEM_USE_MPI
110  ParFiniteElementSpace *GetParTraceFESpace() { return tr_pfes; }
112 #endif
113 
116  void AssembleMatrix(int el, const DenseMatrix &elmat);
117 
120  void AssembleBdrMatrix(int el, const DenseMatrix &elmat);
121 
123  void Finalize();
124 
126  void EliminateReducedTrueDofs(const Array<int> &ess_rtdof_list,
127  int keep_diagonal);
128 
131  bool HasEliminatedBC() const
132  {
133 #ifndef MFEM_USE_MPI
134  return S_e;
135 #else
136  return S_e || pS_e;
137 #endif
138  }
139 
141  SparseMatrix &GetMatrix() { return *S; }
142 
144  SparseMatrix &GetMatrixElim() { return *S_e; }
145 
146 #ifdef MFEM_USE_MPI
147  HypreParMatrix &GetParallelMatrix() { return *pS; }
149 
152 #endif
153 
156  void ReduceRHS(const Vector &b, Vector &sc_b) const;
157 
160  void ReduceSolution(const Vector &sol, Vector &sc_sol) const;
161 
164  void ConvertMarkerToReducedTrueDofs(const Array<int> &ess_tdof_marker,
165  Array<int> &ess_rtdof_marker) const;
166 
169  void ConvertListToReducedTrueDofs(const Array<int> &ess_tdof_list,
170  Array<int> &ess_rtdof_list) const
171  {
172  Array<int> ess_tdof_marker, ess_rtdof_marker;
173  FiniteElementSpace::ListToMarker(ess_tdof_list, fes->GetTrueVSize(),
174  ess_tdof_marker);
175  ConvertMarkerToReducedTrueDofs(ess_tdof_marker, ess_rtdof_marker);
176  FiniteElementSpace::MarkerToList(ess_rtdof_marker, ess_rtdof_list);
177  }
178 
181  void ComputeSolution(const Vector &b, const Vector &sc_sol,
182  Vector &sol) const;
183 };
184 
185 }
186 
187 #endif
int GetVSize() const
Definition: fespace.hpp:161
~StaticCondensation()
Destroy a StaticCondensation object.
Definition: staticcond.cpp:104
bool ReducesTrueVSize() const
Definition: staticcond.cpp:118
void ReduceRHS(const Vector &b, Vector &sc_b) const
Definition: staticcond.cpp:309
ParFiniteElementSpace * GetParTraceFESpace()
Return a pointer to the parallel reduced/trace FE space.
Definition: staticcond.hpp:111
Abstract parallel finite element space.
Definition: pfespace.hpp:28
StaticCondensation(FiniteElementSpace *fespace)
Construct a StaticCondensation object.
Definition: staticcond.cpp:17
void ComputeSolution(const Vector &b, const Vector &sc_sol, Vector &sol) const
Definition: staticcond.cpp:452
int GetNExDofs() const
Return the number of vector exposed/reduced dofs.
Definition: staticcond.hpp:97
static void MarkerToList(const Array< int > &marker, Array< int > &list)
Convert a Boolean marker array to a list containing all marked indices.
Definition: fespace.cpp:292
Data type sparse matrix.
Definition: sparsemat.hpp:38
HypreParMatrix & GetParallelMatrix()
Return the parallel Schur complement matrix.
Definition: staticcond.hpp:148
int GetNPrDofs() const
Return the number of vector private dofs.
Definition: staticcond.hpp:95
void Finalize()
Finalize the construction of the Schur complement matrix.
Definition: staticcond.cpp:235
void AssembleBdrMatrix(int el, const DenseMatrix &elmat)
Definition: staticcond.cpp:227
void EliminateReducedTrueDofs(const Array< int > &ess_rtdof_list, int keep_diagonal)
Eliminate the given reduced true dofs from the Schur complement matrix S.
Definition: staticcond.cpp:286
HypreParMatrix & GetParallelMatrixElim()
Return the eliminated part of the parallel Schur complement matrix.
Definition: staticcond.hpp:151
virtual int GetTrueVSize()
Return the number of vector true (conforming) dofs.
Definition: fespace.hpp:164
FiniteElementSpace * GetTraceFESpace()
Return a pointer to the reduced/trace FE space.
Definition: staticcond.hpp:107
void AssembleMatrix(int el, const DenseMatrix &elmat)
Definition: staticcond.cpp:189
bool HasEliminatedBC() const
Definition: staticcond.hpp:131
static void ListToMarker(const Array< int > &list, int marker_size, Array< int > &marker, int mark_val=-1)
Definition: fespace.cpp:309
Vector data type.
Definition: vector.hpp:33
SparseMatrix & GetMatrix()
Return the serial Schur complement matrix.
Definition: staticcond.hpp:141
void ReduceSolution(const Vector &sol, Vector &sc_sol) const
Definition: staticcond.cpp:388
SparseMatrix & GetMatrixElim()
Return the eliminated part of the serial Schur complement matrix.
Definition: staticcond.hpp:144
Wrapper for hypre&#39;s ParCSR matrix class.
Definition: hypre.hpp:150
void Init(bool symmetric, bool block_diagonal)
Definition: staticcond.cpp:134
void ConvertListToReducedTrueDofs(const Array< int > &ess_tdof_list, Array< int > &ess_rtdof_list) const
Definition: staticcond.hpp:169
void ConvertMarkerToReducedTrueDofs(const Array< int > &ess_tdof_marker, Array< int > &ess_rtdof_marker) const
Definition: staticcond.cpp:415