diff --git a/buildAll b/buildAll index 255da2b45590d8ea172d811ceae0adfd271f5341..3986a9ea1db990dc0960376c7c614a5f44b7ff45 100755 --- a/buildAll +++ b/buildAll @@ -7,6 +7,7 @@ WITH_CUSPARSE=no CUDA_ARCHITECTURE=2.0 VERBOSE=1 +CMAKE="cmake" CPUS=`grep -c processor /proc/cpuinfo` echo "Building $TARGET using $CPUS processors." @@ -21,13 +22,13 @@ then fi cd Debug -cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=${HOME}/local -DCUDA_ARCHITECTURE=${CUDA_ARCHITECTURE} -DWITH_CUDA=${WITH_CUDA} -DWITH_CUSPARSE=${WITH_CUSPARSE} -DPETSC_DIR=${PETSC_DIR} +${CMAKE} .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=${HOME}/local -DCUDA_ARCHITECTURE=${CUDA_ARCHITECTURE} -DWITH_CUDA=${WITH_CUDA} -DWITH_CUSPARSE=${WITH_CUSPARSE} -DPETSC_DIR=${PETSC_DIR} make -j${CPUS} #VERBOSE=1 make -j${CPUS} test make -j${CPUS} install cd ../Release -cmake .. -DCMAKE_INSTALL_PREFIX=${HOME}/local -DCUDA_ARCHITECTURE=${CUDA_ARCHITECTURE} -DWITH_CUDA=${WITH_CUDA} -DWITH_CUSPARSE=${WITH_CUSPARSE} -DPETSC_DIR=${PETSC_DIR} +${CMAKE} .. -DCMAKE_INSTALL_PREFIX=${HOME}/local -DCUDA_ARCHITECTURE=${CUDA_ARCHITECTURE} -DWITH_CUDA=${WITH_CUDA} -DWITH_CUSPARSE=${WITH_CUSPARSE} -DPETSC_DIR=${PETSC_DIR} make -j${CPUS} #VERBOSE=1 make -j${CPUS} test make -j${CPUS} install diff --git a/examples/make-project/Makefile b/examples/make-project/Makefile index 488189da368a80dfba9b7ab7b48a3af3ae2c0b9f..b00118da70bb6ce3fcc31b53e594be3119bd0875 100644 --- a/examples/make-project/Makefile +++ b/examples/make-project/Makefile @@ -32,10 +32,10 @@ uninstall: $(TARGET) rm -f $(CONFIG_FILE) $(INSTALL_DIR)/share $(TARGET): $(OBJECTS) - $(CC) -o $(TARGET) $(OBJECTS) $(LD_FLAGS) + $(CXX) -o $(TARGET) $(OBJECTS) $(LD_FLAGS) %.o: %.cpp $(TARGET)-conf.h $(HEADERS) - $(CC) -c -o $@ $(CXX_FLAGS) $< + $(CXX) -c -o $@ $(CXX_FLAGS) $< $(TARGET)-conf.h: echo "#define CONFIG_FILE \"${INSTALL_DIR}/share/${CONFIG_FILE}\" " > $(TARGET)-conf.h diff --git a/examples/simple-solver/Makefile b/examples/simple-solver/Makefile index 922a7bebe6c91597125d9fcb08d114026c5db28c..8d29cf9b02cac06f39ab11509772c284cf5db1ab 100644 --- a/examples/simple-solver/Makefile +++ b/examples/simple-solver/Makefile @@ -32,10 +32,10 @@ uninstall: $(TARGET) rm -f $(CONFIG_FILE) $(INSTALL_DIR)/share $(TARGET): $(OBJECTS) - $(CC) -o $(TARGET) $(OBJECTS) $(LD_FLAGS) + $(CXX) -o $(TARGET) $(OBJECTS) $(LD_FLAGS) %.o: %.cpp $(TARGET)-conf.h $(HEADERS) - $(CC) -c -o $@ $(CXX_FLAGS) $< + $(CXX) -c -o $@ $(CXX_FLAGS) $< $(TARGET)-conf.h: echo "#define CONFIG_FILE \"${INSTALL_DIR}/share/${CONFIG_FILE}\" " > $(TARGET)-conf.h diff --git a/src/core/tnlFile.h b/src/core/tnlFile.h index acd6cb79ea1543f4f9f7f272bf9072cc771debac..f4f8f1e14a2a17d6975b9493bf297e47055e01e1 100644 --- a/src/core/tnlFile.h +++ b/src/core/tnlFile.h @@ -85,8 +85,8 @@ class tnlFile tnlFile(); bool open( const tnlString& fileName, - const tnlIOMode mode, - const tnlCompression compression = tnlCompressionBzip2 ); + const tnlIOMode mode, + const tnlCompression compression = tnlCompressionBzip2 ); const tnlString& getFileName() const { @@ -104,6 +104,7 @@ class tnlFile } // TODO: this does not work for constant types +#ifdef HAVE_CXX11 template< typename Type, typename Device = tnlHost, typename Index = int > bool read( Type* buffer, const Index& elements ); @@ -117,7 +118,21 @@ class tnlFile template< typename Type, typename Device = tnlHost > bool write( Type* buffer ); +#else + template< typename Type, typename Device, typename Index > + bool read( Type* buffer, + const Index& elements ); + template< typename Type, typename Device > + bool read( Type* buffer ); + + template< typename Type, typename Device, typename Index > + bool write( const Type* buffer, + const Index elements ); + + template< typename Type, typename Device > + bool write( Type* buffer ); +#endif bool close(); diff --git a/src/core/tnlList.h b/src/core/tnlList.h index bcf4112bc9f7042ab0d622a5906290b10f5b8f90..14dae6305a28b6106db52efb3957dcc4b977e680 100644 --- a/src/core/tnlList.h +++ b/src/core/tnlList.h @@ -301,25 +301,41 @@ template< class T > class tnlList //! Save the list in binary format bool Save( tnlFile& file ) const { +#ifdef HAVE_CXX11 file. write( &size ); for( int i = 0; i < size; i ++ ) if( ! file. write( &operator[]( i ), 1 ) ) return false; return true; +#else + file. write< const int, tnlHost >( &size ); + for( int i = 0; i < size; i ++ ) + if( ! file. write< int, tnlHost, int >( &operator[]( i ), 1 ) ) + return false; + return true; +#endif } //! Save the list in binary format using method save of type T bool DeepSave( tnlFile& file ) const { - file. write( &size, 1 ); +#ifdef HAVE_CXX11 + file. write( &size ); for( int i = 0; i < size; i ++ ) if( ! operator[]( i ). save( file ) ) return false; return true; +#else + file. write< const int, tnlHost >( &size ); + for( int i = 0; i < size; i ++ ) + if( ! operator[]( i ). save( file ) ) return false; + return true; +#endif } //! Load the list bool Load( tnlFile& file ) { +#ifdef HAVE_CXX11 EraseAll(); int _size; file. read( &_size, 1 ); @@ -336,6 +352,24 @@ template< class T > class tnlList Append( t ); } return true; +#else + EraseAll(); + int _size; + file. read< int, tnlHost >( &_size ); + if( _size < 0 ) + { + cerr << "The curve size is negative." << endl; + return false; + } + T t; + for( int i = 0; i < _size; i ++ ) + { + if( ! file. read< T, tnlHost >( &t ) ) + return false; + Append( t ); + } + return true; +#endif }; //! Load the list using method Load of the type T @@ -343,7 +377,7 @@ template< class T > class tnlList { EraseAll(); int _size; - file. read( &_size, 1 ); + file. read( &_size ); if( _size < 0 ) { cerr << "The list size is negative." << endl; diff --git a/src/implementation/mesh/tnlGrid2D_impl.h b/src/implementation/mesh/tnlGrid2D_impl.h index f626a05f1e364d5d5cf9a598348c31b4bbfcfbac..f6ec73624452f0663ba65593c52dd01211e19b81 100644 --- a/src/implementation/mesh/tnlGrid2D_impl.h +++ b/src/implementation/mesh/tnlGrid2D_impl.h @@ -159,6 +159,22 @@ Index tnlGrid< 2, Real, Device, Index> :: getNodeIndex( const Index j, const Ind return j * this -> dimensions. x() + i; } +template< typename Real, + typename Device, + typename Index > +Index tnlGrid< 2, Real, Device, Index> :: getNodeNeighbour( const Index node, + const Index dy, + const Index dx ) const +{ + tnlAssert( node + dy * this -> dimensions. x() + dx < getDofs(), + cerr << "Index of neighbour with dx = " << dx + << " and dy = " << dy + << " is out of range ( " << dimensions. x() + << " ) in tnlGrid " << this -> getName(); ) + return node + dy * this -> dimensions. x() + dx; +} + + template< typename Real, typename Device, typename Index > diff --git a/src/mesh/tnlGrid.h b/src/mesh/tnlGrid.h index 0e71a3dcabc217cf13807b1b25ffafedaaa05cc2..0a8079397519b334086164a454b411d3d83917fa 100644 --- a/src/mesh/tnlGrid.h +++ b/src/mesh/tnlGrid.h @@ -124,6 +124,10 @@ class tnlGrid< 2, Real, Device, Index> : public tnlObject Index getNodeIndex( const Index j, const Index i ) const; + Index getNodeNeighbour( const Index node, + const Index dy, + const Index dx ) const; + Index getDofs() const; //! Method for saving the object to a file as a binary data