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

📄 basefab.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.
//

//CH_COPYRIGHT_NOTICE

#ifndef CH_BASEFAB_H
#define CH_BASEFAB_H

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

#include <cstdlib>
#include <assert.h>
#include <string>
#include <typeinfo>
#include "Box.H"
#include "Arena.H"
#include "Interval.H"
#include "REAL.H"



template <class T>
class BaseFab
{
public:


  BaseFab ();


  BaseFab (const Box& bx,
           int        n,
                   T*         alias=NULL);

  BaseFab(const Interval& a_comps,
                  BaseFab<T>& a_original);


  virtual ~BaseFab ();

  void resize (const Box& b,
               int        N = 1,
                           T*         alias=NULL);

  virtual void define(const Box& box, int comps, 
                                          T* alias = NULL) { resize(box, comps, alias);}

  virtual void define(const Interval& a_comps, BaseFab<T>& a_original);

  void clear ();




  int nComp () const;


  const Box& box () const;

  const int* size () const;

  const IntVect& smallEnd () const;
 
  const IntVect& bigEnd () const;


  Interval interval() const
  { return Interval(0, nvar-1); }

  T& operator() (const IntVect& p,
                 int            N);

  T& operator() (const IntVect& p);

  const T& operator() (const IntVect& p,
                       int            N) const;

  const T& operator() (const IntVect& p) const;

  void getVal (T*             data,
               const IntVect& pos,
               int            N,
               int            numcomp) const;

  void getVal (T*             data,
               const IntVect& pos) const;


  const int* loVect () const;
 
  const int* hiVect () const;
 
  const int* nCompPtr () const;
 
  T* dataPtr (int N = 0);

  const T* dataPtr (int N = 0) const;


  bool contains (const BaseFab<T>& fab) const;
 
  bool contains (const Box& bx) const;


  void setVal (T          x,
               const Box& bx,
               int        nstart,
               int        ncomp);


  void setVal (T          x,
               const Box& bx,
               int        N);


  void setVal (T   x,
               int N);


  void setVal (T x);


  BaseFab<T>& copy (const BaseFab<T>& src,
                    const Box&        srcbox,
                    int               srccomp,
                    const Box&        destbox,
                    int               destcomp,
                    int               numcomp);

  BaseFab<T>& copy (const BaseFab<T>& src,
                    int               srccomp,
                    int               destcomp,
                    int               numcomp = 1);

  BaseFab<T>& copy (const BaseFab<T>& src,
                    const Box&        destbox);

  BaseFab<T>& copy (const BaseFab<T>& src);


  void copy(const Box& RegionFrom, 
            const Interval& Cdest, 
            const Box& RegionTo,
            const BaseFab<T>& src, 
            const Interval& Csrc);




  BaseFab<T>& shift (const IntVect& v);


  BaseFab<T>& shift (int idir,
                     int n_cell);


  BaseFab<T>& shiftHalf (int dir,
                         int num_halfs);


  BaseFab<T>& shiftHalf (const IntVect& num_halfs);



  virtual int size(const Box& b, const Interval& comps) const;


  virtual void linearOut(void* buf, const Box& R, const Interval& comps) const;

  virtual void linearIn(void* buf, const Box& R, const Interval& comps);

  static int preAllocatable(){ return 0;} // static preAllocatable

protected:
  //
  // Allocates memory for the `BaseFab<T>'.
  //
  void define ();
  //
  // Deallocates memory for the `BaseFab<T>'.
  //
  void undefine ();
  //
  // template class static data member.  not sure if this will
  // work with all compilers.  It has been in the draft standard
  // for some time
  //
  static Arena* s_Arena;
  //
  //
  static std::string name();
  //
  // The function called by BaseFab copy operations.
  //
  virtual void performCopy (const BaseFab<T>& src,
                            const Box&        srcbox,
                            int               srccomp,
                            const Box&        destbox,
                            int               destcomp,
                            int               numcomp);

  //
  // This function is called by the `BaseFab' setVal operations.
  //
  void performSetVal (T          x,
                      const Box& bx,
                      int        nstart,
                      int        numcomp);


private:
  //
  // These functions are made private to prevent use of the default 
  // functions provided by the C++ compiler.
  //

  BaseFab<T>& operator= (const BaseFab<T>&);
  BaseFab (const BaseFab<T>&);

protected:

  Box  domain;   // My index space.
  int  nvar;     // Number components.
  long numpts;   // Cached number of points in FAB.
  long truesize; // nvar*numpts that was allocated on heap (only if alias==false).
  T*   dptr;     // The data pointer.
  bool aliased;  // The BaseFab is not allocated memory, but is an alias. bvs
};

#include "BaseFabImplem.H"

#endif /*CH_BASEFAB_H*/


⌨️ 快捷键说明

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