Lattice Class Reference

#include <Lattice.h>

List of all members.

Public Member Functions

 Lattice (void)
void set (Vector A, Vector B, Vector C)
void set (Vector A, Vector B, Vector C, Position Origin)
void rescale (Tensor factor)
void rescale (Position &p, Tensor factor) const
Position unscale (ScaledPosition s) const
ScaledPosition scale (Position p) const
Position nearest (Position data, ScaledPosition ref) const
Position nearest (Position data, ScaledPosition ref, Transform *t) const
Position apply_transform (Position data, const Transform &t) const
Position reverse_transform (Position data, const Transform &t) const
Vector delta (const Position &pos1, const Position &pos2) const
Vector delta (const Position &pos1) const
Vector wrap_delta (const Position &pos1) const
Vector wrap_nearest_delta (Position pos1) const
Vector offset (int i) const
Vector a () const
Vector b () const
Vector c () const
int orthogonal () const
Vector origin () const
Vector a_r () const
Vector b_r () const
Vector c_r () const
int a_p () const
int b_p () const
int c_p () const
BigReal volume (void) const

Static Public Member Functions

static int index (int i=0, int j=0, int k=0)
static int offset_a (int i)
static int offset_b (int i)
static int offset_c (int i)


Detailed Description

Definition at line 27 of file Lattice.h.


Constructor & Destructor Documentation

Lattice::Lattice ( void   )  [inline]

Definition at line 30 of file Lattice.h.

00030                 : a1(0,0,0), a2(0,0,0), a3(0,0,0),
00031                   b1(0,0,0), b2(0,0,0), b3(0,0,0),
00032                   o(0,0,0), p1(0), p2(0), p3(0) {};


Member Function Documentation

Vector Lattice::a (  )  const [inline]

Definition at line 262 of file Lattice.h.

Referenced by HomePatch::doMarginCheck(), ComputePmeMgr::initialize(), ComputeMsmMgr::initialize(), OptPmeMgr::initialize_pencils(), ComputePmeMgr::initialize_pencils(), lattice_to_unitcell(), cr_sortop_distance::operator()(), Controller::printEnergies(), ComputeMsmSerialMgr::recvCoord(), ComputeExtMgr::recvCoord(), ComputeNonbondedCUDA::recvYieldDevice(), PatchMap::sizeGrid(), and Controller::writeExtendedSystemData().

00262 { return a1; }

int Lattice::a_p (  )  const [inline]

Definition at line 283 of file Lattice.h.

Referenced by calc_fulldirect(), ComputeMsmMgr::initialize(), lattice_to_unitcell(), WorkDistrib::patchMapInit(), Controller::printEnergies(), SimParameters::readExtendedSystem(), ComputeMsmSerialMgr::recvCoord(), ComputeFmmSerialMgr::recvCoord(), ComputeExtMgr::recvCoord(), PatchMap::sizeGrid(), Node::startup(), Controller::writeExtendedSystemData(), and Controller::writeExtendedSystemLabels().

00283 { return p1; }

Vector Lattice::a_r (  )  const [inline]

Definition at line 278 of file Lattice.h.

Referenced by ComputeEField::doForce(), HomePatch::doMarginCheck(), PmeAtomFiler::fileAtoms(), PDB::find_extremes(), ComputePmeMgr::initialize(), ComputeMsmMgr::initialize(), OptPmeMgr::initialize_pencils(), ComputePmeMgr::initialize_pencils(), WorkDistrib::patchMapInit(), ComputeMsmSerialMgr::recvCoord(), scale_coordinates(), scale_forces(), scale_n_copy_coordinates(), PatchMap::sizeGrid(), and CudaPmeKSpaceCompute::solve().

00278 { return b1; }

Position Lattice::apply_transform ( Position  data,
const Transform t 
) const [inline]

Definition at line 142 of file Lattice.h.

References Transform::i, Transform::j, and Transform::k.

Referenced by Sequencer::berendsenPressure(), WorkDistrib::createAtomLists(), HomePatch::depositMigration(), Sequencer::langevinPiston(), and PatchMgr::moveAtom().

00143   {
00144     return ( data + t.i*a1 + t.j*a2 + t.k*a3 );
00145   }

Vector Lattice::b (  )  const [inline]

Definition at line 263 of file Lattice.h.

Referenced by HomePatch::doMarginCheck(), ComputeMsmMgr::initialize(), OptPmeMgr::initialize_pencils(), ComputePmeMgr::initialize_pencils(), lattice_to_unitcell(), cr_sortop_distance::operator()(), Controller::printEnergies(), ComputeMsmSerialMgr::recvCoord(), ComputeExtMgr::recvCoord(), ComputeNonbondedCUDA::recvYieldDevice(), PatchMap::sizeGrid(), and Controller::writeExtendedSystemData().

00263 { return a2; }

int Lattice::b_p (  )  const [inline]

Definition at line 284 of file Lattice.h.

Referenced by calc_fulldirect(), ComputeMsmMgr::initialize(), lattice_to_unitcell(), WorkDistrib::patchMapInit(), Controller::printEnergies(), SimParameters::readExtendedSystem(), ComputeMsmSerialMgr::recvCoord(), ComputeFmmSerialMgr::recvCoord(), ComputeExtMgr::recvCoord(), PatchMap::sizeGrid(), Node::startup(), Controller::writeExtendedSystemData(), and Controller::writeExtendedSystemLabels().

00284 { return p2; }

Vector Lattice::b_r (  )  const [inline]

Definition at line 279 of file Lattice.h.

Referenced by ComputeEField::doForce(), HomePatch::doMarginCheck(), PmeAtomFiler::fileAtoms(), PDB::find_extremes(), ComputeMsmMgr::initialize(), OptPmeMgr::initialize_pencils(), ComputePmeMgr::initialize_pencils(), WorkDistrib::patchMapInit(), ComputeMsmSerialMgr::recvCoord(), scale_coordinates(), scale_forces(), scale_n_copy_coordinates(), PatchMap::sizeGrid(), and CudaPmeKSpaceCompute::solve().

00279 { return b2; }

Vector Lattice::c (  )  const [inline]

Definition at line 264 of file Lattice.h.

Referenced by ComputeNonbondedSelf::doForce(), ComputeNonbondedPair::doForce(), HomePatch::doMarginCheck(), ComputeHomeTuples< AnisoElem, aniso, aniso >::doWork(), ComputeEwald::doWork(), HomePatch::hardWallDrude(), ComputeMsmMgr::initialize(), Controller::langevinPiston1(), Controller::langevinPiston2(), lattice_to_unitcell(), cr_sortop_distance::operator()(), Controller::printEnergies(), HomePatch::rattle1old(), ComputeMsmSerialMgr::recvCoord(), ComputeExtMgr::recvCoord(), ComputeNonbondedCUDA::recvYieldDevice(), PatchMap::sizeGrid(), Sequencer::submitHalfstep(), and Controller::writeExtendedSystemData().

00264 { return a3; }

int Lattice::c_p (  )  const [inline]

Definition at line 285 of file Lattice.h.

Referenced by calc_fulldirect(), ComputeMsmMgr::initialize(), lattice_to_unitcell(), WorkDistrib::patchMapInit(), Controller::printEnergies(), SimParameters::readExtendedSystem(), ComputeMsmSerialMgr::recvCoord(), ComputeFmmSerialMgr::recvCoord(), ComputeExtMgr::recvCoord(), PatchMap::sizeGrid(), Node::startup(), Controller::writeExtendedSystemData(), and Controller::writeExtendedSystemLabels().

00285 { return p3; }

Vector Lattice::c_r (  )  const [inline]

Definition at line 280 of file Lattice.h.

Referenced by ComputeEField::doForce(), HomePatch::doMarginCheck(), PmeAtomFiler::fileAtoms(), PDB::find_extremes(), ComputeMsmMgr::initialize(), WorkDistrib::patchMapInit(), ComputeMsmSerialMgr::recvCoord(), scale_coordinates(), scale_forces(), scale_n_copy_coordinates(), PatchMap::sizeGrid(), and CudaPmeKSpaceCompute::solve().

00280 { return b3; }

Vector Lattice::delta ( const Position pos1  )  const [inline]

Definition at line 205 of file Lattice.h.

References latticenearbyint.

00206   {
00207     Vector diff = pos1 - o;
00208     Vector result = diff;
00209     if ( p1 ) result -= a1*latticenearbyint(b1*diff);
00210     if ( p2 ) result -= a2*latticenearbyint(b2*diff);
00211     if ( p3 ) result -= a3*latticenearbyint(b3*diff);
00212     return result;
00213   }

Vector Lattice::delta ( const Position pos1,
const Position pos2 
) const [inline]

Definition at line 154 of file Lattice.h.

References latticenearbyint, Vector::x, Vector::y, and Vector::z.

Referenced by TholeElem::computeForce(), ExclElem::computeForce(), ImproperElem::computeForce(), GromacsPairElem::computeForce(), DihedralElem::computeForce(), CrosstermElem::computeForce(), BondElem::computeForce(), AnisoElem::computeForce(), AngleElem::computeForce(), ComputeRestraints::doForce(), colvarproxy_namd::position_dist2(), and colvarproxy_namd::position_distance().

00155   {
00156     Vector diff = pos1 - pos2;
00157 #ifdef ARCH_POWERPC   //Prevents stack temporaries
00158     Vector result = diff;
00159     if ( p1 ) {
00160       BigReal fval = latticenearbyint(b1*diff); 
00161       result.x -= a1.x *fval;    
00162       result.y -= a1.y *fval;    
00163       result.z -= a1.z *fval;    
00164     }
00165     if ( p2 ) {
00166       BigReal fval = latticenearbyint(b2*diff);
00167       result.x -= a2.x * fval;
00168       result.y -= a2.y * fval;
00169       result.z -= a2.z * fval;
00170     }
00171     if ( p3 ) {
00172       BigReal fval = latticenearbyint(b3*diff);
00173       result.x -= a3.x * fval;
00174       result.y -= a3.y * fval;
00175       result.z -= a3.z * fval;
00176     }
00177     return result;
00178 #else
00179     BigReal f1 = p1 ? latticenearbyint(b1*diff) : 0.;
00180     BigReal f2 = p2 ? latticenearbyint(b2*diff) : 0.;
00181     BigReal f3 = p3 ? latticenearbyint(b3*diff) : 0.;
00182     diff.x -= f1*a1.x + f2*a2.x + f3*a3.x;
00183     diff.y -= f1*a1.y + f2*a2.y + f3*a3.y;
00184     diff.z -= f1*a1.z + f2*a2.z + f3*a3.z;
00185     return diff;
00186 #endif
00187   }

static int Lattice::index ( int  i = 0,
int  j = 0,
int  k = 0 
) [inline, static]

Definition at line 35 of file Lattice.h.

References j.

Referenced by PatchMap::downstreamNeighbors(), PatchMap::getPatchesInOctet(), PatchMap::oneAwayNeighbors(), PatchMap::oneOrTwoAwayNeighbors(), and PatchMap::upstreamNeighbors().

00036   {
00037     return 9 * (k+1) + 3 * (j+1) + (i+1);
00038   }

Position Lattice::nearest ( Position  data,
ScaledPosition  ref,
Transform t 
) const [inline]

Definition at line 117 of file Lattice.h.

References Transform::i, Transform::j, Transform::k, latticenearbyint, scale(), unscale(), Vector::x, Vector::y, and Vector::z.

00118   {
00119     ScaledPosition sn = scale(data);
00120     if ( p1 ) {
00121       BigReal tmp = sn.x - ref.x;
00122       BigReal rit = latticenearbyint(tmp);
00123       sn.x -= rit;
00124       t->i -= (int) rit;
00125     }
00126     if ( p2 ) {
00127       BigReal tmp = sn.y - ref.y;
00128       BigReal rit = latticenearbyint(tmp);
00129       sn.y -= rit;
00130       t->j -= (int) rit;
00131     }
00132     if ( p3 ) {
00133       BigReal tmp = sn.z - ref.z;
00134       BigReal rit = latticenearbyint(tmp);
00135       sn.z -= rit;
00136       t->k -= (int) rit;
00137     }
00138     return unscale(sn);
00139   }

Position Lattice::nearest ( Position  data,
ScaledPosition  ref 
) const [inline]

Definition at line 100 of file Lattice.h.

References latticenearbyint, scale(), unscale(), Vector::x, Vector::y, and Vector::z.

Referenced by WorkDistrib::createAtomLists(), HomePatch::depositMigration(), and colvarproxy_namd::select_closest_image().

00101   {
00102     ScaledPosition sn = scale(data);
00103     if ( p1 ) {
00104       sn.x -= latticenearbyint(sn.x - ref.x);
00105     }
00106     if ( p2 ) {
00107       sn.y -= latticenearbyint(sn.y - ref.y);
00108     }
00109     if ( p3 ) {
00110       sn.z -= latticenearbyint(sn.z - ref.z);
00111     }
00112     return unscale(sn);
00113   }

Vector Lattice::offset ( int  i  )  const [inline]

Definition at line 252 of file Lattice.h.

Referenced by ComputeNonbondedPair::doForce().

00253   {
00254     return ( (i%3-1) * a1 + ((i/3)%3-1) * a2 + (i/9-1) * a3 );
00255   }

static int Lattice::offset_a ( int  i  )  [inline, static]

Definition at line 257 of file Lattice.h.

Referenced by registerUserEventsForAllComputeObjs().

00257 { return (i%3-1); }

static int Lattice::offset_b ( int  i  )  [inline, static]

Definition at line 258 of file Lattice.h.

Referenced by registerUserEventsForAllComputeObjs().

00258 { return ((i/3)%3-1); }

static int Lattice::offset_c ( int  i  )  [inline, static]

Definition at line 259 of file Lattice.h.

Referenced by registerUserEventsForAllComputeObjs().

00259 { return (i/9-1); }

Vector Lattice::origin (  )  const [inline]

Definition at line 272 of file Lattice.h.

Referenced by Controller::calcPressure(), ComputeNonbondedSelf::doForce(), ComputeNonbondedPair::doForce(), ComputeEField::doForce(), ComputeHomeTuples< AnisoElem, aniso, aniso >::doWork(), ComputeEwald::doWork(), PDB::find_extremes(), HomePatch::hardWallDrude(), WorkDistrib::patchMapInit(), Controller::printEnergies(), HomePatch::rattle1old(), ComputeMsmSerialMgr::recvCoord(), scale_coordinates(), scale_n_copy_coordinates(), Sequencer::scalePositionsVelocities(), Sequencer::submitHalfstep(), Sequencer::submitReductions(), GridforceGrid::wrap_position(), and Controller::writeExtendedSystemData().

00273   {
00274     return o;
00275   }

int Lattice::orthogonal (  )  const [inline]

Definition at line 267 of file Lattice.h.

References Vector::x, Vector::y, and Vector::z.

00267                          {
00268     return ( ! ( a1.y || a1.z || a2.x || a2.z || a3.x || a3.y ) );
00269   }

void Lattice::rescale ( Position p,
Tensor  factor 
) const [inline]

Definition at line 79 of file Lattice.h.

00080   {
00081     p -= o;
00082     p = factor * p;
00083     p += o;
00084   }

void Lattice::rescale ( Tensor  factor  )  [inline]

Definition at line 70 of file Lattice.h.

Referenced by Sequencer::berendsenPressure(), Controller::berendsenPressure(), Sequencer::langevinPiston(), Controller::langevinPiston1(), Sequencer::multigratorPressure(), and Controller::multigratorPressure().

00071   {
00072     a1 = factor * a1;
00073     a2 = factor * a2;
00074     a3 = factor * a3;
00075     recalculate();
00076   }

Position Lattice::reverse_transform ( Position  data,
const Transform t 
) const [inline]

Definition at line 148 of file Lattice.h.

References Transform::i, Transform::j, and Transform::k.

Referenced by HomePatch::depositMigration(), ComputeGridForce::do_calc(), ComputeStir::doForce(), ComputeEField::doForce(), ComputeConsTorque::doForce(), ComputeConsForce::doForce(), PatchMgr::moveAtom(), ComputeGlobal::recvResults(), and CollectionMgr::submitPositions().

00149   {
00150     return ( data - t.i*a1 - t.j*a2 - t.k*a3 );
00151   }

ScaledPosition Lattice::scale ( Position  p  )  const [inline]

Definition at line 93 of file Lattice.h.

Referenced by msm::PatchData::anterpolation(), msm::PatchData::anterpolationC1Hermite(), PatchMap::assignToPatch(), HomePatch::doAtomMigration(), HomePatch::doMarginCheck(), ComputeMsmMgr::initialize(), msm::PatchData::interpolation(), msm::PatchData::interpolationC1Hermite(), nearest(), and colvarproxy_namd::select_closest_image().

00094   {
00095     p -= o;
00096     return Vector(b1*p,b2*p,b3*p);
00097   }

void Lattice::set ( Vector  A,
Vector  B,
Vector  C,
Position  Origin 
) [inline]

Definition at line 47 of file Lattice.h.

References A, B, cross(), Vector::length(), Vector::length2(), and volume().

00048   {
00049     a1 = A; a2 = B; a3 = C; o = Origin;
00050     p1 = ( a1.length2() ? 1 : 0 );
00051     p2 = ( a2.length2() ? 1 : 0 );
00052     p3 = ( a3.length2() ? 1 : 0 );
00053     if ( ! p1 ) a1 = Vector(1.0,0.0,0.0);
00054     if ( ! p2 ) {
00055       Vector u1 = a1 / a1.length();
00056       Vector e_z(0.0,0.0,1.0);
00057       if ( fabs(e_z * u1) < 0.9 ) { a2 = cross(e_z,a1); }
00058       else { a2 = cross(Vector(1.0,0.0,0.0),a1); }
00059       a2 /= a2.length();
00060     }
00061     if ( ! p3 ) {
00062       a3 = cross(a1,a2);
00063       a3 /= a3.length();
00064     }
00065     if ( volume() < 0.0 ) a3 *= -1.0;
00066     recalculate();
00067   }

void Lattice::set ( Vector  A,
Vector  B,
Vector  C 
) [inline]

Definition at line 41 of file Lattice.h.

References A, and B.

Referenced by get_lattice_from_ts().

00042   {
00043     set(A,B,C,o);
00044   }

Position Lattice::unscale ( ScaledPosition  s  )  const [inline]

Definition at line 87 of file Lattice.h.

References Vector::x, Vector::y, and Vector::z.

Referenced by ComputeNonbondedPair::doForce(), HomePatch::doPairlistCheck(), Patch::forceBoxClosed(), nearest(), Patch::positionsReady(), and HomePatch::positionsReady().

00088   {
00089     return (o + a1*s.x + a2*s.y + a3*s.z);
00090   }

BigReal Lattice::volume ( void   )  const [inline]

Definition at line 287 of file Lattice.h.

References cross().

Referenced by ParallelIOMgr::bcastHydroBasedCounter(), Controller::calcPressure(), PressureProfileReduction::getData(), Controller::langevinPiston1(), Controller::langevinPiston2(), NamdState::loadStructure(), Controller::multigatorCalcEnthalpy(), Controller::multigratorPressure(), Controller::printEnergies(), ComputeEwald::recvResults(), Controller::rescaleaccelMD(), set(), and CudaPmeKSpaceCompute::solve().

00288   {
00289     return ( p1 && p2 && p3 ? cross(a1,a2) * a3 : 0.0 );
00290   }

Vector Lattice::wrap_delta ( const Position pos1  )  const [inline]

Definition at line 216 of file Lattice.h.

References latticenearbyint.

Referenced by ComputeEwald::doWork(), ParallelIOMgr::recvFinalClusterCoor(), wrap_coor_int(), and GridforceGrid::wrap_position().

00217   {
00218     Vector diff = pos1 - o;
00219     Vector result(0.,0.,0.);
00220     if ( p1 ) result -= a1*latticenearbyint(b1*diff);
00221     if ( p2 ) result -= a2*latticenearbyint(b2*diff);
00222     if ( p3 ) result -= a3*latticenearbyint(b3*diff);
00223     return result;
00224   }

Vector Lattice::wrap_nearest_delta ( Position  pos1  )  const [inline]

Definition at line 227 of file Lattice.h.

References latticenearbyint.

Referenced by ParallelIOMgr::recvFinalClusterCoor(), and wrap_coor_int().

00228   {
00229     Vector diff = pos1 - o;
00230     Vector result0(0.,0.,0.);
00231     if ( p1 ) result0 -= a1*latticenearbyint(b1*diff);
00232     if ( p2 ) result0 -= a2*latticenearbyint(b2*diff);
00233     if ( p3 ) result0 -= a3*latticenearbyint(b3*diff);
00234     diff += result0;
00235     BigReal dist = diff.length2();
00236     Vector result(0.,0.,0.);
00237     for ( int i1=-p1; i1<=p1; ++i1 ) {
00238       for ( int i2 =-p2; i2<=p2; ++i2 ) {
00239         for ( int i3 =-p3; i3<=p3; ++i3 ) {
00240           Vector newresult = i1*a1+i2*a2+i3*a3;
00241           BigReal newdist = (diff+newresult).length2();
00242           if ( newdist < dist ) {
00243             dist = newdist;
00244             result = newresult;
00245           }
00246         }
00247       }
00248     }
00249     return result0 + result;
00250   }


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