diff --git a/src/TNL/Meshes/DistributedMeshes/DistributedGridIO_MeshFunction.h b/src/TNL/Meshes/DistributedMeshes/DistributedGridIO_MeshFunction.h index 219346b3de3dc1f3508ffa3cb6c2fe449e68e28d..b5c12736137ee6fac9322814fc3c44191491cf61 100644 --- a/src/TNL/Meshes/DistributedMeshes/DistributedGridIO_MeshFunction.h +++ b/src/TNL/Meshes/DistributedMeshes/DistributedGridIO_MeshFunction.h @@ -13,7 +13,7 @@ #include <TNL/Functions/MeshFunction.h> namespace TNL { -namespace Meshes { +namespace Meshes { namespace DistributedMeshes { @@ -21,19 +21,21 @@ 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 MeshFunction, - int Dimension, - typename Real, +template< int Dimension, + int MeshEntityDimension, + typename MeshReal, typename Device, - typename Index > -class DistributedGridIO< MeshFunction, - LocalCopy, - Meshes::Grid< Dimension, Real, Device, Index >, - Device > + typename Index, + typename Real > +class DistributedGridIO< + Functions::MeshFunction< Meshes::Grid< Dimension, MeshReal, Device, Index >, + MeshEntityDimension, + Real >, + LocalCopy > { public: using MeshType = Meshes::Grid< Dimension, Real, Device, Index >; - using MeshFunctionType = MeshFunction; + using MeshFunctionType = Functions::MeshFunction< MeshType, MeshEntityDimension, Real >; using CoordinatesType = typename MeshFunctionType::MeshType::CoordinatesType; using PointType = typename MeshFunctionType::MeshType::PointType; using VectorType = typename MeshFunctionType::VectorType; @@ -430,17 +432,20 @@ class DistributedGridIO_MPIIOBase }; #endif -template< typename MeshFunction, - int Dimension, - typename Real, - typename Index > -class DistributedGridIO< MeshFunction, - MpiIO, - Meshes::Grid< Dimension, Real, Devices::Cuda, Index >, - Devices::Cuda > +template< int Dimension, + int MeshEntityDimension, + typename MeshReal, + typename Index, + typename Real > +class DistributedGridIO< + Functions::MeshFunction< Meshes::Grid< Dimension, MeshReal, Devices::Cuda, Index >, + MeshEntityDimension, + Real >, + MpiIO > { public: - using MeshFunctionType = MeshFunction; + using MeshType = Meshes::Grid< Dimension, MeshReal, Devices::Cuda, Index >; + using MeshFunctionType = Functions::MeshFunction< MeshType, MeshEntityDimension, Real >; static bool save(const String& fileName, MeshFunctionType &meshFunction) { @@ -477,17 +482,20 @@ class DistributedGridIO< MeshFunction, }; }; -template< typename MeshFunction, - int Dimension, - typename Real, - typename Index > -class DistributedGridIO< MeshFunction, - MpiIO, - Meshes::Grid< Dimension, Real, Devices::Host, Index >, - Devices::Host > +template< int Dimension, + int MeshEntityDimension, + typename MeshReal, + typename Index, + typename Real > +class DistributedGridIO< + Functions::MeshFunction< Meshes::Grid< Dimension, MeshReal, Devices::Host, Index >, + MeshEntityDimension, + Real >, + MpiIO > { public: - using MeshFunctionType = MeshFunction; + using MeshType = Meshes::Grid< Dimension, MeshReal, Devices::Host, Index >; + using MeshFunctionType = Functions::MeshFunction< MeshType, MeshEntityDimension, Real >; static bool save(const String& fileName, MeshFunctionType &meshFunction) { diff --git a/src/TNL/Meshes/DistributedMeshes/DistributedGridIO_VectorField.h b/src/TNL/Meshes/DistributedMeshes/DistributedGridIO_VectorField.h index 5169adabed95276fdbf131f9e71b9a1b1fe54b9c..c3489994f69458bec85813f1915ce8aa245e681d 100644 --- a/src/TNL/Meshes/DistributedMeshes/DistributedGridIO_VectorField.h +++ b/src/TNL/Meshes/DistributedMeshes/DistributedGridIO_VectorField.h @@ -14,23 +14,35 @@ #include <TNL/Meshes/Grid.h> namespace TNL { -namespace Meshes { +namespace Meshes { namespace DistributedMeshes { -template< int Size, - typename MeshFunction, - int Dimension, - typename Real, - typename Device, - typename Index > -class DistributedGridIO< Functions::VectorField< Size, MeshFunction >, - MpiIO, - Meshes::Grid< Dimension, Real, Device, Index >, - Device > +template< + int Size, + int Dimension, + int MeshEntityDimension, + typename MeshReal, + typename Device, + typename Index, + typename Real > +class DistributedGridIO< + Functions::VectorField< + Size, + Functions::MeshFunction< Meshes::Grid< Dimension, MeshReal, Device, Index >, + MeshEntityDimension, + Real > >, + MpiIO > { - public: - static bool save(const String& fileName, Functions::VectorField<Size,MeshFunction > &vectorField) - { + public: + using MeshType = Meshes::Grid< Dimension, Real, Device, Index >; + using MeshFunctionType = Functions::MeshFunction< MeshType, MeshEntityDimension, Real >; + using VectorFieldType = Functions::VectorField< Size, MeshFunctionType >; + using CoordinatesType = typename MeshFunctionType::MeshType::CoordinatesType; + using PointType = typename MeshFunctionType::MeshType::PointType; + using VectorType = typename MeshFunctionType::VectorType; + + static bool save(const String& fileName, Functions::VectorField< Size, MeshFunctionType > &vectorField) + { #ifdef HAVE_MPI if(Communicators::MpiCommunicator::IsInitialized())//i.e. - isUsed { @@ -58,8 +70,8 @@ class DistributedGridIO< Functions::VectorField< Size, MeshFunction >, for( int i = 0; i < vectorField.getVectorDimension(); i++ ) { - typename MeshFunction::RealType * data=vectorField[i]->getData().getData(); //here manage data transfer Device... - int size = DistributedGridIO_MPIIOBase<MeshFunction>::save(file,*(vectorField[i]),data,offset); + typename MeshFunctionType::RealType * data=vectorField[i]->getData().getData(); //here manage data transfer Device... + int size = DistributedGridIO_MPIIOBase<MeshFunctionType>::save(file,*(vectorField[i]),data,offset); offset+=size; if( size==0 ) return false; @@ -76,7 +88,7 @@ class DistributedGridIO< Functions::VectorField< Size, MeshFunction >, #ifdef HAVE_MPI private: - static unsigned int writeVectorFieldHeader(MPI_File &file,Functions::VectorField<Size,MeshFunction> &vectorField) + static unsigned int writeVectorFieldHeader(MPI_File &file,Functions::VectorField<Size,MeshFunctionType > &vectorField) { unsigned int size=0; int count; @@ -100,7 +112,7 @@ class DistributedGridIO< Functions::VectorField< Size, MeshFunction >, return size; } - static unsigned int readVectorFieldHeader(MPI_File &file,Functions::VectorField<Size,MeshFunction> &vectorField) + static unsigned int readVectorFieldHeader(MPI_File &file,Functions::VectorField<Size,MeshFunctionType> &vectorField) { MPI_Status rstatus; char buffer[255]; @@ -119,7 +131,7 @@ class DistributedGridIO< Functions::VectorField< Size, MeshFunction >, #endif public: - static bool load(const String& fileName, Functions::VectorField<Size,MeshFunction> &vectorField) + static bool load(const String& fileName, Functions::VectorField<Size,MeshFunctionType> &vectorField) { #ifdef HAVE_MPI if(Communicators::MpiCommunicator::IsInitialized())//i.e. - isUsed @@ -148,8 +160,8 @@ class DistributedGridIO< Functions::VectorField< Size, MeshFunction >, for( int i = 0; i < vectorField.getVectorDimension(); i++ ) { - typename MeshFunction::RealType * data=vectorField[i]->getData().getData(); //here manage data transfer Device... - int size = DistributedGridIO_MPIIOBase<MeshFunction>::load(file,*(vectorField[i]),data,offset); + typename MeshFunctionType::RealType * data=vectorField[i]->getData().getData(); //here manage data transfer Device... + int size = DistributedGridIO_MPIIOBase<MeshFunctionType>::load(file,*(vectorField[i]),data,offset); offset+=size; if( size==0 ) return false;