DelIndexLst Class Reference

#include <delindexlst.h>

Collaboration diagram for DelIndexLst:
Collaboration graph
[legend]

List of all members.

Classes

class  Info

Public Types

typedef unsigned Index
typedef std::vector< Info >
::const_iterator 
Iterator

Public Member Functions

 DelIndexLst ()
void addIndex (Index i, bool isInnerDelCell=false)
void addUniqueIndex (Index i)
bool exist (Index i)
unsigned getNumInnerGhostCells ()
void close ()
unsigned size ()
Index adjust (Index i, Iterator &it) const
Index convert (Index i, Iterator &it) const
Index convertGhost (const Index &i, Iterator &it, const Index &Off) const
Index index_to_raw_index (Index i) const
Index adjustI (Index i, Iterator it) const
Iterator begin () const
Iterator end () const
Iterator findLUEntry (const Index i) const
 ~DelIndexLst ()

Private Attributes

std::vector< Infom_vec
bool m_bClosed
unsigned m_nNonGhosts

Detailed Description

Implement a list of deleted indices. This is an auxiliary class used in the OrthoMesh classes to implement the concept of holes in the domain. Actually the holes destroy the structure of the orthonormal meshes. The advantage of this structure is that they have almost no memory requirements. To mantain this structure we implement the holes as a list of invalid faces, cells and vertices indexes. When we iterate throw the cells or faces of the mesh, the OrthoMesh compares for each iteration if the face or cell is in the invalid index list. If it is true then the Orthomesh class automatically increments to the next cell until we find a valid cell. For the user program it seems that the cells of invalid indices dont exist since the user never gets an iterator pointing to the invalid cells or faces or vertices. Another problem is that the indices must be reordered to not count the deleted cells or faces. The necessity of continuity of indices is seen mainly in the implicit methods where we build a system matrix. If the indices of the valid mesh's geometries elements (cells, faces, vertices) had some gaps because of the invalid cells, the matrix would have some zero columns and lines. A possible solution is to have a kind of degree of freedom distrubition method along the vertices, faces and cells but that would demand some kind of mapping beetween the mesh dofs and the new dofs, mainly for localization purposes, when we have to map a degree of freedom into a position in the domain.

Definition at line 32 of file delindexlst.h.


Member Typedef Documentation

typedef unsigned DelIndexLst::Index

Definition at line 35 of file delindexlst.h.

typedef std::vector<Info>::const_iterator DelIndexLst::Iterator

Definition at line 68 of file delindexlst.h.


Constructor & Destructor Documentation

DelIndexLst::DelIndexLst (  ) 

Definition at line 10 of file delindexlst.cpp.

00011 {
00012   m_bClosed = false;
00013   //insert the first and last sentinel nodes
00014   m_vec.push_back(Info(0,0));
00015   m_vec.push_back(Info(UINT_MAX,0));
00016 }

DelIndexLst::~DelIndexLst (  ) 

Definition at line 18 of file delindexlst.cpp.

00019 {
00020 
00021 }


Member Function Documentation

void DelIndexLst::addIndex ( Index  i,
bool  isInnerDelCell = false 
)

Definition at line 23 of file delindexlst.cpp.

00024 {
00025   if (m_bClosed)
00026     throw new Exception("DelIndexLst:: List already closed\nCant insert another index.");
00027   struct Info info(i,isInnerCell);
00028   m_vec.push_back(info);
00029 }

void DelIndexLst::addUniqueIndex ( Index  i  ) 

Add the index i, only if it are not in the list.

Parameters:
i 
Returns:

Definition at line 210 of file delindexlst.cpp.

00211 {
00212   if (this->exist(i))
00213     return;
00214   else
00215     addIndex(i);
00216 }

DelIndexLst::Index DelIndexLst::adjust ( Index  i,
Iterator it 
) const

Definition at line 56 of file delindexlst.cpp.

00057 {
00058   if (it->index() > i)
00059   {
00060     do
00061     {
00062       it--;
00063     } while (it->index() > i);
00064     /*Assert the index is valid and is
00065       not included in the deletion list. */
00066     assert(it->index() != i || it == m_vec.begin()); 
00067     return i-(++it)->off();
00068   }
00069   else
00070   {
00071     while (it->index() <= i)
00072     {
00073       it++;
00074     }
00075     assert((it-1)->index() != i || (it-1) == m_vec.begin()); 
00076     return i-it->off();
00077       
00078   }
00079   
00080 }

DelIndexLst::Index DelIndexLst::adjustI ( Index  i,
Iterator  it 
) const

Definition at line 152 of file delindexlst.cpp.

00153 {
00154   if (it->index() > i)
00155   {
00156     do
00157     {
00158       it--;
00159     } while (it->index() > i);
00160     /*Assert the index is valid and is
00161       not included in the deletion list. */
00162     if (it->index() == i && it != m_vec.begin())
00163       return OrthoMesh::invalidIndex();
00164     else
00165       return i-(++it)->off();
00166   }
00167   else
00168   {
00169     while (it->index() < i)
00170     {
00171       it++;
00172     }
00173     if (it->index() == i && it != m_vec.begin())
00174       return OrthoMesh::invalidIndex();
00175     else
00176       return i-it->off();
00177   }
00178 }

Iterator DelIndexLst::begin (  )  const [inline]

Definition at line 85 of file delindexlst.h.

00085 {return ++(m_vec.begin());}

void DelIndexLst::close (  ) 

Definition at line 34 of file delindexlst.cpp.

00035 {
00036   //Sort the info entries.
00037   std::sort(m_vec.begin(),m_vec.end());
00038   //Numerate the offsets of the indices in the list.
00039   std::vector<Info>::iterator it = m_vec.begin();
00040   it++;
00041   unsigned off=0;
00042   m_nNonGhosts=0;
00043   for(;it!=m_vec.end();it++)
00044   {
00045     if (it->m_off)
00046       m_nNonGhosts++;
00047     it->m_off = off++;
00048     it->m_ghostOff=it->m_off-m_nNonGhosts;
00049   }
00050   assert(m_vec.back().m_off == --off);
00051   m_bClosed=true;
00052   
00053 }

Index DelIndexLst::convert ( Index  i,
Iterator it 
) const

Definition at line 82 of file delindexlst.cpp.

00083 {
00084   if (it->index() > i)
00085   {
00086     do
00087     {
00088       it--;
00089     } while (it->index() > i);
00090     /*Assert the index is valid and is
00091       not included in the deletion list. */
00092     if (it->index() == i && it != m_vec.begin())
00093     {
00094       it++;
00095       return OrthoMesh::invalidIndex();
00096     }
00097     else
00098       return i-(++it)->off();
00099   }
00100   else
00101   {
00102     while (it->index() < i)
00103     {
00104       it++;
00105     }
00106     if (it->index() == i && it != m_vec.begin())
00107     {
00108       it++;
00109       return OrthoMesh::invalidIndex();
00110     }
00111     else
00112       return i-it->off();
00113   }
00114 }

Index DelIndexLst::convertGhost ( const Index i,
Iterator it,
const Index Off 
) const

Definition at line 119 of file delindexlst.cpp.

00120 {
00121   if (it->index() > i)
00122   {
00123     do
00124     {
00125       it--;
00126     } while (it->index() > i);
00127     /*Assert the index is valid and is
00128       not included in the deletion list. */
00129     if (it->index() == i && it != m_vec.begin())
00130     {
00131       return Off+(it++)->off();
00132     }
00133     else
00134       return i-(++it)->ghostOff();
00135   }
00136   else
00137   {
00138     while (it->index() < i)
00139     {
00140       it++;
00141     }
00142     if (it->index() == i && it != m_vec.begin())
00143     {
00144       return Off + (it++)->ghostOff();
00145     }
00146     else
00147       return i-it->off();
00148   }
00149 }

Iterator DelIndexLst::end (  )  const [inline]

Definition at line 86 of file delindexlst.h.

00086 {return m_vec.end();}

bool DelIndexLst::exist ( Index  i  ) 

Definition at line 218 of file delindexlst.cpp.

00219 {
00220   assert(i!=OrthoMesh::invalidIndex());
00221   for (Iterator it=begin();it != end();it++)
00222   {
00223     if (it->index() == i)
00224       return true;
00225   }
00226   return false;
00227 }

DelIndexLst::Iterator DelIndexLst::findLUEntry ( const Index  i  )  const

Find the least entry in the list with index greater or equal to i or, in other words, the Least Upper (LU) entry.

Parameters:
i 
Returns:

Definition at line 187 of file delindexlst.cpp.

00188 {
00189   assert(m_bClosed);
00190   Iterator it = begin();
00191   while (it->index() < i)
00192     it++;
00193   return it;
00194       
00195   
00196 }

unsigned DelIndexLst::getNumInnerGhostCells (  ) 

Definition at line 254 of file delindexlst.cpp.

00255 {
00256   assert(m_bClosed);
00257   return m_nNonGhosts;
00258 }

Index DelIndexLst::index_to_raw_index ( Index  i  )  const

Definition at line 234 of file delindexlst.cpp.

00235 {
00236   assert(m_bClosed);
00237   Iterator it = findLUEntry(i);
00238   i+=it->off();
00239   while (i >= it->index())
00240   {
00241     i++;
00242     it++;
00243   }
00244   return i;  
00245   
00246 }

unsigned DelIndexLst::size (  )  [inline]

Definition at line 78 of file delindexlst.h.

00078 {return m_vec.size()-2;}


Member Data Documentation

bool DelIndexLst::m_bClosed [private]

Definition at line 61 of file delindexlst.h.

unsigned DelIndexLst::m_nNonGhosts [private]

Definition at line 62 of file delindexlst.h.

std::vector<Info> DelIndexLst::m_vec [private]

Definition at line 58 of file delindexlst.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Generated on Sun Apr 8 23:13:01 2012 for CO2INJECTION by  doxygen 1.6.3