msm::Grid< T > Class Template Reference

#include <MsmMap.h>

Inheritance diagram for msm::Grid< T >:

msm::IndexRange List of all members.

Public Member Functions

 Grid ()
void init (const IndexRange &n)
void set (int pia, int pni, int pja, int pnj, int pka, int pnk)
void setbounds (int pia, int pib, int pja, int pjb, int pka, int pkb)
void resize (int n)
const T & operator() (int i, int j, int k) const
const T & operator() (const Ivec &n) const
const T & elem (int i, int j, int k) const
T & operator() (int i, int j, int k)
T & operator() (const Ivec &n)
T & elem (int i, int j, int k)
int flatindex (int i, int j, int k) const
const Array< T > & data () const
Array< T > & data ()
void reset (const T &t)
void updateLower (const Ivec &n)
Grid< T > & operator+= (const Grid< T > &g)
void extract (Grid< T > &g)
template<int N>
Grid< T > & operator+= (const GridFixed< T, N > &g)
template<int N>
void extract (GridFixed< T, N > &g)

Detailed Description

template<class T>
class msm::Grid< T >

Definition at line 600 of file MsmMap.h.


Constructor & Destructor Documentation

template<class T>
msm::Grid< T >::Grid (  )  [inline]

Definition at line 602 of file MsmMap.h.

00602 { }


Member Function Documentation

template<class T>
Array<T>& msm::Grid< T >::data (  )  [inline]

Definition at line 667 of file MsmMap.h.

00667 { return gdata; }

template<class T>
const Array<T>& msm::Grid< T >::data (  )  const [inline]

Definition at line 666 of file MsmMap.h.

Referenced by msm::PatchData::anterpolationC1Hermite(), MsmC1HermiteGridCutoff::compute_specialized(), GridMsg::get(), MsmC1HermiteBlock::gridCutoff(), MsmBlock::gridCutoff(), msm::PatchData::interpolationC1Hermite(), GridMsg::put(), msm::PatchData::sendChargeC1Hermite(), MsmC1HermiteBlock::sumReducedPotential(), and MsmBlock::sumReducedPotential().

00666 { return gdata; }

template<class T>
T& msm::Grid< T >::elem ( int  i,
int  j,
int  k 
) [inline]

Definition at line 651 of file MsmMap.h.

00651                                    {
00652         if (i<ia() || i>ib() || j<ja() || j>jb() || k<ka() || k>kb()) {
00653           char msg[200];
00654           snprintf(msg, sizeof(msg), "Grid indexing:\n"
00655               "ia=%d, ib=%d, i=%d\n"
00656               "ja=%d, jb=%d, j=%d\n"
00657               "ka=%d, kb=%d, k=%d\n",
00658               ia(), ib(), i, ja(), jb(), j, ka(), kb(), k);
00659           NAMD_die(msg);
00660         }
00661         return gdata[flatindex(i,j,k)];
00662       }

template<class T>
const T& msm::Grid< T >::elem ( int  i,
int  j,
int  k 
) const [inline]

Definition at line 629 of file MsmMap.h.

Referenced by msm::Grid< Vtype >::operator()().

00629                                                {
00630         if (i<ia() || i>ib() || j<ja() || j>jb() || k<ka() || k>kb()) {
00631           char msg[200];
00632           snprintf(msg, sizeof(msg), "Grid indexing:\n"
00633               "ia=%d, ib=%d, i=%d\n"
00634               "ja=%d, jb=%d, j=%d\n"
00635               "ka=%d, kb=%d, k=%d\n",
00636               ia(), ib(), i, ja(), jb(), j, ka(), kb(), k);
00637           NAMD_die(msg);
00638         }
00639         return gdata[flatindex(i,j,k)];
00640       }

template<class T>
template<int N>
void msm::Grid< T >::extract ( GridFixed< T, N > &  g  )  [inline]

Definition at line 801 of file MsmMap.h.

00801                                       {
00802         ASSERT(IndexRange(g) <= IndexRange(*this));
00803         int gni = g.nextent.i;
00804         int gnj = g.nextent.j;
00805         int gnk = g.nextent.k;
00806         int index = 0;
00807         int ni = nextent.i;
00808         int nij = nextent.i * nextent.j;
00809         int koff = (g.nlower.k - nlower.k) * nij
00810           + (g.nlower.j - nlower.j) * ni + (g.nlower.i - nlower.i);
00811         T *gbuf = g.buffer();
00812         const T *buf = gdata.buffer();
00813         for (int k = 0;  k < gnk;  k++) {
00814           int jkoff = k * nij + koff;
00815           for (int j = 0;  j < gnj;  j++) {
00816             int ijkoff = j * ni + jkoff;
00817             for (int i = 0;  i < gni;  i++, index++) {
00818               gbuf[index] = buf[i + ijkoff];
00819             }
00820           }
00821         }
00822       }

template<class T>
void msm::Grid< T >::extract ( Grid< T > &  g  )  [inline]

Definition at line 748 of file MsmMap.h.

Referenced by msm::PatchData::sendChargeC1Hermite(), MsmC1HermiteBlock::sendDownPotential(), MsmBlock::sendDownPotential(), MsmC1HermiteBlock::sendPatch(), MsmBlock::sendPatch(), MsmC1HermiteBlock::sendUpCharge(), and MsmBlock::sendUpCharge().

00748                                {
00749         ASSERT(IndexRange(g) <= IndexRange(*this));
00750         int gni = g.nextent.i;
00751         int gnj = g.nextent.j;
00752         int gnk = g.nextent.k;
00753         int index = 0;
00754         int ni = nextent.i;
00755         int nij = nextent.i * nextent.j;
00756         int koff = (g.nlower.k - nlower.k) * nij
00757           + (g.nlower.j - nlower.j) * ni + (g.nlower.i - nlower.i);
00758         T *gbuf = g.gdata.buffer();
00759         const T *buf = gdata.buffer();
00760         for (int k = 0;  k < gnk;  k++) {
00761           int jkoff = k * nij + koff;
00762           for (int j = 0;  j < gnj;  j++) {
00763             int ijkoff = j * ni + jkoff;
00764             for (int i = 0;  i < gni;  i++, index++) {
00765               gbuf[index] = buf[i + ijkoff];
00766             }
00767           }
00768         }
00769       }

template<class T>
int msm::Grid< T >::flatindex ( int  i,
int  j,
int  k 
) const [inline]

Definition at line 663 of file MsmMap.h.

Referenced by msm::Grid< Vtype >::elem(), and msm::Grid< Vtype >::operator()().

00663                                                {
00664         return ((k-ka())*nj() + (j-ja()))*ni() + (i-ia());
00665       }

template<class T>
void msm::Grid< T >::init ( const IndexRange n  )  [inline]

Definition at line 603 of file MsmMap.h.

Referenced by MsmC1HermiteGridCutoff::compute_specialized(), MsmBlockKernel< Vtype, Mtype >::MsmBlockKernel(), msm::PatchData::PatchData(), msm::PatchData::sendChargeC1Hermite(), MsmC1HermiteBlock::sendDownPotential(), MsmBlock::sendDownPotential(), MsmC1HermiteBlock::sendPatch(), MsmBlock::sendPatch(), MsmC1HermiteBlock::sendUpCharge(), MsmBlock::sendUpCharge(), MsmC1HermiteBlock::sumReducedPotential(), and MsmBlock::sumReducedPotential().

00603                                      {
00604         nlower = n.lower();
00605         nextent = n.extent();
00606         gdata.resize(nn());
00607       }

template<class T>
T& msm::Grid< T >::operator() ( const Ivec n  )  [inline]

Definition at line 648 of file MsmMap.h.

00648                                    {
00649         return this->operator()(n.i, n.j, n.k);
00650       }

template<class T>
T& msm::Grid< T >::operator() ( int  i,
int  j,
int  k 
) [inline]

Definition at line 641 of file MsmMap.h.

00641                                          {
00642 #ifdef DEBUG_MSM
00643         return elem(i,j,k);
00644 #else
00645         return gdata[flatindex(i,j,k)];
00646 #endif
00647       }

template<class T>
const T& msm::Grid< T >::operator() ( const Ivec n  )  const [inline]

Definition at line 626 of file MsmMap.h.

00626                                                {
00627         return this->operator()(n.i, n.j, n.k);
00628       }

template<class T>
const T& msm::Grid< T >::operator() ( int  i,
int  j,
int  k 
) const [inline]

Definition at line 619 of file MsmMap.h.

Referenced by msm::Grid< Vtype >::operator()().

00619                                                      {
00620 #ifdef DEBUG_MSM
00621         return elem(i,j,k);
00622 #else
00623         return gdata[flatindex(i,j,k)];
00624 #endif
00625       }

template<class T>
template<int N>
Grid<T>& msm::Grid< T >::operator+= ( const GridFixed< T, N > &  g  )  [inline]

Definition at line 774 of file MsmMap.h.

00774                                                    {
00775         ASSERT(IndexRange(g) <= IndexRange(*this));
00776         int gni = g.nextent.i;
00777         int gnj = g.nextent.j;
00778         int gnk = g.nextent.k;
00779         int index = 0;
00780         int ni = nextent.i;
00781         int nij = nextent.i * nextent.j;
00782         int koff = (g.nlower.k - nlower.k) * nij
00783           + (g.nlower.j - nlower.j) * ni + (g.nlower.i - nlower.i);
00784         const T *gbuf = g.buffer();
00785         T *buf = gdata.buffer();
00786         for (int k = 0;  k < gnk;  k++) {
00787           int jkoff = k * nij + koff;
00788           for (int j = 0;  j < gnj;  j++) {
00789             int ijkoff = j * ni + jkoff;
00790             for (int i = 0;  i < gni;  i++, index++) {
00791               buf[i + ijkoff] += gbuf[index];
00792             }
00793           }
00794         }
00795         return(*this);
00796       }

template<class T>
Grid<T>& msm::Grid< T >::operator+= ( const Grid< T > &  g  )  [inline]

Definition at line 681 of file MsmMap.h.

00681                                             {
00682 #if 1
00683         ASSERT(IndexRange(g) <= IndexRange(*this));
00684 #else
00685         if ( ! (IndexRange(g) <= IndexRange(*this)) ) {
00686           Grid<T> tmp = *this;
00687           // expand myself to hold sum
00688           int ia = nlower.i;
00689           if (ia > g.nlower.i) ia = g.nlower.i;
00690           int ja = nlower.j;
00691           if (ja > g.nlower.j) ja = g.nlower.j;
00692           int ka = nlower.k;
00693           if (ka > g.nlower.k) ka = g.nlower.k;
00694           int ib1 = nlower.i + nextent.i;
00695           int gib1 = g.nlower.i + g.nextent.i;
00696           if (ib1 < gib1) ib1 = gib1;
00697           int jb1 = nlower.j + nextent.j;
00698           int gjb1 = g.nlower.j + g.nextent.j;
00699           if (jb1 < gjb1) jb1 = gjb1;
00700           int kb1 = nlower.k + nextent.k;
00701           int gkb1 = g.nlower.k + g.nextent.k;
00702           if (kb1 < gkb1) kb1 = gkb1;
00703           setbounds(ia, ib1-1, ja, jb1-1, ka, kb1-1);
00704           reset(0);  // make sure constructor for T accepts "0" as its zero
00705           // now copy "tmp" grid elements into my expanded self
00706           int index = 0;
00707           int ni = nextent.i;
00708           int nij = nextent.i * nextent.j;
00709           int koff = (tmp.nlower.k - nlower.k) * nij
00710             + (tmp.nlower.j - nlower.j) * ni + (tmp.nlower.i - nlower.i);
00711           const T *gbuf = tmp.gdata.buffer();
00712           T *buf = gdata.buffer();
00713           for (int k = 0;  k < tmp.nextent.k;  k++) {
00714             int jkoff = k * nij + koff;
00715             for (int j = 0;  j < tmp.nextent.j;  j++) {
00716               int ijkoff = j * ni + jkoff;
00717               for (int i = 0;  i < tmp.nextent.i;  i++, index++) {
00718                 buf[i + ijkoff] = gbuf[index];
00719               }
00720             }
00721           }
00722         }
00723 #endif
00724         int gni = g.nextent.i;
00725         int gnj = g.nextent.j;
00726         int gnk = g.nextent.k;
00727         int index = 0;
00728         int ni = nextent.i;
00729         int nij = nextent.i * nextent.j;
00730         int koff = (g.nlower.k - nlower.k) * nij
00731           + (g.nlower.j - nlower.j) * ni + (g.nlower.i - nlower.i);
00732         const T *gbuf = g.gdata.buffer();
00733         T *buf = gdata.buffer();
00734         for (int k = 0;  k < gnk;  k++) {
00735           int jkoff = k * nij + koff;
00736           for (int j = 0;  j < gnj;  j++) {
00737             int ijkoff = j * ni + jkoff;
00738             for (int i = 0;  i < gni;  i++, index++) {
00739               buf[i + ijkoff] += gbuf[index];
00740             }
00741           }
00742         }
00743         return(*this);
00744       }

template<class T>
void msm::Grid< T >::reset ( const T &  t  )  [inline]

Definition at line 670 of file MsmMap.h.

Referenced by MsmC1HermiteGridCutoff::compute_specialized(), msm::PatchData::init(), MsmBlockKernel< Vtype, Mtype >::init(), msm::Grid< Vtype >::operator+=(), MsmBlockKernel< Vtype, Mtype >::prolongationKernel(), and MsmBlockKernel< Vtype, Mtype >::restrictionKernel().

00670                              {
00671         T *buf = gdata.buffer();
00672         int len = nn();
00673         for (int n = 0;  n < len;  n++) { buf[n] = t; }
00674       }

template<class T>
void msm::Grid< T >::resize ( int  n  )  [inline]

Definition at line 616 of file MsmMap.h.

Referenced by msm::PatchData::PatchData().

00616                          { // reserve space but don't set grid indexing
00617         gdata.resize(n);
00618       }

template<class T>
void msm::Grid< T >::set ( int  pia,
int  pni,
int  pja,
int  pnj,
int  pka,
int  pnk 
) [inline]

Reimplemented from msm::IndexRange.

Definition at line 608 of file MsmMap.h.

Referenced by MsmC1HermiteGridCutoff::compute_specialized(), and GridMsg::get().

00608                                                                      {
00609         IndexRange::set(pia, pni, pja, pnj, pka, pnk);
00610         gdata.resize(nn());
00611       }

template<class T>
void msm::Grid< T >::setbounds ( int  pia,
int  pib,
int  pja,
int  pjb,
int  pka,
int  pkb 
) [inline]

Reimplemented from msm::IndexRange.

Definition at line 612 of file MsmMap.h.

Referenced by msm::Grid< Vtype >::operator+=().

00612                                                                            {
00613         IndexRange::setbounds(pia, pib, pja, pjb, pka, pkb);
00614         gdata.resize(nn());
00615       }

template<class T>
void msm::Grid< T >::updateLower ( const Ivec n  )  [inline]

Definition at line 677 of file MsmMap.h.

Referenced by MsmC1HermiteGridCutoff::compute_specialized(), msm::PatchData::sendChargeC1Hermite(), MsmC1HermiteBlock::sendDownPotential(), MsmBlock::sendDownPotential(), MsmC1HermiteBlock::sendPatch(), MsmBlock::sendPatch(), MsmC1HermiteBlock::sendUpCharge(), and MsmBlock::sendUpCharge().

00677 { nlower = n; }


The documentation for this class was generated from the following file:
Generated on Wed Sep 20 01:17:20 2017 for NAMD by  doxygen 1.4.7