Changeset aec775


Ignore:
Timestamp:
Oct 17, 2009, 7:46:28 PM (16 years ago)
Author:
Frederik Heber <heber@…>
Children:
b0ee98
Parents:
bee48d
Message:

Extended class LinkedCell to handle a relative offset to current cell.

Location:
molecuilder/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • molecuilder/src/linkedcell.cpp

    rbee48d raec775  
    202202};
    203203
     204/** Checks whether LinkedCell::n[] plus relative offset is each within [0,N[]].
     205 * \param relative[NDIM] relative offset to current cell
     206 * \return if all in intervals - true, else -false
     207 */
     208bool LinkedCell::CheckBounds(int relative[NDIM])
     209{
     210  bool status = true;
     211  for(int i=0;i<NDIM;i++)
     212    status = status && ((n[i]+relative[i] >=0) && (n[i]+relative[i] < N[i]));
     213  if (!status)
     214  cerr << "ERROR: indices are out of bounds!" << endl;
     215  return status;
     216};
     217
    204218
    205219/** Returns a pointer to the current cell.
     
    210224  if (CheckBounds()) {
    211225    index = n[0] * N[1] * N[2] + n[1] * N[2] + n[2];
     226    return (&(LC[index]));
     227  } else {
     228    return NULL;
     229  }
     230};
     231
     232/** Returns a pointer to the current cell.
     233 * \param relative[NDIM] offset for each axis with respect to the current cell LinkedCell::n[NDIM]
     234 * \return LinkedAtoms pointer to current cell, NULL if LinkedCell::n[]+relative[] are out of bounds.
     235 */
     236LinkedNodes* LinkedCell::GetRelativeToCurrentCell(int relative[NDIM])
     237{
     238  if (CheckBounds(relative)) {
     239    index = (n[0]+relative[0]) * N[1] * N[2] + (n[1]+relative[1]) * N[2] + (n[2]+relative[2]);
    212240    return (&(LC[index]));
    213241  } else {
  • molecuilder/src/linkedcell.hpp

    rbee48d raec775  
    5454    ~LinkedCell();
    5555    LinkedNodes* GetCurrentCell();
     56    LinkedNodes* GetRelativeToCurrentCell(int relative[NDIM]);
    5657    bool SetIndexToNode(const TesselPoint *Walker);
    5758    bool SetIndexToVector(const Vector *x);
    5859    bool CheckBounds();
     60    bool CheckBounds(int relative[NDIM]);
    5961    void GetNeighbourBounds(int lower[NDIM], int upper[NDIM]);
    6062
Note: See TracChangeset for help on using the changeset viewer.