/[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 4801 by caltinay, Wed Mar 26 03:26:58 2014 UTC revision 4851 by sshaw, Wed Apr 9 03:30:36 2014 UTC
# Line 63  Brick::Brick(int n0, int n1, int n2, dou Line 63  Brick::Brick(int n0, int n1, int n2, dou
63               const simap_t& tagnamestonums) :               const simap_t& tagnamestonums) :
64      RipleyDomain(3)      RipleyDomain(3)
65  {  {
66        if (n0 <= 0 || n1 <= 0 || n2 <= 0)
67            throw RipleyException("Number of elements in each spatial dimension "
68                    "must be positive");
69    
70      // ignore subdivision parameters for serial run      // ignore subdivision parameters for serial run
71      if (m_mpiInfo->size == 1) {      if (m_mpiInfo->size == 1) {
72          d0=1;          d0=1;
# Line 203  Brick::Brick(int n0, int n1, int n2, dou Line 207  Brick::Brick(int n0, int n1, int n2, dou
207    
208  Brick::~Brick()  Brick::~Brick()
209  {  {
     paso::SystemMatrixPattern_free(m_pattern);  
     paso::Connector_free(m_connector);  
210      delete assembler;      delete assembler;
211  }  }
212    
# Line 2050  void Brick::nodesToDOF(escript::Data& ou Line 2052  void Brick::nodesToDOF(escript::Data& ou
2052  void Brick::dofToNodes(escript::Data& out, const escript::Data& in) const  void Brick::dofToNodes(escript::Data& out, const escript::Data& in) const
2053  {  {
2054      const dim_t numComp = in.getDataPointSize();      const dim_t numComp = in.getDataPointSize();
2055      paso::Coupler* coupler = paso::Coupler_alloc(m_connector, numComp);      paso::Coupler_ptr coupler(new paso::Coupler(m_connector, numComp));
2056      // 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
2057      const_cast<escript::Data*>(&in)->expand();      const_cast<escript::Data*>(&in)->expand();
2058      paso::Coupler_startCollect(coupler, in.getSampleDataRO(0));      coupler->startCollect(in.getSampleDataRO(0));
2059    
2060      const dim_t numDOF = getNumDOF();      const dim_t numDOF = getNumDOF();
2061      out.requireWrite();      out.requireWrite();
2062      const double* buffer = paso::Coupler_finishCollect(coupler);      const double* buffer = coupler->finishCollect();
2063    
2064  #pragma omp parallel for  #pragma omp parallel for
2065      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 2068  void Brick::dofToNodes(escript::Data& ou
2068                  : &buffer[(m_dofMap[i]-numDOF)*numComp]);                  : &buffer[(m_dofMap[i]-numDOF)*numComp]);
2069          copy(src, src+numComp, out.getSampleDataRW(i));          copy(src, src+numComp, out.getSampleDataRW(i));
2070      }      }
     paso::Coupler_free(coupler);  
2071  }  }
2072    
2073  //private  //private
# Line 2563  void Brick::createPattern() Line 2564  void Brick::createPattern()
2564      }      }
2565    
2566      // create connector      // create connector
2567      Paso_SharedComponents *snd_shcomp = Paso_SharedComponents_alloc(      paso::SharedComponents_ptr snd_shcomp(new paso::SharedComponents(
2568              numDOF, neighbour.size(), &neighbour[0], &sendShared[0],              numDOF, neighbour.size(), &neighbour[0], &sendShared[0],
2569              &offsetInShared[0], 1, 0, m_mpiInfo);              &offsetInShared[0], 1, 0, m_mpiInfo));
2570      Paso_SharedComponents *rcv_shcomp = Paso_SharedComponents_alloc(      paso::SharedComponents_ptr rcv_shcomp(new paso::SharedComponents(
2571              numDOF, neighbour.size(), &neighbour[0], &recvShared[0],              numDOF, neighbour.size(), &neighbour[0], &recvShared[0],
2572              &offsetInShared[0], 1, 0, m_mpiInfo);              &offsetInShared[0], 1, 0, m_mpiInfo));
2573      m_connector = paso::Connector_alloc(snd_shcomp, rcv_shcomp);      m_connector.reset(new paso::Connector(snd_shcomp, rcv_shcomp));
     Paso_SharedComponents_free(snd_shcomp);  
     Paso_SharedComponents_free(rcv_shcomp);  
2574    
2575      // create main and couple blocks      // create main and couple blocks
2576      Paso_Pattern *mainPattern = createMainPattern();      paso::Pattern_ptr mainPattern = createMainPattern();
2577      Paso_Pattern *colPattern, *rowPattern;      paso::Pattern_ptr colPattern, rowPattern;
2578      createCouplePatterns(colIndices, rowIndices, numShared, &colPattern, &rowPattern);      createCouplePatterns(colIndices, rowIndices, numShared, colPattern, rowPattern);
2579    
2580      // allocate paso distribution      // allocate paso distribution
2581      Paso_Distribution* distribution = Paso_Distribution_alloc(m_mpiInfo,      paso::Distribution_ptr distribution(new paso::Distribution(m_mpiInfo,
2582              const_cast<index_t*>(&m_nodeDistribution[0]), 1, 0);              const_cast<index_t*>(&m_nodeDistribution[0]), 1, 0));
2583    
2584      // finally create the system matrix      // finally create the system matrix
2585      m_pattern = new paso::SystemMatrixPattern(MATRIX_FORMAT_DEFAULT,      m_pattern.reset(new paso::SystemMatrixPattern(MATRIX_FORMAT_DEFAULT,
2586              distribution, distribution, mainPattern, colPattern, rowPattern,              distribution, distribution, mainPattern, colPattern, rowPattern,
2587              m_connector, m_connector);              m_connector, m_connector));
   
     Paso_Distribution_free(distribution);  
2588    
2589      // useful debug output      // useful debug output
2590      /*      /*
# Line 2646  void Brick::createPattern() Line 2643  void Brick::createPattern()
2643          cout << "index[" << i << "]=" << rowPattern->index[i] << endl;          cout << "index[" << i << "]=" << rowPattern->index[i] << endl;
2644      }      }
2645      */      */
   
     Paso_Pattern_free(mainPattern);  
     Paso_Pattern_free(colPattern);  
     Paso_Pattern_free(rowPattern);  
2646  }  }
2647    
2648  //private  //private
2649  void Brick::addToMatrixAndRHS(Paso_SystemMatrix* S, escript::Data& F,  void Brick::addToMatrixAndRHS(paso::SystemMatrix_ptr S, escript::Data& F,
2650           const vector<double>& EM_S, const vector<double>& EM_F, bool addS,           const vector<double>& EM_S, const vector<double>& EM_F, bool addS,
2651           bool addF, index_t firstNode, dim_t nEq, dim_t nComp) const           bool addF, index_t firstNode, dim_t nEq, dim_t nComp) const
2652  {  {
# Line 3337  int Brick::findNode(const double *coords Line 3330  int Brick::findNode(const double *coords
3330      double x = coords[0] - m_origin[0];      double x = coords[0] - m_origin[0];
3331      double y = coords[1] - m_origin[1];      double y = coords[1] - m_origin[1];
3332      double z = coords[2] - m_origin[2];      double z = coords[2] - m_origin[2];
3333        
3334        //check if the point is even inside the domain
3335        if (x < 0 || y < 0 || z < 0
3336                || x > m_length[0] || y > m_length[1] || z > m_length[2])
3337            return NOT_MINE;
3338            
3339      // distance in elements      // distance in elements
3340      int ex = (int) floor(x / m_dx[0]);      int ex = (int) floor(x / m_dx[0]);
3341      int ey = (int) floor(y / m_dx[1]);      int ey = (int) floor(y / m_dx[1]);

Legend:
Removed from v.4801  
changed lines
  Added in v.4851

  ViewVC Help
Powered by ViewVC 1.1.26