Chombo + EB + MF  3.2
CoDimCopyManagerI.H
Go to the documentation of this file.
1 #ifdef CH_LANG_CC
2 /*
3  * _______ __
4  * / ___/ / ___ __ _ / / ___
5  * / /__/ _ \/ _ \/ V \/ _ \/ _ \
6  * \___/_//_/\___/_/_/_/_.__/\___/
7  * Please refer to Copyright.txt, in Chombo's root directory.
8  */
9 #endif
10 
11 #ifndef _CODIMCOPYMANAGERI_H_
12 #define _CODIMCOPYMANAGERI_H_
13 
14 #include "CoDimCopier.H"
15 #include "CornerCopier.H"
16 
17 #include "NamespaceHeader.H"
18 
19 /// defining constructor -- calls matching define function
20 template<class T>
21 CoDimCopyManager<T>::CoDimCopyManager(const DisjointBoxLayout& a_grids, const BoxLayout& a_dest, const IntVect& a_ghostVect, bool a_exchange, int a_maxCoDim)
22 {
23  define(a_grids, a_dest, a_ghostVect, a_exchange, a_maxCoDim);
24 }
25 
26 
27 /// destructor
28 template<class T>
30 {
31  /// clean up memory
32  for (int n=0; n<m_copierVect.size(); n++)
33  {
34  if (m_copierVect[n] != NULL)
35  {
36  delete m_copierVect[n];
37  m_copierVect[n] = NULL;
38  }
39  }
40 }
41 
42 
43 /// define
44 template<class T>
45 void
46 CoDimCopyManager<T>::define(const DisjointBoxLayout& a_grids, const BoxLayout& a_dest, const IntVect& a_ghostVect, bool a_exchange, int a_maxCoDim)
47 {
48  m_ghostVect = a_ghostVect;
49  m_srcGrids = a_grids;
50  m_destGrids = a_dest;
51 
52  CH_assert(m_copierVect.size() == 0);
53  m_copierVect.resize(a_maxCoDim-1, NULL);
54  for (int n=0; n<a_maxCoDim-1; n++)
55  {
56  int coDim = n+2;
57  // define a CoDimCopier here
58  CoDimCopier* copyPtr = new CoDimCopier(a_grids, a_dest, a_grids.physDomain(),
59  a_ghostVect, coDim, a_exchange);
60  m_copierVect[n] = static_cast<Copier*>(copyPtr);
61  } // end loop over codims
62 }
63 
64 
65 /// orchestrates CoDim exchanges
66 template<class T>
67 void
69 {
70  for (int n=0; n<m_copierVect.size(); n++)
71  {
72  a_data.exchange(*m_copierVect[n]);
73  }
74 }
75 
76 
77 /// orchestrates CoDim copies
78 template<class T>
79 void
81 {
82  for (int n=0; n<m_copierVect.size(); n++)
83  {
84  a_data.copyTo(a_dest, *m_copierVect[n]);
85  }
86 }
87 
88 
89 #include "NamespaceFooter.H"
90 
91 #endif
92 
93 
const ProblemDomain & physDomain() const
An even strangerer (than CornerCopier) thing to copy from ghost cells to corner ghost cells...
Definition: CoDimCopier.H:35
#define CH_assert(cond)
Definition: CHArray.H:37
void define(const DisjointBoxLayout &a_grids, const BoxLayout &a_dest, const IntVect &a_ghostVect, bool a_exchange=false, int a_maxCoDim=SpaceDim)
define
Definition: CoDimCopyManagerI.H:46
A not-necessarily-disjoint collective of boxes.
Definition: BoxLayout.H:145
A strange but true thing to make copying from one boxlayoutdata to another fast.
Definition: Copier.H:152
void manageCopies(const LevelData< T > &a_data, BoxLayoutData< T > &a_dest) const
orchestrates CoDim copies
Definition: CoDimCopyManagerI.H:80
virtual void exchange(void)
Simplest case – do all components.
Definition: LevelDataI.H:467
new code
Definition: BoxLayoutData.H:170
Data on a BoxLayout.
Definition: BoxLayoutData.H:97
virtual void copyTo(const Interval &srcComps, BoxLayoutData< T > &dest, const Interval &destComps) const
Definition: LevelDataI.H:218
A BoxLayout that has a concept of disjointedness.
Definition: DisjointBoxLayout.H:30
void manageExchanges(LevelData< T > &a_data) const
orchestrates CoDim exchanges
Definition: CoDimCopyManagerI.H:68
CoDimCopyManager()
null constructor
Definition: CoDimCopyManager.H:31
An integer Vector in SpaceDim-dimensional space.
Definition: CHArray.H:42
~CoDimCopyManager()
destructor
Definition: CoDimCopyManagerI.H:29