Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.51 KB | None | 0 0
  1. template <typename T>
  2. bool feMatrix<T>::getBoundaryNodeIndices(ot::DA* da, std::vector<unsigned int> &indices, std::vector<double>& coords, std::function<double(double,double,double, int)> f) {
  3.   // loop over elements, writable? and maintain list of indices and coords that are close enough.
  4.   std::map<unsigned int, Point> bdy;
  5.  
  6.   unsigned int maxD = da->getMaxDepth();
  7.   unsigned int lev;
  8.   double hx, hy, hz, dist, half;
  9.   Point pt;
  10.  
  11.   double xFac = m_dLx/((double)(1<<(maxD-1)));
  12.   double yFac = m_dLy/((double)(1<<(maxD-1)));
  13.   double zFac = m_dLz/((double)(1<<(maxD-1)));
  14.   double xx[8], yy[8], zz[8];
  15.   unsigned int idx[8];
  16.  
  17.   for ( da->init<ot::DA_FLAGS::WRITABLE>(); da->curr() < da->end<ot::DA_FLAGS::WRITABLE>(); da->next<ot::DA_FLAGS::WRITABLE>() ) {
  18.     // set the value
  19.     lev = da->getLevel(da->curr());
  20.     hx = xFac * (1 << (maxD - lev));
  21.     hy = yFac * (1 << (maxD - lev));
  22.     hz = zFac * (1 << (maxD - lev));
  23.  
  24.     half = hx;
  25.     if (half > hy)
  26.     half = hy;
  27.     if (half > hz)
  28.     half = hz;
  29.  
  30.     half = half * 0.5;
  31.  
  32.     pt = da->getCurrentOffset();
  33.  
  34.     //! get the correct coordinates of the nodes ...
  35.     unsigned char hangingMask = da->getHangingNodeIndex(da->curr());
  36.  
  37.     xx[0] = pt.x() * xFac;
  38.     yy[0] = pt.y() * yFac;
  39.     zz[0] = pt.z() * zFac;
  40.     xx[1] = pt.x() * xFac + hx;
  41.     yy[1] = pt.y() * yFac;
  42.     zz[1] = pt.z() * zFac;
  43.     xx[2] = pt.x() * xFac;
  44.     yy[2] = pt.y() * yFac + hy;
  45.     zz[2] = pt.z() * zFac;
  46.     xx[3] = pt.x() * xFac + hx;
  47.     yy[3] = pt.y() * yFac + hy;
  48.     zz[3] = pt.z() * zFac;
  49.  
  50.     xx[4] = pt.x() * xFac;
  51.     yy[4] = pt.y() * yFac;
  52.     zz[4] = pt.z() * zFac + hz;
  53.     xx[5] = pt.x() * xFac + hx;
  54.     yy[5] = pt.y() * yFac;
  55.     zz[5] = pt.z() * zFac + hz;
  56.     xx[6] = pt.x() * xFac;
  57.     yy[6] = pt.y() * yFac + hy;
  58.     zz[6] = pt.z() * zFac + hz;
  59.     xx[7] = pt.x() * xFac + hx;
  60.     yy[7] = pt.y() * yFac + hy;
  61.     zz[7] = pt.z() * zFac + hz;
  62.  
  63.     da->getNodeIndices(idx);
  64.     for (int i = 0; i < 8; ++i) {
  65.       if (!(hangingMask & (1u << i))) {
  66.     for (int j = 1; j <= 6; j++) {
  67.           dist = f(xx[i], yy[i], zz[i], j);
  68.           if (dist < 1e-6) {
  69.             bdy[idx[i]] = Point(xx[i], yy[i], zz[i]);
  70.         //std::cout<<"idx: "<<idx[i]<<std::endl;
  71.       }
  72.         }
  73.       }
  74.     }
  75.   } // loop over elements
  76.  
  77.   // extract the indices and coords from map
  78.   for(auto const& i: bdy) {
  79.     indices.push_back(i.first);
  80.     coords.push_back(i.second.x());
  81.     coords.push_back(i.second.y());
  82.     coords.push_back(i.second.z());
  83.   }
  84. } // getBdy
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement