Commit ce830fbf authored by Tomáš Oberhuber's avatar Tomáš Oberhuber
Browse files

Implemented perioidic neighbors in distributed grid.

parent 7da06cab
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -96,7 +96,7 @@ setGlobalGrid( const GridType& globalGrid,
                        +this->globalBegin.x()*this->globalGrid.getSpaceSteps().x();
       }

      this->setUpNeighbors();
      this->setupNeighbors();

      this->localBegin=overlap;

+1 −1
Original line number Diff line number Diff line
@@ -118,7 +118,7 @@ setGlobalGrid( const GridType &globalGrid,

      this->localOrigin=globalGrid.getOrigin()+TNL::Containers::tnlDotProduct(globalGrid.getSpaceSteps(),this->globalBegin-this->overlap);

      this->setUpNeighbors();
      this->setupNeighbors();

      //nearnodes
      /*if(this->subdomainCoordinates[0]>0)
+1 −1
Original line number Diff line number Diff line
@@ -145,7 +145,7 @@ setGlobalGrid( const GridType &globalGrid,

      this->localOrigin=globalGrid.getOrigin()+TNL::Containers::tnlDotProduct(globalGrid.getSpaceSteps(),this->globalBegin-this->overlap);

      this->setUpNeighbors();
      this->setupNeighbors();

      this->localBegin=this->overlap;

+3 −1
Original line number Diff line number Diff line
@@ -92,7 +92,7 @@ class DistributedGrid_Base
   public: 
      bool isThereNeighbor(const CoordinatesType &direction) const;

      void setUpNeighbors();
      void setupNeighbors();

      GridType globalGrid;
      PointType localOrigin;
@@ -109,6 +109,8 @@ class DistributedGrid_Base

      int neighbors[getNeighborsCount()];
      
      int periodicNeighbors[getNeighborsCount()];

      IndexType Dimensions;        
      bool distributed;
        
+29 −18
Original line number Diff line number Diff line
@@ -15,6 +15,8 @@

#include <iostream>

#include "DistributedGrid_Base.h"

namespace TNL {
   namespace Meshes {
      namespace DistributedMeshes {
@@ -207,21 +209,30 @@ isThereNeighbor(const CoordinatesType &direction) const
template< int dim, typename RealType, typename Device, typename Index >    
void
DistributedGrid_Base< dim, RealType, Device, Index >::
setUpNeighbors()
setupNeighbors()
{
   int *neighbors = this->neighbors;

   for( int i = 0; i < getNeighborsCount(); i++ )
   {
      auto direction = Directions::template getXYZ< dim >( i );
      auto coordinates = this->subdomainCoordinates+direction;
      if( this->isThereNeighbor( direction ) )
        {
            this->neighbors[i]=this->getRankOfProcCoord(this->subdomainCoordinates+direction);
        }
         this->neighbors[ i ] = this->getRankOfProcCoord( coordinates );
      else
        {
         this->neighbors[ i ] =- 1;
      
      // Handling periodic neighbors
      for( int d = 0; d < dim; d++ )
      {
         if( coordinates[ d ] == -1 )
            coordinates[ d ] = this->domainDecomposition[ d ] - 1;
         if( coordinates[ d ] == this->domainDecomposition[ d ] )
            coordinates[ d ] = 0;
         this->periodicNeighbors[ i ] = this->getRankOfProcCoord( coordinates );
      }
      
      std::cout << "Setting i-th neigbour to " << neighbors[ i ] << " and " << periodicNeighbors[ i ] << std::endl;
   }
}

@@ -293,7 +304,7 @@ SetupByCut(DistributedGridType &inputDistributedGrid,

            CommunicatorType::CreateNewGroup(isInCut,newRank,*oldGroup ,*((typename CommunicatorType::CommunicationGroup*) this->communicationGroup));

            setUpNeighbors();
            setupNeighbors();