NAMD
Public Member Functions | Friends | List of all members
msm::GridFixed< T, N > Class Template Reference

#include <MsmMap.h>

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

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)
 
- Public Member Functions inherited from msm::IndexRange
 IndexRange ()
 
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)
 
int ia () const
 
int ib () const
 
int ja () const
 
int jb () const
 
int ka () const
 
int kb () const
 
int ni () const
 
int nj () const
 
int nk () const
 
int nn () const
 
Ivec lower () const
 
Ivec extent () const
 
int operator<= (const IndexRange &n)
 

Friends

class Grid< T >
 

Additional Inherited Members

- Protected Attributes inherited from msm::IndexRange
Ivec nlower
 
Ivec nextent
 

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.

470 { }

Member Function Documentation

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+=().

531 { return gdata; }
template<class T, int N>
T* msm::GridFixed< T, N >::buffer ( )
inline

Definition at line 532 of file MsmMap.h.

532 { return gdata; }
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()().

494  {
495  if (i<ia() || i>ib() || j<ja() || j>jb() || k<ka() || k>kb()) {
496  char msg[200];
497  snprintf(msg, sizeof(msg), "Grid indexing:\n"
498  "ia=%d, ib=%d, i=%d\n"
499  "ja=%d, jb=%d, j=%d\n"
500  "ka=%d, kb=%d, k=%d\n",
501  ia(), ib(), i, ja(), jb(), j, ka(), kb(), k);
502  NAMD_die(msg);
503  }
504  return gdata[flatindex(i,j,k)];
505  }
int ka() const
Definition: MsmMap.h:438
int ia() const
Definition: MsmMap.h:434
int flatindex(int i, int j, int k) const
Definition: MsmMap.h:528
int kb() const
Definition: MsmMap.h:439
int jb() const
Definition: MsmMap.h:437
void NAMD_die(const char *err_msg)
Definition: common.C:83
int ib() const
Definition: MsmMap.h:435
int ja() const
Definition: MsmMap.h:436
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().

516  {
517  if (i<ia() || i>ib() || j<ja() || j>jb() || k<ka() || k>kb()) {
518  char msg[200];
519  snprintf(msg, sizeof(msg), "Grid indexing:\n"
520  "ia=%d, ib=%d, i=%d\n"
521  "ja=%d, jb=%d, j=%d\n"
522  "ka=%d, kb=%d, k=%d\n",
523  ia(), ib(), i, ja(), jb(), j, ka(), kb(), k);
524  NAMD_die(msg);
525  }
526  return gdata[flatindex(i,j,k)];
527  }
int ka() const
Definition: MsmMap.h:438
int ia() const
Definition: MsmMap.h:434
int flatindex(int i, int j, int k) const
Definition: MsmMap.h:528
int kb() const
Definition: MsmMap.h:439
int jb() const
Definition: MsmMap.h:437
void NAMD_die(const char *err_msg)
Definition: common.C:83
int ib() const
Definition: MsmMap.h:435
int ja() const
Definition: MsmMap.h:436
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::Ivec::i, msm::IndexRange::IndexRange(), msm::Ivec::j, msm::Ivec::k, msm::IndexRange::nextent, msm::IndexRange::ni(), and msm::IndexRange::nlower.

571  {
572  ASSERT(IndexRange(g) <= IndexRange(*this));
573  int gni = g.nextent.i;
574  int gnj = g.nextent.j;
575  int gnk = g.nextent.k;
576  int index = 0;
577  int ni = nextent.i;
578  int nij = nextent.i * nextent.j;
579  int koff = (g.nlower.k - nlower.k) * nij
580  + (g.nlower.j - nlower.j) * ni + (g.nlower.i - nlower.i);
581  T *gbuf = g.gdata.buffer();
582  const T *buf = gdata.buffer();
583  for (int k = 0; k < gnk; k++) {
584  int jkoff = k * nij + koff;
585  for (int j = 0; j < gnj; j++) {
586  int ijkoff = j * ni + jkoff;
587  for (int i = 0; i < gni; i++, index++) {
588  gbuf[index] = buf[i + ijkoff];
589  }
590  }
591  }
592  }
#define ASSERT(expr)
Definition: MsmMap.h:68
int k
Definition: MsmMap.h:411
int i
Definition: MsmMap.h:411
int j
Definition: MsmMap.h:411
Ivec nextent
Definition: MsmMap.h:459
int ni() const
Definition: MsmMap.h:440
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()().

528  {
529  return ((k-ka())*nj() + (j-ja()))*ni() + (i-ia());
530  }
int ka() const
Definition: MsmMap.h:438
int ia() const
Definition: MsmMap.h:434
int nj() const
Definition: MsmMap.h:441
int ja() const
Definition: MsmMap.h:436
int ni() const
Definition: MsmMap.h:440
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.

471  {
472  nlower = n.lower();
473  nextent = n.extent();
474  ASSERT(nextent.i * nextent.j * nextent.k <= N);
475  }
#define ASSERT(expr)
Definition: MsmMap.h:68
int k
Definition: MsmMap.h:411
int i
Definition: MsmMap.h:411
int j
Definition: MsmMap.h:411
Ivec nextent
Definition: MsmMap.h:459
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()().

484  {
485 #ifdef DEBUG_MSM
486  return elem(i,j,k);
487 #else
488  return gdata[flatindex(i,j,k)];
489 #endif
490  }
int flatindex(int i, int j, int k) const
Definition: MsmMap.h:528
const T & elem(int i, int j, int k) const
Definition: MsmMap.h:494
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()().

491  {
492  return this->operator()(n.i, n.j, n.k);
493  }
const T & operator()(int i, int j, int k) const
Definition: MsmMap.h:484
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().

506  {
507 #ifdef DEBUG_MSM
508  return elem(i,j,k);
509 #else
510  return gdata[flatindex(i,j,k)];
511 #endif
512  }
int flatindex(int i, int j, int k) const
Definition: MsmMap.h:528
const T & elem(int i, int j, int k) const
Definition: MsmMap.h:494
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()().

513  {
514  return this->operator()(n.i, n.j, n.k);
515  }
const T & operator()(int i, int j, int k) const
Definition: MsmMap.h:484
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::Ivec::i, msm::IndexRange::IndexRange(), msm::Ivec::j, msm::Ivec::k, msm::IndexRange::nextent, msm::IndexRange::ni(), and msm::IndexRange::nlower.

545  {
546  ASSERT(IndexRange(g) <= IndexRange(*this));
547  int gni = g.nextent.i;
548  int gnj = g.nextent.j;
549  int gnk = g.nextent.k;
550  int index = 0;
551  int ni = nextent.i;
552  int nij = nextent.i * nextent.j;
553  int koff = (g.nlower.k - nlower.k) * nij
554  + (g.nlower.j - nlower.j) * ni + (g.nlower.i - nlower.i);
555  const T *gbuf = g.gdata.buffer();
556  T *buf = gdata.buffer();
557  for (int k = 0; k < gnk; k++) {
558  int jkoff = k * nij + koff;
559  for (int j = 0; j < gnj; j++) {
560  int ijkoff = j * ni + jkoff;
561  for (int i = 0; i < gni; i++, index++) {
562  buf[i + ijkoff] += gbuf[index];
563  }
564  }
565  }
566  return(*this);
567  }
#define ASSERT(expr)
Definition: MsmMap.h:68
int k
Definition: MsmMap.h:411
int i
Definition: MsmMap.h:411
int j
Definition: MsmMap.h:411
Ivec nextent
Definition: MsmMap.h:459
int ni() const
Definition: MsmMap.h:440
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().

535  {
536  int len = nn();
537  for (int n = 0; n < len; n++) { gdata[n] = t; }
538  }
int nn() const
Definition: MsmMap.h:443
template<class T, int N>
void msm::GridFixed< T, N >::set ( int  pia,
int  pni,
int  pja,
int  pnj,
int  pka,
int  pnk 
)
inline

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().

476  {
477  IndexRange::set(pia, pni, pja, pnj, pka, pnk);
478  ASSERT(nextent.i * nextent.j * nextent.k <= N);
479  }
#define ASSERT(expr)
Definition: MsmMap.h:68
int k
Definition: MsmMap.h:411
int i
Definition: MsmMap.h:411
void set(int pia, int pni, int pja, int pnj, int pka, int pnk)
Definition: MsmMap.h:426
int j
Definition: MsmMap.h:411
Ivec nextent
Definition: MsmMap.h:459
template<class T, int N>
void msm::GridFixed< T, N >::setbounds ( int  pia,
int  pib,
int  pja,
int  pjb,
int  pka,
int  pkb 
)
inline

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().

480  {
481  IndexRange::setbounds(pia, pib, pja, pjb, pka, pkb);
482  ASSERT(nextent.i * nextent.j * nextent.k <= N);
483  }
#define ASSERT(expr)
Definition: MsmMap.h:68
int k
Definition: MsmMap.h:411
int i
Definition: MsmMap.h:411
void setbounds(int pia, int pib, int pja, int pjb, int pka, int pkb)
Definition: MsmMap.h:431
int j
Definition: MsmMap.h:411
Ivec nextent
Definition: MsmMap.h:459
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.

541 { 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: