GridforceGrid Class Reference

#include <GridForceGrid.h>

Inheritance diagram for GridforceGrid:

GridforceFullMainGrid GridforceLiteGrid List of all members.

Public Types

 GridforceGridTypeUndefined = 0
 GridforceGridTypeFull
 GridforceGridTypeLite
enum  GridforceGridType { GridforceGridTypeUndefined = 0, GridforceGridTypeFull, GridforceGridTypeLite }

Public Member Functions

virtual ~GridforceGrid ()
virtual void initialize (char *potfilename, SimParameters *simParams, MGridforceParams *mgridParams)=0
virtual void reinitialize (SimParameters *simParams, MGridforceParams *mgridParams)=0
virtual Position get_center (void) const =0
virtual Position get_origin (void) const =0
virtual Tensor get_e (void) const =0
virtual Tensor get_inv (void) const =0
virtual Vector get_scale (void) const =0
virtual Bool get_checksize (void) const =0
virtual int get_k0 (void) const =0
virtual int get_k1 (void) const =0
virtual int get_k2 (void) const =0
virtual int get_total_grids (void) const =0
virtual long int get_all_gridvals (float **all_gridvals) const =0
virtual void set_all_gridvals (float *all_gridvals, long int sz)=0
virtual void set_scale (Vector s)=0
Position wrap_position (const Position &pos, const Lattice &lattice)
bool fits_lattice (const Lattice &lattice)
int compute_VdV (Position pos, float &V, Vector &dV) const
GridforceGridType get_grid_type (void)

Static Public Member Functions

static GridforceGridnew_grid (int gridnum, char *potfilename, SimParameters *simParams, MGridforceParams *mgridParams)
static void pack_grid (GridforceGrid *grid, MOStream *msg)
static GridforceGridunpack_grid (int gridnum, MIStream *msg)

Protected Member Functions

virtual void pack (MOStream *msg) const =0
virtual void unpack (MIStream *msg)=0
Position get_corner (int idx)
 GridforceGrid ()

Protected Attributes

GridforceGridType type
int mygridnum

Detailed Description

Definition at line 28 of file GridForceGrid.h.


Member Enumeration Documentation

enum GridforceGrid::GridforceGridType

Enumerator:
GridforceGridTypeUndefined 
GridforceGridTypeFull 
GridforceGridTypeLite 

Definition at line 59 of file GridForceGrid.h.


Constructor & Destructor Documentation

GridforceGrid::~GridforceGrid (  )  [virtual]

Definition at line 48 of file GridForceGrid.C.

00048 { ; }

GridforceGrid::GridforceGrid (  )  [inline, protected]

Definition at line 73 of file GridForceGrid.h.

References GridforceGridTypeUndefined, and type.


Member Function Documentation

int GridforceGrid::compute_VdV ( Position  pos,
float &  V,
Vector dV 
) const [inline]

Reimplemented in GridforceFullMainGrid, and GridforceLiteGrid.

Definition at line 54 of file GridForceGrid.h.

00054 { return -1; }

bool GridforceGrid::fits_lattice ( const Lattice lattice  ) 

Definition at line 84 of file GridForceGrid.C.

References DebugM, endi(), get_center(), get_corner(), and wrap_position().

00085 {
00086     // Idea: Go through each grid corner and wrap it to the grid center;
00087     // if the position moves, then the grid is too big and we return false
00088     DebugM(4, "Checking whether grid fits periodic cell\n");
00089     Position center = get_center();
00090     for (int i = 0; i < 8; i++) {
00091         Position pos = get_corner(i);
00092         Position pos_wrapped = wrap_position(pos, lattice);
00093         if ((pos - pos_wrapped).length() > 1.) {
00094             DebugM(5, "(" << pos << ") != (" << pos_wrapped << ")\n" << endi);
00095             return false;
00096         }
00097     }
00098     return true;
00099 }

virtual long int GridforceGrid::get_all_gridvals ( float **  all_gridvals  )  const [pure virtual]

Implemented in GridforceFullMainGrid, and GridforceLiteGrid.

virtual Position GridforceGrid::get_center ( void   )  const [pure virtual]

Implemented in GridforceFullMainGrid, and GridforceLiteGrid.

Referenced by fits_lattice(), and wrap_position().

virtual Bool GridforceGrid::get_checksize ( void   )  const [pure virtual]

Implemented in GridforceFullMainGrid, and GridforceLiteGrid.

Position GridforceGrid::get_corner ( int  idx  )  [protected]

Definition at line 101 of file GridForceGrid.C.

References DebugM, endi(), get_e(), get_k0(), get_k1(), get_k2(), and get_origin().

Referenced by fits_lattice().

00102 {
00103     // idx -> (x,y,z) (cell basis coordinates)
00104     // 0 -> (0,0,0)
00105     // 1 -> (1,0,0)
00106     // 2 -> (0,1,0)
00107     // 3 -> (1,1,0)
00108     // 4 -> (0,0,1)
00109     // 5 -> (1,0,1)
00110     // 6 -> (0,1,1)
00111     // 7 -> (1,1,1)
00112     Position pos;
00113     if (idx >= 8 || idx < 0) {
00114         // invalid index
00115         pos = Vector(); // default value of Vector() is strange enough to be a decent "undefined" value (-99999, -99999, -999999)
00116     } else if (corners[idx] != Vector()) {
00117         // use cached value if possible
00118         pos = corners[idx];
00119     } else {
00120         // must calculate
00121         Tensor e = get_e();
00122         pos = get_origin();
00123         if (idx & (1 << 0)) pos += e * Vector(get_k0()-1, 0, 0);
00124         if (idx & (1 << 1)) pos += e * Vector(0, get_k1()-1, 0);
00125         if (idx & (1 << 2)) pos += e * Vector(0, 0, get_k2()-1);
00126         corners[idx] = pos;     // cache for future use
00127         DebugM(4, "corner " << idx << " = " << pos << "\n" << endi);
00128     }
00129     return pos;
00130 }

virtual Tensor GridforceGrid::get_e ( void   )  const [pure virtual]

Implemented in GridforceFullMainGrid, and GridforceLiteGrid.

Referenced by get_corner().

GridforceGridType GridforceGrid::get_grid_type ( void   )  [inline]

Definition at line 65 of file GridForceGrid.h.

References type.

Referenced by pack_grid().

00065 { return type; }

virtual Tensor GridforceGrid::get_inv ( void   )  const [pure virtual]

Implemented in GridforceFullMainGrid, and GridforceLiteGrid.

virtual int GridforceGrid::get_k0 ( void   )  const [pure virtual]

Implemented in GridforceFullMainGrid, and GridforceLiteGrid.

Referenced by get_corner().

virtual int GridforceGrid::get_k1 ( void   )  const [pure virtual]

Implemented in GridforceFullMainGrid, and GridforceLiteGrid.

Referenced by get_corner().

virtual int GridforceGrid::get_k2 ( void   )  const [pure virtual]

Implemented in GridforceFullMainGrid, and GridforceLiteGrid.

Referenced by get_corner().

virtual Position GridforceGrid::get_origin ( void   )  const [pure virtual]

Implemented in GridforceFullMainGrid, and GridforceLiteGrid.

Referenced by get_corner().

virtual Vector GridforceGrid::get_scale ( void   )  const [pure virtual]

Implemented in GridforceFullMainGrid, and GridforceLiteGrid.

virtual int GridforceGrid::get_total_grids ( void   )  const [pure virtual]

Implemented in GridforceFullMainGrid, and GridforceLiteGrid.

Referenced by Molecule::build_gridforce_params(), and Molecule::receive_Molecule().

virtual void GridforceGrid::initialize ( char *  potfilename,
SimParameters simParams,
MGridforceParams mgridParams 
) [pure virtual]

Implemented in GridforceFullMainGrid, and GridforceLiteGrid.

Referenced by new_grid().

GridforceGrid * GridforceGrid::new_grid ( int  gridnum,
char *  potfilename,
SimParameters simParams,
MGridforceParams mgridParams 
) [static]

Definition at line 34 of file GridForceGrid.C.

References MGridforceParams::gridforceLite, initialize(), and simParams.

Referenced by Molecule::build_gridforce_params().

00035 {
00036     GridforceGrid *grid = NULL;
00037     if (mgridParams->gridforceLite) {
00038         grid = new GridforceLiteGrid(gridnum);
00039     } else {
00040         grid = new GridforceFullMainGrid(gridnum);
00041     }
00042     
00043     grid->initialize(potfilename, simParams, mgridParams);
00044     
00045     return grid;
00046 }

virtual void GridforceGrid::pack ( MOStream msg  )  const [protected, pure virtual]

Implemented in GridforceFullMainGrid, and GridforceLiteGrid.

Referenced by pack_grid().

void GridforceGrid::pack_grid ( GridforceGrid grid,
MOStream msg 
) [static]

Definition at line 50 of file GridForceGrid.C.

References get_grid_type(), pack(), and MOStream::put().

Referenced by Node::reloadGridforceGrid(), and Molecule::send_Molecule().

00051 {
00052     // Abstract interface for packing a grid into a message.  This
00053     // could easily be a non-static function as it was before, but is
00054     // static to make it similar to unpack_grid below, which does need
00055     // to be static since it creates a GridforceGrid object.
00056     msg->put(grid->get_grid_type());
00057     grid->pack(msg);
00058 }

virtual void GridforceGrid::reinitialize ( SimParameters simParams,
MGridforceParams mgridParams 
) [pure virtual]

Implemented in GridforceFullMainGrid, and GridforceLiteGrid.

Referenced by Node::reloadGridforceGrid().

virtual void GridforceGrid::set_all_gridvals ( float *  all_gridvals,
long int  sz 
) [pure virtual]

Implemented in GridforceFullMainGrid, and GridforceLiteGrid.

virtual void GridforceGrid::set_scale ( Vector  s  )  [pure virtual]

Implemented in GridforceFullMainGrid, and GridforceLiteGrid.

Referenced by Node::updateGridScale().

virtual void GridforceGrid::unpack ( MIStream msg  )  [protected, pure virtual]

Implemented in GridforceFullMainGrid, and GridforceLiteGrid.

Referenced by unpack_grid().

GridforceGrid * GridforceGrid::unpack_grid ( int  gridnum,
MIStream msg 
) [static]

Definition at line 60 of file GridForceGrid.C.

References MIStream::get(), GridforceGridTypeFull, GridforceGridTypeLite, NAMD_bug(), type, and unpack().

Referenced by Molecule::receive_Molecule(), and Node::reloadGridforceGrid().

00061 {
00062     // Abstract interface for unpacking a grid from a message.
00063     GridforceGrid *grid = NULL;
00064     int type;
00065     
00066     msg->get(type);
00067     
00068     switch (type) {
00069     case GridforceGridTypeFull:
00070         grid = new GridforceFullMainGrid(gridnum);
00071         break;
00072     case GridforceGridTypeLite:
00073         grid = new GridforceLiteGrid(gridnum);
00074         break;
00075     default:
00076         NAMD_bug("GridforceGrid::unpack_grid called with unknown grid type!");
00077     }
00078     
00079     grid->unpack(msg);
00080     
00081     return grid;
00082 }

Position GridforceGrid::wrap_position ( const Position pos,
const Lattice lattice 
) [inline]

Definition at line 463 of file GridForceGrid.inl.

References get_center(), Lattice::origin(), and Lattice::wrap_delta().

Referenced by fits_lattice().

00464 {
00465     // Wrap 'pos' about grid center, using periodic cell information in 'lattice'
00466     // Position pos_wrapped = pos;
00467     // Position center = get_center();
00468     // pos_wrapped += lattice.wrap_delta(pos);
00469     // pos_wrapped += lattice.delta(pos_wrapped, center) - (pos_wrapped - center);
00470     
00471     Position pos_wrapped = pos + lattice.wrap_delta(pos - get_center() + lattice.origin());
00472     
00473     return pos_wrapped;
00474 }


Member Data Documentation

int GridforceGrid::mygridnum [protected]

Definition at line 75 of file GridForceGrid.h.

Referenced by GridforceFullMainGrid::GridforceFullMainGrid(), GridforceLiteGrid::GridforceLiteGrid(), GridforceLiteGrid::initialize(), GridforceFullMainGrid::pack(), and GridforceFullMainGrid::unpack().

GridforceGridType GridforceGrid::type [protected]

Definition at line 74 of file GridForceGrid.h.

Referenced by get_grid_type(), GridforceFullMainGrid::GridforceFullMainGrid(), GridforceGrid(), GridforceLiteGrid::GridforceLiteGrid(), and unpack_grid().


The documentation for this class was generated from the following files:
Generated on Fri Nov 24 01:17:18 2017 for NAMD by  doxygen 1.4.7