diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index a4ef60325701fb703062c0c08bd23b410a041b88..2ca4ddd90dacd5786aecb79b76f252559226cdd5 100755 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -8,6 +8,7 @@ set (headers tnlAssert.h tnlCuda.h tnlDataElement.h tnlDevice.h + tnlDynamicTypeTag.h tnlFeature.h tnlFile.h tnlFlopsCounter.h diff --git a/src/core/arrays/tnlArrayOperations.h b/src/core/arrays/tnlArrayOperations.h index 02cb11b32aa198511953e8dd19fb32f4643631a4..73246999dcb2e83bdfb35e9035bb37013cbe4085 100644 --- a/src/core/arrays/tnlArrayOperations.h +++ b/src/core/arrays/tnlArrayOperations.h @@ -69,6 +69,7 @@ class tnlArrayOperations< tnlHost > static bool compareMemory( const Element1* destination, const Element2* source, const Index size ); + }; template<> diff --git a/src/core/tnlDynamicTypeTag.h b/src/core/tnlDynamicTypeTag.h new file mode 100644 index 0000000000000000000000000000000000000000..9c2b6c551ad7e74c045f7fbba4b03c8243dc84b1 --- /dev/null +++ b/src/core/tnlDynamicTypeTag.h @@ -0,0 +1,28 @@ +/*************************************************************************** + tnlDynamicTypeTag.h - description + ------------------- + begin : Mar 13, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef TNLDYNAMICTYPETAG_H_ +#define TNLDYNAMICTYPETAG_H_ + +template< typename Element > +struct tnlDynamicTypeTag +{ + enum { value = false }; +}; + + +#endif /* TNLDYNAMICTYPETAG_H_ */ diff --git a/src/implementation/core/arrays/tnlArrayIO.h b/src/implementation/core/arrays/tnlArrayIO.h new file mode 100644 index 0000000000000000000000000000000000000000..a66be243ed2434626a8a9bfb3faf84927bffd3c4 --- /dev/null +++ b/src/implementation/core/arrays/tnlArrayIO.h @@ -0,0 +1,82 @@ +/*************************************************************************** + tnlArrayIO.h - description + ------------------- + begin : Mar 13, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef TNLARRAYIO_H_ +#define TNLARRAYIO_H_ + +#include<core/tnlDynamicTypeTag.h> +#include<core/tnlFile.h> + +template< typename Element, + typename Device, + typename Index, + bool DynamicType = tnlDynamicTypeTag< Element >::value > +class tnlArrayIO +{}; + +template< typename Element, + typename Device, + typename Index > +class tnlArrayIO< Element, Device, Index, true > +{ + public: + + static bool save( tnlFile& file, + const Element* data, + const Index elements ) + { + for( Index i = 0; i < elements; i++ ) + if( ! data[ i ].save( file ) ) + return false; + return true; + } + + static bool load( tnlFile& file, + Element* data, + const Index elements ) + { + for( Index i = 0; i < elements; i++ ) + if( ! data[ i ].load( file ) ) + return false; + return true; + } +}; + +template< typename Element + typename Device, + typename Index > +class tnlArrayIO< Element, Device, Index, false > +{ + public: + + static bool save( tnlFile& file, + const Element* data, + const Index elements ) + { + return file.write< Element, Device, Index >( data, elements ); + } + + static bool load( tnlFile& file, + Element* data, + const Index elements ) + { + return file.read< Element, Device, Index >( data, elements ); + } + +}; + +#endif /* TNLARRAYIO_H_ */ diff --git a/src/implementation/core/arrays/tnlArray_impl.h b/src/implementation/core/arrays/tnlArray_impl.h index 3f20f9c846685cc54a64ad9baaadf7ca73248ba9..c41235097ab85c559a65bd81f1272c9c73fffe53 100644 --- a/src/implementation/core/arrays/tnlArray_impl.h +++ b/src/implementation/core/arrays/tnlArray_impl.h @@ -24,6 +24,7 @@ #include <core/mfuncs.h> #include <core/param-types.h> #include <core/arrays/tnlArrayOperations.h> +#include <implementation/core/arrays/tnlArrayIO.h> using namespace std; @@ -332,7 +333,7 @@ bool tnlArray< Element, Device, Index > :: save( tnlFile& file ) const if( ! file. write( &this -> size ) ) return false; #endif - if( this -> size != 0 && ! file. write< Element, Device, Index >( this -> data, this -> size ) ) + if( this -> size != 0 && ! tnlArrayIO< Element, Device, Index >::save( file, this -> data, this -> size ) ) { cerr << "I was not able to save " << this->getType() << " " << this -> getName() @@ -365,7 +366,7 @@ bool tnlArray< Element, Device, Index > :: load( tnlFile& file ) if( _size ) { setSize( _size ); - if( ! file. read< Element, Device, Index >( this -> data, this -> size ) ) + if( ! tnlArrayIO< Element, Device, Index >::load( file, this -> data, this -> size ) ) { cerr << "I was not able to load " << this->getType() << " " << this -> getName() @@ -392,7 +393,6 @@ bool tnlArray< Element, Device, Index > :: load( const tnlString& fileName ) return tnlObject :: load( fileName ); } - template< typename Element, typename Device, typename Index > diff --git a/src/mesh/layers/tnlMeshStorageLayer.h b/src/mesh/layers/tnlMeshStorageLayer.h index 129257c386d1fa90eb5d4d6c73ddd19c32683f66..c2474b0c2eef94b6e8915355e3f3525397bc35b1 100644 --- a/src/mesh/layers/tnlMeshStorageLayer.h +++ b/src/mesh/layers/tnlMeshStorageLayer.h @@ -124,7 +124,7 @@ class tnlMeshStorageLayer< ConfigTag, bool save( tnlFile& file ) const { if( ! BaseType::save( file ) || - ! this->entities.save( file ) ) + ! this->entities.saveRecursively( file ) ) return false; return true; } @@ -133,7 +133,7 @@ class tnlMeshStorageLayer< ConfigTag, { cout << "Loading mesh layer with dimensions " << DimensionsTraits::value << endl; if( ! BaseType::load( file ) || - ! this->entities.load( file ) ) + ! this->entities.loadRecursively( file ) ) return false; this->sharedEntities.bind( this->entities ); return true; @@ -278,14 +278,14 @@ class tnlMeshStorageLayer< ConfigTag, bool save( tnlFile& file ) const { - if( ! this->vertices.save( file ) ) + if( ! this->vertices.saveRecursively( file ) ) return false; return true; } bool load( tnlFile& file ) { - if( ! this->vertices.load( file ) ) + if( ! this->vertices.loadRecursively( file ) ) return false; this->sharedVertices.bind( this->vertices ); return true; diff --git a/src/mesh/layers/tnlMeshSuperentityStorageLayer.h b/src/mesh/layers/tnlMeshSuperentityStorageLayer.h index ba81c87459d1a30058bc1315ea2fd5d39f2bd7fa..7eb7feff7ae913778b63cae06e2fdd31be399554 100644 --- a/src/mesh/layers/tnlMeshSuperentityStorageLayer.h +++ b/src/mesh/layers/tnlMeshSuperentityStorageLayer.h @@ -85,7 +85,9 @@ class tnlMeshSuperentityStorageLayer< ConfigTag, ~tnlMeshSuperentityStorageLayer() { - cout << " Destroying " << this->superentitiesIndices.getSize() << " superentities with "<< DimensionsTraits::value << " dimensions." << endl; + cerr << " Destroying " << this->superentitiesIndices.getSize() << " superentities with "<< DimensionsTraits::value << " dimensions." << endl; + cerr << " this->superentitiesIndices.getName() = " << this->superentitiesIndices.getName() << endl; + cerr << " this->sharedSuperentitiesIndices.getName() = " << this->sharedSuperentitiesIndices.getName() << endl; } tnlMeshSuperentityStorageLayer& operator = ( const tnlMeshSuperentityStorageLayer& layer ) @@ -146,9 +148,10 @@ class tnlMeshSuperentityStorageLayer< ConfigTag, bool load( tnlFile& file ) { - if( ! BaseType::load( file ) || - ! this->superentitiesIndices.load( file ) ) + if( ! BaseType::load( file ) ) //|| + //! this->superentitiesIndices.load( file ) ) return false; + cerr << "Loaded superentities " << this->superentitiesIndices.getName() << endl; return true; } diff --git a/src/mesh/tnlMeshEntity.h b/src/mesh/tnlMeshEntity.h index 0c5f9529df865301e156d04513109898c0d81950..aedba5ce329e9f40db4ff1f81cb5faa98ff336d8 100644 --- a/src/mesh/tnlMeshEntity.h +++ b/src/mesh/tnlMeshEntity.h @@ -64,9 +64,9 @@ class tnlMeshEntity bool load( tnlFile& file ) const { - if( ! tnlMeshSubentityStorageLayers< ConfigTag, EntityTag >::load( file ) || - ! tnlMeshSuperentityStorageLayers< ConfigTag, EntityTag >::load( file ) ) - return false; + //if( ! tnlMeshSubentityStorageLayers< ConfigTag, EntityTag >::load( file ) || + // ! tnlMeshSuperentityStorageLayers< ConfigTag, EntityTag >::load( file ) ) + // return false; return true; } @@ -332,9 +332,9 @@ class tnlMeshEntity< ConfigTag, tnlMeshVertexTag > bool load( tnlFile& file ) const { - if( ! tnlMeshSuperentityStorageLayers< ConfigTag, tnlMeshVertexTag >::load( file ) || - ! point.load( file ) ) - return false; + //if( ! tnlMeshSuperentityStorageLayers< ConfigTag, tnlMeshVertexTag >::load( file ) || + // ! point.load( file ) ) + // return false; return true; } diff --git a/tests/unit-tests/mesh/tnlMeshTester.h b/tests/unit-tests/mesh/tnlMeshTester.h index 18df7a25181caa3e67ff835144bcf428e118c22e..ed9d145360943534aef689baee977123fc401343 100644 --- a/tests/unit-tests/mesh/tnlMeshTester.h +++ b/tests/unit-tests/mesh/tnlMeshTester.h @@ -128,7 +128,7 @@ class tnlMeshTester : public CppUnit :: TestCase point0 edge2 point1 */ - tnlMesh< TestTriangleMeshConfig > mesh2, mesh; + tnlMesh< TestTriangleMeshConfig > mesh, mesh2; mesh.setName( "mesh" ); mesh.setNumberOfVertices( 4 ); mesh.setVertex( 0, PointType( 0.0, 0.0 ) ); @@ -156,6 +156,7 @@ class tnlMeshTester : public CppUnit :: TestCase CPPUNIT_ASSERT( mesh2.load( "mesh.tnl" ) ); mesh2.setName( "mesh2" ); + mesh2.print( cout ); //cout << "===================== Mesh2 =========================" << endl; //mesh2.print( cout ); //cout << "=====================================================" << endl; diff --git a/tools/src/tnl-view.cpp b/tools/src/tnl-view.cpp index 81bf602c8e03ef246b442d6a8b3151b7fc0b19d0..e4bb45931711c4fd78e9a724054bfa70f27efb8a 100644 --- a/tools/src/tnl-view.cpp +++ b/tools/src/tnl-view.cpp @@ -27,10 +27,10 @@ #include <mesh/tnlLinearGridGeometry.h> // TODO: Remove -#include <mesh/tnlMesh.h> +/*#include <mesh/tnlMesh.h> #include <mesh/tnlMeshWriterNetgen.h> #include <mesh/config/tnlMeshConfigBase.h> -#include <mesh/topologies/tnlMeshTriangleTag.h> +#include <mesh/topologies/tnlMeshTriangleTag.h>*/ #include "tnlConfig.h" const char configFile[] = TNL_CONFIG_DIRECTORY "tnl-view.cfg.desc"; @@ -125,7 +125,7 @@ int main( int argc, char* argv[] ) } if( parsedMeshType[ 0 ] == "tnlMesh" ) { - tnlString meshFile = parameters. GetParameter< tnlString >( "mesh" ); + /*tnlString meshFile = parameters. GetParameter< tnlString >( "mesh" ); struct MeshConfig : public tnlMeshConfigBase< 2 > { typedef tnlMeshTriangleTag CellTag; @@ -134,7 +134,7 @@ int main( int argc, char* argv[] ) if( ! mesh.load( meshFile ) ) return EXIT_FAILURE; if( ! tnlMeshWriterNetgen::writeMesh( "tnl-mesh.ng", mesh, true ) ) - return EXIT_FAILURE; + return EXIT_FAILURE;*/ } return EXIT_FAILURE; }