/[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 4696 by jfenwick, Wed Feb 19 07:29:50 2014 UTC revision 4703 by jfenwick, Fri Feb 21 00:55:31 2014 UTC
# Line 1884  namespace Line 1884  namespace
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));
1886  // cout << (x+y*(r*2+1)) << " " << arr[(x+r)+(y+r)*(r*2+1)] << endl;  // cout << (x+y*(r*2+1)) << " " << arr[(x+r)+(y+r)*(r*2+1)] << endl;
1887    cerr << "arr[" << (x+r)+(y+r)*(r*2+1) << "] = " << arr[(x+r)+(y+r)*(r*2+1)]<< " ";      
1888                  total+=arr[(x+r)+(y+r)*(r*2+1)];                  total+=arr[(x+r)+(y+r)*(r*2+1)];
1889              }              }
1890    cerr << endl;            
1891          }          }
1892    cerr << "Total is " << total << endl;        
1893          double invtotal=1/total;          double invtotal=1/total;
1894  //cout << "Inv total is "        << invtotal << endl;  cerr << "Inv total is "        << invtotal << endl;
1895          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)
1896          {          {
1897              arr[p]*=invtotal;              arr[p]*=invtotal;
# Line 2057  escript::Data Rectangle::randomFillWorke Line 2060  escript::Data Rectangle::randomFillWorke
2060      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];
2061  #endif        #endif      
2062    
2063  /*          
2064      // if we wanted to test a repeating pattern      // if we wanted to test a repeating pattern
2065      size_t basex=0;      size_t basex=0;
2066      size_t basey=0;      size_t basey=0;
# Line 2067  escript::Data Rectangle::randomFillWorke Line 2070  escript::Data Rectangle::randomFillWorke
2070  #endif  #endif
2071                    
2072      esysUtils::patternFillArray2D(ext[0], ext[1], src, 4, basex, basey, numvals);      esysUtils::patternFillArray2D(ext[0], ext[1], src, 4, basex, basey, numvals);
2073  */      
2074    cout << "Initial pattern\n";    
2075    for (int p=0;p<ext[1];++p)
2076    {
2077        for (int q=0;q<ext[0];++q)
2078        {
2079        cout << '(';
2080        for (int d=0;d<numvals;++d)
2081        {
2082            cout << src[(q+p*ext[0])*numvals+d] << " ";
2083        }
2084        cout << ") ";
2085        }
2086        cout << endl;
2087    }
2088        
2089            
     
2090  #ifdef ESYS_MPI    #ifdef ESYS_MPI  
2091            
2092      BlockGrid2 grid(m_NX[0]-1, m_NX[1]-1);      BlockGrid2 grid(m_NX[0]-1, m_NX[1]-1);
# Line 2078  escript::Data Rectangle::randomFillWorke Line 2095  escript::Data Rectangle::randomFillWorke
2095            
2096      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
2097      size_t ymidlen=ext[1]-2*inset;            size_t ymidlen=ext[1]-2*inset;      
2098    
2099        
2100    cerr << "xmidlen=" << xmidlen << " ymidlen=" << ymidlen << endl;  
2101        
2102            
2103      Block2 block(ext[0], ext[1], inset, xmidlen, ymidlen, numvals);      Block2 block(ext[0], ext[1], inset, xmidlen, ymidlen, numvals);
2104    
# Line 2105  escript::Data Rectangle::randomFillWorke Line 2126  escript::Data Rectangle::randomFillWorke
2126  // }  // }
2127            
2128            
2129    for (size_t j=0;j<incoms.size();++j)
2130    {
2131        message& m=incoms[j];
2132    for (int i=0;i<block.getBuffSize(m.srcbuffid);++i)
2133    {
2134        block.getInBuffer(m.srcbuffid)[i]=-42;
2135    }  
2136    }
2137            
2138        
2139        
2140        
2141      int comserr=0;          int comserr=0;    
2142      for (size_t i=0;i<incoms.size();++i)      for (size_t i=0;i<incoms.size();++i)
2143      {      {
# Line 2117  escript::Data Rectangle::randomFillWorke Line 2150  escript::Data Rectangle::randomFillWorke
2150      for (size_t i=0;i<outcoms.size();++i)      for (size_t i=0;i<outcoms.size();++i)
2151      {      {
2152          message& m=outcoms[i];          message& m=outcoms[i];
2153  // cout << "Sending " <<    (int)m.srcbuffid << " with tag " << m.tag << endl;   cout << "Sending " <<  (int)m.srcbuffid << " with tag " << m.tag << endl;
2154          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++));
2155  // for (int i=0;i<block.getBuffSize(m.srcbuffid);++i)  for (int i=0;i<block.getBuffSize(m.srcbuffid);++i)
2156  // {  {
2157  //     cout << block.getOutBuffer(m.srcbuffid)[i] << " ";      cout << block.getOutBuffer(m.srcbuffid)[i] << " ";
2158  // }  }
2159  // cout << endl;      cout << endl;  
2160      }          }    
2161            
2162      if (!comserr)      if (!comserr)
# Line 2131  escript::Data Rectangle::randomFillWorke Line 2164  escript::Data Rectangle::randomFillWorke
2164          comserr=MPI_Waitall(rused, reqs, stats);          comserr=MPI_Waitall(rused, reqs, stats);
2165            
2166            
2167  //     for (size_t i=0;i<incoms.size();++i)      for (size_t i=0;i<incoms.size();++i)
2168  //     {      {
2169  //         message& m=incoms[i];                message& m=incoms[i];      
2170  // cout << "Gettinging " <<     (int)m.destbuffid << " with tag " << m.tag << endl;  cout << "Gettinging " <<    (int)m.destbuffid << " with tag " << m.tag << endl;
2171  // for (int i=0;i<block.getBuffSize(m.destbuffid);++i)  for (int i=0;i<block.getBuffSize(m.destbuffid);++i)
2172  // {  {
2173  //     cout << block.getInBuffer(m.destbuffid)[i] << " ";      cout << block.getInBuffer(m.destbuffid)[i] << " ";
2174  // }  }
2175  // cout << endl;  cout << endl;
2176  //        
2177  //     }          }  
2178            
2179      }      }
2180    
# Line 2152  escript::Data Rectangle::randomFillWorke Line 2185  escript::Data Rectangle::randomFillWorke
2185          // 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
2186          throw RipleyException("Error in coms for randomFill");                throw RipleyException("Error in coms for randomFill");      
2187      }      }
2188    /*
2189    for (int i=0;i<9;++i)
2190    {
2191        if (i!=4)
2192        {
2193          for (int j=0;j<block.getBuffSize(i);++j)
2194          {
2195          block.getInBuffer(i)[j]=200+i;
2196          }
2197        }
2198    }  */  
2199        
2200            
2201      block.copyUsedFromBuffer(src);          block.copyUsedFromBuffer(src);    
2202            

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

  ViewVC Help
Powered by ViewVC 1.1.26