MFEM  v3.1
Finite element discretization library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
pfespace.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_PFESPACE
13 #define MFEM_PFESPACE
14 
15 #include "../config/config.hpp"
16 
17 #ifdef MFEM_USE_MPI
18 
19 #include "../linalg/hypre.hpp"
20 #include "../mesh/pmesh.hpp"
21 #include "../mesh/nurbs.hpp"
22 #include "fespace.hpp"
23 
24 namespace mfem
25 {
26 
29 {
30 private:
32  MPI_Comm MyComm;
33  int NRanks, MyRank;
34 
36  ParMesh *pmesh;
37 
39  GroupCommunicator *gcomm;
40 
42  int ltdof_size;
43 
45  Array<int> ldof_group;
46 
48  Array<int> ldof_ltdof;
49 
51  Array<HYPRE_Int> dof_offsets;
52 
54  Array<HYPRE_Int> tdof_offsets;
55 
57  Array<HYPRE_Int> tdof_nb_offsets;
58 
60  Array<int> ldof_sign;
61 
63  HypreParMatrix *P;
64 
66  SparseMatrix *R;
67 
68  ParNURBSExtension *pNURBSext()
69  { return dynamic_cast<ParNURBSExtension *>(NURBSext); }
70 
71  GroupTopology &GetGroupTopo()
72  { return (NURBSext) ? pNURBSext()->gtopo : pmesh->gtopo; }
73 
77 
78  // ldof_type = 0 : DOFs communicator, otherwise VDOFs communicator
79  void GetGroupComm(GroupCommunicator &gcomm, int ldof_type,
80  Array<int> *ldof_sign = NULL);
81 
83  void GenerateGlobalOffsets();
84 
86  void ConstructTrueDofs();
87  void ConstructTrueNURBSDofs();
88 
89  void ApplyLDofSigns(Array<int> &dofs) const;
90 
92  struct Dependency
93  {
94  int rank, dof;
95  double coef;
96  Dependency(int r, int d, double c) : rank(r), dof(d), coef(c) {}
97  };
98 
100  struct DepList
101  {
102  Array<Dependency> list;
103  int type;
104 
105  DepList() : type(0) {}
106 
107  bool IsTrueDof(int my_rank) const
108  { return type == 0 || (type == 1 && list[0].rank == my_rank); }
109  };
110 
111  void AddSlaveDependencies(DepList deps[], int master_rank,
112  const Array<int> &master_dofs, int master_ndofs,
113  const Array<int> &slave_dofs, DenseMatrix& I);
114 
115  void Add1To1Dependencies(DepList deps[], int owner_rank,
116  const Array<int> &owner_dofs, int owner_ndofs,
117  const Array<int> &dependent_dofs);
118 
119  void GetDofs(int type, int index, Array<int>& dofs);
120  void ReorderFaceDofs(Array<int> &dofs, int orient);
121 
122  // Used when the ParMesh is non-conforming, i.e. pmesh->pncmesh != NULL.
123  // Constructs the matrices P and R. Determines ltdof_size. Calls
124  // GenerateGlobalOffsets(). Constructs ldof_ltdof.
125  void GetParallelConformingInterpolation();
126 
127 public:
128  // Face-neighbor data
129  // Number of face-neighbor dofs
131  // Face-neighbor-element to face-neighbor dof
133  // Face-neighbor to ldof in the face-neighbor numbering
135  // The global ldof indices of the face-neighbor dofs
137  // Local face-neighbor data: face-neighbor to ldof
139 
141  int dim = 1, int ordering = Ordering::byNODES);
142 
143  MPI_Comm GetComm() { return MyComm; }
144  int GetNRanks() { return NRanks; }
145  int GetMyRank() { return MyRank; }
146 
147  inline ParMesh *GetParMesh() { return pmesh; }
148 
149  int GetDofSign(int i)
150  { return NURBSext || Nonconforming() ? 1 : ldof_sign[VDofToDof(i)]; }
151  HYPRE_Int *GetDofOffsets() { return dof_offsets; }
152  HYPRE_Int *GetTrueDofOffsets() { return tdof_offsets; }
153  HYPRE_Int GlobalVSize()
154  { return Dof_TrueDof_Matrix()->GetGlobalNumRows(); }
155  HYPRE_Int GlobalTrueVSize()
156  { return Dof_TrueDof_Matrix()->GetGlobalNumCols(); }
157 
159  virtual int GetTrueVSize() { return ltdof_size; }
160 
162  virtual void GetElementDofs(int i, Array<int> &dofs) const;
163 
165  virtual void GetBdrElementDofs(int i, Array<int> &dofs) const;
166 
169  virtual void GetFaceDofs(int i, Array<int> &dofs) const;
170 
173 
177  { return (new HypreParVector(MyComm,GlobalTrueVSize(),GetTrueDofOffsets()));}
178 
180  void DivideByGroupSize(double *vec);
181 
183  GroupCommunicator &GroupComm() { return *gcomm; }
184 
187 
190  void Synchronize(Array<int> &ldof_marker) const;
191 
193  virtual void GetEssentialVDofs(const Array<int> &bdr_attr_is_ess,
194  Array<int> &ess_dofs) const;
195 
198  virtual void GetEssentialTrueDofs(const Array<int> &bdr_attr_is_ess,
199  Array<int> &ess_tdof_list);
200 
203  int GetLocalTDofNumber(int ldof);
205  HYPRE_Int GetGlobalTDofNumber(int ldof);
209  HYPRE_Int GetGlobalScalarTDofNumber(int sldof);
210 
211  HYPRE_Int GetMyDofOffset() const;
212  HYPRE_Int GetMyTDofOffset() const;
213 
216  { if (!R) { Dof_TrueDof_Matrix(); } return R; }
217 
218  // Face-neighbor functions
219  void ExchangeFaceNbrData();
220  int GetFaceNbrVSize() const { return num_face_nbr_dofs; }
221  void GetFaceNbrElementVDofs(int i, Array<int> &vdofs) const;
222  const FiniteElement *GetFaceNbrFE(int i) const;
223  const HYPRE_Int *GetFaceNbrGlobalDofMap() { return face_nbr_glob_dof_map; }
224 
226  void LoseDofOffsets() { dof_offsets.LoseData(); }
227  void LoseTrueDofOffsets() { tdof_offsets.LoseData(); }
228 
229  bool Conforming() const { return pmesh->pncmesh == NULL; }
230  bool Nonconforming() const { return pmesh->pncmesh != NULL; }
231 
232  virtual void Update();
234  virtual FiniteElementSpace *SaveUpdate();
235 
236  virtual ~ParFiniteElementSpace() { delete gcomm; delete P; delete R; }
237 
238  // Obsolete, kept for backward compatibility
239  int TrueVSize() { return ltdof_size; }
240 };
241 
242 }
243 
244 #endif // MFEM_USE_MPI
245 
246 #endif
Abstract class for Finite Elements.
Definition: fe.hpp:44
virtual int GetTrueVSize()
Return the number of local vector true dofs.
Definition: pfespace.hpp:159
HypreParVector * NewTrueDofVector()
Definition: pfespace.hpp:176
int VDofToDof(int vdof) const
Definition: fespace.hpp:251
HYPRE_Int * GetDofOffsets()
Definition: pfespace.hpp:151
Data type dense matrix using column-major storage.
Definition: densemat.hpp:22
void DivideByGroupSize(double *vec)
Scale a vector of true dofs.
Definition: pfespace.cpp:479
Abstract parallel finite element space.
Definition: pfespace.hpp:28
void Synchronize(Array< int > &ldof_marker) const
Definition: pfespace.cpp:515
virtual const SparseMatrix * GetRestrictionMatrix()
Get the R matrix which restricts a local dof vector to true dof vector.
Definition: pfespace.hpp:215
const HYPRE_Int * GetFaceNbrGlobalDofMap()
Definition: pfespace.hpp:223
HYPRE_Int GetMyDofOffset() const
Definition: pfespace.cpp:637
ParNCMesh * pncmesh
Definition: pmesh.hpp:103
HYPRE_Int * GetTrueDofOffsets()
Definition: pfespace.hpp:152
virtual void GetBdrElementDofs(int i, Array< int > &dofs) const
Returns indexes of degrees of freedom for i&#39;th boundary element.
Definition: pfespace.cpp:288
void GetFaceNbrElementVDofs(int i, Array< int > &vdofs) const
Definition: pfespace.cpp:867
HYPRE_Int GetGlobalNumRows() const
Definition: hypre.hpp:333
const FiniteElement * GetFaceNbrFE(int i) const
Definition: pfespace.cpp:873
int dim
Definition: ex3.cpp:48
HYPRE_Int GetGlobalNumCols() const
Definition: hypre.hpp:336
Data type sparse matrix.
Definition: sparsemat.hpp:38
void LoseData()
NULL-ifies the data.
Definition: array.hpp:103
HYPRE_Int GetMyTDofOffset() const
Definition: pfespace.cpp:642
int GetLocalTDofNumber(int ldof)
Definition: pfespace.cpp:555
virtual void GetFaceDofs(int i, Array< int > &dofs) const
Definition: pfespace.cpp:302
HypreParMatrix * Dof_TrueDof_Matrix()
The true dof-to-dof interpolation matrix.
Definition: pfespace.cpp:411
Wrapper for hypre&#39;s parallel vector class.
Definition: hypre.hpp:58
Abstract finite element space.
Definition: fespace.hpp:62
virtual void GetEssentialTrueDofs(const Array< int > &bdr_attr_is_ess, Array< int > &ess_tdof_list)
Definition: pfespace.cpp:545
GroupCommunicator & GroupComm()
Return a reference to the internal GroupCommunicator (on VDofs)
Definition: pfespace.hpp:183
HYPRE_Int GetGlobalScalarTDofNumber(int sldof)
Definition: pfespace.cpp:600
bool Nonconforming() const
Definition: pfespace.hpp:230
virtual void GetElementDofs(int i, Array< int > &dofs) const
Returns indexes of degrees of freedom in array dofs for i&#39;th element.
Definition: pfespace.cpp:274
int GetFaceNbrVSize() const
Definition: pfespace.hpp:220
virtual void GetEssentialVDofs(const Array< int > &bdr_attr_is_ess, Array< int > &ess_dofs) const
Determine the boundary degrees of freedom.
Definition: pfespace.cpp:532
NURBSExtension * NURBSext
Definition: fespace.hpp:90
GroupTopology gtopo
Definition: pmesh.hpp:90
Wrapper for hypre&#39;s ParCSR matrix class.
Definition: hypre.hpp:143
GroupCommunicator * ScalarGroupComm()
Return a new GroupCommunicator on Dofs.
Definition: pfespace.cpp:495
Class for parallel meshes.
Definition: pmesh.hpp:28
virtual FiniteElementSpace * SaveUpdate()
Return a copy of the current FE space and update.
Definition: pfespace.cpp:1554
GroupTopology gtopo
Definition: nurbs.hpp:348
HYPRE_Int GetGlobalTDofNumber(int ldof)
Returns the global tdof number of the given local degree of freedom.
Definition: pfespace.cpp:577
Array< HYPRE_Int > face_nbr_glob_dof_map
Definition: pfespace.hpp:136