/[escript]/trunk/ripley/src/Rectangle.cpp
ViewVC logotype

Diff of /trunk/ripley/src/Rectangle.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 4657 by jfenwick, Thu Feb 6 06:12:20 2014 UTC revision 4660 by sshaw, Fri Feb 7 03:08:49 2014 UTC
# Line 2235  escript::Data Rectangle::randomFill(long Line 2235  escript::Data Rectangle::randomFill(long
2235  int Rectangle::findNode(const double *coords) const {  int Rectangle::findNode(const double *coords) const {
2236      const int NOT_MINE = -1;      const int NOT_MINE = -1;
2237      //is the found element even owned by this rank      //is the found element even owned by this rank
2238        // (inside owned or shared elements but will map to an owned element)
2239      for (int dim = 0; dim < m_numDim; dim++) {      for (int dim = 0; dim < m_numDim; dim++) {
2240          if (m_origin[dim] + m_offset[dim] > coords[dim]  || m_origin[dim]          double min = m_origin[dim] + m_offset[dim]* m_dx[dim]
2241                  + m_offset[dim] + m_dx[dim]*m_ownNE[dim] < coords[dim]) {                  - m_dx[dim]/2.; //allows for point outside mapping onto node
2242            double max = m_origin[dim] + (m_offset[dim] + m_NE[dim])*m_dx[dim]
2243                    + m_dx[dim]/2.;
2244            if (min > coords[dim] || max < coords[dim]) {
2245              return NOT_MINE;              return NOT_MINE;
2246          }          }
2247      }      }
# Line 2254  int Rectangle::findNode(const double *co Line 2258  int Rectangle::findNode(const double *co
2258          minDist += m_dx[dim]*m_dx[dim];          minDist += m_dx[dim]*m_dx[dim];
2259      }      }
2260      //find the closest node      //find the closest node
2261      for (int dx = 0; dx < 2; dx++) {      for (int dx = 0; dx < 1; dx++) {
2262          double xdist = (x - (ex + dx)*m_dx[0]);          double xdist = (x - (ex + dx)*m_dx[0]);
2263          for (int dy = 0; dy < 2; dy++) {          for (int dy = 0; dy < 1; dy++) {
2264              double ydist = (y - (ey + dy)*m_dx[1]);              double ydist = (y - (ey + dy)*m_dx[1]);
2265              double total = xdist*xdist + ydist*ydist;              double total = xdist*xdist + ydist*ydist;
2266              if (total < minDist) {              if (total < minDist) {
2267                  closest = INDEX2(ex+dx, ey+dy, m_NE[0] + 1);                  closest = INDEX2(ex+dx-m_offset[0], ey+dy-m_offset[1], m_NE[0] + 1);
2268                  minDist = total;                  minDist = total;
2269              }              }
2270          }          }
2271      }      }
2272        //if this happens, we've let a dirac point slip through, which is awful
2273        if (closest == NOT_MINE) {
2274            throw RipleyException("Unable to map appropriate dirac point to a node,"
2275                    " implementation problem in Rectangle::findNode()");
2276        }
2277      return closest;      return closest;
2278  }  }
2279    

Legend:
Removed from v.4657  
changed lines
  Added in v.4660

  ViewVC Help
Powered by ViewVC 1.1.26