Nektar++
AssemblyMap.h
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File AssemblyMap.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: Assembly (e.g. local to global) base mapping routines
32 //
33 ///////////////////////////////////////////////////////////////////////////////
34 
35 #ifndef MULTIREGIONS_ASSEMBLY_MAP_H
36 #define MULTIREGIONS_ASSEMBLY_MAP_H
37 
41 #include <vector>
44 
45 
46 namespace Nektar
47 {
48  namespace MultiRegions
49  {
50  // Forward declarations
51  class AssemblyMap;
52  class ExpList;
53  typedef std::shared_ptr<AssemblyMap> AssemblyMapSharedPtr;
54  static AssemblyMapSharedPtr NullAssemblyMapSharedPtr;
55 
56  /// Base class for constructing local to global mapping of degrees of
57  /// freedom.
59  {
60  public:
61  /// Default constructor.
63  /// Constructor with a communicator
66  const std::string variable = "DefaultVar");
67 
68  /// Constructor for next level in multi-level static condensation.
69  MULTI_REGIONS_EXPORT AssemblyMap(AssemblyMap* oldLevelMap,
70  const BottomUpSubStructuredGraphSharedPtr& multiLevelGraph);
71  /// Destructor.
73 
74  /// Retrieves the communicator
76 
77  /// Retrieves the hash of this map
78  MULTI_REGIONS_EXPORT size_t GetHash() const;
79 
80  MULTI_REGIONS_EXPORT int GetLocalToGlobalMap(const int i) const;
81 
82  MULTI_REGIONS_EXPORT int GetGlobalToUniversalMap(const int i) const;
83 
85 
87 
89 
91 
93 
95 
98  Array<OneD, NekDouble>& global,
99  bool useComm = true) const;
100 
102  const NekVector<NekDouble>& loc,
103  NekVector< NekDouble>& global,
104  bool useComm = true) const;
105 
107  const Array<OneD, const NekDouble>& global,
108  Array<OneD, NekDouble>& loc) const;
109 
111  const NekVector<NekDouble>& global,
112  NekVector< NekDouble>& loc) const;
113 
115  const Array<OneD, const NekDouble> &loc,
116  Array<OneD, NekDouble> &global) const;
117 
119  const NekVector<NekDouble>& loc,
120  NekVector< NekDouble>& global) const;
121 
123  Array<OneD, NekDouble>& pGlobal) const;
124 
126  NekVector< NekDouble>& pGlobal) const;
127 
129  Array<OneD, NekDouble>& pGlobal,
130  int offset) const;
131 
132  /// Retrieve the global index of a given local boundary mode.
133  MULTI_REGIONS_EXPORT int GetLocalToGlobalBndMap(const int i) const;
134  /// Retrieve the global indices of the local boundary modes.
136 
138 
140 
141  /// Returns true if using a modal expansion requiring a change of
142  /// sign of some modes.
144 
145  /// Retrieve the sign change of a given local boundary mode.
147  /// Retrieve the sign change for all local boundary modes.
149  /// Retrieves the global index corresponding to a boundary expansion
150  /// mode.
152  /// Retrieves the global indices corresponding to the boundary
153  /// expansion modes.
156  /// Returns the modal sign associated with a given boundary
157  /// expansion mode.
159 
160  /// Returns the global index of the boundary trace giving the
161  /// index on the boundary expansion
165 
166  /// Returns the number of global Dirichlet boundary coefficients.
168  /// Returns the number of local Dirichlet boundary coefficients.
170  /// Returns the total number of global boundary coefficients.
172  /// Returns the total number of local boundary coefficients.
174  /// Returns the total number of local coefficients.
176  /// Returns the total number of global coefficients.
178  /// Retrieves if the system is singular (true) or not (false)
180 
181  ///
183  const NekVector<NekDouble>& global,
185  int offset) const;
186 
188  const NekVector<NekDouble>& global,
189  NekVector<NekDouble>& loc) const;
190 
192  const Array<OneD, const NekDouble>& global,
194  int offset) const;
195 
197  const Array<OneD, const NekDouble>& global,
198  Array<OneD,NekDouble>& loc) const;
199 
201  const NekVector<NekDouble>& loc,
202  NekVector<NekDouble>& global,
203  int offset) const;
204 
206  const NekVector<NekDouble>& loc,
207  NekVector<NekDouble>& global) const;
208 
210  const Array<OneD, const NekDouble>& loc,
211  Array<OneD,NekDouble>& global,
212  int offset) const;
213 
215  const Array<OneD, const NekDouble>& loc,
216  Array<OneD,NekDouble>& global) const;
217 
219  NekVector<NekDouble>& global, int offset) const;
220 
222  NekVector<NekDouble>& global) const;
223 
225  Array<OneD, NekDouble>& global, int offset) const;
226 
228  Array<OneD, NekDouble>& global) const;
229 
231  Array<OneD, NekDouble>& pGlobal) const;
232 
234  NekVector< NekDouble>& pGlobal) const;
235 
237  Array<OneD, NekDouble>& pGlobal,
238  int offset) const;
239 
241 
243 
245 
247 
249 
251 
253 
255 
256  MULTI_REGIONS_EXPORT void PrintStats(std::ostream &out, std::string variable, bool printHeader = true) const;
257 
260 
261  MULTI_REGIONS_EXPORT std::shared_ptr<AssemblyMap> LinearSpaceMap(const ExpList &locexp, GlobalSysSolnType solnType);
262 
263  /// Returns the bandwidth of the boundary system.
265  /// Returns the level of static condensation for this map.
267  /// Returns the number of patches in this static condensation level.
269  /// Returns the number of local boundary coefficients in each patch.
272  /// Returns the number of local interior coefficients in each patch.
275  /// Returns the local to global mapping for the next level in the
276  /// multi-level static condensation.
277  MULTI_REGIONS_EXPORT const AssemblyMapSharedPtr
279 
280  MULTI_REGIONS_EXPORT void SetNextLevelLocalToGlobalMap( AssemblyMapSharedPtr pNextLevelLocalToGlobalMap);
281 
282  /// Returns the patch map from the previous level
283  /// of the multi-level static condensation.
285  GetPatchMapFromPrevLevel(void) const;
286 
287  /// Returns true if this is the last level in the multi-level
288  /// static condensation.
289  MULTI_REGIONS_EXPORT bool AtLastLevel() const;
290  /// Returns the method of solving global systems.
296 
298  {
300  }
301 
302  protected:
303  /// Session object
305 
306  /// Communicator
308 
309  /// Hash for map
310  size_t m_hash;
311 
312  /// Number of local boundary coefficients
314  /// Total number of global boundary coefficients
316  /// Number of Local Dirichlet Boundary Coefficients
318  /// Number of Global Dirichlet Boundary Coefficients
320  /// Flag indicating if the system is singular or not
322 
323  /// Total number of local coefficients
324  /** This corresponds to the number of total number of coefficients
325  * - For CG this corresponds to the total of bnd + int DOFs
326  * - For DG this corresponds to the number of bnd DOFs.
327  * This means that #m_numLocalCoeffs = #m_numLocalBndCoeffs
328  * This way, we can consider the trace-system solve as a
329  * statically condensed solve without interior DOFs. This allows
330  * us to use the same global system solver for both cases.
331  */
333 
334  /// Total number of global coefficients
335  /** This corresponds to the number of total number of coefficients
336  * - For CG this corresponds to the total of bnd + int DOFs.
337  * - For DG this corresponds to the number of bnd DOFs.
338  * This means that #m_numGlobalCoeffs = #m_numGlobalBndCoeffs
339  * This way, we can consider the trace-system solve as a
340  * statically condensed solve without interior DOFs. This allows
341  * us to use the same global system solver for both cases.
342  */
344 
345  /// Flag indicating if modes require sign reversal.
347 
348  /// Integer map of local boundary coeffs to global space
350  /// Integer sign of local boundary coeffs to global space
352  /// Integer map of bnd cond coeffs to global coefficients
354  /// Integer map of bnd cond coeffs to global coefficients
356  /// Integer map of bnd cond trace number to global trace number
358  /// Integer map of process coeffs to universal space
360  /// Integer map of unique process coeffs to universal space (signed)
362 
363  /// The solution type of the global system
365  /// The bandwith of the global bnd system
367 
368  /// Type type of preconditioner to use in iterative solver.
370 
371  /// Maximum iterations for iterative solver
373 
374  /// Tolerance for iterative solver
376 
377  /// sucessive RHS for iterative solver
379 
382 
383  /// The level of recursion in the case of multi-level static
384  /// condensation.
386  /// The number of patches (~elements) in the current level
388  /// The number of bnd dofs per patch
390  /// The number of int dofs per patch
392  /// Map from the patches of the previous level to the patches of
393  /// the current level
394 
395  /// The local to global mapping of the next level of recursion
396  AssemblyMapSharedPtr m_nextLevelLocalToGlobalMap;
397  /// Lowest static condensation level.
399 
400  /// Calculates the bandwidth of the boundary system.
402 
404  const Array<OneD, const NekDouble>& global,
405  Array<OneD,NekDouble>& loc);
406 
407  private:
408  /// Mapping information for previous level in MultiLevel Solver
410 
411  virtual int v_GetLocalToGlobalMap(const int i) const;
412 
413  virtual int v_GetGlobalToUniversalMap(const int i) const;
414 
415  virtual int v_GetGlobalToUniversalMapUnique(const int i) const;
416 
418 
420 
422 
423  virtual NekDouble v_GetLocalToGlobalSign(const int i) const;
424 
425  virtual const Array<OneD, NekDouble>& v_GetLocalToGlobalSign() const;
426 
427  virtual void v_LocalToGlobal(
428  const Array<OneD, const NekDouble>& loc,
429  Array<OneD, NekDouble>& global,
430  bool useComm) const;
431 
432  virtual void v_LocalToGlobal(
433  const NekVector<NekDouble>& loc,
434  NekVector< NekDouble>& global,
435  bool useComm) const;
436 
437  virtual void v_GlobalToLocal(
438  const Array<OneD, const NekDouble>& global,
439  Array<OneD, NekDouble>& loc) const;
440 
441  virtual void v_GlobalToLocal(
442  const NekVector<NekDouble>& global,
443  NekVector< NekDouble>& loc) const;
444 
445  virtual void v_Assemble(
446  const Array<OneD, const NekDouble> &loc,
447  Array<OneD, NekDouble> &global) const;
448 
449  virtual void v_Assemble(
450  const NekVector<NekDouble>& loc,
451  NekVector< NekDouble>& global) const;
452 
453  virtual void v_UniversalAssemble(
454  Array<OneD, NekDouble>& pGlobal) const;
455 
456  virtual void v_UniversalAssemble(
457  NekVector< NekDouble>& pGlobal) const;
458 
459  virtual void v_UniversalAssemble(
460  Array<OneD, NekDouble>& pGlobal,
461  int offset) const;
462 
463  virtual int v_GetFullSystemBandWidth() const;
464 
465  virtual int v_GetNumNonDirVertexModes() const;
466 
467  virtual int v_GetNumNonDirEdgeModes() const;
468 
469  virtual int v_GetNumNonDirFaceModes() const;
470 
471  virtual int v_GetNumDirEdges() const;
472 
473  virtual int v_GetNumDirFaces() const;
474 
475  virtual int v_GetNumNonDirEdges() const;
476 
477  virtual int v_GetNumNonDirFaces() const;
478 
479  virtual const Array<OneD, const int>&
481 
482  /// Generate a linear space mapping from existing mapping
483  virtual std::shared_ptr<AssemblyMap> v_LinearSpaceMap(
484  const ExpList &locexp, GlobalSysSolnType solnType);
485  };
486 
487 
488  } // end of namespace
489 } // end of namespace
490 
491 #endif //MULTIREGIONS_ASSEMBLY_MAP_H
492 
493 
const Array< OneD, const int > & GetBndCondTraceToGlobalTraceMap()
void GlobalToLocalBnd(const NekVector< NekDouble > &global, NekVector< NekDouble > &loc, int offset) const
int GetNumLocalDirBndCoeffs() const
Returns the number of local Dirichlet boundary coefficients.
virtual int v_GetFullSystemBandWidth() const
bool m_systemSingular
Flag indicating if the system is singular or not.
Definition: AssemblyMap.h:321
const Array< OneD, const int > & GetGlobalToUniversalMap()
bool m_signChange
Flag indicating if modes require sign reversal.
Definition: AssemblyMap.h:346
PreconditionerType GetPreconType() const
PreconditionerType m_preconType
Type type of preconditioner to use in iterative solver.
Definition: AssemblyMap.h:369
int m_numGlobalBndCoeffs
Total number of global boundary coefficients.
Definition: AssemblyMap.h:315
int GetNumGlobalCoeffs() const
Returns the total number of global coefficients.
LibUtilities::CommSharedPtr GetComm()
Retrieves the communicator.
bool GetSingularSystem() const
Retrieves if the system is singular (true) or not (false)
int GetBndSystemBandWidth() const
Returns the bandwidth of the boundary system.
LibUtilities::CommSharedPtr m_comm
Communicator.
Definition: AssemblyMap.h:307
virtual ~AssemblyMap()
Destructor.
Array< OneD, int > m_bndCondTraceToGlobalTraceMap
Integer map of bnd cond trace number to global trace number.
Definition: AssemblyMap.h:357
virtual int v_GetNumNonDirFaceModes() const
std::shared_ptr< Comm > CommSharedPtr
Pointer to a Communicator object.
Definition: Comm.h:53
#define MULTI_REGIONS_EXPORT
virtual int v_GetNumNonDirEdgeModes() const
virtual int v_GetNumNonDirEdges() const
virtual void v_LocalToGlobal(const Array< OneD, const NekDouble > &loc, Array< OneD, NekDouble > &global, bool useComm) const
int m_numLocalCoeffs
Total number of local coefficients.
Definition: AssemblyMap.h:332
const Array< OneD, const int > & GetExtraDirEdges()
void UniversalAssemble(Array< OneD, NekDouble > &pGlobal) const
PatchMapSharedPtr m_patchMapFromPrevLevel
Mapping information for previous level in MultiLevel Solver.
Definition: AssemblyMap.h:409
const Array< OneD, const int > & GetGlobalToUniversalBndMapUnique()
std::shared_ptr< AssemblyMap > AssemblyMapSharedPtr
Definition: AssemblyMap.h:52
const Array< OneD, const int > & GetLocalToGlobalBndMap()
Retrieve the global indices of the local boundary modes.
AssemblyMapSharedPtr m_nextLevelLocalToGlobalMap
Map from the patches of the previous level to the patches of the current level.
Definition: AssemblyMap.h:396
virtual std::shared_ptr< AssemblyMap > v_LinearSpaceMap(const ExpList &locexp, GlobalSysSolnType solnType)
Generate a linear space mapping from existing mapping.
Base class for constructing local to global mapping of degrees of freedom.
Definition: AssemblyMap.h:58
virtual int v_GetNumDirEdges() const
int m_successiveRHS
sucessive RHS for iterative solver
Definition: AssemblyMap.h:378
const PatchMapSharedPtr & GetPatchMapFromPrevLevel(void) const
Returns the patch map from the previous level of the multi-level static condensation.
virtual void v_UniversalAssemble(Array< OneD, NekDouble > &pGlobal) const
int GetNumLocalBndCoeffs() const
Returns the total number of local boundary coefficients.
bool AtLastLevel() const
Returns true if this is the last level in the multi-level static condensation.
size_t m_hash
Hash for map.
Definition: AssemblyMap.h:310
Base class for all multi-elemental spectral/hp expansions.
Definition: ExpList.h:103
std::shared_ptr< PatchMap > PatchMapSharedPtr
int GetNumGlobalBndCoeffs() const
Returns the total number of global boundary coefficients.
virtual void v_Assemble(const Array< OneD, const NekDouble > &loc, Array< OneD, NekDouble > &global) const
int m_bndSystemBandWidth
The bandwith of the global bnd system.
Definition: AssemblyMap.h:366
virtual void v_GlobalToLocal(const Array< OneD, const NekDouble > &global, Array< OneD, NekDouble > &loc) const
NekDouble m_iterativeTolerance
Tolerance for iterative solver.
Definition: AssemblyMap.h:375
virtual int v_GetNumNonDirFaces() const
NekDouble GetIterativeTolerance() const
Array< OneD, unsigned int > m_numLocalBndCoeffsPerPatch
The number of bnd dofs per patch.
Definition: AssemblyMap.h:389
GlobalSysSolnType m_solnType
The solution type of the global system.
Definition: AssemblyMap.h:364
Array< OneD, NekDouble > m_bndCondCoeffsToGlobalCoeffsSign
Integer map of bnd cond coeffs to global coefficients.
Definition: AssemblyMap.h:355
int m_numGlobalDirBndCoeffs
Number of Global Dirichlet Boundary Coefficients.
Definition: AssemblyMap.h:319
NekDouble GetBndCondCoeffsToGlobalCoeffsSign(const int i)
Returns the modal sign associated with a given boundary expansion mode.
void SetNextLevelLocalToGlobalMap(AssemblyMapSharedPtr pNextLevelLocalToGlobalMap)
void LocalBndToGlobal(const NekVector< NekDouble > &loc, NekVector< NekDouble > &global, int offset) const
Array< OneD, const NekDouble > GetLocalToGlobalBndSign() const
Retrieve the sign change for all local boundary modes.
void UniversalAssembleBnd(Array< OneD, NekDouble > &pGlobal) const
size_t GetHash() const
Retrieves the hash of this map.
virtual int v_GetNumDirFaces() const
double NekDouble
GlobalSysSolnType GetGlobalSysSolnType() const
Returns the method of solving global systems.
virtual int v_GetNumNonDirVertexModes() const
Array< OneD, unsigned int > m_numLocalIntCoeffsPerPatch
The number of int dofs per patch.
Definition: AssemblyMap.h:391
const AssemblyMapSharedPtr GetNextLevelLocalToGlobalMap() const
Returns the local to global mapping for the next level in the multi-level static condensation.
int GetNumGlobalDirBndCoeffs() const
Returns the number of global Dirichlet boundary coefficients.
int m_lowestStaticCondLevel
Lowest static condensation level.
Definition: AssemblyMap.h:398
void CalculateBndSystemBandWidth()
Calculates the bandwidth of the boundary system.
Array< OneD, int > m_localToGlobalBndMap
Integer map of local boundary coeffs to global space.
Definition: AssemblyMap.h:349
const Array< OneD, const int > & GetBndCondCoeffsToGlobalCoeffsMap()
Retrieves the global indices corresponding to the boundary expansion modes.
int m_numLocalDirBndCoeffs
Number of Local Dirichlet Boundary Coefficients.
Definition: AssemblyMap.h:317
bool GetSignChange()
Returns true if using a modal expansion requiring a change of sign of some modes. ...
const Array< OneD, const int > & GetLocalToGlobalMap()
const Array< OneD, const int > & GetGlobalToUniversalBndMap()
Array< OneD, int > m_bndCondCoeffsToGlobalCoeffsMap
Integer map of bnd cond coeffs to global coefficients.
Definition: AssemblyMap.h:353
const Array< OneD, NekDouble > & GetLocalToGlobalSign() const
int m_numLocalBndCoeffs
Number of local boundary coefficients.
Definition: AssemblyMap.h:313
static AssemblyMapSharedPtr NullAssemblyMapSharedPtr
Definition: AssemblyMap.h:54
void LocalToGlobal(const Array< OneD, const NekDouble > &loc, Array< OneD, NekDouble > &global, bool useComm=true) const
int m_staticCondLevel
The level of recursion in the case of multi-level static condensation.
Definition: AssemblyMap.h:385
Array< OneD, NekDouble > m_localToGlobalBndSign
Integer sign of local boundary coeffs to global space.
Definition: AssemblyMap.h:351
void Assemble(const Array< OneD, const NekDouble > &loc, Array< OneD, NekDouble > &global) const
AssemblyMap()
Default constructor.
Definition: AssemblyMap.cpp:80
int m_maxIterations
Maximum iterations for iterative solver.
Definition: AssemblyMap.h:372
int GetStaticCondLevel() const
Returns the level of static condensation for this map.
virtual const Array< OneD, NekDouble > & v_GetLocalToGlobalSign() const
const Array< OneD, const unsigned int > & GetNumLocalBndCoeffsPerPatch()
Returns the number of local boundary coefficients in each patch.
void AssembleBnd(const NekVector< NekDouble > &loc, NekVector< NekDouble > &global, int offset) const
void GlobalToLocalBndWithoutSign(const Array< OneD, const NekDouble > &global, Array< OneD, NekDouble > &loc)
const Array< OneD, const int > & GetGlobalToUniversalMapUnique()
int GetNumPatches() const
Returns the number of patches in this static condensation level.
void PrintStats(std::ostream &out, std::string variable, bool printHeader=true) const
LibUtilities::SessionReaderSharedPtr m_session
Session object.
Definition: AssemblyMap.h:304
int GetNumLocalCoeffs() const
Returns the total number of local coefficients.
virtual const Array< OneD, const int > & v_GetExtraDirEdges()
Array< OneD, int > m_globalToUniversalBndMap
Integer map of process coeffs to universal space.
Definition: AssemblyMap.h:359
Array< OneD, int > m_globalToUniversalBndMapUnique
Integer map of unique process coeffs to universal space (signed)
Definition: AssemblyMap.h:361
virtual const Array< OneD, const int > & v_GetGlobalToUniversalMapUnique()
int m_numGlobalCoeffs
Total number of global coefficients.
Definition: AssemblyMap.h:343
const Array< OneD, const unsigned int > & GetNumLocalIntCoeffsPerPatch()
Returns the number of local interior coefficients in each patch.
std::shared_ptr< AssemblyMap > LinearSpaceMap(const ExpList &locexp, GlobalSysSolnType solnType)
virtual const Array< OneD, const int > & v_GetGlobalToUniversalMap()
std::shared_ptr< BottomUpSubStructuredGraph > BottomUpSubStructuredGraphSharedPtr
std::shared_ptr< SessionReader > SessionReaderSharedPtr
virtual const Array< OneD, const int > & v_GetLocalToGlobalMap()
int m_numPatches
The number of patches (~elements) in the current level.
Definition: AssemblyMap.h:387
void GlobalToLocal(const Array< OneD, const NekDouble > &global, Array< OneD, NekDouble > &loc) const