/[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 4712 by sshaw, Wed Feb 26 04:08:41 2014 UTC revision 4722 by sshaw, Wed Mar 5 05:29:25 2014 UTC
# Line 14  Line 14 
14  *  *
15  *****************************************************************************/  *****************************************************************************/
16    
17    #include <algorithm>
18    
19  #include <ripley/Rectangle.h>  #include <ripley/Rectangle.h>
20  #include <paso/SystemMatrix.h>  #include <paso/SystemMatrix.h>
21  #include <esysUtils/esysFileWriter.h>  #include <esysUtils/esysFileWriter.h>
# Line 1521  void Rectangle::createPattern() Line 1523  void Rectangle::createPattern()
1523      RankVector neighbour;      RankVector neighbour;
1524      IndexVector offsetInShared(1,0);      IndexVector offsetInShared(1,0);
1525      IndexVector sendShared, recvShared;      IndexVector sendShared, recvShared;
1526      int numShared=0;      int numShared=0, expectedShared=0;
1527      const int x=m_mpiInfo->rank%m_NX[0];      const int x=m_mpiInfo->rank%m_NX[0];
1528      const int y=m_mpiInfo->rank/m_NX[0];      const int y=m_mpiInfo->rank/m_NX[0];
1529        if (x > 0)
1530            expectedShared += nDOF1;
1531        if (x < m_NX[0] - 1)
1532            expectedShared += nDOF1;
1533        if (y > 0)
1534            expectedShared += nDOF0;
1535        if (y < m_NX[1] - 1)
1536            expectedShared += nDOF0;
1537        if (x > 0 && y > 0) expectedShared++;
1538        if (x > 0 && y < m_NX[1] - 1) expectedShared++;
1539        if (x < m_NX[0] - 1 && y > 0) expectedShared++;
1540        if (x < m_NX[0] - 1 && y < m_NX[1] - 1) expectedShared++;
1541        
1542        vector<IndexVector> rowIndices(expectedShared);
1543        
1544      for (int i1=-1; i1<2; i1++) {      for (int i1=-1; i1<2; i1++) {
1545          for (int i0=-1; i0<2; i0++) {          for (int i0=-1; i0<2; i0++) {
1546              // skip this rank              // skip this rank
# Line 1543  void Rectangle::createPattern() Line 1560  void Rectangle::createPattern()
1560                          sendShared.push_back(firstDOF+i);                          sendShared.push_back(firstDOF+i);
1561                          recvShared.push_back(numDOF+numShared);                          recvShared.push_back(numDOF+numShared);
1562                          if (i>0)                          if (i>0)
1563                              colIndices[firstDOF+i-1].push_back(numShared);                              doublyLink(colIndices, rowIndices, firstDOF+i-1, numShared);
1564                          colIndices[firstDOF+i].push_back(numShared);                          doublyLink(colIndices, rowIndices, firstDOF+i, numShared);
1565                          if (i<nDOF0-1)                          if (i<nDOF0-1)
1566                              colIndices[firstDOF+i+1].push_back(numShared);                              doublyLink(colIndices, rowIndices, firstDOF+i+1, numShared);
1567                          m_dofMap[firstNode+i]=numDOF+numShared;                          m_dofMap[firstNode+i]=numDOF+numShared;
1568                      }                      }
1569                  } else if (i1==0) {                  } else if (i1==0) {
# Line 1558  void Rectangle::createPattern() Line 1575  void Rectangle::createPattern()
1575                          sendShared.push_back(firstDOF+i*nDOF0);                          sendShared.push_back(firstDOF+i*nDOF0);
1576                          recvShared.push_back(numDOF+numShared);                          recvShared.push_back(numDOF+numShared);
1577                          if (i>0)                          if (i>0)
1578                              colIndices[firstDOF+(i-1)*nDOF0].push_back(numShared);                              doublyLink(colIndices, rowIndices, firstDOF+(i-1)*nDOF0, numShared);
1579                          colIndices[firstDOF+i*nDOF0].push_back(numShared);                          doublyLink(colIndices, rowIndices, firstDOF+i*nDOF0, numShared);
1580                          if (i<nDOF1-1)                          if (i<nDOF1-1)
1581                              colIndices[firstDOF+(i+1)*nDOF0].push_back(numShared);                              doublyLink(colIndices, rowIndices, firstDOF+(i+1)*nDOF0, numShared);
1582                          m_dofMap[firstNode+i*m_NN[0]]=numDOF+numShared;                          m_dofMap[firstNode+i*m_NN[0]]=numDOF+numShared;
1583                      }                      }
1584                  } else {                  } else {
# Line 1571  void Rectangle::createPattern() Line 1588  void Rectangle::createPattern()
1588                      offsetInShared.push_back(offsetInShared.back()+1);                      offsetInShared.push_back(offsetInShared.back()+1);
1589                      sendShared.push_back(dof);                      sendShared.push_back(dof);
1590                      recvShared.push_back(numDOF+numShared);                      recvShared.push_back(numDOF+numShared);
1591                      colIndices[dof].push_back(numShared);                      doublyLink(colIndices, rowIndices, dof, numShared);
1592                      m_dofMap[node]=numDOF+numShared;                      m_dofMap[node]=numDOF+numShared;
1593                      ++numShared;                      ++numShared;
1594                  }                  }
1595              }              }
1596          }          }
1597      }      }
1598            
1599    #pragma omp parallel for
1600        for (int i = 0; i < numShared; i++) {
1601            std::sort(rowIndices[i].begin(), rowIndices[i].end());
1602        }
1603        
1604      // create connector      // create connector
1605      Paso_SharedComponents *snd_shcomp = Paso_SharedComponents_alloc(      Paso_SharedComponents *snd_shcomp = Paso_SharedComponents_alloc(
1606              numDOF, neighbour.size(), &neighbour[0], &sendShared[0],              numDOF, neighbour.size(), &neighbour[0], &sendShared[0],
# Line 1593  void Rectangle::createPattern() Line 1615  void Rectangle::createPattern()
1615      // create main and couple blocks      // create main and couple blocks
1616      Paso_Pattern *mainPattern = createMainPattern();      Paso_Pattern *mainPattern = createMainPattern();
1617      Paso_Pattern *colPattern, *rowPattern;      Paso_Pattern *colPattern, *rowPattern;
1618      createCouplePatterns(colIndices, numShared, &colPattern, &rowPattern);      createCouplePatterns(colIndices, rowIndices, numShared, &colPattern, &rowPattern);
1619    
1620      // allocate paso distribution      // allocate paso distribution
1621      Paso_Distribution* distribution = Paso_Distribution_alloc(m_mpiInfo,      Paso_Distribution* distribution = Paso_Distribution_alloc(m_mpiInfo,

Legend:
Removed from v.4712  
changed lines
  Added in v.4722

  ViewVC Help
Powered by ViewVC 1.1.26