msm::GridFixed< T, N > Class Template Reference

#include <MsmMap.h>

Inheritance diagram for msm::GridFixed< T, N >:

msm::IndexRange List of all members.

Public Member Functions

 GridFixed ()
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)
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 T * buffer () const
T * buffer ()
void reset (const T &t)
void updateLower (const Ivec &n)
GridFixed< T, N > & operator+= (const GridFixed< T, N > &g)
void extract (GridFixed< T, N > &g)

Friends

class Grid< T >

Detailed Description

template<class T, int N>
class msm::GridFixed< T, N >

Definition at line 467 of file MsmMap.h.


Constructor & Destructor Documentation

template<class T, int N>
msm::GridFixed< T, N >::GridFixed (  )  [inline]

Definition at line 470 of file MsmMap.h.

00470 { }


Member Function Documentation

template<class T, int N>
T* msm::GridFixed< T, N >::buffer (  )  [inline]

Definition at line 532 of file MsmMap.h.

00532 { return gdata; }

template<class T, int N>
const T* msm::GridFixed< T, N >::buffer (  )  const [inline]

Definition at line 531 of file MsmMap.h.

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

00531 { return gdata; }

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

Definition at line 516 of file MsmMap.h.

References msm::GridFixed< T, N >::flatindex(), msm::IndexRange::ia(), msm::IndexRange::ib(), msm::IndexRange::ja(), msm::IndexRange::jb(), msm::IndexRange::ka(), msm::IndexRange::kb(), and NAMD_die().

00516                                    {
00517         if (i<ia() || i>ib() || j<ja() || j>jb() || k<ka() || k>kb()) {
00518           char msg[200];
00519           snprintf(msg, sizeof(msg), "Grid indexing:\n"
00520               "ia=%d, ib=%d, i=%d\n"
00521               "ja=%d, jb=%d, j=%d\n"
00522               "ka=%d, kb=%d, k=%d\n",
00523               ia(), ib(), i, ja(), jb(), j, ka(), kb(), k);
00524           NAMD_die(msg);
00525         }
00526         return gdata[flatindex(i,j,k)];
00527       }

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

Definition at line 494 of file MsmMap.h.

References msm::GridFixed< T, N >::flatindex(), msm::IndexRange::ia(), msm::IndexRange::ib(), msm::IndexRange::ja(), msm::IndexRange::jb(), msm::IndexRange::ka(), msm::IndexRange::kb(), and NAMD_die().

Referenced by msm::GridFixed< T, N >::operator()().

00494                                                {
00495         if (i<ia() || i>ib() || j<ja() || j>jb() || k<ka() || k>kb()) {
00496           char msg[200];
00497           snprintf(msg, sizeof(msg), "Grid indexing:\n"
00498               "ia=%d, ib=%d, i=%d\n"
00499               "ja=%d, jb=%d, j=%d\n"
00500               "ka=%d, kb=%d, k=%d\n",
00501               ia(), ib(), i, ja(), jb(), j, ka(), kb(), k);
00502           NAMD_die(msg);
00503         }
00504         return gdata[flatindex(i,j,k)];
00505       }

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

Definition at line 571 of file MsmMap.h.

References ASSERT, msm::GridFixed< T, N >::gdata, msm::Ivec::i, msm::IndexRange::IndexRange(), j, msm::Ivec::j, msm::Ivec::k, msm::IndexRange::nextent, msm::IndexRange::ni(), and msm::IndexRange::nlower.

00571                                       {
00572         ASSERT(IndexRange(g) <= IndexRange(*this));
00573         int gni = g.nextent.i;
00574         int gnj = g.nextent.j;
00575         int gnk = g.nextent.k;
00576         int index = 0;
00577         int ni = nextent.i;
00578         int nij = nextent.i * nextent.j;
00579         int koff = (g.nlower.k - nlower.k) * nij
00580           + (g.nlower.j - nlower.j) * ni + (g.nlower.i - nlower.i);
00581         T *gbuf = g.gdata.buffer();
00582         const T *buf = gdata.buffer();
00583         for (int k = 0;  k < gnk;  k++) {
00584           int jkoff = k * nij + koff;
00585           for (int j = 0;  j < gnj;  j++) {
00586             int ijkoff = j * ni + jkoff;
00587             for (int i = 0;  i < gni;  i++, index++) {
00588               gbuf[index] = buf[i + ijkoff];
00589             }
00590           }
00591         }
00592       }

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

Definition at line 528 of file MsmMap.h.

References msm::IndexRange::ia(), msm::IndexRange::ja(), msm::IndexRange::ka(), msm::IndexRange::ni(), and msm::IndexRange::nj().

Referenced by msm::GridFixed< T, N >::elem(), and msm::GridFixed< T, N >::operator()().

00528                                                {
00529         return ((k-ka())*nj() + (j-ja()))*ni() + (i-ia());
00530       }

template<class T, int N>
void msm::GridFixed< T, N >::init ( const IndexRange n  )  [inline]

Definition at line 471 of file MsmMap.h.

References ASSERT, msm::IndexRange::extent(), msm::Ivec::i, msm::Ivec::j, msm::Ivec::k, msm::IndexRange::lower(), msm::IndexRange::nextent, and msm::IndexRange::nlower.

00471                                      {
00472         nlower = n.lower();
00473         nextent = n.extent();
00474         ASSERT(nextent.i * nextent.j * nextent.k <= N);
00475       }

template<class T, int N>
T& msm::GridFixed< T, N >::operator() ( const Ivec n  )  [inline]

Definition at line 513 of file MsmMap.h.

References msm::Ivec::i, msm::Ivec::j, msm::Ivec::k, and msm::GridFixed< T, N >::operator()().

00513                                    {
00514         return this->operator()(n.i, n.j, n.k);
00515       }

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

Definition at line 506 of file MsmMap.h.

References msm::GridFixed< T, N >::elem(), and msm::GridFixed< T, N >::flatindex().

00506                                          {
00507 #ifdef DEBUG_MSM
00508         return elem(i,j,k);
00509 #else
00510         return gdata[flatindex(i,j,k)];
00511 #endif
00512       }

template<class T, int N>
const T& msm::GridFixed< T, N >::operator() ( const Ivec n  )  const [inline]

Definition at line 491 of file MsmMap.h.

References msm::Ivec::i, msm::Ivec::j, msm::Ivec::k, and msm::GridFixed< T, N >::operator()().

00491                                                {
00492         return this->operator()(n.i, n.j, n.k);
00493       }

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

Definition at line 484 of file MsmMap.h.

References msm::GridFixed< T, N >::elem(), and msm::GridFixed< T, N >::flatindex().

Referenced by msm::GridFixed< T, N >::operator()().

00484                                                      {
00485 #ifdef DEBUG_MSM
00486         return elem(i,j,k);
00487 #else
00488         return gdata[flatindex(i,j,k)];
00489 #endif
00490       }

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

Definition at line 545 of file MsmMap.h.

References ASSERT, msm::GridFixed< T, N >::gdata, msm::Ivec::i, msm::IndexRange::IndexRange(), j, msm::Ivec::j, msm::Ivec::k, msm::IndexRange::nextent, msm::IndexRange::ni(), and msm::IndexRange::nlower.

00545                                                           {
00546         ASSERT(IndexRange(g) <= IndexRange(*this));
00547         int gni = g.nextent.i;
00548         int gnj = g.nextent.j;
00549         int gnk = g.nextent.k;
00550         int index = 0;
00551         int ni = nextent.i;
00552         int nij = nextent.i * nextent.j;
00553         int koff = (g.nlower.k - nlower.k) * nij
00554           + (g.nlower.j - nlower.j) * ni + (g.nlower.i - nlower.i);
00555         const T *gbuf = g.gdata.buffer();
00556         T *buf = gdata.buffer();
00557         for (int k = 0;  k < gnk;  k++) {
00558           int jkoff = k * nij + koff;
00559           for (int j = 0;  j < gnj;  j++) {
00560             int ijkoff = j * ni + jkoff;
00561             for (int i = 0;  i < gni;  i++, index++) {
00562               buf[i + ijkoff] += gbuf[index];
00563             }
00564           }
00565         }
00566         return(*this);
00567       }

template<class T, int N>
void msm::GridFixed< T, N >::reset ( const T &  t  )  [inline]

Definition at line 535 of file MsmMap.h.

References msm::IndexRange::nn().

00535                              {
00536         int len = nn();
00537         for (int n = 0;  n < len;  n++) { gdata[n] = t; }
00538       }

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

Reimplemented from msm::IndexRange.

Definition at line 476 of file MsmMap.h.

References ASSERT, msm::Ivec::i, msm::Ivec::j, msm::Ivec::k, msm::IndexRange::nextent, and msm::IndexRange::set().

00476                                                                      {
00477         IndexRange::set(pia, pni, pja, pnj, pka, pnk);
00478         ASSERT(nextent.i * nextent.j * nextent.k <= N);
00479       }

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

Reimplemented from msm::IndexRange.

Definition at line 480 of file MsmMap.h.

References ASSERT, msm::Ivec::i, msm::Ivec::j, msm::Ivec::k, msm::IndexRange::nextent, and msm::IndexRange::setbounds().

00480                                                                            {
00481         IndexRange::setbounds(pia, pib, pja, pjb, pka, pkb);
00482         ASSERT(nextent.i * nextent.j * nextent.k <= N);
00483       }

template<class T, int N>
void msm::GridFixed< T, N >::updateLower ( const Ivec n  )  [inline]

Definition at line 541 of file MsmMap.h.

References msm::IndexRange::nlower.

00541 { nlower = n; }


Friends And Related Function Documentation

template<class T, int N>
friend class Grid< T > [friend]

Definition at line 468 of file MsmMap.h.


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