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

Added peridoic neighbours to distributed grids for implementation of periodic boundary conditions.

parent ce830fbf
Loading
Loading
Loading
Loading
+32 −0
Original line number Diff line number Diff line
@@ -57,6 +57,8 @@ class MpiCommunicator
      inline static MPI_Datatype MPIDataType( const double* ) { return MPI_DOUBLE; };
      inline static MPI_Datatype MPIDataType( const long double* ) { return MPI_LONG_DOUBLE; };

      // TODO: How to deal with bool

      using Request = MPI_Request;
      using CommunicationGroup = MPI_Comm;
#else
@@ -335,6 +337,36 @@ class MpiCommunicator
#endif
        }
         
         template< typename T >
         static void SendReceive( T* sendData,
                                  int sendCount,
                                  int destination,
                                  int sendTag,
                                  T* receiveData,
                                  int receiveCount,
                                  int source,
                                  int receiveTag,
                                  CommunicationGroup group )
         {
#ifdef HAVE_MPI
            MPI_Status status;
            MPI_Sendrecv( ( void* ) sendData,
                          sendCount,
                          MPIDataType( sendData ),
                          destination,
                          sendTag,
                          ( void* ) receiveData,
                          receiveCount,
                          MPIDataType( receiveData ),
                          source,
                          receiveTag,
                          group,
                          &status );
#else
            throw Exceptions::MPISupportMissing();
#endif            
         }


      static void writeProlog( Logger& logger ) 
      {
+3 −1
Original line number Diff line number Diff line
@@ -81,6 +81,8 @@ class DistributedGrid_Base

      const int* getNeighbors() const;
      
      const int* getPeriodicNeighbors() const; 

      template<typename CommunicatorType, typename DistributedGridType>
      bool SetupByCut(DistributedGridType &inputDistributedGrid, 
                 Containers::StaticVector<dim, int> savedDimensions, 
+9 −0
Original line number Diff line number Diff line
@@ -245,6 +245,15 @@ getNeighbors() const
    return this->neighbors;
}

template< int dim, typename RealType, typename Device, typename Index >   
const int*
DistributedGrid_Base< dim, RealType, Device, Index >::
getPeriodicNeighbors() const
{
    TNL_ASSERT_TRUE(this->isSet,"DistributedGrid is not set, but used by getNeighbors");
    return this->periodicNeighbors;
}

template< int dim, typename RealType, typename Device, typename Index >    
    template<typename CommunicatorType, typename DistributedGridType >
bool 
+1 −1
Original line number Diff line number Diff line
@@ -139,7 +139,7 @@ class Grid< 2, Real, Device, Index > : public Object
   
   void setDistMesh(DistributedMeshType * distGrid);
   
   DistributedMeshType * getDistributedMesh(void) const;
   DistributedMeshType * getDistributedMesh() const;

   //! Method for saving the object to a file as a binary data
   bool save( File& file ) const;
+7 −2
Original line number Diff line number Diff line
@@ -20,14 +20,19 @@ String getType() { return T::getType(); };

template<> inline String getType< void >() { return String( "void" ); };
template<> inline String getType< bool >() { return String( "bool" ); };

template<> inline String getType< char >() { return String( "char" ); };
template<> inline String getType< short int >() { return String( "short int" ); };
template<> inline String getType< int >() { return String( "int" ); };
template<> inline String getType< long int >() { return String( "long int" ); };

template<> inline String getType< unsigned char >() { return String( "unsigned char" ); };
template<> inline String getType< unsigned short >() { return String( "unsigned short" ); };
template<> inline String getType< unsigned int >() { return String( "unsigned int" ); };
template<> inline String getType< unsigned long >() { return String( "unsigned long" ); };
template<> inline String getType< char >() { return String( "char" ); };
template<> inline String getType< unsigned char >() { return String( "unsigned char" ); };

template<> inline String getType< signed char >() { return String( "signed char" ); };

template<> inline String getType< float >() { return String( "float" ); };
template<> inline String getType< double >() { return String( "double" ); };
template<> inline String getType< long double >() { return String( "long double" ); };
Loading