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

Fixing DitributedGridIO to work with general mesh functions.

parent 8053ee82
Loading
Loading
Loading
Loading
+15 −10
Original line number Diff line number Diff line
@@ -580,6 +580,11 @@ template<> struct MPITypeResolver<long double>
{
    static inline MPI_Datatype getType(){return MPI_LONG_DOUBLE;};
};

template<> struct MPITypeResolver< bool >
{
    static inline MPI_Datatype getType(){return MPI_C_BOOL;};
};
#endif

} // namespace <unnamed>
+8 −8
Original line number Diff line number Diff line
@@ -26,16 +26,16 @@ namespace DistributedMeshes {

enum DistrGridIOTypes { Dummy = 0 , LocalCopy = 1, MpiIO=2 };
    
template<typename MeshFunctionType,
template< typename MeshFunction,
          DistrGridIOTypes type = LocalCopy,
         typename Device=typename MeshFunctionType::DeviceType> 
          typename Mesh = typename MeshFunction::MeshType,
          typename Device = typename MeshFunction::DeviceType >
class DistributedGridIO
{
};

template<typename MeshFunctionType,
         typename Device> 
class DistributedGridIO<MeshFunctionType,Dummy,Device>
template< typename MeshFunctionType > 
class DistributedGridIO< MeshFunctionType, Dummy >
{
    bool save(const String& fileName, MeshFunctionType &meshFunction)
    {
+112 −100
Original line number Diff line number Diff line
@@ -21,16 +21,22 @@ namespace DistributedMeshes {
 * This variant cerate copy of MeshFunction but smaller, reduced to local entities, without overlap. 
 * It is slow and has high RAM consumption
 */
template<typename MeshType,
         typename Device> 
class DistributedGridIO<Functions::MeshFunction<MeshType>,LocalCopy,Device>
template< typename MeshFunction,
          int Dimension,
          typename Real,
          typename Device,
          typename Index > 
class DistributedGridIO< MeshFunction,
                         LocalCopy,
                         Meshes::Grid< Dimension, Real, Device, Index >,
                         Device >
{

   public:
	typedef typename Functions::MeshFunction<MeshType> MeshFunctionType;
    typedef typename MeshFunctionType::MeshType::CoordinatesType CoordinatesType;
    typedef typename MeshFunctionType::MeshType::PointType PointType;
    typedef typename MeshFunctionType::VectorType VectorType;
      using MeshType = Meshes::Grid< Dimension, Real, Device, Index >;
      using MeshFunctionType = MeshFunction;
      using CoordinatesType = typename MeshFunctionType::MeshType::CoordinatesType;
      using PointType = typename MeshFunctionType::MeshType::PointType;
      using VectorType = typename MeshFunctionType::VectorType;
      //typedef DistributedGrid< MeshType,MeshFunctionType::getMeshDimension()> DistributedGridType;

      static bool save(const String& fileName, MeshFunctionType &meshFunction)
@@ -424,11 +430,17 @@ class DistributedGridIO_MPIIOBase
};
#endif

template<typename MeshType> 
class DistributedGridIO<Functions::MeshFunction<MeshType>,MpiIO,TNL::Devices::Cuda>
template< typename MeshFunction,
          int Dimension,
          typename Real,
          typename Index > 
class DistributedGridIO< MeshFunction,
                         MpiIO,
                         Meshes::Grid< Dimension, Real, Devices::Cuda, Index >,
                         Devices::Cuda >
{
   public:
	typedef typename Functions::MeshFunction<MeshType> MeshFunctionType;
   	using MeshFunctionType = MeshFunction;

      static bool save(const String& fileName, MeshFunctionType &meshFunction)
      {
@@ -444,7 +456,6 @@ class DistributedGridIO<Functions::MeshFunction<MeshType>,MpiIO,TNL::Devices::Cu
#endif
         std::cout << "MPIIO can be used only with MPICommunicator." << std::endl;
         return false;
      
      };

      static bool load(const String& fileName,MeshFunctionType &meshFunction) 
@@ -464,15 +475,19 @@ class DistributedGridIO<Functions::MeshFunction<MeshType>,MpiIO,TNL::Devices::Cu
         std::cout << "MPIIO can be used only with MPICommunicator." << std::endl;
         return false;
    };

};

template<typename MeshType> 
class DistributedGridIO<Functions::MeshFunction<MeshType>,MpiIO,TNL::Devices::Host>
template< typename MeshFunction,
          int Dimension,
          typename Real,
          typename Index > 
class DistributedGridIO< MeshFunction,
                         MpiIO,
                         Meshes::Grid< Dimension, Real, Devices::Host, Index >,
                         Devices::Host >
{

   public:
	typedef typename Functions::MeshFunction<MeshType> MeshFunctionType;
      using MeshFunctionType = MeshFunction;

      static bool save(const String& fileName, MeshFunctionType &meshFunction)
      {
@@ -485,7 +500,6 @@ class DistributedGridIO<Functions::MeshFunction<MeshType>,MpiIO,TNL::Devices::Ho
#endif
         std::cout << "MPIIO can be used only with MPICommunicator." << std::endl;
         return false;

    };

      static bool load(const String& fileName,MeshFunctionType &meshFunction) 
@@ -500,10 +514,8 @@ class DistributedGridIO<Functions::MeshFunction<MeshType>,MpiIO,TNL::Devices::Ho
         std::cout << "MPIIO can be used only with MPICommunicator." << std::endl;
         return false;
    };

};

}
}
}
      } //namespace DistributedMeshes
   } //namespace Meshes
} //namespace TNL