/[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 4703 by jfenwick, Fri Feb 21 00:55:31 2014 UTC revision 4705 by jfenwick, Fri Feb 21 02:36:15 2014 UTC
# Line 1883  namespace Line 1883  namespace
1883              for (int x=-r;x<=r;++x)              for (int x=-r;x<=r;++x)
1884              {                      {        
1885                  arr[(x+r)+(y+r)*(r*2+1)]=common*exp(-(x*x+y*y)/(2*sigma*sigma));                  arr[(x+r)+(y+r)*(r*2+1)]=common*exp(-(x*x+y*y)/(2*sigma*sigma));
 // cout << (x+y*(r*2+1)) << " " << arr[(x+r)+(y+r)*(r*2+1)] << endl;  
 cerr << "arr[" << (x+r)+(y+r)*(r*2+1) << "] = " << arr[(x+r)+(y+r)*(r*2+1)]<< " ";        
1886                  total+=arr[(x+r)+(y+r)*(r*2+1)];                  total+=arr[(x+r)+(y+r)*(r*2+1)];
1887              }              }
 cerr << endl;              
1888          }          }
 cerr << "Total is " << total << endl;          
1889          double invtotal=1/total;          double invtotal=1/total;
 cerr << "Inv total is "        << invtotal << endl;  
1890          for (size_t p=0;p<(radius*2+1)*(radius*2+1);++p)          for (size_t p=0;p<(radius*2+1)*(radius*2+1);++p)
1891          {          {
1892              arr[p]*=invtotal;              arr[p]*=invtotal;
 //cout << p << "->" << arr[p] << endl;        
1893          }          }
1894          return arr;          return arr;
1895      }      }
# Line 2060  escript::Data Rectangle::randomFillWorke Line 2054  escript::Data Rectangle::randomFillWorke
2054      dim_t Y=m_mpiInfo->rank%(m_NX[0]*m_NX[1])/m_NX[0];      dim_t Y=m_mpiInfo->rank%(m_NX[0]*m_NX[1])/m_NX[0];
2055  #endif        #endif      
2056    
2057        /*    
2058      // if we wanted to test a repeating pattern      // if we wanted to test a repeating pattern
2059      size_t basex=0;      size_t basex=0;
2060      size_t basey=0;      size_t basey=0;
# Line 2070  escript::Data Rectangle::randomFillWorke Line 2064  escript::Data Rectangle::randomFillWorke
2064  #endif  #endif
2065                    
2066      esysUtils::patternFillArray2D(ext[0], ext[1], src, 4, basex, basey, numvals);      esysUtils::patternFillArray2D(ext[0], ext[1], src, 4, basex, basey, numvals);
2067    */
2068    
 cout << "Initial pattern\n";      
 for (int p=0;p<ext[1];++p)  
 {  
     for (int q=0;q<ext[0];++q)  
     {  
     cout << '(';  
     for (int d=0;d<numvals;++d)  
     {  
         cout << src[(q+p*ext[0])*numvals+d] << " ";  
     }  
     cout << ") ";  
     }  
     cout << endl;  
 }  
       
2069            
2070  #ifdef ESYS_MPI    #ifdef ESYS_MPI  
2071            
# Line 2095  for (int p=0;p<ext[1];++p) Line 2075  for (int p=0;p<ext[1];++p)
2075            
2076      size_t xmidlen=ext[0]-2*inset;      // how wide is the x-dimension between the two insets      size_t xmidlen=ext[0]-2*inset;      // how wide is the x-dimension between the two insets
2077      size_t ymidlen=ext[1]-2*inset;            size_t ymidlen=ext[1]-2*inset;      
   
       
 cerr << "xmidlen=" << xmidlen << " ymidlen=" << ymidlen << endl;    
       
2078            
2079      Block2 block(ext[0], ext[1], inset, xmidlen, ymidlen, numvals);      Block2 block(ext[0], ext[1], inset, xmidlen, ymidlen, numvals);
2080    
# Line 2113  cerr << "xmidlen=" << xmidlen << " ymidl Line 2089  cerr << "xmidlen=" << xmidlen << " ymidl
2089      grid.generateOutNeighbours(X, Y, outcoms);      grid.generateOutNeighbours(X, Y, outcoms);
2090            
2091      block.copyAllToBuffer(src);        block.copyAllToBuffer(src);  
   
 // for (int i=0;i<9;++i)  
 // {  
 //     if (i!=4)  
 //     {  
 //       for (int j=0;j<block.getBuffSize(i);++j)  
 //       {  
 //    block.getOutBuffer(i)[j]=100+i;  
 //       }  
 //     }  
 // }  
       
       
 for (size_t j=0;j<incoms.size();++j)  
 {  
     message& m=incoms[j];  
 for (int i=0;i<block.getBuffSize(m.srcbuffid);++i)  
 {  
     block.getInBuffer(m.srcbuffid)[i]=-42;  
 }    
 }  
           
       
       
2092            
2093      int comserr=0;          int comserr=0;    
2094      for (size_t i=0;i<incoms.size();++i)      for (size_t i=0;i<incoms.size();++i)
# Line 2150  for (int i=0;i<block.getBuffSize(m.srcbu Line 2102  for (int i=0;i<block.getBuffSize(m.srcbu
2102      for (size_t i=0;i<outcoms.size();++i)      for (size_t i=0;i<outcoms.size();++i)
2103      {      {
2104          message& m=outcoms[i];          message& m=outcoms[i];
  cout << "Sending " <<  (int)m.srcbuffid << " with tag " << m.tag << endl;  
2105          comserr|=MPI_Isend(block.getOutBuffer(m.srcbuffid), block.getBuffSize(m.srcbuffid) , MPI_DOUBLE, m.destID, m.tag, m_mpiInfo->comm, reqs+(rused++));          comserr|=MPI_Isend(block.getOutBuffer(m.srcbuffid), block.getBuffSize(m.srcbuffid) , MPI_DOUBLE, m.destID, m.tag, m_mpiInfo->comm, reqs+(rused++));
 for (int i=0;i<block.getBuffSize(m.srcbuffid);++i)  
 {  
     cout << block.getOutBuffer(m.srcbuffid)[i] << " ";  
 }  
 cout << endl;    
2106      }          }    
2107            
2108      if (!comserr)      if (!comserr)
2109      {          {    
2110          comserr=MPI_Waitall(rused, reqs, stats);          comserr=MPI_Waitall(rused, reqs, stats);    
       
       
     for (size_t i=0;i<incoms.size();++i)  
     {  
         message& m=incoms[i];        
 cout << "Gettinging " <<    (int)m.destbuffid << " with tag " << m.tag << endl;  
 for (int i=0;i<block.getBuffSize(m.destbuffid);++i)  
 {  
     cout << block.getInBuffer(m.destbuffid)[i] << " ";  
 }  
 cout << endl;  
       
     }    
       
2111      }      }
2112    
2113      if (comserr)      if (comserr)
# Line 2185  cout << endl; Line 2117  cout << endl;
2117          // however, we have no reason to believe coms work at this point anyway          // however, we have no reason to believe coms work at this point anyway
2118          throw RipleyException("Error in coms for randomFill");                throw RipleyException("Error in coms for randomFill");      
2119      }      }
 /*  
 for (int i=0;i<9;++i)  
 {  
     if (i!=4)  
     {  
       for (int j=0;j<block.getBuffSize(i);++j)  
       {  
       block.getInBuffer(i)[j]=200+i;  
       }  
     }  
 }  */    
       
2120            
2121      block.copyUsedFromBuffer(src);          block.copyUsedFromBuffer(src);    
2122            

Legend:
Removed from v.4703  
changed lines
  Added in v.4705

  ViewVC Help
Powered by ViewVC 1.1.26