Nektar++
AssemblyMapCG.h
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File: AssemblyMapCG.h
4 //
5 // For more information, please see: http://www.nektar.info
6 //
7 // The MIT License
8 //
9 // Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
10 // Department of Aeronautics, Imperial College London (UK), and Scientific
11 // Computing and Imaging Institute, University of Utah (USA).
12 //
13 // Permission is hereby granted, free of charge, to any person obtaining a
14 // copy of this software and associated documentation files (the "Software"),
15 // to deal in the Software without restriction, including without limitation
16 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
17 // and/or sell copies of the Software, and to permit persons to whom the
18 // Software is furnished to do so, subject to the following conditions:
19 //
20 // The above copyright notice and this permission notice shall be included
21 // in all copies or substantial portions of the Software.
22 //
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29 // DEALINGS IN THE SOFTWARE.
30 //
31 // Description: C0-continuous Local to Global mapping routines, base class
32 //
33 ///////////////////////////////////////////////////////////////////////////////
34 
35 #ifndef MULTIREGIONS_ASSEMBLYMAPCG_H
36 #define MULTIREGIONS_ASSEMBLYMAPCG_H
37 
38 #include <tuple>
39 
41 #include <MultiRegions/ExpList.h>
43 
44 namespace Nektar
45 {
46 namespace MultiRegions
47 {
48 static std::map<int, int> NullIntIntMap;
49 const static std::vector<std::map<int, int>> NullVecIntIntMap;
50 
51 class AssemblyMapCG;
52 typedef std::shared_ptr<AssemblyMapCG> AssemblyMapCGSharedPtr;
53 typedef std::tuple<int, int, NekDouble> ExtraDirDof;
54 
55 typedef std::vector<std::map<int, int>> DofGraph;
56 
58 std::pair<int, StdRegions::Orientation> DeterminePeriodicEdgeOrientId(
59  int meshEdgeId, StdRegions::Orientation edgeOrient,
60  const std::vector<PeriodicEntity> &periodicEdges);
61 
64  StdRegions::Orientation faceOrient1, StdRegions::Orientation faceOrient2);
65 
66 /// Constructs mappings for the C0 scalar continuous Galerkin formulation.
67 class AssemblyMapCG : public AssemblyMap
68 {
71 
72 public:
73  /// Default constructor.
76  const LibUtilities::CommSharedPtr &comm,
77  const std::string variable = "DefaultVar");
78 
79  /// General constructor for expansions of all dimensions without
80  /// boundary conditions.
83  const int numLocalCoeffs, const ExpList &locExp,
84  const BndCondExp &bndCondExp = NullExpListSharedPtrArray,
85  const BndCond &bndConditions =
87  const bool checkIfSingular = false,
88  const std::string variable = "defaultVar",
89  const PeriodicMap &periodicVerts = NullPeriodicMap,
90  const PeriodicMap &periodicEdges = NullPeriodicMap,
91  const PeriodicMap &periodicFaces = NullPeriodicMap);
92 
93  /// Destructor.
95 
96  MULTI_REGIONS_EXPORT std::set<ExtraDirDof> &GetCopyLocalDirDofs()
97  {
98  return m_copyLocalDirDofs;
99  }
100 
102  {
103  return m_parallelDirBndSign;
104  }
105 
106 protected:
107  /// Integer map of local coeffs to global space
109  /// Integer sign of local coeffs to global space
111  /// Bandwith of the full matrix system (no static condensation).
113  /// Integer map of process coeffs to universal space
115  /// Integer map of unique process coeffs to universal space (signed)
117  /// Number of non Dirichlet vertex modes
119  /// Number of non Dirichlet edge modes
121  /// Number of non Dirichlet face modes
123  /// Number of Dirichlet edges
125  /// Number of Dirichlet faces
127  /// Number of Dirichlet edges
129  /// Number of Dirichlet faces
131  /// Number of local boundary condition coefficients
133  /// Extra dirichlet edges in parallel
135  /// Number of local boundary condition degrees of freedom.
137  /// Maximum static condensation level.
139  /// Set indicating degrees of freedom which are Dirichlet but whose
140  /// value is stored on another processor.
141  std::set<ExtraDirDof> m_copyLocalDirDofs;
142  /// Set indicating the local coeffs just touching parallel
143  /// dirichlet boundary that have a sign change
144  std::set<int> m_parallelDirBndSign;
145 
147  const ExpList &locExp, const BndCondExp &bndCondExp,
148  const Array<OneD, const BndCond> &bndConditions,
149  const bool checkIfSystemSingular, const PeriodicMap &periodicVerts,
150  const PeriodicMap &periodicEdges, const PeriodicMap &periodicFaces,
151  DofGraph &graph, BottomUpSubStructuredGraphSharedPtr &bottomUpGraph,
152  std::set<int> &extraDirVerts, std::set<int> &extraDirEdges,
153  int &firstNonDirGraphVertId, int &nExtraDirichlet, int mdswitch = 1);
154 
155  void SetUpUniversalC0ContMap(const ExpList &locExp,
156  const PeriodicMap &perVerts = NullPeriodicMap,
157  const PeriodicMap &perEdges = NullPeriodicMap,
158  const PeriodicMap &perFaces = NullPeriodicMap);
159 
160  /// Calculate the bandwith of the full matrix system.
162 
164  const int i) const override;
165 
167  const int i) const override;
168 
170  const int i) const override;
171 
173  &v_GetLocalToGlobalMap() override;
174 
176  &v_GetGlobalToUniversalMap() override;
177 
180 
182  const int i) const override;
183 
185  &v_GetLocalToGlobalSign() const override;
186 
189  bool useComm) const override;
190 
193  bool useComm) const override;
194 
196  const Array<OneD, const NekDouble> &global,
197  Array<OneD, NekDouble> &loc) const override;
198 
200  const NekVector<NekDouble> &global,
201  NekVector<NekDouble> &loc) const override;
202 
203  MULTI_REGIONS_EXPORT virtual void v_Assemble(
205  Array<OneD, NekDouble> &global) const override;
206 
207  MULTI_REGIONS_EXPORT virtual void v_Assemble(
208  const NekVector<NekDouble> &loc,
209  NekVector<NekDouble> &global) const override;
210 
212  Array<OneD, NekDouble> &pGlobal) const override;
213 
215  NekVector<NekDouble> &pGlobal) const override;
216 
218  Array<OneD, NekDouble> &pGlobal, int offset) const override;
219 
220  MULTI_REGIONS_EXPORT virtual int v_GetFullSystemBandWidth() const override;
221 
222  MULTI_REGIONS_EXPORT virtual int v_GetNumNonDirVertexModes() const override;
223 
224  MULTI_REGIONS_EXPORT virtual int v_GetNumNonDirEdgeModes() const override;
225 
226  MULTI_REGIONS_EXPORT virtual int v_GetNumNonDirFaceModes() const override;
227 
228  MULTI_REGIONS_EXPORT virtual int v_GetNumDirEdges() const override;
229 
230  MULTI_REGIONS_EXPORT virtual int v_GetNumDirFaces() const override;
231 
232  MULTI_REGIONS_EXPORT virtual int v_GetNumNonDirEdges() const override;
233 
234  MULTI_REGIONS_EXPORT virtual int v_GetNumNonDirFaces() const override;
235 
237  &v_GetExtraDirEdges() override;
238 
240  const ExpList &locexp, GlobalSysSolnType solnType) override;
241 };
242 
243 } // namespace MultiRegions
244 } // namespace Nektar
245 
246 #endif // MULTIREGIONS_ASSEMBLYMAPCG_H
#define MULTI_REGIONS_EXPORT
Constructs mappings for the C0 scalar continuous Galerkin formulation.
Definition: AssemblyMapCG.h:68
virtual int v_GetFullSystemBandWidth() const override
int m_maxStaticCondLevel
Maximum static condensation level.
int m_numNonDirVertexModes
Number of non Dirichlet vertex modes.
virtual const Array< OneD, const int > & v_GetLocalToGlobalMap() override
int CreateGraph(const ExpList &locExp, const BndCondExp &bndCondExp, const Array< OneD, const BndCond > &bndConditions, const bool checkIfSystemSingular, const PeriodicMap &periodicVerts, const PeriodicMap &periodicEdges, const PeriodicMap &periodicFaces, DofGraph &graph, BottomUpSubStructuredGraphSharedPtr &bottomUpGraph, std::set< int > &extraDirVerts, std::set< int > &extraDirEdges, int &firstNonDirGraphVertId, int &nExtraDirichlet, int mdswitch=1)
virtual const Array< OneD, const int > & v_GetGlobalToUniversalMap() override
virtual void v_GlobalToLocal(const Array< OneD, const NekDouble > &global, Array< OneD, NekDouble > &loc) const override
virtual const Array< OneD, const int > & v_GetExtraDirEdges() override
virtual const Array< OneD, const int > & v_GetGlobalToUniversalMapUnique() override
int m_numNonDirEdges
Number of Dirichlet edges.
virtual int v_GetNumDirFaces() const override
virtual void v_Assemble(const Array< OneD, const NekDouble > &loc, Array< OneD, NekDouble > &global) const override
std::set< int > m_parallelDirBndSign
Set indicating the local coeffs just touching parallel dirichlet boundary that have a sign change.
virtual int v_GetNumDirEdges() const override
Array< OneD, int > m_globalToUniversalMapUnique
Integer map of unique process coeffs to universal space (signed)
Array< OneD, const ExpListSharedPtr > BndCondExp
Definition: AssemblyMapCG.h:69
Array< OneD, int > m_extraDirEdges
Extra dirichlet edges in parallel.
virtual int v_GetNumNonDirVertexModes() const override
int m_numLocDirBndCondDofs
Number of local boundary condition degrees of freedom.
int m_numNonDirFaceModes
Number of non Dirichlet face modes.
virtual void v_UniversalAssemble(Array< OneD, NekDouble > &pGlobal) const override
std::set< ExtraDirDof > & GetCopyLocalDirDofs()
Definition: AssemblyMapCG.h:96
int m_numNonDirEdgeModes
Number of non Dirichlet edge modes.
virtual int v_GetNumNonDirFaces() const override
int m_numDirEdges
Number of Dirichlet edges.
virtual AssemblyMapSharedPtr v_LinearSpaceMap(const ExpList &locexp, GlobalSysSolnType solnType) override
Construct an AssemblyMapCG object which corresponds to the linear space of the current object.
virtual int v_GetNumNonDirEdgeModes() const override
int m_fullSystemBandWidth
Bandwith of the full matrix system (no static condensation).
Array< OneD, int > m_localToGlobalMap
Integer map of local coeffs to global space.
AssemblyMapCG(const LibUtilities::SessionReaderSharedPtr &pSession, const LibUtilities::CommSharedPtr &comm, const std::string variable="DefaultVar")
Default constructor.
int m_numDirFaces
Number of Dirichlet faces.
virtual void v_LocalToGlobal(const Array< OneD, const NekDouble > &loc, Array< OneD, NekDouble > &global, bool useComm) const override
void SetUpUniversalC0ContMap(const ExpList &locExp, const PeriodicMap &perVerts=NullPeriodicMap, const PeriodicMap &perEdges=NullPeriodicMap, const PeriodicMap &perFaces=NullPeriodicMap)
Array< OneD, NekDouble > m_localToGlobalSign
Integer sign of local coeffs to global space.
std::set< int > & GetParallelDirBndSign()
void CalculateFullSystemBandWidth()
Calculate the bandwith of the full matrix system.
std::set< ExtraDirDof > m_copyLocalDirDofs
Set indicating degrees of freedom which are Dirichlet but whose value is stored on another processor.
int m_numNonDirFaces
Number of Dirichlet faces.
Array< OneD, int > m_globalToUniversalMap
Integer map of process coeffs to universal space.
virtual int v_GetNumNonDirFaceModes() const override
virtual int v_GetNumNonDirEdges() const override
virtual const Array< OneD, NekDouble > & v_GetLocalToGlobalSign() const override
Array< OneD, const SpatialDomains::BoundaryConditionShPtr > BndCond
Definition: AssemblyMapCG.h:70
int m_numLocalBndCondCoeffs
Number of local boundary condition coefficients.
Base class for constructing local to global mapping of degrees of freedom.
Definition: AssemblyMap.h:58
Base class for all multi-elemental spectral/hp expansions.
Definition: ExpList.h:103
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::shared_ptr< Comm > CommSharedPtr
Pointer to a Communicator object.
Definition: Comm.h:54
static PeriodicMap NullPeriodicMap
std::shared_ptr< BottomUpSubStructuredGraph > BottomUpSubStructuredGraphSharedPtr
std::shared_ptr< AssemblyMapCG > AssemblyMapCGSharedPtr
Definition: AssemblyMapCG.h:51
std::tuple< int, int, NekDouble > ExtraDirDof
Definition: AssemblyMapCG.h:53
std::vector< std::map< int, int > > DofGraph
Definition: AssemblyMapCG.h:55
static std::map< int, int > NullIntIntMap
Definition: AssemblyMapCG.h:48
pair< int, StdRegions::Orientation > DeterminePeriodicEdgeOrientId(int meshEdgeId, StdRegions::Orientation edgeOrient, const vector< PeriodicEntity > &periodicEdges)
Determine orientation of an edge to its periodic equivalents, as well as the ID of the representative...
static const Array< OneD, ExpListSharedPtr > NullExpListSharedPtrArray
Definition: ExpList.h:2266
std::shared_ptr< AssemblyMap > AssemblyMapSharedPtr
Definition: AssemblyMap.h:51
std::map< int, std::vector< PeriodicEntity > > PeriodicMap
static const std::vector< std::map< int, int > > NullVecIntIntMap
Definition: AssemblyMapCG.h:49
StdRegions::Orientation DeterminePeriodicFaceOrient(StdRegions::Orientation faceOrient, StdRegions::Orientation perFaceOrient)
Determine relative orientation between two faces.
static const Array< OneD, BoundaryConditionShPtr > NullBoundaryConditionShPtrArray
Definition: Conditions.h:222
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:2
double NekDouble