⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 intvectset.h

📁 自适应网格划分通用程序包
💻 H
字号:
// This software is copyright (C) by the Lawrence Berkeley
// National Laboratory.  Permission is granted to reproduce
// this software for non-commercial purposes provided that
// this notice is left intact.
//
// It is acknowledged that the U.S. Government has rights to
// this software under Contract DE-AC03-765F00098 between
// the U.S.  Department of Energy and the University of
// California.
//
// This software is provided as a professional and academic
// contribution for joint exchange. Thus it is experimental,
// is provided ``as is'', with no warranties of any kind
// whatsoever, no support, no promise of updates, or printed
// documentation. By using this software, you acknowledge
// that the Lawrence Berkeley National Laboratory and
// Regents of the University of California shall have no
// liability with respect to the infringement of other
// copyrights by any part of this software.
//

#ifndef _INTVECTSET_H_
#define _INTVECTSET_H_

//
// $Id: IntVectSet_8H-source.html,v 1.2 2005/05/13 21:35:19 dbs Exp $
//

#include "SPACE.H"

#ifndef WRAPPER
#include <iostream>
#include "Box.H"
#include "IntVect.H"
#include "TreeIntVectSet.H"
#include "DenseIntVectSet.H"
#include "parstream.H"

#endif


class IntVectSet
{
public:
  friend
  class IVSIterator;



  ~IntVectSet();

  IntVectSet();
  void
  define();


  IntVectSet(const IntVectSet& ivs);
  void
  define(const IntVectSet& ivs);
  void
  define_intvectset(const IntVectSet& ivs){ define(ivs);}
  IntVectSet
  copy() const {return *this;}


  explicit
  IntVectSet(const DenseIntVectSet& a_dense);
  void
  define (const DenseIntVectSet& a_dense);
  explicit
  IntVectSet(const TreeIntVectSet& a_tree);
  void
  define (const TreeIntVectSet& a_tree);



  explicit
  IntVectSet(const IntVect& iv);
  void
  define(const IntVect& iv);
  void
  define_intvect(const IntVect& iv){define(iv);}


  explicit
  IntVectSet(const Box& b);

  void
  define(const Box& b);
  void
  define_box(const Box& b){define(b);}


  IntVectSet&
  operator|=(const IntVectSet& ivs);

  void
  or_intvectset(const IntVectSet& ivs) { *this |= ivs;}


  IntVectSet&
  operator|=(const IntVect& iv);
  void
  or_intvect(const IntVect& ivs) { *this |= ivs;}



  IntVectSet&
  operator|=(const Box& b);
  void
  or_box(const Box& b) { *this |= b;}

  friend
  IntVectSet
  operator|(const IntVectSet& ivs1, const IntVectSet& ivs2);

  friend
  IntVectSet
  operator|(const IntVectSet& ivs, const IntVect& iv);

  friend
  IntVectSet
  operator|(const IntVect& iv, const IntVectSet& ivs);

  friend
  IntVectSet
  operator|(const IntVectSet& ivs, const Box& b);

  friend
  IntVectSet
  operator|(const Box& b, const IntVectSet& ivs);



  IntVectSet
  operator-(const IntVectSet& ivs) const;

  IntVectSet
  operator-(const Box& b) const;

  IntVectSet
  operator-(const IntVect& iv) const;




  IntVectSet&
  operator-=(const IntVectSet& ivs);
  void
  minus(const IntVectSet& ivs){*this -= ivs;}



  IntVectSet&
  operator-=(const Box& b);
  void
  minus_box(const Box& b){ *this -=b;}



  IntVectSet&
  operator-=(const IntVect& iv);
  void
  minus_intvect(const IntVect& iv){ *this -=iv;}



  friend
  IntVectSet
  operator&(const IntVectSet& ivs1, const IntVectSet& ivs2);


  friend
  IntVectSet
  operator&(const IntVectSet& ivs, const Box& b);


  friend
  IntVectSet
  operator&(const Box& b, const IntVectSet& ivs);


  IntVectSet&
  operator&=(const IntVectSet& ivs);
  void
  and_intvectset(const IntVectSet& ivs){*this &= ivs;}

  IntVectSet&
  operator&=(const Box& b);
  void
  and_box(const Box& b){*this &= b;}

  IntVectSet&
  operator&=(const ProblemDomain& domain);
  void
  and_domain(const ProblemDomain& d){*this &= d;}




  void
  grow(int igrow);


  friend
  IntVectSet
  grow(const IntVectSet& ivs, int igrow);



  IntVectSet&
  grow(int idir, int igrow);
  void
  grow_dir(int idir, int igrow){grow(idir, igrow);}



  IntVectSet&
  refine(int iref = 2);



  friend
  IntVectSet
  refine(const IntVectSet& ivs, int iref = 2);



  IntVectSet&
  coarsen(int iref = 2);



  friend
  IntVectSet
  coarsen(const IntVectSet& ivs, int iref = 2);


  void
  shift(const IntVect& iv);



  void
  nestingRegion(int radius, const Box& domain, int granularity  = 1);



  void
  nestingRegion(int radius, const ProblemDomain& probdomain, int granularity = 1);
  void
  nestingRegion_prob(int radius, const ProblemDomain& probdomain)
  {
    nestingRegion(radius, probdomain);
  }


  void
  makeEmpty();



  IntVectSet
  chop(int dir, int chop_pnt);





  int
  numPts() const;


  const Box&
  minBox() const;


  void
  recalcMinBox() const;


  bool
  isEmpty() const;


  bool
  isDense() const;


  bool
  contains(const IntVect& iv) const;


  bool
  contains(const IntVectSet& ivs) const;
  bool
  contains_intvectset(const IntVectSet& ivs) const {return contains(ivs);}



  bool
  contains(const Box& box) const;
  bool
  contains_box(const Box& b) const {return contains(b);}



  Vector<Box>
  boxes() const;



  void
  compact() const;


  int
  linearSize() const;

  void
  linearIn(const void* const a_inBuf);


  void
  linearOut(void* const a_outBuf) const;


  bool
  operator==(const IntVectSet& a_ivs) const;


  void
  printBoxes(std::ostream& a_ostream) const;

  void
  p() const { printBoxes(pout());}

  friend
  std::ostream&
  operator<<(std::ostream& os, const IntVectSet& ivs);


  void convert() const; // turn dense rep into Tree rep.  very costly.
                        // it is 'logically' const, but does modify data structures;

  // not for public consumption.  used in memory tracking.
  static long int count;
  static long int peakcount;
private:

  bool m_isdense;
  TreeIntVectSet m_ivs;
  DenseIntVectSet m_dense;

  // not a user function.  called by memory tracking system on
  // exit to clean up static allocation pools used for the optimization
  // of these routines.
  friend void dumpmemoryatexit();
  static void clearStaticMemory(); // after this functon is called, you cannot
                              // do any other operations with IntVectSet.
};






class IVSIterator
{
public:

  IVSIterator():m_isdense(true) {;}

  IVSIterator(const IntVectSet& ivs);

  ~IVSIterator(){;}

  void define(const IntVectSet& ivs);

  const IntVect& operator()() const ;

  const IntVect& iv() const { return this->operator()();}

  bool ok() const;

  void operator++();

  void incr() { ++(*this);}

  void begin();

  void reset();


  void end();

private:
  bool m_isdense;
  DenseIntVectSetIterator m_dense;
  TreeIntVectSetIterator  m_tree;
};



#ifndef WRAPPER



inline const IntVect& IVSIterator::operator()() const
{
  if(m_isdense) return m_dense();
  return m_tree();
}

inline bool IVSIterator::ok() const
{
  if(m_isdense) return m_dense.ok();
  return m_tree.ok();
}

inline void  IVSIterator::operator++()
{
  if(m_isdense) ++m_dense;
  else          ++m_tree;
}
inline void IVSIterator::reset()
{
  begin();
}

inline void IVSIterator::begin()
{
  if(m_isdense) m_dense.begin();
  else          m_tree.begin();
}

inline void IVSIterator::end()
{
  if(m_isdense) m_dense.end();
  else          m_tree.end();
}


inline IntVectSet::IntVectSet(): m_isdense(true)
{
  count++;
  if(count > peakcount) peakcount = count;
}

inline void IntVectSet::define(const IntVectSet& ige_in)
{
  *this = ige_in;
}

inline IntVectSet::IntVectSet(const IntVectSet& ige_in)
{
  count++;
  if(count > peakcount) peakcount = count;

  *this = ige_in;
}

inline   bool
IntVectSet::isDense() const
{
  return m_isdense;
}

#endif /* WRAPPER */

#endif /*_INTVECTSET_H_*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -