Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Protected Attributes | List of all members
Nektar::MultiRegions::MultiLevelBisectedGraph Class Reference

#include <SubStructuredGraph.h>

Public Member Functions

 MultiLevelBisectedGraph (const Array< OneD, const int > sepTree)
 
 MultiLevelBisectedGraph (MultiLevelBisectedGraphSharedPtr oldLevel, const int nPartition)
 
 MultiLevelBisectedGraph (const int nBndDofs)
 
 ~MultiLevelBisectedGraph (void)
 
int GetTotDofs () const
 
void SetGlobalNumberingOffset ()
 
void DumpNBndDofs (void) const
 
void CollectLeaves (std::vector< SubGraphSharedPtr > &leaves) const
 
int CutLeaves ()
 
int CutEmptyLeaves ()
 
int GetNdaughterGraphs () const
 
const SubGraphSharedPtr GetBndDofsGraph () const
 

Protected Attributes

SubGraphSharedPtr m_BndDofs
 
MultiLevelBisectedGraphSharedPtr m_leftDaughterGraph
 
MultiLevelBisectedGraphSharedPtr m_rightDaughterGraph
 

Detailed Description

Definition at line 153 of file SubStructuredGraph.h.

Constructor & Destructor Documentation

Nektar::MultiRegions::MultiLevelBisectedGraph::MultiLevelBisectedGraph ( const Array< OneD, const int >  sepTree)

Definition at line 88 of file SubStructuredGraph.cpp.

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), ErrorUtil::efatal, m_BndDofs, m_leftDaughterGraph, m_rightDaughterGraph, and NEKERROR.

89  :
90  m_BndDofs (),
93  {
94  static int offset = -5;
95  offset += 5;
96 
97  int recurLevel = sepTree[offset+0];
98  int nLeftIntDofs = sepTree[offset+2];
99  int nRightIntDofs = sepTree[offset+3];
100  int nBndDofs = sepTree[offset+4];
101 
102  bool daughtersConstructed[2] = {false,false};
103 
104  if ((offset + 5) < sepTree.num_elements())
105  {
106  while (sepTree[offset+5] > recurLevel)
107  {
108  switch (sepTree[offset+6])
109  {
110  case 1:
111  {
112  m_leftDaughterGraph = MemoryManager<
113  MultiLevelBisectedGraph>::AllocateSharedPtr(
114  sepTree);
115  daughtersConstructed[0] = true;
116  break;
117  }
118  case 2:
119  {
120  m_rightDaughterGraph = MemoryManager<
121  MultiLevelBisectedGraph>::AllocateSharedPtr(
122  sepTree);
123  daughtersConstructed[1] = true;
124  break;
125  }
126  default:
127  {
128  NEKERROR(ErrorUtil::efatal,"Invalid branch id");
129  }
130  }
131  if ((offset + 5) >= sepTree.num_elements())
132  {
133  break;
134  }
135  }
136  }
137 
139 
140  if (!daughtersConstructed[0] && nLeftIntDofs)
141  {
142  m_leftDaughterGraph = MemoryManager<
143  MultiLevelBisectedGraph>::AllocateSharedPtr(nLeftIntDofs);
144  }
145 
146  if (!daughtersConstructed[1] && nRightIntDofs)
147  {
148  m_rightDaughterGraph = MemoryManager<
149  MultiLevelBisectedGraph>::AllocateSharedPtr(nRightIntDofs);
150  }
151 
152  if (recurLevel == 1)
153  {
154  offset = -5;
155  }
156  }
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mod...
Definition: ErrorUtil.hpp:185
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
MultiLevelBisectedGraph(const Array< OneD, const int > sepTree)
MultiLevelBisectedGraphSharedPtr m_rightDaughterGraph
MultiLevelBisectedGraphSharedPtr m_leftDaughterGraph
Nektar::MultiRegions::MultiLevelBisectedGraph::MultiLevelBisectedGraph ( MultiLevelBisectedGraphSharedPtr  oldLevel,
const int  nPartition 
)

Definition at line 158 of file SubStructuredGraph.cpp.

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), m_BndDofs, and m_leftDaughterGraph.

161  {
162  m_leftDaughterGraph = oldLevel;
164  }
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
MultiLevelBisectedGraphSharedPtr m_leftDaughterGraph
Nektar::MultiRegions::MultiLevelBisectedGraph::MultiLevelBisectedGraph ( const int  nBndDofs)

Definition at line 166 of file SubStructuredGraph.cpp.

166  :
167  m_BndDofs(MemoryManager<SubGraph>::AllocateSharedPtr(nBndDofs)),
170  {
171  }
MultiLevelBisectedGraphSharedPtr m_rightDaughterGraph
MultiLevelBisectedGraphSharedPtr m_leftDaughterGraph
Nektar::MultiRegions::MultiLevelBisectedGraph::~MultiLevelBisectedGraph ( void  )

Definition at line 173 of file SubStructuredGraph.cpp.

174  {
175  }

Member Function Documentation

void Nektar::MultiRegions::MultiLevelBisectedGraph::CollectLeaves ( std::vector< SubGraphSharedPtr > &  leaves) const

Definition at line 249 of file SubStructuredGraph.cpp.

References m_BndDofs, m_leftDaughterGraph, and m_rightDaughterGraph.

251  {
252  int cnt = 0;
253 
254  if (m_leftDaughterGraph.get())
255  {
256  m_leftDaughterGraph->CollectLeaves(leaves);
257  cnt++;
258  }
259 
260  if (m_rightDaughterGraph.get())
261  {
262  m_rightDaughterGraph->CollectLeaves(leaves);
263  cnt++;
264  }
265 
266  if (cnt == 0)
267  {
269  leaves.push_back(leave);
270  }
271  }
boost::shared_ptr< SubGraph > SubGraphSharedPtr
MultiLevelBisectedGraphSharedPtr m_rightDaughterGraph
MultiLevelBisectedGraphSharedPtr m_leftDaughterGraph
int Nektar::MultiRegions::MultiLevelBisectedGraph::CutEmptyLeaves ( )

Definition at line 290 of file SubStructuredGraph.cpp.

References m_leftDaughterGraph, and m_rightDaughterGraph.

291  {
292  int returnval;
293  static int level = 0;
294  static int nLeaves = 0;
295  level++;
296 
297  if (level == 1 &&
298  !m_leftDaughterGraph.get() && !m_rightDaughterGraph.get())
299  {
300  level = 0;
301  nLeaves = 0;
302  return 0;
303  }
304 
305  if (m_leftDaughterGraph.get())
306  {
307  if (m_leftDaughterGraph->GetNdaughterGraphs() == 0 &&
308  m_leftDaughterGraph->GetBndDofsGraph()->GetNverts() == 0)
309  {
311  nLeaves++;
312  }
313  else
314  {
315  m_leftDaughterGraph->CutEmptyLeaves();
316  }
317  }
318 
319  if(m_rightDaughterGraph.get())
320  {
321  if (m_rightDaughterGraph->GetNdaughterGraphs() == 0 &&
322  m_rightDaughterGraph->GetBndDofsGraph()->GetNverts() == 0)
323  {
325  nLeaves++;
326  }
327  else
328  {
329  m_rightDaughterGraph->CutEmptyLeaves();
330  }
331  }
332 
333  returnval = nLeaves;
334 
335  level--;
336  if(level == 0)
337  {
338  nLeaves = 0;
339  }
340 
341  return returnval;
342  }
boost::shared_ptr< MultiLevelBisectedGraph > MultiLevelBisectedGraphSharedPtr
MultiLevelBisectedGraphSharedPtr m_rightDaughterGraph
MultiLevelBisectedGraphSharedPtr m_leftDaughterGraph
int Nektar::MultiRegions::MultiLevelBisectedGraph::CutLeaves ( )

Definition at line 344 of file SubStructuredGraph.cpp.

References m_leftDaughterGraph, and m_rightDaughterGraph.

345  {
346  int returnval;
347  static int level = 0;
348  static int nLeaves = 0;
349  level++;
350 
351  if( (level == 1) &&
352  (!m_leftDaughterGraph.get()) &&
353  (!m_rightDaughterGraph.get()) )
354  {
355  level = 0;
356  nLeaves = 0;
357  return 0;
358  }
359 
360  if(m_leftDaughterGraph.get())
361  {
362  if(m_leftDaughterGraph->GetNdaughterGraphs() == 0)
363  {
365  nLeaves++;
366  }
367  else
368  {
369  m_leftDaughterGraph->CutLeaves();
370  }
371  }
372  if(m_rightDaughterGraph.get())
373  {
374  if(m_rightDaughterGraph->GetNdaughterGraphs() == 0)
375  {
377  nLeaves++;
378  }
379  else
380  {
381  m_rightDaughterGraph->CutLeaves();
382  }
383  }
384 
385  returnval = nLeaves;
386 
387  level--;
388  if(level == 0)
389  {
390  nLeaves = 0;
391  }
392 
393  return returnval;
394  }
boost::shared_ptr< MultiLevelBisectedGraph > MultiLevelBisectedGraphSharedPtr
MultiLevelBisectedGraphSharedPtr m_rightDaughterGraph
MultiLevelBisectedGraphSharedPtr m_leftDaughterGraph
void Nektar::MultiRegions::MultiLevelBisectedGraph::DumpNBndDofs ( void  ) const

Definition at line 231 of file SubStructuredGraph.cpp.

References m_BndDofs, m_leftDaughterGraph, and m_rightDaughterGraph.

232  {
233  static int level = 0;
234  level++;
235  cout << "LEVEL " << level << " " << m_BndDofs->GetNverts() << endl;
236 
237  if (m_leftDaughterGraph.get())
238  {
239  m_leftDaughterGraph->DumpNBndDofs();
240  }
241  if (m_rightDaughterGraph.get())
242  {
243  m_rightDaughterGraph->DumpNBndDofs();
244  }
245 
246  level--;
247  }
MultiLevelBisectedGraphSharedPtr m_rightDaughterGraph
MultiLevelBisectedGraphSharedPtr m_leftDaughterGraph
const SubGraphSharedPtr Nektar::MultiRegions::MultiLevelBisectedGraph::GetBndDofsGraph ( ) const
inline

Definition at line 174 of file SubStructuredGraph.h.

References m_BndDofs.

175  {
176  return m_BndDofs;
177  }
int Nektar::MultiRegions::MultiLevelBisectedGraph::GetNdaughterGraphs ( ) const
inline

Definition at line 273 of file SubStructuredGraph.cpp.

References m_leftDaughterGraph, and m_rightDaughterGraph.

274  {
275  int cnt = 0;
276 
277  if (m_leftDaughterGraph.get())
278  {
279  cnt++;
280  }
281 
282  if (m_rightDaughterGraph.get())
283  {
284  cnt++;
285  }
286 
287  return cnt;
288  }
MultiLevelBisectedGraphSharedPtr m_rightDaughterGraph
MultiLevelBisectedGraphSharedPtr m_leftDaughterGraph
int Nektar::MultiRegions::MultiLevelBisectedGraph::GetTotDofs ( ) const

Definition at line 177 of file SubStructuredGraph.cpp.

References m_BndDofs, m_leftDaughterGraph, and m_rightDaughterGraph.

178  {
179  static int nBndDofs = 0;
180  static int level = 0;
181  level++;
182 
183  int returnval;
184 
185  if(m_leftDaughterGraph.get())
186  {
187  m_leftDaughterGraph->GetTotDofs();
188  }
189  if(m_rightDaughterGraph.get())
190  {
191  m_rightDaughterGraph->GetTotDofs();
192  }
193 
194  nBndDofs += m_BndDofs->GetNverts();
195  returnval = nBndDofs;
196 
197  level--;
198  if(level == 0)
199  {
200  nBndDofs = 0;
201  }
202 
203  return returnval;
204  }
MultiLevelBisectedGraphSharedPtr m_rightDaughterGraph
MultiLevelBisectedGraphSharedPtr m_leftDaughterGraph
void Nektar::MultiRegions::MultiLevelBisectedGraph::SetGlobalNumberingOffset ( )

Definition at line 206 of file SubStructuredGraph.cpp.

References m_BndDofs, m_leftDaughterGraph, and m_rightDaughterGraph.

207  {
208  static int level = 0;
209  static int offset = 0;
210  level++;
211 
212  if(m_leftDaughterGraph.get())
213  {
214  m_leftDaughterGraph->SetGlobalNumberingOffset();
215  }
216  if(m_rightDaughterGraph.get())
217  {
218  m_rightDaughterGraph->SetGlobalNumberingOffset();
219  }
220 
221  m_BndDofs->SetIdOffset(offset);
222  offset += m_BndDofs->GetNverts();
223 
224  level--;
225  if(level == 0)
226  {
227  offset = 0;
228  }
229  }
MultiLevelBisectedGraphSharedPtr m_rightDaughterGraph
MultiLevelBisectedGraphSharedPtr m_leftDaughterGraph

Member Data Documentation

SubGraphSharedPtr Nektar::MultiRegions::MultiLevelBisectedGraph::m_BndDofs
protected
MultiLevelBisectedGraphSharedPtr Nektar::MultiRegions::MultiLevelBisectedGraph::m_leftDaughterGraph
protected
MultiLevelBisectedGraphSharedPtr Nektar::MultiRegions::MultiLevelBisectedGraph::m_rightDaughterGraph
protected