/[escript]/branches/diaplayground/ripley/src/Brick.cpp
ViewVC logotype

Diff of /branches/diaplayground/ripley/src/Brick.cpp

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

revision 4816 by caltinay, Fri Mar 28 06:16:02 2014 UTC revision 4827 by sshaw, Wed Apr 2 07:00:15 2014 UTC
# Line 203  Brick::Brick(int n0, int n1, int n2, dou Line 203  Brick::Brick(int n0, int n1, int n2, dou
203    
204  Brick::~Brick()  Brick::~Brick()
205  {  {
     paso::SystemMatrixPattern_free(m_pattern);  
     paso::Connector_free(m_connector);  
206      delete assembler;      delete assembler;
207  }  }
208    
# Line 2050  void Brick::nodesToDOF(escript::Data& ou Line 2048  void Brick::nodesToDOF(escript::Data& ou
2048  void Brick::dofToNodes(escript::Data& out, const escript::Data& in) const  void Brick::dofToNodes(escript::Data& out, const escript::Data& in) const
2049  {  {
2050      const dim_t numComp = in.getDataPointSize();      const dim_t numComp = in.getDataPointSize();
2051      paso::Coupler* coupler = paso::Coupler_alloc(m_connector, numComp);      paso::Coupler_ptr coupler(new paso::Coupler(m_connector, numComp));
2052      // expand data object if necessary to be able to grab the whole data      // expand data object if necessary to be able to grab the whole data
2053      const_cast<escript::Data*>(&in)->expand();      const_cast<escript::Data*>(&in)->expand();
2054      paso::Coupler_startCollect(coupler, in.getSampleDataRO(0));      coupler->startCollect(in.getSampleDataRO(0));
2055    
2056      const dim_t numDOF = getNumDOF();      const dim_t numDOF = getNumDOF();
2057      out.requireWrite();      out.requireWrite();
2058      const double* buffer = paso::Coupler_finishCollect(coupler);      const double* buffer = coupler->finishCollect();
2059    
2060  #pragma omp parallel for  #pragma omp parallel for
2061      for (index_t i=0; i<getNumNodes(); i++) {      for (index_t i=0; i<getNumNodes(); i++) {
# Line 2066  void Brick::dofToNodes(escript::Data& ou Line 2064  void Brick::dofToNodes(escript::Data& ou
2064                  : &buffer[(m_dofMap[i]-numDOF)*numComp]);                  : &buffer[(m_dofMap[i]-numDOF)*numComp]);
2065          copy(src, src+numComp, out.getSampleDataRW(i));          copy(src, src+numComp, out.getSampleDataRW(i));
2066      }      }
     paso::Coupler_free(coupler);  
2067  }  }
2068    
2069  //private  //private
# Line 2569  void Brick::createPattern() Line 2566  void Brick::createPattern()
2566      paso::SharedComponents_ptr rcv_shcomp(new paso::SharedComponents(      paso::SharedComponents_ptr rcv_shcomp(new paso::SharedComponents(
2567              numDOF, neighbour.size(), &neighbour[0], &recvShared[0],              numDOF, neighbour.size(), &neighbour[0], &recvShared[0],
2568              &offsetInShared[0], 1, 0, m_mpiInfo));              &offsetInShared[0], 1, 0, m_mpiInfo));
2569      m_connector = paso::Connector_alloc(snd_shcomp, rcv_shcomp);      m_connector.reset(new paso::Connector(snd_shcomp, rcv_shcomp));
2570    
2571      // create main and couple blocks      // create main and couple blocks
2572      paso::Pattern *mainPattern = createMainPattern();      paso::Pattern_ptr mainPattern = createMainPattern();
2573      paso::Pattern *colPattern, *rowPattern;      paso::Pattern_ptr colPattern, rowPattern;
2574      createCouplePatterns(colIndices, rowIndices, numShared, &colPattern, &rowPattern);      createCouplePatterns(colIndices, rowIndices, numShared, colPattern, rowPattern);
2575    
2576      // allocate paso distribution      // allocate paso distribution
2577      paso::Distribution_ptr distribution(new paso::Distribution(m_mpiInfo,      paso::Distribution_ptr distribution(new paso::Distribution(m_mpiInfo,
2578              const_cast<index_t*>(&m_nodeDistribution[0]), 1, 0));              const_cast<index_t*>(&m_nodeDistribution[0]), 1, 0));
2579    
2580      // finally create the system matrix      // finally create the system matrix
2581      m_pattern = new paso::SystemMatrixPattern(MATRIX_FORMAT_DEFAULT,      m_pattern.reset(new paso::SystemMatrixPattern(MATRIX_FORMAT_DEFAULT,
2582              distribution, distribution, mainPattern, colPattern, rowPattern,              distribution, distribution, mainPattern, colPattern, rowPattern,
2583              m_connector, m_connector);              m_connector, m_connector));
2584    
2585      // useful debug output      // useful debug output
2586      /*      /*
# Line 2642  void Brick::createPattern() Line 2639  void Brick::createPattern()
2639          cout << "index[" << i << "]=" << rowPattern->index[i] << endl;          cout << "index[" << i << "]=" << rowPattern->index[i] << endl;
2640      }      }
2641      */      */
   
     paso::Pattern_free(mainPattern);  
     paso::Pattern_free(colPattern);  
     paso::Pattern_free(rowPattern);  
2642  }  }
2643    
2644  //private  //private
# Line 3333  int Brick::findNode(const double *coords Line 3326  int Brick::findNode(const double *coords
3326      double x = coords[0] - m_origin[0];      double x = coords[0] - m_origin[0];
3327      double y = coords[1] - m_origin[1];      double y = coords[1] - m_origin[1];
3328      double z = coords[2] - m_origin[2];      double z = coords[2] - m_origin[2];
3329        
3330        //check if the point is even inside the domain
3331        if (x < 0 || y < 0 || z < 0
3332                || x > m_length[0] || y > m_length[1] || z > m_length[2])
3333            return NOT_MINE;
3334            
3335      // distance in elements      // distance in elements
3336      int ex = (int) floor(x / m_dx[0]);      int ex = (int) floor(x / m_dx[0]);
3337      int ey = (int) floor(y / m_dx[1]);      int ey = (int) floor(y / m_dx[1]);

Legend:
Removed from v.4816  
changed lines
  Added in v.4827

  ViewVC Help
Powered by ViewVC 1.1.26