Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 // License for the specific language governing rights and limitations under
14 // Permission is hereby granted, free of charge, to any person obtaining a
15 // copy of this software and associated documentation files (the "Software"),
16 // to deal in the Software without restriction, including without limitation
17 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
18 // and/or sell copies of the Software, and to permit persons to whom the
19 // Software is furnished to do so, subject to the following conditions:
20 //
21 // The above copyright notice and this permission notice shall be included
22 // in all copies or substantial portions of the Software.
23 //
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
25 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
27 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
30 // DEALINGS IN THE SOFTWARE.
31 //
32 // Description: Assembly (e.g. local to global) base mapping routines
33 //
34 ///////////////////////////////////////////////////////////////////////////////
35 
36 #ifndef MULTIREGIONS_ASSEMBLY_MAP_H
37 #define MULTIREGIONS_ASSEMBLY_MAP_H
38 
42 #include <vector>
45 
46 
47 namespace Nektar
48 {
49  namespace MultiRegions
50  {
51  // Forward declarations
52  class AssemblyMap;
53  class ExpList;
54  typedef boost::shared_ptr<AssemblyMap> AssemblyMapSharedPtr;
56 
57  /// Base class for constructing local to global mapping of degrees of
58  /// freedom.
60  {
61  public:
62  /// Default constructor.
64  /// Constructor with a communicator
67  const std::string variable = "DefaultVar");
68 
69  /// Constructor for next level in multi-level static condensation.
70  MULTI_REGIONS_EXPORT AssemblyMap(AssemblyMap* oldLevelMap,
71  const BottomUpSubStructuredGraphSharedPtr& multiLevelGraph);
72  /// Destructor.
74 
75  /// Retrieves the communicator
77 
78  /// Retrieves the hash of this map
79  MULTI_REGIONS_EXPORT size_t GetHash() const;
80 
81  MULTI_REGIONS_EXPORT int GetLocalToGlobalMap(const int i) const;
82 
83  MULTI_REGIONS_EXPORT int GetGlobalToUniversalMap(const int i) const;
84 
86 
87  MULTI_REGIONS_EXPORT const Array<OneD,const int>& GetLocalToGlobalMap();
88 
89  MULTI_REGIONS_EXPORT const Array<OneD, const int>& GetGlobalToUniversalMap();
90 
91  MULTI_REGIONS_EXPORT const Array<OneD, const int>& GetGlobalToUniversalMapUnique();
92 
94 
95  MULTI_REGIONS_EXPORT const Array<OneD, NekDouble>& GetLocalToGlobalSign() const;
96 
98  const Array<OneD, const NekDouble>& loc,
99  Array<OneD, NekDouble>& global) const;
100 
102  const NekVector<NekDouble>& loc,
103  NekVector< NekDouble>& global) const;
104 
106  const Array<OneD, const NekDouble>& global,
107  Array<OneD, NekDouble>& loc) const;
108 
110  const NekVector<NekDouble>& global,
111  NekVector< NekDouble>& loc) const;
112 
114  const Array<OneD, const NekDouble> &loc,
115  Array<OneD, NekDouble> &global) const;
116 
118  const NekVector<NekDouble>& loc,
119  NekVector< NekDouble>& global) const;
120 
122  Array<OneD, NekDouble>& pGlobal) const;
123 
125  NekVector< NekDouble>& pGlobal) const;
126 
128  Array<OneD, NekDouble>& pGlobal,
129  int offset) const;
130 
131  /// Retrieve the global index of a given local boundary mode.
132  MULTI_REGIONS_EXPORT int GetLocalToGlobalBndMap(const int i) const;
133  /// Retrieve the global indices of the local boundary modes.
134  MULTI_REGIONS_EXPORT const Array<OneD,const int>& GetLocalToGlobalBndMap();
135 
136  MULTI_REGIONS_EXPORT const Array<OneD, const int>& GetGlobalToUniversalBndMap();
137 
138  MULTI_REGIONS_EXPORT const Array<OneD, const int>& GetGlobalToUniversalBndMapUnique();
139 
140  /// Returns true if using a modal expansion requiring a change of
141  /// sign of some modes.
143 
144  /// Retrieve the sign change of a given local boundary mode.
145  NekDouble GetLocalToGlobalBndSign(const int i) const;
146  /// Retrieve the sign change for all local boundary modes.
147  Array<OneD, const NekDouble> GetLocalToGlobalBndSign() const;
148  /// Retrieves the global index corresponding to a boundary expansion
149  /// mode.
151  /// Retrieves the global indices corresponding to the boundary
152  /// expansion modes.
153  MULTI_REGIONS_EXPORT const Array<OneD,const int>&
155  /// Returns the modal sign associated with a given boundary
156  /// expansion mode.
158 
159  /// Returns the global index of the boundary trace giving the
160  /// index on the boundary expansion
162  MULTI_REGIONS_EXPORT const Array<OneD, const int>
164 
165  /// Returns the number of global Dirichlet boundary coefficients.
167  /// Returns the number of local Dirichlet boundary coefficients.
169  /// Returns the total number of global boundary coefficients.
171  /// Returns the total number of local boundary coefficients.
173  /// Returns the total number of local coefficients.
175  /// Returns the total number of global coefficients.
177  /// Retrieves if the system is singular (true) or not (false)
179 
180  ///
182  const NekVector<NekDouble>& global,
184  int offset) const;
185 
187  const NekVector<NekDouble>& global,
188  NekVector<NekDouble>& loc) const;
189 
191  const Array<OneD, const NekDouble>& global,
192  Array<OneD,NekDouble>& loc,
193  int offset) const;
194 
196  const Array<OneD, const NekDouble>& global,
197  Array<OneD,NekDouble>& loc) const;
198 
200  const NekVector<NekDouble>& loc,
201  NekVector<NekDouble>& global,
202  int offset) const;
203 
205  const NekVector<NekDouble>& loc,
206  NekVector<NekDouble>& global) const;
207 
209  const Array<OneD, const NekDouble>& loc,
210  Array<OneD,NekDouble>& global,
211  int offset) const;
212 
214  const Array<OneD, const NekDouble>& loc,
215  Array<OneD,NekDouble>& global) const;
216 
218  NekVector<NekDouble>& global, int offset) const;
219 
221  NekVector<NekDouble>& global) const;
222 
223  MULTI_REGIONS_EXPORT void AssembleBnd(const Array<OneD,const NekDouble>& loc,
224  Array<OneD, NekDouble>& global, int offset) const;
225 
226  MULTI_REGIONS_EXPORT void AssembleBnd(const Array<OneD, const NekDouble>& loc,
227  Array<OneD, NekDouble>& global) const;
228 
230  Array<OneD, NekDouble>& pGlobal) const;
231 
233  NekVector< NekDouble>& pGlobal) const;
234 
236  Array<OneD, NekDouble>& pGlobal,
237  int offset) const;
238 
240 
242 
244 
246 
248 
250 
252 
254 
255  MULTI_REGIONS_EXPORT void PrintStats(std::ostream &out, std::string variable) const;
256 
257  MULTI_REGIONS_EXPORT const Array<OneD, const int>&
259 
260  MULTI_REGIONS_EXPORT boost::shared_ptr<AssemblyMap> LinearSpaceMap(const ExpList &locexp, GlobalSysSolnType solnType);
261 
262  /// Returns the bandwidth of the boundary system.
264  /// Returns the level of static condensation for this map.
266  /// Returns the number of patches in this static condensation level.
268  /// Returns the number of local boundary coefficients in each patch.
269  MULTI_REGIONS_EXPORT const Array<OneD,const unsigned int>&
271  /// Returns the number of local interior coefficients in each patch.
272  MULTI_REGIONS_EXPORT const Array<OneD,const unsigned int>&
274  /// Returns the local to global mapping for the next level in the
275  /// multi-level static condensation.
278 
280 
281  /// Returns the patch map from the previous level
282  /// of the multi-level static condensation.
284  GetPatchMapFromPrevLevel(void) const;
285 
286  /// Returns true if this is the last level in the multi-level
287  /// static condensation.
288  MULTI_REGIONS_EXPORT bool AtLastLevel() const;
289  /// Returns the method of solving global systems.
294 
296  {
298  }
299 
300  protected:
301  /// Session object
303 
304  /// Communicator
306 
307  /// Hash for map
308  size_t m_hash;
309 
310  /// Number of local boundary coefficients
312  /// Total number of global boundary coefficients
314  /// Number of Local Dirichlet Boundary Coefficients
316  /// Number of Global Dirichlet Boundary Coefficients
318  /// Flag indicating if the system is singular or not
320 
321  /// Total number of local coefficients
322  /** This corresponds to the number of total number of coefficients
323  * - For CG this corresponds to the total of bnd + int DOFs
324  * - For DG this corresponds to the number of bnd DOFs.
325  * This means that #m_numLocalCoeffs = #m_numLocalBndCoeffs
326  * This way, we can consider the trace-system solve as a
327  * statically condensed solve without interior DOFs. This allows
328  * us to use the same global system solver for both cases.
329  */
331 
332  /// Total number of global coefficients
333  /** This corresponds to the number of total number of coefficients
334  * - For CG this corresponds to the total of bnd + int DOFs.
335  * - For DG this corresponds to the number of bnd DOFs.
336  * This means that #m_numGlobalCoeffs = #m_numGlobalBndCoeffs
337  * This way, we can consider the trace-system solve as a
338  * statically condensed solve without interior DOFs. This allows
339  * us to use the same global system solver for both cases.
340  */
342 
343  /// Flag indicating if modes require sign reversal.
345 
346  /// Integer map of local boundary coeffs to global space
347  Array<OneD,int> m_localToGlobalBndMap;
348  /// Integer sign of local boundary coeffs to global space
349  Array<OneD,NekDouble> m_localToGlobalBndSign;
350  /// Integer map of bnd cond coeffs to global coefficients
352  /// Integer map of bnd cond coeffs to global coefficients
353  Array<OneD,NekDouble> m_bndCondCoeffsToGlobalCoeffsSign;
354  /// Integer map of bnd cond trace number to global trace number
356  /// Integer map of process coeffs to universal space
357  Array<OneD,int> m_globalToUniversalBndMap;
358  /// Integer map of unique process coeffs to universal space (signed)
360 
361  /// The solution type of the global system
363  /// The bandwith of the global bnd system
365 
366  /// Type type of preconditioner to use in iterative solver.
368 
369  /// Tolerance for iterative solver
371 
372  /// sucessive RHS for iterative solver
374 
377 
378  /// The level of recursion in the case of multi-level static
379  /// condensation.
381  /// The number of patches (~elements) in the current level
383  /// The number of bnd dofs per patch
384  Array<OneD, unsigned int> m_numLocalBndCoeffsPerPatch;
385  /// The number of int dofs per patch
386  Array<OneD, unsigned int> m_numLocalIntCoeffsPerPatch;
387  /// Map from the patches of the previous level to the patches of
388  /// the current level
389 
390  /// The local to global mapping of the next level of recursion
392  /// Lowest static condensation level.
394 
395  /// Calculates the bandwidth of the boundary system.
397 
399  const Array<OneD, const NekDouble>& global,
400  Array<OneD,NekDouble>& loc);
401 
402  private:
403  /// Mapping information for previous level in MultiLevel Solver
405 
406  virtual int v_GetLocalToGlobalMap(const int i) const;
407 
408  virtual int v_GetGlobalToUniversalMap(const int i) const;
409 
410  virtual int v_GetGlobalToUniversalMapUnique(const int i) const;
411 
412  virtual const Array<OneD,const int>& v_GetLocalToGlobalMap();
413 
414  virtual const Array<OneD, const int>& v_GetGlobalToUniversalMap();
415 
416  virtual const Array<OneD, const int>& v_GetGlobalToUniversalMapUnique();
417 
418  virtual NekDouble v_GetLocalToGlobalSign(const int i) const;
419 
420  virtual const Array<OneD, NekDouble>& v_GetLocalToGlobalSign() const;
421 
422  virtual void v_LocalToGlobal(
423  const Array<OneD, const NekDouble>& loc,
424  Array<OneD, NekDouble>& global) const;
425 
426  virtual void v_LocalToGlobal(
427  const NekVector<NekDouble>& loc,
428  NekVector< NekDouble>& global) const;
429 
430  virtual void v_GlobalToLocal(
431  const Array<OneD, const NekDouble>& global,
432  Array<OneD, NekDouble>& loc) const;
433 
434  virtual void v_GlobalToLocal(
435  const NekVector<NekDouble>& global,
436  NekVector< NekDouble>& loc) const;
437 
438  virtual void v_Assemble(
439  const Array<OneD, const NekDouble> &loc,
440  Array<OneD, NekDouble> &global) const;
441 
442  virtual void v_Assemble(
443  const NekVector<NekDouble>& loc,
444  NekVector< NekDouble>& global) const;
445 
446  virtual void v_UniversalAssemble(
447  Array<OneD, NekDouble>& pGlobal) const;
448 
449  virtual void v_UniversalAssemble(
450  NekVector< NekDouble>& pGlobal) const;
451 
452  virtual void v_UniversalAssemble(
453  Array<OneD, NekDouble>& pGlobal,
454  int offset) const;
455 
456  virtual int v_GetFullSystemBandWidth() const;
457 
458  virtual int v_GetNumNonDirVertexModes() const;
459 
460  virtual int v_GetNumNonDirEdgeModes() const;
461 
462  virtual int v_GetNumNonDirFaceModes() const;
463 
464  virtual int v_GetNumDirEdges() const;
465 
466  virtual int v_GetNumDirFaces() const;
467 
468  virtual int v_GetNumNonDirEdges() const;
469 
470  virtual int v_GetNumNonDirFaces() const;
471 
472  virtual const Array<OneD, const int>&
474 
475  /// Generate a linear space mapping from existing mapping
476  virtual boost::shared_ptr<AssemblyMap> v_LinearSpaceMap(
477  const ExpList &locexp, GlobalSysSolnType solnType);
478  };
479 
480 
481  } // end of namespace
482 } // end of namespace
483 
484 #endif //MULTIREGIONS_ASSEMBLY_MAP_H
485 
486