diff --git a/.cproject b/.cproject deleted file mode 100644 index 2e42104373e8b53683590425ef365ed94e058198..0000000000000000000000000000000000000000 --- a/.cproject +++ /dev/null @@ -1,66 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage"> - <storageModule moduleId="org.eclipse.cdt.core.settings"> - <cconfiguration id="cdt.managedbuild.toolchain.gnu.base.2134791445"> - <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.toolchain.gnu.base.2134791445" moduleId="org.eclipse.cdt.core.settings" name="Default"> - <externalSettings/> - <extensions> - <extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> - <extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/> - <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> - <extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> - <extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> - <extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/> - </extensions> - </storageModule> - <storageModule moduleId="cdtBuildSystem" version="4.0.0"> - <configuration buildProperties="" description="" id="cdt.managedbuild.toolchain.gnu.base.2134791445" name="Default" parent="org.eclipse.cdt.build.core.emptycfg"> - <folderInfo id="cdt.managedbuild.toolchain.gnu.base.2134791445.1799170915" name="/" resourcePath=""> - <toolChain id="cdt.managedbuild.toolchain.gnu.base.1762402759" name="cdt.managedbuild.toolchain.gnu.base" superClass="cdt.managedbuild.toolchain.gnu.base"> - <targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="cdt.managedbuild.target.gnu.platform.base.840154721" name="Debug Platform" osList="linux,hpux,aix,qnx" superClass="cdt.managedbuild.target.gnu.platform.base"/> - <builder id="cdt.managedbuild.target.gnu.builder.base.573876641" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" superClass="cdt.managedbuild.target.gnu.builder.base"> - <outputEntries> - <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="outputPath" name=""/> - </outputEntries> - </builder> - <tool id="cdt.managedbuild.tool.gnu.archiver.base.958650307" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base"/> - <tool id="cdt.managedbuild.tool.gnu.cpp.compiler.base.1237330740" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.base"> - <inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1856262209" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/> - </tool> - <tool id="cdt.managedbuild.tool.gnu.c.compiler.base.315517693" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.base"> - <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.950045328" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/> - </tool> - <tool id="cdt.managedbuild.tool.gnu.c.linker.base.1786292703" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.base"/> - <tool id="cdt.managedbuild.tool.gnu.cpp.linker.base.1133414639" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.base"> - <inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.692614544" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input"> - <additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/> - <additionalInput kind="additionalinput" paths="$(LIBS)"/> - </inputType> - </tool> - <tool id="cdt.managedbuild.tool.gnu.assembler.base.336757143" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.base"> - <inputType id="cdt.managedbuild.tool.gnu.assembler.input.1329383797" superClass="cdt.managedbuild.tool.gnu.assembler.input"/> - </tool> - </toolChain> - </folderInfo> - <sourceEntries> - <entry excluding="tnlLinearDiffusionTest.cu" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/> - </sourceEntries> - </configuration> - </storageModule> - <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/> - </cconfiguration> - </storageModule> - <storageModule moduleId="cdtBuildSystem" version="4.0.0"> - <project id="tnl.null.219466708" name="tnl"/> - </storageModule> - <storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/> - <storageModule moduleId="scannerConfiguration"> - <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/> - <scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.base.2134791445;cdt.managedbuild.toolchain.gnu.base.2134791445.1799170915;cdt.managedbuild.tool.gnu.c.compiler.base.315517693;cdt.managedbuild.tool.gnu.c.compiler.input.950045328"> - <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/> - </scannerConfigBuildInfo> - <scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.base.2134791445;cdt.managedbuild.toolchain.gnu.base.2134791445.1799170915;cdt.managedbuild.tool.gnu.cpp.compiler.base.1237330740;cdt.managedbuild.tool.gnu.cpp.compiler.input.1856262209"> - <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"/> - </scannerConfigBuildInfo> - </storageModule> -</cproject> diff --git a/CMakeLists.txt b/CMakeLists.txt index 24b7e4cfc481b1f377cd6cb1be7ca28cd2955dcb..6c71a19834bbdfa10428e79b9265b00fe8a163db 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,3 +1,17 @@ +############################################################################### +# Cmake project script for TNL +# ------------------- +# begin : Dec 8, 2010 +# copyright : (C) 2010 by Tomas Oberhuber et al. +# email : tomas.oberhuber@fjfi.cvut.cz +# +############################################################################### +# +# Authors: +# Tomas Oberhuber +# Vladimir Klement +# Jakub Klinkovsky + cmake_minimum_required( VERSION 2.8.10 ) project( tnl ) @@ -130,11 +144,11 @@ if( WITH_CUDA STREQUAL "yes" ) endif( NOT WITH_CUSPARSE STREQUAL "no" ) else( CUDA_FOUND ) - AddCompilerFlag( "-std=gnu++0x" ) + AddCompilerFlag( "-std=c++11" ) endif( CUDA_FOUND ) else( WITH_CUDA STREQUAL "yes" ) #AddCompilerFlag( "-std=gnu++0x -ftree-vectorizer-verbose=1" ) - AddCompilerFlag( "-std=gnu++0x" ) + AddCompilerFlag( "-std=c++11" ) endif( WITH_CUDA STREQUAL "yes" ) #### diff --git a/TODO b/TODO index c8ed457124545ba0f48fc89c85a1777e92ca1339..a6e199989ef8ea7b58c05dcdc9e55cf3af8d039f 100644 --- a/TODO +++ b/TODO @@ -1,8 +1,14 @@ +TODO: Mesh + * vsechny traits zkusit presunout do jednotneho MeshTraits, tj. temer MeshConfigTraits ale pojmenovat jako MeshTraits + * omezit tnlDimesnionsTag - asi to ale nepujde + - ale pozor na konstrukce jako BaseType::superentityIdsArray< SuperDimensionTag >( DimensionsTag ); ( v tnlMesh.h) + * prejmenovat Tagy v topologies na Topology zrejme + * zrusit tnlStorageTraits + TODO: v tnlMeshResolver se provadi preklad pro vsechny mozne sablonove parametry => prorezat TODO: napsat FunctionDiscretizer pro jednotne rozhrani RightHandSide -TODO: doplnit mesh travelsals pro jine mesh entity nez cell TODO: implementace maticovych resicu * Gaussova eliminace * SOR metoda diff --git a/build b/build index 361a2e98b7f78754d108db2fd9a2b4d00767e382..345037d2479673d1891241104d773120fd0c17ef 100755 --- a/build +++ b/build @@ -18,37 +18,38 @@ CMAKE_ONLY="no" HELP="no" VERBOSE="" ROOT_DIR="." +DCMTK_DIR="/usr/include/dcmtk" BUILD_JOBS=`grep -c processor /proc/cpuinfo` for option in "$@" do case $option in - --prefix=* ) PREFIX="${option#*=}" ;; - --build=* ) BUILD="${option#*=}" ;; - --with-tests=* ) WITH_TESTS="${option#*=}" ;; - --with-cuda=* ) WITH_CUDA="${option#*=}" ;; - --with-cublas=* ) WITH_CUBLAS="${option#*=}" ;; - --with-cuda-arch=* ) WITH_CUDA_ARCH="${option#*=}";; - --with-templates-instantiation ) WITH_TEMPLATE_INSTANTIATION="${option#*=}" ;; - --instantiate-long-int=* ) INSTANTIATE_LONG_INT="${option#*=}" ;; - --instantiate-int=* ) INSTANTIATE_INT="${option#*=}" ;; - --instantiate-long-double=* ) INSTANTIATE_LONG_DOUBLE="${option#*=}" ;; - --instantiate-double=* ) INSTANTIATE_DOUBLE="${option#*=}" ;; - --instantiate-float=* ) INSTANTIATE_FLOAT="${option#*=}" ;; - --fast-build ) INSTANTIATE_LONG_INT="no" - INSTANTIATE_INT="yes" - INSTANTIATE_LONG_DOUBLE="no" - INSTANTIATE_DOUBLE="yes" - INSTANTIATE_FLOAT="no" - WITH_CUDA_ARCH="auto" ;; - --with-cmake=* ) CMAKE="${option#*=}" ;; - --build-jobs=* ) BUILD_JOBS="${option#*=}" ;; - --cmake-only=* ) CMAKE_ONLY="${option#*=}" ;; - --verbose ) VERBOSE="VERBOSE=1" ;; - --root-dir=* ) ROOT_DIR="${option#*=}" ;; - --dcmtk-dir=* ) DCMTK_DIR="${option#*=}" ;; - --help ) HELP="yes" ;; - * ) + --prefix=* ) PREFIX="${option#*=}" ;; + --build=* ) BUILD="${option#*=}" ;; + --with-tests=* ) WITH_TESTS="${option#*=}" ;; + --with-cuda=* ) WITH_CUDA="${option#*=}" ;; + --with-cublas=* ) WITH_CUBLAS="${option#*=}" ;; + --with-cuda-arch=* ) WITH_CUDA_ARCH="${option#*=}";; + --with-templates-instantiation=* ) WITH_TEMPLATE_INSTANTIATION="${option#*=}" ;; + --instantiate-long-int=* ) INSTANTIATE_LONG_INT="${option#*=}" ;; + --instantiate-int=* ) INSTANTIATE_INT="${option#*=}" ;; + --instantiate-long-double=* ) INSTANTIATE_LONG_DOUBLE="${option#*=}" ;; + --instantiate-double=* ) INSTANTIATE_DOUBLE="${option#*=}" ;; + --instantiate-float=* ) INSTANTIATE_FLOAT="${option#*=}" ;; + --fast-build ) INSTANTIATE_LONG_INT="no" + INSTANTIATE_INT="yes" + INSTANTIATE_LONG_DOUBLE="no" + INSTANTIATE_DOUBLE="yes" + INSTANTIATE_FLOAT="no" + WITH_CUDA_ARCH="auto" ;; + --with-cmake=* ) CMAKE="${option#*=}" ;; + --build-jobs=* ) BUILD_JOBS="${option#*=}" ;; + --cmake-only=* ) CMAKE_ONLY="${option#*=}" ;; + --verbose ) VERBOSE="VERBOSE=1" ;; + --root-dir=* ) ROOT_DIR="${option#*=}" ;; + --dcmtk-dir=* ) DCMTK_DIR="${option#*=}" ;; + --help ) HELP="yes" ;; + * ) echo "Unknown option ${option}. Use --help for more information." exit 1 ;; esac @@ -105,4 +106,4 @@ then make -j${BUILD_JOBS} test fi -exit 0 \ No newline at end of file +exit 0 diff --git a/examples/heat-equation/tnl-heat-equation-eoc.h b/examples/heat-equation/tnl-heat-equation-eoc.h index 7001a2d71c0dc45166468a752844847794c0cc82..6c4beddcb0ac46b111a1a2a6f35e580a10e191ed 100644 --- a/examples/heat-equation/tnl-heat-equation-eoc.h +++ b/examples/heat-equation/tnl-heat-equation-eoc.h @@ -28,10 +28,10 @@ #include <problems/tnlHeatEquationEocRhs.h> #include <problems/tnlHeatEquationEocProblem.h> -//typedef tnlDefaultBuildConfigTag BuildConfig; +//typedef tnlDefaultBuildMeshConfig BuildConfig; typedef tnlFastBuildConfig BuildConfig; -template< typename ConfigTag > +template< typename MeshConfig > class heatEquationEocConfig { public: @@ -47,7 +47,7 @@ template< typename Real, typename Device, typename Index, typename MeshType, - typename ConfigTag, + typename MeshConfig, typename SolverStarter > class heatEquationSetter { diff --git a/examples/heat-equation/tnl-heat-equation.h b/examples/heat-equation/tnl-heat-equation.h index 77c3121bc4718c06921cb67789224054ff1ed041..e094ea425c6198aacb251f2952fb710ea97fcda9 100644 --- a/examples/heat-equation/tnl-heat-equation.h +++ b/examples/heat-equation/tnl-heat-equation.h @@ -29,10 +29,10 @@ #include <functors/tnlConstantFunction.h> #include <problems/tnlHeatEquationProblem.h> -//typedef tnlDefaultBuildConfigTag BuildConfig; +//typedef tnlDefaultBuildMeshConfig BuildConfig; typedef tnlFastBuildConfig BuildConfig; -template< typename ConfigTag > +template< typename MeshConfig > class heatEquationConfig { public: @@ -54,7 +54,7 @@ template< typename Real, typename Device, typename Index, typename MeshType, - typename ConfigTag, + typename MeshConfig, typename SolverStarter > class heatEquationSetter { diff --git a/examples/navier-stokes/navierStokesSolver_impl.h b/examples/navier-stokes/navierStokesSolver_impl.h index 528e84ccfa9107e74819046fcada6cc13dba53e7..f10e8eb64c7f157f8dd2426baa8e65e51e9f55af 100644 --- a/examples/navier-stokes/navierStokesSolver_impl.h +++ b/examples/navier-stokes/navierStokesSolver_impl.h @@ -51,9 +51,6 @@ navierStokesSolver< Mesh, EulerScheme > :: navierStokesSolver() T( 0.0 ), rhsIndex( 0 ) { - - this -> mesh. setName( "navier-stokes-mesh" ); - this -> dofVector. setName( "navier-stokes-dof-vector" ); } template< typename Mesh, typename EulerScheme > diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 9429eb9f18d6dfa452fbc968a8366c1d001b4ead..0670eed7f98eec266ba9409247c658aa94adc03e 100755 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -3,6 +3,7 @@ ADD_SUBDIRECTORY( containers ) ADD_SUBDIRECTORY( cuda ) ADD_SUBDIRECTORY( vectors ) ADD_SUBDIRECTORY( images ) +ADD_SUBDIRECTORY( multimaps ) set (headers tnlAssert.h tnlConstants.h diff --git a/src/core/arrays/tnlArray.h b/src/core/arrays/tnlArray.h index 6ebf9399b58afc449d8f5ec3fefa9cdfcd0df2cd..fb6e017b80938cfc09a0919c3d0b0eed37da8072 100644 --- a/src/core/arrays/tnlArray.h +++ b/src/core/arrays/tnlArray.h @@ -42,8 +42,6 @@ class tnlArray : public virtual tnlObject tnlArray(); - tnlArray( const tnlString& name ); - static tnlString getType(); tnlString getTypeVirtual() const; diff --git a/src/core/arrays/tnlArrayOperationsCuda_impl.h b/src/core/arrays/tnlArrayOperationsCuda_impl.h index 4179c38ffa9292b72612d7b4f093b0ef58f68382..af554d395776935218d9608ec0f11294fb2b11b4 100644 --- a/src/core/arrays/tnlArrayOperationsCuda_impl.h +++ b/src/core/arrays/tnlArrayOperationsCuda_impl.h @@ -256,6 +256,9 @@ bool tnlArrayOperations< tnlHost, tnlCuda >::compareMemory( const Element1* dest const Element2* source, const Index size ) { + /*** + * Here, destination is on host and source is on CUDA device. + */ tnlAssert( destination, ); tnlAssert( source, ); tnlAssert( size >= 0, cerr << "size = " << size ); @@ -268,7 +271,7 @@ bool tnlArrayOperations< tnlHost, tnlCuda >::compareMemory( const Element1* dest } Index compared( 0 ); while( compared < size ) - { + { Index transfer = Min( size - compared, tnlCuda::getGPUTransferBufferSize() ); if( cudaMemcpy( ( void* ) host_buffer, ( void* ) & ( source[ compared ] ), @@ -280,7 +283,7 @@ bool tnlArrayOperations< tnlHost, tnlCuda >::compareMemory( const Element1* dest delete[] host_buffer; return false; } - if( ! tnlArrayOperations< tnlHost >::compareMemory( host_buffer, destination, transfer ) ) + if( ! tnlArrayOperations< tnlHost >::compareMemory( &destination[ compared ], host_buffer, transfer ) ) { delete[] host_buffer; return false; diff --git a/src/core/arrays/tnlArray_impl.h b/src/core/arrays/tnlArray_impl.h index 3655f886914843aa421983532d67cf3743f3a7db..dff8c2502de1447564b049ad5632370c1051f788 100644 --- a/src/core/arrays/tnlArray_impl.h +++ b/src/core/arrays/tnlArray_impl.h @@ -36,15 +36,6 @@ tnlArray< Element, Device, Index > :: tnlArray() { }; -template< typename Element, - typename Device, - typename Index > -tnlArray< Element, Device, Index > :: tnlArray( const tnlString& name ) -: size( 0 ), data( 0 ) -{ - this -> setName( name ); -}; - template< typename Element, typename Device, typename Index > @@ -88,7 +79,6 @@ bool tnlArray< Element, Device, Index > :: setSize( const Index size ) { tnlAssert( size >= 0, cerr << "You try to set size of tnlArray to negative value." - << "Name: " << this -> getName() << endl << "New size: " << size << endl ); if( this->size == size ) return true; if( this->data ) @@ -101,8 +91,7 @@ bool tnlArray< Element, Device, Index > :: setSize( const Index size ) if( ! this->data ) { cerr << "I am not able to allocate new array with size " - << ( double ) this->size * sizeof( ElementType ) / 1.0e9 << " GB for " - << this->getName() << "." << endl; + << ( double ) this->size * sizeof( ElementType ) / 1.0e9 << " GB." << endl; this -> size = 0; return false; } @@ -117,8 +106,6 @@ bool tnlArray< Element, Device, Index > :: setLike( const Array& array ) { tnlAssert( array. getSize() >= 0, cerr << "You try to set size of tnlArray to negative value." - << "Name: " << this -> getName() << endl - << "Array name:" << array. getName() << "Array size: " << array. getSize() << endl ); return setSize( array.getSize() ); }; @@ -157,8 +144,7 @@ template< typename Element, void tnlArray< Element, Device, Index > :: setElement( const Index i, const Element& x ) { tnlAssert( 0 <= i && i < this -> getSize(), - cerr << "Wrong index for setElement method in tnlArray with name " - << this -> getName() + cerr << "Wrong index for setElement method in tnlArray " << " index is " << i << " and array size is " << this -> getSize() ); return tnlArrayOperations< Device > :: setMemoryElement( &( this -> data[ i ] ), x ); @@ -170,8 +156,7 @@ template< typename Element, Element tnlArray< Element, Device, Index > :: getElement( Index i ) const { tnlAssert( 0 <= i && i < this -> getSize(), - cerr << "Wrong index for getElement method in tnlArray with name " - << this -> getName() + cerr << "Wrong index for getElement method in tnlArray " << " index is " << i << " and array size is " << this -> getSize() ); return tnlArrayOperations< Device > :: getMemoryElement( & ( this -> data[ i ] ) ); @@ -184,8 +169,7 @@ __cuda_callable__ Element& tnlArray< Element, Device, Index > :: operator[] ( Index i ) { tnlAssert( 0 <= i && i < this -> getSize(), - cerr << "Wrong index for operator[] in tnlArray with name " - << this -> getName() + cerr << "Wrong index for operator[] in tnlArray " << " index is " << i << " and array size is " << this -> getSize() ); return this->data[ i ]; @@ -198,8 +182,7 @@ __cuda_callable__ const Element& tnlArray< Element, Device, Index > :: operator[] ( Index i ) const { tnlAssert( 0 <= i && i < this -> getSize(), - cerr << "Wrong index for operator[] in tnlArray with name " - << this -> getName() + cerr << "Wrong index for operator[] in tnlArray " << " index is " << i << " and array size is " << this -> getSize() ); return this->data[ i ]; @@ -212,9 +195,7 @@ tnlArray< Element, Device, Index >& tnlArray< Element, Device, Index > :: operator = ( const tnlArray< Element, Device, Index >& array ) { tnlAssert( array. getSize() == this -> getSize(), - cerr << "Source name: " << array. getName() << endl - << "Source size: " << array. getSize() << endl - << "Target name: " << this -> getName() << endl + cerr << "Source size: " << array. getSize() << endl << "Target size: " << this -> getSize() << endl ); tnlArrayOperations< Device > :: template copyMemory< Element, @@ -234,9 +215,7 @@ tnlArray< Element, Device, Index >& tnlArray< Element, Device, Index > :: operator = ( const Array& array ) { tnlAssert( array. getSize() == this -> getSize(), - cerr << "Source name: " << array. getName() << endl - << "Source size: " << array. getSize() << endl - << "Target name: " << this -> getName() << endl + cerr << "Source size: " << array. getSize() << endl << "Target size: " << this -> getSize() << endl ); tnlArrayOperations< Device, typename Array :: DeviceType > :: @@ -339,7 +318,6 @@ bool tnlArray< Element, Device, Index > :: save( tnlFile& file ) const 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() << " with size " << this -> getSize() << endl; return false; } @@ -372,7 +350,6 @@ bool tnlArray< Element, Device, Index > :: load( tnlFile& file ) if( ! tnlArrayIO< Element, Device, Index >::load( file, this -> data, this -> size ) ) { cerr << "I was not able to load " << this->getType() - << " " << this -> getName() << " with size " << this -> getSize() << endl; return false; } diff --git a/src/core/arrays/tnlConstSharedArray_impl.h b/src/core/arrays/tnlConstSharedArray_impl.h index b42bb5bd10c63e3bd875273a32ae53e6d98cbd87..ce0065859c45fe94f40c8879307f6f5e55e46045 100644 --- a/src/core/arrays/tnlConstSharedArray_impl.h +++ b/src/core/arrays/tnlConstSharedArray_impl.h @@ -78,11 +78,9 @@ void tnlConstSharedArray< Element, Device, Index > :: bind( const Element* data, { tnlAssert( size >= 0, cerr << "You try to set size of tnlConstSharedArray to negative value." - << "Name: " << this -> getName() << endl << "New size: " << size << endl ); tnlAssert( data != 0, - cerr << "You try to use null pointer to data for tnlConstSharedArray." - << "Name: " << this -> getName() ); + cerr << "You try to use null pointer to data for tnlConstSharedArray." ); this -> size = size; this -> data = data; @@ -96,8 +94,9 @@ void tnlConstSharedArray< Element, Device, Index > :: bind( const Array& array, IndexType index, IndexType size ) { - tnlStaticAssert( Array::DeviceType::DeviceType == DeviceType::DeviceType, - "Attempt to bind arrays between different devices." ); + // TODO: This does not work for static arrays. + //tnlStaticAssert( Array::DeviceType::DeviceType == DeviceType::DeviceType, + // "Attempt to bind arrays between different devices." ); this->data = &( array. getData()[ index ] ); if( ! size ) this->size = array. getSize(); @@ -140,7 +139,6 @@ Element tnlConstSharedArray< Element, Device, Index > :: getElement( Index i ) c { tnlAssert( 0 <= i && i < this -> getSize(), cerr << "Wrong index for getElement method in tnlConstSharedArray with name " - << this -> getName() << " index is " << i << " and array size is " << this -> getSize() ); return tnlArrayOperations< Device >::getMemoryElement( &( this -> data[ i ] ) ); @@ -154,7 +152,6 @@ const Element& tnlConstSharedArray< Element, Device, Index > :: operator[] ( Ind { tnlAssert( 0 <= i && i < this -> getSize(), cerr << "Wrong index for operator[] in tnlConstSharedArray with name " - << this -> getName() << " index is " << i << " and array size is " << this -> getSize() ); // TODO: add static assert - this does not make sense for tnlCudaDevice @@ -240,7 +237,7 @@ template< typename Element, bool tnlConstSharedArray< Element, Device, Index > :: save( tnlFile& file ) const { tnlAssert( this -> size != 0, - cerr << "You try to save empty array. Its name is " << this -> getName() ); + cerr << "You try to save empty array." ); if( ! tnlObject :: save( file ) ) return false; #ifdef HAVE_NOT_CXX11 @@ -251,7 +248,7 @@ bool tnlConstSharedArray< Element, Device, Index > :: save( tnlFile& file ) cons return false; if( ! file. write< Element, Device, Index >( this -> data, this -> size ) ) { - cerr << "I was not able to WRITE tnlConstSharedArray " << this -> getName() + cerr << "I was not able to WRITE tnlConstSharedArray " << " with size " << this -> getSize() << endl; return false; } diff --git a/src/core/arrays/tnlMultiArray.h b/src/core/arrays/tnlMultiArray.h index eb24d7afa552628755684120d775a35ea0b89987..0a9345d5b791152ec8c421ed0de1f62669e2d999 100644 --- a/src/core/arrays/tnlMultiArray.h +++ b/src/core/arrays/tnlMultiArray.h @@ -43,8 +43,6 @@ class tnlMultiArray< 1, Element, Device, Index > : public tnlArray< Element, Dev tnlMultiArray(); - tnlMultiArray( const tnlString& name ); - static tnlString getType(); tnlString getTypeVirtual() const; @@ -124,8 +122,6 @@ class tnlMultiArray< 2, Element, Device, Index > : public tnlArray< Element, Dev tnlMultiArray(); - tnlMultiArray( const tnlString& name ); - static tnlString getType(); tnlString getTypeVirtual() const; @@ -209,8 +205,6 @@ class tnlMultiArray< 3, Element, Device, Index > : public tnlArray< Element, Dev tnlMultiArray(); - tnlMultiArray( const tnlString& name ); - static tnlString getType(); tnlString getTypeVirtual() const; @@ -294,8 +288,6 @@ class tnlMultiArray< 4, Element, Device, Index > : public tnlArray< Element, Dev tnlMultiArray(); - tnlMultiArray( const tnlString& name ); - static tnlString getType(); tnlString getTypeVirtual() const; diff --git a/src/core/arrays/tnlMultiArray1D_impl.h b/src/core/arrays/tnlMultiArray1D_impl.h index b45aabdedb0bf4b5f5d8cb72a2d39070597cd98b..2ac13a53af9fc4bc71a5a5f1f48f1c6ab66d26fd 100644 --- a/src/core/arrays/tnlMultiArray1D_impl.h +++ b/src/core/arrays/tnlMultiArray1D_impl.h @@ -23,12 +23,6 @@ tnlMultiArray< 1, Element, Device, Index > :: tnlMultiArray() { } -template< typename Element, typename Device, typename Index > -tnlMultiArray< 1, Element, Device, Index > :: tnlMultiArray( const tnlString& name ) -{ - this -> setName( name ); -} - template< typename Element, typename Device, typename Index > tnlString tnlMultiArray< 1, Element, Device, Index > :: getType() { @@ -155,10 +149,8 @@ bool tnlMultiArray< 1, Element, Device, Index > :: operator == ( const MultiArra // TODO: Static assert on dimensions tnlAssert( this -> getDimensions() == array. getDimensions(), cerr << "You are attempting to compare two arrays with different dimensions." << endl - << "First array name is " << this -> getName() - << " dimensions are ( " << this -> getDimensions() << " )" << endl - << "Second array is " << array. getName() - << " dimensions are ( " << array. getDimensions() << " )" << endl; ); + << "First array dimensions are ( " << this -> getDimensions() << " )" << endl + << "Second array dimensions are ( " << array. getDimensions() << " )" << endl; ); return tnlArray< Element, Device, Index > :: operator == ( array ); } @@ -176,10 +168,8 @@ tnlMultiArray< 1, Element, Device, Index >& // TODO: Static assert on dimensions tnlAssert( this -> getDimensions() == array. getDimensions(), cerr << "You are attempting to assign two arrays with different dimensions." << endl - << "First array name is " << this -> getName() - << " dimensions are ( " << this -> getDimensions() << " )" << endl - << "Second array is " << array. getName() - << " dimensions are ( " << array. getDimensions() << " )" << endl; ); + << "First array dimensions are ( " << this -> getDimensions() << " )" << endl + << "Second array dimensions are ( " << array. getDimensions() << " )" << endl; ); tnlArray< Element, Device, Index > :: operator = ( array ); return ( *this ); } @@ -192,10 +182,8 @@ tnlMultiArray< 1, Element, Device, Index >& // TODO: Static assert on dimensions tnlAssert( this -> getDimensions() == array. getDimensions(), cerr << "You are attempting to assign two arrays with different dimensions." << endl - << "First array name is " << this -> getName() - << " dimensions are ( " << this -> getDimensions() << " )" << endl - << "Second array is " << array. getName() - << " dimensions are ( " << array. getDimensions() << " )" << endl; ); + << "First array dimensions are ( " << this -> getDimensions() << " )" << endl + << "Second array dimensions are ( " << array. getDimensions() << " )" << endl; ); tnlArray< Element, Device, Index > :: operator = ( array ); return ( *this ); } @@ -205,14 +193,12 @@ bool tnlMultiArray< 1, Element, Device, Index > :: save( tnlFile& file ) const { if( ! tnlArray< Element, Device, Index > :: save( file ) ) { - cerr << "I was not able to write the tnlArray of tnlMultiArray " - << this -> getName() << endl; + cerr << "I was not able to write the tnlArray of tnlMultiArray." << endl; return false; } if( ! dimensions. save( file ) ) { - cerr << "I was not able to write the dimensions of tnlMultiArray " - << this -> getName() << endl; + cerr << "I was not able to write the dimensions of tnlMultiArray." << endl; return false; } return true; @@ -223,14 +209,12 @@ bool tnlMultiArray< 1, Element, Device, Index > :: load( tnlFile& file ) { if( ! tnlArray< Element, Device, Index > :: load( file ) ) { - cerr << "I was not able to read the tnlArray of tnlMultiArray " - << this -> getName() << endl; + cerr << "I was not able to read the tnlArray of tnlMultiArray." << endl; return false; } if( ! dimensions. load( file ) ) { - cerr << "I was not able to read the dimensions of tnlMultiArray " - << this -> getName() << endl; + cerr << "I was not able to read the dimensions of tnlMultiArray." << endl; return false; } return true; diff --git a/src/core/arrays/tnlMultiArray2D_impl.h b/src/core/arrays/tnlMultiArray2D_impl.h index cc10ee13d4ccb96750a2f63df0e02932bbc2c27e..2b51149244a19719c77cfe01b65f47c5484739de 100644 --- a/src/core/arrays/tnlMultiArray2D_impl.h +++ b/src/core/arrays/tnlMultiArray2D_impl.h @@ -25,13 +25,6 @@ tnlMultiArray< 2, Element, Device, Index > :: tnlMultiArray() { } -template< typename Element, typename Device, typename Index > -tnlMultiArray< 2, Element, Device, Index > :: tnlMultiArray( const tnlString& name ) -{ - this -> setName( name ); -} - - template< typename Element, typename Device, typename Index > tnlString tnlMultiArray< 2, Element, Device, Index > :: getType() { @@ -168,10 +161,8 @@ bool tnlMultiArray< 2, Element, Device, Index > :: operator == ( const MultiArra // TODO: Static assert on dimensions tnlAssert( this -> getDimensions() == array. getDimensions(), cerr << "You are attempting to compare two arrays with different dimensions." << endl - << "First array name is " << this -> getName() - << " dimensions are ( " << this -> getDimensions() << " )" << endl - << "Second array is " << array. getName() - << " dimensions are ( " << array. getDimensions() << " )" << endl; ); + << "First array dimensions are ( " << this -> getDimensions() << " )" << endl + << "Second array dimensions are ( " << array. getDimensions() << " )" << endl; ); return tnlArray< Element, Device, Index > :: operator == ( array ); } @@ -189,10 +180,8 @@ tnlMultiArray< 2, Element, Device, Index >& // TODO: Static assert on dimensions tnlAssert( this -> getDimensions() == array. getDimensions(), cerr << "You are attempting to assign two arrays with different dimensions." << endl - << "First array name is " << this -> getName() - << " dimensions are ( " << this -> getDimensions() << " )" << endl - << "Second array is " << array. getName() - << " dimensions are ( " << array. getDimensions() << " )" << endl; ); + << "First array dimensions are ( " << this -> getDimensions() << " )" << endl + << "Second array dimensions are ( " << array. getDimensions() << " )" << endl; ); tnlArray< Element, Device, Index > :: operator = ( array ); return ( *this ); } @@ -205,10 +194,8 @@ tnlMultiArray< 2, Element, Device, Index >& // TODO: Static assert on dimensions tnlAssert( this -> getDimensions() == array. getDimensions(), cerr << "You are attempting to assign two arrays with different dimensions." << endl - << "First array name is " << this -> getName() - << " dimensions are ( " << this -> getDimensions() << " )" << endl - << "Second array is " << array. getName() - << " dimensions are ( " << array. getDimensions() << " )" << endl; ); + << "First array dimensions are ( " << this -> getDimensions() << " )" << endl + << "Second array dimensions are ( " << array. getDimensions() << " )" << endl; ); tnlArray< Element, Device, Index > :: operator = ( array ); return ( *this ); } @@ -218,14 +205,12 @@ bool tnlMultiArray< 2, Element, Device, Index > :: save( tnlFile& file ) const { if( ! tnlArray< Element, Device, Index > :: save( file ) ) { - cerr << "I was not able to write the tnlArray of tnlMultiArray " - << this -> getName() << endl; + cerr << "I was not able to write the tnlArray of tnlMultiArray." << endl; return false; } if( ! dimensions. save( file ) ) { - cerr << "I was not able to write the dimensions of tnlMultiArray " - << this -> getName() << endl; + cerr << "I was not able to write the dimensions of tnlMultiArray." << endl; return false; } return true; @@ -236,14 +221,12 @@ bool tnlMultiArray< 2, Element, Device, Index > :: load( tnlFile& file ) { if( ! tnlArray< Element, Device, Index > :: load( file ) ) { - cerr << "I was not able to read the tnlArray of tnlMultiArray " - << this -> getName() << endl; + cerr << "I was not able to read the tnlArray of tnlMultiArray." << endl; return false; } if( ! dimensions. load( file ) ) { - cerr << "I was not able to read the dimensions of tnlMultiArray " - << this -> getName() << endl; + cerr << "I was not able to read the dimensions of tnlMultiArray." << endl; return false; } return true; diff --git a/src/core/arrays/tnlMultiArray3D_impl.h b/src/core/arrays/tnlMultiArray3D_impl.h index 3cd8dfbd237ba327d54d77d9359041320b95ead0..25a91599dfa95d51d2817818315a711ce3adc916 100644 --- a/src/core/arrays/tnlMultiArray3D_impl.h +++ b/src/core/arrays/tnlMultiArray3D_impl.h @@ -25,12 +25,6 @@ tnlMultiArray< 3, Element, Device, Index > :: tnlMultiArray() { } -template< typename Element, typename Device, typename Index > -tnlMultiArray< 3, Element, Device, Index > :: tnlMultiArray( const tnlString& name ) -{ - this -> setName( name ); -} - template< typename Element, typename Device, typename Index > tnlString tnlMultiArray< 3, Element, Device, Index > :: getType() { @@ -191,10 +185,8 @@ bool tnlMultiArray< 3, Element, Device, Index > :: operator == ( const MultiArra // TODO: Static assert on dimensions tnlAssert( this -> getDimensions() == array. getDimensions(), cerr << "You are attempting to compare two arrays with different dimensions." << endl - << "First array name is " << this -> getName() - << " dimensions are ( " << this -> getDimensions() << " )" << endl - << "Second array is " << array. getName() - << " dimensions are ( " << array. getDimensions() << " )" << endl; ); + << "First array dimensions are ( " << this -> getDimensions() << " )" << endl + << "Second array dimensions are ( " << array. getDimensions() << " )" << endl; ); return tnlArray< Element, Device, Index > :: operator == ( array ); } @@ -212,10 +204,8 @@ tnlMultiArray< 3, Element, Device, Index >& // TODO: Static assert on dimensions tnlAssert( this -> getDimensions() == array. getDimensions(), cerr << "You are attempting to assign two arrays with different dimensions." << endl - << "First array name is " << this -> getName() - << " dimensions are ( " << this -> getDimensions() << " )" << endl - << "Second array is " << array. getName() - << " dimensions are ( " << array. getDimensions() << " )" << endl; ); + << "First array dimensions are ( " << this -> getDimensions() << " )" << endl + << "Second array dimensions are ( " << array. getDimensions() << " )" << endl; ); tnlArray< Element, Device, Index > :: operator = ( array ); return ( *this ); } @@ -228,10 +218,8 @@ tnlMultiArray< 3, Element, Device, Index >& // TODO: Static assert on dimensions tnlAssert( this -> getDimensions() == array. getDimensions(), cerr << "You are attempting to assign two arrays with different dimensions." << endl - << "First array name is " << this -> getName() - << " dimensions are ( " << this -> getDimensions() << " )" << endl - << "Second array is " << array. getName() - << " dimensions are ( " << array. getDimensions() << " )" << endl; ); + << "First array dimensions are ( " << this -> getDimensions() << " )" << endl + << "Second array dimensions are ( " << array. getDimensions() << " )" << endl; ); tnlArray< Element, Device, Index > :: operator = ( array ); return ( *this ); } @@ -241,14 +229,12 @@ bool tnlMultiArray< 3, Element, Device, Index > :: save( tnlFile& file ) const { if( ! tnlArray< Element, Device, Index > :: save( file ) ) { - cerr << "I was not able to write the tnlArray of tnlMultiArray " - << this -> getName() << endl; + cerr << "I was not able to write the tnlArray of tnlMultiArray." << endl; return false; } if( ! dimensions. save( file ) ) { - cerr << "I was not able to write the dimensions of tnlMultiArray " - << this -> getName() << endl; + cerr << "I was not able to write the dimensions of tnlMultiArray." << endl; return false; } return true; @@ -259,14 +245,12 @@ bool tnlMultiArray< 3, Element, Device, Index > :: load( tnlFile& file ) { if( ! tnlArray< Element, Device, Index > :: load( file ) ) { - cerr << "I was not able to read the tnlArray of tnlMultiArray " - << this -> getName() << endl; + cerr << "I was not able to read the tnlArray of tnlMultiArray." << endl; return false; } if( ! dimensions. load( file ) ) { - cerr << "I was not able to read the dimensions of tnlMultiArray " - << this -> getName() << endl; + cerr << "I was not able to read the dimensions of tnlMultiArray." << endl; return false; } return true; diff --git a/src/core/arrays/tnlMultiArray4D_impl.h b/src/core/arrays/tnlMultiArray4D_impl.h index a2ebfcd21f709f8da7ad77d1ec96d3ee54f03a06..67d492fa119a6b6b980e5228702b060a694becfc 100644 --- a/src/core/arrays/tnlMultiArray4D_impl.h +++ b/src/core/arrays/tnlMultiArray4D_impl.h @@ -25,12 +25,6 @@ tnlMultiArray< 4, Element, Device, Index > :: tnlMultiArray() { } -template< typename Element, typename Device, typename Index > -tnlMultiArray< 4, Element, Device, Index > :: tnlMultiArray( const tnlString& name ) -{ - this -> setName( name ); -} - template< typename Element, typename Device, typename Index > tnlString tnlMultiArray< 4, Element, Device, Index > :: getType() { @@ -205,10 +199,8 @@ bool tnlMultiArray< 4, Element, Device, Index > :: operator == ( const MultiArra // TODO: Static assert on dimensions tnlAssert( this -> getDimensions() == array. getDimensions(), cerr << "You are attempting to compare two arrays with different dimensions." << endl - << "First array name is " << this -> getName() - << " dimensions are ( " << this -> getDimensions() << " )" << endl - << "Second array is " << array. getName() - << " dimensions are ( " << array. getDimensions() << " )" << endl; ); + << "First array dimensions are ( " << this -> getDimensions() << " )" << endl + << "Second array dimensions are ( " << array. getDimensions() << " )" << endl; ); return tnlArray< Element, Device, Index > :: operator == ( array ); } @@ -226,10 +218,8 @@ tnlMultiArray< 4, Element, Device, Index >& // TODO: Static assert on dimensions tnlAssert( this -> getDimensions() == array. getDimensions(), cerr << "You are attempting to assign two arrays with different dimensions." << endl - << "First array name is " << this -> getName() - << " dimensions are ( " << this -> getDimensions() << " )" << endl - << "Second array is " << array. getName() - << " dimensions are ( " << array. getDimensions() << " )" << endl; ); + << "First array dimensions are ( " << this -> getDimensions() << " )" << endl + << "Second array dimensions are ( " << array. getDimensions() << " )" << endl; ); tnlArray< Element, Device, Index > :: operator = ( array ); return ( *this ); } @@ -242,10 +232,8 @@ tnlMultiArray< 4, Element, Device, Index >& // TODO: Static assert on dimensions tnlAssert( this -> getDimensions() == array. getDimensions(), cerr << "You are attempting to assign two arrays with different dimensions." << endl - << "First array name is " << this -> getName() - << " dimensions are ( " << this -> getDimensions() << " )" << endl - << "Second array is " << array. getName() - << " dimensions are ( " << array. getDimensions() << " )" << endl; ); + << "First array dimensions are ( " << this -> getDimensions() << " )" << endl + << "Second array dimensions are ( " << array. getDimensions() << " )" << endl; ); tnlArray< Element, Device, Index > :: operator = ( array ); return ( *this ); } @@ -255,14 +243,12 @@ bool tnlMultiArray< 4, Element, Device, Index > :: save( tnlFile& file ) const { if( ! tnlArray< Element, Device, Index > :: save( file ) ) { - cerr << "I was not able to write the tnlArray of tnlMultiArray " - << this -> getName() << endl; + cerr << "I was not able to write the tnlArray of tnlMultiArray." << endl; return false; } if( ! dimensions. save( file ) ) { - cerr << "I was not able to write the dimensions of tnlMultiArray " - << this -> getName() << endl; + cerr << "I was not able to write the dimensions of tnlMultiArray." << endl; return false; } return true; @@ -273,14 +259,12 @@ bool tnlMultiArray< 4, Element, Device, Index > :: load( tnlFile& file ) { if( ! tnlArray< Element, Device, Index > :: load( file ) ) { - cerr << "I was not able to read the tnlArray of tnlMultiArray " - << this -> getName() << endl; + cerr << "I was not able to read the tnlArray of tnlMultiArray." << endl; return false; } if( ! dimensions. load( file ) ) { - cerr << "I was not able to read the dimensions of tnlMultiArray " - << this -> getName() << endl; + cerr << "I was not able to read the dimensions of tnlMultiArray." << endl; return false; } return true; diff --git a/src/core/arrays/tnlSharedArray_impl.h b/src/core/arrays/tnlSharedArray_impl.h index c58802aef78569d31543cfb22f2028abea756347..d4b998073e4cf737499a530c04b8f5dbe449494b 100644 --- a/src/core/arrays/tnlSharedArray_impl.h +++ b/src/core/arrays/tnlSharedArray_impl.h @@ -104,11 +104,9 @@ void tnlSharedArray< Element, Device, Index > :: bind( Element* data, { tnlAssert( size >= 0, cerr << "You try to set size of tnlSharedArray to negative value." - << "Name: " << this -> getName() << endl << "New size: " << size << endl ); tnlAssert( data != 0, - cerr << "You try to use null pointer to data for tnlSharedArray." - << "Name: " << this -> getName() ); + cerr << "You try to use null pointer to data for tnlSharedArray." ); this -> size = size; this -> data = data; @@ -122,8 +120,9 @@ void tnlSharedArray< Element, Device, Index > :: bind( Array& array, IndexType index, IndexType size ) { - tnlStaticAssert( Array::DeviceType::DeviceType == DeviceType::DeviceType, - "Attempt to bind arrays between different devices." ); + //tnlStaticAssert( Array::DeviceType::DeviceType == DeviceType::DeviceType, + // "Attempt to bind arrays between different devices." ); + // TODO: fix this - it does nto work with tnlStaticArray this->data = &( array. getData()[ index ] ); if( ! size ) this->size = array. getSize(); @@ -184,8 +183,7 @@ template< typename Element, void tnlSharedArray< Element, Device, Index > :: setElement( const Index i, const Element& x ) { tnlAssert( 0 <= i && i < this -> getSize(), - cerr << "Wrong index for setElement method in tnlSharedArray with name " - << this -> getName() + cerr << "Wrong index for setElement method in tnlSharedArray " << " index is " << i << " and array size is " << this -> getSize() ); return tnlArrayOperations< Device >::setMemoryElement( & ( this -> data[ i ] ), x ); @@ -197,8 +195,7 @@ template< typename Element, Element tnlSharedArray< Element, Device, Index > :: getElement( Index i ) const { tnlAssert( 0 <= i && i < this -> getSize(), - cerr << "Wrong index for getElement method in tnlSharedArray with name " - << this -> getName() + cerr << "Wrong index for getElement method in tnlSharedArray " << " index is " << i << " and array size is " << this -> getSize() ); return tnlArrayOperations< Device >::getMemoryElement( &( this -> data[ i ] ) ); @@ -211,8 +208,7 @@ __cuda_callable__ Element& tnlSharedArray< Element, Device, Index > :: operator[] ( Index i ) { tnlAssert( 0 <= i && i < this -> getSize(), - cerr << "Wrong index for operator[] in tnlSharedArray with name " - << this -> getName() + cerr << "Wrong index for operator[] in tnlSharedArray " << " index is " << i << " and array size is " << this -> getSize() ); return this->data[ i ]; @@ -225,8 +221,7 @@ __cuda_callable__ const Element& tnlSharedArray< Element, Device, Index > :: operator[] ( Index i ) const { tnlAssert( 0 <= i && i < this -> getSize(), - cerr << "Wrong index for operator[] in tnlSharedArray with name " - << this -> getName() + cerr << "Wrong index for operator[] in tnlSharedArray " << " index is " << i << " and array size is " << this -> getSize() ); return this->data[ i ]; @@ -239,9 +234,7 @@ tnlSharedArray< Element, Device, Index >& tnlSharedArray< Element, Device, Index > :: operator = ( const tnlSharedArray< Element, Device, Index >& array ) { tnlAssert( array. getSize() == this -> getSize(), - cerr << "Source name: " << array. getName() << endl - << "Source size: " << array. getSize() << endl - << "Target name: " << this -> getName() << endl + cerr << "Source size: " << array. getSize() << endl << "Target size: " << this -> getSize() << endl ); tnlArrayOperations< Device > :: template copyMemory< Element, @@ -260,9 +253,7 @@ template< typename Element, tnlSharedArray< Element, Device, Index >& tnlSharedArray< Element, Device, Index > :: operator = ( const Array& array ) { tnlAssert( array. getSize() == this -> getSize(), - cerr << "Source name: " << array. getName() << endl - << "Source size: " << array. getSize() << endl - << "Target name: " << this -> getName() << endl + cerr << "Source size: " << array. getSize() << endl << "Target size: " << this -> getSize() << endl ); tnlArrayOperations< typename Array :: DeviceType, Device > :: @@ -307,8 +298,7 @@ template< typename Element, typename Index > void tnlSharedArray< Element, Device, Index > :: setValue( const Element& e ) { - tnlAssert( this -> size != 0, - cerr << "Array name is " << this -> getName() ); + tnlAssert( this -> size != 0, ); tnlArrayOperations< Device >::template setMemory< Element, Index > ( this -> getData(), e, this -> getSize() ); @@ -354,7 +344,7 @@ template< typename Element, bool tnlSharedArray< Element, Device, Index > :: save( tnlFile& file ) const { tnlAssert( this -> size != 0, - cerr << "You try to save empty array. Its name is " << this -> getName() ); + cerr << "You try to save empty array." << endl ); if( ! tnlObject :: save( file ) ) return false; #ifdef HAVE_NOT_CXX11 @@ -365,8 +355,7 @@ bool tnlSharedArray< Element, Device, Index > :: save( tnlFile& file ) const return false; if( ! file. write< Element, Device, Index >( this -> data, this -> size ) ) { - cerr << "I was not able to WRITE tnlSharedArray " << this -> getName() - << " with size " << this -> getSize() << endl; + cerr << "I was not able to WRITE tnlSharedArray with size " << this -> getSize() << endl; return false; } return true; @@ -398,16 +387,14 @@ bool tnlSharedArray< Element, Device, Index > :: load( tnlFile& file ) if( _size != this->size ) { cerr << "Error: The size " << _size << " of the data to be load is different from the " << - "allocated array. This is not possible in the shared array ( in " << this->getName() << - " )." << endl; + "allocated array. This is not possible in the shared array." << endl; return false; } if( _size ) { if( ! file. read< Element, Device, Index >( this -> data, this -> size ) ) { - cerr << "I was not able to READ tnlSharedArray " << this -> getName() - << " with size " << this -> getSize() << endl; + cerr << "I was not able to READ tnlSharedArray with size " << this -> getSize() << endl; return false; } } diff --git a/src/core/arrays/tnlStaticArray.h b/src/core/arrays/tnlStaticArray.h index 6ac981143391207f81bc887bc98fddacdd090cb9..c83d809d3681e7a4c228bde447501808ddf84958 100644 --- a/src/core/arrays/tnlStaticArray.h +++ b/src/core/arrays/tnlStaticArray.h @@ -100,6 +100,8 @@ class tnlStaticArray bool load( tnlFile& file); void sort(); + + ostream& write( ostream& str, const char* separator = " " ) const; protected: Element data[ Size ]; @@ -192,6 +194,8 @@ class tnlStaticArray< 1, Element > bool load( tnlFile& file); void sort(); + + ostream& write( ostream& str, const char* separator = " " ) const; protected: Element data[ size ]; @@ -301,6 +305,8 @@ class tnlStaticArray< 2, Element > bool load( tnlFile& file); void sort(); + + ostream& write( ostream& str, const char* separator = " " ) const; protected: Element data[ size ]; @@ -422,6 +428,8 @@ class tnlStaticArray< 3, Element > bool load( tnlFile& file); void sort(); + + ostream& write( ostream& str, const char* separator = " " ) const; protected: Element data[ size ]; diff --git a/src/core/arrays/tnlStaticArray1D_impl.h b/src/core/arrays/tnlStaticArray1D_impl.h index 170488b655ba13fe968628f860d81ba838b1ed6b..e7779e9eae31f7f2b2bd7db2703ef3164e74999c 100644 --- a/src/core/arrays/tnlStaticArray1D_impl.h +++ b/src/core/arrays/tnlStaticArray1D_impl.h @@ -202,6 +202,13 @@ void tnlStaticArray< 1, Element >::sort() { } +template< typename Element > +ostream& tnlStaticArray< 1, Element >::write( ostream& str, const char* separator ) const +{ + str << data[ 0 ]; + return str; +} + #ifdef TEMPLATE_EXPLICIT_INSTANTIATION // TODO: it does not work with CUDA diff --git a/src/core/arrays/tnlStaticArray2D_impl.h b/src/core/arrays/tnlStaticArray2D_impl.h index 3e3cd35820ec1c83a86a4ded314d5bd10c5e28f4..dcbe0cfce801f205031f2398fad5c9cc88351963 100644 --- a/src/core/arrays/tnlStaticArray2D_impl.h +++ b/src/core/arrays/tnlStaticArray2D_impl.h @@ -239,6 +239,13 @@ void tnlStaticArray< 2, Element >::sort() Swap( data[ 0 ], data[ 1 ] ); } +template< typename Element > +ostream& tnlStaticArray< 2, Element >::write( ostream& str, const char* separator ) const +{ + str << data[ 0 ] << separator << data[ 1 ]; + return str; +} + #ifdef TEMPLATE_EXPLICIT_INSTANTIATION // TODO: it does not work with CUDA diff --git a/src/core/arrays/tnlStaticArray3D_impl.h b/src/core/arrays/tnlStaticArray3D_impl.h index 5b9755f0281d614177db0e781d2986c57c52030f..95740a73dea224d407e9893e85eb29c6631e2769 100644 --- a/src/core/arrays/tnlStaticArray3D_impl.h +++ b/src/core/arrays/tnlStaticArray3D_impl.h @@ -270,6 +270,14 @@ void tnlStaticArray< 3, Element >::sort() Swap( data[ 0 ], data[ 1 ] ); } +template< typename Element > +ostream& tnlStaticArray< 3, Element >::write( ostream& str, const char* separator ) const +{ + str << data[ 0 ] << separator << data[ 1 ] << separator << data[ 2 ]; + return str; +} + + #ifdef TEMPLATE_EXPLICIT_INSTANTIATION // TODO: it does not work with CUDA diff --git a/src/core/arrays/tnlStaticArray_impl.h b/src/core/arrays/tnlStaticArray_impl.h index 08c5606e4f387b0763060ffcb1a05e3b6176d717..e2abac44e2dfec987097f3fee0f4d4c2687c63d2 100644 --- a/src/core/arrays/tnlStaticArray_impl.h +++ b/src/core/arrays/tnlStaticArray_impl.h @@ -203,15 +203,25 @@ void tnlStaticArray< Size, Element >::sort() Swap( data[ i ], data[ i+1 ] ); } +template< int Size, typename Element > +ostream& tnlStaticArray< Size, Element >::write( ostream& str, const char* separator ) const +{ + for( int i = 0; i < Size - 1; i++ ) + str << data[ i ] << separator; + str << data[ Size - 1 ]; + return str; +} + template< int Size, typename Element > ostream& operator << ( ostream& str, const tnlStaticArray< Size, Element >& a ) { - for( int i = 0; i < Size - 1; i ++ ) + a.write( str, "," ); + /*for( int i = 0; i < Size - 1; i ++ ) { str << a[ i ] << ", "; } - str << a[ Size - 1 ]; + str << a[ Size - 1 ];*/ return str; }; diff --git a/src/core/containers/tnlContainer_impl.h b/src/core/containers/tnlContainer_impl.h index 5a0d10946a70d18cdc5894c685dc95d858fefb21..7a536a860e43ba433574a7809e1c5ae0827ef6ab 100644 --- a/src/core/containers/tnlContainer_impl.h +++ b/src/core/containers/tnlContainer_impl.h @@ -88,8 +88,7 @@ bool tnlContainer< Element, Device, Index >::save( tnlFile& file ) const if( ! tnlObject::save( file ) || ! this->data.save( file ) ) { - cerr << "I am no able to save " << this->getType() - << " " << this->getName() << "." << endl; + cerr << "I am no able to save " << this->getType() << "." << endl; return false; } return true; @@ -101,8 +100,7 @@ bool tnlContainer< Element, Device, Index >::load( tnlFile& file ) if( ! tnlObject::load( file ) || ! this->data.load( file ) ) { - cerr << "I am no able to load " << this->getType() - << " " << this->getName() << "." << endl; + cerr << "I am no able to load " << this->getType() << "." << endl; return false; } return true; diff --git a/src/core/containers/tnlStaticContainer_impl.h b/src/core/containers/tnlStaticContainer_impl.h index 2ea081a9a3bdfda26577cc086832ef55de3c558d..009e43b89947d7c6bf4a396eadb41908ec348865 100644 --- a/src/core/containers/tnlStaticContainer_impl.h +++ b/src/core/containers/tnlStaticContainer_impl.h @@ -70,8 +70,7 @@ bool tnlStaticContainer< Size, Element >::save( tnlFile& file ) const if( ! tnlObject::save( file ) || ! this->data.save( file ) ) { - cerr << "I am no able to save " << this->getType() - << " " << this->getName() << "." << endl; + cerr << "I am no able to save " << this->getType() << "." << endl; return false; } return true; @@ -83,8 +82,7 @@ bool tnlStaticContainer< Size, Element >::load( tnlFile& file ) if( ! tnlObject::load( file ) || ! this->data.load( file ) ) { - cerr << "I am no able to load " << this->getType() - << " " << this->getName() << "." << endl; + cerr << "I am no able to load " << this->getType() << "." << endl; return false; } return true; diff --git a/src/core/cuda/CMakeLists.txt b/src/core/cuda/CMakeLists.txt index 3530dda77a5aed1f1b2acdbd160af0a26555b74d..815e59463774a91e8ecd9650d739837b1a332efb 100755 --- a/src/core/cuda/CMakeLists.txt +++ b/src/core/cuda/CMakeLists.txt @@ -20,6 +20,7 @@ IF( BUILD_CUDA ) ${CURRENT_DIR}/cuda-reduction-abs-max_impl.cu ${CURRENT_DIR}/cuda-reduction-and_impl.cu ${CURRENT_DIR}/cuda-reduction-or_impl.cu + ${CURRENT_DIR}/cuda-reduction-l2-norm_impl.cu ${CURRENT_DIR}/cuda-reduction-lp-norm_impl.cu ${CURRENT_DIR}/cuda-reduction-equalities_impl.cu ${CURRENT_DIR}/cuda-reduction-inequalities_impl.cu @@ -30,9 +31,10 @@ IF( BUILD_CUDA ) ${CURRENT_DIR}/cuda-reduction-diff-abs-sum_impl.cu ${CURRENT_DIR}/cuda-reduction-diff-abs-min_impl.cu ${CURRENT_DIR}/cuda-reduction-diff-abs-max_impl.cu + ${CURRENT_DIR}/cuda-reduction-diff-l2-norm_impl.cu ${CURRENT_DIR}/cuda-reduction-diff-lp-norm_impl.cu ${CURRENT_DIR}/cuda-prefix-sum_impl.cu - PARENT_SCOPE ) + PARENT_SCOPE ) endif() set( tnl_core_cuda_SOURCES diff --git a/src/core/cuda/cuda-prefix-sum_impl.cu b/src/core/cuda/cuda-prefix-sum_impl.cu index 74f3e85fb7c75554e37e3f4075aabcf8fa2092bd..58393298d201ff66a4c379c5791f8f3ce9c50e26 100644 --- a/src/core/cuda/cuda-prefix-sum_impl.cu +++ b/src/core/cuda/cuda-prefix-sum_impl.cu @@ -23,7 +23,7 @@ template bool cudaPrefixSum( const int size, const int blockSize, const int *deviceInput, int* deviceOutput, - const tnlParallelReductionSum< int, int >& operation, + tnlParallelReductionSum< int, int >& operation, const enumPrefixSumType prefixSumType ); @@ -32,7 +32,7 @@ template bool cudaPrefixSum( const int size, const int blockSize, const float *deviceInput, float* deviceOutput, - const tnlParallelReductionSum< float, int >& operation, + tnlParallelReductionSum< float, int >& operation, const enumPrefixSumType prefixSumType ); #endif @@ -40,7 +40,7 @@ template bool cudaPrefixSum( const int size, const int blockSize, const double *deviceInput, double* deviceOutput, - const tnlParallelReductionSum< double, int >& operation, + tnlParallelReductionSum< double, int >& operation, const enumPrefixSumType prefixSumType ); #ifdef INSTANTIATE_LONG_DOUBLE @@ -48,7 +48,7 @@ template bool cudaPrefixSum( const int size, const int blockSize, const long double *deviceInput, long double* deviceOutput, - const tnlParallelReductionSum< long double, int >& operation, + tnlParallelReductionSum< long double, int >& operation, const enumPrefixSumType prefixSumType ); #endif @@ -57,7 +57,7 @@ template bool cudaPrefixSum( const long int size, const long int blockSize, const int *deviceInput, int* deviceOutput, - const tnlParallelReductionSum< int, long int >& operation, + tnlParallelReductionSum< int, long int >& operation, const enumPrefixSumType prefixSumType ); @@ -66,7 +66,7 @@ template bool cudaPrefixSum( const long int size, const long int blockSize, const float *deviceInput, float* deviceOutput, - const tnlParallelReductionSum< float, long int >& operation, + tnlParallelReductionSum< float, long int >& operation, const enumPrefixSumType prefixSumType ); #endif @@ -74,7 +74,7 @@ template bool cudaPrefixSum( const long int size, const long int blockSize, const double *deviceInput, double* deviceOutput, - const tnlParallelReductionSum< double, long int >& operation, + tnlParallelReductionSum< double, long int >& operation, const enumPrefixSumType prefixSumType ); #ifdef INSTANTIATE_LONG_DOUBLE @@ -82,7 +82,7 @@ template bool cudaPrefixSum( const long int size, const long int blockSize, const long double *deviceInput, long double* deviceOutput, - const tnlParallelReductionSum< long double, long int >& operation, + tnlParallelReductionSum< long double, long int >& operation, const enumPrefixSumType prefixSumType ); #endif #endif diff --git a/src/core/cuda/cuda-prefix-sum_impl.h b/src/core/cuda/cuda-prefix-sum_impl.h index ad2d02aa3341c21056b9e2994df93918aa38db52..2c5644cc20855fd9cd7a897e3236997b7218693a 100644 --- a/src/core/cuda/cuda-prefix-sum_impl.h +++ b/src/core/cuda/cuda-prefix-sum_impl.h @@ -30,7 +30,7 @@ template< typename DataType, typename Operation, typename Index > __global__ void cudaFirstPhaseBlockPrefixSum( const enumPrefixSumType prefixSumType, - const Operation operation, + Operation operation, const Index size, const Index elementsInBlock, const DataType* input, @@ -159,7 +159,7 @@ __global__ void cudaFirstPhaseBlockPrefixSum( const enumPrefixSumType prefixSumT template< typename DataType, typename Operation, typename Index > -__global__ void cudaSecondPhaseBlockPrefixSum( const Operation operation, +__global__ void cudaSecondPhaseBlockPrefixSum( Operation operation, const Index size, const Index elementsInBlock, const Index gridShift, @@ -186,7 +186,7 @@ template< typename DataType, typename Operation, typename Index > bool cudaRecursivePrefixSum( const enumPrefixSumType prefixSumType, - const Operation& operation, + Operation& operation, const Index size, const Index blockSize, const Index elementsInBlock, @@ -276,7 +276,7 @@ template< typename DataType, typename Operation, typename Index > bool cudaGridPrefixSum( enumPrefixSumType prefixSumType, - const Operation& operation, + Operation& operation, const Index size, const Index blockSize, const Index elementsInBlock, @@ -313,7 +313,7 @@ bool cudaPrefixSum( const Index size, const Index blockSize, const DataType *deviceInput, DataType* deviceOutput, - const Operation& operation, + Operation& operation, const enumPrefixSumType prefixSumType ) { /**** @@ -361,7 +361,7 @@ extern template bool cudaPrefixSum( const int size, const int blockSize, const int *deviceInput, int* deviceOutput, - const tnlParallelReductionSum< int, int >& operation, + tnlParallelReductionSum< int, int >& operation, const enumPrefixSumType prefixSumType ); @@ -369,14 +369,14 @@ extern template bool cudaPrefixSum( const int size, const int blockSize, const float *deviceInput, float* deviceOutput, - const tnlParallelReductionSum< float, int >& operation, + tnlParallelReductionSum< float, int >& operation, const enumPrefixSumType prefixSumType ); extern template bool cudaPrefixSum( const int size, const int blockSize, const double *deviceInput, double* deviceOutput, - const tnlParallelReductionSum< double, int >& operation, + tnlParallelReductionSum< double, int >& operation, const enumPrefixSumType prefixSumType ); #ifdef INSTANTIATE_LONG_DOUBLE @@ -384,7 +384,7 @@ extern template bool cudaPrefixSum( const int size, const int blockSize, const long double *deviceInput, long double* deviceOutput, - const tnlParallelReductionSum< long double, int >& operation, + tnlParallelReductionSum< long double, int >& operation, const enumPrefixSumType prefixSumType ); #endif @@ -393,7 +393,7 @@ extern template bool cudaPrefixSum( const long int size, const long int blockSize, const int *deviceInput, int* deviceOutput, - const tnlParallelReductionSum< int, long int >& operation, + tnlParallelReductionSum< int, long int >& operation, const enumPrefixSumType prefixSumType ); @@ -401,14 +401,14 @@ extern template bool cudaPrefixSum( const long int size, const long int blockSize, const float *deviceInput, float* deviceOutput, - const tnlParallelReductionSum< float, long int >& operation, + tnlParallelReductionSum< float, long int >& operation, const enumPrefixSumType prefixSumType ); extern template bool cudaPrefixSum( const long int size, const long int blockSize, const double *deviceInput, double* deviceOutput, - const tnlParallelReductionSum< double, long int >& operation, + tnlParallelReductionSum< double, long int >& operation, const enumPrefixSumType prefixSumType ); #ifdef INSTANTIATE_LONG_DOUBLE @@ -416,7 +416,7 @@ extern template bool cudaPrefixSum( const long int size, const long int blockSize, const long double *deviceInput, long double* deviceOutput, - const tnlParallelReductionSum< long double, long int >& operation, + tnlParallelReductionSum< long double, long int >& operation, const enumPrefixSumType prefixSumType ); #endif #endif diff --git a/src/core/cuda/cuda-reduction-abs-max_impl.cu b/src/core/cuda/cuda-reduction-abs-max_impl.cu index 8540fc71a381ba90b2db7c341abe24ff1e60f74a..e69a225ada6cc40b06b76999336c629f3c0c51b0 100644 --- a/src/core/cuda/cuda-reduction-abs-max_impl.cu +++ b/src/core/cuda/cuda-reduction-abs-max_impl.cu @@ -25,28 +25,28 @@ */ template bool reductionOnCudaDevice< tnlParallelReductionAbsMax< char, int > > - ( const tnlParallelReductionAbsMax< char, int >& operation, + ( tnlParallelReductionAbsMax< char, int >& operation, const typename tnlParallelReductionAbsMax< char, int > :: IndexType size, const typename tnlParallelReductionAbsMax< char, int > :: RealType* deviceInput1, const typename tnlParallelReductionAbsMax< char, int > :: RealType* deviceInput2, typename tnlParallelReductionAbsMax< char, int > :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionAbsMax< int, int > > - ( const tnlParallelReductionAbsMax< int, int >& operation, + ( tnlParallelReductionAbsMax< int, int >& operation, const typename tnlParallelReductionAbsMax< int, int > :: IndexType size, const typename tnlParallelReductionAbsMax< int, int > :: RealType* deviceInput1, const typename tnlParallelReductionAbsMax< int, int > :: RealType* deviceInput2, typename tnlParallelReductionAbsMax< int, int > :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionAbsMax< float, int > > - ( const tnlParallelReductionAbsMax< float, int >& operation, + ( tnlParallelReductionAbsMax< float, int >& operation, const typename tnlParallelReductionAbsMax< float, int > :: IndexType size, const typename tnlParallelReductionAbsMax< float, int > :: RealType* deviceInput1, const typename tnlParallelReductionAbsMax< float, int > :: RealType* deviceInput2, typename tnlParallelReductionAbsMax< float, int> :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionAbsMax< double, int > > - ( const tnlParallelReductionAbsMax< double, int>& operation, + ( tnlParallelReductionAbsMax< double, int>& operation, const typename tnlParallelReductionAbsMax< double, int > :: IndexType size, const typename tnlParallelReductionAbsMax< double, int > :: RealType* deviceInput1, const typename tnlParallelReductionAbsMax< double, int > :: RealType* deviceInput2, @@ -54,7 +54,7 @@ template bool reductionOnCudaDevice< tnlParallelReductionAbsMax< double, int > > #ifdef INSTANTIATE_LONG_DOUBLE template bool reductionOnCudaDevice< tnlParallelReductionAbsMax< long double, int > > - ( const tnlParallelReductionAbsMax< long double, int>& operation, + ( tnlParallelReductionAbsMax< long double, int>& operation, const typename tnlParallelReductionAbsMax< long double, int > :: IndexType size, const typename tnlParallelReductionAbsMax< long double, int > :: RealType* deviceInput1, const typename tnlParallelReductionAbsMax< long double, int > :: RealType* deviceInput2, @@ -62,7 +62,7 @@ template bool reductionOnCudaDevice< tnlParallelReductionAbsMax< long double, in #endif template bool reductionOnCudaDevice< tnlParallelReductionAbsMax< char, long int > > - ( const tnlParallelReductionAbsMax< char, long int >& operation, + ( tnlParallelReductionAbsMax< char, long int >& operation, const typename tnlParallelReductionAbsMax< char, long int > :: IndexType size, const typename tnlParallelReductionAbsMax< char, long int > :: RealType* deviceInput1, const typename tnlParallelReductionAbsMax< char, long int > :: RealType* deviceInput2, @@ -70,21 +70,21 @@ template bool reductionOnCudaDevice< tnlParallelReductionAbsMax< char, long int #ifdef INSTANTIATE_LONG_INT template bool reductionOnCudaDevice< tnlParallelReductionAbsMax< int, long int > > - ( const tnlParallelReductionAbsMax< int, long int >& operation, + ( tnlParallelReductionAbsMax< int, long int >& operation, const typename tnlParallelReductionAbsMax< int, long int > :: IndexType size, const typename tnlParallelReductionAbsMax< int, long int > :: RealType* deviceInput1, const typename tnlParallelReductionAbsMax< int, long int > :: RealType* deviceInput2, typename tnlParallelReductionAbsMax< int, long int > :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionAbsMax< float, long int > > - ( const tnlParallelReductionAbsMax< float, long int >& operation, + ( tnlParallelReductionAbsMax< float, long int >& operation, const typename tnlParallelReductionAbsMax< float, long int > :: IndexType size, const typename tnlParallelReductionAbsMax< float, long int > :: RealType* deviceInput1, const typename tnlParallelReductionAbsMax< float, long int > :: RealType* deviceInput2, typename tnlParallelReductionAbsMax< float, long int> :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionAbsMax< double, long int > > - ( const tnlParallelReductionAbsMax< double, long int>& operation, + ( tnlParallelReductionAbsMax< double, long int>& operation, const typename tnlParallelReductionAbsMax< double, long int > :: IndexType size, const typename tnlParallelReductionAbsMax< double, long int > :: RealType* deviceInput1, const typename tnlParallelReductionAbsMax< double, long int > :: RealType* deviceInput2, @@ -92,7 +92,7 @@ template bool reductionOnCudaDevice< tnlParallelReductionAbsMax< double, long in #ifdef INSTANTIATE_LONG_DOUBLE template bool reductionOnCudaDevice< tnlParallelReductionAbsMax< long double, long int > > - ( const tnlParallelReductionAbsMax< long double, long int>& operation, + ( tnlParallelReductionAbsMax< long double, long int>& operation, const typename tnlParallelReductionAbsMax< long double, long int > :: IndexType size, const typename tnlParallelReductionAbsMax< long double, long int > :: RealType* deviceInput1, const typename tnlParallelReductionAbsMax< long double, long int > :: RealType* deviceInput2, diff --git a/src/core/cuda/cuda-reduction-abs-min_impl.cu b/src/core/cuda/cuda-reduction-abs-min_impl.cu index 629fa37ddcf71fb4adacaf7e7e872fa938fda10c..21da19efa4345e2a1cb5251aef1bf2ee92607a67 100644 --- a/src/core/cuda/cuda-reduction-abs-min_impl.cu +++ b/src/core/cuda/cuda-reduction-abs-min_impl.cu @@ -25,28 +25,28 @@ */ template bool reductionOnCudaDevice< tnlParallelReductionAbsMin< char, int > > - ( const tnlParallelReductionAbsMin< char, int >& operation, + ( tnlParallelReductionAbsMin< char, int >& operation, const typename tnlParallelReductionAbsMin< char, int > :: IndexType size, const typename tnlParallelReductionAbsMin< char, int > :: RealType* deviceInput1, const typename tnlParallelReductionAbsMin< char, int > :: RealType* deviceInput2, typename tnlParallelReductionAbsMin< char, int > :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionAbsMin< int, int > > - ( const tnlParallelReductionAbsMin< int, int >& operation, + ( tnlParallelReductionAbsMin< int, int >& operation, const typename tnlParallelReductionAbsMin< int, int > :: IndexType size, const typename tnlParallelReductionAbsMin< int, int > :: RealType* deviceInput1, const typename tnlParallelReductionAbsMin< int, int > :: RealType* deviceInput2, typename tnlParallelReductionAbsMin< int, int > :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionAbsMin< float, int > > - ( const tnlParallelReductionAbsMin< float, int >& operation, + ( tnlParallelReductionAbsMin< float, int >& operation, const typename tnlParallelReductionAbsMin< float, int > :: IndexType size, const typename tnlParallelReductionAbsMin< float, int > :: RealType* deviceInput1, const typename tnlParallelReductionAbsMin< float, int > :: RealType* deviceInput2, typename tnlParallelReductionAbsMin< float, int> :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionAbsMin< double, int > > - ( const tnlParallelReductionAbsMin< double, int>& operation, + ( tnlParallelReductionAbsMin< double, int>& operation, const typename tnlParallelReductionAbsMin< double, int > :: IndexType size, const typename tnlParallelReductionAbsMin< double, int > :: RealType* deviceInput1, const typename tnlParallelReductionAbsMin< double, int > :: RealType* deviceInput2, @@ -54,7 +54,7 @@ template bool reductionOnCudaDevice< tnlParallelReductionAbsMin< double, int > > #ifdef INSTANTIATE_LONG_DOUBLE template bool reductionOnCudaDevice< tnlParallelReductionAbsMin< long double, int > > - ( const tnlParallelReductionAbsMin< long double, int>& operation, + ( tnlParallelReductionAbsMin< long double, int>& operation, const typename tnlParallelReductionAbsMin< long double, int > :: IndexType size, const typename tnlParallelReductionAbsMin< long double, int > :: RealType* deviceInput1, const typename tnlParallelReductionAbsMin< long double, int > :: RealType* deviceInput2, @@ -62,7 +62,7 @@ template bool reductionOnCudaDevice< tnlParallelReductionAbsMin< long double, in #endif template bool reductionOnCudaDevice< tnlParallelReductionAbsMin< char, long int > > - ( const tnlParallelReductionAbsMin< char, long int >& operation, + ( tnlParallelReductionAbsMin< char, long int >& operation, const typename tnlParallelReductionAbsMin< char, long int > :: IndexType size, const typename tnlParallelReductionAbsMin< char, long int > :: RealType* deviceInput1, const typename tnlParallelReductionAbsMin< char, long int > :: RealType* deviceInput2, @@ -70,21 +70,21 @@ template bool reductionOnCudaDevice< tnlParallelReductionAbsMin< char, long int #ifdef INSTANTIATE_LONG_INT template bool reductionOnCudaDevice< tnlParallelReductionAbsMin< int, long int > > - ( const tnlParallelReductionAbsMin< int, long int >& operation, + ( tnlParallelReductionAbsMin< int, long int >& operation, const typename tnlParallelReductionAbsMin< int, long int > :: IndexType size, const typename tnlParallelReductionAbsMin< int, long int > :: RealType* deviceInput1, const typename tnlParallelReductionAbsMin< int, long int > :: RealType* deviceInput2, typename tnlParallelReductionAbsMin< int, long int > :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionAbsMin< float, long int > > - ( const tnlParallelReductionAbsMin< float, long int >& operation, + ( tnlParallelReductionAbsMin< float, long int >& operation, const typename tnlParallelReductionAbsMin< float, long int > :: IndexType size, const typename tnlParallelReductionAbsMin< float, long int > :: RealType* deviceInput1, const typename tnlParallelReductionAbsMin< float, long int > :: RealType* deviceInput2, typename tnlParallelReductionAbsMin< float, long int> :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionAbsMin< double, long int > > - ( const tnlParallelReductionAbsMin< double, long int>& operation, + ( tnlParallelReductionAbsMin< double, long int>& operation, const typename tnlParallelReductionAbsMin< double, long int > :: IndexType size, const typename tnlParallelReductionAbsMin< double, long int > :: RealType* deviceInput1, const typename tnlParallelReductionAbsMin< double, long int > :: RealType* deviceInput2, @@ -92,7 +92,7 @@ template bool reductionOnCudaDevice< tnlParallelReductionAbsMin< double, long in #ifdef INSTANTIATE_LONG_DOUBLE template bool reductionOnCudaDevice< tnlParallelReductionAbsMin< long double, long int > > - ( const tnlParallelReductionAbsMin< long double, long int>& operation, + ( tnlParallelReductionAbsMin< long double, long int>& operation, const typename tnlParallelReductionAbsMin< long double, long int > :: IndexType size, const typename tnlParallelReductionAbsMin< long double, long int > :: RealType* deviceInput1, const typename tnlParallelReductionAbsMin< long double, long int > :: RealType* deviceInput2, diff --git a/src/core/cuda/cuda-reduction-abs-sum_impl.cu b/src/core/cuda/cuda-reduction-abs-sum_impl.cu index a023631a03927fed1f0a57c71d671d7b25dcb01f..96c8ab7a9cca414b75a6cc4b4ec40eb36d81397d 100644 --- a/src/core/cuda/cuda-reduction-abs-sum_impl.cu +++ b/src/core/cuda/cuda-reduction-abs-sum_impl.cu @@ -25,28 +25,28 @@ */ template bool reductionOnCudaDevice< tnlParallelReductionAbsSum< char, int > > - ( const tnlParallelReductionAbsSum< char, int >& operation, + ( tnlParallelReductionAbsSum< char, int >& operation, const typename tnlParallelReductionAbsSum< char, int > :: IndexType size, const typename tnlParallelReductionAbsSum< char, int > :: RealType* deviceInput1, const typename tnlParallelReductionAbsSum< char, int > :: RealType* deviceInput2, typename tnlParallelReductionAbsSum< char, int > :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionAbsSum< int, int > > - ( const tnlParallelReductionAbsSum< int, int >& operation, + ( tnlParallelReductionAbsSum< int, int >& operation, const typename tnlParallelReductionAbsSum< int, int > :: IndexType size, const typename tnlParallelReductionAbsSum< int, int > :: RealType* deviceInput1, const typename tnlParallelReductionAbsSum< int, int > :: RealType* deviceInput2, typename tnlParallelReductionAbsSum< int, int > :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionAbsSum< float, int > > - ( const tnlParallelReductionAbsSum< float, int >& operation, + ( tnlParallelReductionAbsSum< float, int >& operation, const typename tnlParallelReductionAbsSum< float, int > :: IndexType size, const typename tnlParallelReductionAbsSum< float, int > :: RealType* deviceInput1, const typename tnlParallelReductionAbsSum< float, int > :: RealType* deviceInput2, typename tnlParallelReductionAbsSum< float, int> :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionAbsSum< double, int > > - ( const tnlParallelReductionAbsSum< double, int>& operation, + ( tnlParallelReductionAbsSum< double, int>& operation, const typename tnlParallelReductionAbsSum< double, int > :: IndexType size, const typename tnlParallelReductionAbsSum< double, int > :: RealType* deviceInput1, const typename tnlParallelReductionAbsSum< double, int > :: RealType* deviceInput2, @@ -54,7 +54,7 @@ template bool reductionOnCudaDevice< tnlParallelReductionAbsSum< double, int > > #ifdef INSTANTIATE_LONG_DOUBLE template bool reductionOnCudaDevice< tnlParallelReductionAbsSum< long double, int > > - ( const tnlParallelReductionAbsSum< long double, int>& operation, + ( tnlParallelReductionAbsSum< long double, int>& operation, const typename tnlParallelReductionAbsSum< long double, int > :: IndexType size, const typename tnlParallelReductionAbsSum< long double, int > :: RealType* deviceInput1, const typename tnlParallelReductionAbsSum< long double, int > :: RealType* deviceInput2, @@ -62,7 +62,7 @@ template bool reductionOnCudaDevice< tnlParallelReductionAbsSum< long double, in #endif template bool reductionOnCudaDevice< tnlParallelReductionAbsSum< char, long int > > - ( const tnlParallelReductionAbsSum< char, long int >& operation, + ( tnlParallelReductionAbsSum< char, long int >& operation, const typename tnlParallelReductionAbsSum< char, long int > :: IndexType size, const typename tnlParallelReductionAbsSum< char, long int > :: RealType* deviceInput1, const typename tnlParallelReductionAbsSum< char, long int > :: RealType* deviceInput2, @@ -70,21 +70,21 @@ template bool reductionOnCudaDevice< tnlParallelReductionAbsSum< char, long int #ifdef INSTANTIATE_LONG_INT template bool reductionOnCudaDevice< tnlParallelReductionAbsSum< int, long int > > - ( const tnlParallelReductionAbsSum< int, long int >& operation, + ( tnlParallelReductionAbsSum< int, long int >& operation, const typename tnlParallelReductionAbsSum< int, long int > :: IndexType size, const typename tnlParallelReductionAbsSum< int, long int > :: RealType* deviceInput1, const typename tnlParallelReductionAbsSum< int, long int > :: RealType* deviceInput2, typename tnlParallelReductionAbsSum< int, long int > :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionAbsSum< float, long int > > - ( const tnlParallelReductionAbsSum< float, long int >& operation, + ( tnlParallelReductionAbsSum< float, long int >& operation, const typename tnlParallelReductionAbsSum< float, long int > :: IndexType size, const typename tnlParallelReductionAbsSum< float, long int > :: RealType* deviceInput1, const typename tnlParallelReductionAbsSum< float, long int > :: RealType* deviceInput2, typename tnlParallelReductionAbsSum< float, long int> :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionAbsSum< double, long int > > - ( const tnlParallelReductionAbsSum< double, long int>& operation, + ( tnlParallelReductionAbsSum< double, long int>& operation, const typename tnlParallelReductionAbsSum< double, long int > :: IndexType size, const typename tnlParallelReductionAbsSum< double, long int > :: RealType* deviceInput1, const typename tnlParallelReductionAbsSum< double, long int > :: RealType* deviceInput2, @@ -92,7 +92,7 @@ template bool reductionOnCudaDevice< tnlParallelReductionAbsSum< double, long in #ifdef INSTANTIATE_LONG_DOUBLE template bool reductionOnCudaDevice< tnlParallelReductionAbsSum< long double, long int > > - ( const tnlParallelReductionAbsSum< long double, long int>& operation, + ( tnlParallelReductionAbsSum< long double, long int>& operation, const typename tnlParallelReductionAbsSum< long double, long int > :: IndexType size, const typename tnlParallelReductionAbsSum< long double, long int > :: RealType* deviceInput1, const typename tnlParallelReductionAbsSum< long double, long int > :: RealType* deviceInput2, diff --git a/src/core/cuda/cuda-reduction-and_impl.cu b/src/core/cuda/cuda-reduction-and_impl.cu index ac71e46e192fef91c6bbd62fc6418aeb435355f6..1baa1699f12b628fc8c8816f492934f9a421c186 100644 --- a/src/core/cuda/cuda-reduction-and_impl.cu +++ b/src/core/cuda/cuda-reduction-and_impl.cu @@ -24,28 +24,28 @@ * Logical AND */ template bool reductionOnCudaDevice< tnlParallelReductionLogicalAnd< char, int > > - ( const tnlParallelReductionLogicalAnd< char, int >& operation, + ( tnlParallelReductionLogicalAnd< char, int >& operation, const typename tnlParallelReductionLogicalAnd< char, int > :: IndexType size, const typename tnlParallelReductionLogicalAnd< char, int > :: RealType* deviceInput1, const typename tnlParallelReductionLogicalAnd< char, int > :: RealType* deviceInput2, typename tnlParallelReductionLogicalAnd< char, int > :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionLogicalAnd< int, int > > - ( const tnlParallelReductionLogicalAnd< int, int >& operation, + ( tnlParallelReductionLogicalAnd< int, int >& operation, const typename tnlParallelReductionLogicalAnd< int, int > :: IndexType size, const typename tnlParallelReductionLogicalAnd< int, int > :: RealType* deviceInput1, const typename tnlParallelReductionLogicalAnd< int, int > :: RealType* deviceInput2, typename tnlParallelReductionLogicalAnd< int, int > :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionLogicalAnd< float, int > > - ( const tnlParallelReductionLogicalAnd< float, int >& operation, + ( tnlParallelReductionLogicalAnd< float, int >& operation, const typename tnlParallelReductionLogicalAnd< float, int > :: IndexType size, const typename tnlParallelReductionLogicalAnd< float, int > :: RealType* deviceInput1, const typename tnlParallelReductionLogicalAnd< float, int > :: RealType* deviceInput2, typename tnlParallelReductionLogicalAnd< float, int> :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionLogicalAnd< double, int > > - ( const tnlParallelReductionLogicalAnd< double, int>& operation, + ( tnlParallelReductionLogicalAnd< double, int>& operation, const typename tnlParallelReductionLogicalAnd< double, int > :: IndexType size, const typename tnlParallelReductionLogicalAnd< double, int > :: RealType* deviceInput1, const typename tnlParallelReductionLogicalAnd< double, int > :: RealType* deviceInput2, @@ -53,7 +53,7 @@ template bool reductionOnCudaDevice< tnlParallelReductionLogicalAnd< double, int #ifdef INSTANTIATE_LONG_DOUBLE template bool reductionOnCudaDevice< tnlParallelReductionLogicalAnd< long double, int > > - ( const tnlParallelReductionLogicalAnd< long double, int>& operation, + ( tnlParallelReductionLogicalAnd< long double, int>& operation, const typename tnlParallelReductionLogicalAnd< long double, int > :: IndexType size, const typename tnlParallelReductionLogicalAnd< long double, int > :: RealType* deviceInput1, const typename tnlParallelReductionLogicalAnd< long double, int > :: RealType* deviceInput2, @@ -62,28 +62,28 @@ template bool reductionOnCudaDevice< tnlParallelReductionLogicalAnd< long double #ifdef INSTANTIATE_LONG_INT template bool reductionOnCudaDevice< tnlParallelReductionLogicalAnd< char, long int > > - ( const tnlParallelReductionLogicalAnd< char, long int >& operation, + ( tnlParallelReductionLogicalAnd< char, long int >& operation, const typename tnlParallelReductionLogicalAnd< char, long int > :: IndexType size, const typename tnlParallelReductionLogicalAnd< char, long int > :: RealType* deviceInput1, const typename tnlParallelReductionLogicalAnd< char, long int > :: RealType* deviceInput2, typename tnlParallelReductionLogicalAnd< char, long int > :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionLogicalAnd< int, long int > > - ( const tnlParallelReductionLogicalAnd< int, long int >& operation, + ( tnlParallelReductionLogicalAnd< int, long int >& operation, const typename tnlParallelReductionLogicalAnd< int, long int > :: IndexType size, const typename tnlParallelReductionLogicalAnd< int, long int > :: RealType* deviceInput1, const typename tnlParallelReductionLogicalAnd< int, long int > :: RealType* deviceInput2, typename tnlParallelReductionLogicalAnd< int, long int > :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionLogicalAnd< float, long int > > - ( const tnlParallelReductionLogicalAnd< float, long int >& operation, + ( tnlParallelReductionLogicalAnd< float, long int >& operation, const typename tnlParallelReductionLogicalAnd< float, long int > :: IndexType size, const typename tnlParallelReductionLogicalAnd< float, long int > :: RealType* deviceInput1, const typename tnlParallelReductionLogicalAnd< float, long int > :: RealType* deviceInput2, typename tnlParallelReductionLogicalAnd< float, long int> :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionLogicalAnd< double, long int > > - ( const tnlParallelReductionLogicalAnd< double, long int>& operation, + ( tnlParallelReductionLogicalAnd< double, long int>& operation, const typename tnlParallelReductionLogicalAnd< double, long int > :: IndexType size, const typename tnlParallelReductionLogicalAnd< double, long int > :: RealType* deviceInput1, const typename tnlParallelReductionLogicalAnd< double, long int > :: RealType* deviceInput2, @@ -91,7 +91,7 @@ template bool reductionOnCudaDevice< tnlParallelReductionLogicalAnd< double, lon #ifdef INSTANTIATE_LONG_DOUBLE template bool reductionOnCudaDevice< tnlParallelReductionLogicalAnd< long double, long int > > - ( const tnlParallelReductionLogicalAnd< long double, long int>& operation, + ( tnlParallelReductionLogicalAnd< long double, long int>& operation, const typename tnlParallelReductionLogicalAnd< long double, long int > :: IndexType size, const typename tnlParallelReductionLogicalAnd< long double, long int > :: RealType* deviceInput1, const typename tnlParallelReductionLogicalAnd< long double, long int > :: RealType* deviceInput2, diff --git a/src/core/cuda/cuda-reduction-diff-abs-max_impl.cu b/src/core/cuda/cuda-reduction-diff-abs-max_impl.cu index 291810ef74385624b4213c0d6afff9b4da009781..a65ec09deeb1c76f398222acb6da5e8b6c7bb367 100644 --- a/src/core/cuda/cuda-reduction-diff-abs-max_impl.cu +++ b/src/core/cuda/cuda-reduction-diff-abs-max_impl.cu @@ -25,28 +25,28 @@ */ template bool reductionOnCudaDevice< tnlParallelReductionDiffAbsMax< char, int > > - ( const tnlParallelReductionDiffAbsMax< char, int >& operation, + ( tnlParallelReductionDiffAbsMax< char, int >& operation, const typename tnlParallelReductionDiffAbsMax< char, int > :: IndexType size, const typename tnlParallelReductionDiffAbsMax< char, int > :: RealType* deviceInput1, const typename tnlParallelReductionDiffAbsMax< char, int > :: RealType* deviceInput2, typename tnlParallelReductionDiffAbsMax< char, int > :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionDiffAbsMax< int, int > > - ( const tnlParallelReductionDiffAbsMax< int, int >& operation, + ( tnlParallelReductionDiffAbsMax< int, int >& operation, const typename tnlParallelReductionDiffAbsMax< int, int > :: IndexType size, const typename tnlParallelReductionDiffAbsMax< int, int > :: RealType* deviceInput1, const typename tnlParallelReductionDiffAbsMax< int, int > :: RealType* deviceInput2, typename tnlParallelReductionDiffAbsMax< int, int > :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionDiffAbsMax< float, int > > - ( const tnlParallelReductionDiffAbsMax< float, int >& operation, + ( tnlParallelReductionDiffAbsMax< float, int >& operation, const typename tnlParallelReductionDiffAbsMax< float, int > :: IndexType size, const typename tnlParallelReductionDiffAbsMax< float, int > :: RealType* deviceInput1, const typename tnlParallelReductionDiffAbsMax< float, int > :: RealType* deviceInput2, typename tnlParallelReductionDiffAbsMax< float, int> :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionDiffAbsMax< double, int > > - ( const tnlParallelReductionDiffAbsMax< double, int>& operation, + ( tnlParallelReductionDiffAbsMax< double, int>& operation, const typename tnlParallelReductionDiffAbsMax< double, int > :: IndexType size, const typename tnlParallelReductionDiffAbsMax< double, int > :: RealType* deviceInput1, const typename tnlParallelReductionDiffAbsMax< double, int > :: RealType* deviceInput2, @@ -54,7 +54,7 @@ template bool reductionOnCudaDevice< tnlParallelReductionDiffAbsMax< double, int #ifdef INSTANTIATE_LONG_DOUBLE template bool reductionOnCudaDevice< tnlParallelReductionDiffAbsMax< long double, int > > - ( const tnlParallelReductionDiffAbsMax< long double, int>& operation, + ( tnlParallelReductionDiffAbsMax< long double, int>& operation, const typename tnlParallelReductionDiffAbsMax< long double, int > :: IndexType size, const typename tnlParallelReductionDiffAbsMax< long double, int > :: RealType* deviceInput1, const typename tnlParallelReductionDiffAbsMax< long double, int > :: RealType* deviceInput2, @@ -63,28 +63,28 @@ template bool reductionOnCudaDevice< tnlParallelReductionDiffAbsMax< long double #ifdef INSTANTIATE_LONG_INT template bool reductionOnCudaDevice< tnlParallelReductionDiffAbsMax< char, long int > > - ( const tnlParallelReductionDiffAbsMax< char, long int >& operation, + ( tnlParallelReductionDiffAbsMax< char, long int >& operation, const typename tnlParallelReductionDiffAbsMax< char, long int > :: IndexType size, const typename tnlParallelReductionDiffAbsMax< char, long int > :: RealType* deviceInput1, const typename tnlParallelReductionDiffAbsMax< char, long int > :: RealType* deviceInput2, typename tnlParallelReductionDiffAbsMax< char, long int > :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionDiffAbsMax< int, long int > > - ( const tnlParallelReductionDiffAbsMax< int, long int >& operation, + ( tnlParallelReductionDiffAbsMax< int, long int >& operation, const typename tnlParallelReductionDiffAbsMax< int, long int > :: IndexType size, const typename tnlParallelReductionDiffAbsMax< int, long int > :: RealType* deviceInput1, const typename tnlParallelReductionDiffAbsMax< int, long int > :: RealType* deviceInput2, typename tnlParallelReductionDiffAbsMax< int, long int > :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionDiffAbsMax< float, long int > > - ( const tnlParallelReductionDiffAbsMax< float, long int >& operation, + ( tnlParallelReductionDiffAbsMax< float, long int >& operation, const typename tnlParallelReductionDiffAbsMax< float, long int > :: IndexType size, const typename tnlParallelReductionDiffAbsMax< float, long int > :: RealType* deviceInput1, const typename tnlParallelReductionDiffAbsMax< float, long int > :: RealType* deviceInput2, typename tnlParallelReductionDiffAbsMax< float, long int> :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionDiffAbsMax< double, long int > > - ( const tnlParallelReductionDiffAbsMax< double, long int>& operation, + ( tnlParallelReductionDiffAbsMax< double, long int>& operation, const typename tnlParallelReductionDiffAbsMax< double, long int > :: IndexType size, const typename tnlParallelReductionDiffAbsMax< double, long int > :: RealType* deviceInput1, const typename tnlParallelReductionDiffAbsMax< double, long int > :: RealType* deviceInput2, @@ -92,7 +92,7 @@ template bool reductionOnCudaDevice< tnlParallelReductionDiffAbsMax< double, lon #ifdef INSTANTIATE_LONG_DOUBLE template bool reductionOnCudaDevice< tnlParallelReductionDiffAbsMax< long double, long int > > - ( const tnlParallelReductionDiffAbsMax< long double, long int>& operation, + ( tnlParallelReductionDiffAbsMax< long double, long int>& operation, const typename tnlParallelReductionDiffAbsMax< long double, long int > :: IndexType size, const typename tnlParallelReductionDiffAbsMax< long double, long int > :: RealType* deviceInput1, const typename tnlParallelReductionDiffAbsMax< long double, long int > :: RealType* deviceInput2, diff --git a/src/core/cuda/cuda-reduction-diff-abs-min_impl.cu b/src/core/cuda/cuda-reduction-diff-abs-min_impl.cu index d9ce714abde23b2788c9a94a81e03b283860ebf5..9610ee2675e475d3a5fd82a07df93b82aada6f85 100644 --- a/src/core/cuda/cuda-reduction-diff-abs-min_impl.cu +++ b/src/core/cuda/cuda-reduction-diff-abs-min_impl.cu @@ -26,28 +26,28 @@ */ template bool reductionOnCudaDevice< tnlParallelReductionDiffAbsMin< char, int > > - ( const tnlParallelReductionDiffAbsMin< char, int >& operation, + ( tnlParallelReductionDiffAbsMin< char, int >& operation, const typename tnlParallelReductionDiffAbsMin< char, int > :: IndexType size, const typename tnlParallelReductionDiffAbsMin< char, int > :: RealType* deviceInput1, const typename tnlParallelReductionDiffAbsMin< char, int > :: RealType* deviceInput2, typename tnlParallelReductionDiffAbsMin< char, int > :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionDiffAbsMin< int, int > > - ( const tnlParallelReductionDiffAbsMin< int, int >& operation, + ( tnlParallelReductionDiffAbsMin< int, int >& operation, const typename tnlParallelReductionDiffAbsMin< int, int > :: IndexType size, const typename tnlParallelReductionDiffAbsMin< int, int > :: RealType* deviceInput1, const typename tnlParallelReductionDiffAbsMin< int, int > :: RealType* deviceInput2, typename tnlParallelReductionDiffAbsMin< int, int > :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionDiffAbsMin< float, int > > - ( const tnlParallelReductionDiffAbsMin< float, int >& operation, + ( tnlParallelReductionDiffAbsMin< float, int >& operation, const typename tnlParallelReductionDiffAbsMin< float, int > :: IndexType size, const typename tnlParallelReductionDiffAbsMin< float, int > :: RealType* deviceInput1, const typename tnlParallelReductionDiffAbsMin< float, int > :: RealType* deviceInput2, typename tnlParallelReductionDiffAbsMin< float, int> :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionDiffAbsMin< double, int > > - ( const tnlParallelReductionDiffAbsMin< double, int>& operation, + ( tnlParallelReductionDiffAbsMin< double, int>& operation, const typename tnlParallelReductionDiffAbsMin< double, int > :: IndexType size, const typename tnlParallelReductionDiffAbsMin< double, int > :: RealType* deviceInput1, const typename tnlParallelReductionDiffAbsMin< double, int > :: RealType* deviceInput2, @@ -55,7 +55,7 @@ template bool reductionOnCudaDevice< tnlParallelReductionDiffAbsMin< double, int #ifdef INSTANTIATE_LONG_DOUBLE template bool reductionOnCudaDevice< tnlParallelReductionDiffAbsMin< long double, int > > - ( const tnlParallelReductionDiffAbsMin< long double, int>& operation, + ( tnlParallelReductionDiffAbsMin< long double, int>& operation, const typename tnlParallelReductionDiffAbsMin< long double, int > :: IndexType size, const typename tnlParallelReductionDiffAbsMin< long double, int > :: RealType* deviceInput1, const typename tnlParallelReductionDiffAbsMin< long double, int > :: RealType* deviceInput2, @@ -64,28 +64,28 @@ template bool reductionOnCudaDevice< tnlParallelReductionDiffAbsMin< long double #ifdef INSTANTIATE_LONG_INT template bool reductionOnCudaDevice< tnlParallelReductionDiffAbsMin< char, long int > > - ( const tnlParallelReductionDiffAbsMin< char, long int >& operation, + ( tnlParallelReductionDiffAbsMin< char, long int >& operation, const typename tnlParallelReductionDiffAbsMin< char, long int > :: IndexType size, const typename tnlParallelReductionDiffAbsMin< char, long int > :: RealType* deviceInput1, const typename tnlParallelReductionDiffAbsMin< char, long int > :: RealType* deviceInput2, typename tnlParallelReductionDiffAbsMin< char, long int > :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionDiffAbsMin< int, long int > > - ( const tnlParallelReductionDiffAbsMin< int, long int >& operation, + ( tnlParallelReductionDiffAbsMin< int, long int >& operation, const typename tnlParallelReductionDiffAbsMin< int, long int > :: IndexType size, const typename tnlParallelReductionDiffAbsMin< int, long int > :: RealType* deviceInput1, const typename tnlParallelReductionDiffAbsMin< int, long int > :: RealType* deviceInput2, typename tnlParallelReductionDiffAbsMin< int, long int > :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionDiffAbsMin< float, long int > > - ( const tnlParallelReductionDiffAbsMin< float, long int >& operation, + ( tnlParallelReductionDiffAbsMin< float, long int >& operation, const typename tnlParallelReductionDiffAbsMin< float, long int > :: IndexType size, const typename tnlParallelReductionDiffAbsMin< float, long int > :: RealType* deviceInput1, const typename tnlParallelReductionDiffAbsMin< float, long int > :: RealType* deviceInput2, typename tnlParallelReductionDiffAbsMin< float, long int> :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionDiffAbsMin< double, long int > > - ( const tnlParallelReductionDiffAbsMin< double, long int>& operation, + ( tnlParallelReductionDiffAbsMin< double, long int>& operation, const typename tnlParallelReductionDiffAbsMin< double, long int > :: IndexType size, const typename tnlParallelReductionDiffAbsMin< double, long int > :: RealType* deviceInput1, const typename tnlParallelReductionDiffAbsMin< double, long int > :: RealType* deviceInput2, @@ -93,7 +93,7 @@ template bool reductionOnCudaDevice< tnlParallelReductionDiffAbsMin< double, lon #ifdef INSTANTIATE_LONG_DOUBLE template bool reductionOnCudaDevice< tnlParallelReductionDiffAbsMin< long double, long int > > - ( const tnlParallelReductionDiffAbsMin< long double, long int>& operation, + ( tnlParallelReductionDiffAbsMin< long double, long int>& operation, const typename tnlParallelReductionDiffAbsMin< long double, long int > :: IndexType size, const typename tnlParallelReductionDiffAbsMin< long double, long int > :: RealType* deviceInput1, const typename tnlParallelReductionDiffAbsMin< long double, long int > :: RealType* deviceInput2, diff --git a/src/core/cuda/cuda-reduction-diff-abs-sum_impl.cu b/src/core/cuda/cuda-reduction-diff-abs-sum_impl.cu index 5298d033491f1d23330a05bc5528c211c1335e99..b70f953add3bb26af21820de4f55acb6223c034d 100644 --- a/src/core/cuda/cuda-reduction-diff-abs-sum_impl.cu +++ b/src/core/cuda/cuda-reduction-diff-abs-sum_impl.cu @@ -25,28 +25,28 @@ */ template bool reductionOnCudaDevice< tnlParallelReductionDiffAbsSum< char, int > > - ( const tnlParallelReductionDiffAbsSum< char, int >& operation, + ( tnlParallelReductionDiffAbsSum< char, int >& operation, const typename tnlParallelReductionDiffAbsSum< char, int > :: IndexType size, const typename tnlParallelReductionDiffAbsSum< char, int > :: RealType* deviceInput1, const typename tnlParallelReductionDiffAbsSum< char, int > :: RealType* deviceInput2, typename tnlParallelReductionDiffAbsSum< char, int > :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionDiffAbsSum< int, int > > - ( const tnlParallelReductionDiffAbsSum< int, int >& operation, + ( tnlParallelReductionDiffAbsSum< int, int >& operation, const typename tnlParallelReductionDiffAbsSum< int, int > :: IndexType size, const typename tnlParallelReductionDiffAbsSum< int, int > :: RealType* deviceInput1, const typename tnlParallelReductionDiffAbsSum< int, int > :: RealType* deviceInput2, typename tnlParallelReductionDiffAbsSum< int, int > :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionDiffAbsSum< float, int > > - ( const tnlParallelReductionDiffAbsSum< float, int >& operation, + ( tnlParallelReductionDiffAbsSum< float, int >& operation, const typename tnlParallelReductionDiffAbsSum< float, int > :: IndexType size, const typename tnlParallelReductionDiffAbsSum< float, int > :: RealType* deviceInput1, const typename tnlParallelReductionDiffAbsSum< float, int > :: RealType* deviceInput2, typename tnlParallelReductionDiffAbsSum< float, int> :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionDiffAbsSum< double, int > > - ( const tnlParallelReductionDiffAbsSum< double, int>& operation, + ( tnlParallelReductionDiffAbsSum< double, int>& operation, const typename tnlParallelReductionDiffAbsSum< double, int > :: IndexType size, const typename tnlParallelReductionDiffAbsSum< double, int > :: RealType* deviceInput1, const typename tnlParallelReductionDiffAbsSum< double, int > :: RealType* deviceInput2, @@ -54,7 +54,7 @@ template bool reductionOnCudaDevice< tnlParallelReductionDiffAbsSum< double, int #ifdef INSTANTIATE_LONG_DOUBLE template bool reductionOnCudaDevice< tnlParallelReductionDiffAbsSum< long double, int > > - ( const tnlParallelReductionDiffAbsSum< long double, int>& operation, + ( tnlParallelReductionDiffAbsSum< long double, int>& operation, const typename tnlParallelReductionDiffAbsSum< long double, int > :: IndexType size, const typename tnlParallelReductionDiffAbsSum< long double, int > :: RealType* deviceInput1, const typename tnlParallelReductionDiffAbsSum< long double, int > :: RealType* deviceInput2, @@ -63,28 +63,28 @@ template bool reductionOnCudaDevice< tnlParallelReductionDiffAbsSum< long double #ifdef INSTANTIATE_LONG_INT template bool reductionOnCudaDevice< tnlParallelReductionDiffAbsSum< char, long int > > - ( const tnlParallelReductionDiffAbsSum< char, long int >& operation, + ( tnlParallelReductionDiffAbsSum< char, long int >& operation, const typename tnlParallelReductionDiffAbsSum< char, long int > :: IndexType size, const typename tnlParallelReductionDiffAbsSum< char, long int > :: RealType* deviceInput1, const typename tnlParallelReductionDiffAbsSum< char, long int > :: RealType* deviceInput2, typename tnlParallelReductionDiffAbsSum< char, long int > :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionDiffAbsSum< int, long int > > - ( const tnlParallelReductionDiffAbsSum< int, long int >& operation, + ( tnlParallelReductionDiffAbsSum< int, long int >& operation, const typename tnlParallelReductionDiffAbsSum< int, long int > :: IndexType size, const typename tnlParallelReductionDiffAbsSum< int, long int > :: RealType* deviceInput1, const typename tnlParallelReductionDiffAbsSum< int, long int > :: RealType* deviceInput2, typename tnlParallelReductionDiffAbsSum< int, long int > :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionDiffAbsSum< float, long int > > - ( const tnlParallelReductionDiffAbsSum< float, long int >& operation, + ( tnlParallelReductionDiffAbsSum< float, long int >& operation, const typename tnlParallelReductionDiffAbsSum< float, long int > :: IndexType size, const typename tnlParallelReductionDiffAbsSum< float, long int > :: RealType* deviceInput1, const typename tnlParallelReductionDiffAbsSum< float, long int > :: RealType* deviceInput2, typename tnlParallelReductionDiffAbsSum< float, long int> :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionDiffAbsSum< double, long int > > - ( const tnlParallelReductionDiffAbsSum< double, long int>& operation, + ( tnlParallelReductionDiffAbsSum< double, long int>& operation, const typename tnlParallelReductionDiffAbsSum< double, long int > :: IndexType size, const typename tnlParallelReductionDiffAbsSum< double, long int > :: RealType* deviceInput1, const typename tnlParallelReductionDiffAbsSum< double, long int > :: RealType* deviceInput2, @@ -92,7 +92,7 @@ template bool reductionOnCudaDevice< tnlParallelReductionDiffAbsSum< double, lon #ifdef INSTANTIATE_LONG_DOUBLE template bool reductionOnCudaDevice< tnlParallelReductionDiffAbsSum< long double, long int > > - ( const tnlParallelReductionDiffAbsSum< long double, long int>& operation, + ( tnlParallelReductionDiffAbsSum< long double, long int>& operation, const typename tnlParallelReductionDiffAbsSum< long double, long int > :: IndexType size, const typename tnlParallelReductionDiffAbsSum< long double, long int > :: RealType* deviceInput1, const typename tnlParallelReductionDiffAbsSum< long double, long int > :: RealType* deviceInput2, diff --git a/src/core/cuda/cuda-reduction-diff-l2-norm_impl.cu b/src/core/cuda/cuda-reduction-diff-l2-norm_impl.cu new file mode 100644 index 0000000000000000000000000000000000000000..a6bfae5b949dc33bf6edfa2665201a7b6651713a --- /dev/null +++ b/src/core/cuda/cuda-reduction-diff-l2-norm_impl.cu @@ -0,0 +1,87 @@ +/*************************************************************************** + cuda-reduction-diff-lp-norm_impl.cu - description + ------------------- + begin : Jan 19, 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. * + * * + ***************************************************************************/ + +#include <core/cuda/reduction-operations.h> +#include <core/cuda/cuda-reduction.h> + +#ifdef TEMPLATE_EXPLICIT_INSTANTIATION + +/**** + * Diff L2 Norm + */ +template bool reductionOnCudaDevice< tnlParallelReductionDiffL2Norm< float, int > > + ( tnlParallelReductionDiffL2Norm< float, int >& operation, + const typename tnlParallelReductionDiffL2Norm< float, int > :: IndexType size, + const typename tnlParallelReductionDiffL2Norm< float, int > :: RealType* deviceInput1, + const typename tnlParallelReductionDiffL2Norm< float, int > :: RealType* deviceInput2, + typename tnlParallelReductionDiffL2Norm< float, int> :: ResultType& result ); + +template bool reductionOnCudaDevice< tnlParallelReductionDiffL2Norm< double, int > > + ( tnlParallelReductionDiffL2Norm< double, int>& operation, + const typename tnlParallelReductionDiffL2Norm< double, int > :: IndexType size, + const typename tnlParallelReductionDiffL2Norm< double, int > :: RealType* deviceInput1, + const typename tnlParallelReductionDiffL2Norm< double, int > :: RealType* deviceInput2, + typename tnlParallelReductionDiffL2Norm< double, int> :: ResultType& result ); + +#ifdef INSTANTIATE_LONG_DOUBLE +template bool reductionOnCudaDevice< tnlParallelReductionDiffL2Norm< long double, int > > + ( tnlParallelReductionDiffL2Norm< long double, int>& operation, + const typename tnlParallelReductionDiffL2Norm< long double, int > :: IndexType size, + const typename tnlParallelReductionDiffL2Norm< long double, int > :: RealType* deviceInput1, + const typename tnlParallelReductionDiffL2Norm< long double, int > :: RealType* deviceInput2, + typename tnlParallelReductionDiffL2Norm< long double, int> :: ResultType& result ); +#endif + +#ifdef INSTANTIATE_LONG_INT +template bool reductionOnCudaDevice< tnlParallelReductionDiffL2Norm< char, long int > > + ( tnlParallelReductionDiffL2Norm< char, long int >& operation, + const typename tnlParallelReductionDiffL2Norm< char, long int > :: IndexType size, + const typename tnlParallelReductionDiffL2Norm< char, long int > :: RealType* deviceInput1, + const typename tnlParallelReductionDiffL2Norm< char, long int > :: RealType* deviceInput2, + typename tnlParallelReductionDiffL2Norm< char, long int > :: ResultType& result ); + +template bool reductionOnCudaDevice< tnlParallelReductionDiffL2Norm< int, long int > > + ( tnlParallelReductionDiffL2Norm< int, long int >& operation, + const typename tnlParallelReductionDiffL2Norm< int, long int > :: IndexType size, + const typename tnlParallelReductionDiffL2Norm< int, long int > :: RealType* deviceInput1, + const typename tnlParallelReductionDiffL2Norm< int, long int > :: RealType* deviceInput2, + typename tnlParallelReductionDiffL2Norm< int, long int > :: ResultType& result ); + +template bool reductionOnCudaDevice< tnlParallelReductionDiffL2Norm< float, long int > > + ( tnlParallelReductionDiffL2Norm< float, long int >& operation, + const typename tnlParallelReductionDiffL2Norm< float, long int > :: IndexType size, + const typename tnlParallelReductionDiffL2Norm< float, long int > :: RealType* deviceInput1, + const typename tnlParallelReductionDiffL2Norm< float, long int > :: RealType* deviceInput2, + typename tnlParallelReductionDiffL2Norm< float, long int> :: ResultType& result ); + +template bool reductionOnCudaDevice< tnlParallelReductionDiffL2Norm< double, long int > > + ( tnlParallelReductionDiffL2Norm< double, long int>& operation, + const typename tnlParallelReductionDiffL2Norm< double, long int > :: IndexType size, + const typename tnlParallelReductionDiffL2Norm< double, long int > :: RealType* deviceInput1, + const typename tnlParallelReductionDiffL2Norm< double, long int > :: RealType* deviceInput2, + typename tnlParallelReductionDiffL2Norm< double, long int> :: ResultType& result ); + +#ifdef INSTANTIATE_LONG_DOUBLE +template bool reductionOnCudaDevice< tnlParallelReductionDiffL2Norm< long double, long int > > + ( tnlParallelReductionDiffL2Norm< long double, long int>& operation, + const typename tnlParallelReductionDiffL2Norm< long double, long int > :: IndexType size, + const typename tnlParallelReductionDiffL2Norm< long double, long int > :: RealType* deviceInput1, + const typename tnlParallelReductionDiffL2Norm< long double, long int > :: RealType* deviceInput2, + typename tnlParallelReductionDiffL2Norm< long double, long int> :: ResultType& result ); +#endif +#endif +#endif diff --git a/src/core/cuda/cuda-reduction-diff-lp-norm_impl.cu b/src/core/cuda/cuda-reduction-diff-lp-norm_impl.cu index 2359564477c934f1bcfa62de9e1a155c6875cff3..a762c1d194db3debda0c4c6a0a740591d0df12aa 100644 --- a/src/core/cuda/cuda-reduction-diff-lp-norm_impl.cu +++ b/src/core/cuda/cuda-reduction-diff-lp-norm_impl.cu @@ -24,14 +24,14 @@ * Diff Lp Norm */ template bool reductionOnCudaDevice< tnlParallelReductionDiffLpNorm< float, int > > - ( const tnlParallelReductionDiffLpNorm< float, int >& operation, + ( tnlParallelReductionDiffLpNorm< float, int >& operation, const typename tnlParallelReductionDiffLpNorm< float, int > :: IndexType size, const typename tnlParallelReductionDiffLpNorm< float, int > :: RealType* deviceInput1, const typename tnlParallelReductionDiffLpNorm< float, int > :: RealType* deviceInput2, typename tnlParallelReductionDiffLpNorm< float, int> :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionDiffLpNorm< double, int > > - ( const tnlParallelReductionDiffLpNorm< double, int>& operation, + ( tnlParallelReductionDiffLpNorm< double, int>& operation, const typename tnlParallelReductionDiffLpNorm< double, int > :: IndexType size, const typename tnlParallelReductionDiffLpNorm< double, int > :: RealType* deviceInput1, const typename tnlParallelReductionDiffLpNorm< double, int > :: RealType* deviceInput2, @@ -39,7 +39,7 @@ template bool reductionOnCudaDevice< tnlParallelReductionDiffLpNorm< double, int #ifdef INSTANTIATE_LONG_DOUBLE template bool reductionOnCudaDevice< tnlParallelReductionDiffLpNorm< long double, int > > - ( const tnlParallelReductionDiffLpNorm< long double, int>& operation, + ( tnlParallelReductionDiffLpNorm< long double, int>& operation, const typename tnlParallelReductionDiffLpNorm< long double, int > :: IndexType size, const typename tnlParallelReductionDiffLpNorm< long double, int > :: RealType* deviceInput1, const typename tnlParallelReductionDiffLpNorm< long double, int > :: RealType* deviceInput2, @@ -48,28 +48,28 @@ template bool reductionOnCudaDevice< tnlParallelReductionDiffLpNorm< long double #ifdef INSTANTIATE_LONG_INT template bool reductionOnCudaDevice< tnlParallelReductionDiffLpNorm< char, long int > > - ( const tnlParallelReductionDiffLpNorm< char, long int >& operation, + ( tnlParallelReductionDiffLpNorm< char, long int >& operation, const typename tnlParallelReductionDiffLpNorm< char, long int > :: IndexType size, const typename tnlParallelReductionDiffLpNorm< char, long int > :: RealType* deviceInput1, const typename tnlParallelReductionDiffLpNorm< char, long int > :: RealType* deviceInput2, typename tnlParallelReductionDiffLpNorm< char, long int > :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionDiffLpNorm< int, long int > > - ( const tnlParallelReductionDiffLpNorm< int, long int >& operation, + ( tnlParallelReductionDiffLpNorm< int, long int >& operation, const typename tnlParallelReductionDiffLpNorm< int, long int > :: IndexType size, const typename tnlParallelReductionDiffLpNorm< int, long int > :: RealType* deviceInput1, const typename tnlParallelReductionDiffLpNorm< int, long int > :: RealType* deviceInput2, typename tnlParallelReductionDiffLpNorm< int, long int > :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionDiffLpNorm< float, long int > > - ( const tnlParallelReductionDiffLpNorm< float, long int >& operation, + ( tnlParallelReductionDiffLpNorm< float, long int >& operation, const typename tnlParallelReductionDiffLpNorm< float, long int > :: IndexType size, const typename tnlParallelReductionDiffLpNorm< float, long int > :: RealType* deviceInput1, const typename tnlParallelReductionDiffLpNorm< float, long int > :: RealType* deviceInput2, typename tnlParallelReductionDiffLpNorm< float, long int> :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionDiffLpNorm< double, long int > > - ( const tnlParallelReductionDiffLpNorm< double, long int>& operation, + ( tnlParallelReductionDiffLpNorm< double, long int>& operation, const typename tnlParallelReductionDiffLpNorm< double, long int > :: IndexType size, const typename tnlParallelReductionDiffLpNorm< double, long int > :: RealType* deviceInput1, const typename tnlParallelReductionDiffLpNorm< double, long int > :: RealType* deviceInput2, @@ -77,7 +77,7 @@ template bool reductionOnCudaDevice< tnlParallelReductionDiffLpNorm< double, lon #ifdef INSTANTIATE_LONG_DOUBLE template bool reductionOnCudaDevice< tnlParallelReductionDiffLpNorm< long double, long int > > - ( const tnlParallelReductionDiffLpNorm< long double, long int>& operation, + ( tnlParallelReductionDiffLpNorm< long double, long int>& operation, const typename tnlParallelReductionDiffLpNorm< long double, long int > :: IndexType size, const typename tnlParallelReductionDiffLpNorm< long double, long int > :: RealType* deviceInput1, const typename tnlParallelReductionDiffLpNorm< long double, long int > :: RealType* deviceInput2, diff --git a/src/core/cuda/cuda-reduction-diff-max_impl.cu b/src/core/cuda/cuda-reduction-diff-max_impl.cu index fe91ae6ef6a0f9116df733f392016a588dd9c5e4..822d9e779c5d15d3aedaee9b93390a7213d7417d 100644 --- a/src/core/cuda/cuda-reduction-diff-max_impl.cu +++ b/src/core/cuda/cuda-reduction-diff-max_impl.cu @@ -25,28 +25,28 @@ */ template bool reductionOnCudaDevice< tnlParallelReductionDiffMax< char, int > > - ( const tnlParallelReductionDiffMax< char, int >& operation, + ( tnlParallelReductionDiffMax< char, int >& operation, const typename tnlParallelReductionDiffMax< char, int > :: IndexType size, const typename tnlParallelReductionDiffMax< char, int > :: RealType* deviceInput1, const typename tnlParallelReductionDiffMax< char, int > :: RealType* deviceInput2, typename tnlParallelReductionDiffMax< char, int > :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionDiffMax< int, int > > - ( const tnlParallelReductionDiffMax< int, int >& operation, + ( tnlParallelReductionDiffMax< int, int >& operation, const typename tnlParallelReductionDiffMax< int, int > :: IndexType size, const typename tnlParallelReductionDiffMax< int, int > :: RealType* deviceInput1, const typename tnlParallelReductionDiffMax< int, int > :: RealType* deviceInput2, typename tnlParallelReductionDiffMax< int, int > :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionDiffMax< float, int > > - ( const tnlParallelReductionDiffMax< float, int >& operation, + ( tnlParallelReductionDiffMax< float, int >& operation, const typename tnlParallelReductionDiffMax< float, int > :: IndexType size, const typename tnlParallelReductionDiffMax< float, int > :: RealType* deviceInput1, const typename tnlParallelReductionDiffMax< float, int > :: RealType* deviceInput2, typename tnlParallelReductionDiffMax< float, int> :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionDiffMax< double, int > > - ( const tnlParallelReductionDiffMax< double, int>& operation, + ( tnlParallelReductionDiffMax< double, int>& operation, const typename tnlParallelReductionDiffMax< double, int > :: IndexType size, const typename tnlParallelReductionDiffMax< double, int > :: RealType* deviceInput1, const typename tnlParallelReductionDiffMax< double, int > :: RealType* deviceInput2, @@ -54,7 +54,7 @@ template bool reductionOnCudaDevice< tnlParallelReductionDiffMax< double, int > #ifdef INSTANTIATE_LONG_DOUBLE template bool reductionOnCudaDevice< tnlParallelReductionDiffMax< long double, int > > - ( const tnlParallelReductionDiffMax< long double, int>& operation, + ( tnlParallelReductionDiffMax< long double, int>& operation, const typename tnlParallelReductionDiffMax< long double, int > :: IndexType size, const typename tnlParallelReductionDiffMax< long double, int > :: RealType* deviceInput1, const typename tnlParallelReductionDiffMax< long double, int > :: RealType* deviceInput2, @@ -63,28 +63,28 @@ template bool reductionOnCudaDevice< tnlParallelReductionDiffMax< long double, i #ifdef INSTANTIATE_LONG_INT template bool reductionOnCudaDevice< tnlParallelReductionDiffMax< char, long int > > - ( const tnlParallelReductionDiffMax< char, long int >& operation, + ( tnlParallelReductionDiffMax< char, long int >& operation, const typename tnlParallelReductionDiffMax< char, long int > :: IndexType size, const typename tnlParallelReductionDiffMax< char, long int > :: RealType* deviceInput1, const typename tnlParallelReductionDiffMax< char, long int > :: RealType* deviceInput2, typename tnlParallelReductionDiffMax< char, long int > :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionDiffMax< int, long int > > - ( const tnlParallelReductionDiffMax< int, long int >& operation, + ( tnlParallelReductionDiffMax< int, long int >& operation, const typename tnlParallelReductionDiffMax< int, long int > :: IndexType size, const typename tnlParallelReductionDiffMax< int, long int > :: RealType* deviceInput1, const typename tnlParallelReductionDiffMax< int, long int > :: RealType* deviceInput2, typename tnlParallelReductionDiffMax< int, long int > :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionDiffMax< float, long int > > - ( const tnlParallelReductionDiffMax< float, long int >& operation, + ( tnlParallelReductionDiffMax< float, long int >& operation, const typename tnlParallelReductionDiffMax< float, long int > :: IndexType size, const typename tnlParallelReductionDiffMax< float, long int > :: RealType* deviceInput1, const typename tnlParallelReductionDiffMax< float, long int > :: RealType* deviceInput2, typename tnlParallelReductionDiffMax< float, long int> :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionDiffMax< double, long int > > - ( const tnlParallelReductionDiffMax< double, long int>& operation, + ( tnlParallelReductionDiffMax< double, long int>& operation, const typename tnlParallelReductionDiffMax< double, long int > :: IndexType size, const typename tnlParallelReductionDiffMax< double, long int > :: RealType* deviceInput1, const typename tnlParallelReductionDiffMax< double, long int > :: RealType* deviceInput2, @@ -92,7 +92,7 @@ template bool reductionOnCudaDevice< tnlParallelReductionDiffMax< double, long i #ifdef INSTANTIATE_LONG_DOUBLE template bool reductionOnCudaDevice< tnlParallelReductionDiffMax< long double, long int > > - ( const tnlParallelReductionDiffMax< long double, long int>& operation, + ( tnlParallelReductionDiffMax< long double, long int>& operation, const typename tnlParallelReductionDiffMax< long double, long int > :: IndexType size, const typename tnlParallelReductionDiffMax< long double, long int > :: RealType* deviceInput1, const typename tnlParallelReductionDiffMax< long double, long int > :: RealType* deviceInput2, diff --git a/src/core/cuda/cuda-reduction-diff-min_impl.cu b/src/core/cuda/cuda-reduction-diff-min_impl.cu index ed13335b8b282352727a8a6687c10ae122196a48..5973ad0bcf5a3ec65b49418125b14cffbc1d204b 100644 --- a/src/core/cuda/cuda-reduction-diff-min_impl.cu +++ b/src/core/cuda/cuda-reduction-diff-min_impl.cu @@ -26,28 +26,28 @@ */ template bool reductionOnCudaDevice< tnlParallelReductionDiffMin< char, int > > - ( const tnlParallelReductionDiffMin< char, int >& operation, + ( tnlParallelReductionDiffMin< char, int >& operation, const typename tnlParallelReductionDiffMin< char, int > :: IndexType size, const typename tnlParallelReductionDiffMin< char, int > :: RealType* deviceInput1, const typename tnlParallelReductionDiffMin< char, int > :: RealType* deviceInput2, typename tnlParallelReductionDiffMin< char, int > :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionDiffMin< int, int > > - ( const tnlParallelReductionDiffMin< int, int >& operation, + ( tnlParallelReductionDiffMin< int, int >& operation, const typename tnlParallelReductionDiffMin< int, int > :: IndexType size, const typename tnlParallelReductionDiffMin< int, int > :: RealType* deviceInput1, const typename tnlParallelReductionDiffMin< int, int > :: RealType* deviceInput2, typename tnlParallelReductionDiffMin< int, int > :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionDiffMin< float, int > > - ( const tnlParallelReductionDiffMin< float, int >& operation, + ( tnlParallelReductionDiffMin< float, int >& operation, const typename tnlParallelReductionDiffMin< float, int > :: IndexType size, const typename tnlParallelReductionDiffMin< float, int > :: RealType* deviceInput1, const typename tnlParallelReductionDiffMin< float, int > :: RealType* deviceInput2, typename tnlParallelReductionDiffMin< float, int> :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionDiffMin< double, int > > - ( const tnlParallelReductionDiffMin< double, int>& operation, + ( tnlParallelReductionDiffMin< double, int>& operation, const typename tnlParallelReductionDiffMin< double, int > :: IndexType size, const typename tnlParallelReductionDiffMin< double, int > :: RealType* deviceInput1, const typename tnlParallelReductionDiffMin< double, int > :: RealType* deviceInput2, @@ -55,7 +55,7 @@ template bool reductionOnCudaDevice< tnlParallelReductionDiffMin< double, int > #ifdef INSTANTIATE_LONG_DOUBLE template bool reductionOnCudaDevice< tnlParallelReductionDiffMin< long double, int > > - ( const tnlParallelReductionDiffMin< long double, int>& operation, + ( tnlParallelReductionDiffMin< long double, int>& operation, const typename tnlParallelReductionDiffMin< long double, int > :: IndexType size, const typename tnlParallelReductionDiffMin< long double, int > :: RealType* deviceInput1, const typename tnlParallelReductionDiffMin< long double, int > :: RealType* deviceInput2, @@ -64,28 +64,28 @@ template bool reductionOnCudaDevice< tnlParallelReductionDiffMin< long double, i #ifdef INSTANTIATE_LONG_INT template bool reductionOnCudaDevice< tnlParallelReductionDiffMin< char, long int > > - ( const tnlParallelReductionDiffMin< char, long int >& operation, + ( tnlParallelReductionDiffMin< char, long int >& operation, const typename tnlParallelReductionDiffMin< char, long int > :: IndexType size, const typename tnlParallelReductionDiffMin< char, long int > :: RealType* deviceInput1, const typename tnlParallelReductionDiffMin< char, long int > :: RealType* deviceInput2, typename tnlParallelReductionDiffMin< char, long int > :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionDiffMin< int, long int > > - ( const tnlParallelReductionDiffMin< int, long int >& operation, + ( tnlParallelReductionDiffMin< int, long int >& operation, const typename tnlParallelReductionDiffMin< int, long int > :: IndexType size, const typename tnlParallelReductionDiffMin< int, long int > :: RealType* deviceInput1, const typename tnlParallelReductionDiffMin< int, long int > :: RealType* deviceInput2, typename tnlParallelReductionDiffMin< int, long int > :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionDiffMin< float, long int > > - ( const tnlParallelReductionDiffMin< float, long int >& operation, + ( tnlParallelReductionDiffMin< float, long int >& operation, const typename tnlParallelReductionDiffMin< float, long int > :: IndexType size, const typename tnlParallelReductionDiffMin< float, long int > :: RealType* deviceInput1, const typename tnlParallelReductionDiffMin< float, long int > :: RealType* deviceInput2, typename tnlParallelReductionDiffMin< float, long int> :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionDiffMin< double, long int > > - ( const tnlParallelReductionDiffMin< double, long int>& operation, + ( tnlParallelReductionDiffMin< double, long int>& operation, const typename tnlParallelReductionDiffMin< double, long int > :: IndexType size, const typename tnlParallelReductionDiffMin< double, long int > :: RealType* deviceInput1, const typename tnlParallelReductionDiffMin< double, long int > :: RealType* deviceInput2, @@ -93,7 +93,7 @@ template bool reductionOnCudaDevice< tnlParallelReductionDiffMin< double, long i #ifdef INSTANTIATE_LONG_DOUBLE template bool reductionOnCudaDevice< tnlParallelReductionDiffMin< long double, long int > > - ( const tnlParallelReductionDiffMin< long double, long int>& operation, + ( tnlParallelReductionDiffMin< long double, long int>& operation, const typename tnlParallelReductionDiffMin< long double, long int > :: IndexType size, const typename tnlParallelReductionDiffMin< long double, long int > :: RealType* deviceInput1, const typename tnlParallelReductionDiffMin< long double, long int > :: RealType* deviceInput2, diff --git a/src/core/cuda/cuda-reduction-diff-sum_impl.cu b/src/core/cuda/cuda-reduction-diff-sum_impl.cu index aa08778ea70f66cc6c6d24b86effa4cf942db1d3..8f2eb27587117e1ce35ac8f39caf9cbb7891c90b 100644 --- a/src/core/cuda/cuda-reduction-diff-sum_impl.cu +++ b/src/core/cuda/cuda-reduction-diff-sum_impl.cu @@ -25,28 +25,28 @@ */ template bool reductionOnCudaDevice< tnlParallelReductionDiffSum< char, int > > - ( const tnlParallelReductionDiffSum< char, int >& operation, + ( tnlParallelReductionDiffSum< char, int >& operation, const typename tnlParallelReductionDiffSum< char, int > :: IndexType size, const typename tnlParallelReductionDiffSum< char, int > :: RealType* deviceInput1, const typename tnlParallelReductionDiffSum< char, int > :: RealType* deviceInput2, typename tnlParallelReductionDiffSum< char, int > :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionDiffSum< int, int > > - ( const tnlParallelReductionDiffSum< int, int >& operation, + ( tnlParallelReductionDiffSum< int, int >& operation, const typename tnlParallelReductionDiffSum< int, int > :: IndexType size, const typename tnlParallelReductionDiffSum< int, int > :: RealType* deviceInput1, const typename tnlParallelReductionDiffSum< int, int > :: RealType* deviceInput2, typename tnlParallelReductionDiffSum< int, int > :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionDiffSum< float, int > > - ( const tnlParallelReductionDiffSum< float, int >& operation, + ( tnlParallelReductionDiffSum< float, int >& operation, const typename tnlParallelReductionDiffSum< float, int > :: IndexType size, const typename tnlParallelReductionDiffSum< float, int > :: RealType* deviceInput1, const typename tnlParallelReductionDiffSum< float, int > :: RealType* deviceInput2, typename tnlParallelReductionDiffSum< float, int> :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionDiffSum< double, int > > - ( const tnlParallelReductionDiffSum< double, int>& operation, + ( tnlParallelReductionDiffSum< double, int>& operation, const typename tnlParallelReductionDiffSum< double, int > :: IndexType size, const typename tnlParallelReductionDiffSum< double, int > :: RealType* deviceInput1, const typename tnlParallelReductionDiffSum< double, int > :: RealType* deviceInput2, @@ -54,7 +54,7 @@ template bool reductionOnCudaDevice< tnlParallelReductionDiffSum< double, int > #ifdef INSTANTIATE_LONG_DOUBLE template bool reductionOnCudaDevice< tnlParallelReductionDiffSum< long double, int > > - ( const tnlParallelReductionDiffSum< long double, int>& operation, + ( tnlParallelReductionDiffSum< long double, int>& operation, const typename tnlParallelReductionDiffSum< long double, int > :: IndexType size, const typename tnlParallelReductionDiffSum< long double, int > :: RealType* deviceInput1, const typename tnlParallelReductionDiffSum< long double, int > :: RealType* deviceInput2, @@ -63,28 +63,28 @@ template bool reductionOnCudaDevice< tnlParallelReductionDiffSum< long double, i #ifdef INSTANTIATE_LONG_INT template bool reductionOnCudaDevice< tnlParallelReductionDiffSum< char, long int > > - ( const tnlParallelReductionDiffSum< char, long int >& operation, + ( tnlParallelReductionDiffSum< char, long int >& operation, const typename tnlParallelReductionDiffSum< char, long int > :: IndexType size, const typename tnlParallelReductionDiffSum< char, long int > :: RealType* deviceInput1, const typename tnlParallelReductionDiffSum< char, long int > :: RealType* deviceInput2, typename tnlParallelReductionDiffSum< char, long int > :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionDiffSum< int, long int > > - ( const tnlParallelReductionDiffSum< int, long int >& operation, + ( tnlParallelReductionDiffSum< int, long int >& operation, const typename tnlParallelReductionDiffSum< int, long int > :: IndexType size, const typename tnlParallelReductionDiffSum< int, long int > :: RealType* deviceInput1, const typename tnlParallelReductionDiffSum< int, long int > :: RealType* deviceInput2, typename tnlParallelReductionDiffSum< int, long int > :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionDiffSum< float, long int > > - ( const tnlParallelReductionDiffSum< float, long int >& operation, + ( tnlParallelReductionDiffSum< float, long int >& operation, const typename tnlParallelReductionDiffSum< float, long int > :: IndexType size, const typename tnlParallelReductionDiffSum< float, long int > :: RealType* deviceInput1, const typename tnlParallelReductionDiffSum< float, long int > :: RealType* deviceInput2, typename tnlParallelReductionDiffSum< float, long int> :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionDiffSum< double, long int > > - ( const tnlParallelReductionDiffSum< double, long int>& operation, + ( tnlParallelReductionDiffSum< double, long int>& operation, const typename tnlParallelReductionDiffSum< double, long int > :: IndexType size, const typename tnlParallelReductionDiffSum< double, long int > :: RealType* deviceInput1, const typename tnlParallelReductionDiffSum< double, long int > :: RealType* deviceInput2, @@ -92,7 +92,7 @@ template bool reductionOnCudaDevice< tnlParallelReductionDiffSum< double, long i #ifdef INSTANTIATE_LONG_DOUBLE template bool reductionOnCudaDevice< tnlParallelReductionDiffSum< long double, long int > > - ( const tnlParallelReductionDiffSum< long double, long int>& operation, + ( tnlParallelReductionDiffSum< long double, long int>& operation, const typename tnlParallelReductionDiffSum< long double, long int > :: IndexType size, const typename tnlParallelReductionDiffSum< long double, long int > :: RealType* deviceInput1, const typename tnlParallelReductionDiffSum< long double, long int > :: RealType* deviceInput2, diff --git a/src/core/cuda/cuda-reduction-equalities_impl.cu b/src/core/cuda/cuda-reduction-equalities_impl.cu index 6bf7f0263055adc7d6deda2f4316de48006ec3f6..398012099e47da5991ff7e97ff228c8ac564fdaf 100644 --- a/src/core/cuda/cuda-reduction-equalities_impl.cu +++ b/src/core/cuda/cuda-reduction-equalities_impl.cu @@ -24,28 +24,28 @@ * Equalities */ template bool reductionOnCudaDevice< tnlParallelReductionEqualities< char, int > > - ( const tnlParallelReductionEqualities< char, int >& operation, + ( tnlParallelReductionEqualities< char, int >& operation, const typename tnlParallelReductionEqualities< char, int > :: IndexType size, const typename tnlParallelReductionEqualities< char, int > :: RealType* deviceInput1, const typename tnlParallelReductionEqualities< char, int > :: RealType* deviceInput2, typename tnlParallelReductionEqualities< char, int > :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionEqualities< int, int > > - ( const tnlParallelReductionEqualities< int, int >& operation, + ( tnlParallelReductionEqualities< int, int >& operation, const typename tnlParallelReductionEqualities< int, int > :: IndexType size, const typename tnlParallelReductionEqualities< int, int > :: RealType* deviceInput1, const typename tnlParallelReductionEqualities< int, int > :: RealType* deviceInput2, typename tnlParallelReductionEqualities< int, int > :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionEqualities< float, int > > - ( const tnlParallelReductionEqualities< float, int >& operation, + ( tnlParallelReductionEqualities< float, int >& operation, const typename tnlParallelReductionEqualities< float, int > :: IndexType size, const typename tnlParallelReductionEqualities< float, int > :: RealType* deviceInput1, const typename tnlParallelReductionEqualities< float, int > :: RealType* deviceInput2, typename tnlParallelReductionEqualities< float, int> :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionEqualities< double, int > > - ( const tnlParallelReductionEqualities< double, int>& operation, + ( tnlParallelReductionEqualities< double, int>& operation, const typename tnlParallelReductionEqualities< double, int > :: IndexType size, const typename tnlParallelReductionEqualities< double, int > :: RealType* deviceInput1, const typename tnlParallelReductionEqualities< double, int > :: RealType* deviceInput2, @@ -53,7 +53,7 @@ template bool reductionOnCudaDevice< tnlParallelReductionEqualities< double, int #ifdef INSTANTIATE_LONG_DOUBLE template bool reductionOnCudaDevice< tnlParallelReductionEqualities< long double, int > > - ( const tnlParallelReductionEqualities< long double, int>& operation, + ( tnlParallelReductionEqualities< long double, int>& operation, const typename tnlParallelReductionEqualities< long double, int > :: IndexType size, const typename tnlParallelReductionEqualities< long double, int > :: RealType* deviceInput1, const typename tnlParallelReductionEqualities< long double, int > :: RealType* deviceInput2, @@ -62,28 +62,28 @@ template bool reductionOnCudaDevice< tnlParallelReductionEqualities< long double #ifdef INSTANTIATE_LONG_INT template bool reductionOnCudaDevice< tnlParallelReductionEqualities< char, long int > > - ( const tnlParallelReductionEqualities< char, long int >& operation, + ( tnlParallelReductionEqualities< char, long int >& operation, const typename tnlParallelReductionEqualities< char, long int > :: IndexType size, const typename tnlParallelReductionEqualities< char, long int > :: RealType* deviceInput1, const typename tnlParallelReductionEqualities< char, long int > :: RealType* deviceInput2, typename tnlParallelReductionEqualities< char, long int > :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionEqualities< int, long int > > - ( const tnlParallelReductionEqualities< int, long int >& operation, + ( tnlParallelReductionEqualities< int, long int >& operation, const typename tnlParallelReductionEqualities< int, long int > :: IndexType size, const typename tnlParallelReductionEqualities< int, long int > :: RealType* deviceInput1, const typename tnlParallelReductionEqualities< int, long int > :: RealType* deviceInput2, typename tnlParallelReductionEqualities< int, long int > :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionEqualities< float, long int > > - ( const tnlParallelReductionEqualities< float, long int >& operation, + ( tnlParallelReductionEqualities< float, long int >& operation, const typename tnlParallelReductionEqualities< float, long int > :: IndexType size, const typename tnlParallelReductionEqualities< float, long int > :: RealType* deviceInput1, const typename tnlParallelReductionEqualities< float, long int > :: RealType* deviceInput2, typename tnlParallelReductionEqualities< float, long int> :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionEqualities< double, long int > > - ( const tnlParallelReductionEqualities< double, long int>& operation, + ( tnlParallelReductionEqualities< double, long int>& operation, const typename tnlParallelReductionEqualities< double, long int > :: IndexType size, const typename tnlParallelReductionEqualities< double, long int > :: RealType* deviceInput1, const typename tnlParallelReductionEqualities< double, long int > :: RealType* deviceInput2, @@ -91,7 +91,7 @@ template bool reductionOnCudaDevice< tnlParallelReductionEqualities< double, lon #ifdef INSTANTIATE_LONG_DOUBLE template bool reductionOnCudaDevice< tnlParallelReductionEqualities< long double, long int > > - ( const tnlParallelReductionEqualities< long double, long int>& operation, + ( tnlParallelReductionEqualities< long double, long int>& operation, const typename tnlParallelReductionEqualities< long double, long int > :: IndexType size, const typename tnlParallelReductionEqualities< long double, long int > :: RealType* deviceInput1, const typename tnlParallelReductionEqualities< long double, long int > :: RealType* deviceInput2, diff --git a/src/core/cuda/cuda-reduction-inequalities_impl.cu b/src/core/cuda/cuda-reduction-inequalities_impl.cu index 828c88af106c9e8965bf64d12bc798aac41a9cae..479d9b2a31efec4c7131765e13186cd303aadea3 100644 --- a/src/core/cuda/cuda-reduction-inequalities_impl.cu +++ b/src/core/cuda/cuda-reduction-inequalities_impl.cu @@ -24,28 +24,28 @@ * Inequalities */ template bool reductionOnCudaDevice< tnlParallelReductionInequalities< char, int > > - ( const tnlParallelReductionInequalities< char, int >& operation, + ( tnlParallelReductionInequalities< char, int >& operation, const typename tnlParallelReductionInequalities< char, int > :: IndexType size, const typename tnlParallelReductionInequalities< char, int > :: RealType* deviceInput1, const typename tnlParallelReductionInequalities< char, int > :: RealType* deviceInput2, typename tnlParallelReductionInequalities< char, int > :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionInequalities< int, int > > - ( const tnlParallelReductionInequalities< int, int >& operation, + ( tnlParallelReductionInequalities< int, int >& operation, const typename tnlParallelReductionInequalities< int, int > :: IndexType size, const typename tnlParallelReductionInequalities< int, int > :: RealType* deviceInput1, const typename tnlParallelReductionInequalities< int, int > :: RealType* deviceInput2, typename tnlParallelReductionInequalities< int, int > :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionInequalities< float, int > > - ( const tnlParallelReductionInequalities< float, int >& operation, + ( tnlParallelReductionInequalities< float, int >& operation, const typename tnlParallelReductionInequalities< float, int > :: IndexType size, const typename tnlParallelReductionInequalities< float, int > :: RealType* deviceInput1, const typename tnlParallelReductionInequalities< float, int > :: RealType* deviceInput2, typename tnlParallelReductionInequalities< float, int> :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionInequalities< double, int > > - ( const tnlParallelReductionInequalities< double, int>& operation, + ( tnlParallelReductionInequalities< double, int>& operation, const typename tnlParallelReductionInequalities< double, int > :: IndexType size, const typename tnlParallelReductionInequalities< double, int > :: RealType* deviceInput1, const typename tnlParallelReductionInequalities< double, int > :: RealType* deviceInput2, @@ -53,7 +53,7 @@ template bool reductionOnCudaDevice< tnlParallelReductionInequalities< double, i #ifdef INSTANTIATE_LONG_DOUBLE template bool reductionOnCudaDevice< tnlParallelReductionInequalities< long double, int > > - ( const tnlParallelReductionInequalities< long double, int>& operation, + ( tnlParallelReductionInequalities< long double, int>& operation, const typename tnlParallelReductionInequalities< long double, int > :: IndexType size, const typename tnlParallelReductionInequalities< long double, int > :: RealType* deviceInput1, const typename tnlParallelReductionInequalities< long double, int > :: RealType* deviceInput2, @@ -62,28 +62,28 @@ template bool reductionOnCudaDevice< tnlParallelReductionInequalities< long doub #ifdef INSTANTIATE_LONG_INT template bool reductionOnCudaDevice< tnlParallelReductionInequalities< char, long int > > - ( const tnlParallelReductionInequalities< char, long int >& operation, + ( tnlParallelReductionInequalities< char, long int >& operation, const typename tnlParallelReductionInequalities< char, long int > :: IndexType size, const typename tnlParallelReductionInequalities< char, long int > :: RealType* deviceInput1, const typename tnlParallelReductionInequalities< char, long int > :: RealType* deviceInput2, typename tnlParallelReductionInequalities< char, long int > :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionInequalities< int, long int > > - ( const tnlParallelReductionInequalities< int, long int >& operation, + ( tnlParallelReductionInequalities< int, long int >& operation, const typename tnlParallelReductionInequalities< int, long int > :: IndexType size, const typename tnlParallelReductionInequalities< int, long int > :: RealType* deviceInput1, const typename tnlParallelReductionInequalities< int, long int > :: RealType* deviceInput2, typename tnlParallelReductionInequalities< int, long int > :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionInequalities< float, long int > > - ( const tnlParallelReductionInequalities< float, long int >& operation, + ( tnlParallelReductionInequalities< float, long int >& operation, const typename tnlParallelReductionInequalities< float, long int > :: IndexType size, const typename tnlParallelReductionInequalities< float, long int > :: RealType* deviceInput1, const typename tnlParallelReductionInequalities< float, long int > :: RealType* deviceInput2, typename tnlParallelReductionInequalities< float, long int> :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionInequalities< double, long int > > - ( const tnlParallelReductionInequalities< double, long int>& operation, + ( tnlParallelReductionInequalities< double, long int>& operation, const typename tnlParallelReductionInequalities< double, long int > :: IndexType size, const typename tnlParallelReductionInequalities< double, long int > :: RealType* deviceInput1, const typename tnlParallelReductionInequalities< double, long int > :: RealType* deviceInput2, @@ -91,7 +91,7 @@ template bool reductionOnCudaDevice< tnlParallelReductionInequalities< double, l #ifdef INSTANTIATE_LONG_DOUBLE template bool reductionOnCudaDevice< tnlParallelReductionInequalities< long double, long int > > - ( const tnlParallelReductionInequalities< long double, long int>& operation, + ( tnlParallelReductionInequalities< long double, long int>& operation, const typename tnlParallelReductionInequalities< long double, long int > :: IndexType size, const typename tnlParallelReductionInequalities< long double, long int > :: RealType* deviceInput1, const typename tnlParallelReductionInequalities< long double, long int > :: RealType* deviceInput2, diff --git a/src/core/cuda/cuda-reduction-l2-norm_impl.cu b/src/core/cuda/cuda-reduction-l2-norm_impl.cu new file mode 100644 index 0000000000000000000000000000000000000000..214a15b53b37ef0ec780468b15701cb120e1d3c4 --- /dev/null +++ b/src/core/cuda/cuda-reduction-l2-norm_impl.cu @@ -0,0 +1,80 @@ +/*************************************************************************** + cuda-reduction-l2-norm_impl.cu - description + ------------------- + begin : Jan 19, 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. * + * * + ***************************************************************************/ + +#include <core/cuda/reduction-operations.h> +#include <core/cuda/cuda-reduction.h> + +#ifdef TEMPLATE_EXPLICIT_INSTANTIATION + +/**** + * L2 Norm + */ +template bool reductionOnCudaDevice< tnlParallelReductionL2Norm< float, int > > + ( tnlParallelReductionL2Norm< float, int >& operation, + const typename tnlParallelReductionL2Norm< float, int > :: IndexType size, + const typename tnlParallelReductionL2Norm< float, int > :: RealType* deviceInput1, + const typename tnlParallelReductionL2Norm< float, int > :: RealType* deviceInput2, + typename tnlParallelReductionL2Norm< float, int> :: ResultType& result ); + +template bool reductionOnCudaDevice< tnlParallelReductionL2Norm< double, int > > + ( tnlParallelReductionL2Norm< double, int>& operation, + const typename tnlParallelReductionL2Norm< double, int > :: IndexType size, + const typename tnlParallelReductionL2Norm< double, int > :: RealType* deviceInput1, + const typename tnlParallelReductionL2Norm< double, int > :: RealType* deviceInput2, + typename tnlParallelReductionL2Norm< double, int> :: ResultType& result ); + +#ifdef INSTANTIATE_LONG_DOUBLE +template bool reductionOnCudaDevice< tnlParallelReductionL2Norm< long double, int > > + ( tnlParallelReductionL2Norm< long double, int>& operation, + const typename tnlParallelReductionL2Norm< long double, int > :: IndexType size, + const typename tnlParallelReductionL2Norm< long double, int > :: RealType* deviceInput1, + const typename tnlParallelReductionL2Norm< long double, int > :: RealType* deviceInput2, + typename tnlParallelReductionL2Norm< long double, int> :: ResultType& result ); +#endif + +#ifdef INSTANTIATE_LONG_INT +template bool reductionOnCudaDevice< tnlParallelReductionL2Norm< int, long int > > + ( tnlParallelReductionL2Norm< int, long int >& operation, + const typename tnlParallelReductionL2Norm< int, long int > :: IndexType size, + const typename tnlParallelReductionL2Norm< int, long int > :: RealType* deviceInput1, + const typename tnlParallelReductionL2Norm< int, long int > :: RealType* deviceInput2, + typename tnlParallelReductionL2Norm< int, long int> :: ResultType& result ); + +template bool reductionOnCudaDevice< tnlParallelReductionL2Norm< float, long int > > + ( tnlParallelReductionL2Norm< float, long int >& operation, + const typename tnlParallelReductionL2Norm< float, long int > :: IndexType size, + const typename tnlParallelReductionL2Norm< float, long int > :: RealType* deviceInput1, + const typename tnlParallelReductionL2Norm< float, long int > :: RealType* deviceInput2, + typename tnlParallelReductionL2Norm< float, long int> :: ResultType& result ); + +template bool reductionOnCudaDevice< tnlParallelReductionL2Norm< double, long int > > + ( tnlParallelReductionL2Norm< double, long int>& operation, + const typename tnlParallelReductionL2Norm< double, long int > :: IndexType size, + const typename tnlParallelReductionL2Norm< double, long int > :: RealType* deviceInput1, + const typename tnlParallelReductionL2Norm< double, long int > :: RealType* deviceInput2, + typename tnlParallelReductionL2Norm< double, long int> :: ResultType& result ); + +#ifdef INSTANTIATE_LONG_DOUBLE +template bool reductionOnCudaDevice< tnlParallelReductionL2Norm< long double, long int > > + ( tnlParallelReductionL2Norm< long double, long int>& operation, + const typename tnlParallelReductionL2Norm< long double, long int > :: IndexType size, + const typename tnlParallelReductionL2Norm< long double, long int > :: RealType* deviceInput1, + const typename tnlParallelReductionL2Norm< long double, long int > :: RealType* deviceInput2, + typename tnlParallelReductionL2Norm< long double, long int> :: ResultType& result ); +#endif +#endif +#endif \ No newline at end of file diff --git a/src/core/cuda/cuda-reduction-lp-norm_impl.cu b/src/core/cuda/cuda-reduction-lp-norm_impl.cu index a5f5d6644cad7c3c9ff11a83e3343f75f16471e4..4de950159022a52d973982c0d60b0ccd99951bdb 100644 --- a/src/core/cuda/cuda-reduction-lp-norm_impl.cu +++ b/src/core/cuda/cuda-reduction-lp-norm_impl.cu @@ -24,14 +24,14 @@ * Lp Norm */ template bool reductionOnCudaDevice< tnlParallelReductionLpNorm< float, int > > - ( const tnlParallelReductionLpNorm< float, int >& operation, + ( tnlParallelReductionLpNorm< float, int >& operation, const typename tnlParallelReductionLpNorm< float, int > :: IndexType size, const typename tnlParallelReductionLpNorm< float, int > :: RealType* deviceInput1, const typename tnlParallelReductionLpNorm< float, int > :: RealType* deviceInput2, typename tnlParallelReductionLpNorm< float, int> :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionLpNorm< double, int > > - ( const tnlParallelReductionLpNorm< double, int>& operation, + ( tnlParallelReductionLpNorm< double, int>& operation, const typename tnlParallelReductionLpNorm< double, int > :: IndexType size, const typename tnlParallelReductionLpNorm< double, int > :: RealType* deviceInput1, const typename tnlParallelReductionLpNorm< double, int > :: RealType* deviceInput2, @@ -39,7 +39,7 @@ template bool reductionOnCudaDevice< tnlParallelReductionLpNorm< double, int > > #ifdef INSTANTIATE_LONG_DOUBLE template bool reductionOnCudaDevice< tnlParallelReductionLpNorm< long double, int > > - ( const tnlParallelReductionLpNorm< long double, int>& operation, + ( tnlParallelReductionLpNorm< long double, int>& operation, const typename tnlParallelReductionLpNorm< long double, int > :: IndexType size, const typename tnlParallelReductionLpNorm< long double, int > :: RealType* deviceInput1, const typename tnlParallelReductionLpNorm< long double, int > :: RealType* deviceInput2, @@ -48,21 +48,21 @@ template bool reductionOnCudaDevice< tnlParallelReductionLpNorm< long double, in #ifdef INSTANTIATE_LONG_INT template bool reductionOnCudaDevice< tnlParallelReductionLpNorm< int, long int > > - ( const tnlParallelReductionLpNorm< int, long int >& operation, + ( tnlParallelReductionLpNorm< int, long int >& operation, const typename tnlParallelReductionLpNorm< int, long int > :: IndexType size, const typename tnlParallelReductionLpNorm< int, long int > :: RealType* deviceInput1, const typename tnlParallelReductionLpNorm< int, long int > :: RealType* deviceInput2, typename tnlParallelReductionLpNorm< int, long int> :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionLpNorm< float, long int > > - ( const tnlParallelReductionLpNorm< float, long int >& operation, + ( tnlParallelReductionLpNorm< float, long int >& operation, const typename tnlParallelReductionLpNorm< float, long int > :: IndexType size, const typename tnlParallelReductionLpNorm< float, long int > :: RealType* deviceInput1, const typename tnlParallelReductionLpNorm< float, long int > :: RealType* deviceInput2, typename tnlParallelReductionLpNorm< float, long int> :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionLpNorm< double, long int > > - ( const tnlParallelReductionLpNorm< double, long int>& operation, + ( tnlParallelReductionLpNorm< double, long int>& operation, const typename tnlParallelReductionLpNorm< double, long int > :: IndexType size, const typename tnlParallelReductionLpNorm< double, long int > :: RealType* deviceInput1, const typename tnlParallelReductionLpNorm< double, long int > :: RealType* deviceInput2, @@ -70,7 +70,7 @@ template bool reductionOnCudaDevice< tnlParallelReductionLpNorm< double, long in #ifdef INSTANTIATE_LONG_DOUBLE template bool reductionOnCudaDevice< tnlParallelReductionLpNorm< long double, long int > > - ( const tnlParallelReductionLpNorm< long double, long int>& operation, + ( tnlParallelReductionLpNorm< long double, long int>& operation, const typename tnlParallelReductionLpNorm< long double, long int > :: IndexType size, const typename tnlParallelReductionLpNorm< long double, long int > :: RealType* deviceInput1, const typename tnlParallelReductionLpNorm< long double, long int > :: RealType* deviceInput2, diff --git a/src/core/cuda/cuda-reduction-max_impl.cu b/src/core/cuda/cuda-reduction-max_impl.cu index cba153c81bf8d4a7a0964b62f155217ff10b7a26..cfca4156f9ba521d7c6625f475126ecae546b91d 100644 --- a/src/core/cuda/cuda-reduction-max_impl.cu +++ b/src/core/cuda/cuda-reduction-max_impl.cu @@ -25,28 +25,28 @@ */ template bool reductionOnCudaDevice< tnlParallelReductionMax< char, int > > - ( const tnlParallelReductionMax< char, int >& operation, + ( tnlParallelReductionMax< char, int >& operation, const typename tnlParallelReductionMax< char, int > :: IndexType size, const typename tnlParallelReductionMax< char, int > :: RealType* deviceInput1, const typename tnlParallelReductionMax< char, int > :: RealType* deviceInput2, typename tnlParallelReductionMax< char, int > :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionMax< int, int > > - ( const tnlParallelReductionMax< int, int >& operation, + ( tnlParallelReductionMax< int, int >& operation, const typename tnlParallelReductionMax< int, int > :: IndexType size, const typename tnlParallelReductionMax< int, int > :: RealType* deviceInput1, const typename tnlParallelReductionMax< int, int > :: RealType* deviceInput2, typename tnlParallelReductionMax< int, int > :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionMax< float, int > > - ( const tnlParallelReductionMax< float, int >& operation, + ( tnlParallelReductionMax< float, int >& operation, const typename tnlParallelReductionMax< float, int > :: IndexType size, const typename tnlParallelReductionMax< float, int > :: RealType* deviceInput1, const typename tnlParallelReductionMax< float, int > :: RealType* deviceInput2, typename tnlParallelReductionMax< float, int> :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionMax< double, int > > - ( const tnlParallelReductionMax< double, int>& operation, + ( tnlParallelReductionMax< double, int>& operation, const typename tnlParallelReductionMax< double, int > :: IndexType size, const typename tnlParallelReductionMax< double, int > :: RealType* deviceInput1, const typename tnlParallelReductionMax< double, int > :: RealType* deviceInput2, @@ -54,7 +54,7 @@ template bool reductionOnCudaDevice< tnlParallelReductionMax< double, int > > #ifdef INSTANTIATE_LONG_DOUBLE template bool reductionOnCudaDevice< tnlParallelReductionMax< long double, int > > - ( const tnlParallelReductionMax< long double, int>& operation, + ( tnlParallelReductionMax< long double, int>& operation, const typename tnlParallelReductionMax< long double, int > :: IndexType size, const typename tnlParallelReductionMax< long double, int > :: RealType* deviceInput1, const typename tnlParallelReductionMax< long double, int > :: RealType* deviceInput2, @@ -63,28 +63,28 @@ template bool reductionOnCudaDevice< tnlParallelReductionMax< long double, int > #ifdef INSTANTIATE_LONG_INT template bool reductionOnCudaDevice< tnlParallelReductionMax< char, long int > > - ( const tnlParallelReductionMax< char, long int >& operation, + ( tnlParallelReductionMax< char, long int >& operation, const typename tnlParallelReductionMax< char, long int > :: IndexType size, const typename tnlParallelReductionMax< char, long int > :: RealType* deviceInput1, const typename tnlParallelReductionMax< char, long int > :: RealType* deviceInput2, typename tnlParallelReductionMax< char, long int > :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionMax< int, long int > > - ( const tnlParallelReductionMax< int, long int >& operation, + ( tnlParallelReductionMax< int, long int >& operation, const typename tnlParallelReductionMax< int, long int > :: IndexType size, const typename tnlParallelReductionMax< int, long int > :: RealType* deviceInput1, const typename tnlParallelReductionMax< int, long int > :: RealType* deviceInput2, typename tnlParallelReductionMax< int, long int > :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionMax< float, long int > > - ( const tnlParallelReductionMax< float, long int >& operation, + ( tnlParallelReductionMax< float, long int >& operation, const typename tnlParallelReductionMax< float, long int > :: IndexType size, const typename tnlParallelReductionMax< float, long int > :: RealType* deviceInput1, const typename tnlParallelReductionMax< float, long int > :: RealType* deviceInput2, typename tnlParallelReductionMax< float, long int> :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionMax< double, long int > > - ( const tnlParallelReductionMax< double, long int>& operation, + ( tnlParallelReductionMax< double, long int>& operation, const typename tnlParallelReductionMax< double, long int > :: IndexType size, const typename tnlParallelReductionMax< double, long int > :: RealType* deviceInput1, const typename tnlParallelReductionMax< double, long int > :: RealType* deviceInput2, @@ -92,7 +92,7 @@ template bool reductionOnCudaDevice< tnlParallelReductionMax< double, long int > #ifdef INSTANTIATE_LONG_DOUBLE template bool reductionOnCudaDevice< tnlParallelReductionMax< long double, long int > > - ( const tnlParallelReductionMax< long double, long int>& operation, + ( tnlParallelReductionMax< long double, long int>& operation, const typename tnlParallelReductionMax< long double, long int > :: IndexType size, const typename tnlParallelReductionMax< long double, long int > :: RealType* deviceInput1, const typename tnlParallelReductionMax< long double, long int > :: RealType* deviceInput2, diff --git a/src/core/cuda/cuda-reduction-min_impl.cu b/src/core/cuda/cuda-reduction-min_impl.cu index dc5a1f41407b410e4333f73c70744506814288a3..535b38a32f8199fe6fc05abe5b59cff7cdace55c 100644 --- a/src/core/cuda/cuda-reduction-min_impl.cu +++ b/src/core/cuda/cuda-reduction-min_impl.cu @@ -25,28 +25,28 @@ */ template bool reductionOnCudaDevice< tnlParallelReductionMin< char, int > > - ( const tnlParallelReductionMin< char, int >& operation, + ( tnlParallelReductionMin< char, int >& operation, const typename tnlParallelReductionMin< char, int > :: IndexType size, const typename tnlParallelReductionMin< char, int > :: RealType* deviceInput1, const typename tnlParallelReductionMin< char, int > :: RealType* deviceInput2, typename tnlParallelReductionMin< char, int > :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionMin< int, int > > - ( const tnlParallelReductionMin< int, int >& operation, + ( tnlParallelReductionMin< int, int >& operation, const typename tnlParallelReductionMin< int, int > :: IndexType size, const typename tnlParallelReductionMin< int, int > :: RealType* deviceInput1, const typename tnlParallelReductionMin< int, int > :: RealType* deviceInput2, typename tnlParallelReductionMin< int, int > :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionMin< float, int > > - ( const tnlParallelReductionMin< float, int >& operation, + ( tnlParallelReductionMin< float, int >& operation, const typename tnlParallelReductionMin< float, int > :: IndexType size, const typename tnlParallelReductionMin< float, int > :: RealType* deviceInput1, const typename tnlParallelReductionMin< float, int > :: RealType* deviceInput2, typename tnlParallelReductionMin< float, int> :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionMin< double, int > > - ( const tnlParallelReductionMin< double, int>& operation, + ( tnlParallelReductionMin< double, int>& operation, const typename tnlParallelReductionMin< double, int > :: IndexType size, const typename tnlParallelReductionMin< double, int > :: RealType* deviceInput1, const typename tnlParallelReductionMin< double, int > :: RealType* deviceInput2, @@ -54,7 +54,7 @@ template bool reductionOnCudaDevice< tnlParallelReductionMin< double, int > > #ifdef INSTANTIATE_LONG_DOUBLE template bool reductionOnCudaDevice< tnlParallelReductionMin< long double, int > > - ( const tnlParallelReductionMin< long double, int>& operation, + ( tnlParallelReductionMin< long double, int>& operation, const typename tnlParallelReductionMin< long double, int > :: IndexType size, const typename tnlParallelReductionMin< long double, int > :: RealType* deviceInput1, const typename tnlParallelReductionMin< long double, int > :: RealType* deviceInput2, @@ -63,28 +63,28 @@ template bool reductionOnCudaDevice< tnlParallelReductionMin< long double, int > #ifdef INSTANTIATE_LONG_INT template bool reductionOnCudaDevice< tnlParallelReductionMin< char, long int > > - ( const tnlParallelReductionMin< char, long int >& operation, + ( tnlParallelReductionMin< char, long int >& operation, const typename tnlParallelReductionMin< char, long int > :: IndexType size, const typename tnlParallelReductionMin< char, long int > :: RealType* deviceInput1, const typename tnlParallelReductionMin< char, long int > :: RealType* deviceInput2, typename tnlParallelReductionMin< char, long int > :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionMin< int, long int > > - ( const tnlParallelReductionMin< int, long int >& operation, + ( tnlParallelReductionMin< int, long int >& operation, const typename tnlParallelReductionMin< int, long int > :: IndexType size, const typename tnlParallelReductionMin< int, long int > :: RealType* deviceInput1, const typename tnlParallelReductionMin< int, long int > :: RealType* deviceInput2, typename tnlParallelReductionMin< int, long int > :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionMin< float, long int > > - ( const tnlParallelReductionMin< float, long int >& operation, + ( tnlParallelReductionMin< float, long int >& operation, const typename tnlParallelReductionMin< float, long int > :: IndexType size, const typename tnlParallelReductionMin< float, long int > :: RealType* deviceInput1, const typename tnlParallelReductionMin< float, long int > :: RealType* deviceInput2, typename tnlParallelReductionMin< float, long int> :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionMin< double, long int > > - ( const tnlParallelReductionMin< double, long int>& operation, + ( tnlParallelReductionMin< double, long int>& operation, const typename tnlParallelReductionMin< double, long int > :: IndexType size, const typename tnlParallelReductionMin< double, long int > :: RealType* deviceInput1, const typename tnlParallelReductionMin< double, long int > :: RealType* deviceInput2, @@ -92,7 +92,7 @@ template bool reductionOnCudaDevice< tnlParallelReductionMin< double, long int > #ifdef INSTANTIATE_LONG_DOUBLE template bool reductionOnCudaDevice< tnlParallelReductionMin< long double, long int > > - ( const tnlParallelReductionMin< long double, long int>& operation, + ( tnlParallelReductionMin< long double, long int>& operation, const typename tnlParallelReductionMin< long double, long int > :: IndexType size, const typename tnlParallelReductionMin< long double, long int > :: RealType* deviceInput1, const typename tnlParallelReductionMin< long double, long int > :: RealType* deviceInput2, diff --git a/src/core/cuda/cuda-reduction-or_impl.cu b/src/core/cuda/cuda-reduction-or_impl.cu index 811ec445fd4c79fc99dd02d023fabdf856c71000..f312e5ff45b73080f11cb8f1d89908a613ecacff 100644 --- a/src/core/cuda/cuda-reduction-or_impl.cu +++ b/src/core/cuda/cuda-reduction-or_impl.cu @@ -24,28 +24,28 @@ * Logical OR */ template bool reductionOnCudaDevice< tnlParallelReductionLogicalOr< char, int > > - ( const tnlParallelReductionLogicalOr< char, int >& operation, + ( tnlParallelReductionLogicalOr< char, int >& operation, const typename tnlParallelReductionLogicalOr< char, int > :: IndexType size, const typename tnlParallelReductionLogicalOr< char, int > :: RealType* deviceInput1, const typename tnlParallelReductionLogicalOr< char, int > :: RealType* deviceInput2, typename tnlParallelReductionLogicalOr< char, int > :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionLogicalOr< int, int > > - ( const tnlParallelReductionLogicalOr< int, int >& operation, + ( tnlParallelReductionLogicalOr< int, int >& operation, const typename tnlParallelReductionLogicalOr< int, int > :: IndexType size, const typename tnlParallelReductionLogicalOr< int, int > :: RealType* deviceInput1, const typename tnlParallelReductionLogicalOr< int, int > :: RealType* deviceInput2, typename tnlParallelReductionLogicalOr< int, int > :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionLogicalOr< float, int > > - ( const tnlParallelReductionLogicalOr< float, int >& operation, + ( tnlParallelReductionLogicalOr< float, int >& operation, const typename tnlParallelReductionLogicalOr< float, int > :: IndexType size, const typename tnlParallelReductionLogicalOr< float, int > :: RealType* deviceInput1, const typename tnlParallelReductionLogicalOr< float, int > :: RealType* deviceInput2, typename tnlParallelReductionLogicalOr< float, int> :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionLogicalOr< double, int > > - ( const tnlParallelReductionLogicalOr< double, int>& operation, + ( tnlParallelReductionLogicalOr< double, int>& operation, const typename tnlParallelReductionLogicalOr< double, int > :: IndexType size, const typename tnlParallelReductionLogicalOr< double, int > :: RealType* deviceInput1, const typename tnlParallelReductionLogicalOr< double, int > :: RealType* deviceInput2, @@ -53,7 +53,7 @@ template bool reductionOnCudaDevice< tnlParallelReductionLogicalOr< double, int #ifdef INSTANTIATE_LONG_DOUBLE template bool reductionOnCudaDevice< tnlParallelReductionLogicalOr< long double, int > > - ( const tnlParallelReductionLogicalOr< long double, int>& operation, + ( tnlParallelReductionLogicalOr< long double, int>& operation, const typename tnlParallelReductionLogicalOr< long double, int > :: IndexType size, const typename tnlParallelReductionLogicalOr< long double, int > :: RealType* deviceInput1, const typename tnlParallelReductionLogicalOr< long double, int > :: RealType* deviceInput2, @@ -62,28 +62,28 @@ template bool reductionOnCudaDevice< tnlParallelReductionLogicalOr< long double, #ifdef INSTANTIATE_LONG_INT template bool reductionOnCudaDevice< tnlParallelReductionLogicalOr< char, long int > > - ( const tnlParallelReductionLogicalOr< char, long int >& operation, + ( tnlParallelReductionLogicalOr< char, long int >& operation, const typename tnlParallelReductionLogicalOr< char, long int > :: IndexType size, const typename tnlParallelReductionLogicalOr< char, long int > :: RealType* deviceInput1, const typename tnlParallelReductionLogicalOr< char, long int > :: RealType* deviceInput2, typename tnlParallelReductionLogicalOr< char, long int > :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionLogicalOr< int, long int > > - ( const tnlParallelReductionLogicalOr< int, long int >& operation, + ( tnlParallelReductionLogicalOr< int, long int >& operation, const typename tnlParallelReductionLogicalOr< int, long int > :: IndexType size, const typename tnlParallelReductionLogicalOr< int, long int > :: RealType* deviceInput1, const typename tnlParallelReductionLogicalOr< int, long int > :: RealType* deviceInput2, typename tnlParallelReductionLogicalOr< int, long int > :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionLogicalOr< float, long int > > - ( const tnlParallelReductionLogicalOr< float, long int >& operation, + ( tnlParallelReductionLogicalOr< float, long int >& operation, const typename tnlParallelReductionLogicalOr< float, long int > :: IndexType size, const typename tnlParallelReductionLogicalOr< float, long int > :: RealType* deviceInput1, const typename tnlParallelReductionLogicalOr< float, long int > :: RealType* deviceInput2, typename tnlParallelReductionLogicalOr< float, long int> :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionLogicalOr< double, long int > > - ( const tnlParallelReductionLogicalOr< double, long int>& operation, + ( tnlParallelReductionLogicalOr< double, long int>& operation, const typename tnlParallelReductionLogicalOr< double, long int > :: IndexType size, const typename tnlParallelReductionLogicalOr< double, long int > :: RealType* deviceInput1, const typename tnlParallelReductionLogicalOr< double, long int > :: RealType* deviceInput2, @@ -91,7 +91,7 @@ template bool reductionOnCudaDevice< tnlParallelReductionLogicalOr< double, long #ifdef INSTANTIATE_LONG_DOUBLE template bool reductionOnCudaDevice< tnlParallelReductionLogicalOr< long double, long int > > - ( const tnlParallelReductionLogicalOr< long double, long int>& operation, + ( tnlParallelReductionLogicalOr< long double, long int>& operation, const typename tnlParallelReductionLogicalOr< long double, long int > :: IndexType size, const typename tnlParallelReductionLogicalOr< long double, long int > :: RealType* deviceInput1, const typename tnlParallelReductionLogicalOr< long double, long int > :: RealType* deviceInput2, diff --git a/src/core/cuda/cuda-reduction-scalar-product_impl.cu b/src/core/cuda/cuda-reduction-scalar-product_impl.cu index 082d65540ae5f5d514436d847b168a97c9ca4ad7..6de27958bdd8bdb15827808c9d2f7fc5aeb72ff5 100644 --- a/src/core/cuda/cuda-reduction-scalar-product_impl.cu +++ b/src/core/cuda/cuda-reduction-scalar-product_impl.cu @@ -24,28 +24,28 @@ * ScalarProduct */ template bool reductionOnCudaDevice< tnlParallelReductionScalarProduct< char, int > > - ( const tnlParallelReductionScalarProduct< char, int >& operation, + ( tnlParallelReductionScalarProduct< char, int >& operation, const typename tnlParallelReductionScalarProduct< char, int > :: IndexType size, const typename tnlParallelReductionScalarProduct< char, int > :: RealType* deviceInput1, const typename tnlParallelReductionScalarProduct< char, int > :: RealType* deviceInput2, typename tnlParallelReductionScalarProduct< char, int > :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionScalarProduct< int, int > > - ( const tnlParallelReductionScalarProduct< int, int >& operation, + ( tnlParallelReductionScalarProduct< int, int >& operation, const typename tnlParallelReductionScalarProduct< int, int > :: IndexType size, const typename tnlParallelReductionScalarProduct< int, int > :: RealType* deviceInput1, const typename tnlParallelReductionScalarProduct< int, int > :: RealType* deviceInput2, typename tnlParallelReductionScalarProduct< int, int > :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionScalarProduct< float, int > > - ( const tnlParallelReductionScalarProduct< float, int >& operation, + ( tnlParallelReductionScalarProduct< float, int >& operation, const typename tnlParallelReductionScalarProduct< float, int > :: IndexType size, const typename tnlParallelReductionScalarProduct< float, int > :: RealType* deviceInput1, const typename tnlParallelReductionScalarProduct< float, int > :: RealType* deviceInput2, typename tnlParallelReductionScalarProduct< float, int> :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionScalarProduct< double, int > > - ( const tnlParallelReductionScalarProduct< double, int>& operation, + ( tnlParallelReductionScalarProduct< double, int>& operation, const typename tnlParallelReductionScalarProduct< double, int > :: IndexType size, const typename tnlParallelReductionScalarProduct< double, int > :: RealType* deviceInput1, const typename tnlParallelReductionScalarProduct< double, int > :: RealType* deviceInput2, @@ -53,7 +53,7 @@ template bool reductionOnCudaDevice< tnlParallelReductionScalarProduct< double, #ifdef INSTANTIATE_LONG_DOUBLE template bool reductionOnCudaDevice< tnlParallelReductionScalarProduct< long double, int > > - ( const tnlParallelReductionScalarProduct< long double, int>& operation, + ( tnlParallelReductionScalarProduct< long double, int>& operation, const typename tnlParallelReductionScalarProduct< long double, int > :: IndexType size, const typename tnlParallelReductionScalarProduct< long double, int > :: RealType* deviceInput1, const typename tnlParallelReductionScalarProduct< long double, int > :: RealType* deviceInput2, @@ -62,28 +62,28 @@ template bool reductionOnCudaDevice< tnlParallelReductionScalarProduct< long dou #ifdef INSTANTIATE_LONG_INT template bool reductionOnCudaDevice< tnlParallelReductionScalarProduct< char, long int > > - ( const tnlParallelReductionScalarProduct< char, long int >& operation, + ( tnlParallelReductionScalarProduct< char, long int >& operation, const typename tnlParallelReductionScalarProduct< char, long int > :: IndexType size, const typename tnlParallelReductionScalarProduct< char, long int > :: RealType* deviceInput1, const typename tnlParallelReductionScalarProduct< char, long int > :: RealType* deviceInput2, typename tnlParallelReductionScalarProduct< char, long int > :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionScalarProduct< int, long int > > - ( const tnlParallelReductionScalarProduct< int, long int >& operation, + ( tnlParallelReductionScalarProduct< int, long int >& operation, const typename tnlParallelReductionScalarProduct< int, long int > :: IndexType size, const typename tnlParallelReductionScalarProduct< int, long int > :: RealType* deviceInput1, const typename tnlParallelReductionScalarProduct< int, long int > :: RealType* deviceInput2, typename tnlParallelReductionScalarProduct< int, long int > :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionScalarProduct< float, long int > > - ( const tnlParallelReductionScalarProduct< float, long int >& operation, + ( tnlParallelReductionScalarProduct< float, long int >& operation, const typename tnlParallelReductionScalarProduct< float, long int > :: IndexType size, const typename tnlParallelReductionScalarProduct< float, long int > :: RealType* deviceInput1, const typename tnlParallelReductionScalarProduct< float, long int > :: RealType* deviceInput2, typename tnlParallelReductionScalarProduct< float, long int> :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionScalarProduct< double, long int > > - ( const tnlParallelReductionScalarProduct< double, long int>& operation, + ( tnlParallelReductionScalarProduct< double, long int>& operation, const typename tnlParallelReductionScalarProduct< double, long int > :: IndexType size, const typename tnlParallelReductionScalarProduct< double, long int > :: RealType* deviceInput1, const typename tnlParallelReductionScalarProduct< double, long int > :: RealType* deviceInput2, @@ -91,7 +91,7 @@ template bool reductionOnCudaDevice< tnlParallelReductionScalarProduct< double, #ifdef INSTANTIATE_LONG_DOUBLE template bool reductionOnCudaDevice< tnlParallelReductionScalarProduct< long double, long int > > - ( const tnlParallelReductionScalarProduct< long double, long int>& operation, + ( tnlParallelReductionScalarProduct< long double, long int>& operation, const typename tnlParallelReductionScalarProduct< long double, long int > :: IndexType size, const typename tnlParallelReductionScalarProduct< long double, long int > :: RealType* deviceInput1, const typename tnlParallelReductionScalarProduct< long double, long int > :: RealType* deviceInput2, diff --git a/src/core/cuda/cuda-reduction-sum_impl.cu b/src/core/cuda/cuda-reduction-sum_impl.cu index 8447ea5f00d8c448362d13181ae70e4574e3c350..62ed0a2beb59e6e71be42552df0a16f28c8ad24d 100644 --- a/src/core/cuda/cuda-reduction-sum_impl.cu +++ b/src/core/cuda/cuda-reduction-sum_impl.cu @@ -25,28 +25,28 @@ */ template bool reductionOnCudaDevice< tnlParallelReductionSum< char, int > > - ( const tnlParallelReductionSum< char, int >& operation, + ( tnlParallelReductionSum< char, int >& operation, const typename tnlParallelReductionSum< char, int > :: IndexType size, const typename tnlParallelReductionSum< char, int > :: RealType* deviceInput1, const typename tnlParallelReductionSum< char, int > :: RealType* deviceInput2, typename tnlParallelReductionSum< char, int > :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionSum< int, int > > - ( const tnlParallelReductionSum< int, int >& operation, + ( tnlParallelReductionSum< int, int >& operation, const typename tnlParallelReductionSum< int, int > :: IndexType size, const typename tnlParallelReductionSum< int, int > :: RealType* deviceInput1, const typename tnlParallelReductionSum< int, int > :: RealType* deviceInput2, typename tnlParallelReductionSum< int, int > :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionSum< float, int > > - ( const tnlParallelReductionSum< float, int >& operation, + ( tnlParallelReductionSum< float, int >& operation, const typename tnlParallelReductionSum< float, int > :: IndexType size, const typename tnlParallelReductionSum< float, int > :: RealType* deviceInput1, const typename tnlParallelReductionSum< float, int > :: RealType* deviceInput2, typename tnlParallelReductionSum< float, int> :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionSum< double, int > > - ( const tnlParallelReductionSum< double, int>& operation, + ( tnlParallelReductionSum< double, int>& operation, const typename tnlParallelReductionSum< double, int > :: IndexType size, const typename tnlParallelReductionSum< double, int > :: RealType* deviceInput1, const typename tnlParallelReductionSum< double, int > :: RealType* deviceInput2, @@ -54,7 +54,7 @@ template bool reductionOnCudaDevice< tnlParallelReductionSum< double, int > > #ifdef INSTANTIATE_LONG_DOUBLE template bool reductionOnCudaDevice< tnlParallelReductionSum< long double, int > > - ( const tnlParallelReductionSum< long double, int>& operation, + ( tnlParallelReductionSum< long double, int>& operation, const typename tnlParallelReductionSum< long double, int > :: IndexType size, const typename tnlParallelReductionSum< long double, int > :: RealType* deviceInput1, const typename tnlParallelReductionSum< long double, int > :: RealType* deviceInput2, @@ -63,28 +63,28 @@ template bool reductionOnCudaDevice< tnlParallelReductionSum< long double, int > #ifdef INSTANTIATE_LONG_INT template bool reductionOnCudaDevice< tnlParallelReductionSum< char, long int > > - ( const tnlParallelReductionSum< char, long int >& operation, + ( tnlParallelReductionSum< char, long int >& operation, const typename tnlParallelReductionSum< char, long int > :: IndexType size, const typename tnlParallelReductionSum< char, long int > :: RealType* deviceInput1, const typename tnlParallelReductionSum< char, long int > :: RealType* deviceInput2, typename tnlParallelReductionSum< char, long int > :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionSum< int, long int > > - ( const tnlParallelReductionSum< int, long int >& operation, + ( tnlParallelReductionSum< int, long int >& operation, const typename tnlParallelReductionSum< int, long int > :: IndexType size, const typename tnlParallelReductionSum< int, long int > :: RealType* deviceInput1, const typename tnlParallelReductionSum< int, long int > :: RealType* deviceInput2, typename tnlParallelReductionSum< int, long int > :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionSum< float, long int > > - ( const tnlParallelReductionSum< float, long int >& operation, + ( tnlParallelReductionSum< float, long int >& operation, const typename tnlParallelReductionSum< float, long int > :: IndexType size, const typename tnlParallelReductionSum< float, long int > :: RealType* deviceInput1, const typename tnlParallelReductionSum< float, long int > :: RealType* deviceInput2, typename tnlParallelReductionSum< float, long int> :: ResultType& result ); template bool reductionOnCudaDevice< tnlParallelReductionSum< double, long int > > - ( const tnlParallelReductionSum< double, long int>& operation, + ( tnlParallelReductionSum< double, long int>& operation, const typename tnlParallelReductionSum< double, long int > :: IndexType size, const typename tnlParallelReductionSum< double, long int > :: RealType* deviceInput1, const typename tnlParallelReductionSum< double, long int > :: RealType* deviceInput2, @@ -92,11 +92,11 @@ template bool reductionOnCudaDevice< tnlParallelReductionSum< double, long int > #ifdef INSTANTIATE_LONG_DOUBLE template bool reductionOnCudaDevice< tnlParallelReductionSum< long double, long int > > - ( const tnlParallelReductionSum< long double, long int>& operation, + ( tnlParallelReductionSum< long double, long int>& operation, const typename tnlParallelReductionSum< long double, long int > :: IndexType size, const typename tnlParallelReductionSum< long double, long int > :: RealType* deviceInput1, const typename tnlParallelReductionSum< long double, long int > :: RealType* deviceInput2, typename tnlParallelReductionSum< long double, long int> :: ResultType& result ); #endif #endif -#endif \ No newline at end of file +#endif diff --git a/src/core/cuda/cuda-reduction_impl.h b/src/core/cuda/cuda-reduction_impl.h index 389d166ca9a11945cab2e2dfafcbfc78106e6acf..e8795ec7bceb1373fc4e9af41fb61b6124b86778 100644 --- a/src/core/cuda/cuda-reduction_impl.h +++ b/src/core/cuda/cuda-reduction_impl.h @@ -42,14 +42,14 @@ using namespace std; * are reduced on CPU. The constant must not be larger * than maximal CUDA grid size. */ -const int minGPUReductionDataSize = 128;//65536; //16384;//1024;//256; +const int minGPUReductionDataSize = 256;//65536; //16384;//1024;//256; //static tnlCudaReductionBuffer cudaReductionBuffer( 8 * minGPUReductionDataSize ); #ifdef HAVE_CUDA template< typename Operation, int blockSize > -__global__ void tnlCUDAReductionKernel( const Operation operation, +__global__ void tnlCUDAReductionKernel( Operation operation, const typename Operation :: IndexType size, const typename Operation :: RealType* input1, const typename Operation :: RealType* input2, @@ -60,7 +60,7 @@ __global__ void tnlCUDAReductionKernel( const Operation operation, }; template< typename Operation > -typename Operation::IndexType reduceOnCudaDevice( const Operation& operation, +typename Operation::IndexType reduceOnCudaDevice( Operation& operation, const typename Operation::IndexType size, const typename Operation::RealType* input1, const typename Operation::RealType* input2, @@ -135,7 +135,7 @@ typename Operation::IndexType reduceOnCudaDevice( const Operation& operation, #endif template< typename Operation > -bool reductionOnCudaDevice( const Operation& operation, +bool reductionOnCudaDevice( Operation& operation, const typename Operation :: IndexType size, const typename Operation :: RealType* deviceInput1, const typename Operation :: RealType* deviceInput2, @@ -231,7 +231,6 @@ bool reductionOnCudaDevice( const Operation& operation, /**** * Sum */ - extern template bool reductionOnCudaDevice< tnlParallelReductionSum< char, int > > ( const tnlParallelReductionSum< char, int >& operation, const typename tnlParallelReductionSum< char, int > :: IndexType size, @@ -311,7 +310,6 @@ extern template bool reductionOnCudaDevice< tnlParallelReductionSum< long double /**** * Min */ - extern template bool reductionOnCudaDevice< tnlParallelReductionMin< char, int > > ( const tnlParallelReductionMin< char, int >& operation, const typename tnlParallelReductionMin< char, int > :: IndexType size, diff --git a/src/core/cuda/reduction-operations.h b/src/core/cuda/reduction-operations.h index 93de5076d8fad0fd24c41c60d5f829cadd5b27c9..b328d5b3f622a39ccfa4687af04b1a3797410988 100644 --- a/src/core/cuda/reduction-operations.h +++ b/src/core/cuda/reduction-operations.h @@ -203,17 +203,17 @@ class tnlParallelReductionSum ResultType reduceOnHost( const IndexType idx, const ResultType& current, const RealType* data1, - const RealType* data2 ) const + const RealType* data2 ) { return current + data1[ idx ]; }; - __cuda_callable__ ResultType initialValue() const { return 0; }; + __cuda_callable__ ResultType initialValue() { return 0; }; __cuda_callable__ void cudaFirstReduction( ResultType& result, const IndexType index, const RealType* data1, - const RealType* data2 ) const + const RealType* data2 ) { result += data1[ index ]; } @@ -221,13 +221,13 @@ class tnlParallelReductionSum #ifdef HAVE_CUDA __device__ void commonReductionOnDevice( ResultType& result, - const ResultType& data ) const + const ResultType& data ) { result += data; }; __device__ void commonReductionOnDevice( volatile ResultType& result, - volatile const ResultType& data ) const + volatile const ResultType& data ) { result += data; }; @@ -248,30 +248,30 @@ class tnlParallelReductionMin ResultType reduceOnHost( const IndexType idx, const ResultType& current, const RealType* data1, - const RealType* data2 ) const + const RealType* data2 ) { return Min( current, data1[ idx ] ); }; - __cuda_callable__ ResultType initialValue() const { return tnlMaxValue< ResultType>(); }; + __cuda_callable__ ResultType initialValue() { return tnlMaxValue< ResultType>(); }; __cuda_callable__ void cudaFirstReduction( ResultType& result, const IndexType index, const RealType* data1, - const RealType* data2 ) const + const RealType* data2 ) { result = tnlCudaMin( result, data1[ index ] ); } #ifdef HAVE_CUDA __device__ void commonReductionOnDevice( ResultType& result, - const ResultType& data ) const + const ResultType& data ) { result = tnlCudaMin( result, data ); }; __device__ void commonReductionOnDevice( volatile ResultType& result, - volatile const ResultType& data ) const + volatile const ResultType& data ) { result = tnlCudaMin( result, data ); }; @@ -293,30 +293,30 @@ class tnlParallelReductionMax ResultType reduceOnHost( const IndexType idx, const ResultType& current, const RealType* data1, - const RealType* data2 ) const + const RealType* data2 ) { return Max( current, data1[ idx ] ); }; - __cuda_callable__ ResultType initialValue() const { return tnlMinValue< ResultType>(); }; + __cuda_callable__ ResultType initialValue() { return tnlMinValue< ResultType>(); }; __cuda_callable__ void cudaFirstReduction( ResultType& result, const IndexType index, const RealType* data1, - const RealType* data2 ) const + const RealType* data2 ) { result = tnlCudaMax( result, data1[ index ] ); } #ifdef HAVE_CUDA __device__ void commonReductionOnDevice( ResultType& result, - const ResultType& data ) const + const ResultType& data ) { result = tnlCudaMax( result, data ); }; __device__ void commonReductionOnDevice( volatile ResultType& result, - volatile const ResultType& data ) const + volatile const ResultType& data ) { result = tnlCudaMax( result, data ); }; @@ -336,17 +336,17 @@ class tnlParallelReductionLogicalAnd ResultType reduceOnHost( const IndexType idx, const ResultType& current, const RealType* data1, - const RealType* data2 ) const + const RealType* data2 ) { return current && data1[ idx ]; }; - __cuda_callable__ ResultType initialValue() const { return ( ResultType ) true; }; + __cuda_callable__ ResultType initialValue() { return ( ResultType ) true; }; __cuda_callable__ void cudaFirstReduction( ResultType& result, const IndexType index, const RealType* data1, - const RealType* data2 ) const + const RealType* data2 ) { result = result && data1[ index ]; } @@ -354,13 +354,13 @@ class tnlParallelReductionLogicalAnd #ifdef HAVE_CUDA __device__ void commonReductionOnDevice( ResultType& result, - const ResultType& data ) const + const ResultType& data ) { result = result && data; }; __device__ void commonReductionOnDevice( volatile ResultType& result, - volatile const ResultType& data ) const + volatile const ResultType& data ) { result = result && data; }; @@ -383,31 +383,31 @@ class tnlParallelReductionLogicalOr ResultType reduceOnHost( const IndexType idx, const ResultType& current, const RealType* data1, - const RealType* data2 ) const + const RealType* data2 ) { return current || data1[ idx ]; }; - __cuda_callable__ ResultType initialValue() const { return ( ResultType ) false; }; + __cuda_callable__ ResultType initialValue() { return ( ResultType ) false; }; __cuda_callable__ void cudaFirstReduction( ResultType& result, const IndexType index, const RealType* data1, - const RealType* data2 ) const + const RealType* data2 ) { result = result || data1[ index ]; } -#ifdef HAVE_CUDA +#ifdef HAVE_CUDA __device__ void commonReductionOnDevice( ResultType& result, - const ResultType& data ) const + const ResultType& data ) { result = result || data; }; __device__ void commonReductionOnDevice( volatile ResultType& result, - volatile const ResultType& data ) const + volatile const ResultType& data ) { result = result || data; }; @@ -427,17 +427,17 @@ class tnlParallelReductionAbsSum : public tnlParallelReductionSum< Real, Index > ResultType reduceOnHost( const IndexType idx, const ResultType& current, const RealType* data1, - const RealType* data2 ) const + const RealType* data2 ) { return current + tnlAbs( data1[ idx ] ); }; - __cuda_callable__ ResultType initialValue() const { return ( ResultType ) 0; }; + __cuda_callable__ ResultType initialValue() { return ( ResultType ) 0; }; __cuda_callable__ void cudaFirstReduction( ResultType& result, const IndexType index, const RealType* data1, - const RealType* data2 ) const + const RealType* data2 ) { result += tnlCudaAbs( data1[ index ] ); } @@ -456,17 +456,17 @@ class tnlParallelReductionAbsMin : public tnlParallelReductionMin< Real, Index > ResultType reduceOnHost( const IndexType idx, const ResultType& current, const RealType* data1, - const RealType* data2 ) const + const RealType* data2 ) { return Min( current, tnlAbs( data1[ idx ] ) ); }; - __cuda_callable__ ResultType initialValue() const { return tnlMaxValue< ResultType>(); }; + __cuda_callable__ ResultType initialValue() { return tnlMaxValue< ResultType>(); }; __cuda_callable__ void cudaFirstReduction( ResultType& result, const IndexType index, const RealType* data1, - const RealType* data2 ) const + const RealType* data2 ) { result = tnlCudaMin( result, tnlCudaAbs( data1[ index ] ) ); } @@ -485,22 +485,53 @@ class tnlParallelReductionAbsMax : public tnlParallelReductionMax< Real, Index > ResultType reduceOnHost( const IndexType idx, const ResultType& current, const RealType* data1, - const RealType* data2 ) const + const RealType* data2 ) { return Max( current, tnlAbs( data1[ idx ] ) ); }; - __cuda_callable__ ResultType initialValue() const { return ( ResultType ) 0; }; + __cuda_callable__ ResultType initialValue() { return ( ResultType ) 0; }; __cuda_callable__ void cudaFirstReduction( ResultType& result, const IndexType index, const RealType* data1, - const RealType* data2 ) const + const RealType* data2 ) { result = tnlCudaMax( result, tnlCudaAbs( data1[ index ] ) ); } }; +template< typename Real, typename Index > +class tnlParallelReductionL2Norm : public tnlParallelReductionSum< Real, Index > +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Real ResultType; + typedef tnlParallelReductionSum< Real, Index > LaterReductionOperation; + + ResultType reduceOnHost( const IndexType idx, + const ResultType& current, + const RealType* data1, + const RealType* data2 ) + { + const RealType& aux = data1[ idx ]; + return current + aux * aux; + }; + + __cuda_callable__ ResultType initialValue() { return ( ResultType ) 0; }; + + __cuda_callable__ void cudaFirstReduction( ResultType& result, + const IndexType index, + const RealType* data1, + const RealType* data2 ) + { + const RealType& aux = data1[ index ]; + result += aux * aux; + } +}; + template< typename Real, typename Index > class tnlParallelReductionLpNorm : public tnlParallelReductionSum< Real, Index > @@ -520,17 +551,17 @@ class tnlParallelReductionLpNorm : public tnlParallelReductionSum< Real, Index > ResultType reduceOnHost( const IndexType idx, const ResultType& current, const RealType* data1, - const RealType* data2 ) const + const RealType* data2 ) { return current + pow( tnlAbs( data1[ idx ] ), p ); }; - __cuda_callable__ ResultType initialValue() const { return ( ResultType ) 0; }; + __cuda_callable__ ResultType initialValue() { return ( ResultType ) 0; }; __cuda_callable__ void cudaFirstReduction( ResultType& result, const IndexType index, const RealType* data1, - const RealType* data2 ) const + const RealType* data2 ) { result += tnlCudaPow( tnlCudaAbs( data1[ index ] ), p ); } @@ -553,17 +584,17 @@ class tnlParallelReductionEqualities : public tnlParallelReductionLogicalAnd< bo ResultType reduceOnHost( const IndexType idx, const ResultType& current, const RealType* data1, - const RealType* data2 ) const + const RealType* data2 ) { return current && ( data1[ idx ] == data2[ idx ] ); }; - __cuda_callable__ ResultType initialValue() const { return ( ResultType ) true; }; + __cuda_callable__ ResultType initialValue() { return ( ResultType ) true; }; __cuda_callable__ void cudaFirstReduction( ResultType& result, const IndexType index, const RealType* data1, - const RealType* data2 ) const + const RealType* data2 ) { result = result && ( data1[ index ] == data2[ index ] ); } @@ -582,17 +613,17 @@ class tnlParallelReductionInequalities : public tnlParallelReductionLogicalAnd< ResultType reduceOnHost( const IndexType idx, const ResultType& current, const RealType* data1, - const RealType* data2 ) const + const RealType* data2 ) { return current && ( data1[ idx ] != data2[ idx ] ); }; - __cuda_callable__ ResultType initialValue() const { return ( ResultType ) false; }; + __cuda_callable__ ResultType initialValue() { return ( ResultType ) false; }; __cuda_callable__ void cudaFirstReduction( ResultType& result, const IndexType index, const RealType* data1, - const RealType* data2 ) const + const RealType* data2 ) { result = result && ( data1[ index ] != data2[ index ] ); } @@ -611,17 +642,17 @@ class tnlParallelReductionScalarProduct : public tnlParallelReductionSum< Real, ResultType reduceOnHost( const IndexType idx, const ResultType& current, const RealType* data1, - const RealType* data2 ) const + const RealType* data2 ) { return current + ( data1[ idx ] * data2[ idx ] ); }; - __cuda_callable__ ResultType initialValue() const { return ( ResultType ) 0; }; + __cuda_callable__ ResultType initialValue() { return ( ResultType ) 0; }; __cuda_callable__ inline void cudaFirstReduction( ResultType& result, const IndexType index, const RealType* data1, - const RealType* data2 ) const + const RealType* data2 ) { result += data1[ index ] * data2[ index ]; } @@ -640,17 +671,17 @@ class tnlParallelReductionDiffSum : public tnlParallelReductionSum< Real, Index ResultType reduceOnHost( const IndexType idx, const ResultType& current, const RealType* data1, - const RealType* data2 ) const + const RealType* data2 ) { return current + ( data1[ idx ] - data2[ idx ] ); }; - __cuda_callable__ ResultType initialValue() const { return ( ResultType ) 0; }; + __cuda_callable__ ResultType initialValue() { return ( ResultType ) 0; }; __cuda_callable__ void cudaFirstReduction( ResultType& result, const IndexType index, const RealType* data1, - const RealType* data2 ) const + const RealType* data2 ) { result += data1[ index ] - data2[ index ]; } @@ -669,17 +700,17 @@ class tnlParallelReductionDiffMin : public tnlParallelReductionMin< Real, Index ResultType reduceOnHost( const IndexType idx, const ResultType& current, const RealType* data1, - const RealType* data2 ) const + const RealType* data2 ) { return Min( current, data1[ idx ] - data2[ idx ] ); }; - __cuda_callable__ ResultType initialValue() const { return tnlMaxValue< ResultType>(); }; + __cuda_callable__ ResultType initialValue() { return tnlMaxValue< ResultType>(); }; __cuda_callable__ void cudaFirstReduction( ResultType& result, const IndexType index, const RealType* data1, - const RealType* data2 ) const + const RealType* data2 ) { result = tnlCudaMin( result, data1[ index ] - data2[ index ] ); } @@ -698,17 +729,17 @@ class tnlParallelReductionDiffMax : public tnlParallelReductionMax< Real, Index ResultType reduceOnHost( const IndexType idx, const ResultType& current, const RealType* data1, - const RealType* data2 ) const + const RealType* data2 ) { return Max( current, data1[ idx ] - data2[ idx ] ); }; - __cuda_callable__ ResultType initialValue() const { return ( ResultType ) 0; }; + __cuda_callable__ ResultType initialValue() { return ( ResultType ) 0; }; __cuda_callable__ void cudaFirstReduction( ResultType& result, const IndexType index, const RealType* data1, - const RealType* data2 ) const + const RealType* data2 ) { result = tnlCudaMax( result, data1[ index ] - data2[ index ] ); } @@ -727,17 +758,17 @@ class tnlParallelReductionDiffAbsSum : public tnlParallelReductionMax< Real, Ind ResultType reduceOnHost( const IndexType idx, const ResultType& current, const RealType* data1, - const RealType* data2 ) const + const RealType* data2 ) { return current + tnlAbs( data1[ idx ] - data2[ idx ] ); }; - __cuda_callable__ ResultType initialValue() const { return ( ResultType ) 0; }; + __cuda_callable__ ResultType initialValue() { return ( ResultType ) 0; }; __cuda_callable__ void cudaFirstReduction( ResultType& result, const IndexType index, const RealType* data1, - const RealType* data2 ) const + const RealType* data2 ) { result += tnlCudaAbs( data1[ index ] - data2[ index ] ); } @@ -756,17 +787,17 @@ class tnlParallelReductionDiffAbsMin : public tnlParallelReductionMin< Real, Ind ResultType reduceOnHost( const IndexType idx, const ResultType& current, const RealType* data1, - const RealType* data2 ) const + const RealType* data2 ) { return Min( current, tnlAbs( data1[ idx ] - data2[ idx ] ) ); }; - __cuda_callable__ ResultType initialValue() const { return tnlMaxValue< ResultType>(); }; + __cuda_callable__ ResultType initialValue() { return tnlMaxValue< ResultType>(); }; __cuda_callable__ void cudaFirstReduction( ResultType& result, const IndexType index, const RealType* data1, - const RealType* data2 ) const + const RealType* data2 ) { result = tnlCudaMin( result, tnlCudaAbs( data1[ index ] - data2[ index ] ) ); } @@ -785,22 +816,57 @@ class tnlParallelReductionDiffAbsMax : public tnlParallelReductionMax< Real, Ind ResultType reduceOnHost( const IndexType idx, const ResultType& current, const RealType* data1, - const RealType* data2 ) const + const RealType* data2 ) { return Max( current, tnlAbs( data1[ idx ] - data2[ idx ] ) ); }; - __cuda_callable__ ResultType initialValue() const { return ( ResultType ) 0; }; + __cuda_callable__ ResultType initialValue() { return ( ResultType ) 0; }; __cuda_callable__ void cudaFirstReduction( ResultType& result, const IndexType index, const RealType* data1, - const RealType* data2 ) const + const RealType* data2 ) { result = tnlCudaMax( result, tnlCudaAbs( data1[ index ] - data2[ index ] ) ); } }; +template< typename Real, typename Index > +class tnlParallelReductionDiffL2Norm : public tnlParallelReductionSum< Real, Index > +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Real ResultType; + typedef tnlParallelReductionSum< Real, Index > LaterReductionOperation; + + ResultType reduceOnHost( const IndexType idx, + const ResultType& current, + const RealType* data1, + const RealType* data2 ) + { + this->aux = data2[ idx ] - data1[ idx ]; + return current + aux * aux; + }; + + __cuda_callable__ ResultType initialValue() { return ( ResultType ) 0; }; + + __cuda_callable__ void cudaFirstReduction( ResultType& result, + const IndexType index, + const RealType* data1, + const RealType* data2 ) + { + this->aux = data2[ index ] - data1[ index ]; + result += aux * aux; + } + + protected: + + RealType aux; +}; + template< typename Real, typename Index > class tnlParallelReductionDiffLpNorm : public tnlParallelReductionSum< Real, Index > { @@ -819,17 +885,17 @@ class tnlParallelReductionDiffLpNorm : public tnlParallelReductionSum< Real, Ind ResultType reduceOnHost( const IndexType idx, const ResultType& current, const RealType* data1, - const RealType* data2 ) const + const RealType* data2 ) { return current + pow( tnlAbs( data1[ idx ] - data2[ idx ] ), p ); }; - __cuda_callable__ ResultType initialValue() const { return ( ResultType ) 0; }; + __cuda_callable__ ResultType initialValue() { return ( ResultType ) 0; }; __cuda_callable__ void cudaFirstReduction( ResultType& result, const IndexType index, const RealType* data1, - const RealType* data2 ) const + const RealType* data2 ) { result += tnlCudaPow( tnlCudaAbs( data1[ index ] - data2[ index ] ), p ); } diff --git a/src/core/cuda/tnlCudaReduction.h b/src/core/cuda/tnlCudaReduction.h index 9b7bf7ab2cb234ecbeae74f4a571cc8383720cb0..d5084cff8bc8a7bfcab573d23f4c867a631309c8 100644 --- a/src/core/cuda/tnlCudaReduction.h +++ b/src/core/cuda/tnlCudaReduction.h @@ -30,7 +30,7 @@ class tnlCUDAReduction typedef typename Operation::ResultType ResultType; - __device__ static void reduce( const Operation operation, + __device__ static void reduce( Operation& operation, const IndexType size, const RealType* input1, const RealType* input2, @@ -47,7 +47,7 @@ class tnlCUDAReduction< tnlParallelReductionScalarProduct< Real, Index >, blockS typedef typename Operation::RealType RealType; typedef typename Operation::ResultType ResultType; - __device__ static void reduce( const Operation operation, + __device__ static void reduce( Operation operation, const IndexType size, const RealType* input1, const RealType* input2, diff --git a/src/core/cuda/tnlCudaReduction_impl.h b/src/core/cuda/tnlCudaReduction_impl.h index 5187141a1a70c4d601b3fb87ba5e7018b5e8f0ed..5fa295f65eb7642278ad25da914146339455060e 100644 --- a/src/core/cuda/tnlCudaReduction_impl.h +++ b/src/core/cuda/tnlCudaReduction_impl.h @@ -22,7 +22,7 @@ template< typename Operation, int blockSize > __device__ void tnlCUDAReduction< Operation, blockSize >:: -reduce( const Operation operation, +reduce( Operation& operation, const IndexType size, const RealType* input1, const RealType* input2, @@ -158,7 +158,7 @@ template< typename Real, typename Index, int blockSize > __device__ void tnlCUDAReduction< tnlParallelReductionScalarProduct< Real, Index >, blockSize >:: -reduce( const Operation operation, +reduce( Operation& operation, const IndexType size, const RealType* input1, const RealType* input2, @@ -182,7 +182,7 @@ reduce( const Operation operation, * sequential reduction. */ sdata[ tid ] = ( RealType ) 0; - while( gid + 4 * gridSize < size ) + /*while( gid + 4 * gridSize < size ) { sdata[ tid ] += input1[ gid ] * input2[ gid ]; sdata[ tid ] += input1[ gid + gridSize ] * input2[ gid + gridSize ]; @@ -195,7 +195,7 @@ reduce( const Operation operation, sdata[ tid ] += input1[ gid ] * input2[ gid ]; sdata[ tid ] += input1[ gid + gridSize ] * input2[ gid + gridSize ]; gid += 2*gridSize; - } + }*/ while( gid < size ) { sdata[ tid ] += input1[ gid ] * input2[ gid ]; diff --git a/src/core/images/tnlDicomSeries_impl.h b/src/core/images/tnlDicomSeries_impl.h index 4c26543080dcaf0cd075538369e67664374d4d6b..68e5409744698dab61c63532b5cf339493ba7f16 100644 --- a/src/core/images/tnlDicomSeries_impl.h +++ b/src/core/images/tnlDicomSeries_impl.h @@ -182,7 +182,7 @@ inline bool tnlDicomSeries::loadImage( const tnlString& filePath, int number) #ifdef HAVE_DCMTK_H //load header tnlDicomHeader *header = new tnlDicomHeader(); - dicomSeriesHeaders.setSize( fileList->getSize() ); + dicomSeriesHeaders.setSize( fileList.getSize() ); dicomSeriesHeaders.setElement( number, header ); if( !header->loadFromFile( filePath ) ) return false; @@ -283,7 +283,7 @@ inline bool tnlDicomSeries::loadImage( const tnlString& filePath, int number) imagesInfo.frameSize = size; if (pixelData) delete pixelData; - pixelData = new Uint16[imagesInfo.frameUintsCount * fileList->getSize()]; + pixelData = new Uint16[imagesInfo.frameUintsCount * fileList.getSize()]; } else {//check image size for compatibility diff --git a/src/core/images/tnlJPEGImage_impl.h b/src/core/images/tnlJPEGImage_impl.h index 55a396b37f64bba97e079388a8fc60a82087fa7b..f4af5f312b9384bc4116efdb06ea7485d6080183 100644 --- a/src/core/images/tnlJPEGImage_impl.h +++ b/src/core/images/tnlJPEGImage_impl.h @@ -108,7 +108,7 @@ read( const tnlRegionOfInterest< Index > roi, const tnlGrid< 2, Real, Device, Index >& grid, Vector& vector ) { -#ifdef HAVE_PNG_H +#ifdef HAVE_JPEG_H typedef tnlGrid< 2, Real, Device, Index > GridType; typedef typename GridType::CoordinatesType CoordinatesType; @@ -195,7 +195,7 @@ writeHeader( const tnlGrid< 2, Real, Device, Index >& grid ) jpeg_set_defaults( &this->cinfo ); jpeg_start_compress( &this->cinfo, true ); #else - //cerr << "TNL was not compiled with support of PNG. You may still use PGM format." << endl; + //cerr << "TNL was not compiled with support of JPEG. You may still use PGM format." << endl; return false; #endif } diff --git a/src/core/multimaps/CMakeLists.txt b/src/core/multimaps/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..7f705ebcd59e2279a84c79ea1aad95f3f3a35990 --- /dev/null +++ b/src/core/multimaps/CMakeLists.txt @@ -0,0 +1,20 @@ +SET( headers tnlEllpackIndexMultimap.h + tnlEllpackIndexMultimap_impl.h + tnlEllpackIndexMultimapValues.h + tnlEllpackIndexMultimapValues_impl.h ) + +SET( CURRENT_DIR ${CMAKE_SOURCE_DIR}/src/core/multimaps ) +set( common_SOURCES + ) + +IF( BUILD_CUDA ) + set( tnl_core_multimaps_CUDA__SOURCES + ${common_SOURCES} + PARENT_SCOPE ) +ENDIF() + +set( tnl_core_multimaps_SOURCES + ${common_SOURCES} + PARENT_SCOPE ) + +INSTALL( FILES ${headers} DESTINATION include/tnl-${tnlVersion}/core/multimaps ) \ No newline at end of file diff --git a/src/core/multimaps/tnlEllpackIndexMultimap.h b/src/core/multimaps/tnlEllpackIndexMultimap.h new file mode 100644 index 0000000000000000000000000000000000000000..c7be27b4585936ad9229b56699edfa93e7cb2e56 --- /dev/null +++ b/src/core/multimaps/tnlEllpackIndexMultimap.h @@ -0,0 +1,72 @@ +/*************************************************************************** + tnlEllpackIndexMultimap.h - description + ------------------- + begin : Sep 9, 2015 + copyright : (C) 2015 by Tomas Oberhuber et al. + 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 TNLELLPACKINDEXMULTIMAP_H +#define TNLELLPACKINDEXMULTIMAP_H + +#include <core/vectors/tnlVector.h> + +template< typename Index = int, + typename Device = tnlHost > +class tnlEllpackIndexMultimapValues; + +template< typename Index = int, + typename Device = tnlHost > +class tnlEllpackIndexMultimapConstValues; + +template< typename Index = int, + typename Device = tnlHost > +class tnlEllpackIndexMultimap +{ + public: + + typedef Device DeviceType; + typedef Index IndexType; + typedef tnlEllpackIndexMultimapValues< IndexType, DeviceType > ValuesAccessorType; + typedef tnlEllpackIndexMultimapConstValues< IndexType, DeviceType > ConstValuesAccessorType; + typedef tnlVector< IndexType, DeviceType, IndexType > ValuesAllocationVectorType; + + tnlEllpackIndexMultimap(); + + static tnlString getType(); + + tnlString getTypeVirtual() const; + + void setRanges( const IndexType keysRange, + const IndexType valuesRange ); + + const IndexType getKeysRange() const; + + const IndexType getValuesRange() const; + + void allocate( const ValuesAllocationVectorType& portsCount ); + + ValuesAccessorType getValues( const IndexType& inputIndex ); + + ConstValuesAccessorType getValues( const IndexType& inputIndex ) const; + + protected: + + tnlVector< IndexType, DeviceType, IndexType > values; + + IndexType keysRange, valuesRange, valuesMaxCount; +}; + +#include <core/multimaps/tnlEllpackIndexMultimap_impl.h> + +#endif /* TNLELLPACKINDEXMULTIMAP_H */ + diff --git a/src/core/multimaps/tnlEllpackIndexMultimapValues.h b/src/core/multimaps/tnlEllpackIndexMultimapValues.h new file mode 100644 index 0000000000000000000000000000000000000000..cba0ee8aa0ff22f6783c83cb6b3c9ada0085c870 --- /dev/null +++ b/src/core/multimaps/tnlEllpackIndexMultimapValues.h @@ -0,0 +1,70 @@ +/*************************************************************************** + tnlEllpackIndexMultimapValues.h - description + ------------------- + begin : Sep 10, 2015 + copyright : (C) 2015 by Tomas Oberhuber et al. + 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 TNLELLPACKINDEXMULTIMAPVALUES_H +#define TNLELLPACKINDEXMULTIMAPVALUES_H + +#include <ostream> +#include <core/multimaps/tnlEllpackIndexMultimap.h> + +template< typename Index, + typename Device > +class tnlEllpackIndexMultimapValues +{ + public: + + typedef Device DeviceType; + typedef Index IndexType; + typedef tnlEllpackIndexMultimap< IndexType, DeviceType > NetworkType; + + tnlEllpackIndexMultimapValues(); + + IndexType getPortsCount() const; + + void setOutput( const IndexType portIndex, + const IndexType output ); + + IndexType getOutput( const IndexType portIndex ) const; + + IndexType& operator[]( const IndexType portIndex ); + + const IndexType& operator[]( const IndexType portIndex ) const; + + void print( std::ostream& str ) const; + + protected: + + tnlEllpackIndexMultimapValues( IndexType* ports, + const IndexType input, + const IndexType portsMaxCount ); + + IndexType* ports; + + IndexType step, portsMaxCount; + + friend tnlEllpackIndexMultimap< IndexType, DeviceType >; +}; + +template< typename Index, + typename Device > +std::ostream& operator << ( std::ostream& str, const tnlEllpackIndexMultimapValues< Index, Device>& ports ); + +#include <core/multimaps/tnlEllpackIndexMultimapValues_impl.h> + + +#endif /* TNLELLPACKINDEXMULTIMAPVALUES_H */ + diff --git a/src/core/multimaps/tnlEllpackIndexMultimapValues_impl.h b/src/core/multimaps/tnlEllpackIndexMultimapValues_impl.h new file mode 100644 index 0000000000000000000000000000000000000000..0441495b7a4f83568c77176285e87d35a379fa61 --- /dev/null +++ b/src/core/multimaps/tnlEllpackIndexMultimapValues_impl.h @@ -0,0 +1,114 @@ +/*************************************************************************** + tnlEllpackIndexMultimapValues_impl.h - description + ------------------- + begin : Sep 10, 2015 + copyright : (C) 2015 by Tomas Oberhuber et al. + 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 TNLELLPACKINDEXMULTIMAPVALUES_IMPL_H +#define TNLELLPACKINDEXMULTIMAPVALUES_IMPL_H + +#include "tnlEllpackIndexMultimapValues.h" + + +template< typename Index, + typename Device > +tnlEllpackIndexMultimapValues< Index, Device >:: +tnlEllpackIndexMultimapValues() +{ +} + +template< typename Index, + typename Device > +tnlEllpackIndexMultimapValues< Index, Device >:: +tnlEllpackIndexMultimapValues( IndexType* networkPorts, + const IndexType input, + const IndexType portsMaxCount ) +{ + this->ports = &networkPorts[ input * portsMaxCount ]; + this->portsMaxCount = portsMaxCount; +} + +template< typename Index, + typename Device > +Index +tnlEllpackIndexMultimapValues< Index, Device >:: +getPortsCount() const +{ + return this->portsMaxCount; +} + +template< typename Index, + typename Device > +void +tnlEllpackIndexMultimapValues< Index, Device >:: +setOutput( const IndexType portIndex, + const IndexType output ) +{ + this->ports[ portIndex ] = output; +} + +template< typename Index, + typename Device > +Index +tnlEllpackIndexMultimapValues< Index, Device >:: +getOutput( const IndexType portIndex ) const +{ + return this->ports[ portIndex ]; +} + +template< typename Index, + typename Device > +Index& +tnlEllpackIndexMultimapValues< Index, Device >:: +operator[]( const IndexType portIndex ) +{ + return this->ports[ portIndex ]; +} + +template< typename Index, + typename Device > +const Index& +tnlEllpackIndexMultimapValues< Index, Device >:: +operator[]( const IndexType portIndex ) const +{ + return this->ports[ portIndex ]; +} + +template< typename Index, + typename Device > +void +tnlEllpackIndexMultimapValues< Index, Device >:: +print( std::ostream& str ) const +{ + if( this->getPortsCount() == 0 ) + { + str << "[]"; + return; + } + str << "[ " << this->getOutput( 0 ); + for( Index i = 1; i < this->getPortsCount(); i++ ) + str << ", " << this->getOutput( i ); + str << " ]"; +} + +template< typename Index, + typename Device > +std::ostream& operator << ( std::ostream& str, const tnlEllpackIndexMultimapValues< Index, Device>& ports ) +{ + ports.print( str ); + return str; +} + +#endif /* TNLELLPACKGRAPHLINKSACCESSOR_IMPL_H */ + diff --git a/src/core/multimaps/tnlEllpackIndexMultimap_impl.h b/src/core/multimaps/tnlEllpackIndexMultimap_impl.h new file mode 100644 index 0000000000000000000000000000000000000000..0434bd445db60115b42b9a939eae64671b6c0ff7 --- /dev/null +++ b/src/core/multimaps/tnlEllpackIndexMultimap_impl.h @@ -0,0 +1,116 @@ +/*************************************************************************** + tnlEllpackIndexMultimap_impl.h - description + ------------------- + begin : Sep 9, 2015 + copyright : (C) 2015 by Tomas Oberhuber et al. + 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 TNLELLPACKINDEXMULTIMAP_IMPL_H +#define TNLELLPACKINDEXMULTIMAP_IMPL_H + +#include <core/multimaps/tnlEllpackIndexMultimap.h> +#include <core/multimaps/tnlEllpackIndexMultimapValues.h> + + +template< typename Index, + typename Device > +tnlEllpackIndexMultimap< Index, Device >:: +tnlEllpackIndexMultimap() +: keysRange( 0 ), valuesRange( 0 ), valuesMaxCount( 0 ) +{ +} + +template< typename Index, + typename Device > +tnlString tnlEllpackIndexMultimap< Index, Device > :: getType() +{ + return tnlString( "tnlEllpackIndexMultimap< ") + + Device :: getDeviceType() + + tnlString( ", " ) + + tnlString( ::getType< Index >() ) + + tnlString( " >" ); +} + +template< typename Index, + typename Device > +tnlString tnlEllpackIndexMultimap< Index, Device >::getTypeVirtual() const +{ + return this->getType(); +} + +template< typename Index, + typename Device > +void +tnlEllpackIndexMultimap< Index, Device >:: +setRanges( const IndexType inputs, + const IndexType outputs ) +{ + this->keysRange = inputs; + this->valuesRange = outputs; +} + +template< typename Index, + typename Device > +const Index +tnlEllpackIndexMultimap< Index, Device >:: +getKeysRange() const +{ + return this->keysRange; +} + +template< typename Index, + typename Device > +const Index +tnlEllpackIndexMultimap< Index, Device >:: +getValuesRange() const +{ + return this->valuesRange; +} + +template< typename Index, + typename Device > +void +tnlEllpackIndexMultimap< Index, Device >:: +allocate( const ValuesAllocationVectorType& portsCount ) +{ + tnlAssert( portsCount.getSize() == this->keysRange, + cerr << "portsCount.getSize() = " << portsCount.getSize() + << "this->inputs = " << this->keysRange ); + this->valuesMaxCount = portsCount.max(); + + tnlAssert( this->valuesMaxCount >= 0 && this->valuesMaxCount <= this->valuesRange, + cerr << "this->portsMaxCount = " << this->valuesMaxCount + << " this->outputs = " << this->valuesRange ); + this->values.setSize( this->keysRange * this->valuesMaxCount ); +} + +template< typename Index, + typename Device > +typename tnlEllpackIndexMultimap< Index, Device >::ValuesAccessorType +tnlEllpackIndexMultimap< Index, Device >:: +getValues( const IndexType& inputIndex ) +{ + return ValuesAccessorType( this->values.getData(), inputIndex, this->valuesMaxCount ); +} + +template< typename Index, + typename Device > +typename tnlEllpackIndexMultimap< Index, Device >::ConstValuesAccessorType +tnlEllpackIndexMultimap< Index, Device >:: +getValues( const IndexType& inputIndex ) const +{ + return ConstPortsType( this->values.getData(), inputIndex, this->valuesMaxCount ); +} + +#endif /* TNLELLPACKGRAPH_IMPL_H */ + diff --git a/src/core/tnlCurve.h b/src/core/tnlCurve.h index 89ead3407a12a45bb3846b8bef24520f6af633ae..dce343e3ee02435933fd6599427ce1f66e9b31a3 100644 --- a/src/core/tnlCurve.h +++ b/src/core/tnlCurve.h @@ -184,14 +184,12 @@ template< class T > bool Write( const tnlCurve< T >& curve, tnlFile file; if( ! file. open( tnlString( file_name ) + tnlString( ".tnl" ), tnlWriteMode ) ) { - cerr << "I am not able to open the file " << file_name << " for drawing curve " - << curve. getName() <<"." << endl; + cerr << "I am not able to open the file " << file_name << " for drawing curve." << endl; return false; } if( ! curve. save( file ) ) { - cerr << "I am not able to write to the file " << file_name << " for drawing grid " - << curve. getName() <<"." << endl; + cerr << "I am not able to write to the file " << file_name << " for drawing grid." << endl; return false; } file. close(); @@ -202,8 +200,7 @@ template< class T > bool Write( const tnlCurve< T >& curve, file. open( file_name, ios :: out ); if( ! file ) { - cerr << "I am not able to to open the file " << file_name << " for drawing curve " - << curve. getName() <<"." << endl; + cerr << "I am not able to to open the file " << file_name << " for drawing curve." << endl; return false; } bool result = Write( curve, file, format, step ); diff --git a/src/core/tnlIndexedSet.h b/src/core/tnlIndexedSet.h index 05e263749f83065a2dec9a2b2a8aa45add91d098..1af9f4c201535106e8968dd80232ad772d27efa5 100644 --- a/src/core/tnlIndexedSet.h +++ b/src/core/tnlIndexedSet.h @@ -47,13 +47,19 @@ class tnlIndexedSet const Element& getElement( KeyType key ) const; Element& getElement( KeyType key ); - + void print( ostream& str ) const; protected: struct DataWithIndex { + // This constructor is here only because of bug in g++, we might fix it later. + // http://stackoverflow.com/questions/22357887/comparing-two-mapiterators-why-does-it-need-the-copy-constructor-of-stdpair + DataWithIndex(){}; + + DataWithIndex( const DataWithIndex& d ) : data( d.data ), index( d.index) {} + explicit DataWithIndex( const Element data) : data( data ) {} DataWithIndex( const Element data, diff --git a/src/core/tnlObject.cpp b/src/core/tnlObject.cpp index 6e32643b6896feda8f1ed2a1592bbffe07d7fb40..f4b2ed0f13184a20c3fb421b90fb04876f088a18 100644 --- a/src/core/tnlObject.cpp +++ b/src/core/tnlObject.cpp @@ -25,21 +25,15 @@ #include <cstring> #include <stdio.h> -const char magic_number[] = "SIM33"; +const char magic_number[] = "TNLMN"; tnlObject :: tnlObject() -: name( "<no name>" ) { - dbgFunctionName( "tnlObject", "tnlObject" ); - dbgCout( "Initiating object " << getName() ); } tnlObject :: tnlObject( const tnlString& _name ) -: name( _name ) { - dbgFunctionName( "tnlObject", "tnlObject" ); - dbgCout( "Initiating object " << getName() ); } tnlString tnlObject :: getType() @@ -62,16 +56,6 @@ tnlString tnlObject :: getSerializationTypeVirtual() const return this->getSerializationType(); } -void tnlObject :: setName( const tnlString& name) -{ - this -> name = name; -} - -const tnlString& tnlObject :: getName() const -{ - return name; -} - bool tnlObject :: save( tnlFile& file ) const { dbgFunctionName( "tnlObject", "Save" ); @@ -82,9 +66,7 @@ bool tnlObject :: save( tnlFile& file ) const if( ! file. write( magic_number, strlen( magic_number ) ) ) #endif return false; - dbgCout( "Writing object name " << name ); - if( ! this->getSerializationTypeVirtual().save( file ) || - ! name. save( file ) ) return false; + if( ! this->getSerializationTypeVirtual().save( file ) ) return false; return true; } @@ -100,8 +82,6 @@ bool tnlObject :: load( tnlFile& file ) cerr << "Given file contains instance of " << objectType << " but " << getSerializationTypeVirtual() << " is expected." << endl; return false; } - dbgCout( "Reading object name " ); - if( ! name. load( file ) ) return false; return true; } @@ -144,7 +124,6 @@ bool tnlObject :: load( const tnlString& fileName ) bool getObjectType( tnlFile& file, tnlString& type ) { dbgFunctionName( "", "getObjectType" ); - dbgCout( "Checking magic number." ); char mn[ 10 ]; #ifdef HAVE_NOT_CXX11 if( ! file. read< char, tnlHost, int >( mn, strlen( magic_number ) ) ) @@ -155,7 +134,8 @@ bool getObjectType( tnlFile& file, tnlString& type ) cerr << "Unable to read file " << file. getFileName() << " ... " << endl; return false; } - if( strncmp( mn, magic_number, 5 ) != 0 ) return false; + if( strncmp( mn, magic_number, 5 ) != 0 && + strncmp( mn, "SIM33", 5 ) != 0 ) return false; if( ! type. load( file ) ) return false; return true; } diff --git a/src/core/tnlObject.h b/src/core/tnlObject.h index ad6338bd5e348364168cb0133c7365cd52319d1c..be9f0f26d7cc4b7969978aab0d407dd8fda5db72 100644 --- a/src/core/tnlObject.h +++ b/src/core/tnlObject.h @@ -61,16 +61,6 @@ class tnlObject virtual tnlString getSerializationTypeVirtual() const; - /**** - * Name getter - */ - void setName( const tnlString& name ); - - /**** - * Name getter - */ - const tnlString& getName() const; - //! Method for saving the object to a file as a binary data virtual bool save( tnlFile& file ) const; @@ -84,10 +74,6 @@ class tnlObject //! Destructor virtual ~tnlObject(){}; - protected: - - //! Object name - tnlString name; }; bool getObjectType( tnlFile& file, tnlString& type ); diff --git a/src/core/vectors/CMakeLists.txt b/src/core/vectors/CMakeLists.txt index 63b3ef39b81e2fb47d55d02dee7f82d6b75f2eb7..72b06ef4ab6e2a326953be438fa653e2e2862c57 100755 --- a/src/core/vectors/CMakeLists.txt +++ b/src/core/vectors/CMakeLists.txt @@ -18,7 +18,7 @@ set( headers tnlVector.h SET( CURRENT_DIR ${CMAKE_SOURCE_DIR}/src/core/vectors ) set( common_SOURCES - ${CURRENT_DIR}/tnlVectorOperations_impl.cpp + ${CURRENT_DIR}/tnlVectorOperationsHost_impl.cpp ${CURRENT_DIR}/tnlMultiVector_impl.cpp ${CURRENT_DIR}/tnlSharedVector_impl.cpp ${CURRENT_DIR}/tnlVector_impl.cpp @@ -27,14 +27,19 @@ set( common_SOURCES IF( BUILD_CUDA ) set( tnl_core_vectors_CUDA__SOURCES ${common_SOURCES} - ${CURRENT_DIR}/tnlVectorOperations_impl.cu + ${CURRENT_DIR}/tnlVectorOperationsCuda_impl.cu ${CURRENT_DIR}/tnlVector_impl.cu ${CURRENT_DIR}/tnlStaticVector_impl.cu PARENT_SCOPE ) + set( tnl_core_vectors_SOURCES + ${common_SOURCES} + PARENT_SCOPE ) +else() + set( tnl_core_vectors_SOURCES + ${common_SOURCES} + ${CURRENT_DIR}/tnlVectorOperationsCuda_impl.cpp + PARENT_SCOPE ) ENDIF() -set( tnl_core_vectors_SOURCES - ${common_SOURCES} - PARENT_SCOPE ) INSTALL( FILES ${headers} DESTINATION include/tnl-${tnlVersion}/core/vectors ) \ No newline at end of file diff --git a/src/core/vectors/tnlMultiVector1D_impl.h b/src/core/vectors/tnlMultiVector1D_impl.h index 6e1b6a6695f41c38454f24a8493d9ae68b4bbe90..1fe506de95cbb7890a50f3df9c8485aa3a70650e 100644 --- a/src/core/vectors/tnlMultiVector1D_impl.h +++ b/src/core/vectors/tnlMultiVector1D_impl.h @@ -25,12 +25,6 @@ tnlMultiVector< 1, Real, Device, Index > :: tnlMultiVector() { } -template< typename Real, typename Device, typename Index > -tnlMultiVector< 1, Real, Device, Index > :: tnlMultiVector( const tnlString& name ) -{ - this -> setName( name ); -} - template< typename Real, typename Device, typename Index > tnlString tnlMultiVector< 1, Real, Device, Index > :: getType() { @@ -147,10 +141,8 @@ bool tnlMultiVector< 1, Real, Device, Index > :: operator == ( const MultiVector // TODO: Static assert on dimensions tnlAssert( this -> getDimensions() == Vector. getDimensions(), cerr << "You are attempting to compare two Vectors with different dimensions." << endl - << "First Vector name is " << this -> getName() - << " dimensions are ( " << this -> getDimensions() << " )" << endl - << "Second Vector is " << Vector. getName() - << " dimensions are ( " << Vector. getDimensions() << " )" << endl; ); + << "First Vector name dimensions are ( " << this -> getDimensions() << " )" << endl + << "Second Vector dimensions are ( " << Vector. getDimensions() << " )" << endl; ); return tnlVector< Real, Device, Index > :: operator == ( Vector ); } @@ -168,10 +160,8 @@ tnlMultiVector< 1, Real, Device, Index >& // TODO: Static assert on dimensions tnlAssert( this -> getDimensions() == Vector. getDimensions(), cerr << "You are attempting to assign two Vectors with different dimensions." << endl - << "First Vector name is " << this -> getName() - << " dimensions are ( " << this -> getDimensions() << " )" << endl - << "Second Vector is " << Vector. getName() - << " dimensions are ( " << Vector. getDimensions() << " )" << endl; ); + << "First vector dimensions are ( " << this -> getDimensions() << " )" << endl + << "Second vector dimensions are ( " << Vector. getDimensions() << " )" << endl; ); tnlVector< Real, Device, Index > :: operator = ( Vector ); return ( *this ); } @@ -184,10 +174,8 @@ tnlMultiVector< 1, Real, Device, Index >& // TODO: Static assert on dimensions tnlAssert( this -> getDimensions() == Vector. getDimensions(), cerr << "You are attempting to assign two Vectors with different dimensions." << endl - << "First Vector name is " << this -> getName() - << " dimensions are ( " << this -> getDimensions() << " )" << endl - << "Second Vector is " << Vector. getName() - << " dimensions are ( " << Vector. getDimensions() << " )" << endl; ); + << "First vector dimensions are ( " << this -> getDimensions() << " )" << endl + << "Second vector dimensions are ( " << Vector. getDimensions() << " )" << endl; ); tnlVector< Real, Device, Index > :: operator = ( Vector ); return ( *this ); } @@ -197,14 +185,12 @@ bool tnlMultiVector< 1, Real, Device, Index > :: save( tnlFile& file ) const { if( ! tnlVector< Real, Device, Index > :: save( file ) ) { - cerr << "I was not able to write the tnlVector of tnlMultiVector " - << this -> getName() << endl; + cerr << "I was not able to write the tnlVector of tnlMultiVector." << endl; return false; } if( ! dimensions. save( file ) ) { - cerr << "I was not able to write the dimensions of tnlMultiVector " - << this -> getName() << endl; + cerr << "I was not able to write the dimensions of tnlMultiVector." << endl; return false; } return true; @@ -215,14 +201,12 @@ bool tnlMultiVector< 1, Real, Device, Index > :: load( tnlFile& file ) { if( ! tnlVector< Real, Device, Index > :: load( file ) ) { - cerr << "I was not able to read the tnlVector of tnlMultiVector " - << this -> getName() << endl; + cerr << "I was not able to read the tnlVector of tnlMultiVector." << endl; return false; } if( ! dimensions. load( file ) ) { - cerr << "I was not able to read the dimensions of tnlMultiVector " - << this -> getName() << endl; + cerr << "I was not able to read the dimensions of tnlMultiVector." << endl; return false; } return true; diff --git a/src/core/vectors/tnlMultiVector2D_impl.h b/src/core/vectors/tnlMultiVector2D_impl.h index a964b062e641695bfcc29f30861c4c43b50f35f4..be3f3874d9f68504a3b9ff4ea09cc39f7c9fe3e8 100644 --- a/src/core/vectors/tnlMultiVector2D_impl.h +++ b/src/core/vectors/tnlMultiVector2D_impl.h @@ -25,13 +25,6 @@ tnlMultiVector< 2, Real, Device, Index > :: tnlMultiVector() { } -template< typename Real, typename Device, typename Index > -tnlMultiVector< 2, Real, Device, Index > :: tnlMultiVector( const tnlString& name ) -{ - this -> setName( name ); -} - - template< typename Real, typename Device, typename Index > tnlString tnlMultiVector< 2, Real, Device, Index > :: getType() { @@ -155,10 +148,8 @@ bool tnlMultiVector< 2, Real, Device, Index > :: operator == ( const MultiVector // TODO: Static assert on dimensions tnlAssert( this -> getDimensions() == Vector. getDimensions(), cerr << "You are attempting to compare two Vectors with different dimensions." << endl - << "First Vector name is " << this -> getName() - << " dimensions are ( " << this -> getDimensions() << " )" << endl - << "Second Vector is " << Vector. getName() - << " dimensions are ( " << Vector. getDimensions() << " )" << endl; ); + << "First vector dimensions are ( " << this -> getDimensions() << " )" << endl + << "Second vector dimensions are ( " << Vector. getDimensions() << " )" << endl; ); return tnlVector< Real, Device, Index > :: operator == ( Vector ); } @@ -176,10 +167,8 @@ tnlMultiVector< 2, Real, Device, Index >& // TODO: Static assert on dimensions tnlAssert( this -> getDimensions() == Vector. getDimensions(), cerr << "You are attempting to assign two Vectors with different dimensions." << endl - << "First Vector name is " << this -> getName() - << " dimensions are ( " << this -> getDimensions() << " )" << endl - << "Second Vector is " << Vector. getName() - << " dimensions are ( " << Vector. getDimensions() << " )" << endl; ); + << "First vector dimensions are ( " << this -> getDimensions() << " )" << endl + << "Second vector dimensions are ( " << Vector. getDimensions() << " )" << endl; ); tnlVector< Real, Device, Index > :: operator = ( Vector ); return ( *this ); } @@ -192,10 +181,8 @@ tnlMultiVector< 2, Real, Device, Index >& // TODO: Static assert on dimensions tnlAssert( this -> getDimensions() == Vector. getDimensions(), cerr << "You are attempting to assign two Vectors with different dimensions." << endl - << "First Vector name is " << this -> getName() - << " dimensions are ( " << this -> getDimensions() << " )" << endl - << "Second Vector is " << Vector. getName() - << " dimensions are ( " << Vector. getDimensions() << " )" << endl; ); + << "First vector dimensions are ( " << this -> getDimensions() << " )" << endl + << "Second vector dimensions are ( " << Vector. getDimensions() << " )" << endl; ); tnlVector< Real, Device, Index > :: operator = ( Vector ); return ( *this ); } @@ -205,14 +192,12 @@ bool tnlMultiVector< 2, Real, Device, Index > :: save( tnlFile& file ) const { if( ! tnlVector< Real, Device, Index > :: save( file ) ) { - cerr << "I was not able to write the tnlVector of tnlMultiVector " - << this -> getName() << endl; + cerr << "I was not able to write the tnlVector of tnlMultiVector." << endl; return false; } if( ! dimensions. save( file ) ) { - cerr << "I was not able to write the dimensions of tnlMultiVector " - << this -> getName() << endl; + cerr << "I was not able to write the dimensions of tnlMultiVector." << endl; return false; } return true; @@ -223,14 +208,12 @@ bool tnlMultiVector< 2, Real, Device, Index > :: load( tnlFile& file ) { if( ! tnlVector< Real, Device, Index > :: load( file ) ) { - cerr << "I was not able to read the tnlVector of tnlMultiVector " - << this -> getName() << endl; + cerr << "I was not able to read the tnlVector of tnlMultiVector." << endl; return false; } if( ! dimensions. load( file ) ) { - cerr << "I was not able to read the dimensions of tnlMultiVector " - << this -> getName() << endl; + cerr << "I was not able to read the dimensions of tnlMultiVector." << endl; return false; } return true; diff --git a/src/core/vectors/tnlMultiVector3D_impl.h b/src/core/vectors/tnlMultiVector3D_impl.h index 3a19302c373be1f7b56db3fee36b688aa6aa6a04..a549954007be0df8a18ba2461688de0ac6d59065 100644 --- a/src/core/vectors/tnlMultiVector3D_impl.h +++ b/src/core/vectors/tnlMultiVector3D_impl.h @@ -25,12 +25,6 @@ tnlMultiVector< 3, Real, Device, Index > :: tnlMultiVector() { } -template< typename Real, typename Device, typename Index > -tnlMultiVector< 3, Real, Device, Index > :: tnlMultiVector( const tnlString& name ) -{ - this -> setName( name ); -} - template< typename Real, typename Device, typename Index > tnlString tnlMultiVector< 3, Real, Device, Index > :: getType() { @@ -174,10 +168,8 @@ bool tnlMultiVector< 3, Real, Device, Index > :: operator == ( const MultiVector // TODO: Static assert on dimensions tnlAssert( this -> getDimensions() == Vector. getDimensions(), cerr << "You are attempting to compare two Vectors with different dimensions." << endl - << "First Vector name is " << this -> getName() - << " dimensions are ( " << this -> getDimensions() << " )" << endl - << "Second Vector is " << Vector. getName() - << " dimensions are ( " << Vector. getDimensions() << " )" << endl; ); + << "First vector dimensions are ( " << this -> getDimensions() << " )" << endl + << "Second vector dimensions are ( " << Vector. getDimensions() << " )" << endl; ); return tnlVector< Real, Device, Index > :: operator == ( Vector ); } @@ -195,10 +187,8 @@ tnlMultiVector< 3, Real, Device, Index >& // TODO: Static assert on dimensions tnlAssert( this -> getDimensions() == Vector. getDimensions(), cerr << "You are attempting to assign two Vectors with different dimensions." << endl - << "First Vector name is " << this -> getName() - << " dimensions are ( " << this -> getDimensions() << " )" << endl - << "Second Vector is " << Vector. getName() - << " dimensions are ( " << Vector. getDimensions() << " )" << endl; ); + << "First vector dimensions are ( " << this -> getDimensions() << " )" << endl + << "Second vector dimensions are ( " << Vector. getDimensions() << " )" << endl; ); tnlVector< Real, Device, Index > :: operator = ( Vector ); return ( *this ); } @@ -211,10 +201,8 @@ tnlMultiVector< 3, Real, Device, Index >& // TODO: Static assert on dimensions tnlAssert( this -> getDimensions() == Vector. getDimensions(), cerr << "You are attempting to assign two Vectors with different dimensions." << endl - << "First Vector name is " << this -> getName() - << " dimensions are ( " << this -> getDimensions() << " )" << endl - << "Second Vector is " << Vector. getName() - << " dimensions are ( " << Vector. getDimensions() << " )" << endl; ); + << "First vector dimensions are ( " << this -> getDimensions() << " )" << endl + << "Second vector dimensions are ( " << Vector. getDimensions() << " )" << endl; ); tnlVector< Real, Device, Index > :: operator = ( Vector ); return ( *this ); } @@ -224,14 +212,12 @@ bool tnlMultiVector< 3, Real, Device, Index > :: save( tnlFile& file ) const { if( ! tnlVector< Real, Device, Index > :: save( file ) ) { - cerr << "I was not able to write the tnlVector of tnlMultiVector " - << this -> getName() << endl; + cerr << "I was not able to write the tnlVector of tnlMultiVector." << endl; return false; } if( ! dimensions. save( file ) ) { - cerr << "I was not able to write the dimensions of tnlMultiVector " - << this -> getName() << endl; + cerr << "I was not able to write the dimensions of tnlMultiVector." << endl; return false; } return true; @@ -242,14 +228,12 @@ bool tnlMultiVector< 3, Real, Device, Index > :: load( tnlFile& file ) { if( ! tnlVector< Real, Device, Index > :: load( file ) ) { - cerr << "I was not able to read the tnlVector of tnlMultiVector " - << this -> getName() << endl; + cerr << "I was not able to read the tnlVector of tnlMultiVector." << endl; return false; } if( ! dimensions. load( file ) ) { - cerr << "I was not able to read the dimensions of tnlMultiVector " - << this -> getName() << endl; + cerr << "I was not able to read the dimensions of tnlMultiVector." << endl; return false; } return true; diff --git a/src/core/vectors/tnlMultiVector4D_impl.h b/src/core/vectors/tnlMultiVector4D_impl.h index b843e4838df4691c6f101bdc793e3dad71c7aebe..2e34a41bbae4458b3c912c7107494bd9370f2015 100644 --- a/src/core/vectors/tnlMultiVector4D_impl.h +++ b/src/core/vectors/tnlMultiVector4D_impl.h @@ -25,12 +25,6 @@ tnlMultiVector< 4, Real, Device, Index > :: tnlMultiVector() { } -template< typename Real, typename Device, typename Index > -tnlMultiVector< 4, Real, Device, Index > :: tnlMultiVector( const tnlString& name ) -{ - this -> setName( name ); -} - template< typename Real, typename Device, typename Index > tnlString tnlMultiVector< 4, Real, Device, Index > :: getType() { @@ -191,10 +185,8 @@ bool tnlMultiVector< 4, Real, Device, Index > :: operator == ( const MultiVector // TODO: Static assert on dimensions tnlAssert( this -> getDimensions() == Vector. getDimensions(), cerr << "You are attempting to compare two Vectors with different dimensions." << endl - << "First Vector name is " << this -> getName() - << " dimensions are ( " << this -> getDimensions() << " )" << endl - << "Second Vector is " << Vector. getName() - << " dimensions are ( " << Vector. getDimensions() << " )" << endl; ); + << "First vector dimensions are ( " << this -> getDimensions() << " )" << endl + << "Second vector dimensions are ( " << Vector. getDimensions() << " )" << endl; ); return tnlVector< Real, Device, Index > :: operator == ( Vector ); } @@ -212,10 +204,8 @@ tnlMultiVector< 4, Real, Device, Index >& // TODO: Static assert on dimensions tnlAssert( this -> getDimensions() == Vector. getDimensions(), cerr << "You are attempting to assign two Vectors with different dimensions." << endl - << "First Vector name is " << this -> getName() - << " dimensions are ( " << this -> getDimensions() << " )" << endl - << "Second Vector is " << Vector. getName() - << " dimensions are ( " << Vector. getDimensions() << " )" << endl; ); + << "First vector dimensions are ( " << this -> getDimensions() << " )" << endl + << "Second vector dimensions are ( " << Vector. getDimensions() << " )" << endl; ); tnlVector< Real, Device, Index > :: operator = ( Vector ); return ( *this ); } @@ -228,10 +218,8 @@ tnlMultiVector< 4, Real, Device, Index >& // TODO: Static assert on dimensions tnlAssert( this -> getDimensions() == Vector. getDimensions(), cerr << "You are attempting to assign two Vectors with different dimensions." << endl - << "First Vector name is " << this -> getName() - << " dimensions are ( " << this -> getDimensions() << " )" << endl - << "Second Vector is " << Vector. getName() - << " dimensions are ( " << Vector. getDimensions() << " )" << endl; ); + << "First vector dimensions are ( " << this -> getDimensions() << " )" << endl + << "Second vector dimensions are ( " << Vector. getDimensions() << " )" << endl; ); tnlVector< Real, Device, Index > :: operator = ( Vector ); return ( *this ); } @@ -241,14 +229,12 @@ bool tnlMultiVector< 4, Real, Device, Index > :: save( tnlFile& file ) const { if( ! tnlVector< Real, Device, Index > :: save( file ) ) { - cerr << "I was not able to write the tnlVector of tnlMultiVector " - << this -> getName() << endl; + cerr << "I was not able to write the tnlVector of tnlMultiVector." << endl; return false; } if( ! dimensions. save( file ) ) { - cerr << "I was not able to write the dimensions of tnlMultiVector " - << this -> getName() << endl; + cerr << "I was not able to write the dimensions of tnlMultiVector." << endl; return false; } return true; @@ -259,14 +245,12 @@ bool tnlMultiVector< 4, Real, Device, Index > :: load( tnlFile& file ) { if( ! tnlVector< Real, Device, Index > :: load( file ) ) { - cerr << "I was not able to read the tnlVector of tnlMultiVector " - << this -> getName() << endl; + cerr << "I was not able to read the tnlVector of tnlMultiVector." << endl; return false; } if( ! dimensions. load( file ) ) { - cerr << "I was not able to read the dimensions of tnlMultiVector " - << this -> getName() << endl; + cerr << "I was not able to read the dimensions of tnlMultiVector." << endl; return false; } return true; diff --git a/src/core/vectors/tnlSharedVector.h b/src/core/vectors/tnlSharedVector.h index d3e19391f1008a8219572c1c521e91e543a85bf3..d68f4c8a5dc1d2ec64a2d6d06ee68f8bb3b8c3ea 100644 --- a/src/core/vectors/tnlSharedVector.h +++ b/src/core/vectors/tnlSharedVector.h @@ -20,7 +20,7 @@ #include <core/arrays/tnlSharedArray.h> #include <core/vectors/tnlVector.h> -#include <functors/tnlFunctionType.h> +#include <functors/tnlFunction.h> class tnlHost; @@ -37,6 +37,8 @@ class tnlSharedVector : public tnlSharedArray< Real, Device, Index > typedef tnlSharedVector< Real, tnlHost, Index > HostType; typedef tnlSharedVector< Real, tnlCuda, Index > CudaType; + //static constexpr tnlFunctionType getFunctionType() { return tnlDiscreteFunction; } + enum { functionType = tnlDiscreteFunction }; tnlSharedVector(); @@ -147,16 +149,6 @@ class tnlSharedVector : public tnlSharedArray< Real, Device, Index > }; -template< typename Real, - typename Device, - typename Index > -class tnlFunctionType< tnlSharedVector< Real, Device, Index > > -{ - public: - - enum { Type = tnlDiscreteFunction }; -}; - #include <core/vectors/tnlSharedVector_impl.h> #endif /* TNLSHAREDVECTOR_H_ */ diff --git a/src/core/vectors/tnlSharedVector_impl.h b/src/core/vectors/tnlSharedVector_impl.h index 83a5c92e396a3a27de2075ae1e96db929f3d42de..8efd8ab7331947493072695f5569b191295c35ac 100644 --- a/src/core/vectors/tnlSharedVector_impl.h +++ b/src/core/vectors/tnlSharedVector_impl.h @@ -142,7 +142,7 @@ template< typename Real, template< typename Vector > bool tnlSharedVector< Real, Device, Index > :: operator != ( const Vector& vector ) const { - return tnlSharedArray< Real, Device, Index > :: operator == ( vector ); + return tnlSharedArray< Real, Device, Index > :: operator != ( vector ); } template< typename Real, diff --git a/src/core/vectors/tnlVector.h b/src/core/vectors/tnlVector.h index be32ab03b7eaab1b199cc55d71ec1e9f15a9c51c..5108b1835516f3f3dff702724b9e5c921b2a40f8 100644 --- a/src/core/vectors/tnlVector.h +++ b/src/core/vectors/tnlVector.h @@ -19,7 +19,7 @@ #define TNLVECTOR_H_ #include <core/arrays/tnlArray.h> -#include <functors/tnlFunctionType.h> +#include <functors/tnlFunction.h> class tnlHost; @@ -36,12 +36,12 @@ class tnlVector : public tnlArray< Real, Device, Index > typedef tnlVector< Real, tnlHost, Index > HostType; typedef tnlVector< Real, tnlCuda, Index > CudaType; + //static constexpr tnlFunctionType getFunctionType() { return tnlDiscreteFunction; } + enum { functionType = tnlDiscreteFunction }; tnlVector(); - tnlVector( const tnlString& name ); - - tnlVector( const tnlString& name, const Index size ); + tnlVector( const Index size ); static tnlString getType(); @@ -139,16 +139,6 @@ class tnlVector : public tnlArray< Real, Device, Index > void computeExclusivePrefixSum( const IndexType begin, const IndexType end ); }; -template< typename Real, - typename Device, - typename Index > -class tnlFunctionType< tnlVector< Real, Device, Index > > -{ - public: - - enum { Type = tnlDiscreteFunction }; -}; - #include <core/vectors/tnlVector_impl.h> #endif /* TNLVECTOR_H_ */ diff --git a/src/core/vectors/tnlVectorOperations.h b/src/core/vectors/tnlVectorOperations.h index 3438b5250ff5a39dfc3529c5cf452938ff59cdbc..afa7b2e96249ae383cd9f982b98e303c2d559c20 100644 --- a/src/core/vectors/tnlVectorOperations.h +++ b/src/core/vectors/tnlVectorOperations.h @@ -54,6 +54,12 @@ class tnlVectorOperations< tnlHost > template< typename Vector > static typename Vector::RealType getVectorAbsMin( const Vector& v ); + template< typename Vector > + static typename Vector::RealType getVectorL1Norm( const Vector& v ); + + template< typename Vector > + static typename Vector::RealType getVectorL2Norm( const Vector& v ); + template< typename Vector > static typename Vector::RealType getVectorLpNorm( const Vector& v, const typename Vector::RealType& p ); @@ -77,6 +83,14 @@ class tnlVectorOperations< tnlHost > static typename Vector1::RealType getVectorDifferenceAbsMin( const Vector1& v1, const Vector2& v2 ); + template< typename Vector1, typename Vector2 > + static typename Vector1::RealType getVectorDifferenceL1Norm( const Vector1& v1, + const Vector2& v2 ); + + template< typename Vector1, typename Vector2 > + static typename Vector1::RealType getVectorDifferenceL2Norm( const Vector1& v1, + const Vector2& v2 ); + template< typename Vector1, typename Vector2 > static typename Vector1::RealType getVectorDifferenceLpNorm( const Vector1& v1, const Vector2& v2, @@ -85,6 +99,8 @@ class tnlVectorOperations< tnlHost > template< typename Vector1, typename Vector2 > static typename Vector1::RealType getVectorDifferenceSum( const Vector1& v1, const Vector2& v2 ); + + template< typename Vector > static void vectorScalarMultiplication( Vector& v, const typename Vector::RealType& alpha ); @@ -146,11 +162,17 @@ class tnlVectorOperations< tnlCuda > template< typename Vector > static typename Vector::RealType getVectorAbsMin( const Vector& v ); - + + template< typename Vector > + static typename Vector::RealType getVectorL1Norm( const Vector& v ); + + template< typename Vector > + static typename Vector::RealType getVectorL2Norm( const Vector& v ); + template< typename Vector > static typename Vector::RealType getVectorLpNorm( const Vector& v, const typename Vector::RealType& p ); - + template< typename Vector > static typename Vector::RealType getVectorSum( const Vector& v ); @@ -168,8 +190,16 @@ class tnlVectorOperations< tnlCuda > template< typename Vector1, typename Vector2 > static typename Vector1::RealType getVectorDifferenceAbsMin( const Vector1& v1, - const Vector2& v2 ); + const Vector2& v2 ); + + template< typename Vector1, typename Vector2 > + static typename Vector1::RealType getVectorDifferenceL1Norm( const Vector1& v1, + const Vector2& v2 ); + template< typename Vector1, typename Vector2 > + static typename Vector1::RealType getVectorDifferenceL2Norm( const Vector1& v1, + const Vector2& v2 ); + template< typename Vector1, typename Vector2 > static typename Vector1::RealType getVectorDifferenceLpNorm( const Vector1& v1, const Vector2& v2, @@ -178,6 +208,7 @@ class tnlVectorOperations< tnlCuda > template< typename Vector1, typename Vector2 > static typename Vector1::RealType getVectorDifferenceSum( const Vector1& v1, const Vector2& v2 ); + template< typename Vector > static void vectorScalarMultiplication( Vector& v, const typename Vector::RealType& alpha ); diff --git a/src/core/vectors/tnlVectorOperationsCuda_impl.cpp b/src/core/vectors/tnlVectorOperationsCuda_impl.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c9b21196d2741180bcfd597f79d0137cda4d2c33 --- /dev/null +++ b/src/core/vectors/tnlVectorOperationsCuda_impl.cpp @@ -0,0 +1,328 @@ +/*************************************************************************** + tnlVectorOperationsCuda_impl.cpp - description + ------------------- + begin : Dec 10, 2015 + copyright : (C) 2015 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. * + * * + ***************************************************************************/ + +#include <core/vectors/tnlVectorOperations.h> + +#ifdef TEMPLATE_EXPLICIT_INSTANTIATION + +/**** + * Max + */ +template int tnlVectorOperations< tnlCuda >::getVectorMax( const tnlVector< int, tnlCuda, int >& v ); +template long int tnlVectorOperations< tnlCuda >::getVectorMax( const tnlVector< long int, tnlCuda, int >& v ); +#ifdef INSTANTIATE_FLOAT +template float tnlVectorOperations< tnlCuda >::getVectorMax( const tnlVector< float, tnlCuda, int >& v ); +#endif +template double tnlVectorOperations< tnlCuda >::getVectorMax( const tnlVector< double, tnlCuda, int >& v ); +#ifdef INSTANTIATE_LONG_DOUBLE +template long double tnlVectorOperations< tnlCuda >::getVectorMax( const tnlVector< long double, tnlCuda, int >& v ); +#endif + +#ifdef INSTANTIATE_LONG_INT +template int tnlVectorOperations< tnlCuda >::getVectorMax( const tnlVector< int, tnlCuda, long int >& v ); +template long int tnlVectorOperations< tnlCuda >::getVectorMax( const tnlVector< long int, tnlCuda, long int >& v ); +#ifdef INSTANTIATE_FLOAT +template float tnlVectorOperations< tnlCuda >::getVectorMax( const tnlVector< float, tnlCuda, long int >& v ); +#endif +template double tnlVectorOperations< tnlCuda >::getVectorMax( const tnlVector< double, tnlCuda, long int >& v ); +#ifdef INSTANTIATE_LONG_DOUBLE +template long double tnlVectorOperations< tnlCuda >::getVectorMax( const tnlVector< long double, tnlCuda, long int >& v ); +#endif +#endif + +/**** + * Min + */ +template int tnlVectorOperations< tnlCuda >::getVectorMin( const tnlVector< int, tnlCuda, int >& v ); +template long int tnlVectorOperations< tnlCuda >::getVectorMin( const tnlVector< long int, tnlCuda, int >& v ); +#ifdef INSTANTIATE_FLOAT +template float tnlVectorOperations< tnlCuda >::getVectorMin( const tnlVector< float, tnlCuda, int >& v ); +#endif +template double tnlVectorOperations< tnlCuda >::getVectorMin( const tnlVector< double, tnlCuda, int >& v ); +#ifdef INSTANTIATE_LONG_DOUBLE +template long double tnlVectorOperations< tnlCuda >::getVectorMin( const tnlVector< long double, tnlCuda, int >& v ); +#endif + +#ifdef INSTANTIATE_LONG_INT +template int tnlVectorOperations< tnlCuda >::getVectorMin( const tnlVector< int, tnlCuda, long int >& v ); +template long int tnlVectorOperations< tnlCuda >::getVectorMin( const tnlVector< long int, tnlCuda, long int >& v ); +#ifdef INSTANTIATE_FLOAT +template float tnlVectorOperations< tnlCuda >::getVectorMin( const tnlVector< float, tnlCuda, long int >& v ); +#endif +template double tnlVectorOperations< tnlCuda >::getVectorMin( const tnlVector< double, tnlCuda, long int >& v ); +#ifdef INSTANTIATE_LONG_DOUBLE +template long double tnlVectorOperations< tnlCuda >::getVectorMin( const tnlVector< long double, tnlCuda, long int >& v ); +#endif +#endif + +/**** + * Abs max + */ +template int tnlVectorOperations< tnlCuda >::getVectorAbsMax( const tnlVector< int, tnlCuda, int >& v ); +template long int tnlVectorOperations< tnlCuda >::getVectorAbsMax( const tnlVector< long int, tnlCuda, int >& v ); +#ifdef INSTANTIATE_FLOAT +template float tnlVectorOperations< tnlCuda >::getVectorAbsMax( const tnlVector< float, tnlCuda, int >& v ); +#endif +template double tnlVectorOperations< tnlCuda >::getVectorAbsMax( const tnlVector< double, tnlCuda, int >& v ); +#ifdef INSTANTIATE_LONG_DOUBLE +template long double tnlVectorOperations< tnlCuda >::getVectorAbsMax( const tnlVector< long double, tnlCuda, int >& v ); +#endif + +#ifdef INSTANTIATE_LONG_INT +template int tnlVectorOperations< tnlCuda >::getVectorAbsMax( const tnlVector< int, tnlCuda, long int >& v ); +template long int tnlVectorOperations< tnlCuda >::getVectorAbsMax( const tnlVector< long int, tnlCuda, long int >& v ); +#ifdef INSTANTIATE_FLOAT +template float tnlVectorOperations< tnlCuda >::getVectorAbsMax( const tnlVector< float, tnlCuda, long int >& v ); +#endif +template double tnlVectorOperations< tnlCuda >::getVectorAbsMax( const tnlVector< double, tnlCuda, long int >& v ); +#ifdef INSTANTIATE_LONG_DOUBLE +template long double tnlVectorOperations< tnlCuda >::getVectorAbsMax( const tnlVector< long double, tnlCuda, long int >& v ); +#endif +#endif + + +/**** + * Abs min + */ +template int tnlVectorOperations< tnlCuda >::getVectorAbsMin( const tnlVector< int, tnlCuda, int >& v ); +template long int tnlVectorOperations< tnlCuda >::getVectorAbsMin( const tnlVector< long int, tnlCuda, int >& v ); +#ifdef INSTANTIATE_FLOAT +template float tnlVectorOperations< tnlCuda >::getVectorAbsMin( const tnlVector< float, tnlCuda, int >& v ); +#endif +template double tnlVectorOperations< tnlCuda >::getVectorAbsMin( const tnlVector< double, tnlCuda, int >& v ); +#ifdef INSTANTIATE_LONG_DOUBLE +template long double tnlVectorOperations< tnlCuda >::getVectorAbsMin( const tnlVector< long double, tnlCuda, int >& v ); +#endif + +#ifdef INSTANTIATE_LONG_INT +template int tnlVectorOperations< tnlCuda >::getVectorAbsMin( const tnlVector< int, tnlCuda, long int >& v ); +template long int tnlVectorOperations< tnlCuda >::getVectorAbsMin( const tnlVector< long int, tnlCuda, long int >& v ); +#ifdef INSTANTIATE_FLOAT +template float tnlVectorOperations< tnlCuda >::getVectorAbsMin( const tnlVector< float, tnlCuda, long int >& v ); +#endif +template double tnlVectorOperations< tnlCuda >::getVectorAbsMin( const tnlVector< double, tnlCuda, long int >& v ); +#ifdef INSTANTIATE_LONG_DOUBLE +template long double tnlVectorOperations< tnlCuda >::getVectorAbsMin( const tnlVector< long double, tnlCuda, long int >& v ); +#endif +#endif + +/**** + * L2 norm + */ +template int tnlVectorOperations< tnlCuda >::getVectorL2Norm( const tnlVector< int, tnlCuda, int >& v ); +template long int tnlVectorOperations< tnlCuda >::getVectorL2Norm( const tnlVector< long int, tnlCuda, int >& v ); +#ifdef INSTANTIATE_FLOAT +template float tnlVectorOperations< tnlCuda >::getVectorL2Norm( const tnlVector< float, tnlCuda, int >& v ); +#endif +template double tnlVectorOperations< tnlCuda >::getVectorL2Norm( const tnlVector< double, tnlCuda, int >& v ); +#ifdef INSTANTIATE_LONG_DOUBLE +template long double tnlVectorOperations< tnlCuda >::getVectorL2Norm( const tnlVector< long double, tnlCuda, int >& v ); +#endif + +#ifdef INSTANTIATE_LONG_INT +template int tnlVectorOperations< tnlCuda >::getVectorL2Norm( const tnlVector< int, tnlCuda, long int >& v ); +template long int tnlVectorOperations< tnlCuda >::getVectorL2Norm( const tnlVector< long int, tnlCuda, long int >& v ); +#ifdef INSTANTIATE_FLOAT +template float tnlVectorOperations< tnlCuda >::getVectorL2Norm( const tnlVector< float, tnlCuda, long int >& v ); +#endif +template double tnlVectorOperations< tnlCuda >::getVectorL2Norm( const tnlVector< double, tnlCuda, long int >& v ); +#ifdef INSTANTIATE_LONG_DOUBLE +template long double tnlVectorOperations< tnlCuda >::getVectorL2Norm( const tnlVector< long double, tnlCuda, long int >& v ); +#endif +#endif + +/**** + * L1 norm + */ +template int tnlVectorOperations< tnlCuda >::getVectorL1Norm( const tnlVector< int, tnlCuda, int >& v ); +template long int tnlVectorOperations< tnlCuda >::getVectorL1Norm( const tnlVector< long int, tnlCuda, int >& v ); +#ifdef INSTANTIATE_FLOAT +template float tnlVectorOperations< tnlCuda >::getVectorL1Norm( const tnlVector< float, tnlCuda, int >& v ); +#endif +template double tnlVectorOperations< tnlCuda >::getVectorL1Norm( const tnlVector< double, tnlCuda, int >& v ); +#ifdef INSTANTIATE_LONG_DOUBLE +template long double tnlVectorOperations< tnlCuda >::getVectorL1Norm( const tnlVector< long double, tnlCuda, int >& v ); +#endif + +#ifdef INSTANTIATE_LONG_INT +template int tnlVectorOperations< tnlCuda >::getVectorL1Norm( const tnlVector< int, tnlCuda, long int >& v ); +template long int tnlVectorOperations< tnlCuda >::getVectorL1Norm( const tnlVector< long int, tnlCuda, long int >& v ); +#ifdef INSTANTIATE_FLOAT +template float tnlVectorOperations< tnlCuda >::getVectorL1Norm( const tnlVector< float, tnlCuda, long int >& v ); +#endif +template double tnlVectorOperations< tnlCuda >::getVectorL1Norm( const tnlVector< double, tnlCuda, long int >& v ); +#ifdef INSTANTIATE_LONG_DOUBLE +template long double tnlVectorOperations< tnlCuda >::getVectorL1Norm( const tnlVector< long double, tnlCuda, long int >& v ); +#endif +#endif + +/**** + * Lp norm + */ +template int tnlVectorOperations< tnlCuda >::getVectorLpNorm( const tnlVector< int, tnlCuda, int >& v, const int& p ); +template long int tnlVectorOperations< tnlCuda >::getVectorLpNorm( const tnlVector< long int, tnlCuda, int >& v, const long int& p ); +#ifdef INSTANTIATE_FLOAT +template float tnlVectorOperations< tnlCuda >::getVectorLpNorm( const tnlVector< float, tnlCuda, int >& v, const float& p ); +#endif +template double tnlVectorOperations< tnlCuda >::getVectorLpNorm( const tnlVector< double, tnlCuda, int >& v, const double& p ); +#ifdef INSTANTIATE_LONG_DOUBLE +template long double tnlVectorOperations< tnlCuda >::getVectorLpNorm( const tnlVector< long double, tnlCuda, int >& v, const long double& p ); +#endif + +#ifdef INSTANTIATE_LONG_INT +template int tnlVectorOperations< tnlCuda >::getVectorLpNorm( const tnlVector< int, tnlCuda, long int >& v, const int& p ); +template long int tnlVectorOperations< tnlCuda >::getVectorLpNorm( const tnlVector< long int, tnlCuda, long int >& v, const long int& p ); +#ifdef INSTANTIATE_FLOAT +template float tnlVectorOperations< tnlCuda >::getVectorLpNorm( const tnlVector< float, tnlCuda, long int >& v, const float& p ); +#endif +template double tnlVectorOperations< tnlCuda >::getVectorLpNorm( const tnlVector< double, tnlCuda, long int >& v, const double& p ); +#ifdef INSTANTIATE_LONG_DOUBLE +template long double tnlVectorOperations< tnlCuda >::getVectorLpNorm( const tnlVector< long double, tnlCuda, long int >& v, const long double& p ); +#endif +#endif + + + +/**** + * Sum + */ +template int tnlVectorOperations< tnlCuda >::getVectorSum( const tnlVector< int, tnlCuda, int >& v ); +template long int tnlVectorOperations< tnlCuda >::getVectorSum( const tnlVector< long int, tnlCuda, int >& v ); +#ifdef INSTANTIATE_FLOAT +template float tnlVectorOperations< tnlCuda >::getVectorSum( const tnlVector< float, tnlCuda, int >& v ); +#endif +template double tnlVectorOperations< tnlCuda >::getVectorSum( const tnlVector< double, tnlCuda, int >& v ); +#ifdef INSTANTIATE_LONG_DOUBLE +template long double tnlVectorOperations< tnlCuda >::getVectorSum( const tnlVector< long double, tnlCuda, int >& v ); +#endif + +#ifdef INSTANTIATE_LONG_INT +template int tnlVectorOperations< tnlCuda >::getVectorSum( const tnlVector< int, tnlCuda, long int >& v ); +template long int tnlVectorOperations< tnlCuda >::getVectorSum( const tnlVector< long int, tnlCuda, long int >& v ); +#ifdef INSTANTIATE_FLOAT +template float tnlVectorOperations< tnlCuda >::getVectorSum( const tnlVector< float, tnlCuda, long int >& v ); +#endif +template double tnlVectorOperations< tnlCuda >::getVectorSum( const tnlVector< double, tnlCuda, long int >& v ); +#ifdef INSTANTIATE_LONG_DOUBLE +template long double tnlVectorOperations< tnlCuda >::getVectorSum( const tnlVector< long double, tnlCuda, long int >& v ); +#endif +#endif + +/**** + * Difference max + */ +template int tnlVectorOperations< tnlCuda >::getVectorDifferenceMax( const tnlVector< int, tnlCuda, int >& v1, const tnlVector< int, tnlCuda, int >& v2 ); +template long int tnlVectorOperations< tnlCuda >::getVectorDifferenceMax( const tnlVector< long int, tnlCuda, int >& v1, const tnlVector< long int, tnlCuda, int >& v2 ); +#ifdef INSTANTIATE_FLOAT +template float tnlVectorOperations< tnlCuda >::getVectorDifferenceMax( const tnlVector< float, tnlCuda, int >& v1, const tnlVector< float, tnlCuda, int >& v2); +#endif +template double tnlVectorOperations< tnlCuda >::getVectorDifferenceMax( const tnlVector< double, tnlCuda, int >& v1, const tnlVector< double, tnlCuda, int >& v2 ); +#ifdef INSTANTIATE_LONG_DOUBLE +template long double tnlVectorOperations< tnlCuda >::getVectorDifferenceMax( const tnlVector< long double, tnlCuda, int >& v1, const tnlVector< long double, tnlCuda, int >& v2 ); +#endif + +#ifdef INSTANTIATE_LONG_INT +template int tnlVectorOperations< tnlCuda >::getVectorDifferenceMax( const tnlVector< int, tnlCuda, long int >& v1, const tnlVector< int, tnlCuda, long int >& v2 ); +template long int tnlVectorOperations< tnlCuda >::getVectorDifferenceMax( const tnlVector< long int, tnlCuda, long int >& v1, const tnlVector< long int, tnlCuda, long int >& v2 ); +#ifdef INSTANTIATE_FLOAT +template float tnlVectorOperations< tnlCuda >::getVectorDifferenceMax( const tnlVector< float, tnlCuda, long int >& v1, const tnlVector< float, tnlCuda, long int >& v2 ); +#endif +template double tnlVectorOperations< tnlCuda >::getVectorDifferenceMax( const tnlVector< double, tnlCuda, long int >& v1, const tnlVector< double, tnlCuda, long int >& v2 ); +#ifdef INSTANTIATE_LONG_DOUBLE +template long double tnlVectorOperations< tnlCuda >::getVectorDifferenceMax( const tnlVector< long double, tnlCuda, long int >& v1, const tnlVector< long double, tnlCuda, long int >& v2 ); +#endif +#endif + +/**** + * Difference min + */ +template int tnlVectorOperations< tnlCuda >::getVectorDifferenceMin( const tnlVector< int, tnlCuda, int >& v1, const tnlVector< int, tnlCuda, int >& v2 ); +template long int tnlVectorOperations< tnlCuda >::getVectorDifferenceMin( const tnlVector< long int, tnlCuda, int >& v1, const tnlVector< long int, tnlCuda, int >& v2 ); +#ifdef INSTANTIATE_FLOAT +template float tnlVectorOperations< tnlCuda >::getVectorDifferenceMin( const tnlVector< float, tnlCuda, int >& v1, const tnlVector< float, tnlCuda, int >& v2); +#endif +template double tnlVectorOperations< tnlCuda >::getVectorDifferenceMin( const tnlVector< double, tnlCuda, int >& v1, const tnlVector< double, tnlCuda, int >& v2 ); +#ifdef INSTANTIATE_LONG_DOUBLE +template long double tnlVectorOperations< tnlCuda >::getVectorDifferenceMin( const tnlVector< long double, tnlCuda, int >& v1, const tnlVector< long double, tnlCuda, int >& v2 ); +#endif + +#ifdef INSTANTIATE_LONG_INT +template int tnlVectorOperations< tnlCuda >::getVectorDifferenceMin( const tnlVector< int, tnlCuda, long int >& v1, const tnlVector< int, tnlCuda, long int >& v2 ); +template long int tnlVectorOperations< tnlCuda >::getVectorDifferenceMin( const tnlVector< long int, tnlCuda, long int >& v1, const tnlVector< long int, tnlCuda, long int >& v2 ); +#ifdef INSTANTIATE_FLOAT +template float tnlVectorOperations< tnlCuda >::getVectorDifferenceMin( const tnlVector< float, tnlCuda, long int >& v1, const tnlVector< float, tnlCuda, long int >& v2 ); +#endif +template double tnlVectorOperations< tnlCuda >::getVectorDifferenceMin( const tnlVector< double, tnlCuda, long int >& v1, const tnlVector< double, tnlCuda, long int >& v2 ); +#ifdef INSTANTIATE_LONG_DOUBLE +template long double tnlVectorOperations< tnlCuda >::getVectorDifferenceMin( const tnlVector< long double, tnlCuda, long int >& v1, const tnlVector< long double, tnlCuda, long int >& v2 ); +#endif +#endif + +/**** + * Difference abs max + */ +template int tnlVectorOperations< tnlCuda >::getVectorDifferenceAbsMax( const tnlVector< int, tnlCuda, int >& v1, const tnlVector< int, tnlCuda, int >& v2 ); +template long int tnlVectorOperations< tnlCuda >::getVectorDifferenceAbsMax( const tnlVector< long int, tnlCuda, int >& v1, const tnlVector< long int, tnlCuda, int >& v2 ); +#ifdef INSTANTIATE_FLOAT +template float tnlVectorOperations< tnlCuda >::getVectorDifferenceAbsMax( const tnlVector< float, tnlCuda, int >& v1, const tnlVector< float, tnlCuda, int >& v2); +#endif +template double tnlVectorOperations< tnlCuda >::getVectorDifferenceAbsMax( const tnlVector< double, tnlCuda, int >& v1, const tnlVector< double, tnlCuda, int >& v2 ); +#ifdef INSTANTIATE_LONG_DOUBLE +template long double tnlVectorOperations< tnlCuda >::getVectorDifferenceAbsMax( const tnlVector< long double, tnlCuda, int >& v1, const tnlVector< long double, tnlCuda, int >& v2 ); +#endif + +#ifdef INSTANTIATE_LONG_INT +template int tnlVectorOperations< tnlCuda >::getVectorDifferenceAbsMax( const tnlVector< int, tnlCuda, long int >& v1, const tnlVector< int, tnlCuda, long int >& v2 ); +template long int tnlVectorOperations< tnlCuda >::getVectorDifferenceAbsMax( const tnlVector< long int, tnlCuda, long int >& v1, const tnlVector< long int, tnlCuda, long int >& v2 ); +#ifdef INSTANTIATE_FLOAT +template float tnlVectorOperations< tnlCuda >::getVectorDifferenceAbsMax( const tnlVector< float, tnlCuda, long int >& v1, const tnlVector< float, tnlCuda, long int >& v2 ); +#endif +template double tnlVectorOperations< tnlCuda >::getVectorDifferenceAbsMax( const tnlVector< double, tnlCuda, long int >& v1, const tnlVector< double, tnlCuda, long int >& v2 ); +#ifdef INSTANTIATE_LONG_DOUBLE +template long double tnlVectorOperations< tnlCuda >::getVectorDifferenceAbsMax( const tnlVector< long double, tnlCuda, long int >& v1, const tnlVector< long double, tnlCuda, long int >& v2 ); +#endif +#endif + + +/**** + * Difference abs min + */ +template int tnlVectorOperations< tnlCuda >::getVectorDifferenceAbsMin( const tnlVector< int, tnlCuda, int >& v1, const tnlVector< int, tnlCuda, int >& v2 ); +template long int tnlVectorOperations< tnlCuda >::getVectorDifferenceAbsMin( const tnlVector< long int, tnlCuda, int >& v1, const tnlVector< long int, tnlCuda, int >& v2 ); +#ifdef INSTANTIATE_FLOAT +template float tnlVectorOperations< tnlCuda >::getVectorDifferenceAbsMin( const tnlVector< float, tnlCuda, int >& v1, const tnlVector< float, tnlCuda, int >& v2); +#endif +template double tnlVectorOperations< tnlCuda >::getVectorDifferenceAbsMin( const tnlVector< double, tnlCuda, int >& v1, const tnlVector< double, tnlCuda, int >& v2 ); +#ifdef INSTANTIATE_LONG_DOUBLE +template long double tnlVectorOperations< tnlCuda >::getVectorDifferenceAbsMin( const tnlVector< long double, tnlCuda, int >& v1, const tnlVector< long double, tnlCuda, int >& v2 ); +#endif + +#ifdef INSTANTIATE_LONG_INT +template int tnlVectorOperations< tnlCuda >::getVectorDifferenceAbsMin( const tnlVector< int, tnlCuda, long int >& v1, const tnlVector< int, tnlCuda, long int >& v2 ); +template long int tnlVectorOperations< tnlCuda >::getVectorDifferenceAbsMin( const tnlVector< long int, tnlCuda, long int >& v1, const tnlVector< long int, tnlCuda, long int >& v2 ); +#ifdef INSTANTIATE_FLOAT +template float tnlVectorOperations< tnlCuda >::getVectorDifferenceAbsMin( const tnlVector< float, tnlCuda, long int >& v1, const tnlVector< float, tnlCuda, long int >& v2 ); +#endif +template double tnlVectorOperations< tnlCuda >::getVectorDifferenceAbsMin( const tnlVector< double, tnlCuda, long int >& v1, const tnlVector< double, tnlCuda, long int >& v2 ); +#ifdef INSTANTIATE_LONG_DOUBLE +template long double tnlVectorOperations< tnlCuda >::getVectorDifferenceAbsMin( const tnlVector< long double, tnlCuda, long int >& v1, const tnlVector< long double, tnlCuda, long int >& v2 ); +#endif +#endif + +#endif + + diff --git a/src/core/vectors/tnlVectorOperations_impl.cu b/src/core/vectors/tnlVectorOperationsCuda_impl.cu similarity index 85% rename from src/core/vectors/tnlVectorOperations_impl.cu rename to src/core/vectors/tnlVectorOperationsCuda_impl.cu index b8af43c24dba48c7b2775a4c27eba77a1a77b6fa..6190d289a3b76df5c605da8496af3f0fb8dd70d8 100644 --- a/src/core/vectors/tnlVectorOperations_impl.cu +++ b/src/core/vectors/tnlVectorOperationsCuda_impl.cu @@ -1,5 +1,5 @@ /*************************************************************************** - tnlVectorOperations_impl.cu - description + tnlVectorOperationsCuda_impl.cu - description ------------------- begin : Jul 20, 2013 copyright : (C) 2013 by Tomas Oberhuber @@ -120,6 +120,55 @@ template long double tnlVectorOperations< tnlCuda >::getVectorAbsMin( const tnlV #endif #endif +/**** + * L2 norm + */ +template int tnlVectorOperations< tnlCuda >::getVectorL2Norm( const tnlVector< int, tnlCuda, int >& v ); +template long int tnlVectorOperations< tnlCuda >::getVectorL2Norm( const tnlVector< long int, tnlCuda, int >& v ); +#ifdef INSTANTIATE_FLOAT +template float tnlVectorOperations< tnlCuda >::getVectorL2Norm( const tnlVector< float, tnlCuda, int >& v ); +#endif +template double tnlVectorOperations< tnlCuda >::getVectorL2Norm( const tnlVector< double, tnlCuda, int >& v ); +#ifdef INSTANTIATE_LONG_DOUBLE +template long double tnlVectorOperations< tnlCuda >::getVectorL2Norm( const tnlVector< long double, tnlCuda, int >& v ); +#endif + +#ifdef INSTANTIATE_LONG_INT +template int tnlVectorOperations< tnlCuda >::getVectorL2Norm( const tnlVector< int, tnlCuda, long int >& v ); +template long int tnlVectorOperations< tnlCuda >::getVectorL2Norm( const tnlVector< long int, tnlCuda, long int >& v ); +#ifdef INSTANTIATE_FLOAT +template float tnlVectorOperations< tnlCuda >::getVectorL2Norm( const tnlVector< float, tnlCuda, long int >& v ); +#endif +template double tnlVectorOperations< tnlCuda >::getVectorL2Norm( const tnlVector< double, tnlCuda, long int >& v ); +#ifdef INSTANTIATE_LONG_DOUBLE +template long double tnlVectorOperations< tnlCuda >::getVectorL2Norm( const tnlVector< long double, tnlCuda, long int >& v ); +#endif +#endif + +/**** + * L1 norm + */ +template int tnlVectorOperations< tnlCuda >::getVectorL1Norm( const tnlVector< int, tnlCuda, int >& v ); +template long int tnlVectorOperations< tnlCuda >::getVectorL1Norm( const tnlVector< long int, tnlCuda, int >& v ); +#ifdef INSTANTIATE_FLOAT +template float tnlVectorOperations< tnlCuda >::getVectorL1Norm( const tnlVector< float, tnlCuda, int >& v ); +#endif +template double tnlVectorOperations< tnlCuda >::getVectorL1Norm( const tnlVector< double, tnlCuda, int >& v ); +#ifdef INSTANTIATE_LONG_DOUBLE +template long double tnlVectorOperations< tnlCuda >::getVectorL1Norm( const tnlVector< long double, tnlCuda, int >& v ); +#endif + +#ifdef INSTANTIATE_LONG_INT +template int tnlVectorOperations< tnlCuda >::getVectorL1Norm( const tnlVector< int, tnlCuda, long int >& v ); +template long int tnlVectorOperations< tnlCuda >::getVectorL1Norm( const tnlVector< long int, tnlCuda, long int >& v ); +#ifdef INSTANTIATE_FLOAT +template float tnlVectorOperations< tnlCuda >::getVectorL1Norm( const tnlVector< float, tnlCuda, long int >& v ); +#endif +template double tnlVectorOperations< tnlCuda >::getVectorL1Norm( const tnlVector< double, tnlCuda, long int >& v ); +#ifdef INSTANTIATE_LONG_DOUBLE +template long double tnlVectorOperations< tnlCuda >::getVectorL1Norm( const tnlVector< long double, tnlCuda, long int >& v ); +#endif +#endif /**** * Lp norm @@ -146,6 +195,8 @@ template long double tnlVectorOperations< tnlCuda >::getVectorLpNorm( const tnlV #endif #endif + + /**** * Sum */ diff --git a/src/core/vectors/tnlVectorOperationsCuda_impl.h b/src/core/vectors/tnlVectorOperationsCuda_impl.h index 41d537fb5f9c4cb85bd7e4bf503048765b43198b..d026378a8567300063a01a221fa7091fcba278f7 100644 --- a/src/core/vectors/tnlVectorOperationsCuda_impl.h +++ b/src/core/vectors/tnlVectorOperationsCuda_impl.h @@ -45,8 +45,7 @@ typename Vector :: RealType tnlVectorOperations< tnlCuda > :: getVectorMax( cons typedef typename Vector :: RealType Real; typedef typename Vector :: IndexType Index; - tnlAssert( v. getSize() > 0, - cerr << "Vector name is " << v. getName() ); + tnlAssert( v. getSize() > 0, ); Real result( 0 ); tnlParallelReductionMax< Real, Index > operation; @@ -64,8 +63,7 @@ typename Vector :: RealType tnlVectorOperations< tnlCuda > :: getVectorMin( cons typedef typename Vector :: RealType Real; typedef typename Vector :: IndexType Index; - tnlAssert( v. getSize() > 0, - cerr << "Vector name is " << v. getName() ); + tnlAssert( v. getSize() > 0, ); Real result( 0 ); tnlParallelReductionMin< Real, Index > operation; @@ -83,8 +81,7 @@ typename Vector :: RealType tnlVectorOperations< tnlCuda > :: getVectorAbsMax( c typedef typename Vector :: RealType Real; typedef typename Vector :: IndexType Index; - tnlAssert( v. getSize() > 0, - cerr << "Vector name is " << v. getName() ); + tnlAssert( v. getSize() > 0, ); Real result( 0 ); tnlParallelReductionAbsMax< Real, Index > operation; @@ -102,8 +99,7 @@ typename Vector :: RealType tnlVectorOperations< tnlCuda > :: getVectorAbsMin( c typedef typename Vector :: RealType Real; typedef typename Vector :: IndexType Index; - tnlAssert( v. getSize() > 0, - cerr << "Vector name is " << v. getName() ); + tnlAssert( v. getSize() > 0, ); Real result( 0 ); tnlParallelReductionAbsMin< Real, Index > operation; @@ -116,17 +112,63 @@ typename Vector :: RealType tnlVectorOperations< tnlCuda > :: getVectorAbsMin( c } template< typename Vector > -typename Vector :: RealType tnlVectorOperations< tnlCuda > :: getVectorLpNorm( const Vector& v, - const typename Vector :: RealType& p ) +typename Vector::RealType +tnlVectorOperations< tnlCuda >:: +getVectorL1Norm( const Vector& v ) +{ + typedef typename Vector :: RealType Real; + typedef typename Vector :: IndexType Index; + + tnlAssert( v. getSize() > 0, ); + + Real result( 0 ); + tnlParallelReductionAbsSum< Real, Index > operation; + reductionOnCudaDevice( operation, + v. getSize(), + v. getData(), + ( Real* ) 0, + result ); + return result; +} + +template< typename Vector > +typename Vector::RealType +tnlVectorOperations< tnlCuda >:: +getVectorL2Norm( const Vector& v ) { typedef typename Vector :: RealType Real; typedef typename Vector :: IndexType Index; - tnlAssert( v. getSize() > 0, - cerr << "Vector name is " << v. getName() ); + tnlAssert( v. getSize() > 0, ); + + Real result( 0 ); + tnlParallelReductionL2Norm< Real, Index > operation; + reductionOnCudaDevice( operation, + v. getSize(), + v. getData(), + ( Real* ) 0, + result ); + return sqrt( result ); +} + + +template< typename Vector > +typename Vector::RealType +tnlVectorOperations< tnlCuda >:: +getVectorLpNorm( const Vector& v, + const typename Vector::RealType& p ) +{ + typedef typename Vector :: RealType Real; + typedef typename Vector :: IndexType Index; + + tnlAssert( v. getSize() > 0, ); tnlAssert( p > 0.0, cerr << " p = " << p ); - + + if( p == 1 ) + return getVectorL1Norm( v ); + if( p == 2 ) + return getVectorL2Norm( v ); Real result( 0 ); tnlParallelReductionLpNorm< Real, Index > operation; operation. setPower( p ); @@ -144,8 +186,7 @@ typename Vector :: RealType tnlVectorOperations< tnlCuda > :: getVectorSum( cons typedef typename Vector :: RealType Real; typedef typename Vector :: IndexType Index; - tnlAssert( v. getSize() > 0, - cerr << "Vector name is " << v. getName() ); + tnlAssert( v. getSize() > 0, ); Real result( 0 ); tnlParallelReductionSum< Real, Index > operation; @@ -164,10 +205,8 @@ typename Vector1 :: RealType tnlVectorOperations< tnlCuda > :: getVectorDifferen typedef typename Vector1 :: RealType Real; typedef typename Vector1 :: IndexType Index; - tnlAssert( v1. getSize() > 0, - cerr << "Vector name is " << v1. getName() ); - tnlAssert( v1. getSize() == v2. getSize(), - cerr << "Vector names are " << v1. getName() << " and " << v2. getName() ); + tnlAssert( v1. getSize() > 0, ); + tnlAssert( v1. getSize() == v2. getSize(), ); Real result( 0 ); tnlParallelReductionDiffMax< Real, Index > operation; @@ -186,10 +225,8 @@ typename Vector1 :: RealType tnlVectorOperations< tnlCuda > :: getVectorDifferen typedef typename Vector1 :: RealType Real; typedef typename Vector1 :: IndexType Index; - tnlAssert( v1. getSize() > 0, - cerr << "Vector name is " << v1. getName() ); - tnlAssert( v1. getSize() == v2. getSize(), - cerr << "Vector names are " << v1. getName() << " and " << v2. getName() ); + tnlAssert( v1. getSize() > 0, ); + tnlAssert( v1. getSize() == v2. getSize(), ); Real result( 0 ); tnlParallelReductionDiffMin< Real, Index > operation; @@ -209,10 +246,8 @@ typename Vector1 :: RealType tnlVectorOperations< tnlCuda > :: getVectorDifferen typedef typename Vector1 :: RealType Real; typedef typename Vector1 :: IndexType Index; - tnlAssert( v1. getSize() > 0, - cerr << "Vector name is " << v1. getName() ); - tnlAssert( v1. getSize() == v2. getSize(), - cerr << "Vector names are " << v1. getName() << " and " << v2. getName() ); + tnlAssert( v1. getSize() > 0, ); + tnlAssert( v1. getSize() == v2. getSize(), ); Real result( 0 ); tnlParallelReductionDiffAbsMax< Real, Index > operation; @@ -231,10 +266,8 @@ typename Vector1 :: RealType tnlVectorOperations< tnlCuda > :: getVectorDifferen typedef typename Vector1 :: RealType Real; typedef typename Vector1 :: IndexType Index; - tnlAssert( v1. getSize() > 0, - cerr << "Vector name is " << v1. getName() ); - tnlAssert( v1. getSize() == v2. getSize(), - cerr << "Vector names are " << v1. getName() << " and " << v2. getName() ); + tnlAssert( v1. getSize() > 0, ); + tnlAssert( v1. getSize() == v2. getSize(), ); Real result( 0 ); tnlParallelReductionDiffAbsMin< Real, Index > operation; @@ -246,6 +279,51 @@ typename Vector1 :: RealType tnlVectorOperations< tnlCuda > :: getVectorDifferen return result; } +template< typename Vector1, typename Vector2 > +typename Vector1::RealType +tnlVectorOperations< tnlCuda >:: +getVectorDifferenceL1Norm( const Vector1& v1, + const Vector2& v2 ) +{ + typedef typename Vector1 :: RealType Real; + typedef typename Vector1 :: IndexType Index; + + tnlAssert( v1. getSize() > 0, ); + tnlAssert( v1. getSize() == v2. getSize(), ); + + Real result( 0 ); + tnlParallelReductionDiffAbsSum< Real, Index > operation; + reductionOnCudaDevice( operation, + v1. getSize(), + v1. getData(), + v2. getData(), + result ); + return result; +} + +template< typename Vector1, typename Vector2 > +typename Vector1::RealType +tnlVectorOperations< tnlCuda >:: +getVectorDifferenceL2Norm( const Vector1& v1, + const Vector2& v2 ) +{ + typedef typename Vector1 :: RealType Real; + typedef typename Vector1 :: IndexType Index; + + tnlAssert( v1. getSize() > 0, ); + tnlAssert( v1. getSize() == v2. getSize(), ); + + Real result( 0 ); + tnlParallelReductionDiffL2Norm< Real, Index > operation; + reductionOnCudaDevice( operation, + v1. getSize(), + v1. getData(), + v2. getData(), + result ); + return sqrt( result ); +} + + template< typename Vector1, typename Vector2 > typename Vector1::RealType tnlVectorOperations< tnlCuda >:: @@ -258,10 +336,8 @@ getVectorDifferenceLpNorm( const Vector1& v1, tnlAssert( p > 0.0, cerr << " p = " << p ); - tnlAssert( v1. getSize() > 0, - cerr << "Vector name is " << v1. getName() ); - tnlAssert( v1. getSize() == v2. getSize(), - cerr << "Vector names are " << v1. getName() << " and " << v2. getName() ); + tnlAssert( v1. getSize() > 0, ); + tnlAssert( v1. getSize() == v2. getSize(), ); Real result( 0 ); tnlParallelReductionDiffLpNorm< Real, Index > operation; @@ -281,10 +357,8 @@ typename Vector1 :: RealType tnlVectorOperations< tnlCuda > :: getVectorDifferen typedef typename Vector1 :: RealType Real; typedef typename Vector1 :: IndexType Index; - tnlAssert( v1. getSize() > 0, - cerr << "Vector name is " << v1. getName() ); - tnlAssert( v1. getSize() == v2. getSize(), - cerr << "Vector names are " << v1. getName() << " and " << v2. getName() ); + tnlAssert( v1. getSize() > 0, ); + tnlAssert( v1. getSize() == v2. getSize(), ); Real result( 0 ); tnlParallelReductionDiffSum< Real, Index > operation; @@ -319,8 +393,7 @@ void tnlVectorOperations< tnlCuda > :: vectorScalarMultiplication( Vector& v, typedef typename Vector :: RealType Real; typedef typename Vector :: IndexType Index; - tnlAssert( v. getSize() > 0, - cerr << "Vector name is " << v. getName() ); + tnlAssert( v. getSize() > 0, ); #ifdef HAVE_CUDA dim3 blockSize( 0 ), gridSize( 0 ); @@ -345,10 +418,8 @@ typename Vector1 :: RealType tnlVectorOperations< tnlCuda > :: getScalarProduct( typedef typename Vector1 :: RealType Real; typedef typename Vector1 :: IndexType Index; - tnlAssert( v1. getSize() > 0, - cerr << "Vector name is " << v1. getName() ); - tnlAssert( v1. getSize() == v2. getSize(), - cerr << "Vector names are " << v1. getName() << " and " << v2. getName() ); + tnlAssert( v1. getSize() > 0, ); + tnlAssert( v1. getSize() == v2. getSize(), ); Real result( 0 ); /*#if defined HAVE_CUBLAS && defined HAVE_CUDA @@ -402,10 +473,8 @@ void tnlVectorOperations< tnlCuda > :: addVector( Vector1& y, typedef typename Vector1 :: RealType Real; typedef typename Vector1 :: IndexType Index; - tnlAssert( y. getSize() > 0, - cerr << "Vector name is " << y. getName() ); - tnlAssert( y. getSize() == x. getSize(), - cerr << "Vector names are " << x. getName() << " and " << y. getName() ); + tnlAssert( y. getSize() > 0, ); + tnlAssert( y. getSize() == x. getSize(), ); tnlAssert( y.getData() != 0, ); tnlAssert( x.getData() != 0, ); @@ -476,12 +545,9 @@ addVectors( Vector1& v, typedef typename Vector1 :: RealType Real; typedef typename Vector1 :: IndexType Index; - tnlAssert( v.getSize() > 0, - cerr << "Vector name is " << v.getName() ); - tnlAssert( v.getSize() == v1.getSize(), - cerr << "Vector names are " << v.getName() << " and " << v1.getName() ); - tnlAssert( v.getSize() == v2.getSize(), - cerr << "Vector names are " << v.getName() << " and " << v2.getName() ); + tnlAssert( v.getSize() > 0, ); + tnlAssert( v.getSize() == v1.getSize(), ); + tnlAssert( v.getSize() == v2.getSize(), ); tnlAssert( v.getData() != 0, ); tnlAssert( v1.getData() != 0, ); tnlAssert( v2.getData() != 0, ); diff --git a/src/core/vectors/tnlVectorOperations_impl.cpp b/src/core/vectors/tnlVectorOperationsHost_impl.cpp similarity index 52% rename from src/core/vectors/tnlVectorOperations_impl.cpp rename to src/core/vectors/tnlVectorOperationsHost_impl.cpp index dbd2275c17f405ec2733f8fb19018dafd2ced47f..6b95318297dc2588633710c47ca9c39c500b6865 100644 --- a/src/core/vectors/tnlVectorOperations_impl.cpp +++ b/src/core/vectors/tnlVectorOperationsHost_impl.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - tnlVectorOperations_impl.cpp - description + tnlVectorOperationsHost_impl.cpp - description ------------------- begin : Jul 20, 2013 copyright : (C) 2013 by Tomas Oberhuber @@ -119,6 +119,57 @@ template long double tnlVectorOperations< tnlHost >::getVectorAbsMin( const tnlV #endif #endif +/**** + * L1 norm + */ +template int tnlVectorOperations< tnlHost >::getVectorL1Norm( const tnlVector< int, tnlHost, int >& v ); +template long int tnlVectorOperations< tnlHost >::getVectorL1Norm( const tnlVector< long int, tnlHost, int >& v ); +#ifdef INSTANTIATE_FLOAT +template float tnlVectorOperations< tnlHost >::getVectorL1Norm( const tnlVector< float, tnlHost, int >& v ); +#endif +template double tnlVectorOperations< tnlHost >::getVectorL1Norm( const tnlVector< double, tnlHost, int >& v ); +#ifdef INSTANTIATE_LONG_DOUBLE +template long double tnlVectorOperations< tnlHost >::getVectorL1Norm( const tnlVector< long double, tnlHost, int >& v ); +#endif + +#ifdef INSTANTIATE_LONG_INT +template int tnlVectorOperations< tnlHost >::getVectorL1Norm( const tnlVector< int, tnlHost, long int >& v ); +template long int tnlVectorOperations< tnlHost >::getVectorL1Norm( const tnlVector< long int, tnlHost, long int >& v ); +#ifdef INSTANTIATE_FLOAT +template float tnlVectorOperations< tnlHost >::getVectorL1Norm( const tnlVector< float, tnlHost, long int >& v ); +#endif +template double tnlVectorOperations< tnlHost >::getVectorL1Norm( const tnlVector< double, tnlHost, long int >& v ); +#ifdef INSTANTIATE_LONG_DOUBLE +template long double tnlVectorOperations< tnlHost >::getVectorL1Norm( const tnlVector< long double, tnlHost, long int >& v ); +#endif +#endif + +/**** + * L2 norm + */ +template int tnlVectorOperations< tnlHost >::getVectorL2Norm( const tnlVector< int, tnlHost, int >& v ); +template long int tnlVectorOperations< tnlHost >::getVectorL2Norm( const tnlVector< long int, tnlHost, int >& v ); +#ifdef INSTANTIATE_FLOAT +template float tnlVectorOperations< tnlHost >::getVectorL2Norm( const tnlVector< float, tnlHost, int >& v ); +#endif +template double tnlVectorOperations< tnlHost >::getVectorL2Norm( const tnlVector< double, tnlHost, int >& v ); +#ifdef INSTANTIATE_LONG_DOUBLE +template long double tnlVectorOperations< tnlHost >::getVectorL2Norm( const tnlVector< long double, tnlHost, int >& v ); +#endif + +#ifdef INSTANTIATE_LONG_INT +template int tnlVectorOperations< tnlHost >::getVectorL2Norm( const tnlVector< int, tnlHost, long int >& v ); +template long int tnlVectorOperations< tnlHost >::getVectorL2Norm( const tnlVector< long int, tnlHost, long int >& v ); +#ifdef INSTANTIATE_FLOAT +template float tnlVectorOperations< tnlHost >::getVectorL2Norm( const tnlVector< float, tnlHost, long int >& v ); +#endif +template double tnlVectorOperations< tnlHost >::getVectorL2Norm( const tnlVector< double, tnlHost, long int >& v ); +#ifdef INSTANTIATE_LONG_DOUBLE +template long double tnlVectorOperations< tnlHost >::getVectorL2Norm( const tnlVector< long double, tnlHost, long int >& v ); +#endif +#endif + + /**** * Lp norm */ @@ -144,6 +195,8 @@ template long double tnlVectorOperations< tnlHost >::getVectorLpNorm( const tnlV #endif #endif + + /**** * Sum */ @@ -269,258 +322,6 @@ template long double tnlVectorOperations< tnlHost >::getVectorDifferenceAbsMin( #endif #endif -/**** - * Max - */ -template int tnlVectorOperations< tnlCuda >::getVectorMax( const tnlVector< int, tnlCuda, int >& v ); -template long int tnlVectorOperations< tnlCuda >::getVectorMax( const tnlVector< long int, tnlCuda, int >& v ); -#ifdef INSTANTIATE_FLOAT -template float tnlVectorOperations< tnlCuda >::getVectorMax( const tnlVector< float, tnlCuda, int >& v ); -#endif -template double tnlVectorOperations< tnlCuda >::getVectorMax( const tnlVector< double, tnlCuda, int >& v ); -#ifdef INSTANTIATE_LONG_DOUBLE -template long double tnlVectorOperations< tnlCuda >::getVectorMax( const tnlVector< long double, tnlCuda, int >& v ); -#endif - -#ifdef INSTANTIATE_LONG_INT -template int tnlVectorOperations< tnlCuda >::getVectorMax( const tnlVector< int, tnlCuda, long int >& v ); -template long int tnlVectorOperations< tnlCuda >::getVectorMax( const tnlVector< long int, tnlCuda, long int >& v ); -#ifdef INSTANTIATE_FLOAT -template float tnlVectorOperations< tnlCuda >::getVectorMax( const tnlVector< float, tnlCuda, long int >& v ); -#endif -template double tnlVectorOperations< tnlCuda >::getVectorMax( const tnlVector< double, tnlCuda, long int >& v ); -#ifdef INSTANTIATE_LONG_DOUBLE -template long double tnlVectorOperations< tnlCuda >::getVectorMax( const tnlVector< long double, tnlCuda, long int >& v ); -#endif -#endif - - -/**** - * Min - */ -template int tnlVectorOperations< tnlCuda >::getVectorMin( const tnlVector< int, tnlCuda, int >& v ); -template long int tnlVectorOperations< tnlCuda >::getVectorMin( const tnlVector< long int, tnlCuda, int >& v ); -#ifdef INSTANTIATE_FLOAT -template float tnlVectorOperations< tnlCuda >::getVectorMin( const tnlVector< float, tnlCuda, int >& v ); -#endif -template double tnlVectorOperations< tnlCuda >::getVectorMin( const tnlVector< double, tnlCuda, int >& v ); -#ifdef INSTANTIATE_LONG_DOUBLE -template long double tnlVectorOperations< tnlCuda >::getVectorMin( const tnlVector< long double, tnlCuda, int >& v ); -#endif - -#ifdef INSTANTIATE_LONG_INT -template int tnlVectorOperations< tnlCuda >::getVectorMin( const tnlVector< int, tnlCuda, long int >& v ); -template long int tnlVectorOperations< tnlCuda >::getVectorMin( const tnlVector< long int, tnlCuda, long int >& v ); -#ifdef INSTANTIATE_FLOAT -template float tnlVectorOperations< tnlCuda >::getVectorMin( const tnlVector< float, tnlCuda, long int >& v ); -#endif -template double tnlVectorOperations< tnlCuda >::getVectorMin( const tnlVector< double, tnlCuda, long int >& v ); -#ifdef INSTANTIATE_LONG_DOUBLE -template long double tnlVectorOperations< tnlCuda >::getVectorMin( const tnlVector< long double, tnlCuda, long int >& v ); -#endif -#endif - -/**** - * Abs max - */ -template int tnlVectorOperations< tnlCuda >::getVectorAbsMax( const tnlVector< int, tnlCuda, int >& v ); -template long int tnlVectorOperations< tnlCuda >::getVectorAbsMax( const tnlVector< long int, tnlCuda, int >& v ); -#ifdef INSTANTIATE_FLOAT -template float tnlVectorOperations< tnlCuda >::getVectorAbsMax( const tnlVector< float, tnlCuda, int >& v ); -#endif -template double tnlVectorOperations< tnlCuda >::getVectorAbsMax( const tnlVector< double, tnlCuda, int >& v ); -#ifdef INSTANTIATE_LONG_DOUBLE -template long double tnlVectorOperations< tnlCuda >::getVectorAbsMax( const tnlVector< long double, tnlCuda, int >& v ); -#endif - -#ifdef INSTANTIATE_LONG_INT -template int tnlVectorOperations< tnlCuda >::getVectorAbsMax( const tnlVector< int, tnlCuda, long int >& v ); -template long int tnlVectorOperations< tnlCuda >::getVectorAbsMax( const tnlVector< long int, tnlCuda, long int >& v ); -#ifdef INSTANTIATE_FLOAT -template float tnlVectorOperations< tnlCuda >::getVectorAbsMax( const tnlVector< float, tnlCuda, long int >& v ); -#endif -template double tnlVectorOperations< tnlCuda >::getVectorAbsMax( const tnlVector< double, tnlCuda, long int >& v ); -#ifdef INSTANTIATE_LONG_DOUBLE -template long double tnlVectorOperations< tnlCuda >::getVectorAbsMax( const tnlVector< long double, tnlCuda, long int >& v ); -#endif -#endif - -/**** - * Abs min - */ -template int tnlVectorOperations< tnlCuda >::getVectorAbsMin( const tnlVector< int, tnlCuda, int >& v ); -template long int tnlVectorOperations< tnlCuda >::getVectorAbsMin( const tnlVector< long int, tnlCuda, int >& v ); -#ifdef INSTANTIATE_FLOAT -template float tnlVectorOperations< tnlCuda >::getVectorAbsMin( const tnlVector< float, tnlCuda, int >& v ); -#endif -template double tnlVectorOperations< tnlCuda >::getVectorAbsMin( const tnlVector< double, tnlCuda, int >& v ); -#ifdef INSTANTIATE_LONG_DOUBLE -template long double tnlVectorOperations< tnlCuda >::getVectorAbsMin( const tnlVector< long double, tnlCuda, int >& v ); -#endif - -#ifdef INSTANTIATE_LONG_INT -template int tnlVectorOperations< tnlCuda >::getVectorAbsMin( const tnlVector< int, tnlCuda, long int >& v ); -template long int tnlVectorOperations< tnlCuda >::getVectorAbsMin( const tnlVector< long int, tnlCuda, long int >& v ); -#ifdef INSTANTIATE_FLOAT -template float tnlVectorOperations< tnlCuda >::getVectorAbsMin( const tnlVector< float, tnlCuda, long int >& v ); -#endif -template double tnlVectorOperations< tnlCuda >::getVectorAbsMin( const tnlVector< double, tnlCuda, long int >& v ); -#ifdef INSTANTIATE_LONG_DOUBLE -template long double tnlVectorOperations< tnlCuda >::getVectorAbsMin( const tnlVector< long double, tnlCuda, long int >& v ); -#endif -#endif - -/**** - * Lp norm - */ -template int tnlVectorOperations< tnlCuda >::getVectorLpNorm( const tnlVector< int, tnlCuda, int >& v, const int& p ); -template long int tnlVectorOperations< tnlCuda >::getVectorLpNorm( const tnlVector< long int, tnlCuda, int >& v, const long int& p ); -#ifdef INSTANTIATE_FLOAT -template float tnlVectorOperations< tnlCuda >::getVectorLpNorm( const tnlVector< float, tnlCuda, int >& v, const float& p ); -#endif -template double tnlVectorOperations< tnlCuda >::getVectorLpNorm( const tnlVector< double, tnlCuda, int >& v, const double& p ); -#ifdef INSTANTIATE_LONG_DOUBLE -template long double tnlVectorOperations< tnlCuda >::getVectorLpNorm( const tnlVector< long double, tnlCuda, int >& v, const long double& p ); -#endif - -#ifdef INSTANTIATE_LONG_INT -template int tnlVectorOperations< tnlCuda >::getVectorLpNorm( const tnlVector< int, tnlCuda, long int >& v, const int& p ); -template long int tnlVectorOperations< tnlCuda >::getVectorLpNorm( const tnlVector< long int, tnlCuda, long int >& v, const long int& p ); -#ifdef INSTANTIATE_FLOAT -template float tnlVectorOperations< tnlCuda >::getVectorLpNorm( const tnlVector< float, tnlCuda, long int >& v, const float& p ); -#endif -template double tnlVectorOperations< tnlCuda >::getVectorLpNorm( const tnlVector< double, tnlCuda, long int >& v, const double& p ); -#ifdef INSTANTIATE_LONG_DOUBLE -template long double tnlVectorOperations< tnlCuda >::getVectorLpNorm( const tnlVector< long double, tnlCuda, long int >& v, const long double& p ); -#endif -#endif - -/**** - * Sum - */ -template int tnlVectorOperations< tnlCuda >::getVectorSum( const tnlVector< int, tnlCuda, int >& v ); -template long int tnlVectorOperations< tnlCuda >::getVectorSum( const tnlVector< long int, tnlCuda, int >& v ); -#ifdef INSTANTIATE_FLOAT -template float tnlVectorOperations< tnlCuda >::getVectorSum( const tnlVector< float, tnlCuda, int >& v ); -#endif -template double tnlVectorOperations< tnlCuda >::getVectorSum( const tnlVector< double, tnlCuda, int >& v ); -#ifdef INSTANTIATE_LONG_DOUBLE -template long double tnlVectorOperations< tnlCuda >::getVectorSum( const tnlVector< long double, tnlCuda, int >& v ); -#endif - -#ifdef INSTANTIATE_LONG_INT -template int tnlVectorOperations< tnlCuda >::getVectorSum( const tnlVector< int, tnlCuda, long int >& v ); -template long int tnlVectorOperations< tnlCuda >::getVectorSum( const tnlVector< long int, tnlCuda, long int >& v ); -#ifdef INSTANTIATE_FLOAT -template float tnlVectorOperations< tnlCuda >::getVectorSum( const tnlVector< float, tnlCuda, long int >& v ); -#endif -template double tnlVectorOperations< tnlCuda >::getVectorSum( const tnlVector< double, tnlCuda, long int >& v ); -#ifdef INSTANTIATE_LONG_DOUBLE -template long double tnlVectorOperations< tnlCuda >::getVectorSum( const tnlVector< long double, tnlCuda, long int >& v ); -#endif -#endif - - -/**** - * Difference max - */ -template int tnlVectorOperations< tnlCuda >::getVectorDifferenceMax( const tnlVector< int, tnlCuda, int >& v1, const tnlVector< int, tnlCuda, int >& v2 ); -template long int tnlVectorOperations< tnlCuda >::getVectorDifferenceMax( const tnlVector< long int, tnlCuda, int >& v1, const tnlVector< long int, tnlCuda, int >& v2 ); -#ifdef INSTANTIATE_FLOAT -template float tnlVectorOperations< tnlCuda >::getVectorDifferenceMax( const tnlVector< float, tnlCuda, int >& v1, const tnlVector< float, tnlCuda, int >& v2); -#endif -template double tnlVectorOperations< tnlCuda >::getVectorDifferenceMax( const tnlVector< double, tnlCuda, int >& v1, const tnlVector< double, tnlCuda, int >& v2 ); -#ifdef INSTANTIATE_LONG_DOUBLE -template long double tnlVectorOperations< tnlCuda >::getVectorDifferenceMax( const tnlVector< long double, tnlCuda, int >& v1, const tnlVector< long double, tnlCuda, int >& v2 ); -#endif - -#ifdef INSTANTIATE_LONG_INT -template int tnlVectorOperations< tnlCuda >::getVectorDifferenceMax( const tnlVector< int, tnlCuda, long int >& v1, const tnlVector< int, tnlCuda, long int >& v2 ); -template long int tnlVectorOperations< tnlCuda >::getVectorDifferenceMax( const tnlVector< long int, tnlCuda, long int >& v1, const tnlVector< long int, tnlCuda, long int >& v2 ); -#ifdef INSTANTIATE_FLOAT -template float tnlVectorOperations< tnlCuda >::getVectorDifferenceMax( const tnlVector< float, tnlCuda, long int >& v1, const tnlVector< float, tnlCuda, long int >& v2 ); -#endif -template double tnlVectorOperations< tnlCuda >::getVectorDifferenceMax( const tnlVector< double, tnlCuda, long int >& v1, const tnlVector< double, tnlCuda, long int >& v2 ); -#ifdef INSTANTIATE_LONG_DOUBLE -template long double tnlVectorOperations< tnlCuda >::getVectorDifferenceMax( const tnlVector< long double, tnlCuda, long int >& v1, const tnlVector< long double, tnlCuda, long int >& v2 ); -#endif -#endif - - -/**** - * Difference min - */ -template int tnlVectorOperations< tnlCuda >::getVectorDifferenceMin( const tnlVector< int, tnlCuda, int >& v1, const tnlVector< int, tnlCuda, int >& v2 ); -template long int tnlVectorOperations< tnlCuda >::getVectorDifferenceMin( const tnlVector< long int, tnlCuda, int >& v1, const tnlVector< long int, tnlCuda, int >& v2 ); -#ifdef INSTANTIATE_FLOAT -template float tnlVectorOperations< tnlCuda >::getVectorDifferenceMin( const tnlVector< float, tnlCuda, int >& v1, const tnlVector< float, tnlCuda, int >& v2); -#endif -template double tnlVectorOperations< tnlCuda >::getVectorDifferenceMin( const tnlVector< double, tnlCuda, int >& v1, const tnlVector< double, tnlCuda, int >& v2 ); -#ifdef INSTANTIATE_LONG_DOUBLE -template long double tnlVectorOperations< tnlCuda >::getVectorDifferenceMin( const tnlVector< long double, tnlCuda, int >& v1, const tnlVector< long double, tnlCuda, int >& v2 ); -#endif - -#ifdef INSTANTIATE_LONG_INT -template int tnlVectorOperations< tnlCuda >::getVectorDifferenceMin( const tnlVector< int, tnlCuda, long int >& v1, const tnlVector< int, tnlCuda, long int >& v2 ); -template long int tnlVectorOperations< tnlCuda >::getVectorDifferenceMin( const tnlVector< long int, tnlCuda, long int >& v1, const tnlVector< long int, tnlCuda, long int >& v2 ); -#ifdef INSTANTIATE_FLOAT -template float tnlVectorOperations< tnlCuda >::getVectorDifferenceMin( const tnlVector< float, tnlCuda, long int >& v1, const tnlVector< float, tnlCuda, long int >& v2 ); -#endif -template double tnlVectorOperations< tnlCuda >::getVectorDifferenceMin( const tnlVector< double, tnlCuda, long int >& v1, const tnlVector< double, tnlCuda, long int >& v2 ); -#ifdef INSTANTIATE_LONG_DOUBLE -template long double tnlVectorOperations< tnlCuda >::getVectorDifferenceMin( const tnlVector< long double, tnlCuda, long int >& v1, const tnlVector< long double, tnlCuda, long int >& v2 ); -#endif -#endif - -/**** - * Difference abs max - */ -template int tnlVectorOperations< tnlCuda >::getVectorDifferenceAbsMax( const tnlVector< int, tnlCuda, int >& v1, const tnlVector< int, tnlCuda, int >& v2 ); -template long int tnlVectorOperations< tnlCuda >::getVectorDifferenceAbsMax( const tnlVector< long int, tnlCuda, int >& v1, const tnlVector< long int, tnlCuda, int >& v2 ); -#ifdef INSTANTIATE_FLOAT -template float tnlVectorOperations< tnlCuda >::getVectorDifferenceAbsMax( const tnlVector< float, tnlCuda, int >& v1, const tnlVector< float, tnlCuda, int >& v2); -#endif -template double tnlVectorOperations< tnlCuda >::getVectorDifferenceAbsMax( const tnlVector< double, tnlCuda, int >& v1, const tnlVector< double, tnlCuda, int >& v2 ); -#ifdef INSTANTIATE_LONG_DOUBLE -template long double tnlVectorOperations< tnlCuda >::getVectorDifferenceAbsMax( const tnlVector< long double, tnlCuda, int >& v1, const tnlVector< long double, tnlCuda, int >& v2 ); -#endif - -#ifdef INSTANTIATE_LONG_INT -template int tnlVectorOperations< tnlCuda >::getVectorDifferenceAbsMax( const tnlVector< int, tnlCuda, long int >& v1, const tnlVector< int, tnlCuda, long int >& v2 ); -template long int tnlVectorOperations< tnlCuda >::getVectorDifferenceAbsMax( const tnlVector< long int, tnlCuda, long int >& v1, const tnlVector< long int, tnlCuda, long int >& v2 ); -#ifdef INSTANTIATE_FLOAT -template float tnlVectorOperations< tnlCuda >::getVectorDifferenceAbsMax( const tnlVector< float, tnlCuda, long int >& v1, const tnlVector< float, tnlCuda, long int >& v2 ); -#endif -template double tnlVectorOperations< tnlCuda >::getVectorDifferenceAbsMax( const tnlVector< double, tnlCuda, long int >& v1, const tnlVector< double, tnlCuda, long int >& v2 ); -#ifdef INSTANTIATE_LONG_DOUBLE -template long double tnlVectorOperations< tnlCuda >::getVectorDifferenceAbsMax( const tnlVector< long double, tnlCuda, long int >& v1, const tnlVector< long double, tnlCuda, long int >& v2 ); -#endif -#endif - -/**** - * Difference abs min - */ -template int tnlVectorOperations< tnlCuda >::getVectorDifferenceAbsMin( const tnlVector< int, tnlCuda, int >& v1, const tnlVector< int, tnlCuda, int >& v2 ); -template long int tnlVectorOperations< tnlCuda >::getVectorDifferenceAbsMin( const tnlVector< long int, tnlCuda, int >& v1, const tnlVector< long int, tnlCuda, int >& v2 ); -#ifdef INSTANTIATE_FLOAT -template float tnlVectorOperations< tnlCuda >::getVectorDifferenceAbsMin( const tnlVector< float, tnlCuda, int >& v1, const tnlVector< float, tnlCuda, int >& v2); -#endif -template double tnlVectorOperations< tnlCuda >::getVectorDifferenceAbsMin( const tnlVector< double, tnlCuda, int >& v1, const tnlVector< double, tnlCuda, int >& v2 ); -#ifdef INSTANTIATE_LONG_DOUBLE -template long double tnlVectorOperations< tnlCuda >::getVectorDifferenceAbsMin( const tnlVector< long double, tnlCuda, int >& v1, const tnlVector< long double, tnlCuda, int >& v2 ); -#endif - -#ifdef INSTANTIATE_LONG_INT -template int tnlVectorOperations< tnlCuda >::getVectorDifferenceAbsMin( const tnlVector< int, tnlCuda, long int >& v1, const tnlVector< int, tnlCuda, long int >& v2 ); -template long int tnlVectorOperations< tnlCuda >::getVectorDifferenceAbsMin( const tnlVector< long int, tnlCuda, long int >& v1, const tnlVector< long int, tnlCuda, long int >& v2 ); -#ifdef INSTANTIATE_FLOAT -template float tnlVectorOperations< tnlCuda >::getVectorDifferenceAbsMin( const tnlVector< float, tnlCuda, long int >& v1, const tnlVector< float, tnlCuda, long int >& v2 ); -#endif -template double tnlVectorOperations< tnlCuda >::getVectorDifferenceAbsMin( const tnlVector< double, tnlCuda, long int >& v1, const tnlVector< double, tnlCuda, long int >& v2 ); -#ifdef INSTANTIATE_LONG_DOUBLE -template long double tnlVectorOperations< tnlCuda >::getVectorDifferenceAbsMin( const tnlVector< long double, tnlCuda, long int >& v1, const tnlVector< long double, tnlCuda, long int >& v2 ); -#endif -#endif #endif diff --git a/src/core/vectors/tnlVectorOperationsHost_impl.h b/src/core/vectors/tnlVectorOperationsHost_impl.h index 29d8485eb08c20501b6cefe1c49bb3e055fb091a..c508ff9204af39797a2e98fcec328d3b022f791a 100644 --- a/src/core/vectors/tnlVectorOperationsHost_impl.h +++ b/src/core/vectors/tnlVectorOperationsHost_impl.h @@ -42,8 +42,7 @@ typename Vector::RealType tnlVectorOperations< tnlHost >::getVectorMax( const Ve { typedef typename Vector :: RealType Real; typedef typename Vector :: IndexType Index; - tnlAssert( v. getSize() > 0, - cerr << "Vector name is " << v. getName() ); + tnlAssert( v. getSize() > 0, ); Real result = v. getElement( 0 ); const Index n = v. getSize(); for( Index i = 1; i < n; i ++ ) @@ -56,8 +55,7 @@ typename Vector :: RealType tnlVectorOperations< tnlHost > :: getVectorMin( cons { typedef typename Vector :: RealType Real; typedef typename Vector :: IndexType Index; - tnlAssert( v. getSize() > 0, - cerr << "Vector name is " << v. getName() ); + tnlAssert( v. getSize() > 0, ); Real result = v. getElement( 0 ); const Index n = v. getSize(); for( Index i = 1; i < n; i ++ ) @@ -70,8 +68,7 @@ typename Vector :: RealType tnlVectorOperations< tnlHost > :: getVectorAbsMax( c { typedef typename Vector :: RealType Real; typedef typename Vector :: IndexType Index; - tnlAssert( v. getSize() > 0, - cerr << "Vector name is " << v. getName() ); + tnlAssert( v. getSize() > 0, ); Real result = fabs( v. getElement( 0 ) ); const Index n = v. getSize(); for( Index i = 1; i < n; i ++ ) @@ -85,8 +82,7 @@ typename Vector :: RealType tnlVectorOperations< tnlHost > :: getVectorAbsMin( c { typedef typename Vector :: RealType Real; typedef typename Vector :: IndexType Index; - tnlAssert( v. getSize() > 0, - cerr << "Vector name is " << v. getName() ); + tnlAssert( v. getSize() > 0, ); Real result = fabs( v. getElement( 0 ) ); const Index n = v. getSize(); for( Index i = 1; i < n; i ++ ) @@ -94,41 +90,69 @@ typename Vector :: RealType tnlVectorOperations< tnlHost > :: getVectorAbsMin( c return result; } +template< typename Vector > +typename Vector::RealType +tnlVectorOperations< tnlHost >:: +getVectorL1Norm( const Vector& v ) +{ + typedef typename Vector :: RealType Real; + typedef typename Vector :: IndexType Index; + tnlAssert( v. getSize() > 0, ); + + Real result( 0.0 ); + const Index n = v. getSize(); +#ifdef HAVE_OPENMP +#pragma omp parallel for reduction(+:result) if( n > OpenMPVectorOperationsThreshold ) // TODO: check this threshold +#endif + for( Index i = 0; i < n; i ++ ) + result += fabs( v[ i ] ); + return result; +} + +template< typename Vector > +typename Vector::RealType +tnlVectorOperations< tnlHost >:: +getVectorL2Norm( const Vector& v ) +{ + typedef typename Vector :: RealType Real; + typedef typename Vector :: IndexType Index; + tnlAssert( v. getSize() > 0, ); + Real result( 0.0 ); + const Index n = v. getSize(); +#ifdef HAVE_OPENMP +#pragma omp parallel for reduction(+:result) if( n > OpenMPVectorOperationsThreshold ) // TODO: check this threshold +#endif + for( Index i = 0; i < n; i ++ ) + { + const Real& aux = v[ i ]; + result += aux * aux; + } + return sqrt( result ); +} template< typename Vector > -typename Vector :: RealType tnlVectorOperations< tnlHost > :: getVectorLpNorm( const Vector& v, - const typename Vector :: RealType& p ) +typename Vector::RealType +tnlVectorOperations< tnlHost >:: +getVectorLpNorm( const Vector& v, + const typename Vector :: RealType& p ) { typedef typename Vector :: RealType Real; typedef typename Vector :: IndexType Index; - tnlAssert( v. getSize() > 0, - cerr << "Vector name is " << v. getName() ); + tnlAssert( v. getSize() > 0, ); tnlAssert( p > 0.0, cerr << " p = " << p ); if( p == 1.0 ) - { - Real result = fabs( v. getElement( 0 ) ); - const Index n = v. getSize(); - for( Index i = 1; i < n; i ++ ) - result += fabs( v. getElement( i ) ); - return result; - } + return getVectorL1Norm( v ); if( p == 2.0 ) - { - Real result = v. getElement( 0 ); - result *= result; - const Index n = v. getSize(); - for( Index i = 1; i < n; i ++ ) - { - const Real aux = v. getElement( i ); - result += aux * aux; - } - return sqrt( result ); - } - Real result = pow( fabs( v. getElement( 0 ) ), p ); + return getVectorL2Norm( v ); + + Real result( 0.0 ); const Index n = v. getSize(); - for( Index i = 1; i < n; i ++ ) - result += pow( fabs( v. getElement( i ) ), p ); +#ifdef HAVE_OPENMP +#pragma omp parallel for reduction(+:result) if( n > OpenMPVectorOperationsThreshold ) // TODO: check this threshold +#endif + for( Index i = 0; i < n; i ++ ) + result += pow( fabs( v[ i ] ), p ); return pow( result, 1.0 / p ); } @@ -137,13 +161,15 @@ typename Vector :: RealType tnlVectorOperations< tnlHost > :: getVectorSum( cons { typedef typename Vector :: RealType Real; typedef typename Vector :: IndexType Index; - tnlAssert( v. getSize() > 0, - cerr << "Vector name is " << v. getName() ); + tnlAssert( v. getSize() > 0, ); - Real result = v. getElement( 0 ); + Real result( 0.0 ); const Index n = v. getSize(); - for( Index i = 1; i < n; i ++ ) - result += v. getElement( i ); +#ifdef HAVE_OPENMP +#pragma omp parallel for reduction(+:result) if( n > OpenMPVectorOperationsThreshold ) // TODO: check this threshold +#endif + for( Index i = 0; i < n; i ++ ) + result += v[ i ]; return result; } @@ -153,10 +179,8 @@ typename Vector1 :: RealType tnlVectorOperations< tnlHost > :: getVectorDifferen { typedef typename Vector1 :: RealType Real; typedef typename Vector1 :: IndexType Index; - tnlAssert( v1. getSize() > 0, - cerr << "Vector name is " << v1. getName() ); - tnlAssert( v1. getSize() == v2. getSize(), - cerr << "Vector names are " << v1. getName() << " and " << v2. getName() ); + tnlAssert( v1. getSize() > 0, ); + tnlAssert( v1. getSize() == v2. getSize(), ); Real result = v1. getElement( 0 ) - v2. getElement( 0 ); const Index n = v1. getSize(); for( Index i = 1; i < n; i ++ ) @@ -171,10 +195,8 @@ typename Vector1 :: RealType tnlVectorOperations< tnlHost > :: getVectorDifferen typedef typename Vector1 :: RealType Real; typedef typename Vector1 :: IndexType Index; - tnlAssert( v1. getSize() > 0, - cerr << "Vector name is " << v1. getName() ); - tnlAssert( v1. getSize() == v2. getSize(), - cerr << "Vector names are " << v1. getName() << " and " << v2. getName() ); + tnlAssert( v1. getSize() > 0, ); + tnlAssert( v1. getSize() == v2. getSize(), ); Real result = v1. getElement( 0 ) - v2. getElement( 0 ); const Index n = v1. getSize(); @@ -190,10 +212,8 @@ typename Vector1 :: RealType tnlVectorOperations< tnlHost > :: getVectorDifferen typedef typename Vector1 :: RealType Real; typedef typename Vector1 :: IndexType Index; - tnlAssert( v1. getSize() > 0, - cerr << "Vector name is " << v1. getName() ); - tnlAssert( v1. getSize() == v2. getSize(), - cerr << "Vector names are " << v1. getName() << " and " << v2. getName() ); + tnlAssert( v1. getSize() > 0, ); + tnlAssert( v1. getSize() == v2. getSize(), ); Real result = fabs( v1. getElement( 0 ) - v2. getElement( 0 ) ); const Index n = v1. getSize(); @@ -209,76 +229,110 @@ typename Vector1 :: RealType tnlVectorOperations< tnlHost > :: getVectorDifferen typedef typename Vector1 :: RealType Real; typedef typename Vector1 :: IndexType Index; - tnlAssert( v1. getSize() > 0, - cerr << "Vector name is " << v1. getName() ); - tnlAssert( v1. getSize() == v2. getSize(), - cerr << "Vector names are " << v1. getName() << " and " << v2. getName() ); + tnlAssert( v1. getSize() > 0, ); + tnlAssert( v1. getSize() == v2. getSize(), ); - Real result = fabs( v1. getElement( 0 ) - v2. getElement( 0 ) ); + Real result = fabs( v1[ 0 ] - v2[ 0 ] ); const Index n = v1. getSize(); for( Index i = 1; i < n; i ++ ) - result = Min( result, ( Real ) fabs( v1. getElement( i ) - v2. getElement( i ) ) ); + result = Min( result, ( Real ) fabs( v1[ i ] - v2[ i ] ) ); + return result; +} + +template< typename Vector1, typename Vector2 > +typename Vector1::RealType +tnlVectorOperations< tnlHost >:: +getVectorDifferenceL1Norm( const Vector1& v1, + const Vector2& v2 ) +{ + typedef typename Vector1 :: RealType Real; + typedef typename Vector1 :: IndexType Index; + + tnlAssert( v1. getSize() > 0, ); + tnlAssert( v1. getSize() == v2. getSize(), ); + + Real result( 0.0 ); + const Index n = v1. getSize(); +#ifdef HAVE_OPENMP +#pragma omp parallel for reduction(+:result) if( n > OpenMPVectorOperationsThreshold ) // TODO: check this threshold +#endif + for( Index i = 0; i < n; i ++ ) + result += fabs( v1[ i ] - v2[ i ] ); return result; } +template< typename Vector1, typename Vector2 > +typename Vector1::RealType +tnlVectorOperations< tnlHost >:: +getVectorDifferenceL2Norm( const Vector1& v1, + const Vector2& v2 ) +{ + typedef typename Vector1 :: RealType Real; + typedef typename Vector1 :: IndexType Index; + + tnlAssert( v1. getSize() > 0, ); + tnlAssert( v1. getSize() == v2. getSize(), ); + + Real result( 0.0 ); + const Index n = v1. getSize(); +#ifdef HAVE_OPENMP +#pragma omp parallel for reduction(+:result) if( n > OpenMPVectorOperationsThreshold ) // TODO: check this threshold +#endif + for( Index i = 0; i < n; i ++ ) + { + Real aux = fabs( v1[ i ] - v2[ i ] ); + result += aux * aux; + } + return sqrt( result ); +} + template< typename Vector1, typename Vector2 > -typename Vector1 :: RealType tnlVectorOperations< tnlHost > :: getVectorDifferenceLpNorm( const Vector1& v1, - const Vector2& v2, - const typename Vector1 :: RealType& p ) +typename Vector1::RealType +tnlVectorOperations< tnlHost >:: +getVectorDifferenceLpNorm( const Vector1& v1, + const Vector2& v2, + const typename Vector1::RealType& p ) { typedef typename Vector1 :: RealType Real; typedef typename Vector1 :: IndexType Index; tnlAssert( p > 0.0, cerr << " p = " << p ); - tnlAssert( v1. getSize() > 0, - cerr << "Vector name is " << v1. getName() ); - tnlAssert( v1. getSize() == v2. getSize(), - cerr << "Vector names are " << v1. getName() << " and " << v2. getName() ); + tnlAssert( v1. getSize() > 0, ); + tnlAssert( v1. getSize() == v2. getSize(), ); if( p == 1.0 ) - { - Real result = fabs( v1. getElement( 0 ) - v2. getElement( 0 ) ); - const Index n = v1. getSize(); - for( Index i = 1; i < n; i ++ ) - result += fabs( v1. getElement( i ) - v2. getElement( i ) ); - return result; - } + return getVectorDifferenceL1Norm( v1, v2 ); if( p == 2.0 ) - { - Real result = fabs( v1. getElement( 0 ) - v2. getElement( 0 ) ); - result *= result; - const Index n = v1. getSize(); - for( Index i = 1; i < n; i ++ ) - { - Real aux = fabs( v1. getElement( i ) - v2. getElement( i ) ); - result += aux * aux; - } - return sqrt( result ); - } - Real result = pow( fabs( v1. getElement( 0 ) - v2. getElement( 0 ) ), p ); + return getVectorDifferenceL2Norm( v1, v2 ); + + Real result( 0.0 ); const Index n = v1. getSize(); - for( Index i = 1; i < n; i ++ ) +#ifdef HAVE_OPENMP +#pragma omp parallel for reduction(+:result) if( n > OpenMPVectorOperationsThreshold ) // TODO: check this threshold +#endif + for( Index i = 0; i < n; i ++ ) result += pow( fabs( v1. getElement( i ) - v2. getElement( i ) ), p ); return pow( result, 1.0 / p ); } template< typename Vector1, typename Vector2 > -typename Vector1 :: RealType tnlVectorOperations< tnlHost > :: getVectorDifferenceSum( const Vector1& v1, - const Vector2& v2 ) +typename Vector1::RealType tnlVectorOperations< tnlHost > :: getVectorDifferenceSum( const Vector1& v1, + const Vector2& v2 ) { typedef typename Vector1 :: RealType Real; typedef typename Vector1 :: IndexType Index; - tnlAssert( v1. getSize() > 0, - cerr << "Vector name is " << v1. getName() ); - tnlAssert( v1. getSize() == v2. getSize(), - cerr << "Vector names are " << v1. getName() << " and " << v2. getName() ); + tnlAssert( v1. getSize() > 0, ); + tnlAssert( v1. getSize() == v2. getSize(), ); - Real result = v1. getElement( 0 ) - v2. getElement( 0 ); + Real result( 0.0 ); const Index n = v1. getSize(); - for( Index i = 1; i < n; i ++ ) +#ifdef HAVE_OPENMP +#pragma omp parallel for reduction(+:result) if( n > OpenMPVectorOperationsThreshold ) // TODO: check this threshold +#endif + for( Index i = 0; i < n; i ++ ) result += v1. getElement( i ) - v2. getElement( i ); return result; } @@ -291,10 +345,12 @@ void tnlVectorOperations< tnlHost > :: vectorScalarMultiplication( Vector& v, typedef typename Vector :: RealType Real; typedef typename Vector :: IndexType Index; - tnlAssert( v. getSize() > 0, - cerr << "Vector name is " << v. getName() ); + tnlAssert( v. getSize() > 0, ); const Index n = v. getSize(); +#ifdef HAVE_OPENMP +#pragma omp parallel for if( n > OpenMPVectorOperationsThreshold ) // TODO: check this threshold +#endif for( Index i = 0; i < n; i ++ ) v[ i ] *= alpha; } @@ -307,10 +363,8 @@ typename Vector1 :: RealType tnlVectorOperations< tnlHost > :: getScalarProduct( typedef typename Vector1 :: RealType Real; typedef typename Vector1 :: IndexType Index; - tnlAssert( v1. getSize() > 0, - cerr << "Vector name is " << v1. getName() ); - tnlAssert( v1. getSize() == v2. getSize(), - cerr << "Vector names are " << v1. getName() << " and " << v2. getName() ); + tnlAssert( v1. getSize() > 0, ); + tnlAssert( v1. getSize() == v2. getSize(), ); Real result = 0; const Index n = v1. getSize(); @@ -331,16 +385,20 @@ void tnlVectorOperations< tnlHost > :: addVector( Vector1& y, typedef typename Vector1 :: RealType Real; typedef typename Vector1 :: IndexType Index; - tnlAssert( x. getSize() > 0, - cerr << "Vector name is " << x. getName() ); - tnlAssert( x. getSize() == y. getSize(), - cerr << "Vector names are " << x. getName() << " and " << y. getName() ); + tnlAssert( x. getSize() > 0, ); + tnlAssert( x. getSize() == y. getSize(), ); const Index n = y. getSize(); if( thisMultiplicator == 1.0 ) +#ifdef HAVE_OPENMP +#pragma omp parallel for if( n > OpenMPVectorOperationsThreshold ) // TODO: check this threshold +#endif for( Index i = 0; i < n; i ++ ) y[ i ] += alpha * x[ i ]; else +#ifdef HAVE_OPENMP +#pragma omp parallel for if( n > OpenMPVectorOperationsThreshold ) // TODO: check this threshold +#endif for( Index i = 0; i < n; i ++ ) y[ i ] = thisMultiplicator * y[ i ] + alpha * x[ i ]; } @@ -360,19 +418,21 @@ addVectors( Vector1& v, typedef typename Vector1 :: RealType Real; typedef typename Vector1 :: IndexType Index; - tnlAssert( v.getSize() > 0, - cerr << "Vector name is " << v.getName() ); - tnlAssert( v.getSize() == v1.getSize(), - cerr << "Vector names are " << v.getName() << " and " << v1.getName() ); - tnlAssert( v.getSize() == v2.getSize(), - cerr << "Vector names are " << v.getName() << " and " << v2.getName() ); - + tnlAssert( v.getSize() > 0, ); + tnlAssert( v.getSize() == v1.getSize(), ); + tnlAssert( v.getSize() == v2.getSize(), ); const Index n = v.getSize(); if( thisMultiplicator == 1.0 ) +#ifdef HAVE_OPENMP +#pragma omp parallel for if( n > OpenMPVectorOperationsThreshold ) // TODO: check this threshold +#endif for( Index i = 0; i < n; i ++ ) v[ i ] += multiplicator1 * v1[ i ] + multiplicator2 * v2[ i ]; else +#ifdef HAVE_OPENMP +#pragma omp parallel for if( n > OpenMPVectorOperationsThreshold ) // TODO: check this threshold +#endif for( Index i = 0; i < n; i ++ ) v[ i ] = thisMultiplicator * v[ i ] * multiplicator1 * v1[ i ] + multiplicator2 * v2[ i ]; } diff --git a/src/core/vectors/tnlVector_impl.h b/src/core/vectors/tnlVector_impl.h index c0d08a6ae2baea5e04aabfb27479839707287439..ff4446623264e91ff521e4a2a1bd4b84780e20f7 100644 --- a/src/core/vectors/tnlVector_impl.h +++ b/src/core/vectors/tnlVector_impl.h @@ -31,17 +31,8 @@ tnlVector< Real, Device, Index > :: tnlVector() template< typename Real, typename Device, typename Index > -tnlVector< Real, Device, Index > :: tnlVector( const tnlString& name ) +tnlVector< Real, Device, Index > :: tnlVector( const Index size ) { - this -> setName( name ); -} - -template< typename Real, - typename Device, - typename Index > -tnlVector< Real, Device, Index > :: tnlVector( const tnlString& name, const Index size ) -{ - this -> setName( name ); this -> setSize( size ); } @@ -136,7 +127,7 @@ template< typename Real, template< typename Vector > bool tnlVector< Real, Device, Index > :: operator != ( const Vector& vector ) const { - return tnlArray< Real, Device, Index > :: operator == ( vector ); + return tnlArray< Real, Device, Index > :: operator != ( vector ); } template< typename Real, diff --git a/src/functors/CMakeLists.txt b/src/functors/CMakeLists.txt index 8b8dae1c5b86e9a3753a7e0003d1c657a1f3ce30..40cfe1e8adfade5df233663ba4817361824b130d 100755 --- a/src/functors/CMakeLists.txt +++ b/src/functors/CMakeLists.txt @@ -12,7 +12,7 @@ SET( headers tnlFunctionDiscretizer.h tnlSinWaveFunction.h tnlSinWaveFunction_impl.h tnlTestFunction.h - tnlFunctionType.h + tnlFunction.h tnlTestFunction_impl.h ) SET( CURRENT_DIR ${CMAKE_SOURCE_DIR}/src/functors ) diff --git a/src/functors/tnlConstantFunction.h b/src/functors/tnlConstantFunction.h index df85597ef742b7d5eb9cc9877b99ecb3d6429ba0..c382347a01e66f319b8ef1f0280434abfb9aceff 100644 --- a/src/functors/tnlConstantFunction.h +++ b/src/functors/tnlConstantFunction.h @@ -20,11 +20,11 @@ #include <iostream> #include <core/vectors/tnlStaticVector.h> -#include <functors/tnlFunctionType.h> +#include <functors/tnlFunction.h> template< int FunctionDimensions, typename Real = double > -class tnlConstantFunction +class tnlConstantFunction : public tnlFunction< tnlAnalyticFunction> { public: @@ -80,15 +80,6 @@ std::ostream& operator << ( std::ostream& str, const tnlConstantFunction< Functi return str; } -template< int FunctionDimensions, - typename Real > -class tnlFunctionType< tnlConstantFunction< FunctionDimensions, Real > > -{ - public: - - enum { Type = tnlAnalyticFunction }; -}; - #include <functors/tnlConstantFunction_impl.h> #endif /* TNLCONSTANTFUNCTION_H_ */ diff --git a/src/functors/tnlExpBumpFunction.h b/src/functors/tnlExpBumpFunction.h index 1159f1849f3bd4bb911a321f8843c70312fe3efa..9774bfcf5727a72753817d73b78b73c274f77318 100644 --- a/src/functors/tnlExpBumpFunction.h +++ b/src/functors/tnlExpBumpFunction.h @@ -20,13 +20,13 @@ #include <config/tnlParameterContainer.h> #include <core/vectors/tnlStaticVector.h> -#include <functors/tnlFunctionType.h> +#include <functors/tnlFunction.h> template< typename Real > -class tnlExpBumpFunctionBase +class tnlExpBumpFunctionBase : public tnlFunction< tnlAnalyticFunction > { public: - + typedef Real RealType; bool setup( const tnlParameterContainer& parameters, @@ -143,16 +143,6 @@ ostream& operator << ( ostream& str, const tnlExpBumpFunction< Dimensions, Real return str; } -template< int FunctionDimensions, - typename Real > -class tnlFunctionType< tnlExpBumpFunction< FunctionDimensions, Real > > -{ - public: - - enum { Type = tnlAnalyticFunction }; -}; - - #include <functors/tnlExpBumpFunction_impl.h> diff --git a/src/functors/tnlFunction.h b/src/functors/tnlFunction.h new file mode 100644 index 0000000000000000000000000000000000000000..38b6412fc7e450d0681d7381f6e84e99c872081a --- /dev/null +++ b/src/functors/tnlFunction.h @@ -0,0 +1,36 @@ +/*************************************************************************** + tnlFunction.h - description + ------------------- + begin : Nov 8, 2015 + copyright : (C) 2015 by 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 TNLFUNCTION_H +#define TNLFUNCTION_H + +enum tnlFunctionType { tnlGeneralFunction, + tnlDiscreteFunction, + tnlAnalyticFunction }; + +template< tnlFunctionType FunctionType > +class tnlFunction +{ + public: + + //static constexpr tnlFunctionType getFunctionType() { return FunctionType; } + enum { functionType = FunctionType }; +}; + +#endif /* TNLFUNCTION_H */ + diff --git a/src/functors/tnlFunctorAdapter.h b/src/functors/tnlFunctorAdapter.h index 3d6a96df58f61a84357cb6927487881816b5ef3f..4369754f45c36f4f25ed2e111247741931f57c83 100644 --- a/src/functors/tnlFunctorAdapter.h +++ b/src/functors/tnlFunctorAdapter.h @@ -19,11 +19,11 @@ #define tnlFunctorAdapter_H_ #include <functors/tnlConstantFunction.h> -#include <functors/tnlFunctionType.h> +#include <functors/tnlFunction.h> template< typename Mesh, typename Function, - int FunctionType = tnlFunctionType< Function >::Type > + int FunctionType = Function::functionType > class tnlFunctorAdapter { }; diff --git a/src/functors/tnlSinBumpsFunction.h b/src/functors/tnlSinBumpsFunction.h index 2b3183f8c252605c7501c9e88312d6a207a860d5..984c018b960a9cab10f5994434f985951e5630bd 100644 --- a/src/functors/tnlSinBumpsFunction.h +++ b/src/functors/tnlSinBumpsFunction.h @@ -20,13 +20,13 @@ #include <config/tnlParameterContainer.h> #include <core/vectors/tnlStaticVector.h> -#include <functors/tnlFunctionType.h> +#include <functors/tnlFunction.h> template< typename Vertex > -class tnlSinBumpsFunctionBase +class tnlSinBumpsFunctionBase : public tnlFunction< tnlAnalyticFunction > { public: - + typedef Vertex VertexType; typedef typename Vertex::RealType RealType; enum { Dimensions = VertexType::size }; @@ -158,15 +158,6 @@ ostream& operator << ( ostream& str, const tnlSinBumpsFunction< Dimensions, Real return str; } -template< int FunctionDimensions, - typename Real > -class tnlFunctionType< tnlSinBumpsFunction< FunctionDimensions, Real > > -{ - public: - - enum { Type = tnlAnalyticFunction }; -}; - #include <functors/tnlSinBumpsFunction_impl.h> diff --git a/src/functors/tnlSinWaveFunction.h b/src/functors/tnlSinWaveFunction.h index e6d066d80d73a3a7f67fc4495b5f01fe545e6ff6..3e3025c29bf5d89a93c03a2838f8747f00c2c2cb 100644 --- a/src/functors/tnlSinWaveFunction.h +++ b/src/functors/tnlSinWaveFunction.h @@ -20,13 +20,13 @@ #include <config/tnlParameterContainer.h> #include <core/vectors/tnlStaticVector.h> -#include <functors/tnlFunctionType.h> +#include <functors/tnlFunction.h> template< typename Real = double > -class tnlSinWaveFunctionBase +class tnlSinWaveFunctionBase : public tnlFunction< tnlAnalyticFunction > { public: - + tnlSinWaveFunctionBase(); bool setup( const tnlParameterContainer& parameters, @@ -141,15 +141,6 @@ ostream& operator << ( ostream& str, const tnlSinWaveFunction< Dimensions, Real return str; } -template< int FunctionDimensions, - typename Real > -class tnlFunctionType< tnlSinWaveFunction< FunctionDimensions, Real > > -{ - public: - - enum { Type = tnlAnalyticFunction }; -}; - #include <functors/tnlSinWaveFunction_impl.h> #endif /* TNLSINWAVEFUNCTION_H_ */ diff --git a/src/legacy/CMakeLists.txt b/src/legacy/CMakeLists.txt index e5716caa29486217a4d5d866609a145d3d74049d..d97b78740023dd147b62fba4d2fe2324aa8c27c4 100755 --- a/src/legacy/CMakeLists.txt +++ b/src/legacy/CMakeLists.txt @@ -1,6 +1,6 @@ ADD_SUBDIRECTORY( core ) ADD_SUBDIRECTORY( diff ) -ADD_SUBDIRECTORY( mesh ) +#ADD_SUBDIRECTORY( mesh ) ADD_SUBDIRECTORY( solvers ) SET( headers ) diff --git a/src/legacy/benchmarks/matrix-solvers-benchmark.h b/src/legacy/benchmarks/matrix-solvers-benchmark.h index 01bc0824bccef1b6bee22564a8e8c8bd75191b4a..69325136ee7a5805964bdb71ffafc6fdf47baa94 100644 --- a/src/legacy/benchmarks/matrix-solvers-benchmark.h +++ b/src/legacy/benchmarks/matrix-solvers-benchmark.h @@ -256,7 +256,6 @@ bool benchmarkMatrix( const tnlParameterContainer& parameters ) typedef tnlCSRMatrix< Real, tnlHost, Index > csrMatrixType; tnlString inputFile = parameters. getParameter< tnlString >( "input-file" ); csrMatrixType csrMatrix; - csrMatrix.setName( "matrix-solvers-benchmark:csrMatrix" ); if( ! csrMatrix. load( inputFile ) ) { cerr << "Unable to load file " << inputFile << endl; diff --git a/src/legacy/benchmarks/tnlSpmvBenchmarkBase_impl.h b/src/legacy/benchmarks/tnlSpmvBenchmarkBase_impl.h index 9066c57d7e5b8b76806346e5651a5232c384210f..dd51338e56a6ad4251de8c0a9c49060a90897ad4 100644 --- a/src/legacy/benchmarks/tnlSpmvBenchmarkBase_impl.h +++ b/src/legacy/benchmarks/tnlSpmvBenchmarkBase_impl.h @@ -36,7 +36,6 @@ tnlSpmvBenchmarkBase< Matrix >::tnlSpmvBenchmarkBase() benchmarkStatusColumnWidth( 12 ), infoColumnWidth( 20 ) { - matrix.setName( "spmvBenchmark::matrix" ); } template< typename Matrix > diff --git a/src/legacy/diff/tnlMPIMesh2D.h b/src/legacy/diff/tnlMPIMesh2D.h index 83c6bbfa4fbaea36a32ccbdd4c97484ef20d268d..367f8f43696c00f13560ebfd08dbd793c6ad3930 100644 --- a/src/legacy/diff/tnlMPIMesh2D.h +++ b/src/legacy/diff/tnlMPIMesh2D.h @@ -460,7 +460,6 @@ bool tnlMPIMesh< 2, Real, Device, Index > :: CreateMesh( const tnlGridOld< 2, Re ay = u. GetAy(); hx = u. GetHx(); hy = u. GetHy(); - name. setString( u. getName(). getString() ); } :: MPIBcast< double >( ax, 1, root, original_comm ); :: MPIBcast< double >( ay, 1, root, original_comm ); @@ -483,7 +482,6 @@ bool tnlMPIMesh< 2, Real, Device, Index > :: CreateMesh( const tnlGridOld< 2, Re hx, hy ); //cout << "Node " << MPIGetRank() << " mesh size " // << sub_u -> GetXSize() << "x" << sub_u -> GetYSize() << endl; - sub_u. setName( name. getString() ); MPI_Allreduce( &err, &all_err, 1, MPI_INT,MPI_SUM, mesh_comm ); if( all_err != 0 ) return false; #else diff --git a/src/legacy/diff/tnlMPIMesh3D.h b/src/legacy/diff/tnlMPIMesh3D.h index 9e28be84b038ec68006788b27e4050fadb84ad09..30e3a2c31d44af200491348275daec2f8644dd53 100644 --- a/src/legacy/diff/tnlMPIMesh3D.h +++ b/src/legacy/diff/tnlMPIMesh3D.h @@ -578,7 +578,6 @@ bool tnlMPIMesh< 3, Real, Device, Index > :: CreateMesh( const tnlGridOld< 3, Re hx = u. GetHx(); hy = u. GetHy(); hz = u. GetHz(); - name. setString( u. getName(). getString() ); } :: MPIBcast< double >( ax, 1, root, original_comm ); :: MPIBcast< double >( ay, 1, root, original_comm ); @@ -614,7 +613,6 @@ bool tnlMPIMesh< 3, Real, Device, Index > :: CreateMesh( const tnlGridOld< 3, Re << " rank " << MPIGetRank( original_comm ) << "." << endl; err = 1; } - sub_u. setName( name. getString() ); dbgMPIBarrier; dbgCout( "Subdomain is as: Ax = " << sub_u. GetAx() << " Ay = " << sub_u. GetAy() << diff --git a/src/legacy/matrices/tnlAdaptiveRgCSRMatrix.h b/src/legacy/matrices/tnlAdaptiveRgCSRMatrix.h index d5e02d7712d2c91409d2e0a07ebd8178db9602a0..0f9e338bbac4cdd203916165435b7d17a411a98d 100644 --- a/src/legacy/matrices/tnlAdaptiveRgCSRMatrix.h +++ b/src/legacy/matrices/tnlAdaptiveRgCSRMatrix.h @@ -926,13 +926,14 @@ void tnlAdaptiveRgCSRMatrix< Real, Device, Index > :: printOutGroup( ostream& st template< typename Real, typename Device, typename Index > void tnlAdaptiveRgCSRMatrix< Real, Device, Index > :: printOut( ostream& str, + const tnlString& name, const tnlString& format, const Index lines ) const { if( format == "" || format == "text" ) { str << "Structure of tnlAdaptiveRgCSRMatrix" << endl; - str << "Matrix name:" << this -> getName() << endl; + str << "Matrix name:" << name << endl; str << "Matrix size:" << this -> getSize() << endl; str << "Allocated elements:" << nonzeroElements. getSize() << endl; str << "Number of groups: " << numberOfGroups << endl; @@ -954,7 +955,7 @@ void tnlAdaptiveRgCSRMatrix< Real, Device, Index > :: printOut( ostream& str, if( format == "html" ) { str << "<h1>Structure of tnlAdaptiveRgCSRMatrix</h1>" << endl; - str << "<b>Matrix name:</b> " << this -> getName() << "<p>" << endl; + str << "<b>Matrix name:</b> " << name << "<p>" << endl; str << "<b>Matrix size:</b> " << this -> getSize() << "<p>" << endl; str << "<b>Allocated elements:</b> " << nonzeroElements. getSize() << "<p>" << endl; str << "<b>Number of groups:</b> " << this -> numberOfGroups << "<p>" << endl; diff --git a/src/legacy/matrices/tnlCSRMatrix.h b/src/legacy/matrices/tnlCSRMatrix.h index 79e531fd0452605b9a5b33f4ac0ca1490703a37a..b59f0e31397a5eda5f261c05575db22f84cf04f2 100644 --- a/src/legacy/matrices/tnlCSRMatrix.h +++ b/src/legacy/matrices/tnlCSRMatrix.h @@ -798,11 +798,12 @@ tnlCSRMatrix< Real, Device, Index >& tnlCSRMatrix< Real, Device, Index > :: oper template< typename Real, typename Device, typename Index > void tnlCSRMatrix< Real, Device, Index > :: printOut( ostream& str, + const tnlString& name, const tnlString& format, const Index lines ) const { str << "Structure of tnlCSRMatrix" << endl; - str << "Matrix name:" << this -> getName() << endl; + str << "Matrix name:" << name << endl; str << "Matrix size:" << this -> getSize() << endl; str << "Allocated elements:" << nonzero_elements. getSize() << endl; str << "Matrix rows:" << endl; diff --git a/src/legacy/matrices/tnlEllpackMatrix.h b/src/legacy/matrices/tnlEllpackMatrix.h index 16146ec3f27626954a1b39e2f68b0ff716670075..33b3c28919b370a704b9b43e772a2580905e504d 100644 --- a/src/legacy/matrices/tnlEllpackMatrix.h +++ b/src/legacy/matrices/tnlEllpackMatrix.h @@ -308,10 +308,11 @@ void tnlEllpackMatrix< Real, tnlHost, Index > :: vectorProduct( const tnlVector< }; template< typename Real, typename Index > -void tnlEllpackMatrix< Real, tnlHost, Index > :: printOut( ostream& str ) const +void tnlEllpackMatrix< Real, tnlHost, Index > :: printOut( ostream& str, + const tnlString& name ) const { str << "Structure of tnlEllpackMatrix" << endl; - str << "Matrix name:" << this -> getName() << endl; + str << "Matrix name:" << name << endl; str << "Matrix size:" << this -> getSize() << endl; str << "Allocated elements:" << ellpack_nonzero_elements. getSize() << endl; str << "Matrix row length:" << row_length << endl; @@ -328,6 +329,4 @@ void tnlEllpackMatrix< Real, tnlHost, Index > :: printOut( ostream& str ) const } } - - #endif /* TNLELLPACKMATRIX_H_ */ diff --git a/src/legacy/matrices/tnlFastCSRMatrix.h b/src/legacy/matrices/tnlFastCSRMatrix.h index b00df4b26605550ad2a9a8ca4468e0ca01fab0ab..ffd3c7dc179cfb5789b035aa598222ce719aa687 100644 --- a/src/legacy/matrices/tnlFastCSRMatrix.h +++ b/src/legacy/matrices/tnlFastCSRMatrix.h @@ -474,10 +474,11 @@ bool tnlFastCSRMatrix< Real, tnlHost, Index > :: Load( istream& file ) template< typename Real, typename Index > void tnlFastCSRMatrix< Real, tnlHost, Index > :: printOut( ostream& str, - const Index lines ) const + const tnlString& name, + const Index lines ) const { str << "Structure of tnlFastCSRMatrix" << endl; - str << "Matrix name:" << this -> getName() << endl; + str << "Matrix name:" << name << endl; str << "Matrix size:" << this -> getSize() << endl; str << "Allocated elements:" << nonzero_elements. getSize() << endl; str << "Matrix rows:" << endl; diff --git a/src/legacy/matrices/tnlFastRgCSRMatrix.h b/src/legacy/matrices/tnlFastRgCSRMatrix.h index b5003985bd45645aadd720f8219300d9f05d5812..b11e0b1fb2dc659df73b27f7ae94d52d2a7c33ac 100644 --- a/src/legacy/matrices/tnlFastRgCSRMatrix.h +++ b/src/legacy/matrices/tnlFastRgCSRMatrix.h @@ -610,10 +610,11 @@ void tnlFastRgCSRMatrix< Real, tnlHost, Index > :: vectorProduct( const tnlVecto template< typename Real, typename Index > void tnlFastRgCSRMatrix< Real, tnlHost, Index > :: printOut( ostream& str, - const Index lines ) const + const tnlString& name, + const Index lines ) const { str << "Structure of tnlFastRgCSRMatrix" << endl; - str << "Matrix name:" << this -> getName() << endl; + str << "Matrix name:" << name << endl; str << "Matrix size:" << this -> getSize() << endl; str << "Allocated elements:" << nonzero_elements. getSize() << endl; str << "Matrix blocks: " << block_offsets. getSize() << endl; diff --git a/src/legacy/matrices/tnlFastRgCSRMatrixCUDA.h b/src/legacy/matrices/tnlFastRgCSRMatrixCUDA.h index ba7ef95556c177f0077d860d1ed75a0f3bb4bea7..96f89a69fd2acdbbe9c6d0b0584ded7637358b16 100644 --- a/src/legacy/matrices/tnlFastRgCSRMatrixCUDA.h +++ b/src/legacy/matrices/tnlFastRgCSRMatrixCUDA.h @@ -350,10 +350,11 @@ void tnlFastRgCSRMatrix< Real, tnlCuda, Index > :: vectorProduct( const tnlVecto template< typename Real, typename Index > void tnlFastRgCSRMatrix< Real, tnlCuda, Index > :: printOut( ostream& str, - const int lines ) const + const tnlString& name, + const int lines ) const { str << "Structure of tnlFastRgCSRMatrix" << endl; - str << "Matrix name:" << this -> getName() << endl; + str << "Matrix name:" << name << endl; str << "Matrix size:" << this -> getSize() << endl; str << "Allocated elements:" << nonzero_elements. getSize() << endl; str << "Matrix blocks: " << block_offsets. getSize() << endl; diff --git a/src/legacy/matrices/tnlMatrix.h b/src/legacy/matrices/tnlMatrix.h index c8245cde094eefb3e17883215e9e740827553e5e..db31c122a3103ee73942da5040a99e6ad91bbec9 100644 --- a/src/legacy/matrices/tnlMatrix.h +++ b/src/legacy/matrices/tnlMatrix.h @@ -188,7 +188,7 @@ Index tnlMatrix< Real, Device, Index > :: getArtificialZeroElements() const template< typename Real, typename Device, typename Index > Index tnlMatrix< Real, Device, Index > :: getNonzeroElementsInRow( const Index& row ) const { - tnlAssert( false, cerr << "not implemented yet - matrix name is " << this -> getName() ); + tnlAssert( false, cerr << "not implemented yet." ); /* * TODO: this method should be abstract */ diff --git a/src/legacy/matrices/tnlRgCSRMatrix.h b/src/legacy/matrices/tnlRgCSRMatrix.h index df7216035e61d000b2a19c2c5312f6fc15cd7bfb..f6d3f98bcdebd7e59908687ec757dff026d19e79 100644 --- a/src/legacy/matrices/tnlRgCSRMatrix.h +++ b/src/legacy/matrices/tnlRgCSRMatrix.h @@ -498,10 +498,12 @@ bool tnlRgCSRMatrix< Real, Device, Index > :: copyFrom( const tnlCSRMatrix< Real template< typename Real, typename Device, typename Index > template< typename Device2 > -bool tnlRgCSRMatrix< Real, Device, Index > :: copyFrom( const tnlRgCSRMatrix< Real, Device2, Index >& rgCSRMatrix ) +bool +tnlRgCSRMatrix< Real, Device, Index >:: +copyFrom( const tnlRgCSRMatrix< Real, Device2, Index >& rgCSRMatrix ) { dbgFunctionName( "tnlRgCSRMatrix< Real, Device, Index >", "copyFrom" ); - tnlAssert( rgCSRMatrix. getSize() > 0, cerr << "Copying from matrix " << rgCSRMatrix. getName() << " with non-positiove size." ); + tnlAssert( rgCSRMatrix. getSize() > 0, cerr << "Copying from matrix with non-positiove size." ); this -> cudaBlockSize = rgCSRMatrix. cudaBlockSize; this -> groupSize = rgCSRMatrix. groupSize; @@ -797,13 +799,14 @@ void tnlRgCSRMatrix< Real, Device, Index > :: vectorProduct( const tnlVector< Re template< typename Real, typename Device, typename Index > void tnlRgCSRMatrix< Real, Device, Index > :: printOut( ostream& str, + const tnlString& name, const tnlString& format, const Index lines ) const { if( format == "" || format == "text" ) { str << "Structure of tnlRgCSRMatrix" << endl; - str << "Matrix name:" << this -> getName() << endl; + str << "Matrix name:" << name << endl; str << "Matrix size:" << this -> getSize() << endl; str << "Allocated elements:" << nonzeroElements. getSize() << endl; str << "Number of groups: " << groupOffsets. getSize() << endl; @@ -851,7 +854,7 @@ void tnlRgCSRMatrix< Real, Device, Index > :: printOut( ostream& str, if( format == "html" ) { str << "<h1>Structure of tnlRgCSRMatrix</h1>" << endl; - str << "<b>Matrix name:</b> " << this -> getName() << "<p>" << endl; + str << "<b>Matrix name:</b> " << name << "<p>" << endl; str << "<b>Matrix size:</b> " << this -> getSize() << "<p>" << endl; str << "<b>Allocated elements:</b> " << nonzeroElements. getSize() << "<p>" << endl; str << "<b>Number of groups:</b> " << this -> numberOfGroups << "<p>" << endl; diff --git a/src/legacy/mesh/CMakeLists.txt b/src/legacy/mesh/CMakeLists.txt deleted file mode 100755 index bafbc607fa6e450304d74f49bb82a24d70449904..0000000000000000000000000000000000000000 --- a/src/legacy/mesh/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -ADD_SUBDIRECTORY( implementation ) - -SET( headers tnlDistributedGrid.h - tnlGridOld.h ) - -set( tnl_legacy_mesh_SOURCES - ${tnl_legacy_mesh_implementation_SOURCES} - PARENT_SCOPE ) - -INSTALL( FILES ${headers} DESTINATION include/tnl-${tnlVersion}/legacy/mesh ) \ No newline at end of file diff --git a/src/legacy/mesh/implementation/CMakeLists.txt b/src/legacy/mesh/implementation/CMakeLists.txt deleted file mode 100644 index 13fd6057a11db6f1ca1cc9896619f9b68842dcb7..0000000000000000000000000000000000000000 --- a/src/legacy/mesh/implementation/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -SET( headers tnlGrid1D_impl.h - tnlGrid2D_impl.h - tnlGrid3D_impl.h ) - -SET( CURRENT_DIR ${CMAKE_SOURCE_DIR}/src/legacy/mesh/implementation ) -set( tnl_legacy_mesh_implementation_SOURCES - ${CURRENT_DIR}/tnlGridOld_impl.cpp - PARENT_SCOPE ) - -INSTALL( FILES ${headers} DESTINATION include/tnl-${tnlVersion}/legacy/mesh/implementation ) \ No newline at end of file diff --git a/src/legacy/mesh/implementation/tnlGrid1D_impl.h b/src/legacy/mesh/implementation/tnlGrid1D_impl.h deleted file mode 100644 index e61c4122e86ad9ff509e19cc766f28e15943ec17..0000000000000000000000000000000000000000 --- a/src/legacy/mesh/implementation/tnlGrid1D_impl.h +++ /dev/null @@ -1,751 +0,0 @@ -/*************************************************************************** - tnlGridOld1D_impl.h - description - ------------------- - begin : Nov 22, 2012 - copyright : (C) 2012 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 tnlGridOld1D_IMPL_H_ -#define tnlGridOld1D_IMPL_H_ - -#ifdef HAVE_CUDA -template< int Dimensions, typename Real, typename Index > -__global__ void setConstantDirichletBC( const Index xSize, - const Real bc, - Real* u ); - -template< int Dimensions, typename Real, typename Index > -__global__ void setDirichletBC( const Index xSize, - const Real* bc, - Real* u ); - -template< int Dimensions, typename Real, typename Index > -__global__ void setConstantNeumannBC( const Index xSize, - const Real hx, - const Real bc, - Real* u ); - -template< int Dimensions, typename Real, typename Index > -__global__ void setNeumannBC( const Index xSize, - const Real hx, - const Real* bc, - Real* u ); -#endif - -template< typename Real, typename Device, typename Index > -tnlGridOld< 1, Real, Device, Index > :: tnlGridOld() -{ -} - - -template< typename Real, typename Device, typename Index > -tnlGridOld< 1, Real, Device, Index > :: tnlGridOld( const tnlString& name ) -{ - this -> setName( name ); -} - -template< typename Real, typename Device, typename Index > -tnlGridOld< 1, Real, Device, Index > :: tnlGridOld( const tnlString& name, - const tnlGridOld< 1, Real, tnlHost, Index >& grid ) -{ - this -> setName( name ); - this -> setLike( grid ); -} - -template< typename Real, typename Device, typename Index > -tnlGridOld< 1, Real, Device, Index > :: tnlGridOld( const tnlString& name, - const tnlGridOld< 1, Real, tnlCuda, Index >& grid ) -{ - this -> setName( name ); - this -> setLike( grid ); -} - -template< typename Real, typename Device, typename Index > -const tnlStaticVector< 1, Index >& tnlGridOld< 1, Real, Device, Index > :: getDimensions() const -{ - return tnlMultiVector< 1, Real, Device, Index > :: getDimensions(); -} - -template< typename Real, typename Device, typename Index > -bool tnlGridOld< 1, Real, Device, Index > :: setDimensions( const tnlStaticVector< 1, Index >& dimensions ) -{ - if( ! tnlMultiVector< 1, Real, Device, Index > :: setDimensions( dimensions ) ) - return false; - spaceSteps[ 0 ] = ( domainUpperCorner[ 0 ] - domainLowerCorner[ 0 ] ) / ( Real ) ( this -> getDimensions()[ 0 ] - 1 ); - return true; -} - -template< typename Real, typename Device, typename Index > -bool tnlGridOld< 1, Real, Device, Index > :: setDomain( const tnlStaticVector< 1, Real >& origin, - const tnlStaticVector< 1, Real >& proportions ) -{ - if( origin >= proportions ) - { - cerr << "Wrong parameters for the grid domain of " << this -> getName() << ". The low corner must by smaller than the high corner." << endl - << "origin = " << origin << endl << "proportions = " << proportions << endl; - return false; - } - domainLowerCorner = origin; - domainUpperCorner = proportions; - spaceSteps[ 0 ] = ( domainUpperCorner[ 0 ] - domainLowerCorner[ 0 ] ) / ( Real ) ( this -> getDimensions()[ 0 ] - 1 ); - return true; -} - -template< typename Real, typename Device, typename Index > - template< typename Grid > -bool tnlGridOld< 1, Real, Device, Index > :: setLike( const Grid& v ) -{ - return tnlMultiVector< 1, Real, Device, Index > :: setDimensions( v. getDimensions() ) && - this -> setDomain( v. getDomainLowerCorner(), v. getDomainUpperCorner() ); -} - -template< typename Real, typename Device, typename Index > -const tnlStaticVector< 1, Real >& tnlGridOld< 1, Real, Device, Index > :: getDomainLowerCorner() const -{ - return this -> domainLowerCorner; -} - -template< typename Real, typename Device, typename Index > -const tnlStaticVector< 1, Real >& tnlGridOld< 1, Real, Device, Index > :: getDomainUpperCorner() const -{ - return this -> domainUpperCorner; -} - -template< typename Real, typename Device, typename Index > -const tnlStaticVector< 1, Real >& tnlGridOld< 1, Real, Device, Index > :: getSpaceSteps() const -{ - return spaceSteps; -} - -template< typename Real, typename Device, typename Index > -tnlString tnlGridOld< 1, Real, Device, Index > :: getType() const -{ - return tnlString( "tnlGridOld< ") + - tnlString( "1" ) + - tnlString( ", " ) + - tnlString( ::getType< Real >() ) + - tnlString( ", " ) + - Device :: getDeviceType() + - tnlString( ", " ) + - tnlString( ::getType< Index >() ) + - tnlString( " >" ); -} - -template< typename Real, typename Device, typename Index > -bool tnlGridOld< 1, Real, Device, Index > :: operator == ( const tnlGridOld< 1, Real, Device, Index >& grid ) const -{ - tnlAssert( this -> getDomainLowerCorner() == grid. getDomainLowerCorner() && - this -> getDomainUpperCorner() == grid. getDomainUpperCorner(), - cerr << "You are attempting to compare two grids with different domains." << endl - << "First grid name is " << this -> getName() - << " domain is ( " << this -> getDomainLowerCorner() << " )- (" - << this -> getDomainUpperCorner() << ")" << endl - << "Second grid is " << grid. getName() - << " domain is ( " << grid. getDomainLowerCorner() << " )- (" - << grid. getDomainUpperCorner() << ")" << endl; ); - return tnlMultiVector< 1, Real, Device, Index > :: operator == ( grid ); -} - -template< typename Real, typename Device, typename Index > -bool tnlGridOld< 1, Real, Device, Index > :: operator != ( const tnlGridOld< 1, Real, Device, Index >& grid ) const -{ - return ! ( (* this ) == grid ); -} - -template< typename Real, typename Device, typename Index > - template< typename Real2, typename Device2, typename Index2 > -tnlGridOld< 1, Real, Device, Index >& -tnlGridOld< 1, Real, Device, Index > -:: operator = ( const tnlGridOld< 1, Real2, Device2, Index2 >& grid ) -{ - tnlMultiVector< 1, Real, Device, Index > :: operator = ( grid ); - return ( *this ); -} - -template< typename Real, typename Device, typename Index > -Real tnlGridOld< 1, Real, Device, Index > :: getValue( const tnlStaticVector< 1, Real >& point ) const -{ - tnlAssert( 0, cerr << "Interpolation is not implemented yet."); -} - -template< typename Real, typename Device, typename Index > -Real tnlGridOld< 1, Real, Device, Index > :: getValue( const Real& x ) const -{ - return this -> getValue( tnlStaticVector< 1, Real >( x ) ); -} - -template< typename Real, typename Device, typename Index > -Real tnlGridOld< 1, Real, Device, Index > :: Partial_x_f( const Index i1 ) const -{ - tnlAssert( i1 >= 0 && - i1 < ( this -> getDimensions(). x() - 1 ), - cerr << " i1 = " << i1 << " and it should be in [ 0, " << - ( this -> getDimensions(). y() - 1 ) << " )" << endl; ); - - const Real& Hx = spaceSteps[ 0 ]; - tnlAssert( Hx > 0, cerr << "Hx = " << Hx << endl; ); - return ( this -> getElementIndex( i1 + 1 ) - - this -> getElementIndex( i1 ) ) / Hx; -}; - -template< typename Real, typename Device, typename Index > -Real tnlGridOld< 1, Real, Device, Index > :: Partial_x_b( const Index i1 ) const -{ - tnlAssert( i1 > 0 && - i1 <= ( this -> getDimensions()[ tnlX ] - 1 ), - cerr << " i1 = " << i1 << " and it should be in ( 0, " << - ( this -> getDimensions()[ tnlX ] - 1 ) << " ] " << endl; ); - - const Real& Hx = spaceSteps[ 0 ]; - tnlAssert( Hx > 0, cerr << "Hx = " << Hx << endl; ); - return ( this -> getElement( i1 ) - - this -> getElement( i1 - 1 ) ) / Hx; -}; - -template< typename Real, typename Device, typename Index > -Real tnlGridOld< 1, Real, Device, Index > :: Partial_x( const Index i1 ) const -{ - tnlAssert( i1 > 0 && - i1 < ( this -> getDimensions()[ tnlX ] - 1 ), - cerr << " i1 = " << i1 << " and it should be in ( 0, " << - ( this -> getDimensions()[ tnlX ] - 1 ) << " ) " << endl; ); - - const Real& Hx = spaceSteps[ 0 ]; - tnlAssert( Hx > 0, cerr << "Hx = " << Hx << endl; ); - return ( this -> getElement( i1 + 1 ) - - this -> getElement( i1 - 1 ) ) / ( 2.0 * Hx ); -}; - -template< typename Real, typename Device, typename Index > -Real tnlGridOld< 1, Real, Device, Index > :: Partial_xx( const Index i1 ) const -{ - tnlAssert( i1 > 0 && - i1 < ( this -> getDimensions()[ tnlX ] - 1 ), - cerr << " i1 = " << i1 << " and it should be in ( 0, " << - ( this -> getDimensions()[ tnlX ] - 1 ) << " ) " << endl; ); - - const Real& Hx = spaceSteps[ 0 ]; - tnlAssert( Hx > 0, cerr << "Hx = " << Hx << endl; ); - return ( this -> getElement( i1 + 1 ) - - 2.0 * this -> getElement( i1 ) + - this -> getElement( i1 - 1 ) ) / ( Hx * Hx ); -}; - - -template< typename Real, typename Device, typename Index > -void tnlGridOld< 1, Real, Device, Index > :: setDirichletBC( const tnlGridOld< 1, Real, Device, Index >&bc, - const tnlStaticVector< 1, bool >& lowerBC, - const tnlStaticVector< 1, bool >& upperBC ) -{ - if( Device :: getDevice() == tnlHostDevice ) - { - const Index xSize = this -> getDimensions(). x(); - if( lowerBC. x() ) - ( *this )( 0 ) = bc( 0 ); - if( upperBC. x() ) - ( *this )( xSize - 1 ) = bc( xSize - 1 ); - } - if( Device :: getDevice() == tnlCudaDevice ) - { -#ifdef HAVE_CUDA - { - tnlAssert( false, ); - /*const Index size = this -> getSize(); - const Index desBlockSize = 64; - const Index gridSize = size / desBlockSize + ( size % desBlockSize != 0 ); - dim3 gridDim( 0 ), blockDim( 0 ); - gridDim. x = gridSize; - blockDim. x = desBlockSize; - :: setDirichletBC< 2, Real, Index ><<< gridDim, blockDim >>>( this -> getDimensions(). x(), - this -> getDimensions(). y(), - bc. getData(), - this -> getData() );*/ - } -#endif - } -} - -template< typename Real, typename Device, typename Index > -void tnlGridOld< 1, Real, Device, Index > :: setDirichletBC( const Real& bcValue, - const tnlStaticVector< 1, bool >& lowerBC, - const tnlStaticVector< 1, bool >& upperBC ) -{ - if( Device :: getDevice() == tnlHostDevice ) - { - const Index xSize = this -> getDimensions(). x(); - if( lowerBC. x() ) - ( *this )( 0 ) = bcValue; - if( upperBC. x() ) - ( *this )( xSize - 1 ) = bcValue; - } - if( Device :: getDevice() == tnlCudaDevice ) - { -#ifdef HAVE_CUDA - tnlAssert( false, ); - /*{ - const Index size = this -> getSize(); - const Index desBlockSize = 64; - const Index gridSize = size / desBlockSize + ( size % desBlockSize != 0 ); - dim3 gridDim( 0 ), blockDim( 0 ); - gridDim. x = gridSize; - blockDim. x = desBlockSize; - :: setConstantDirichletBC< 2, Real, Index ><<< gridDim, blockDim >>>( this -> getDimensions(). x(), - this -> getDimensions(). y(), - bcValue, - this -> getData() ); - }*/ -#endif - } -} - -template< typename Real, typename Device, typename Index > -void tnlGridOld< 1, Real, Device, Index > :: setNeumannBC( const tnlGridOld< 1, Real, Device, Index >&bc, - const tnlStaticVector< 1, bool >& lowerBC, - const tnlStaticVector< 1, bool >& upperBC ) -{ - if( Device :: getDevice() == tnlHostDevice ) - { - const Real& hx = this -> getSpaceSteps(). x(); - - const Index xSize = this -> getDimensions(). x(); - if( lowerBC. x() ) - ( *this )( 0 ) = ( *this )( 1 ) + hx * bc( 0 ); - if( upperBC. x() ) - ( *this )( xSize - 1 ) = ( *this )( xSize - 1 ) + hx * bc( xSize -1 ); - } - if( Device :: getDevice() == tnlCudaDevice ) - { -#ifdef HAVE_CUDA - tnlAssert( false, ); - /*{ - const Index size = this -> getSize(); - const Index desBlockSize = 64; - const Index gridSize = size / desBlockSize + ( size % desBlockSize != 0 ); - dim3 gridDim( 0 ), blockDim( 0 ); - gridDim. x = gridSize; - blockDim. x = desBlockSize; - ::setNeumannBC< 2, Real, Index ><<< gridDim, blockDim >>>( this -> getDimensions(). x(), - this -> getDimensions(). y(), - this -> getSpaceSteps(). x(), - this -> getSpaceSteps(). y(), - bc. getData(), - this -> getData() ); - }*/ -#endif - } -} - -template< typename Real, typename Device, typename Index > -void tnlGridOld< 1, Real, Device, Index > :: setNeumannBC( const Real& bcValue, - const tnlStaticVector< 1, bool >& lowerBC, - const tnlStaticVector< 1, bool >& upperBC ) -{ - if( Device :: getDevice() == tnlHostDevice ) - { - const Real& hx = this -> getSpaceSteps(). x(); - - const Index xSize = this -> getDimensions(). x(); - if( lowerBC. x() ) - ( *this )( 0 ) = ( *this )( 1 ) + hx * bcValue; - if( upperBC. x() ) - ( *this )( xSize - 1 ) = ( *this )( xSize - 1 ) + hx * bcValue; - } - if( Device :: getDevice() == tnlCudaDevice ) - { -#ifdef HAVE_CUDA - tnlAssert( false, ) - /*{ - const Index size = this -> getSize(); - const Index desBlockSize = 64; - const Index gridSize = size / desBlockSize + ( size % desBlockSize != 0 ); - dim3 gridDim( 0 ), blockDim( 0 ); - gridDim. x = gridSize; - blockDim. x = desBlockSize; - :: setConstantNeumannBC< 2, Real, Index ><<< gridDim, blockDim >>>( this -> getDimensions(). x(), - this -> getDimensions(). y(), - this -> getSpaceSteps(). x(), - this -> getSpaceSteps(). y(), - bcValue, - this -> getData() ); - }*/ -#endif - } -} - -/* -template< typename Real, typename Device, typename Index > -Real tnlGridOld< 1, Real, Device, Index > :: getMax() const -{ - return tnlMax( * this ); -} - -template< typename Real, typename Device, typename Index > -Real tnlGridOld< 1, Real, Device, Index > :: getMin() const -{ - return tnlMin( * this ); -} - -template< typename Real, typename Device, typename Index > -Real tnlGridOld< 1, Real, Device, Index > :: getAbsMax() const -{ - return tnlAbsMax( * this ); -} - -template< typename Real, typename Device, typename Index > -Real tnlGridOld< 1, Real, Device, Index > :: getAbsMin() const -{ - return tnlAbsMin( * this ); -} -*/ - -template< typename Real, typename Device, typename Index > -Real tnlGridOld< 1, Real, Device, Index > :: getLpNorm( const Real& p ) const -{ - Real result = this -> lpNorm( p ); - return result * getSpaceSteps(). x(); -} - -/*template< typename Real, typename Device, typename Index > -Real tnlGridOld< 1, Real, Device, Index > :: getSum() const -{ - return tnlMultiVector< 1, Real, Device, Index > :: sum( * this ); -} - -template< typename Real, typename Device, typename Index > -Real tnlGridOld< 1, Real, Device, Index > :: getDifferenceMax( const tnlVector< Real, Device, Index >& v ) const -{ - tnlAssert( this -> getDimensions() == v. getDimensions(), - cerr << "The grid names are " << this -> getName() - << " and " << v. getName() - << "To get grids with the same parameters use the method setLike." << endl; ); - tnlAssert( this -> getDomainLoweCorner() == v. getDomainLowerCorner() && - this -> getDomainUpperCorner() == v. getDomainUpperCorner(), - cerr << "The grid names are " << this -> getName() - << " and " << v. getName() - << "To get grids with the same parameters use the method setLike." << endl; ); - return v. differenceMax( *this ); -} - -template< typename Real, typename Device, typename Index > -Real tnlGridOld< 1, Real, Device, Index > :: getDifferenceMin( const tnlVector< Real, Device, Index >& v ) const -{ - tnlAssert( this -> getDimensions() == v. getDimensions(), - cerr << "The grid names are " << this -> getName() - << " and " << v. getName() - << "To get grids with the same parameters use the method setLike." << endl; ); - tnlAssert( this -> getDomainLoweCorner() == v. getDomainLowerCorner() && - this -> getDomainUpperCorner() == v. getDomainUpperCorner(), - cerr << "The grid names are " << this -> getName() - << " and " << v. getName() - << "To get grids with the same parameters use the method setLike." << endl; ); - return v. differenceMin( *this ); -} - -template< typename Real, typename Device, typename Index > -Real tnlGridOld< 1, Real, Device, Index > :: getDifferenceAbsMax( const tnlVector< Real, Device, Index >& v ) const -{ - tnlAssert( this -> getDimensions() == v. getDimensions(), - cerr << "The grid names are " << this -> getName() - << " and " << v. getName() - << "To get grids with the same parameters use the method setLike." << endl; ); - tnlAssert( this -> getDomainLoweCorner() == v. getDomainLowerCorner() && - this -> getDomainUpperCorner() == v. getDomainUpperCorner(), - cerr << "The grid names are " << this -> getName() - << " and " << v. getName() - << "To get grids with the same parameters use the method setLike." << endl; ); - return v. differenceAbsMax( *this ); -} - -template< typename Real, typename Device, typename Index > -Real tnlGridOld< 1, Real, Device, Index > :: getDifferenceAbsMin( const tnlVector< Real, Device, Index >& v ) const -{ - tnlAssert( this -> getDimensions() == v. getDimensions(), - cerr << "The grid names are " << this -> getName() - << " and " << v. getName() - << "To get grids with the same parameters use the method setLike." << endl; ); - tnlAssert( this -> getDomainLoweCorner() == v. getDomainLowerCorner() && - this -> getDomainUpperCorner() == v. getDomainUpperCorner(), - cerr << "The grid names are " << this -> getName() - << " and " << v. getName() - << "To get grids with the same parameters use the method setLike." << endl; ); - return v. differenceAbsMin( *this ); -} -*/ - -template< typename Real, typename Device, typename Index > -Real tnlGridOld< 1, Real, Device, Index > :: getDifferenceLpNorm( const tnlVector< Real, Device, Index >& v, const Real& p ) const -{ - tnlAssert( this -> getDimensions() == v. getDimensions(), - cerr << "The grid names are " << this -> getName() - << " and " << v. getName() - << "To get grids with the same parameters use the method setLike." << endl; ); - tnlAssert( this -> getDomainLoweCorner() == v. getDomainLowerCorner() && - this -> getDomainUpperCorner() == v. getDomainUpperCorner(), - cerr << "The grid names are " << this -> getName() - << " and " << v. getName() - << "To get grids with the same parameters use the method setLike." << endl; ); - - Real result = v. differenceLpNorm( * this, p ); - return result * getSpaceSteps(). x(); -} - -/* -template< typename Real, typename Device, typename Index > -Real tnlGridOld< 1, Real, Device, Index > :: getDifferenceSum( const tnlVector< Real, Device, Index >& v ) const -{ - tnlAssert( this -> getDimensions() == v. getDimensions(), - cerr << "The grid names are " << this -> getName() - << " and " << v. getName() - << "To get grids with the same parameters use the method setLike." << endl; ); - tnlAssert( this -> getDomainLoweCorner() == v. getDomainLowerCorner() && - this -> getDomainUpperCorner() == v. getDomainUpperCorner(), - cerr << "The grid names are " << this -> getName() - << " and " << v. getName() - << "To get grids with the same parameters use the method setLike." << endl; ); - return this -> differenceSum( v ); -} - -template< typename Real, typename Device, typename Index > -void tnlGridOld< 1, Real, Device, Index > :: scalarMultiplication( const Real& alpha ) -{ - return this -> scalarMultiplication( alpha ); -} - -template< typename Real, typename Device, typename Index > -Real tnlGridOld< 1, Real, Device, Index > :: scalarProduct( const tnlVector< Real, Device, Index >& v ) const -{ - tnlAssert( this -> getDimensions() == v. getDimensions(), - cerr << "The grid names are " << this -> getName() - << " and " << v. getName() - << "To get grids with the same parameters use the method setLike." << endl; ); - tnlAssert( this -> getDomainLoweCorner() == v. getDomainLowerCorner() && - this -> getDomainUpperCorner() == v. getDomainUpperCorner(), - cerr << "The grid names are " << this -> getName() - << " and " << v. getName() - << "To get grids with the same parameters use the method setLike." << endl; ); - return this -> scalarProduct( v ); -}; - -template< typename Real, typename Device, typename Index > -void tnlGridOld< 1, Real, Device, Index > :: alphaXPlusY( const Real& alpha, - const tnlVector< Real, Device, Index >& x ) -{ - tnlAssert( this -> getDimensions() == v. getDimensions(), - cerr << "The grid names are " << this -> getName() - << " and " << v. getName() - << "To get grids with the same parameters use the method setLike." << endl; ); - tnlAssert( this -> getDomainLoweCorner() == v. getDomainLowerCorner() && - this -> getDomainUpperCorner() == v. getDomainUpperCorner(), - cerr << "The grid names are " << this -> getName() - << " and " << v. getName() - << "To get grids with the same parameters use the method setLike." << endl; ); - this -> alphaXPlusY( alpha, x ); -}; - -template< typename Real, typename Device, typename Index > -void tnlGridOld< 1, Real, Device, Index > :: saxmy( const Real& alpha, - const tnlVector< Real, Device, Index >& x ) -{ - tnlAssert( this -> getDimensions() == v. getDimensions(), - cerr << "The grid names are " << this -> getName() - << " and " << v. getName() - << "To get grids with the same parameters use the method setLike." << endl; ); - tnlAssert( this -> getDomainLoweCorner() == v. getDomainLowerCorner() && - this -> getDomainUpperCorner() == v. getDomainUpperCorner(), - cerr << "The grid names are " << this -> getName() - << " and " << v. getName() - << "To get grids with the same parameters use the method setLike." << endl; ); - this -> saxmy( alpha, x ); -}; -*/ - -template< typename Real, typename Device, typename Index > -bool tnlGridOld< 1, Real, Device, Index > :: save( tnlFile& file ) const -{ - if( ! tnlMultiVector< 1, Real, Device, Index > :: save( file ) ) - { - cerr << "I was not able to write the tnlMultiVector of the tnlGridOld " - << this -> getName() << endl; - return false; - } - if( ! domainLowerCorner. save( file ) || - ! domainUpperCorner. save( file ) || - ! spaceSteps. save( file ) ) - { - cerr << "I was not able to write the domain decsription of the tnlGridOld " - << this -> getName() << endl; - return false; - } - return true; -} - -template< typename Real, typename Device, typename Index > -bool tnlGridOld< 1, Real, Device, Index > :: load( tnlFile& file ) -{ - if( ! tnlMultiVector< 1, Real, Device, Index > :: load( file ) ) - { - cerr << "I was not able to read the tnlMultiVector of the tnlGridOld " - << this -> getName() << endl; - return false; - } - if( ! domainLowerCorner. load( file ) || - ! domainUpperCorner. load( file ) || - ! spaceSteps. load( file ) ) - { - cerr << "I was not able to read the domain description of the tnlGridOld " - << this -> getName() << endl; - return false; - } - return true; -} - -template< typename Real, typename Device, typename Index > -bool tnlGridOld< 1, Real, Device, Index > :: save( const tnlString& fileName ) const -{ - return tnlObject :: save( fileName ); -} - -template< typename Real, typename Device, typename Index > -bool tnlGridOld< 1, Real, Device, Index > :: load( const tnlString& fileName ) -{ - return tnlObject :: load( fileName ); -} - -template< typename Real, typename Device, typename Index > -bool tnlGridOld< 1, Real, Device, Index > :: draw( const tnlString& fileName, - const tnlString& format, - const tnlStaticVector< 1, Index > steps ) const -{ - tnlAssert( steps > ( tnlStaticVector< 1, Index >( 0 ) ), - cerr << "Wrong steps of increment ( " << steps << " )" - << " for drawing the tnlGridOld " << this -> getName() << "." << endl; ); - if( format == "tnl" ) - return this -> save( fileName ); - fstream file; - file. open( fileName. getString(), ios :: out ); - if( ! file ) - { - cerr << " I am not able to open the file " << fileName - << " for drawing the tnlGridOld " << this -> getName() << "." << endl; - return false; - } - if( format == "gnuplot" ) - { - const Index xSize = this -> getDimensions()[ tnlX ]; - const Real& ax = this -> getDomainLowerCorner()[ tnlX ]; - const Real& hx = this -> getSpaceSteps()[ tnlX ]; - for( Index i = 0; i < xSize; i += steps[ tnlX ] ) - file << setprecision( 12 ) - << ax + i * hx * steps[ tnlX ] - << " " - << this -> getElement( i ) - << endl; - return true; - } - cerr << endl << "I do not know a format " << format << " for tnlGridOld with 2 dimensions."; - return false; -} - -#ifdef HAVE_CUDA -template< int Dimensions, typename Real, typename Index > -__global__ void setConstantDirichletBC( const Index xSize, - const Real bc, - Real* u ) -{ - /*const Index ij = blockIdx. x * blockDim. x + threadIdx. x; - const Index i = ij / ySize; - const Index j = ij % ySize; - - if( ij < xSize * ySize && - ( i == 0 || j == 0 || i == xSize - 1 || j == ySize - 1 ) ) - { - u[ ij ] = bc; - }*/ -} - -template< int Dimensions, typename Real, typename Index > -__global__ void setDirichletBC( const Index xSize, - const Real* bc, - Real* u ) -{ - /*const Index ij = blockIdx. x * blockDim. x + threadIdx. x; - const Index i = ij / ySize; - const Index j = ij % ySize; - - if( ij < xSize * ySize && - ( i == 0 || j == 0 || i == xSize - 1 || j == ySize - 1 ) ) - { - u[ ij ] = bc[ ij ]; - }*/ -} - -template< int Dimensions, typename Real, typename Index > -__global__ void setConstantNeumannBC( const Index xSize, - const Real hx, - const Real bc, - Real* u ) -{ - /*const Index ij = blockIdx. x * blockDim. x + threadIdx. x; - const Index i = ij / ySize; - const Index j = ij % ySize; - - if( ij < xSize * ySize && - ( i == 0 || j == 0 || i == xSize - 1 || j == ySize - 1 ) ) - { - if( i == 0 ) - u[ ij ] = u[ ij + ySize ] + hx * bc; - if( i == xSize - 1 ) - u[ ij ] = u[ ij - ySize ] + hx * bc; - - __syncthreads(); - - if( j == 0 ) - u[ ij ] = u[ ij + 1 ] + hy * bc; - if( j == ySize - 1 ) - u[ ij ] = u[ ij - 1 ] + hy * bc; - }*/ -} - -template< int Dimensions, typename Real, typename Index > -__global__ void setNeumannBC( const Index xSize, - const Real hx, - const Real* bc, - Real* u ) -{ - /*const Index ij = blockIdx. x * blockDim. x + threadIdx. x; - const Index i = ij / ySize; - const Index j = ij % ySize; - - if( ij < xSize * ySize && - ( i == 0 || j == 0 || i == xSize - 1 || j == ySize - 1 ) ) - { - if( i == 0 ) - u[ ij ] = u[ ij + ySize ] + hx * bc[ ij ]; - if( i == xSize - 1 ) - u[ ij ] = u[ ij - ySize ] + hx * bc[ ij ]; - - __syncthreads(); - - if( j == 0 ) - u[ ij ] = u[ ij + 1 ] + hy * bc[ ij ]; - if( j == ySize - 1 ) - u[ ij ] = u[ ij - 1 ] + hy * bc[ ij ]; - }*/ -} - -#endif - - - - -#endif /* tnlGrid1D_IMPL_H_ */ diff --git a/src/legacy/mesh/implementation/tnlGrid2D_impl.h b/src/legacy/mesh/implementation/tnlGrid2D_impl.h deleted file mode 100644 index 2a6d9a668588c62c9133feec4a89b6c3f2d0f032..0000000000000000000000000000000000000000 --- a/src/legacy/mesh/implementation/tnlGrid2D_impl.h +++ /dev/null @@ -1,948 +0,0 @@ -/*************************************************************************** - tnlGridOld2D_impl.h - description - ------------------- - begin : Nov 22, 2012 - copyright : (C) 2012 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 tnlGridOld2D_IMPL_H_ -#define tnlGridOld2D_IMPL_H_ - -#ifdef HAVE_CUDA -template< int Dimensions, typename Real, typename Index > -__global__ void setConstantDirichletBC( const Index xSize, - const Index ySize, - const Real bc, - Real* u ); - -template< int Dimensions, typename Real, typename Index > -__global__ void setDirichletBC( const Index xSize, - const Index ySize, - const Real* bc, - Real* u ); - -template< int Dimensions, typename Real, typename Index > -__global__ void setConstantNeumannBC( const Index xSize, - const Index ySize, - const Real hx, - const Real hy, - const Real bc, - Real* u ); - -template< int Dimensions, typename Real, typename Index > -__global__ void setNeumannBC( const Index xSize, - const Index ySize, - const Real hx, - const Real hy, - const Real* bc, - Real* u ); -#endif - -template< typename Real, typename Device, typename Index > -tnlGridOld< 2, Real, Device, Index > :: tnlGridOld() -{ -} - -template< typename Real, typename Device, typename Index > -tnlGridOld< 2, Real, Device, Index > :: tnlGridOld( const tnlString& name ) -{ - this -> setName( name ); -} - -template< typename Real, typename Device, typename Index > -tnlGridOld< 2, Real, Device, Index > :: tnlGridOld( const tnlString& name, - const tnlGridOld< 2, Real, tnlHost, Index >& grid ) -{ - this -> setName( name ); - this -> setLike( grid ); -} - -template< typename Real, typename Device, typename Index > -tnlGridOld< 2, Real, Device, Index > :: tnlGridOld( const tnlString& name, - const tnlGridOld< 2, Real, tnlCuda, Index >& grid ) -{ - this -> setName( name ); - this -> setLike( grid ); -} - -template< typename Real, typename Device, typename Index > -const tnlStaticVector< 2, Index >& tnlGridOld< 2, Real, Device, Index > :: getDimensions() const -{ - return tnlMultiVector< 2, Real, Device, Index > :: getDimensions(); -} - -template< typename Real, typename Device, typename Index > -bool tnlGridOld< 2, Real, Device, Index > :: setDimensions( const tnlStaticVector< 2, Index >& dimensions ) -{ - if( ! tnlMultiVector< 2, Real, Device, Index > :: setDimensions( dimensions ) ) - return false; - spaceSteps[ 0 ] = ( domainUpperCorner[ 0 ] - domainLowerCorner[ 0 ] ) / ( Real ) ( this -> getDimensions()[ 0 ] - 1 ); - spaceSteps[ 1 ] = ( domainUpperCorner[ 1 ] - domainLowerCorner[ 1 ] ) / ( Real ) ( this -> getDimensions()[ 1 ] - 1 ); - return true; -} - -template< typename Real, typename Device, typename Index > -bool tnlGridOld< 2, Real, Device, Index > :: setDomain( const tnlStaticVector< 2, Real >& origin, - const tnlStaticVector< 2, Real >& proportions ) -{ - if( origin >= proportions ) - { - cerr << "Wrong parameters for the grid domain of " << this -> getName() << ". The low corner must by smaller than the high corner." << endl - << "origin = " << origin << endl << "proportions = " << proportions << endl; - return false; - } - domainLowerCorner = origin; - domainUpperCorner = proportions; - spaceSteps[ 0 ] = ( domainUpperCorner[ 0 ] - domainLowerCorner[ 0 ] ) / ( Real ) ( this -> getDimensions()[ 0 ] - 1 ); - spaceSteps[ 1 ] = ( domainUpperCorner[ 1 ] - domainLowerCorner[ 1 ] ) / ( Real ) ( this -> getDimensions()[ 1 ] - 1 ); - return true; -} - -template< typename Real, typename Device, typename Index > - template< typename Grid > -bool tnlGridOld< 2, Real, Device, Index > :: setLike( const Grid& v ) -{ - return tnlMultiVector< 2, Real, Device, Index > :: setLike( v ) && - this -> setDomain( v. getDomainLowerCorner(), v. getDomainUpperCorner() ); -} - -template< typename Real, typename Device, typename Index > -const tnlStaticVector< 2, Real >& tnlGridOld< 2, Real, Device, Index > :: getDomainLowerCorner() const -{ - return this -> domainLowerCorner; -} - -template< typename Real, typename Device, typename Index > -const tnlStaticVector< 2, Real >& tnlGridOld< 2, Real, Device, Index > :: getDomainUpperCorner() const -{ - return this -> domainUpperCorner; -} - -template< typename Real, typename Device, typename Index > -const tnlStaticVector< 2, Real >& tnlGridOld< 2, Real, Device, Index > :: getSpaceSteps() const -{ - return spaceSteps; -} - -template< typename Real, typename Device, typename Index > -tnlString tnlGridOld< 2, Real, Device, Index > :: getType() const -{ - return tnlString( "tnlGridOld< ") + - tnlString( "2" ) + - tnlString( ", " ) + - tnlString( ::getType< Real >() ) + - tnlString( ", " ) + - Device :: getDeviceType() + - tnlString( ", " ) + - tnlString( ::getType< Index >() ) + - tnlString( " >" ); -} - -template< typename Real, typename Device, typename Index > -bool tnlGridOld< 2, Real, Device, Index > :: operator == ( const tnlGridOld< 2, Real, Device, Index >& grid ) const -{ - tnlAssert( this -> getDomainLowerCorner() == grid. getDomainLowerCorner() && - this -> getDomainUpperCorner() == grid. getDomainUpperCorner(), - cerr << "You are attempting to compare two grids with different domains." << endl - << "First grid name is " << this -> getName() - << " domain is ( " << this -> getDomainLowerCorner() << " )- (" - << this -> getDomainUpperCorner() << ")" << endl - << "Second grid is " << grid. getName() - << " domain is ( " << grid. getDomainLowerCorner() << " )- (" - << grid. getDomainUpperCorner() << ")" << endl; ); - return tnlMultiVector< 2, Real, Device, Index > :: operator == ( grid ); -} - -template< typename Real, typename Device, typename Index > -bool tnlGridOld< 2, Real, Device, Index > :: operator != ( const tnlGridOld< 2, Real, Device, Index >& grid ) const -{ - return ! ( (* this ) == grid ); -} - -template< typename Real, typename Device, typename Index > - template< typename Real2, typename Device2, typename Index2 > -tnlGridOld< 2, Real, Device, Index >& -tnlGridOld< 2, Real, Device, Index > -:: operator = ( const tnlGridOld< 2, Real2, Device2, Index2 >& grid ) -{ - tnlAssert( this -> getDimensions() == grid. getDimensions(), - cerr << "You are attempting to assign two arrays with different dimensions." << endl - << "First array name is " << this -> getName() - << " dimensions are ( " << this -> getDimensions() << " )" << endl - << "Second array is " << grid. getName() - << " dimensions are ( " << grid. getDimensions() << " )" << endl; ); - tnlVector< Real, Device, Index > :: operator = ( grid ); - return ( *this ); -} - -template< typename Real, typename Device, typename Index > -Real tnlGridOld< 2, Real, Device, Index > :: getValue( const tnlStaticVector< 2, Real >& point ) const -{ - Real x = ( point[ 0 ] - domainLowerCorner[ 0 ] ) / spaceSteps[ 0 ]; - Real y = ( point[ 1 ] - domainLowerCorner[ 1 ] ) / spaceSteps[ 1 ]; - Index ix = ( Index ) ( x ); - Index iy = ( Index ) ( y ); - Real dx = x - ( Real ) ix; - Real dy = y - ( Real ) iy; - if( iy >= this -> getDimensions()[ tnlY ] - 1 ) - { - if( ix >= this -> getDimensions()[ tnlX ] - 1 ) - return this -> getElement( this -> getDimensions()[ tnlX ] - 1, - this -> getDimensions()[ tnlY ] - 1 ); - return ( Real( 1.0 ) - dx ) * this -> getElement( ix, - this -> getDimensions()[ tnlY ] - 1 ) + - dx * this -> getElement( ix + 1, - this -> getDimensions()[ tnlY ] - 1 ); - if( ix >= this -> getDimensions()[ tnlX ] - 1 ) - return ( Real( 1.0 ) - dy ) * this -> getElement( this -> getDimensions()[ tnlX ] - 1, - iy ) + - dy * this -> getElement( this -> getDimensions()[ tnlX ] - 1, - iy + 1 ); - Real a1, a2; - a1 = ( Real( 1.0 ) - dx ) * this -> getElement( ix, iy ) + - dx * this -> getElement( ix + 1, iy ); - - a2 = ( Real( 1.0 ) - dx ) * this -> getElement( ix, iy + 1 ) + - dx * this -> getElement( ix + 1, iy + 1 ); - return ( Real( 1.0 ) - dy ) * a1 + dy * a2; - } -} - -template< typename Real, typename Device, typename Index > -Real tnlGridOld< 2, Real, Device, Index > :: getValue( const Real& x, - const Real& y ) const -{ - return this -> getValue( tnlStaticVector< 2, Real >( x, y ) ); -} - -template< typename Real, typename Device, typename Index > -Real tnlGridOld< 2, Real, Device, Index > :: Partial_x_f( const Index i1, - const Index i2 ) const -{ - tnlAssert( i1 >= 0 && i2 >= 0 && - i1 < this -> getDimensions(). x() - 1 && i2 <= this -> getDimensions(). y() - 1, - cerr << " i1 = " << i1 << " and it should be in [ 0, " << - ( this -> getDimensions() .x() - 1 ) << " ) " << endl - << " i2 = " << i2 << " and it should be in [ 0, " << - ( this -> getDimensions(). y() - 1 ) << " ] " << endl; ); - - const Real& Hx = spaceSteps[ 0 ]; - tnlAssert( Hx > 0, cerr << "Hx = " << Hx << endl; ); - return ( this -> getElement( i1 + 1, i2 ) - - this -> getElement( i1, i2 ) ) / Hx; -}; - -template< typename Real, typename Device, typename Index > -Real tnlGridOld< 2, Real, Device, Index > :: Partial_x_b( const Index i1, - const Index i2 ) const -{ - tnlAssert( i1 > 0 && i2 >= 0 && - i1 <= this -> getDimensions()[ tnlX ] - 1 && i2 <= this -> getDimensions()[ tnlY ] - 1, - cerr << " i1 = " << i1 << " and it should be in ( 0, " << - ( this -> getDimensions()[ tnlX ] - 1 ) << " ] " << endl - << " i2 = " << i2 << " and it should be in [ 0, " << - ( this -> getDimensions()[ tnlY ] - 1 ) << " ] " << endl; ); - - const Real& Hx = spaceSteps[ 0 ]; - tnlAssert( Hx > 0, cerr << "Hx = " << Hx << endl; ); - return ( this -> getElement( i1, i2 ) - - this -> getElement( i1 - 1, i2 ) ) / Hx; -}; -template< typename Real, typename Device, typename Index > -Real tnlGridOld< 2, Real, Device, Index > :: Partial_x( const Index i1, - const Index i2 ) const -{ - tnlAssert( i1 > 0 && i2 >= 0 && - i1 < this -> getDimensions()[ tnlX ] - 1 && i2 <= this -> getDimensions()[ tnlY ] - 1, - cerr << " i1 = " << i1 << " and it should be in ( 0, " << - ( this -> getDimensions()[ tnlX ] - 1 ) << " ) " << endl - << " i2 = " << i2 << " and it should be in [ 0, " << - ( this -> getDimensions()[ tnlY ] - 1 ) << " ] " << endl; ); - - const Real& Hx = spaceSteps[ 0 ]; - tnlAssert( Hx > 0, cerr << "Hx = " << Hx << endl; ); - return ( this -> getElement( i1 + 1, i2 ) - - this -> getElement( i1 - 1, i2 ) ) / ( 2.0 * Hx ); -}; - -template< typename Real, typename Device, typename Index > -Real tnlGridOld< 2, Real, Device, Index > :: Partial_xx( const Index i1, - const Index i2 ) const -{ - tnlAssert( i1 > 0 && i2 >= 0 && - i1 < this -> getDimensions()[ tnlX ] - 1 && i2 <= this -> getDimensions()[ tnlY ] - 1, - cerr << " i1 = " << i1 << " and it should be in ( 0, " << - ( this -> getDimensions()[ tnlX ] - 1 ) << " ) " << endl - << " i2 = " << i2 << " and it should be in [ 0, " << - ( this -> getDimensions()[ tnlY ] - 1 ) << " ] " << endl; ); - - const Real& Hx = spaceSteps[ 0 ]; - tnlAssert( Hx > 0, cerr << "Hx = " << Hx << endl; ); - return ( this -> getElement( i1 + 1, i2 ) - - 2.0 * this -> getElement( i1, i2 ) + - this -> getElement( i1 - 1, i2 ) ) / ( Hx * Hx ); -}; -template< typename Real, typename Device, typename Index > -Real tnlGridOld< 2, Real, Device, Index > :: Partial_y_f( const Index i1, - const Index i2 ) const -{ - tnlAssert( i1 >= 0 && i2 >= 0 && - i1 <= this -> getDimensions()[ tnlX ] - 1 && i2 < this -> getDimensions()[ tnlY ] - 1, - cerr << " i1 = " << i1 << " and it should be in [ 0, " << - ( this -> getDimensions()[ tnlX ] - 1 ) << " ] " << endl - << " i2 = " << i2 << " and it should be in [ 0, " << - ( this -> getDimensions()[ tnlY ] - 1 ) << " ) " << endl; ); - - const Real& Hy = spaceSteps[ 1 ]; - tnlAssert( Hy > 0, cerr << "Hy = " << Hy << endl; ); - return ( this -> getElement( i1, i2 + 1 ) - - this -> getElement( i1, i2 ) ) / Hy; -}; - -template< typename Real, typename Device, typename Index > -Real tnlGridOld< 2, Real, Device, Index > :: Partial_y_b( const Index i1, - const Index i2 ) const -{ - tnlAssert( i1 >= 0 && i2 > 0 && - i1 <= this -> getDimensions()[ tnlX ] - 1 && i2 <= this -> getDimensions()[ tnlY ] - 1, - cerr << " i1 = " << i1 << " and it should be in [ 0, " << - ( this -> getDimensions()[ tnlX ] - 1 ) << " ] " << endl - << " i2 = " << i2 << " and it should be in ( 0, " << - ( this -> getDimensions()[ tnlY ] - 1 ) << " ] " << endl; ); - - const Real& Hy = spaceSteps[ 1 ]; - tnlAssert( Hy > 0, cerr << "Hy = " << Hy << endl; ); - return ( this -> getElement( i1, i2 ) - - this -> getElement( i1, i2 - 1 ) ) / Hy; -}; - -template< typename Real, typename Device, typename Index > -Real tnlGridOld< 2, Real, Device, Index > :: Partial_y( const Index i1, - const Index i2 ) const -{ - tnlAssert( i1 >= 0 && i2 > 0 && - i1 <= this -> getDimensions()[ tnlX ] - 1 && i2 < this -> getDimensions()[ tnlY ] - 1, - cerr << " i1 = " << i1 << " and it should be in [ 0, " << - ( this -> getDimensions()[ tnlX ] - 1 ) << " ] " << endl - << " i2 = " << i2 << " and it should be in ( 0, " << - ( this -> getDimensions()[ tnlY ] - 1 ) << " ) " << endl; ); - - const Real& Hy = spaceSteps[ 1 ]; - tnlAssert( Hy > 0, cerr << "Hy = " << Hy << endl; ); - return ( this -> getElement( i1, i2 + 1 ) - - this -> getElement( i1, i2 - 1 ) ) / ( 2.0 * Hy ); -}; - -template< typename Real, typename Device, typename Index > -Real tnlGridOld< 2, Real, Device, Index > :: Partial_yy( const Index i1, - const Index i2 ) const -{ - tnlAssert( i1 >= 0 && i2 > 0 && - i1 <= this -> getDimensions()[ tnlX ] - 1 && i2 < this -> getDimensions()[ tnlY ] - 1, - cerr << " i1 = " << i1 << " and it should be in [ 0, " << - ( this -> getDimensions()[ tnlX ] - 1 ) << " ] " << endl - << " i2 = " << i2 << " and it should be in ( 0, " << - ( this -> getDimensions()[ tnlY ] - 1 ) << " ) " << endl; ); - - const Real& Hy = spaceSteps[ 1 ]; - tnlAssert( Hy > 0, cerr << "Hy = " << Hy << endl; ); - return ( this -> getElement( i1, i2 + 1 ) - - 2.0 * this -> getElement( i1, i2 ) + - this -> getElement( i1, i2 - 1 ) ) / ( Hy * Hy ); -}; - -template< typename Real, typename Device, typename Index > -void tnlGridOld< 2, Real, Device, Index > :: setDirichletBC( const tnlGridOld< 2, Real, Device, Index >&bc, - const tnlStaticVector< 2, bool >& lowerBC, - const tnlStaticVector< 2, bool >& upperBC ) -{ - if( Device :: getDevice() == tnlHostDevice ) - { - const Index xSize = this -> getDimensions(). x(); - const Index ySize = this -> getDimensions(). y(); - Index i, j; - - if( lowerBC. x() ) - for( i = 0; i < xSize; i ++ ) - ( *this )( i, 0 ) = bc( i, 0 ); - if( upperBC. x() ) - for( i = 0; i < xSize; i ++ ) - ( *this )( i, ySize - 1 ) = bc( i, ySize - 1 ); - - if( lowerBC. y() ) - for( j = 0; j < ySize; j ++ ) - ( *this )( 0, j ) = bc( 0, j ); - if( upperBC. y() ) - for( j = 0; j < ySize; j ++ ) - ( *this )( xSize - 1, j ) = bc( xSize - 1, j ); - } - if( Device :: getDevice() == tnlCudaDevice ) - { -#ifdef HAVE_CUDA - const Index size = this -> getSize(); - const Index desBlockSize = 64; - const Index gridSize = size / desBlockSize + ( size % desBlockSize != 0 ); - dim3 gridDim( 0 ), blockDim( 0 ); - gridDim. x = gridSize; - blockDim. x = desBlockSize; - :: setDirichletBC< 2, Real, Index ><<< gridDim, blockDim >>>( this -> getDimensions(). x(), - this -> getDimensions(). y(), - bc. getData(), - this -> getData() ); -#endif - } -} - -template< typename Real, typename Device, typename Index > -void tnlGridOld< 2, Real, Device, Index > :: setDirichletBC( const Real& bcValue, - const tnlStaticVector< 2, bool >& lowerBC, - const tnlStaticVector< 2, bool >& upperBC ) -{ - if( Device :: getDevice() == tnlHostDevice ) - { - const Index xSize = this -> getDimensions(). x(); - const Index ySize = this -> getDimensions(). y(); - Index i, j; - - if( lowerBC. x() ) - for( i = 0; i < xSize; i ++ ) - ( *this )( i, 0 ) = bcValue; - if( upperBC. x() ) - for( i = 0; i < xSize; i ++ ) - ( *this )( i, ySize - 1 ) = bcValue; - - if( lowerBC. y() ) - for( j = 0; j < ySize; j ++ ) - ( *this )( 0, j ) = bcValue; - if( upperBC. y() ) - for( j = 0; j < ySize; j ++ ) - ( *this )( xSize - 1, j ) = bcValue; - } - if( Device :: getDevice() == tnlCudaDevice ) - { -#ifdef HAVE_CUDA - const Index size = this -> getSize(); - const Index desBlockSize = 64; - const Index gridSize = size / desBlockSize + ( size % desBlockSize != 0 ); - dim3 gridDim( 0 ), blockDim( 0 ); - gridDim. x = gridSize; - blockDim. x = desBlockSize; - :: setConstantDirichletBC< 2, Real, Index ><<< gridDim, blockDim >>>( this -> getDimensions(). x(), - this -> getDimensions(). y(), - bcValue, - this -> getData() ); -#endif - } -} - -template< typename Real, typename Device, typename Index > -void tnlGridOld< 2, Real, Device, Index > :: setNeumannBC( const tnlGridOld< 2, Real, Device, Index >&bc, - const tnlStaticVector< 2, bool >& lowerBC, - const tnlStaticVector< 2, bool >& upperBC ) -{ - if( Device :: getDevice() == tnlHostDevice ) - { - const Real& hx = this -> getSpaceSteps(). x(); - const Real& hy = this -> getSpaceSteps(). y(); - - const Index xSize = this -> getDimensions(). x(); - const Index ySize = this -> getDimensions(). y(); - Index i, j; - - if( lowerBC. x() ) - for( i = 0; i < xSize; i ++ ) - ( *this )( i, 0 ) = ( *this )( i, 1 ) + hy * bc( i, 0 ); - if( upperBC. x() ) - for( i = 0; i < xSize; i ++ ) - ( *this )( i, ySize - 1 ) = ( *this )( i, ySize - 2 ) + hy * bc( i, ySize - 1 ); - - if( lowerBC. y() ) - for( j = 0; j < ySize; j ++ ) - ( *this )( 0, j ) = ( *this )( 1, j ) + hx * bc( 0, j ); - if( upperBC. y() ) - for( j = 0; j < ySize; j ++ ) - ( *this )( xSize - 1, j ) = ( *this )( xSize - 2, j ) + hx * bc( xSize - 1, j ); - } - if( Device :: getDevice() == tnlCudaDevice ) - { -#ifdef HAVE_CUDA - const Index size = this -> getSize(); - const Index desBlockSize = 64; - const Index gridSize = size / desBlockSize + ( size % desBlockSize != 0 ); - dim3 gridDim( 0 ), blockDim( 0 ); - gridDim. x = gridSize; - blockDim. x = desBlockSize; - ::setNeumannBC< 2, Real, Index ><<< gridDim, blockDim >>>( this -> getDimensions(). x(), - this -> getDimensions(). y(), - this -> getSpaceSteps(). x(), - this -> getSpaceSteps(). y(), - bc. getData(), - this -> getData() ); -#endif - } -} - -template< typename Real, typename Device, typename Index > -void tnlGridOld< 2, Real, Device, Index > :: setNeumannBC( const Real& bcValue, - const tnlStaticVector< 2, bool >& lowerBC, - const tnlStaticVector< 2, bool >& upperBC ) -{ - if( Device :: getDevice() == tnlHostDevice ) - { - const Real& hx = this -> getSpaceSteps(). x(); - const Real& hy = this -> getSpaceSteps(). y(); - - const Index xSize = this -> getDimensions(). x(); - const Index ySize = this -> getDimensions(). y(); - Index i, j; - - if( lowerBC. x() ) - for( i = 0; i < xSize; i ++ ) - ( *this )( i, 0 ) = ( *this )( i, 1 ) + hy * bcValue; - if( upperBC. x() ) - for( i = 0; i < xSize; i ++ ) - ( *this )( i, ySize - 1 ) = ( *this )( i, ySize - 2 ) + hy * bcValue; - - if( lowerBC. y() ) - for( j = 0; j < ySize; j ++ ) - ( *this )( 0, j ) = ( *this )( 1, j ) + hx * bcValue; - if( upperBC. y() ) - for( j = 0; j < ySize; j ++ ) - ( *this )( xSize - 1, j ) = ( *this )( xSize - 2, j ) + hx * bcValue; - } - if( Device :: getDevice() == tnlCudaDevice ) - { -#ifdef HAVE_CUDA - const Index size = this -> getSize(); - const Index desBlockSize = 64; - const Index gridSize = size / desBlockSize + ( size % desBlockSize != 0 ); - dim3 gridDim( 0 ), blockDim( 0 ); - gridDim. x = gridSize; - blockDim. x = desBlockSize; - :: setConstantNeumannBC< 2, Real, Index ><<< gridDim, blockDim >>>( this -> getDimensions(). x(), - this -> getDimensions(). y(), - this -> getSpaceSteps(). x(), - this -> getSpaceSteps(). y(), - bcValue, - this -> getData() ); -#endif - } -} - -/*template< typename Real, typename Device, typename Index > -Real tnlGridOld< 2, Real, Device, Index > :: getMax() const -{ - return tnlMax( * this ); -} - -template< typename Real, typename Device, typename Index > -Real tnlGridOld< 2, Real, Device, Index > :: getMin() const -{ - return tnlMin( * this ); -} - -template< typename Real, typename Device, typename Index > -Real tnlGridOld< 2, Real, Device, Index > :: getAbsMax() const -{ - return tnlAbsMax( * this ); -} - -template< typename Real, typename Device, typename Index > -Real tnlGridOld< 2, Real, Device, Index > :: getAbsMin() const -{ - return tnlAbsMin( * this ); -}*/ - -template< typename Real, typename Device, typename Index > -Real tnlGridOld< 2, Real, Device, Index > :: getLpNorm( const Real& p ) const -{ - Real result = this -> lpNorm( p ); - return result * getSpaceSteps(). x() - * getSpaceSteps(). y(); -} - -/*template< typename Real, typename Device, typename Index > -Real tnlGridOld< 2, Real, Device, Index > :: getSum() const -{ - return tnlMultiVector< 2, Real, Device, Index > :: sum( * this ); -} - -template< typename Real, typename Device, typename Index > -Real tnlGridOld< 2, Real, Device, Index > :: getDifferenceMax( const tnlVector< Real, Device, Index >& v ) const -{ - tnlAssert( this -> getDimensions() == v. getDimensions(), - cerr << "The grid names are " << this -> getName() - << " and " << v. getName() - << "To get grids with the same parameters use the method setLike." << endl; ); - tnlAssert( this -> getDomainLoweCorner() == v. getDomainLowerCorner() && - this -> getDomainUpperCorner() == v. getDomainUpperCorner(), - cerr << "The grid names are " << this -> getName() - << " and " << v. getName() - << "To get grids with the same parameters use the method setLike." << endl; ); - return v. differenceMax( *this ); -} - -template< typename Real, typename Device, typename Index > -Real tnlGridOld< 2, Real, Device, Index > :: getDifferenceMin( const tnlVector< Real, Device, Index >& v ) const -{ - tnlAssert( this -> getDimensions() == v. getDimensions(), - cerr << "The grid names are " << this -> getName() - << " and " << v. getName() - << "To get grids with the same parameters use the method setLike." << endl; ); - tnlAssert( this -> getDomainLoweCorner() == v. getDomainLowerCorner() && - this -> getDomainUpperCorner() == v. getDomainUpperCorner(), - cerr << "The grid names are " << this -> getName() - << " and " << v. getName() - << "To get grids with the same parameters use the method setLike." << endl; ); - return v. differenceMin( *this ); -} - -template< typename Real, typename Device, typename Index > -Real tnlGridOld< 2, Real, Device, Index > :: getDifferenceAbsMax( const tnlVector< Real, Device, Index >& v ) const -{ - tnlAssert( this -> getDimensions() == v. getDimensions(), - cerr << "The grid names are " << this -> getName() - << " and " << v. getName() - << "To get grids with the same parameters use the method setLike." << endl; ); - tnlAssert( this -> getDomainLoweCorner() == v. getDomainLowerCorner() && - this -> getDomainUpperCorner() == v. getDomainUpperCorner(), - cerr << "The grid names are " << this -> getName() - << " and " << v. getName() - << "To get grids with the same parameters use the method setLike." << endl; ); - return v. differenceAbsMax( *this ); -} - -template< typename Real, typename Device, typename Index > -Real tnlGridOld< 2, Real, Device, Index > :: getDifferenceAbsMin( const tnlVector< Real, Device, Index >& v ) const -{ - tnlAssert( this -> getDimensions() == v. getDimensions(), - cerr << "The grid names are " << this -> getName() - << " and " << v. getName() - << "To get grids with the same parameters use the method setLike." << endl; ); - tnlAssert( this -> getDomainLoweCorner() == v. getDomainLowerCorner() && - this -> getDomainUpperCorner() == v. getDomainUpperCorner(), - cerr << "The grid names are " << this -> getName() - << " and " << v. getName() - << "To get grids with the same parameters use the method setLike." << endl; ); - return v. differenceAbsMin( *this ); -}*/ - -template< typename Real, typename Device, typename Index > -Real tnlGridOld< 2, Real, Device, Index > :: getDifferenceLpNorm( const tnlVector< Real, Device, Index >& v, const Real& p ) const -{ - tnlAssert( this -> getDimensions() == v. getDimensions(), - cerr << "The grid names are " << this -> getName() - << " and " << v. getName() - << "To get grids with the same parameters use the method setLike." << endl; ); - tnlAssert( this -> getDomainLoweCorner() == v. getDomainLowerCorner() && - this -> getDomainUpperCorner() == v. getDomainUpperCorner(), - cerr << "The grid names are " << this -> getName() - << " and " << v. getName() - << "To get grids with the same parameters use the method setLike." << endl; ); - - Real result = v. differenceLpNorm( * this, p ); - return result * getSpaceSteps(). x() - * getSpaceSteps(). y(); -} - -/*template< typename Real, typename Device, typename Index > -Real tnlGridOld< 2, Real, Device, Index > :: getDifferenceSum( const tnlVector< Real, Device, Index >& v ) const -{ - tnlAssert( this -> getDimensions() == v. getDimensions(), - cerr << "The grid names are " << this -> getName() - << " and " << v. getName() - << "To get grids with the same parameters use the method setLike." << endl; ); - tnlAssert( this -> getDomainLoweCorner() == v. getDomainLowerCorner() && - this -> getDomainUpperCorner() == v. getDomainUpperCorner(), - cerr << "The grid names are " << this -> getName() - << " and " << v. getName() - << "To get grids with the same parameters use the method setLike." << endl; ); - return this -> differenceSum( v ); -} - -template< typename Real, typename Device, typename Index > -void tnlGridOld< 2, Real, Device, Index > :: scalarMultiplication( const Real& alpha ) -{ - return this -> scalarMultiplication( alpha ); -} - -template< typename Real, typename Device, typename Index > -Real tnlGridOld< 2, Real, Device, Index > :: scalarProduct( const tnlVector< Real, Device, Index >& v ) const -{ - tnlAssert( this -> getDimensions() == v. getDimensions(), - cerr << "The grid names are " << this -> getName() - << " and " << v. getName() - << "To get grids with the same parameters use the method setLike." << endl; ); - tnlAssert( this -> getDomainLoweCorner() == v. getDomainLowerCorner() && - this -> getDomainUpperCorner() == v. getDomainUpperCorner(), - cerr << "The grid names are " << this -> getName() - << " and " << v. getName() - << "To get grids with the same parameters use the method setLike." << endl; ); - return this -> scalarProduct( v ); -}; - -template< typename Real, typename Device, typename Index > -void tnlGridOld< 2, Real, Device, Index > :: alphaXPlusY( const Real& alpha, - const tnlVector< Real, Device, Index >& x ) -{ - tnlAssert( this -> getDimensions() == v. getDimensions(), - cerr << "The grid names are " << this -> getName() - << " and " << v. getName() - << "To get grids with the same parameters use the method setLike." << endl; ); - tnlAssert( this -> getDomainLoweCorner() == v. getDomainLowerCorner() && - this -> getDomainUpperCorner() == v. getDomainUpperCorner(), - cerr << "The grid names are " << this -> getName() - << " and " << v. getName() - << "To get grids with the same parameters use the method setLike." << endl; ); - this -> alphaXPlusY( alpha, x ); -}; - -template< typename Real, typename Device, typename Index > -void tnlGridOld< 2, Real, Device, Index > :: saxmy( const Real& alpha, - const tnlVector< Real, Device, Index >& x ) -{ - tnlAssert( this -> getDimensions() == v. getDimensions(), - cerr << "The grid names are " << this -> getName() - << " and " << v. getName() - << "To get grids with the same parameters use the method setLike." << endl; ); - tnlAssert( this -> getDomainLoweCorner() == v. getDomainLowerCorner() && - this -> getDomainUpperCorner() == v. getDomainUpperCorner(), - cerr << "The grid names are " << this -> getName() - << " and " << v. getName() - << "To get grids with the same parameters use the method setLike." << endl; ); - this -> saxmy( alpha, x ); -};*/ - - -template< typename Real, typename Device, typename Index > -bool tnlGridOld< 2, Real, Device, Index > :: save( tnlFile& file ) const -{ - if( ! tnlMultiVector< 2, Real, Device, Index > :: save( file ) ) - { - cerr << "I was not able to write the tnlMultiVector of the tnlGridOld " - << this -> getName() << endl; - return false; - } - if( ! domainLowerCorner. save( file ) || - ! domainUpperCorner. save( file ) || - ! spaceSteps. save( file ) ) - { - cerr << "I was not able to write the domain decsription of the tnlGridOld " - << this -> getName() << endl; - return false; - } - return true; -} - -template< typename Real, typename Device, typename Index > -bool tnlGridOld< 2, Real, Device, Index > :: load( tnlFile& file ) -{ - if( ! tnlMultiVector< 2, Real, Device, Index > :: load( file ) ) - { - cerr << "I was not able to read the tnlMultiVector of the tnlGridOld " - << this -> getName() << endl; - return false; - } - if( ! domainLowerCorner. load( file ) || - ! domainUpperCorner. load( file ) || - ! spaceSteps. load( file ) ) - { - cerr << "I was not able to read the domain description of the tnlGridOld " - << this -> getName() << endl; - return false; - } - return true; -} - -template< typename Real, typename Device, typename Index > -bool tnlGridOld< 2, Real, Device, Index > :: save( const tnlString& fileName ) const -{ - return tnlObject :: save( fileName ); -} - -template< typename Real, typename Device, typename Index > -bool tnlGridOld< 2, Real, Device, Index > :: load( const tnlString& fileName ) -{ - return tnlObject :: load( fileName ); -} - -template< typename Real, typename Device, typename Index > -bool tnlGridOld< 2, Real, Device, Index > :: draw( const tnlString& fileName, - const tnlString& format, - const tnlStaticVector< 2, Index > steps ) const -{ - tnlAssert( steps > ( tnlStaticVector< 2, Index >( 0 ) ), - cerr << "Wrong steps of increment ( " << steps << " )" - << " for drawing the tnlGridOld " << this -> getName() << "." << endl; ); - if( format == "tnl" ) - return this -> save( fileName ); - fstream file; - file. open( fileName. getString(), ios :: out ); - if( ! file ) - { - cerr << " I am not able to open the file " << fileName - << " for drawing the tnlGridOld " << this -> getName() << "." << endl; - return false; - } - const Index xSize = this -> getDimensions()[ tnlX ]; - const Index ySize = this -> getDimensions()[ tnlY ]; - const Real& ax = this -> getDomainLowerCorner()[ tnlX ]; - const Real& ay = this -> getDomainLowerCorner()[ tnlY ]; - const Real& hx = this -> getSpaceSteps()[ tnlX ]; - const Real& hy = this -> getSpaceSteps()[ tnlY ]; - if( format == "gnuplot" ) - { - for( Index i = 0; i < xSize; i += steps[ tnlX ] ) - { - for( Index j = 0; j < ySize; j += steps[ tnlY ] ) - { - file << setprecision( 12 ) - << ax + Real( i ) * hx * steps[ tnlX ] - << " " - << ay + Real( j ) * hy * steps[ tnlY ] - << " " - << this -> getElement( i, j ) - << endl; - } - file << endl; - } - return true; - } - if( format == "vti" ) - { - file << "<VTKFile type=\"ImagegetString\" version=\"0.1\" byte_order=\"LittleEndian\">" << endl; - file << "<ImagegetString WholeExtent=\"" - << 0 << " " << xSize - 1 << " " << 0 << " " << ySize - 1 - << " 0 0\" Origin=\"0 0 0\" Spacing=\"" - << hx * steps[ tnlX ] << " " << hy * steps[ tnlY ] << " 0\">" << endl; - file << "<Piece Extent=\"0 " << xSize - 1 << " 0 " << ySize - 1 <<" 0 0\">" << endl; - file << "<PointgetString Scalars=\"order_parameter\">" << endl; - file << "<getStringArray Name=\"order_parameter\" type=\"Float32\" format=\"ascii\">" << endl; - file. flags( ios_base::scientific ); - Index iStep = steps[ tnlX ]; - Index jStep = steps[ tnlY ]; - for( Index j = 0; j <= ySize - jStep; j += jStep ) - for( Index i = 0; i <= xSize - iStep; i += iStep ) - file << this -> getElement( i, j ) << " "; - file << endl; - file << "</getStringArray>" << endl; - file << "</PointgetString>" << endl; - file << "</Piece>" << endl; - file << "</ImagegetString>" << endl; - file << "</VTKFile>" << endl; - return true; - } - cerr << endl << "I do not know a format " << format << " for tnlGridOld with 2 dimensions."; - return false; -} - -#ifdef HAVE_CUDA -template< int Dimensions, typename Real, typename Index > -__global__ void setConstantDirichletBC( const Index xSize, - const Index ySize, - const Real bc, - Real* u ) -{ - const Index ij = blockIdx. x * blockDim. x + threadIdx. x; - const Index i = ij / ySize; - const Index j = ij % ySize; - - if( ij < xSize * ySize && - ( i == 0 || j == 0 || i == xSize - 1 || j == ySize - 1 ) ) - { - u[ ij ] = bc; - } - -} - -template< int Dimensions, typename Real, typename Index > -__global__ void setDirichletBC( const Index xSize, - const Index ySize, - const Real* bc, - Real* u ) -{ - const Index ij = blockIdx. x * blockDim. x + threadIdx. x; - const Index i = ij / ySize; - const Index j = ij % ySize; - - if( ij < xSize * ySize && - ( i == 0 || j == 0 || i == xSize - 1 || j == ySize - 1 ) ) - { - u[ ij ] = bc[ ij ]; - } -} - -template< int Dimensions, typename Real, typename Index > -__global__ void setConstantNeumannBC( const Index xSize, - const Index ySize, - const Real hx, - const Real hy, - const Real bc, - Real* u ) -{ - const Index ij = blockIdx. x * blockDim. x + threadIdx. x; - const Index i = ij / ySize; - const Index j = ij % ySize; - - if( ij < xSize * ySize && - ( i == 0 || j == 0 || i == xSize - 1 || j == ySize - 1 ) ) - { - if( i == 0 ) - u[ ij ] = u[ ij + ySize ] + hx * bc; - if( i == xSize - 1 ) - u[ ij ] = u[ ij - ySize ] + hx * bc; - - __syncthreads(); - - if( j == 0 ) - u[ ij ] = u[ ij + 1 ] + hy * bc; - if( j == ySize - 1 ) - u[ ij ] = u[ ij - 1 ] + hy * bc; - } -} - -template< int Dimensions, typename Real, typename Index > -__global__ void setNeumannBC( const Index xSize, - const Index ySize, - const Real hx, - const Real hy, - const Real* bc, - Real* u ) -{ - const Index ij = blockIdx. x * blockDim. x + threadIdx. x; - const Index i = ij / ySize; - const Index j = ij % ySize; - - if( ij < xSize * ySize && - ( i == 0 || j == 0 || i == xSize - 1 || j == ySize - 1 ) ) - { - if( i == 0 ) - u[ ij ] = u[ ij + ySize ] + hx * bc[ ij ]; - if( i == xSize - 1 ) - u[ ij ] = u[ ij - ySize ] + hx * bc[ ij ]; - - __syncthreads(); - - if( j == 0 ) - u[ ij ] = u[ ij + 1 ] + hy * bc[ ij ]; - if( j == ySize - 1 ) - u[ ij ] = u[ ij - 1 ] + hy * bc[ ij ]; - } -} - -#endif - - - - -#endif /* tnlGrid2D_IMPL_H_ */ diff --git a/src/legacy/mesh/implementation/tnlGrid3D_impl.h b/src/legacy/mesh/implementation/tnlGrid3D_impl.h deleted file mode 100644 index e3d7757e7bb2b97a13eb97a8bfb4de6470d99515..0000000000000000000000000000000000000000 --- a/src/legacy/mesh/implementation/tnlGrid3D_impl.h +++ /dev/null @@ -1,1157 +0,0 @@ -/*************************************************************************** - tnlGridOld3D_impl.h - description - ------------------- - begin : Nov 22, 2012 - copyright : (C) 2012 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 tnlGridOld3D_IMPL_H_ -#define tnlGridOld3D_IMPL_H_ - -#ifdef HAVE_CUDA -/*template< int Dimensions, typename Real, typename Index > -__global__ void setConstantDirichletBC( const Index xSize, - const Index ySize, - const Real bc, - Real* u ); - -template< int Dimensions, typename Real, typename Index > -__global__ void setDirichletBC( const Index xSize, - const Index ySize, - const Real* bc, - Real* u ); - -template< int Dimensions, typename Real, typename Index > -__global__ void setConstantNeumannBC( const Index xSize, - const Index ySize, - const Real hx, - const Real hy, - const Real bc, - Real* u ); - -template< int Dimensions, typename Real, typename Index > -__global__ void setNeumannBC( const Index xSize, - const Index ySize, - const Real hx, - const Real hy, - const Real* bc, - Real* u ); -*/ -#endif - -template< typename Real, typename Device, typename Index > -tnlGridOld< 3,Real, Device, Index > :: tnlGridOld() -{ -} - -template< typename Real, typename Device, typename Index > -tnlGridOld< 3,Real, Device, Index > :: tnlGridOld( const tnlString& name ) -{ - this -> setName( name ); -} - -template< typename Real, typename Device, typename Index > -tnlGridOld< 3,Real, Device, Index > :: tnlGridOld( const tnlString& name, - const tnlGridOld< 3,Real, tnlHost, Index >& grid ) -{ - this -> setName( name ); - this -> setLike( grid ); -} - -template< typename Real, typename Device, typename Index > -tnlGridOld< 3,Real, Device, Index > :: tnlGridOld( const tnlString& name, - const tnlGridOld< 3,Real, tnlCuda, Index >& grid ) -{ - this -> setName( name ); - this -> setLike( grid ); -} - -template< typename Real, typename Device, typename Index > -const tnlStaticVector< 3,Index >& tnlGridOld< 3,Real, Device, Index > :: getDimensions() const -{ - return tnlMultiVector< 3,Real, Device, Index > :: getDimensions(); -} - -template< typename Real, typename Device, typename Index > -bool tnlGridOld< 3,Real, Device, Index > :: setDimensions( const tnlStaticVector< 3,Index >& dimensions ) -{ - if( ! tnlMultiVector< 3,Real, Device, Index > :: setDimensions( dimensions ) ) - return false; - spaceSteps[ 0 ] = ( domainUpperCorner[ 0 ] - domainLowerCorner[ 0 ] ) / ( Real ) ( this -> getDimensions()[ 0 ] - 1 ); - spaceSteps[ 1 ] = ( domainUpperCorner[ 1 ] - domainLowerCorner[ 1 ] ) / ( Real ) ( this -> getDimensions()[ 1 ] - 1 ); - spaceSteps[ 2 ] = ( domainUpperCorner[ 2 ] - domainLowerCorner[ 2 ] ) / ( Real ) ( this -> getDimensions()[ 2 ] - 1 ); - return true; -} - -template< typename Real, typename Device, typename Index > -bool tnlGridOld< 3,Real, Device, Index > :: setDomain( const tnlStaticVector< 3,Real >& origin, - const tnlStaticVector< 3,Real >& proportions ) -{ - if( origin >= proportions ) - { - cerr << "Wrong parameters for the grid domain of " << this -> getName() << ". The low corner must by smaller than the high corner." << endl - << "origin = " << origin << endl << "proportions = " << proportions << endl; - return false; - } - domainLowerCorner = origin; - domainUpperCorner = proportions; - spaceSteps[ 0 ] = ( domainUpperCorner[ 0 ] - domainLowerCorner[ 0 ] ) / ( Real ) ( this -> getDimensions()[ 0 ] - 1 ); - spaceSteps[ 1 ] = ( domainUpperCorner[ 1 ] - domainLowerCorner[ 1 ] ) / ( Real ) ( this -> getDimensions()[ 1 ] - 1 ); - spaceSteps[ 2 ] = ( domainUpperCorner[ 2 ] - domainLowerCorner[ 2 ] ) / ( Real ) ( this -> getDimensions()[ 2 ] - 1 ); - return true; -} - -template< typename Real, typename Device, typename Index > - template< typename Grid > -bool tnlGridOld< 3,Real, Device, Index > :: setLike( const Grid& v ) -{ - return tnlMultiVector< 3,Real, Device, Index > :: setLike( v ) && - this -> setDomain( v. getDomainLowerCorner(), v. getDomainUpperCorner() ); -} - -template< typename Real, typename Device, typename Index > -const tnlStaticVector< 3,Real >& tnlGridOld< 3,Real, Device, Index > :: getDomainLowerCorner() const -{ - return this -> domainLowerCorner; -} - -template< typename Real, typename Device, typename Index > -const tnlStaticVector< 3,Real >& tnlGridOld< 3,Real, Device, Index > :: getDomainUpperCorner() const -{ - return this -> domainUpperCorner; -} - -template< typename Real, typename Device, typename Index > -const tnlStaticVector< 3,Real >& tnlGridOld< 3,Real, Device, Index > :: getSpaceSteps() const -{ - return spaceSteps; -} - -template< typename Real, typename Device, typename Index > -tnlString tnlGridOld< 3,Real, Device, Index > :: getType() const -{ - return tnlString( "tnlGridOld< ") + - tnlString( "3" ) + - tnlString( ", " ) + - tnlString( ::getType< Real >() ) + - tnlString( ", " ) + - Device :: getDeviceType() + - tnlString( ", " ) + - tnlString( ::getType< Index >() ) + - tnlString( " >" ); -} - -template< typename Real, typename Device, typename Index > -bool tnlGridOld< 3,Real, Device, Index > :: operator == ( const tnlGridOld< 3,Real, Device, Index >& grid ) const -{ - tnlAssert( this -> getDomainLowerCorner() == grid. getDomainLowerCorner() && - this -> getDomainUpperCorner() == grid. getDomainUpperCorner(), - cerr << "You are attempting to compare two grids with different domains." << endl - << "First grid name is " << this -> getName() - << " domain is ( " << this -> getDomainLowerCorner() << " )- (" - << this -> getDomainUpperCorner() << ")" << endl - << "Second grid is " << grid. getName() - << " domain is ( " << grid. getDomainLowerCorner() << " )- (" - << grid. getDomainUpperCorner() << ")" << endl; ); - return tnlMultiVector< 3,Real, Device, Index > :: operator == ( grid ); -} - -template< typename Real, typename Device, typename Index > -bool tnlGridOld< 3,Real, Device, Index > :: operator != ( const tnlGridOld< 3,Real, Device, Index >& grid ) const -{ - return ! ( (* this ) == grid ); -} - -template< typename Real, typename Device, typename Index > - template< typename Real2, typename Device2, typename Index2 > -tnlGridOld< 3,Real, Device, Index >& -tnlGridOld< 3,Real, Device, Index > -:: operator = ( const tnlGridOld< 3,Real2, Device2, Index2 >& grid ) -{ - tnlAssert( this -> getDimensions() == grid. getDimensions(), - cerr << "You are attempting to assign two arrays with different dimensions." << endl - << "First array name is " << this -> getName() - << " dimensions are ( " << this -> getDimensions() << " )" << endl - << "Second array is " << grid. getName() - << " dimensions are ( " << grid. getDimensions() << " )" << endl; ); - tnlVector< Real, Device, Index > :: operator = ( grid ); - return ( *this ); -} - -template< typename Real, typename Device, typename Index > -Real tnlGridOld< 3,Real, Device, Index > :: getValue( const tnlStaticVector< 3,Real >& point ) const -{ - tnlAssert( 0, cerr << "Interpolation is not implemented yet."); -} - -template< typename Real, typename Device, typename Index > -Real tnlGridOld< 3,Real, Device, Index > :: getValue( const Real& x, - const Real& y, - const Real& z ) const -{ - return this -> getValue( tnlStaticVector< 3, Real >( x, y, z ) ); -} - - -template< typename Real, typename Device, typename Index > -Real tnlGridOld< 3,Real, Device, Index > :: Partial_x_f( const Index i1, - const Index i2, - const Index i3 ) const -{ - tnlAssert( i1 >= 0 && i2 >= 0 && i3 >= 0 && - i1 < this -> getDimensions()[ tnlX ] - 1 && - i2 <= this -> getDimensions()[ tnlY ] - 1 && - i3 <= this -> getDimensions()[ tnlZ ] - 1, - cerr << " i1 = " << i1 << " and it should be in [ 0, " << - ( this -> getDimensions()[ tnlX ] - 1 ) << " ) " << endl - << " i2 = " << i2 << " and it should be in [ 0, " << - ( this -> getDimensions()[ tnlY ] - 1 ) << " ] " << endl - << " i3 = " << i3 << " and it should be in [ 0, " << - ( this -> getDimensions()[ tnlZ ] - 1 ) << " ] " << endl; ); - - const Real& Hx = spaceSteps[ 0 ]; - tnlAssert( Hx > 0, cerr << "Hx = " << Hx << endl; ); - return ( this -> getElement( i1 + 1, i2, i3 ) - - this -> getElement( i1, i2, i3 ) ) / Hx; -}; - -template< typename Real, typename Device, typename Index > -Real tnlGridOld< 3,Real, Device, Index > :: Partial_x_b( const Index i1, - const Index i2, - const Index i3 ) const -{ - tnlAssert( i1 > 0 && i2 >= 0 && i3 >= 0 && - i1 <= this -> getDimensions()[ tnlX ] - 1 && - i2 <= this -> getDimensions()[ tnlY ] - 1 && - i3 <= this -> getDimensions()[ tnlZ ] - 1, - cerr << " i1 = " << i1 << " and it should be in ( 0, " << - ( this -> getDimensions()[ tnlX ] - 1 ) << " ] " << endl - << " i2 = " << i2 << " and it should be in [ 0, " << - ( this -> getDimensions()[ tnlY ] - 1 ) << " ] " << endl - << " i3 = " << i3 << " and it should be in [ 0, " << - ( this -> getDimensions()[ tnlZ ] - 1 ) << " ] " << endl; ); - - const Real& Hx = spaceSteps[ 0 ]; - tnlAssert( Hx > 0, cerr << "Hx = " << Hx << endl; ); - return ( this -> getElement( i1, i2, i3 ) - - this -> getElement( i1 - 1, i2, i3 ) ) / Hx; -}; - -template< typename Real, typename Device, typename Index > -Real tnlGridOld< 3,Real, Device, Index > :: Partial_x( const Index i1, - const Index i2, - const Index i3 ) const -{ - tnlAssert( i1 > 0 && i2 >= 0 && i3 >= 0 && - i1 < this -> getDimensions()[ tnlX ] - 1 && - i2 <= this -> getDimensions()[ tnlY ] - 1 && - i3 <= this -> getDimensions()[ tnlZ ] - 1, - cerr << " i1 = " << i1 << " and it should be in ( 0, " << - ( this -> getDimensions()[ tnlX ] - 1 ) << " ) " << endl - << " i2 = " << i2 << " and it should be in [ 0, " << - ( this -> getDimensions()[ tnlY ] - 1 ) << " ] " << endl - << " i3 = " << i3 << " and it should be in [ 0, " << - ( this -> getDimensions()[ tnlZ ] - 1 ) << " ] " << endl; ); - - const Real& Hx = spaceSteps[ 0 ]; - tnlAssert( Hx > 0, cerr << "Hx = " << Hx << endl; ); - return ( this -> getElement( i1 + 1, i2, i3 ) - - this -> getElement( i1 - 1, i2, i3 ) ) / ( 2.0 * Hx ); -}; - -template< typename Real, typename Device, typename Index > -Real tnlGridOld< 3,Real, Device, Index > :: Partial_xx( const Index i1, - const Index i2, - const Index i3 ) const -{ - tnlAssert( i1 > 0 && i2 >= 0 && i3 >= 0 && - i1 < this -> getDimensions()[ tnlX ] - 1 && - i2 <= this -> getDimensions()[ tnlY ] - 1 && - i3 <= this -> getDimensions()[ tnlZ ] - 1, - cerr << " i1 = " << i1 << " and it should be in ( 0, " << - ( this -> getDimensions()[ tnlX ] - 1 ) << " ) " << endl - << " i2 = " << i2 << " and it should be in [ 0, " << - ( this -> getDimensions()[ tnlY ] - 1 ) << " ] " << endl - << " i3 = " << i3 << " and it should be in [ 0, " << - ( this -> getDimensions()[ tnlZ ] - 1 ) << " ] " << endl; ); - - const Real& Hx = spaceSteps[ 0 ]; - tnlAssert( Hx > 0, cerr << "Hx = " << Hx << endl; ); - return ( this -> getElement( i1 + 1, i2, i3 ) - - 2.0 * this -> getElement( i1, i2, i3 ) + - this -> getElement( i1 - 1, i2, i3 ) ) / ( Hx * Hx ); -}; - -template< typename Real, typename Device, typename Index > -Real tnlGridOld< 3,Real, Device, Index > :: Partial_y_f( const Index i1, - const Index i2, - const Index i3 ) const -{ - tnlAssert( i1 >= 0 && i2 >= 0 && i3 >= 0 && - i1 <= this -> getDimensions()[ tnlX ] - 1 && - i2 < this -> getDimensions()[ tnlY ] - 1 && - i3 <= this -> getDimensions()[ tnlZ ] - 1, - cerr << " i1 = " << i1 << " and it should be in [ 0, " << - ( this -> getDimensions()[ tnlX ] - 1 ) << " ] " << endl - << " i2 = " << i2 << " and it should be in [ 0, " << - ( this -> getDimensions()[ tnlY ] - 1 ) << " ) " << endl - << " i3 = " << i3 << " and it should be in [ 0, " << - ( this -> getDimensions()[ tnlZ ] - 1 ) << " ] " << endl; ); - - const Real& Hy = spaceSteps[ 1 ]; - tnlAssert( Hy > 0, cerr << "Hy = " << Hy << endl; ); - return ( this -> getElement( i1, i2 + 1, i3 ) - - this -> getElement( i1, i2, i3 ) ) / Hy; -}; - -template< typename Real, typename Device, typename Index > -Real tnlGridOld< 3,Real, Device, Index > :: Partial_y_b( const Index i1, - const Index i2, - const Index i3 ) const -{ - tnlAssert( i1 >= 0 && i2 > 0 && i3 >= 0 && - i1 <= this -> getDimensions()[ tnlX ] - 1 && - i2 <= this -> getDimensions()[ tnlY ] - 1 && - i3 <= this -> getDimensions()[ tnlZ ] - 1, - cerr << " i1 = " << i1 << " and it should be in [ 0, " << - ( this -> getDimensions()[ tnlX ] - 1 ) << " ] " << endl - << " i2 = " << i2 << " and it should be in ( 0, " << - ( this -> getDimensions()[ tnlY ] - 1 ) << " ] " << endl - << " i3 = " << i3 << " and it should be in [ 0, " << - ( this -> getDimensions()[ tnlZ ] - 1 ) << " ] " << endl; ); - - const Real& Hy = spaceSteps[ 1 ]; - tnlAssert( Hy > 0, cerr << "Hy = " << Hy << endl; ); - return ( this -> getElement( i1, i2, i3 ) - - this -> getElement( i1, i2 - 1, i3 ) ) / Hy; -}; - -template< typename Real, typename Device, typename Index > -Real tnlGridOld< 3,Real, Device, Index > :: Partial_y( const Index i1, - const Index i2, - const Index i3 ) const -{ - tnlAssert( i1 >= 0 && i2 > 0 && i3 >= 0 && - i1 <= this -> getDimensions()[ tnlX ] - 1 && - i2 < this -> getDimensions()[ tnlY ] - 1 && - i3 <= this -> getDimensions()[ tnlZ ] - 1, - cerr << " i1 = " << i1 << " and it should be in [ 0, " << - ( this -> getDimensions()[ tnlX ] - 1 ) << " ] " << endl - << " i2 = " << i2 << " and it should be in ( 0, " << - ( this -> getDimensions()[ tnlY ] - 1 ) << " ) " << endl - << " i3 = " << i3 << " and it should be in [ 0, " << - ( this -> getDimensions()[ tnlZ ] - 1 ) << " ] " << endl; ); - - const Real& Hy = spaceSteps[ 1 ]; - tnlAssert( Hy > 0, cerr << "Hy = " << Hy << endl; ); - return ( this -> getElement( i1, i2 + 1, i3 ) - - this -> getElement( i1, i2 - 1, i3 ) ) / ( 2.0 * Hy ); -}; - -template< typename Real, typename Device, typename Index > -Real tnlGridOld< 3,Real, Device, Index > :: Partial_yy( const Index i1, - const Index i2, - const Index i3 ) const -{ - tnlAssert( i1 >= 0 && i2 > 0 && i3 >= 0 && - i1 <= this -> getDimensions()[ tnlX ] - 1 && - i2 < this -> getDimensions()[ tnlY ] - 1 && - i3 <= this -> getDimensions()[ tnlZ ] - 1, - cerr << " i1 = " << i1 << " and it should be in [ 0, " << - ( this -> getDimensions()[ tnlX ] - 1 ) << " ] " << endl - << " i2 = " << i2 << " and it should be in ( 0, " << - ( this -> getDimensions()[ tnlY ] - 1 ) << " ) " << endl - << " i3 = " << i3 << " and it should be in [ 0, " << - ( this -> getDimensions()[ tnlZ ] - 1 ) << " ] " << endl; ); - - const Real& Hy = spaceSteps[ 1 ]; - tnlAssert( Hy > 0, cerr << "Hy = " << Hy << endl; ); - return ( this -> getElement( i1, i2 + 1, i3 ) - - 2.0 * this -> getElement( i1, i2, i3 ) + - this -> getElement( i1, i2 - 1, i3 ) ) / ( Hy * Hy ); -}; - -template< typename Real, typename Device, typename Index > -Real tnlGridOld< 3,Real, Device, Index > :: Partial_z_f( const Index i1, - const Index i2, - const Index i3 ) const -{ - tnlAssert( i1 >= 0 && i2 >= 0 && i3 >= 0 && - i1 <= this -> getDimensions()[ tnlX ] - 1 && - i2 <= this -> getDimensions()[ tnlY ] - 1 && - i3 < this -> getDimensions()[ tnlZ ] - 1, - cerr << " i1 = " << i1 << " and it should be in [ 0, " << - ( this -> getDimensions()[ tnlX ] - 1 ) << " ] " << endl - << " i2 = " << i2 << " and it should be in [ 0, " << - ( this -> getDimensions()[ tnlY ] - 1 ) << " ] " << endl - << " i3 = " << i3 << " and it should be in [ 0, " << - ( this -> getDimensions()[ tnlZ ] - 1 ) << " ) " << endl; ); - - const Real& Hz = spaceSteps[ 2 ]; - tnlAssert( Hz > 0, cerr << "Hz = " << Hz << endl; ); - return ( this -> getElement( i1, i2, i3 + 1 ) - - this -> getElement( i1, i2, i3 ) ) / Hz; -}; - -template< typename Real, typename Device, typename Index > -Real tnlGridOld< 3,Real, Device, Index > :: Partial_z_b( const Index i1, - const Index i2, - const Index i3 ) const -{ - tnlAssert( i1 >= 0 && i2 >= 0 && i3 > 0 && - i1 <= this -> getDimensions()[ tnlX ] - 1 && - i2 <= this -> getDimensions()[ tnlY ] - 1 && - i3 <= this -> getDimensions()[ tnlZ ] - 1, - cerr << " i1 = " << i1 << " and it should be in [ 0, " << - ( this -> getDimensions()[ tnlX ] - 1 ) << " ] " << endl - << " i2 = " << i2 << " and it should be in [ 0, " << - ( this -> getDimensions()[ tnlY ] - 1 ) << " ] " << endl - << " i3 = " << i3 << " and it should be in ( 0, " << - ( this -> getDimensions()[ tnlZ ] - 1 ) << " ] " << endl; ); - - const Real& Hz = spaceSteps[ 2 ]; - tnlAssert( Hz > 0, cerr << "Hz = " << Hz << endl; ); - return ( this -> getElement( i1, i2, i3 ) - - this -> getElement( i1, i2, i3 - 1 ) ) / Hz; -}; - -template< typename Real, typename Device, typename Index > -Real tnlGridOld< 3,Real, Device, Index > :: Partial_z( const Index i1, - const Index i2, - const Index i3 ) const -{ - tnlAssert( i1 >= 0 && i2 >= 0 && i3 > 0 && - i1 <= this -> getDimensions()[ tnlX ] - 1 && - i2 <= this -> getDimensions()[ tnlY ] - 1 && - i3 < this -> getDimensions()[ tnlZ ] - 1, - cerr << " i1 = " << i1 << " and it should be in [ 0, " << - ( this -> getDimensions()[ tnlX ] - 1 ) << " ] " << endl - << " i2 = " << i2 << " and it should be in [ 0, " << - ( this -> getDimensions()[ tnlY ] - 1 ) << " ] " << endl - << " i3 = " << i3 << " and it should be in ( 0, " << - ( this -> getDimensions()[ tnlZ ] - 1 ) << " ) " << endl; ); - - const Real& Hz = spaceSteps[ 2 ]; - tnlAssert( Hz > 0, cerr << "Hz = " << Hz << endl; ); - return ( this -> getElement( i1, i2, i3 + 1 ) - - this -> getElement( i1, i2, i3 - 1 ) ) / ( 2.0 * Hz ); -}; - -template< typename Real, typename Device, typename Index > -Real tnlGridOld< 3,Real, Device, Index > :: Partial_zz( const Index i1, - const Index i2, - const Index i3 ) const -{ - tnlAssert( i1 >= 0 && i2 >= 0 && i3 > 0 && - i1 <= this -> getDimensions()[ tnlX ] - 1 && - i2 <= this -> getDimensions()[ tnlY ] - 1 && - i3 < this -> getDimensions()[ tnlZ ] - 1, - cerr << " i1 = " << i1 << " and it should be in [ 0, " << - ( this -> getDimensions()[ tnlX ] - 1 ) << " ] " << endl - << " i2 = " << i2 << " and it should be in [ 0, " << - ( this -> getDimensions()[ tnlY ] - 1 ) << " ] " << endl - << " i3 = " << i3 << " and it should be in ( 0, " << - ( this -> getDimensions()[ tnlZ ] - 1 ) << " ) " << endl; ); - - const Real& Hz = spaceSteps[ 2 ]; - tnlAssert( Hz > 0, cerr << "Hz = " << Hz << endl; ); - return ( this -> getElement( i1, i2, i3 + 1 ) - - 2.0 * this -> getElement( i1, i2, i3 ) + - this -> getElement( i1, i2, i3 - 1 ) ) / ( Hz * Hz ); -}; - -template< typename Real, typename Device, typename Index > -void tnlGridOld< 3,Real, Device, Index > :: setDirichletBC( const tnlGridOld< 3,Real, Device, Index >&bc, - const tnlStaticVector< 3,bool >& lowerBC, - const tnlStaticVector< 3,bool >& upperBC ) -{ - if( Device :: getDevice() == tnlHostDevice ) - { - const Index xSize = this -> getDimensions(). x(); - const Index ySize = this -> getDimensions(). y(); - const Index zSize = this -> getDimensions(). z(); - Index i, j, k; - - if( lowerBC. x() ) - for( i = 0; i < xSize; i ++ ) - for( k = 0; k < zSize; k ++ ) - ( *this )( i, 0, k ) = bc( i, 0, k ); - - if( upperBC. x() ) - for( i = 0; i < xSize; i ++ ) - for( k = 0; k < zSize; k ++ ) - ( *this )( i, ySize - 1, k ) = ( i, ySize - 1, k ); - - if( lowerBC. y() ) - for( j = 0; j < ySize; j ++ ) - for( k = 0; k < zSize; k ++ ) - ( *this )( 0, j, k ) = bc( 0, j, k ); - - if( upperBC. y() ) - for( j = 0; j < ySize; j ++ ) - for( k = 0; k < zSize; k ++ ) - ( *this )( xSize - 1, j, k ) = bc( xSize - 1, j, k ); - - if( lowerBC. z() ) - for( i = 0; i < xSize; i ++ ) - for( j = 0; j < ySize; j ++ ) - ( *this )( i, j, 0 ) = bc( i, j, 0 ); - - if( upperBC. z() ) - for( i = 0; i < xSize; i ++ ) - for( j = 0; j < ySize; j ++ ) - ( *this )( i, j, zSize - 1 ) = bc( i, j, zSize - 1 ); - } - if( Device :: getDevice() == tnlCudaDevice ) - { -#ifdef HAVE_CUDA - tnlAssert( false, ); - /*const Index size = this -> getSize(); - const Index desBlockSize = 64; - const Index gridSize = size / desBlockSize + ( size % desBlockSize != 0 ); - dim3 gridDim( 0 ), blockDim( 0 ); - gridDim. x = gridSize; - blockDim. x = desBlockSize; - :: setDirichletBC< 3,Real, Index ><<< gridDim, blockDim >>>( this -> getDimensions(). x(), - this -> getDimensions(). y(), - bc. getData(), - this -> getData() );*/ - -#endif - } -} - -template< typename Real, typename Device, typename Index > -void tnlGridOld< 3,Real, Device, Index > :: setDirichletBC( const Real& bcValue, - const tnlStaticVector< 3,bool >& lowerBC, - const tnlStaticVector< 3,bool >& upperBC ) -{ - if( Device :: getDevice() == tnlHostDevice ) - { - const Index xSize = this -> getDimensions(). x(); - const Index ySize = this -> getDimensions(). y(); - const Index zSize = this -> getDimensions(). z(); - Index i, j, k; - - if( lowerBC. x() ) - for( i = 0; i < xSize; i ++ ) - for( k = 0; k < zSize; k ++ ) - ( *this )( i, 0, k ) = bcValue; - - if( upperBC. x() ) - for( i = 0; i < xSize; i ++ ) - for( k = 0; k < zSize; k ++ ) - ( *this )( i, ySize - 1, k ) = bcValue; - - if( lowerBC. y() ) - for( j = 0; j < ySize; j ++ ) - for( k = 0; k < zSize; k ++ ) - ( *this )( 0, j, k ) = bcValue; - - if( upperBC. y() ) - for( j = 0; j < ySize; j ++ ) - for( k = 0; k < zSize; k ++ ) - ( *this )( xSize - 1, j, k ) = bcValue; - - if( lowerBC. z() ) - for( i = 0; i < xSize; i ++ ) - for( j = 0; j < ySize; j ++ ) - ( *this )( i, j, 0 ) = bcValue; - - if( upperBC. z() ) - for( i = 0; i < xSize; i ++ ) - for( j = 0; j < ySize; j ++ ) - ( *this )( i, j, zSize - 1 ) = bcValue; - } - if( Device :: getDevice() == tnlCudaDevice ) - { -#ifdef HAVE_CUDA - const Index size = this -> getSize(); - const Index desBlockSize = 64; - const Index gridSize = size / desBlockSize + ( size % desBlockSize != 0 ); - dim3 gridDim( 0 ), blockDim( 0 ); - gridDim. x = gridSize; - blockDim. x = desBlockSize; - :: setConstantDirichletBC< 3,Real, Index ><<< gridDim, blockDim >>>( this -> getDimensions(). x(), - this -> getDimensions(). y(), - bcValue, - this -> getData() ); -#endif - } -} - -template< typename Real, typename Device, typename Index > -void tnlGridOld< 3,Real, Device, Index > :: setNeumannBC( const tnlGridOld< 3,Real, Device, Index >&bc, - const tnlStaticVector< 3,bool >& lowerBC, - const tnlStaticVector< 3,bool >& upperBC ) -{ - if( Device :: getDevice() == tnlHostDevice ) - { - const Real& hx = this -> getSpaceSteps(). x(); - const Real& hy = this -> getSpaceSteps(). y(); - const Real& hz = this -> getSpaceSteps(). z(); - - const Index xSize = this -> getDimensions(). x(); - const Index ySize = this -> getDimensions(). y(); - const Index zSize = this -> getDimensions(). z(); - Index i, j, k; - - if( lowerBC. x() ) - for( i = 0; i < xSize; i ++ ) - for( k = 0; k < zSize; k ++ ) - ( *this )( i, 0, k ) = ( *this )( i, 1, k ) + hy * bc. getElement( i, 0, k ); - if( upperBC. x() ) - for( i = 0; i < xSize; i ++ ) - for( k = 0; k < zSize; k ++ ) - ( *this )( i, ySize - 1, k ) = ( *this )( i, ySize - 2, k ) + hy * bc( i, ySize - 1, k ); - - if( lowerBC. y() ) - for( j = 0; j < ySize; j ++ ) - for( k = 0; k < zSize; k ++ ) - ( *this )( 0, j, k ) = ( *this )( 1, j, k ) + hx * bc( 0, j, k ); - - if( upperBC. y() ) - for( j = 0; j < ySize; j ++ ) - for( k = 0; k < zSize; k ++ ) - ( *this )( xSize - 1, j, k ) = ( *this )( xSize - 2, j, k ) + hx * bc( xSize - 1, j, k ); - - if( lowerBC. z() ) - for( i = 0; i < xSize; i ++ ) - for( j = 0; j < ySize; j ++ ) - ( *this )( i, j, 0 ) = ( *this )( i, j, 1 ) + hz * bc( i, j, 0 ); - - if( upperBC. z() ) - for( i = 0; i < xSize; i ++ ) - for( j = 0; j < ySize; j ++ ) - ( *this )( i, j, zSize - 1 ) = ( *this )( i, j, zSize - 2 ) + hz * bc( i, j, zSize - 1 ); - } - if( Device :: getDevice() == tnlCudaDevice ) - { -#ifdef HAVE_CUDA - /* - const Index size = this -> getSize(); - const Index desBlockSize = 64; - const Index gridSize = size / desBlockSize + ( size % desBlockSize != 0 ); - dim3 gridDim( 0 ), blockDim( 0 ); - gridDim. x = gridSize; - blockDim. x = desBlockSize; - ::setNeumannBC< 3,Real, Index ><<< gridDim, blockDim >>>( this -> getDimensions(). x(), - this -> getDimensions(). y(), - this -> getSpaceSteps(). x(), - this -> getSpaceSteps(). y(), - bc. getData(), - this -> getData() ); - */ -#endif - } -} - -template< typename Real, typename Device, typename Index > -void tnlGridOld< 3,Real, Device, Index > :: setNeumannBC( const Real& bcValue, - const tnlStaticVector< 3,bool >& lowerBC, - const tnlStaticVector< 3,bool >& upperBC ) -{ - if( Device :: getDevice() == tnlHostDevice ) - { - const Real& hx = this -> getSpaceSteps(). x(); - const Real& hy = this -> getSpaceSteps(). y(); - const Real& hz = this -> getSpaceSteps(). z(); - - const Index xSize = this -> getDimensions(). x(); - const Index ySize = this -> getDimensions(). y(); - const Index zSize = this -> getDimensions(). z(); - Index i, j, k; - - if( lowerBC. x() ) - for( i = 0; i < xSize; i ++ ) - for( k = 0; k < zSize; k ++ ) - ( *this )( i, 0, k ) = ( *this )( i, 1, k ) + hy * bcValue; - if( upperBC. x() ) - for( i = 0; i < xSize; i ++ ) - for( k = 0; k < zSize; k ++ ) - ( *this )( i, ySize - 1, k ) = ( *this )( i, ySize - 2, k ) + hy * bcValue; - - if( lowerBC. y() ) - for( j = 0; j < ySize; j ++ ) - for( k = 0; k < zSize; k ++ ) - ( *this )( 0, j, k ) = ( *this )( 1, j, k ) + hx * bcValue; - - if( upperBC. y() ) - for( j = 0; j < ySize; j ++ ) - for( k = 0; k < zSize; k ++ ) - ( *this )( xSize - 1, j, k ) = ( *this )( xSize - 2, j, k ) + hx * bcValue; - - if( lowerBC. z() ) - for( i = 0; i < xSize; i ++ ) - for( j = 0; j < ySize; j ++ ) - ( *this )( i, j, 0 ) = ( *this )( i, j, 1 ) + hz * bcValue; - - if( upperBC. z() ) - for( i = 0; i < xSize; i ++ ) - for( j = 0; j < ySize; j ++ ) - ( *this )( i, j, zSize - 1 ) = ( *this )( i, j, zSize - 2 ) + hz * bcValue; - } - if( Device :: getDevice() == tnlCudaDevice ) - { -#ifdef HAVE_CUDA - const Index size = this -> getSize(); - const Index desBlockSize = 64; - const Index gridSize = size / desBlockSize + ( size % desBlockSize != 0 ); - dim3 gridDim( 0 ), blockDim( 0 ); - gridDim. x = gridSize; - blockDim. x = desBlockSize; - :: setConstantNeumannBC< 3,Real, Index ><<< gridDim, blockDim >>>( this -> getDimensions(). x(), - this -> getDimensions(). y(), - this -> getSpaceSteps(). x(), - this -> getSpaceSteps(). y(), - bcValue, - this -> getData() ); -#endif - } -} - -/*template< typename Real, typename Device, typename Index > -Real tnlGridOld< 3,Real, Device, Index > :: getMax() const -{ - return tnlMax( * this ); -} - -template< typename Real, typename Device, typename Index > -Real tnlGridOld< 3,Real, Device, Index > :: getMin() const -{ - return tnlMin( * this ); -} - -template< typename Real, typename Device, typename Index > -Real tnlGridOld< 3,Real, Device, Index > :: getAbsMax() const -{ - return tnlAbsMax( * this ); -} - -template< typename Real, typename Device, typename Index > -Real tnlGridOld< 3,Real, Device, Index > :: getAbsMin() const -{ - return tnlAbsMin( * this ); -}*/ - -template< typename Real, typename Device, typename Index > -Real tnlGridOld< 3,Real, Device, Index > :: getLpNorm( const Real& p ) const -{ - Real result = this -> lpNorm( p ); - return result * getSpaceSteps(). x() - * getSpaceSteps(). y() - * getSpaceSteps(). z(); -} - -/* -template< typename Real, typename Device, typename Index > -Real tnlGridOld< 3,Real, Device, Index > :: getSum() const -{ - return tnlMultiVector< 3,Real, Device, Index > :: sum( * this ); -} - -template< typename Real, typename Device, typename Index > -Real tnlGridOld< 3,Real, Device, Index > :: getDifferenceMax( const tnlVector< Real, Device, Index >& v ) const -{ - tnlAssert( this -> getDimensions() == v. getDimensions(), - cerr << "The grid names are " << this -> getName() - << " and " << v. getName() - << "To get grids with the same parameters use the method setLike." << endl; ); - tnlAssert( this -> getDomainLoweCorner() == v. getDomainLowerCorner() && - this -> getDomainUpperCorner() == v. getDomainUpperCorner(), - cerr << "The grid names are " << this -> getName() - << " and " << v. getName() - << "To get grids with the same parameters use the method setLike." << endl; ); - return v. differenceMax( *this ); -} - -template< typename Real, typename Device, typename Index > -Real tnlGridOld< 3,Real, Device, Index > :: getDifferenceMin( const tnlVector< Real, Device, Index >& v ) const -{ - tnlAssert( this -> getDimensions() == v. getDimensions(), - cerr << "The grid names are " << this -> getName() - << " and " << v. getName() - << "To get grids with the same parameters use the method setLike." << endl; ); - tnlAssert( this -> getDomainLoweCorner() == v. getDomainLowerCorner() && - this -> getDomainUpperCorner() == v. getDomainUpperCorner(), - cerr << "The grid names are " << this -> getName() - << " and " << v. getName() - << "To get grids with the same parameters use the method setLike." << endl; ); - return v. differenceMin( *this ); -} - -template< typename Real, typename Device, typename Index > -Real tnlGridOld< 3,Real, Device, Index > :: getDifferenceAbsMax( const tnlVector< Real, Device, Index >& v ) const -{ - tnlAssert( this -> getDimensions() == v. getDimensions(), - cerr << "The grid names are " << this -> getName() - << " and " << v. getName() - << "To get grids with the same parameters use the method setLike." << endl; ); - tnlAssert( this -> getDomainLoweCorner() == v. getDomainLowerCorner() && - this -> getDomainUpperCorner() == v. getDomainUpperCorner(), - cerr << "The grid names are " << this -> getName() - << " and " << v. getName() - << "To get grids with the same parameters use the method setLike." << endl; ); - return v. differenceAbsMax( *this ); -} - -template< typename Real, typename Device, typename Index > -Real tnlGridOld< 3,Real, Device, Index > :: getDifferenceAbsMin( const tnlVector< Real, Device, Index >& v ) const -{ - tnlAssert( this -> getDimensions() == v. getDimensions(), - cerr << "The grid names are " << this -> getName() - << " and " << v. getName() - << "To get grids with the same parameters use the method setLike." << endl; ); - tnlAssert( this -> getDomainLoweCorner() == v. getDomainLowerCorner() && - this -> getDomainUpperCorner() == v. getDomainUpperCorner(), - cerr << "The grid names are " << this -> getName() - << " and " << v. getName() - << "To get grids with the same parameters use the method setLike." << endl; ); - return v. differenceAbsMin( *this ); -}*/ - -template< typename Real, typename Device, typename Index > -Real tnlGridOld< 3,Real, Device, Index > :: getDifferenceLpNorm( const tnlVector< Real, Device, Index >& v, const Real& p ) const -{ - tnlAssert( this -> getDimensions() == v. getDimensions(), - cerr << "The grid names are " << this -> getName() - << " and " << v. getName() - << "To get grids with the same parameters use the method setLike." << endl; ); - tnlAssert( this -> getDomainLoweCorner() == v. getDomainLowerCorner() && - this -> getDomainUpperCorner() == v. getDomainUpperCorner(), - cerr << "The grid names are " << this -> getName() - << " and " << v. getName() - << "To get grids with the same parameters use the method setLike." << endl; ); - - Real result = v. differenceLpNorm( * this, p ); - return result * getSpaceSteps(). x() - * getSpaceSteps(). y() - * getSpaceSteps(). z(); -} - -/*template< typename Real, typename Device, typename Index > -Real tnlGridOld< 3,Real, Device, Index > :: getDifferenceSum( const tnlVector< Real, Device, Index >& v ) const -{ - tnlAssert( this -> getDimensions() == v. getDimensions(), - cerr << "The grid names are " << this -> getName() - << " and " << v. getName() - << "To get grids with the same parameters use the method setLike." << endl; ); - tnlAssert( this -> getDomainLoweCorner() == v. getDomainLowerCorner() && - this -> getDomainUpperCorner() == v. getDomainUpperCorner(), - cerr << "The grid names are " << this -> getName() - << " and " << v. getName() - << "To get grids with the same parameters use the method setLike." << endl; ); - return this -> differenceSum( v ); -} - -template< typename Real, typename Device, typename Index > -void tnlGridOld< 3,Real, Device, Index > :: scalarMultiplication( const Real& alpha ) -{ - return this -> scalarMultiplication( alpha ); -} - -template< typename Real, typename Device, typename Index > -Real tnlGridOld< 3,Real, Device, Index > :: scalarProduct( const tnlVector< Real, Device, Index >& v ) const -{ - tnlAssert( this -> getDimensions() == v. getDimensions(), - cerr << "The grid names are " << this -> getName() - << " and " << v. getName() - << "To get grids with the same parameters use the method setLike." << endl; ); - tnlAssert( this -> getDomainLoweCorner() == v. getDomainLowerCorner() && - this -> getDomainUpperCorner() == v. getDomainUpperCorner(), - cerr << "The grid names are " << this -> getName() - << " and " << v. getName() - << "To get grids with the same parameters use the method setLike." << endl; ); - return this -> scalarProduct( v ); -}; - -template< typename Real, typename Device, typename Index > -void tnlGridOld< 3,Real, Device, Index > :: alphaXPlusY( const Real& alpha, - const tnlVector< Real, Device, Index >& x ) -{ - tnlAssert( this -> getDimensions() == v. getDimensions(), - cerr << "The grid names are " << this -> getName() - << " and " << v. getName() - << "To get grids with the same parameters use the method setLike." << endl; ); - tnlAssert( this -> getDomainLoweCorner() == v. getDomainLowerCorner() && - this -> getDomainUpperCorner() == v. getDomainUpperCorner(), - cerr << "The grid names are " << this -> getName() - << " and " << v. getName() - << "To get grids with the same parameters use the method setLike." << endl; ); - this -> alphaXPlusY( alpha, x ); -}; - -template< typename Real, typename Device, typename Index > -void tnlGridOld< 3,Real, Device, Index > :: saxmy( const Real& alpha, - const tnlVector< Real, Device, Index >& x ) -{ - tnlAssert( this -> getDimensions() == v. getDimensions(), - cerr << "The grid names are " << this -> getName() - << " and " << v. getName() - << "To get grids with the same parameters use the method setLike." << endl; ); - tnlAssert( this -> getDomainLoweCorner() == v. getDomainLowerCorner() && - this -> getDomainUpperCorner() == v. getDomainUpperCorner(), - cerr << "The grid names are " << this -> getName() - << " and " << v. getName() - << "To get grids with the same parameters use the method setLike." << endl; ); - this -> saxmy( alpha, x ); -};*/ - - -template< typename Real, typename Device, typename Index > -bool tnlGridOld< 3,Real, Device, Index > :: save( tnlFile& file ) const -{ - if( ! tnlMultiVector< 3,Real, Device, Index > :: save( file ) ) - { - cerr << "I was not able to write the tnlMultiVector of the tnlGridOld " - << this -> getName() << endl; - return false; - } - if( ! domainLowerCorner. save( file ) || - ! domainUpperCorner. save( file ) || - ! spaceSteps. save( file ) ) - { - cerr << "I was not able to write the domain decsription of the tnlGridOld " - << this -> getName() << endl; - return false; - } - return true; -} - -template< typename Real, typename Device, typename Index > -bool tnlGridOld< 3,Real, Device, Index > :: load( tnlFile& file ) -{ - if( ! tnlMultiVector< 3,Real, Device, Index > :: load( file ) ) - { - cerr << "I was not able to read the tnlMultiVector of the tnlGridOld " - << this -> getName() << endl; - return false; - } - if( ! domainLowerCorner. load( file ) || - ! domainUpperCorner. load( file ) || - ! spaceSteps. load( file ) ) - { - cerr << "I was not able to read the domain description of the tnlGridOld " - << this -> getName() << endl; - return false; - } - return true; -} - -template< typename Real, typename Device, typename Index > -bool tnlGridOld< 3,Real, Device, Index > :: save( const tnlString& fileName ) const -{ - return tnlObject :: save( fileName ); -} - -template< typename Real, typename Device, typename Index > -bool tnlGridOld< 3,Real, Device, Index > :: load( const tnlString& fileName ) -{ - return tnlObject :: load( fileName ); -} - -template< typename Real, typename Device, typename Index > -bool tnlGridOld< 3,Real, Device, Index > :: draw( const tnlString& fileName, - const tnlString& format, - const tnlStaticVector< 3,Index > steps ) const -{ - tnlAssert( steps > ( tnlStaticVector< 3,Index >( 0 ) ), - cerr << "Wrong steps of increment ( " << steps << " )" - << " for drawing the tnlGridOld " << this -> getName() << "." << endl; ); - if( format == "tnl" ) - return this -> save( fileName ); - fstream file; - file. open( fileName. getString(), ios :: out ); - if( ! file ) - { - cerr << " I am not able to open the file " << fileName - << " for drawing the tnlGridOld " << this -> getName() << "." << endl; - return false; - } - const Index xSize = this -> getDimensions()[ tnlX ]; - const Index ySize = this -> getDimensions()[ tnlY ]; - const Index zSize = this -> getDimensions()[ tnlZ ]; - const Real& ax = this -> getDomainLowerCorner()[ tnlX ]; - const Real& ay = this -> getDomainLowerCorner()[ tnlY ]; - const Real& az = this -> getDomainLowerCorner()[ tnlZ ]; - const Real& hx = this -> getSpaceSteps()[ tnlX ]; - const Real& hy = this -> getSpaceSteps()[ tnlY ]; - const Real& hz = this -> getSpaceSteps()[ tnlZ ]; - if( format == "gnuplot" ) - { - cout << "GNUPLOT is not supported for tnlGridOld3D." << endl; - return false; - } - if( format == "vti" ) - { - file << "<VTKFile type=\"ImagegetString\" version=\"0.1\" byte_order=\"LittleEndian\">" << endl; - file << "<ImagegetString WholeExtent=\"" - << "0 " << xSize - 1 - << " 0 " << ySize - 1 - << " 0 " << zSize - 1 << "\" Origin=\"0 0 0\" Spacing=\"" - << hx * steps[ tnlX ] << " " << hy * steps[ tnlY ] << " " << hz * steps[ tnlZ ] << "\">" << endl; - file << "<Piece Extent=\"0 " - << xSize - 1 << " 0 " - << ySize - 1 << " 0 " - << zSize - 1 << "\">" << endl; - file << "<PointgetString Scalars=\"order_parameter\">" << endl; - file << "<getStringArray Name=\"order_parameter\" type=\"Float32\" format=\"ascii\">" << endl; - file. flags( ios_base::scientific ); - Index iStep = steps[ tnlX ]; - Index jStep = steps[ tnlY ]; - Index kStep = steps[ tnlZ ]; - for( Index k = 0; k <= zSize - kStep; k += kStep ) - for( Index j = 0; j <= ySize - jStep; j += jStep ) - for( Index i = 0; i <= xSize - iStep; i += iStep ) - { - file << this -> getElement( i, j, k ) << " "; - } - file << endl; - file << "</getStringArray>" << endl; - file << "</PointgetString>" << endl; - file << "</Piece>" << endl; - file << "</ImagegetString>" << endl; - file << "</VTKFile>" << endl; - return true; - } - if( format == "povray" ) - { - file. put( ( char ) ( xSize >> 8 ) ); - file. put( ( char ) ( xSize & 0xff ) ); - file. put( ( char ) ( ySize >> 8 ) ); - file. put( ( char ) ( ySize & 0xff ) ); - file. put( ( char ) ( zSize >> 8 ) ); - file. put( ( char ) ( zSize & 0xff ) ); - Real min( this -> getElement( 0, 0, 0 ) ), max( this -> getElement( 0, 0, 0 ) ); - for( Index k = 0; k < zSize; k ++ ) - for( Index j = 0; j < ySize; j ++ ) - for( Index i = 0; i < xSize; i ++ ) - { - min = Min( min, this -> getElement( i, j, k ) ); - max = Max( max, this -> getElement( i, j, k ) ); - } - - for( Index k = 0; k < zSize; k ++ ) - for( Index j = 0; j < ySize; j ++ ) - for( Index i = 0; i < xSize; i ++ ) - { - int v = Real( 255.0 ) * ( this -> getElement( i, j, k ) - min ) / ( max - min ); - file. write( ( char* ) &v, sizeof( int ) ); - } - return true; - } - cerr << endl << "I do not know a format " << format << " for tnlGridOld with 3 dimensions."; - return false; -} - -#ifdef HAVE_CUDA -/* -template< int Dimensions, typename Real, typename Index > -__global__ void setConstantDirichletBC( const Index xSize, - const Index ySize, - const Real bc, - Real* u ) -{ - const Index ij = blockIdx. x * blockDim. x + threadIdx. x; - const Index i = ij / ySize; - const Index j = ij % ySize; - - if( ij < xSize * ySize && - ( i == 0 || j == 0 || i == xSize - 1 || j == ySize - 1 ) ) - { - u[ ij ] = bc; - } - -} - -template< int Dimensions, typename Real, typename Index > -__global__ void setDirichletBC( const Index xSize, - const Index ySize, - const Real* bc, - Real* u ) -{ - const Index ij = blockIdx. x * blockDim. x + threadIdx. x; - const Index i = ij / ySize; - const Index j = ij % ySize; - - if( ij < xSize * ySize && - ( i == 0 || j == 0 || i == xSize - 1 || j == ySize - 1 ) ) - { - u[ ij ] = bc[ ij ]; - } -} - -template< int Dimensions, typename Real, typename Index > -__global__ void setConstantNeumannBC( const Index xSize, - const Index ySize, - const Real hx, - const Real hy, - const Real bc, - Real* u ) -{ - const Index ij = blockIdx. x * blockDim. x + threadIdx. x; - const Index i = ij / ySize; - const Index j = ij % ySize; - - if( ij < xSize * ySize && - ( i == 0 || j == 0 || i == xSize - 1 || j == ySize - 1 ) ) - { - if( i == 0 ) - u[ ij ] = u[ ij + ySize ] + hx * bc; - if( i == xSize - 1 ) - u[ ij ] = u[ ij - ySize ] + hx * bc; - - __syncthreads(); - - if( j == 0 ) - u[ ij ] = u[ ij + 1 ] + hy * bc; - if( j == ySize - 1 ) - u[ ij ] = u[ ij - 1 ] + hy * bc; - } -} - -template< int Dimensions, typename Real, typename Index > -__global__ void setNeumannBC( const Index xSize, - const Index ySize, - const Real hx, - const Real hy, - const Real* bc, - Real* u ) -{ - const Index ij = blockIdx. x * blockDim. x + threadIdx. x; - const Index i = ij / ySize; - const Index j = ij % ySize; - - if( ij < xSize * ySize && - ( i == 0 || j == 0 || i == xSize - 1 || j == ySize - 1 ) ) - { - if( i == 0 ) - u[ ij ] = u[ ij + ySize ] + hx * bc[ ij ]; - if( i == xSize - 1 ) - u[ ij ] = u[ ij - ySize ] + hx * bc[ ij ]; - - __syncthreads(); - - if( j == 0 ) - u[ ij ] = u[ ij + 1 ] + hy * bc[ ij ]; - if( j == ySize - 1 ) - u[ ij ] = u[ ij - 1 ] + hy * bc[ ij ]; - } -} -*/ -#endif - - - - -#endif /* tnlGrid3D_IMPL_H_ */ diff --git a/src/legacy/mesh/implementation/tnlGridOld_impl.cpp b/src/legacy/mesh/implementation/tnlGridOld_impl.cpp deleted file mode 100644 index 4caed2850ee70f5ec173e641e7a94b7c25f92b4c..0000000000000000000000000000000000000000 --- a/src/legacy/mesh/implementation/tnlGridOld_impl.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/*************************************************************************** - tnlGridOld_impl.cpp - description - ------------------- - begin : Mar 18, 2013 - copyright : (C) 2013 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. * - * * - ***************************************************************************/ - -#include <legacy/mesh/tnlGridOld.h> -/* -#ifdef TEMPLATE_EXPLICIT_INSTANTIATION - -template class tnlGridOld< 1, float, tnlHost, int >; -template class tnlGridOld< 1, double, tnlHost, int >; -template class tnlGridOld< 1, float, tnlHost, long int >; -template class tnlGridOld< 1, double, tnlHost, long int >; -template class tnlGridOld< 2, float, tnlHost, int >; -template class tnlGridOld< 2, double, tnlHost, int >; -template class tnlGridOld< 2, float, tnlHost, long int >; -template class tnlGridOld< 2, double, tnlHost, long int >; -template class tnlGridOld< 3, float, tnlHost, int >; -template class tnlGridOld< 3, double, tnlHost, int >; -template class tnlGridOld< 3, float, tnlHost, long int >; -template class tnlGridOld< 3, double, tnlHost, long int >; - -#ifdef HAVE_CUDA -#endif - -template class tnlGridOld< 1, float, tnlCuda, int >; -template class tnlGridOld< 1, double, tnlCuda, int >; -template class tnlGridOld< 1, float, tnlCuda, long int >; -template class tnlGridOld< 1, double, tnlCuda, long int >; -template class tnlGridOld< 2, float, tnlCuda, int >; -template class tnlGridOld< 2, double, tnlCuda, int >; -template class tnlGridOld< 2, float, tnlCuda, long int >; -template class tnlGridOld< 2, double, tnlCuda, long int >; -template class tnlGridOld< 3, float, tnlCuda, int >; -template class tnlGridOld< 3, double, tnlCuda, int >; -template class tnlGridOld< 3, float, tnlCuda, long int >; -template class tnlGridOld< 3, double, tnlCuda, long int >; - -#endif -*/ - - - diff --git a/src/legacy/mesh/tnlGridOld.h b/src/legacy/mesh/tnlGridOld.h deleted file mode 100644 index fbae218608a51bcf44aa562e826673e50f91218a..0000000000000000000000000000000000000000 --- a/src/legacy/mesh/tnlGridOld.h +++ /dev/null @@ -1,505 +0,0 @@ -/*************************************************************************** - tnlGridOld.h - description - ------------------- - begin : Dec 12, 2010 - copyright : (C) 2010 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 tnlGridOld_H_ -#define tnlGridOld_H_ - -#include <iomanip> -#include <fstream> -#include <core/tnlAssert.h> -#include <core/vectors/tnlMultiVector.h> -#include <core/vectors/tnlVector.h> - -using namespace std; - -template< int Dimensions, typename Real = double, typename Device = tnlHost, typename Index = int > -class tnlGridOld : public tnlMultiVector< Dimensions, Real, Device, Index > -{ -}; - -template< typename Real, typename Device, typename Index > -class tnlGridOld< 1, Real, Device, Index > : public tnlMultiVector< 1, Real, Device, Index > -{ - public: - - tnlGridOld(); - - //! We do not allow copy constructor without object name. - //tnlGridOld( const tnlGridOld< Dimensions, Real, Device, Index >& a ); - - tnlGridOld( const tnlString& name ); - - tnlGridOld( const tnlString& name, - const tnlGridOld< 1, Real, tnlHost, Index >& grid ); - - tnlGridOld( const tnlString& name, - const tnlGridOld< 1, Real, tnlCuda, Index >& grid ); - - const tnlStaticVector< 1, Index >& getDimensions() const; - - //! Sets the dimensions - /*** - * This method also must recompute space steps. It is save to call setDimensions and - * setDomain in any order. Both recompute the space steps. - */ - bool setDimensions( const tnlStaticVector< 1, Index >& dimensions ); - - //! Sets the computation domain in form of "rectangle". - /*** - * This method also must recompute space steps. It is save to call setDimensions and - * setDomain in any order. Both recompute the space steps. - */ - - bool setDomain( const tnlStaticVector< 1, Real >& lowerCorner, - const tnlStaticVector< 1, Real >& upperCorner ); - - template< typename Grid > - bool setLike( const Grid& v ); - - const tnlStaticVector< 1, Real >& getDomainLowerCorner() const; - - const tnlStaticVector< 1, Real >& getDomainUpperCorner() const; - - const tnlStaticVector< 1, Real >& getSpaceSteps() const; - - tnlString getType() const; - - bool operator == ( const tnlGridOld< 1, Real, Device, Index >& array ) const; - - bool operator != ( const tnlGridOld< 1, Real, Device, Index >& array ) const; - - template< typename Real2, typename Device2, typename Index2 > - tnlGridOld< 1, Real, Device, Index >& operator = ( const tnlGridOld< 1, Real2, Device2, Index2 >& array ); - - //! This method interpolates value at given point. - Real getValue( const tnlStaticVector< 1, Real >& point ) const; - - //! Interpolation for 1D grid. - Real getValue( const Real& x ) const; - - //! Forward difference w.r.t x - Real Partial_x_f( const Index i1 ) const; - - //! Backward difference w.r.t x - Real Partial_x_b( const Index i1 ) const; - - //! Central difference w.r.t. x - Real Partial_x( const Index i1 ) const; - - //! Second order difference w.r.t. x - Real Partial_xx( const Index i1 ) const; - - //! Set space dependent Dirichlet boundary conditions - void setDirichletBC( const tnlGridOld< 1, Real, Device, Index >&bc, - const tnlStaticVector< 1, bool >& lowerBC, - const tnlStaticVector< 1, bool >& upperBC ); - - //! Set constant Dirichlet boundary conditions - void setDirichletBC( const Real& bc, - const tnlStaticVector< 1, bool >& lowerBC, - const tnlStaticVector< 1, bool >& upperBC ); - - //! Set space dependent Neumann boundary conditions - void setNeumannBC( const tnlGridOld< 1, Real, Device, Index >&bc, - const tnlStaticVector< 1, bool >& lowerBC, - const tnlStaticVector< 1, bool >& upperBC ); - - //! Set constant Neumann boundary conditions - void setNeumannBC( const Real& bc, - const tnlStaticVector< 1, bool >& lowerBC, - const tnlStaticVector< 1, bool >& upperBC ); - - Real getLpNorm( const Real& p ) const; - - Real getDifferenceLpNorm( const tnlVector< Real, Device, Index >& v, const Real& p ) const; - - //! Method for saving the object to a file as a binary data - bool save( tnlFile& file ) const; - - //! Method for restoring the object from a file - bool load( tnlFile& file ); - - bool save( const tnlString& fileName ) const; - - bool load( const tnlString& fileName ); - - //! This method writes the grid in some format suitable for some other preprocessing. - /*! Possible formats are: - * 1) Gnuplot format (gnuplot) - * 2) VTI format (vti) - * 3) Povray format (povray) - only for 3D. - */ - bool draw( const tnlString& fileName, - const tnlString& format, - const tnlStaticVector< 1, Index > steps = ( tnlStaticVector< 1, Index > ) 1 ) const; - - protected: - tnlStaticVector< 1, Real > domainLowerCorner, domainUpperCorner, spaceSteps; -}; - -template< typename Real, typename Device, typename Index > -class tnlGridOld< 2, Real, Device, Index > : public tnlMultiVector< 2, Real, Device, Index > -{ - public: - - tnlGridOld(); - - //! We do not allow copy constructor without object name. - //tnlGridOld( const tnlGridOld< Dimensions, Real, Device, Index >& a ); - - tnlGridOld( const tnlString& name ); - - tnlGridOld( const tnlString& name, - const tnlGridOld< 2, Real, tnlHost, Index >& grid ); - - tnlGridOld( const tnlString& name, - const tnlGridOld< 2, Real, tnlCuda, Index >& grid ); - - const tnlStaticVector< 2, Index >& getDimensions() const; - - //! Sets the dimensions - /*** - * This method also must recompute space steps. It is save to call setDimensions and - * setDomain in any order. Both recompute the space steps. - */ - bool setDimensions( const tnlStaticVector< 2, Index >& dimensions ); - - //! Sets the computation domain in form of "rectangle". - /*** - * This method also must recompute space steps. It is save to call setDimensions and - * setDomain in any order. Both recompute the space steps. - */ - - bool setDomain( const tnlStaticVector< 2, Real >& lowerCorner, - const tnlStaticVector< 2, Real >& upperCorner ); - - template< typename Grid > - bool setLike( const Grid& v ); - - const tnlStaticVector< 2, Real >& getDomainLowerCorner() const; - - const tnlStaticVector< 2, Real >& getDomainUpperCorner() const; - - const tnlStaticVector< 2, Real >& getSpaceSteps() const; - - tnlString getType() const; - - bool operator == ( const tnlGridOld< 2, Real, Device, Index >& array ) const; - - bool operator != ( const tnlGridOld< 2, Real, Device, Index >& array ) const; - - template< typename Real2, typename Device2, typename Index2 > - tnlGridOld< 2, Real, Device, Index >& operator = ( const tnlGridOld< 2, Real2, Device2, Index2 >& array ); - - //! This method interpolates value at given point. - Real getValue( const tnlStaticVector< 2, Real >& point ) const; - - //! Interpolation for 2D grid. - Real getValue( const Real& x, - const Real& y ) const; - - //! Forward difference w.r.t x in two dimensions - Real Partial_x_f( const Index i1, - const Index i2 ) const; - - //! Backward difference w.r.t x in two dimensions - Real Partial_x_b( const Index i1, - const Index i2 ) const; - - //! Central difference w.r.t. x in two dimensions - Real Partial_x( const Index i1, - const Index i2 ) const; - - //! Second order difference w.r.t. x in two dimensions - Real Partial_xx( const Index i1, - const Index i2 ) const; - - //! Forward difference w.r.t y - Real Partial_y_f( const Index i1, - const Index i2 ) const; - - //! Backward difference w.r.t y - Real Partial_y_b( const Index i1, - const Index i2 ) const; - - //! Central difference w.r.t y - Real Partial_y( const Index i1, - const Index i2 ) const; - - //! Second order difference w.r.t. y - Real Partial_yy( const Index i1, - const Index i2 ) const; - - //! Set space dependent Dirichlet boundary conditions - void setDirichletBC( const tnlGridOld< 2, Real, Device, Index >&bc, - const tnlStaticVector< 2, bool >& lowerBC, - const tnlStaticVector< 2, bool >& upperBC ); - - //! Set constant Dirichlet boundary conditions - void setDirichletBC( const Real& bc, - const tnlStaticVector< 2, bool >& lowerBC, - const tnlStaticVector< 2, bool >& upperBC ); - - //! Set space dependent Neumann boundary conditions - void setNeumannBC( const tnlGridOld< 2, Real, Device, Index >&bc, - const tnlStaticVector< 2, bool >& lowerBC, - const tnlStaticVector< 2, bool >& upperBC ); - - //! Set constant Neumann boundary conditions - void setNeumannBC( const Real& bc, - const tnlStaticVector< 2, bool >& lowerBC, - const tnlStaticVector< 2, bool >& upperBC ); - - Real getLpNorm( const Real& p ) const; - - Real getDifferenceLpNorm( const tnlVector< Real, Device, Index >& v, const Real& p ) const; - - //! Method for saving the object to a file as a binary data - bool save( tnlFile& file ) const; - - //! Method for restoring the object from a file - bool load( tnlFile& file ); - - bool save( const tnlString& fileName ) const; - - bool load( const tnlString& fileName ); - - //! This method writes the grid in some format suitable for some other preprocessing. - /*! Possible formats are: - * 1) Gnuplot format (gnuplot) - * 2) VTI format (vti) - * 3) Povray format (povray) - only for 3D. - */ - bool draw( const tnlString& fileName, - const tnlString& format, - const tnlStaticVector< 2, Index > steps = ( tnlStaticVector< 2, Index > ) 1 ) const; - - protected: - tnlStaticVector< 2, Real > domainLowerCorner, domainUpperCorner, spaceSteps; -}; - -template< typename Real, typename Device, typename Index > -class tnlGridOld< 3, Real, Device, Index > : public tnlMultiVector< 3, Real, Device, Index > -{ - public: - - tnlGridOld(); - - //! We do not allow copy constructor without object name. - //tnlGridOld( const tnlGridOld< Dimensions, Real, Device, Index >& a ); - - tnlGridOld( const tnlString& name ); - - tnlGridOld( const tnlString& name, - const tnlGridOld< 3, Real, tnlHost, Index >& grid ); - - tnlGridOld( const tnlString& name, - const tnlGridOld< 3, Real, tnlCuda, Index >& grid ); - - const tnlStaticVector< 3, Index >& getDimensions() const; - - //! Sets the dimensions - /*** - * This method also must recompute space steps. It is save to call setDimensions and - * setDomain in any order. Both recompute the space steps. - */ - bool setDimensions( const tnlStaticVector< 3, Index >& dimensions ); - - //! Sets the computation domain in form of "rectangle". - /*** - * This method also must recompute space steps. It is save to call setDimensions and - * setDomain in any order. Both recompute the space steps. - */ - - bool setDomain( const tnlStaticVector< 3, Real >& lowerCorner, - const tnlStaticVector< 3, Real >& upperCorner ); - - template< typename Grid > - bool setLike( const Grid& v ); - - const tnlStaticVector< 3, Real >& getDomainLowerCorner() const; - - const tnlStaticVector< 3, Real >& getDomainUpperCorner() const; - - const tnlStaticVector< 3, Real >& getSpaceSteps() const; - - tnlString getType() const; - - bool operator == ( const tnlGridOld< 3, Real, Device, Index >& array ) const; - - bool operator != ( const tnlGridOld< 3, Real, Device, Index >& array ) const; - - template< typename Real2, typename Device2, typename Index2 > - tnlGridOld< 3, Real, Device, Index >& operator = ( const tnlGridOld< 3, Real2, Device2, Index2 >& array ); - - //! This method interpolates value at given point. - Real getValue( const tnlStaticVector< 3, Real >& point ) const; - - //! Interpolation for 3D grid. - Real getValue( const Real& x, - const Real& y, - const Real& z ) const; - - //! Forward difference w.r.t x in three dimensions - Real Partial_x_f( const Index i1, - const Index i2, - const Index i3 ) const; - - //! Backward difference w.r.t x in three dimensions - Real Partial_x_b( const Index i1, - const Index i2, - const Index i3 ) const; - - //! Central difference w.r.t. x - Real Partial_x( const Index i1, - const Index i2, - const Index i3 ) const; - - //! Second order difference w.r.t. x - Real Partial_xx( const Index i1, - const Index i2, - const Index i3 ) const; - - //! Forward difference w.r.t y in three dimensions - Real Partial_y_f( const Index i1, - const Index i2, - const Index i3 ) const; - - //! Backward difference w.r.t y in three dimensions - Real Partial_y_b( const Index i1, - const Index i2, - const Index i3 ) const; - - //! Central difference w.r.t y - Real Partial_y( const Index i1, - const Index i2, - const Index i3 ) const; - - //! Second order difference w.r.t. y in three dimensions - Real Partial_yy( const Index i1, - const Index i2, - const Index i3 ) const; - - //! Forward difference w.r.t z - Real Partial_z_f( const Index i1, - const Index i2, - const Index i3 ) const; - - //! Backward difference w.r.t z - Real Partial_z_b( const Index i1, - const Index i2, - const Index i3 ) const; - - //! Central difference w.r.t z - Real Partial_z( const Index i1, - const Index i2, - const Index i3 ) const; - - //! Second order difference w.r.t. z - Real Partial_zz( const Index i1, - const Index i2, - const Index i3 ) const; - - //! Set space dependent Dirichlet boundary conditions - void setDirichletBC( const tnlGridOld< 3, Real, Device, Index >&bc, - const tnlStaticVector< 3, bool >& lowerBC, - const tnlStaticVector< 3, bool >& upperBC ); - - //! Set constant Dirichlet boundary conditions - void setDirichletBC( const Real& bc, - const tnlStaticVector< 3, bool >& lowerBC, - const tnlStaticVector< 3, bool >& upperBC ); - - //! Set space dependent Neumann boundary conditions - void setNeumannBC( const tnlGridOld< 3, Real, Device, Index >&bc, - const tnlStaticVector< 3, bool >& lowerBC, - const tnlStaticVector< 3, bool >& upperBC ); - - //! Set constant Neumann boundary conditions - void setNeumannBC( const Real& bc, - const tnlStaticVector< 3, bool >& lowerBC, - const tnlStaticVector< 3, bool >& upperBC ); - - Real getLpNorm( const Real& p ) const; - - Real getDifferenceLpNorm( const tnlVector< Real, Device, Index >& v, const Real& p ) const; - - //! Method for saving the object to a file as a binary data - bool save( tnlFile& file ) const; - - //! Method for restoring the object from a file - bool load( tnlFile& file ); - - bool save( const tnlString& fileName ) const; - - bool load( const tnlString& fileName ); - - //! This method writes the grid in some format suitable for some other preprocessing. - /*! Possible formats are: - * 1) Gnuplot format (gnuplot) - * 2) VTI format (vti) - * 3) Povray format (povray) - only for 3D. - */ - bool draw( const tnlString& fileName, - const tnlString& format, - const tnlStaticVector< 3, Index > steps = ( tnlStaticVector< 3, Index > ) 1 ) const; - - protected: - tnlStaticVector< 3, Real > domainLowerCorner, domainUpperCorner, spaceSteps; -}; - -#include <legacy/mesh/implementation/tnlGrid1D_impl.h> -#include <legacy/mesh/implementation/tnlGrid2D_impl.h> -#include <legacy/mesh/implementation/tnlGrid3D_impl.h> - -/* -#ifdef TEMPLATE_EXPLICIT_INSTANTIATION - -extern template class tnlGridOld< 1, float, tnlHost, int >; -extern template class tnlGridOld< 1, double, tnlHost, int >; -extern template class tnlGridOld< 1, float, tnlHost, long int >; -extern template class tnlGridOld< 1, double, tnlHost, long int >; -extern template class tnlGridOld< 2, float, tnlHost, int >; -extern template class tnlGridOld< 2, double, tnlHost, int >; -extern template class tnlGridOld< 2, float, tnlHost, long int >; -extern template class tnlGridOld< 2, double, tnlHost, long int >; -extern template class tnlGridOld< 3, float, tnlHost, int >; -extern template class tnlGridOld< 3, double, tnlHost, int >; -extern template class tnlGridOld< 3, float, tnlHost, long int >; -extern template class tnlGridOld< 3, double, tnlHost, long int >; - -#ifdef HAVE_CUDA - -extern template class tnlGridOld< 1, float, tnlCuda, int >; -extern template class tnlGridOld< 1, double, tnlCuda, int >; -extern template class tnlGridOld< 1, float, tnlCuda, long int >; -extern template class tnlGridOld< 1, double, tnlCuda, long int >; -extern template class tnlGridOld< 2, float, tnlCuda, int >; -extern template class tnlGridOld< 2, double, tnlCuda, int >; -extern template class tnlGridOld< 2, float, tnlCuda, long int >; -extern template class tnlGridOld< 2, double, tnlCuda, long int >; -extern template class tnlGridOld< 3, float, tnlCuda, int >; -extern template class tnlGridOld< 3, double, tnlCuda, int >; -extern template class tnlGridOld< 3, float, tnlCuda, long int >; -extern template class tnlGridOld< 3, double, tnlCuda, long int >; - -#endif - -#endif -*/ -#endif /* tnlGridOld_H_ */ - diff --git a/src/matrices/tnlCSRMatrix_impl.h b/src/matrices/tnlCSRMatrix_impl.h index d99ee5732fb53c4111bfe60de1914fd4f484946d..0ac092be1bdbb5836eb7c873c6f01020052dfa5a 100644 --- a/src/matrices/tnlCSRMatrix_impl.h +++ b/src/matrices/tnlCSRMatrix_impl.h @@ -206,7 +206,6 @@ bool tnlCSRMatrix< Real, Device, Index >::addElementFast( const IndexType row, this->values[ elementPtr ] = value; return true; } - return false; } template< typename Real, @@ -486,8 +485,7 @@ bool tnlCSRMatrix< Real, Device, Index >::performSORIteration( const Vector& b, { tnlAssert( row >=0 && row < this->getRows(), cerr << "row = " << row - << " this->getRows() = " << this->getRows() - << " this->getName() = " << this->getName() << endl ); + << " this->getRows() = " << this->getRows() << endl ); RealType diagonalValue( 0.0 ); RealType sum( 0.0 ); @@ -505,7 +503,7 @@ bool tnlCSRMatrix< Real, Device, Index >::performSORIteration( const Vector& b, } if( diagonalValue == ( Real ) 0.0 ) { - cerr << "There is zero on the diagonal in " << row << "-th row of the matrix " << this->getName() << ". I cannot perform SOR iteration." << endl; + cerr << "There is zero on the diagonal in " << row << "-th row of the matrix. I cannot perform SOR iteration." << endl; return false; } x[ row ] = ( 1.0 - omega ) * x[ row ] + omega / diagonalValue * ( b[ row ] - sum ); diff --git a/src/matrices/tnlChunkedEllpackMatrix.h b/src/matrices/tnlChunkedEllpackMatrix.h index b4afc8604e16eaac09e9df51a34d36df0a5c665b..8c39d44d5d6c19939efa0332432ba7d88e0c57a3 100644 --- a/src/matrices/tnlChunkedEllpackMatrix.h +++ b/src/matrices/tnlChunkedEllpackMatrix.h @@ -2,7 +2,7 @@ tnlChunkedEllpackMatrix.h - description ------------------- begin : Dec 12, 2013 - copyright : (C) 2013 by Tomas Oberhuber + copyright : (C) 2013 by Tomas Oberhuber et al. email : tomas.oberhuber@fjfi.cvut.cz ***************************************************************************/ @@ -15,6 +15,18 @@ * * ***************************************************************************/ +/*** + * Authors: + * Oberhuber Tomas, tomas.oberhuber@fjfi.cvut.cz + * Heller Martin + * + * The algorithm/method was published in: + * Heller M., Oberhuber T., Improved Row-grouped CSR Format for Storing of + * Sparse Matrices on GPU, Proceedings of Algoritmy 2012, 2012, HandloviÄová A., + * Minarechová Z. and Å evÄoviÄ D. (ed.), pages 282-290. + */ + + #ifndef TNLCHUNKEDELLPACKMATRIX_H_ #define TNLCHUNKEDELLPACKMATRIX_H_ @@ -217,7 +229,8 @@ class tnlChunkedEllpackMatrix : public tnlSparseMatrix< Real, Device, Index > void print( ostream& str ) const; - void printStructure( ostream& str ) const; + void printStructure( ostream& str, + const tnlString& = "" ) const; protected: diff --git a/src/matrices/tnlChunkedEllpackMatrix_impl.h b/src/matrices/tnlChunkedEllpackMatrix_impl.h index 49ea5e9ab286a91bc44cfb8b2fb7bd187b152f80..a867c847fc99099ab4fa82b621f3e017efe6e27e 100644 --- a/src/matrices/tnlChunkedEllpackMatrix_impl.h +++ b/src/matrices/tnlChunkedEllpackMatrix_impl.h @@ -42,12 +42,6 @@ tnlChunkedEllpackMatrix< Real, Device, Index >::tnlChunkedEllpackMatrix() desiredChunkSize( 16 ), numberOfSlices( 0 ) { - this->values.setName( "tnlChunkedEllpackMatrix::values" ); - this->columnIndexes.setName( "tnlChunkedEllpackMatrix::columnIndexes" ); - rowToChunkMapping.setName( "tnlChunkedEllpackMatrix::rowToChunkMapping" ); - rowToSliceMapping.setName( "tnlChunkedEllpackMatrix::rowToSliceMapping" ); - rowPointers.setName( "tnlChunkedEllpackMatrix::rowPointers" ); - slices.setName( "tnlChunkedEllpackMatrix::slices" ); }; template< typename Real, @@ -353,9 +347,7 @@ bool tnlChunkedEllpackMatrix< Real, Device, Index >::operator == ( const tnlChun cerr << "this->getRows() = " << this->getRows() << " matrix.getRows() = " << matrix.getRows() << " this->getColumns() = " << this->getColumns() - << " matrix.getColumns() = " << matrix.getColumns() - << " this->getName() = " << this->getName() - << " matrix.getName() = " << matrix.getName() ); + << " matrix.getColumns() = " << matrix.getColumns() ); // TODO: implement this return false; } @@ -1154,8 +1146,7 @@ bool tnlChunkedEllpackMatrix< Real, Device, Index >::performSORIteration( const { tnlAssert( row >=0 && row < this->getRows(), cerr << "row = " << row - << " this->getRows() = " << this->getRows() - << " this->getName() = " << this->getName() << endl ); + << " this->getRows() = " << this->getRows() << endl ); RealType diagonalValue( 0.0 ); RealType sum( 0.0 ); @@ -1176,7 +1167,7 @@ bool tnlChunkedEllpackMatrix< Real, Device, Index >::performSORIteration( const } if( diagonalValue == ( Real ) 0.0 ) { - cerr << "There is zero on the diagonal in " << row << "-th row of thge matrix " << this->getName() << ". I cannot perform SOR iteration." << endl; + cerr << "There is zero on the diagonal in " << row << "-th row of a matrix. I cannot perform SOR iteration." << endl; return false; } x. setElement( row, x[ row ] + omega / diagonalValue * ( b[ row ] - sum ) ); @@ -1258,11 +1249,12 @@ void tnlChunkedEllpackMatrix< Real, Device, Index >::print( ostream& str ) const template< typename Real, typename Device, typename Index > -void tnlChunkedEllpackMatrix< Real, Device, Index >::printStructure( ostream& str ) const +void tnlChunkedEllpackMatrix< Real, Device, Index >::printStructure( ostream& str, + const tnlString& name ) const { const IndexType numberOfSlices = this->getNumberOfSlices(); str << "Matrix type: " << getType() << endl - << "Marix name: " << this->getName() << endl + << "Marix name: " << name << endl << "Rows: " << this->getRows() << endl << "Columns: " << this->getColumns() << endl << "Slices: " << numberOfSlices << endl; diff --git a/src/matrices/tnlDenseMatrix_impl.h b/src/matrices/tnlDenseMatrix_impl.h index aa5f316aa027ccc916c7042ac034aaa9e657364c..557070f17207fb357e1b16094cabab3dbcb498ee 100644 --- a/src/matrices/tnlDenseMatrix_impl.h +++ b/src/matrices/tnlDenseMatrix_impl.h @@ -217,8 +217,7 @@ bool tnlDenseMatrix< Real, Device, Index >::setRowFast( const IndexType row, { tnlAssert( elements <= this->getColumns(), cerr << " elements = " << elements - << " this->columns = " << this->getColumns() - << " this->getName() = " << this->getName() ); + << " this->columns = " << this->getColumns() ); for( IndexType i = 0; i < elements; i++ ) this->setElementFast( row, columns[ i ], values[ i ] ); return true; @@ -234,8 +233,7 @@ bool tnlDenseMatrix< Real, Device, Index >::setRow( const IndexType row, { tnlAssert( elements <= this->getColumns(), cerr << " elements = " << elements - << " this->columns = " << this->getColumns() - << " this->getName() = " << this->getName() ); + << " this->columns = " << this->getColumns() ); for( IndexType i = 0; i < elements; i++ ) this->setElement( row, columns[ i ], values[ i ] ); return true; @@ -253,8 +251,7 @@ bool tnlDenseMatrix< Real, Device, Index >::addRowFast( const IndexType row, { tnlAssert( elements <= this->columns, cerr << " elements = " << elements - << " this->columns = " << this->columns - << " this->getName() = " << this->getName() ); + << " this->columns = " << this->columns ); for( IndexType i = 0; i < elements; i++ ) this->setElementFast( row, columns[ i ], thisRowMultiplicator * this->getElementFast( row, columns[ i ] ) + values[ i ] ); @@ -272,8 +269,7 @@ bool tnlDenseMatrix< Real, Device, Index >::addRow( const IndexType row, { tnlAssert( elements <= this->columns, cerr << " elements = " << elements - << " this->columns = " << this->columns - << " this->getName() = " << this->getName() ); + << " this->columns = " << this->columns ); for( IndexType i = 0; i < elements; i++ ) this->setElement( row, columns[ i ], thisRowMultiplicator * this->getElement( row, columns[ i ] ) + values[ i ] ); @@ -378,14 +374,10 @@ void tnlDenseMatrix< Real, Device, Index >::vectorProduct( const InVector& inVec { tnlAssert( this->getColumns() == inVector.getSize(), cerr << "Matrix columns: " << this->getColumns() << endl - << "Matrix name: " << this->getName() << endl - << "Vector size: " << inVector.getSize() << endl - << "Vector name: " << inVector.getName() << endl ); + << "Vector size: " << inVector.getSize() << endl ); tnlAssert( this->getRows() == outVector.getSize(), cerr << "Matrix rows: " << this->getRows() << endl - << "Matrix name: " << this->getName() << endl - << "Vector size: " << outVector.getSize() << endl - << "Vector name: " << outVector.getName() << endl ); + << "Vector size: " << outVector.getSize() << endl ); DeviceDependentCode::vectorProduct( *this, inVector, outVector ); } @@ -402,10 +394,8 @@ void tnlDenseMatrix< Real, Device, Index >::addMatrix( const Matrix& matrix, this->getRows() == matrix.getRows(), cerr << "This matrix columns: " << this->getColumns() << endl << "This matrix rows: " << this->getRows() << endl - << "This matrix name: " << this->getName() << endl << "That matrix columns: " << matrix.getColumns() << endl - << "That matrix rows: " << matrix.getRows() << endl - << "That matrix name: " << matrix.getName() << endl ); + << "That matrix rows: " << matrix.getRows() << endl ); if( thisMatrixMultiplicator == 1.0 ) this->values.addVector( matrix.values, matrixMultiplicator ); @@ -526,13 +516,10 @@ void tnlDenseMatrix< Real, Device, Index >::getMatrixProduct( const Matrix1& mat this->getColumns() == matrix2.getColumns(), cerr << "This matrix columns: " << this->getColumns() << endl << "This matrix rows: " << this->getRows() << endl - << "This matrix name: " << this->getName() << endl << "Matrix1 columns: " << matrix1.getColumns() << endl << "Matrix1 rows: " << matrix1.getRows() << endl - << "Matrix1 name: " << matrix1.getName() << endl << "Matrix2 columns: " << matrix2.getColumns() << endl - << "Matrix2 rows: " << matrix2.getRows() << endl - << "Matrix2 name: " << matrix2.getName() << endl ); + << "Matrix2 rows: " << matrix2.getRows() << endl ); if( Device::getDevice() == tnlHostDevice ) for( IndexType i = 0; i < this->getRows(); i += tileDim ) @@ -763,11 +750,9 @@ void tnlDenseMatrix< Real, Device, Index >::getTransposition( const Matrix& matr tnlAssert( this->getColumns() == matrix.getRows() && this->getRows() == matrix.getColumns(), cerr << "This matrix columns: " << this->getColumns() << endl - << "This matrix rows: " << this->getRows() << endl - << "This matrix name: " << this->getName() << endl + << "This matrix rows: " << this->getRows() << endl << "That matrix columns: " << matrix.getColumns() << endl - << "That matrix rows: " << matrix.getRows() << endl - << "That matrix name: " << matrix.getName() << endl ); + << "That matrix rows: " << matrix.getRows() << endl ); if( Device::getDevice() == tnlHostDevice ) { diff --git a/src/matrices/tnlEllpackMatrix.h b/src/matrices/tnlEllpackMatrix.h index 4003ceed39fb218da89926fc800fd6ea5c7171ac..78efa93cc24d46ebd4e909d121a03c98d8b50e44 100644 --- a/src/matrices/tnlEllpackMatrix.h +++ b/src/matrices/tnlEllpackMatrix.h @@ -60,7 +60,7 @@ class tnlEllpackMatrix : public tnlSparseMatrix< Real, Device, Index > bool setLike( const tnlEllpackMatrix< Real2, Device2, Index2 >& matrix ); void reset(); - + template< typename Real2, typename Device2, typename Index2 > bool operator == ( const tnlEllpackMatrix< Real2, Device2, Index2 >& matrix ) const; diff --git a/src/matrices/tnlEllpackMatrix_impl.h b/src/matrices/tnlEllpackMatrix_impl.h index 088dd84e404b0663e18f0b53552f1738aa5138f4..a4197cb02dcf0fe6344a70843f8410cd03ec2689 100644 --- a/src/matrices/tnlEllpackMatrix_impl.h +++ b/src/matrices/tnlEllpackMatrix_impl.h @@ -39,6 +39,8 @@ tnlString tnlEllpackMatrix< Real, Device, Index > :: getType() tnlString( ::getType< Real >() ) + tnlString( ", " ) + Device :: getDeviceType() + + tnlString( ", " ) + + tnlString( ::getType< Index >() ) + tnlString( " >" ); } @@ -113,6 +115,7 @@ bool tnlEllpackMatrix< Real, Device, Index >::setLike( const tnlEllpackMatrix< R if( ! tnlSparseMatrix< Real, Device, Index >::setLike( matrix ) ) return false; this->rowLengths = matrix.rowLengths; + this->alignedRows = matrix.alignedRows; return true; } @@ -123,6 +126,7 @@ void tnlEllpackMatrix< Real, Device, Index > :: reset() { tnlSparseMatrix< Real, Device, Index >::reset(); this->rowLengths = 0; + this->alignedRows = 0; } template< typename Real, @@ -138,9 +142,7 @@ bool tnlEllpackMatrix< Real, Device, Index >::operator == ( const tnlEllpackMatr cerr << "this->getRows() = " << this->getRows() << " matrix.getRows() = " << matrix.getRows() << " this->getColumns() = " << this->getColumns() - << " matrix.getColumns() = " << matrix.getColumns() - << " this->getName() = " << this->getName() - << " matrix.getName() = " << matrix.getName() ); + << " matrix.getColumns() = " << matrix.getColumns() ); // TODO: implement this return false; } @@ -539,8 +541,7 @@ bool tnlEllpackMatrix< Real, Device, Index > :: performSORIteration( const Vecto { tnlAssert( row >=0 && row < this->getRows(), cerr << "row = " << row - << " this->getRows() = " << this->getRows() - << " this->getName() = " << this->getName() << endl ); + << " this->getRows() = " << this->getRows() << endl ); RealType diagonalValue( 0.0 ); RealType sum( 0.0 ); @@ -560,7 +561,7 @@ bool tnlEllpackMatrix< Real, Device, Index > :: performSORIteration( const Vecto } if( diagonalValue == ( Real ) 0.0 ) { - cerr << "There is zero on the diagonal in " << row << "-th row of thge matrix " << this->getName() << ". I cannot perform SOR iteration." << endl; + cerr << "There is zero on the diagonal in " << row << "-th row of a matrix. I cannot perform SOR iteration." << endl; return false; } x[ row ] = ( 1.0 - omega ) * x[ row ] + omega / diagonalValue * ( b[ row ] - sum ); @@ -691,9 +692,54 @@ class tnlEllpackMatrixDeviceDependentCode< tnlHost > #endif for( Index row = 0; row < matrix.getRows(); row ++ ) outVector[ row ] = matrix.rowVectorProduct( row, inVector ); + /*Index col; + for( Index row = 0; row < matrix.getRows(); row ++ ) + { + outVector[ row ] = 0.0; + const Index rowEnd = ( row + 1 ) * matrix.rowLengths; + for( Index i = row * matrix.rowLengths; i < rowEnd; i++ ) + if( ( col = matrix.columnIndexes[ i ] ) < matrix.columns ) + outVector[ row ] += matrix.values[ i ] * inVector[ col ]; + }*/ } }; +#ifdef HAVE_CUDA +template< + typename Real, + typename Index > +__global__ void tnlEllpackMatrixVectorProductCudaKernel( + const Index rows, + const Index columns, + const Index compressedRowsLengths, + const Index alignedRows, + const Index paddingIndex, + const Index* columnIndexes, + const Real* values, + const Real* inVector, + Real* outVector, + const Index gridIdx ) +{ + const Index rowIdx = ( gridIdx * tnlCuda::getMaxGridSize() + blockIdx.x ) * blockDim.x + threadIdx.x; + if( rowIdx >= rows ) + return; + Index i = rowIdx; + Index el( 0 ); + Real result( 0.0 ); + Index columnIndex; + while( el++ < compressedRowsLengths && + ( columnIndex = columnIndexes[ i ] ) < columns && + columnIndex != paddingIndex ) + { + result += values[ i ] * inVector[ columnIndex ]; + i += alignedRows; + } + outVector[ rowIdx ] = result; +} +#endif + + + template<> class tnlEllpackMatrixDeviceDependentCode< tnlCuda > { @@ -735,7 +781,42 @@ class tnlEllpackMatrixDeviceDependentCode< tnlCuda > const InVector& inVector, OutVector& outVector ) { - tnlMatrixVectorProductCuda( matrix, inVector, outVector ); + //tnlMatrixVectorProductCuda( matrix, inVector, outVector ); + #ifdef HAVE_CUDA + typedef tnlEllpackMatrix< Real, Device, Index > Matrix; + typedef typename Matrix::IndexType IndexType; + //Matrix* kernel_this = tnlCuda::passToDevice( matrix ); + //InVector* kernel_inVector = tnlCuda::passToDevice( inVector ); + //OutVector* kernel_outVector = tnlCuda::passToDevice( outVector ); + dim3 cudaBlockSize( 256 ), cudaGridSize( tnlCuda::getMaxGridSize() ); + const IndexType cudaBlocks = roundUpDivision( matrix.getRows(), cudaBlockSize.x ); + const IndexType cudaGrids = roundUpDivision( cudaBlocks, tnlCuda::getMaxGridSize() ); + for( IndexType gridIdx = 0; gridIdx < cudaGrids; gridIdx++ ) + { + if( gridIdx == cudaGrids - 1 ) + cudaGridSize.x = cudaBlocks % tnlCuda::getMaxGridSize(); + tnlEllpackMatrixVectorProductCudaKernel + < Real, Index > + <<< cudaGridSize, cudaBlockSize >>> + ( matrix.getRows(), + matrix.getColumns(), + matrix.rowLengths, + matrix.alignedRows, + matrix.getPaddingIndex(), + matrix.columnIndexes.getData(), + matrix.values.getData(), + inVector.getData(), + outVector.getData(), + gridIdx ); + checkCudaDevice; + } + //tnlCuda::freeFromDevice( kernel_this ); + //tnlCuda::freeFromDevice( kernel_inVector ); + //tnlCuda::freeFromDevice( kernel_outVector ); + checkCudaDevice; + cudaThreadSynchronize(); + #endif + } }; diff --git a/src/matrices/tnlMultidiagonalMatrix_impl.h b/src/matrices/tnlMultidiagonalMatrix_impl.h index c64660b8f3087ffae4e7876a02f7ffec62cf652d..f425782cfdd10bcee847d548b5178b1852020278 100644 --- a/src/matrices/tnlMultidiagonalMatrix_impl.h +++ b/src/matrices/tnlMultidiagonalMatrix_impl.h @@ -193,9 +193,7 @@ bool tnlMultidiagonalMatrix< Real, Device, Index >::operator == ( const tnlMulti cerr << "this->getRows() = " << this->getRows() << " matrix.getRows() = " << matrix.getRows() << " this->getColumns() = " << this->getColumns() - << " matrix.getColumns() = " << matrix.getColumns() - << " this->getName() = " << this->getName() - << " matrix.getName() = " << matrix.getName() ); + << " matrix.getColumns() = " << matrix.getColumns() ); return ( this->diagonals == matrix.diagonals && this->values == matrix.values ); } @@ -512,14 +510,10 @@ void tnlMultidiagonalMatrix< Real, Device, Index >::vectorProduct( const InVecto { tnlAssert( this->getColumns() == inVector.getSize(), cerr << "Matrix columns: " << this->getColumns() << endl - << "Matrix name: " << this->getName() << endl - << "Vector size: " << inVector.getSize() << endl - << "Vector name: " << inVector.getName() << endl ); + << "Vector size: " << inVector.getSize() << endl ); tnlAssert( this->getRows() == outVector.getSize(), cerr << "Matrix rows: " << this->getRows() << endl - << "Matrix name: " << this->getName() << endl - << "Vector size: " << outVector.getSize() << endl - << "Vector name: " << outVector.getName() << endl ); + << "Vector size: " << outVector.getSize() << endl ); DeviceDependentCode::vectorProduct( *this, inVector, outVector ); } @@ -572,8 +566,7 @@ bool tnlMultidiagonalMatrix< Real, Device, Index > :: performSORIteration( const { tnlAssert( row >=0 && row < this->getRows(), cerr << "row = " << row - << " this->getRows() = " << this->getRows() - << " this->getName() = " << this->getName() << endl ); + << " this->getRows() = " << this->getRows() << endl ); RealType diagonalValue( 0.0 ); RealType sum( 0.0 ); @@ -595,7 +588,7 @@ bool tnlMultidiagonalMatrix< Real, Device, Index > :: performSORIteration( const } if( diagonalValue == ( Real ) 0.0 ) { - cerr << "There is zero on the diagonal in " << row << "-th row of thge matrix " << this->getName() << ". I cannot perform SOR iteration." << endl; + cerr << "There is zero on the diagonal in " << row << "-th row of thge matrix. I cannot perform SOR iteration." << endl; return false; } x[ row ] = ( 1.0 - omega ) * x[ row ] + omega / diagonalValue * ( b[ row ] - sum ); @@ -668,12 +661,10 @@ bool tnlMultidiagonalMatrix< Real, Device, Index >::getElementIndex( const Index { tnlAssert( row >=0 && row < this->rows, cerr << "row = " << row - << " this->rows = " << this->rows - << " this->getName() = " << this->getName() << endl ); + << " this->rows = " << this->rows << endl ); tnlAssert( column >=0 && column < this->columns, cerr << "column = " << column - << " this->columns = " << this->columns - << " this->getName() = " << this->getName() << endl ); + << " this->columns = " << this->columns << endl ); typedef tnlMultidiagonalMatrixDeviceDependentCode< Device > DDCType; IndexType i( 0 ); @@ -699,12 +690,10 @@ bool tnlMultidiagonalMatrix< Real, Device, Index >::getElementIndexFast( const I { tnlAssert( row >=0 && row < this->rows, cerr << "row = " << row - << " this->rows = " << this->rows - << " this->getName() = " << this->getName() << endl ); + << " this->rows = " << this->rows << endl ); tnlAssert( column >=0 && column < this->columns, cerr << "column = " << column - << " this->columns = " << this->columns - << " this->getName() = " << this->getName() << endl ); + << " this->columns = " << this->columns << endl ); typedef tnlMultidiagonalMatrixDeviceDependentCode< Device > DDCType; IndexType i( 0 ); diff --git a/src/matrices/tnlSlicedEllpackMatrix.h b/src/matrices/tnlSlicedEllpackMatrix.h index 975f78c44c6be9542800adeec7093da665438203..a0b573dec7288ecf4787ad604b9083c7cbc0fd11 100644 --- a/src/matrices/tnlSlicedEllpackMatrix.h +++ b/src/matrices/tnlSlicedEllpackMatrix.h @@ -2,7 +2,7 @@ tnlSlicedEllpackMatrix.h - description ------------------- begin : Dec 8, 2013 - copyright : (C) 2013 by Tomas Oberhuber + copyright : (C) 2013 by Tomas Oberhuber et al. email : tomas.oberhuber@fjfi.cvut.cz ***************************************************************************/ @@ -15,6 +15,17 @@ * * ***************************************************************************/ +/*** + * Authors: + * Oberhuber Tomas, tomas.oberhuber@fjfi.cvut.cz + * Vacata Jan + * + * The algorithm/method was published in: + * Oberhuber T., Suzuki A., Vacata J., New Row-grouped CSR format for storing + * the sparse matrices on GPU with implementation in CUDA, Acta Technica, 2011, + * vol. 56, no. 4, pp. 447-466. + */ + #ifndef TNLSLICEDELLPACKMATRIX_H_ #define TNLSLICEDELLPACKMATRIX_H_ diff --git a/src/matrices/tnlSlicedEllpackMatrix_impl.h b/src/matrices/tnlSlicedEllpackMatrix_impl.h index a5944cc1f66823ebf696e77b7b2b1d16decdd46f..628e5e39a7321465a2a248e7dd7b61b8e04e2818 100644 --- a/src/matrices/tnlSlicedEllpackMatrix_impl.h +++ b/src/matrices/tnlSlicedEllpackMatrix_impl.h @@ -137,9 +137,7 @@ bool tnlSlicedEllpackMatrix< Real, Device, Index, SliceSize >::operator == ( con cerr << "this->getRows() = " << this->getRows() << " matrix.getRows() = " << matrix.getRows() << " this->getColumns() = " << this->getColumns() - << " matrix.getColumns() = " << matrix.getColumns() - << " this->getName() = " << this->getName() - << " matrix.getName() = " << matrix.getName() ); + << " matrix.getColumns() = " << matrix.getColumns() ); // TODO: implement this return false; } @@ -549,8 +547,7 @@ bool tnlSlicedEllpackMatrix< Real, Device, Index, SliceSize >::performSORIterati { tnlAssert( row >=0 && row < this->getRows(), cerr << "row = " << row - << " this->getRows() = " << this->getRows() - << " this->getName() = " << this->getName() << endl ); + << " this->getRows() = " << this->getRows() << endl ); RealType diagonalValue( 0.0 ); RealType sum( 0.0 ); @@ -573,7 +570,7 @@ bool tnlSlicedEllpackMatrix< Real, Device, Index, SliceSize >::performSORIterati } if( diagonalValue == ( Real ) 0.0 ) { - cerr << "There is zero on the diagonal in " << row << "-th row of the matrix " << this->getName() << ". I cannot perform SOR iteration." << endl; + cerr << "There is zero on the diagonal in " << row << "-th row of a matrix. I cannot perform SOR iteration." << endl; return false; } x[ row ] = ( 1.0 - omega ) * x[ row ] + omega / diagonalValue * ( b[ row ] - sum ); @@ -780,6 +777,45 @@ __global__ void tnlSlicedEllpackMatrix_computeMaximalRowLengthInSlices_CudaKerne } #endif +#ifdef HAVE_CUDA +template< + typename Real, + typename Index, + int SliceSize > +__global__ void tnlSlicedEllpackMatrixVectorProductCudaKernel( + const Index rows, + const Index columns, + const Index* slicePointers, + const Index* sliceCompressedRowsLengths, + const Index paddingIndex, + const Index* columnIndexes, + const Real* values, + const Real* inVector, + Real* outVector, + const Index gridIdx ) +{ + const Index rowIdx = ( gridIdx * tnlCuda::getMaxGridSize() + blockIdx.x ) * blockDim.x + threadIdx.x; + if( rowIdx >= rows ) + return; + const Index sliceIdx = rowIdx / SliceSize; + const Index slicePointer = slicePointers[ sliceIdx ]; + const Index rowLength = sliceCompressedRowsLengths[ sliceIdx ]; + Index i = slicePointer + rowIdx - sliceIdx * SliceSize; + const Index rowEnd = i + rowLength * SliceSize; + Real result( 0.0 ); + Index columnIndex; + while( i < rowEnd && + ( columnIndex = columnIndexes[ i ] ) < columns && + columnIndex < paddingIndex ) + { + result += values[ i ] * inVector[ columnIndex ]; + i += SliceSize; + } + outVector[ rowIdx ] = result; +} +#endif + + template<> class tnlSlicedEllpackMatrixDeviceDependentCode< tnlCuda > { @@ -865,7 +901,41 @@ class tnlSlicedEllpackMatrixDeviceDependentCode< tnlCuda > const InVector& inVector, OutVector& outVector ) { - tnlMatrixVectorProductCuda( matrix, inVector, outVector ); + //tnlMatrixVectorProductCuda( matrix, inVector, outVector ); + #ifdef HAVE_CUDA + typedef tnlSlicedEllpackMatrix< Real, Device, Index, SliceSize > Matrix; + typedef typename Matrix::IndexType IndexType; + //Matrix* kernel_this = tnlCuda::passToDevice( matrix ); + //InVector* kernel_inVector = tnlCuda::passToDevice( inVector ); + //OutVector* kernel_outVector = tnlCuda::passToDevice( outVector ); + dim3 cudaBlockSize( 256 ), cudaGridSize( tnlCuda::getMaxGridSize() ); + const IndexType cudaBlocks = roundUpDivision( matrix.getRows(), cudaBlockSize.x ); + const IndexType cudaGrids = roundUpDivision( cudaBlocks, tnlCuda::getMaxGridSize() ); + for( IndexType gridIdx = 0; gridIdx < cudaGrids; gridIdx++ ) + { + if( gridIdx == cudaGrids - 1 ) + cudaGridSize.x = cudaBlocks % tnlCuda::getMaxGridSize(); + tnlSlicedEllpackMatrixVectorProductCudaKernel + < Real, Index, SliceSize > + <<< cudaGridSize, cudaBlockSize >>> + ( matrix.getRows(), + matrix.getColumns(), + matrix.slicePointers.getData(), + matrix.sliceCompressedRowsLengths.getData(), + matrix.getPaddingIndex(), + matrix.columnIndexes.getData(), + matrix.values.getData(), + inVector.getData(), + outVector.getData(), + gridIdx ); + checkCudaDevice; + } + //tnlCuda::freeFromDevice( kernel_this ); + //tnlCuda::freeFromDevice( kernel_inVector ); + //tnlCuda::freeFromDevice( kernel_outVector ); + checkCudaDevice; + cudaThreadSynchronize(); + #endif } }; diff --git a/src/matrices/tnlTridiagonalMatrix_impl.h b/src/matrices/tnlTridiagonalMatrix_impl.h index 56b7aee702867da7cceec2e106a11ac7819da866..6791f7b48fa5966121e1f0a2e045f1cf95f98506 100644 --- a/src/matrices/tnlTridiagonalMatrix_impl.h +++ b/src/matrices/tnlTridiagonalMatrix_impl.h @@ -247,8 +247,7 @@ bool tnlTridiagonalMatrix< Real, Device, Index >::setRowFast( const IndexType ro { tnlAssert( elements <= this->columns, cerr << " elements = " << elements - << " this->columns = " << this->columns - << " this->getName() = " << this->getName() ); + << " this->columns = " << this->columns ); return this->addRowFast( row, columns, values, elements, 0.0 ); } @@ -262,8 +261,7 @@ bool tnlTridiagonalMatrix< Real, Device, Index >::setRow( const IndexType row, { tnlAssert( elements <= this->columns, cerr << " elements = " << elements - << " this->columns = " << this->columns - << " this->getName() = " << this->getName() ); + << " this->columns = " << this->columns ); return this->addRow( row, columns, values, elements, 0.0 ); } @@ -279,8 +277,7 @@ bool tnlTridiagonalMatrix< Real, Device, Index >::addRowFast( const IndexType ro { tnlAssert( elements <= this->columns, cerr << " elements = " << elements - << " this->columns = " << this->columns - << " this->getName() = " << this->getName() ); + << " this->columns = " << this->columns ); if( elements > 3 ) return false; for( IndexType i = 0; i < elements; i++ ) @@ -304,8 +301,7 @@ bool tnlTridiagonalMatrix< Real, Device, Index >::addRow( const IndexType row, { tnlAssert( elements <= this->columns, cerr << " elements = " << elements - << " this->columns = " << this->columns - << " this->getName() = " << this->getName() ); + << " this->columns = " << this->columns ); if( elements > 3 ) return false; for( IndexType i = 0; i < elements; i++ ) @@ -419,14 +415,10 @@ void tnlTridiagonalMatrix< Real, Device, Index >::vectorProduct( const InVector& { tnlAssert( this->getColumns() == inVector.getSize(), cerr << "Matrix columns: " << this->getColumns() << endl - << "Matrix name: " << this->getName() << endl - << "Vector size: " << inVector.getSize() << endl - << "Vector name: " << inVector.getName() << endl ); + << "Vector size: " << inVector.getSize() << endl ); tnlAssert( this->getRows() == outVector.getSize(), cerr << "Matrix rows: " << this->getRows() << endl - << "Matrix name: " << this->getName() << endl - << "Vector size: " << outVector.getSize() << endl - << "Vector name: " << outVector.getName() << endl ); + << "Vector size: " << outVector.getSize() << endl ); DeviceDependentCode::vectorProduct( *this, inVector, outVector ); } @@ -441,8 +433,7 @@ void tnlTridiagonalMatrix< Real, Device, Index >::addMatrix( const tnlTridiagona { tnlAssert( this->getRows() == matrix.getRows(), cerr << "This matrix columns: " << this->getColumns() << endl - << "This matrix rows: " << this->getRows() << endl - << "This matrix name: " << this->getName() << endl ); + << "This matrix rows: " << this->getRows() << endl ); if( thisMatrixMultiplicator == 1.0 ) this->values.addVector( matrix.values, matrixMultiplicator ); @@ -551,7 +542,7 @@ bool tnlTridiagonalMatrix< Real, Device, Index >::save( tnlFile& file ) const if( ! tnlMatrix< Real, Device, Index >::save( file ) || ! this->values.save( file ) ) { - cerr << "Unable to save the tridiagonal matrix " << this->getName() << "." << endl; + cerr << "Unable to save a tridiagonal matrix." << endl; return false; } return true; @@ -565,7 +556,7 @@ bool tnlTridiagonalMatrix< Real, Device, Index >::load( tnlFile& file ) if( ! tnlMatrix< Real, Device, Index >::load( file ) || ! this->values.load( file ) ) { - cerr << "Unable to save the tridiagonal matrix " << this->getName() << "." << endl; + cerr << "Unable to save a tridiagonal matrix." << endl; return false; } return true; diff --git a/src/mesh/CMakeLists.txt b/src/mesh/CMakeLists.txt index 0381314ac754930402690625546276abc5af10fe..7b6f21c12c00b882d9a26a81c8e7354f5e44b26a 100755 --- a/src/mesh/CMakeLists.txt +++ b/src/mesh/CMakeLists.txt @@ -1,37 +1,25 @@ ADD_SUBDIRECTORY( config ) +ADD_SUBDIRECTORY( grids ) +ADD_SUBDIRECTORY( initializer ) ADD_SUBDIRECTORY( layers ) ADD_SUBDIRECTORY( traits ) ADD_SUBDIRECTORY( topologies ) SET( headers tnlGrid.h - tnlGrid1D.h - tnlGrid1D_impl.h - tnlGrid2D.h - tnlGrid2D_impl.h - tnlGrid3D.h - tnlGrid3D_impl.h tnlDummyMesh.h + tnlDimensionsTag.h tnlGnuplotWriter.h tnlMesh.h tnlMeshEntity.h tnlMeshEntityId.h - tnlMeshEntityKey.h tnlMeshReaderNetgen.h tnlMeshWriterNetgen.h - tnlMeshInitializer.h - tnlMeshEntityInitializer.h - tnlMeshSuperentityInitializerLayer.h + tnlMeshIntegrityChecker.h tnlTraverser.h - tnlTraverser_Grid1D.h - tnlTraverser_Grid1D_impl.h - tnlTraverser_Grid2D.h - tnlTraverser_Grid2D_impl.h - tnlTraverser_Grid3D.h - tnlTraverser_Grid3D_impl.h ) + ) SET( CURRENT_DIR ${CMAKE_SOURCE_DIR}/src/mesh ) SET( tnl_mesh_SOURCES - ${CURRENT_DIR}/tnlGrid_impl.cpp PARENT_SCOPE ) INSTALL( FILES ${headers} DESTINATION include/tnl-${tnlVersion}/mesh ) \ No newline at end of file diff --git a/src/mesh/config/CMakeLists.txt b/src/mesh/config/CMakeLists.txt index 5da9330921543fe65818233d8e49393bc736c6e1..db2417314fcf20164227dc7560022d623467a79c 100755 --- a/src/mesh/config/CMakeLists.txt +++ b/src/mesh/config/CMakeLists.txt @@ -1,3 +1,4 @@ -SET( headers tnlMeshConfigBase.h ) +SET( headers tnlMeshConfigBase.h + tnlMeshConfigValidator.h ) INSTALL( FILES ${headers} DESTINATION include/tnl-${tnlVersion}/mesh/config ) \ No newline at end of file diff --git a/src/mesh/config/tnlMeshConfigBase.h b/src/mesh/config/tnlMeshConfigBase.h index cc96c8fbd8be790276e9b94e31bb11c637587940..34a8c608a0ee8a0c4be8ae1217bcf5cc9942ec97 100644 --- a/src/mesh/config/tnlMeshConfigBase.h +++ b/src/mesh/config/tnlMeshConfigBase.h @@ -24,62 +24,74 @@ * It means that each mesh entity stores its index in its * mesh storage layer. */ -template< int WorldDimensions, +template< typename Cell, + int WorldDimensions = Cell::dimensions, typename Real = double, typename GlobalIndex = int, typename LocalIndex = GlobalIndex, typename Id = void > struct tnlMeshConfigBase { + typedef Cell CellTopology; typedef Real RealType; typedef GlobalIndex GlobalIndexType; typedef LocalIndex LocalIndexType; typedef Id IdType; - enum { worldDimensions = WorldDimensions }; + static const int worldDimensions = WorldDimensions; + static const int meshDimensions = Cell::dimensions; static tnlString getType() { return tnlString( "tnlMeshConfigBase< >"); }; + + /**** + * Storage of mesh entities. + */ + static constexpr bool entityStorage( int dimensions ) + { + /**** + * Vertices and cells must always be stored + */ + return true; + //return ( dimensions == 0 || dimensions == cellDimensions ); + } + + /**** + * Storage of subentities of mesh entities + */ + template< typename MeshEntity > + static constexpr bool subentityStorage( MeshEntity, int SubentityDimensions ) + { + /**** + * Vertices must always be stored + */ + return true; + //return ( SubentityDimensions == 0 ); + } -}; + /**** + * Storage of subentity orientations of mesh entities. + * It must be false for vertices and cells. + */ + template< typename MeshEntity > + static constexpr bool subentityOrientationStorage( MeshEntity, int SubentityDimensions ) + { + return ( SubentityDimensions > 0 ); + } -/**** - * Explicit storage of all mesh entities by default. - * To disable it, write your own specialization with given - * dimensions and config tag. - */ -template< typename ConfigTag, - int Dimensions > -struct tnlMeshEntityStorage -{ - enum { enabled = true }; -}; - -/**** - * By default, ALL SUBENTITIES of a mesh entity ARE STORED - * provided that they are stored in the mesh. - * Write your own specialization if you do not want so. - */ -template< typename ConfigTag, - typename EntityTag, - int Dimensions > -struct tnlMeshSubentityStorage -{ - enum { enabled = tnlMeshEntityStorage< ConfigTag, Dimensions >::enabled }; -}; - -/*** - * By default, NO SUPERENTITIES of any mesh entity ARE STORED. - * Write your own specialization if you need to stored them. - */ -template< typename ConfigTag, - typename EntityTag, - int Dimensions > -struct tnlMeshSuperentityStorage -{ - enum { enabled = false }; + /**** + * Storage of superentities of mesh entities + */ + template< typename MeshEntity > + static constexpr bool superentityStorage( MeshEntity, int SuperentityDimensions ) + { + return true; + //return false; + } + + static_assert( WorldDimensions >= Cell::dimensions, "The number of the cell dimensions cannot be larger than the world dimension." ); }; #endif /* TNLMESHCONFIGBASE_H_ */ diff --git a/src/mesh/config/tnlMeshConfigValidator.h b/src/mesh/config/tnlMeshConfigValidator.h new file mode 100644 index 0000000000000000000000000000000000000000..c9f8e5bed7f46897cc95be680a0b5204a3f89d76 --- /dev/null +++ b/src/mesh/config/tnlMeshConfigValidator.h @@ -0,0 +1,114 @@ +/*************************************************************************** + tnlMeshConfigValidator.h - description + ------------------- + begin : Aug 14, 2015 + copyright : (C) 2015 by Tomas Oberhuber et al. + 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 TNLMESHCONFIGVALIDATOR_H +#define TNLMESHCONFIGVALIDATOR_H + +#include <core/tnlAssert.h> +#include <mesh/topologies/tnlMeshEntityTopology.h> +#include <mesh/tnlDimensionsTag.h> + +template< typename MeshConfig, + typename MeshEntity, + typename dimensions > +class tnlMeshConfigValidatorSubtopologyLayer : +public tnlMeshConfigValidatorSubtopologyLayer< MeshConfig, MeshEntity, typename dimensions::Decrement > +{ + static_assert( ! MeshConfig::subentityStorage( MeshEntity(), dimensions::value ) || + MeshConfig::entityStorage( MeshEntity::dimensions ), "entities of which subentities are stored must be stored" ); + static_assert( ! MeshConfig::subentityStorage( MeshEntity(), dimensions::value ) || + MeshConfig::entityStorage( dimensions::value ), "entities that are stored as subentities must be stored"); + static_assert( ! MeshConfig::subentityOrientationStorage( MeshEntity(), dimensions::value ) || + MeshConfig::subentityStorage( MeshEntity(), dimensions::value ), "orientation can be stored only for subentities that are stored"); +}; + +template< typename MeshConfig, + typename MeshEntity > +class tnlMeshConfigValidatorSubtopologyLayer< MeshConfig, MeshEntity, tnlDimensionsTag< 0 > > +{ + static_assert( ! MeshConfig::subentityStorage( MeshEntity(), 0 ) || + MeshConfig::entityStorage( 0 ), "entities that are stored as subentities must be stored" ); + static_assert( ! MeshConfig::subentityOrientationStorage( MeshEntity(), 0 ), "storage of vertex orientation does not make sense" ); +}; + + +template< typename MeshConfig, + typename MeshEntity, + typename dimensions > +class tnlMeshConfigValidatorSupertopologyLayer : +public tnlMeshConfigValidatorSupertopologyLayer< MeshConfig, MeshEntity, typename dimensions::Decrement > +{ + static_assert( ! MeshConfig::superentityStorage( MeshEntity(), 0 ) || + MeshConfig::entityStorage( MeshEntity::dimensions ), "entities of which superentities are stored must be stored"); + static_assert( ! MeshConfig::superentityStorage( MeshEntity(), 0 ) || + MeshConfig::entityStorage( dimensions::value ), "entities that are stored as superentities must be stored"); +}; + +template< typename MeshConfig, + typename MeshEntity > +class tnlMeshConfigValidatorSupertopologyLayer< MeshConfig, MeshEntity, tnlDimensionsTag< MeshEntity::dimensions > > +{}; + + +template< typename MeshConfig, int dimensions > +class tnlMeshConfigValidatorLayer : + public tnlMeshConfigValidatorLayer< MeshConfig, dimensions - 1 >, + public tnlMeshConfigValidatorSubtopologyLayer< MeshConfig, + typename tnlMeshSubtopology< typename MeshConfig::CellTopology, dimensions >::Topology, + tnlDimensionsTag< dimensions - 1 > >, + public tnlMeshConfigValidatorSupertopologyLayer< MeshConfig, + typename tnlMeshSubtopology< typename MeshConfig::CellTopology, dimensions >::Topology, + tnlDimensionsTag< MeshConfig::CellTopology::dimensions > > +{ + typedef typename tnlMeshSubtopology< typename MeshConfig::CellTopology, dimensions >::Topology Topology; + + static_assert( ! MeshConfig::entityStorage( dimensions ) || MeshConfig::subentityStorage( Topology(), 0 ), "subvertices of all stored entities must be stored"); +}; + +template< typename MeshConfig > +class tnlMeshConfigValidatorLayer< MeshConfig, 0 > +{ +}; + +template< typename MeshConfig > +class tnlMeshConfigValidatorLayerCell : + public tnlMeshConfigValidatorLayer< MeshConfig, MeshConfig::CellTopology::dimensions - 1 >, + public tnlMeshConfigValidatorSubtopologyLayer< MeshConfig, + typename MeshConfig::CellTopology, + tnlDimensionsTag< MeshConfig::CellTopology::dimensions - 1 > > +{ + typedef typename MeshConfig::CellTopology CellTopology; + static const int dimensions = CellTopology::dimensions; + + static_assert( !MeshConfig::entityStorage( dimensions ) || MeshConfig::subentityStorage( CellTopology(), 0 ), "subvertices of all stored entities must be stored"); +}; + +template<typename MeshConfig > +class tnlMeshConfigValidator : public tnlMeshConfigValidatorLayerCell< MeshConfig > +{ + static const int meshDimensions = MeshConfig::CellTopology::dimensions; + + static_assert(1 <= meshDimensions, "zero dimensional meshes are not supported"); + static_assert( meshDimensions <= MeshConfig::worldDimensions, "world dimension must not be less than mesh dimension"); + + static_assert( MeshConfig::entityStorage( 0 ), "mesh vertices must be stored"); + static_assert( MeshConfig::entityStorage( meshDimensions ), "mesh cells must be stored"); +}; + + +#endif /* TNLMESHCONFIGVALIDATOR_H */ + diff --git a/src/mesh/grids/CMakeLists.txt b/src/mesh/grids/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..90e8e99ae35165a01b5f4ef3e515931ee805ab71 --- /dev/null +++ b/src/mesh/grids/CMakeLists.txt @@ -0,0 +1,19 @@ +SET( headers tnlGrid1D.h + tnlGrid1D_impl.h + tnlGrid2D.h + tnlGrid2D_impl.h + tnlGrid3D.h + tnlGrid3D_impl.h + tnlTraverser_Grid1D.h + tnlTraverser_Grid1D_impl.h + tnlTraverser_Grid2D.h + tnlTraverser_Grid2D_impl.h + tnlTraverser_Grid3D.h + tnlTraverser_Grid3D_impl.h ) + +SET( CURRENT_DIR ${CMAKE_SOURCE_DIR}/src/mesh/grids ) +SET( tnl_mesh_grids_SOURCES + ${CURRENT_DIR}/tnlGrid_impl.cpp + PARENT_SCOPE ) + +INSTALL( FILES ${headers} DESTINATION include/tnl-${tnlVersion}/mesh/grids ) \ No newline at end of file diff --git a/src/mesh/tnlGrid1D.h b/src/mesh/grids/tnlGrid1D.h similarity index 99% rename from src/mesh/tnlGrid1D.h rename to src/mesh/grids/tnlGrid1D.h index aca447619c9171ceff774acd8abea1aec2ae2589..6e4665380d7f7c65b5bd472b72a05456dcabcfbf 100644 --- a/src/mesh/tnlGrid1D.h +++ b/src/mesh/grids/tnlGrid1D.h @@ -186,6 +186,6 @@ class tnlGrid< 1, Real, Device, Index > : public tnlObject }; -#include <mesh/tnlGrid1D_impl.h> +#include <mesh/grids/tnlGrid1D_impl.h> #endif /* SRC_MESH_TNLGRID1D_H_ */ diff --git a/src/mesh/tnlGrid1D_impl.h b/src/mesh/grids/tnlGrid1D_impl.h similarity index 92% rename from src/mesh/tnlGrid1D_impl.h rename to src/mesh/grids/tnlGrid1D_impl.h index 61006531c3ce3478c64301de225203d10596c16d..776d9570c502c2bb77372660392ffff94a25a4a1 100644 --- a/src/mesh/tnlGrid1D_impl.h +++ b/src/mesh/grids/tnlGrid1D_impl.h @@ -165,8 +165,7 @@ Index tnlGrid< 1, Real, Device, Index > :: getCellIndex( const CoordinatesType& { tnlAssert( cellCoordinates.x() >= 0 && cellCoordinates.x() < this->getDimensions().x(), cerr << "cellCoordinates.x() = " << cellCoordinates.x() - << " this->getDimensions().x() = " << this->getDimensions().x() - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().x() = " << this->getDimensions().x() ); return cellCoordinates.x(); } @@ -179,8 +178,7 @@ tnlGrid< 1, Real, Device, Index > :: getCellCoordinates( const Index cellIndex ) { tnlAssert( cellIndex >= 0 && cellIndex < this->getNumberOfCells(), cerr << " cellIndex = " << cellIndex - << " this->getNumberOfCells() = " << this->getNumberOfCells() - << " this->getName() " << this->getName(); ); + << " this->getNumberOfCells() = " << this->getNumberOfCells() ); return CoordinatesType( cellIndex ); } @@ -192,8 +190,7 @@ Index tnlGrid< 1, Real, Device, Index > :: getVertexIndex( const CoordinatesType { tnlAssert( vertexCoordinates.x() >= 0 && vertexCoordinates.x() < this->getDimensions().x() + 1, cerr << "vertexCoordinates.x() = " << vertexCoordinates.x() - << " this->getDimensions().x() + 1 = " << this->getDimensions().x() + 1 - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().x() + 1 = " << this->getDimensions().x() + 1 ); return vertexCoordinates.x(); } @@ -206,8 +203,7 @@ tnlGrid< 1, Real, Device, Index > :: getVertexCoordinates( const Index vertexInd { tnlAssert( vertexIndex >= 0 && vertexIndex < this->getNumberOfVertices(), cerr << " vertexIndex = " << vertexIndex - << " this->getNumberOfVertices() = " << this->getNumberOfVertices() - << " this->getName() " << this->getName(); ); + << " this->getNumberOfVertices() = " << this->getNumberOfVertices() ); return CoordinatesType( vertexIndex ); } @@ -222,8 +218,7 @@ Index tnlGrid< 1, Real, Device, Index > :: getCellNextToCell( const IndexType& c cellIndex + dx < this->getNumberOfCells(), cerr << " cellIndex = " << cellIndex << " dx = " << dx - << " this->getNumberOfCells() = " << this->getNumberOfCells() - << " this->getName() " << this->getName(); ); + << " this->getNumberOfCells() = " << this->getNumberOfCells() ); return cellIndex + dx; } @@ -281,8 +276,7 @@ Vertex tnlGrid< 1, Real, Device, Index >::getCellCenter( const CoordinatesType& { tnlAssert( cellCoordinates.x() >= 0 && cellCoordinates.x() < this->getDimensions().x(), cerr << "cellCoordinates.x() = " << cellCoordinates.x() - << " this->getDimensions().x() = " << this->getDimensions().x() - << " this->getName() = " << this->getName(); ) + << " this->getDimensions().x() = " << this->getDimensions().x() ); return this->origin.x() + ( cellCoordinates.x() + 0.5 ) * this->cellProportions.x(); } @@ -295,8 +289,7 @@ Vertex tnlGrid< 1, Real, Device, Index >::getCellCenter( const IndexType& cellIn { tnlAssert( cellIndex >= 0 && cellIndex < this->getNumberOfCells(), cerr << " cellIndex = " << cellIndex - << " this->getNumberOfCells() = " << this->getNumberOfCells() - << " this->getName() " << this->getName(); ); + << " this->getNumberOfCells() = " << this->getNumberOfCells() ); return this->getCellCenter< VertexType >( this->getCellCoordinates( cellIndex ) ); } @@ -309,8 +302,7 @@ Vertex tnlGrid< 1, Real, Device, Index >::getVertex( const CoordinatesType& vert { tnlAssert( vertexCoordinates.x() >= 0 && vertexCoordinates.x() < this->getDimensions().x() + 1, cerr << "vertexCoordinates.x() = " << vertexCoordinates.x() - << " this->getDimensions().x() = " << this->getDimensions().x() - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().x() = " << this->getDimensions().x() ); return Vertex( this->origin.x() + vertexCoordinates.x() * this->cellProportions.x() ); } @@ -340,8 +332,7 @@ bool tnlGrid< 1, Real, Device, Index > :: isBoundaryCell( const CoordinatesType& { tnlAssert( cellCoordinates.x() >= 0 && cellCoordinates.x() < this->getDimensions().x(), cerr << "cellCoordinates.x() = " << cellCoordinates.x() - << " this->getDimensions().x() = " << this->getDimensions().x() - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().x() = " << this->getDimensions().x() ); if( cellCoordinates.x() == 0 || cellCoordinates.x() == this->getDimensions().x() - 1 ) return true; return false; @@ -357,8 +348,7 @@ isBoundaryCell( const IndexType& cellIndex ) const { tnlAssert( cellIndex >= 0 && cellIndex < this->getNumberOfCells(), cerr << " cellIndex = " << cellIndex - << " this->getNumberOfCells() = " << this->getNumberOfCells() - << " this->getName() " << this->getName(); ); + << " this->getNumberOfCells() = " << this->getNumberOfCells() ); return this->isBoundaryCell( this->getCellCoordinates( cellIndex ) ); } @@ -370,8 +360,7 @@ bool tnlGrid< 1, Real, Device, Index > :: isBoundaryVertex( const CoordinatesTyp { tnlAssert( vertexCoordinates.x() >= 0 && vertexCoordinates.x() < this->getDimensions().x() + 1, cerr << "vertexCoordinates.x() = " << vertexCoordinates.x() - << " this->getDimensions().x() + 1 = " << this->getDimensions().x() + 1 - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().x() + 1 = " << this->getDimensions().x() + 1 ); if( vertexCoordinates.x() == 0 || vertexCoordinates.x() == this->getDimensions().x() ) return true; return false; @@ -425,8 +414,7 @@ bool tnlGrid< 1, Real, Device, Index >::save( tnlFile& file ) const ! this->proportions.save( file ) || ! this->dimensions.save( file ) ) { - cerr << "I was not able to save the domain description of the tnlGrid " - << this -> getName() << endl; + cerr << "I was not able to save the domain description of a tnlGrid." << endl; return false; } return true; @@ -444,8 +432,7 @@ bool tnlGrid< 1, Real, Device, Index > :: load( tnlFile& file ) ! this->proportions.load( file ) || ! dimensions.load( file ) ) { - cerr << "I was not able to load the domain description of the tnlGrid " - << this -> getName() << endl; + cerr << "I was not able to load the domain description of a tnlGrid." << endl; return false; } this -> setDimensions( dimensions ); @@ -490,8 +477,9 @@ bool tnlGrid< 1, Real, Device, Index > :: write( const MeshFunction& function, { if( this->getNumberOfCells() != function. getSize() ) { - cerr << "The size ( " << function. getSize() << " ) of the mesh function " << function. getName() - << " does not agree with the DOFs ( " << this -> getNumberOfCells() << " ) of the mesh " << this -> getName() << "." << endl; + cerr << "The size ( " << function. getSize() + << " ) of the mesh function does not agree with the DOFs ( " + << this -> getNumberOfCells() << " ) of a mesh." << endl; return false; } fstream file; diff --git a/src/mesh/tnlGrid2D.h b/src/mesh/grids/tnlGrid2D.h similarity index 99% rename from src/mesh/tnlGrid2D.h rename to src/mesh/grids/tnlGrid2D.h index e1dd1d9a79e4cad050649f7f33d1ab37abd9cc78..79fe912ec1d351ae706e4b36bc3d2884b2ff714d 100644 --- a/src/mesh/tnlGrid2D.h +++ b/src/mesh/grids/tnlGrid2D.h @@ -250,6 +250,6 @@ class tnlGrid< 2, Real, Device, Index > : public tnlObject }; -#include <mesh/tnlGrid2D_impl.h> +#include <mesh/grids/tnlGrid2D_impl.h> #endif /* SRC_MESH_TNLGRID2D_H_ */ diff --git a/src/mesh/tnlGrid2D_impl.h b/src/mesh/grids/tnlGrid2D_impl.h similarity index 91% rename from src/mesh/tnlGrid2D_impl.h rename to src/mesh/grids/tnlGrid2D_impl.h index 544928509b59a315d1db5afeed3ac77e08ed781c..000077e05fddc0ed29d0a43a0b5e4d524f7132a5 100644 --- a/src/mesh/tnlGrid2D_impl.h +++ b/src/mesh/grids/tnlGrid2D_impl.h @@ -181,12 +181,10 @@ Index tnlGrid< 2, Real, Device, Index > :: getCellIndex( const CoordinatesType& { tnlAssert( cellCoordinates.x() >= 0 && cellCoordinates.x() < this->getDimensions().x(), cerr << "cellCoordinates.x() = " << cellCoordinates.x() - << " this->getDimensions().x() = " << this->getDimensions().x() - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().x() = " << this->getDimensions().x() ); tnlAssert( cellCoordinates.y() >= 0 && cellCoordinates.y() < this->getDimensions().y(), cerr << "cellCoordinates.y() = " << cellCoordinates.y() - << " this->getDimensions().y() = " << this->getDimensions().y() - << " this->getName() = " << this->getName(); ) + << " this->getDimensions().y() = " << this->getDimensions().y() ) return cellCoordinates.y() * this->dimensions.x() + cellCoordinates.x(); } @@ -200,8 +198,7 @@ tnlGrid< 2, Real, Device, Index >::getCellCoordinates( const Index cellIndex ) c { tnlAssert( cellIndex >= 0 && cellIndex < this->getNumberOfCells(), cerr << " cellIndex = " << cellIndex - << " this->getNumberOfCells() = " << this->getNumberOfCells() - << " this->getName() " << this->getName(); ); + << " this->getNumberOfCells() = " << this->getNumberOfCells() ); return CoordinatesType( cellIndex % this->getDimensions().x(), cellIndex / this->getDimensions().x() ); } @@ -217,22 +214,18 @@ Index tnlGrid< 2, Real, Device, Index >::getFaceIndex( const CoordinatesType& fa { tnlAssert( faceCoordinates.x() >= 0 && faceCoordinates.x() < this->getDimensions().x() + 1, cerr << "faceCoordinates.x() = " << faceCoordinates.x() - << " this->getDimensions().x() + 1 = " << this->getDimensions().x() + 1 - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().x() + 1 = " << this->getDimensions().x() + 1 ); tnlAssert( faceCoordinates.y() >= 0 && faceCoordinates.y() < this->getDimensions().y(), cerr << "faceCoordinates.y() = " << faceCoordinates.y() - << " this->getDimensions().y() = " << this->getDimensions().y() - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().y() = " << this->getDimensions().y() ); return faceCoordinates.y() * ( this->getDimensions().x() + 1 ) + faceCoordinates.x(); } tnlAssert( faceCoordinates.x() >= 0 && faceCoordinates.x() < this->getDimensions().x(), cerr << "faceCoordinates.x() = " << faceCoordinates.x() - << " this->getDimensions().x() = " << this->getDimensions().x() - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().x() = " << this->getDimensions().x() ); tnlAssert( faceCoordinates.y() >= 0 && faceCoordinates.y() < this->getDimensions().y() + 1, cerr << "faceCoordinates.y() = " << faceCoordinates.y() - << " this->getDimensions().y() + 1 = " << this->getDimensions().y() + 1 - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().y() + 1 = " << this->getDimensions().y() + 1 ); return this->numberOfNxFaces + faceCoordinates.y() * this->getDimensions().x() + faceCoordinates.x(); } @@ -245,8 +238,7 @@ tnlGrid< 2, Real, Device, Index >::getFaceCoordinates( const Index faceIndex, in { tnlAssert( faceIndex >= 0 && faceIndex < ( this->template getNumberOfFaces< 1, 1 >() ), cerr << " faceIndex = " << faceIndex - << " this->getNumberOfFaces() = " << ( this->template getNumberOfFaces< 1, 1 >() ) - << " this->getName() " << this->getName(); ); + << " this->getNumberOfFaces() = " << ( this->template getNumberOfFaces< 1, 1 >() ) ); if( faceIndex < this->numberOfNxFaces ) { nx = 1; @@ -269,12 +261,10 @@ Index tnlGrid< 2, Real, Device, Index > :: getVertexIndex( const CoordinatesType { tnlAssert( vertexCoordinates.x() >= 0 && vertexCoordinates.x() < this->getDimensions().x() + 1, cerr << "vertexCoordinates.x() = " << vertexCoordinates.x() - << " this->getDimensions().x() + 1 = " << this->getDimensions().x() + 1 - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().x() + 1 = " << this->getDimensions().x() + 1 ); tnlAssert( vertexCoordinates.y() >= 0 && vertexCoordinates.y() < this->getDimensions().y() + 1, cerr << "vertexCoordinates.y() = " << vertexCoordinates.y() - << " this->getDimensions().y() + 1 = " << this->getDimensions().y() + 1 - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().y() + 1 = " << this->getDimensions().y() + 1 ); return vertexCoordinates.y() * ( this->dimensions.x() +1 ) + vertexCoordinates.x(); } @@ -287,8 +277,7 @@ tnlGrid< 2, Real, Device, Index > :: getVertexCoordinates( const Index vertexInd { tnlAssert( vertexIndex >= 0 && vertexIndex < this->getNumberOfVertices(), cerr << " vertexIndex = " << vertexIndex - << " this->getNumberOfVertices() = " << this->getNumberOfVertices() - << " this->getName() " << this->getName(); ); + << " this->getNumberOfVertices() = " << this->getNumberOfVertices() ); const IndexType aux = this->dimensions.x() + 1; return CoordinatesType( vertexIndex % aux, vertexIndex / aux ); } @@ -306,8 +295,7 @@ Index tnlGrid< 2, Real, Device, Index >::getCellNextToCell( const IndexType& cel cerr << " cellIndex = " << cellIndex << " dx = " << dx << " dy = " << dy - << " this->getNumberOfCells() = " << this->getNumberOfCells() - << " this->getName() " << this->getName(); ); + << " this->getNumberOfCells() = " << this->getNumberOfCells() ); return result; } @@ -331,8 +319,7 @@ Index tnlGrid< 2, Real, Device, Index >::getFaceNextToCell( const IndexType& cel cerr << " cellIndex = " << cellIndex << " nx = " << nx << " ny = " << ny - << " this->getNumberOfCells() = " << ( this->template getNumberOfCells< 1, 1 >() ) - << " this->getName() " << this->getName(); ); + << " this->getNumberOfCells() = " << ( this->getNumberOfCells() ) ); return result; } @@ -474,12 +461,10 @@ Vertex tnlGrid< 2, Real, Device, Index > :: getCellCenter( const CoordinatesType { tnlAssert( cellCoordinates.x() >= 0 && cellCoordinates.x() < this->getDimensions().x(), cerr << "cellCoordinates.x() = " << cellCoordinates.x() - << " this->getDimensions().x() = " << this->getDimensions().x() - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().x() = " << this->getDimensions().x() ); tnlAssert( cellCoordinates.y() >= 0 && cellCoordinates.y() < this->getDimensions().y(), cerr << "cellCoordinates.y() = " << cellCoordinates.y() - << " this->getDimensions().y() = " << this->getDimensions().y() - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().y() = " << this->getDimensions().y() ); return Vertex( this->origin.x() + ( cellCoordinates.x() + 0.5 ) * this->cellProportions.x(), this->origin.y() + ( cellCoordinates.y() + 0.5 ) * this->cellProportions.y() ); @@ -494,8 +479,7 @@ Vertex tnlGrid< 2, Real, Device, Index >::getCellCenter( const IndexType& cellIn { tnlAssert( cellIndex >= 0 && cellIndex < this->getNumberOfCells(), cerr << " cellIndex = " << cellIndex - << " this->getNumberOfCells() = " << this->getNumberOfCells() - << " this->getName() " << this->getName(); ); + << " this->getNumberOfCells() = " << this->getNumberOfCells() ); return this->getCellCenter< VertexType >( this->getCellCoordinates( cellIndex ) ); } @@ -511,12 +495,10 @@ Vertex tnlGrid< 2, Real, Device, Index > :: getFaceCenter( const CoordinatesType { tnlAssert( faceCoordinates.x() >= 0 && faceCoordinates.x() < this->getDimensions().x() + 1, cerr << "faceCoordinates.x() = " << faceCoordinates.x() - << " this->getDimensions().x() + 1 = " << this->getDimensions().x() + 1 - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().x() + 1 = " << this->getDimensions().x() + 1 ); tnlAssert( faceCoordinates.y() >= 0 && faceCoordinates.y() < this->getDimensions().y(), cerr << "faceCoordinates.y() = " << faceCoordinates.y() - << " this->getDimensions().y() = " << this->getDimensions().y() - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().y() = " << this->getDimensions().y() ); return Vertex( this->origin.x() + faceCoordinates.x() * this->cellProportions.x(), this->origin.y() + ( faceCoordinates.y() + 0.5 ) * this->cellProportions.y() ); } @@ -524,12 +506,10 @@ Vertex tnlGrid< 2, Real, Device, Index > :: getFaceCenter( const CoordinatesType { tnlAssert( faceCoordinates.x() >= 0 && faceCoordinates.x() < this->getDimensions().x(), cerr << "faceCoordinates.x() = " << faceCoordinates.x() - << " this->getDimensions().x() = " << this->getDimensions().x() - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().x() = " << this->getDimensions().x() ); tnlAssert( faceCoordinates.y() >= 0 && faceCoordinates.y() < this->getDimensions().y() + 1, cerr << "faceCoordinates.y() = " << faceCoordinates.y() - << " this->getDimensions().y() + 1 = " << this->getDimensions().y() + 1 - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().y() + 1 = " << this->getDimensions().y() + 1 ); return Vertex( this->origin.x() + ( faceCoordinates.x() + 0.5 ) * this->cellProportions.x(), this->origin.y() + faceCoordinates.y() * this->cellProportions.y() ); } @@ -545,12 +525,10 @@ Vertex tnlGrid< 2, Real, Device, Index >::getVertex( const CoordinatesType& vert { tnlAssert( vertexCoordinates.x() >= 0 && vertexCoordinates.x() < this->getDimensions().x() + 1, cerr << "vertexCoordinates.x() = " << vertexCoordinates.x() - << " this->getDimensions().x() = " << this->getDimensions().x() - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().x() = " << this->getDimensions().x() ); tnlAssert( vertexCoordinates.y() >= 0 && vertexCoordinates.y() < this->getDimensions().y() + 1, cerr << "vertexCoordinates.y() = " << vertexCoordinates.y() - << " this->getDimensions().y() = " << this->getDimensions().y() - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().y() = " << this->getDimensions().y() ); return Vertex( this->origin.x() + vertexCoordinates.x() * this->cellProportions.x(), this->origin.y() + vertexCoordinates.y() * this->cellProportions.y() ); @@ -593,12 +571,10 @@ bool tnlGrid< 2, Real, Device, Index > :: isBoundaryCell( const CoordinatesType& { tnlAssert( cellCoordinates.x() >= 0 && cellCoordinates.x() < this->getDimensions().x(), cerr << "cellCoordinates.x() = " << cellCoordinates.x() - << " this->getDimensions().x() = " << this->getDimensions().x() - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().x() = " << this->getDimensions().x() ); tnlAssert( cellCoordinates.y() >= 0 && cellCoordinates.y() < this->getDimensions().y(), cerr << "cellCoordinates.y() = " << cellCoordinates.y() - << " this->getDimensions().y() = " << this->getDimensions().y() - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().y() = " << this->getDimensions().y() ); if( cellCoordinates.x() == 0 || cellCoordinates.x() == this->getDimensions().x() - 1 || cellCoordinates.y() == 0 || cellCoordinates.y() == this->getDimensions().y() - 1 ) @@ -617,8 +593,7 @@ isBoundaryCell( const IndexType& cellIndex ) const { tnlAssert( cellIndex >= 0 && cellIndex < this->getNumberOfCells(), cerr << " cellIndex = " << cellIndex - << " this->getNumberOfCells() = " << this->getNumberOfCells() - << " this->getName() " << this->getName(); ); + << " this->getNumberOfCells() = " << this->getNumberOfCells() ); return this->isBoundaryCell( this->getCellCoordinates( cellIndex ) ); } @@ -635,24 +610,20 @@ bool tnlGrid< 2, Real, Device, Index > :: isBoundaryFace( const CoordinatesType& { tnlAssert( faceCoordinates.x() >= 0 && faceCoordinates.x() < this->getDimensions().x() + 1, cerr << "faceCoordinates.x() = " << faceCoordinates.x() - << " this->getDimensions().x() + 1 = " << this->getDimensions().x() + 1 - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().x() + 1 = " << this->getDimensions().x() + 1 ); tnlAssert( faceCoordinates.y() >= 0 && faceCoordinates.y() < this->getDimensions().y(), cerr << "faceCoordinates.y() = " << faceCoordinates.y() - << " this->getDimensions().y() = " << this->getDimensions().y() - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().y() = " << this->getDimensions().y() ); if( faceCoordinates.x() == 0 || faceCoordinates.x() == this->getDimensions().x() ) return true; return false; } tnlAssert( faceCoordinates.x() >= 0 && faceCoordinates.x() < this->getDimensions().x(), cerr << "faceCoordinates.x() = " << faceCoordinates.x() - << " this->getDimensions().x() = " << this->getDimensions().x() - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().x() = " << this->getDimensions().x() ); tnlAssert( faceCoordinates.y() >= 0 && faceCoordinates.y() < this->getDimensions().y() + 1, cerr << "faceCoordinates.y() = " << faceCoordinates.y() - << " this->getDimensions().y() + 1 = " << this->getDimensions().y() + 1 - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().y() + 1 = " << this->getDimensions().y() + 1 ); if( faceCoordinates.y() == 0 || faceCoordinates.y() == this->getDimensions().y() ) return true; return false; @@ -667,12 +638,10 @@ bool tnlGrid< 2, Real, Device, Index > :: isBoundaryVertex( const CoordinatesTyp { tnlAssert( vertexCoordinates.x() >= 0 && vertexCoordinates.x() < this->getDimensions().x() + 1, cerr << "vertexCoordinates.x() = " << vertexCoordinates.x() - << " this->getDimensions().x() + 1 = " << this->getDimensions().x() + 1 - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().x() + 1 = " << this->getDimensions().x() + 1 ); tnlAssert( vertexCoordinates.y() >= 0 && vertexCoordinates.y() < this->getDimensions().y() + 1, cerr << "vertexCoordinates.y() = " << vertexCoordinates.y() - << " this->getDimensions().y() + 1 = " << this->getDimensions().y() + 1 - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().y() + 1 = " << this->getDimensions().y() + 1 ); if( vertexCoordinates.x() == 0 || vertexCoordinates.x() == this->getDimensions().x() || vertexCoordinates.y() == 0 || vertexCoordinates.y() == this->getDimensions().y() ) @@ -751,8 +720,7 @@ bool tnlGrid< 2, Real, Device, Index > :: save( tnlFile& file ) const ! this->proportions.save( file ) || ! this -> dimensions.save( file ) ) { - cerr << "I was not able to save the domain description of the tnlGrid " - << this -> getName() << endl; + cerr << "I was not able to save the domain description of a tnlGrid." << endl; return false; } return true; @@ -770,8 +738,7 @@ bool tnlGrid< 2, Real, Device, Index > :: load( tnlFile& file ) ! this->proportions.load( file ) || ! dimensions.load( file ) ) { - cerr << "I was not able to load the domain description of the tnlGrid " - << this -> getName() << endl; + cerr << "I was not able to load the domain description of a tnlGrid." << endl; return false; } this -> setDimensions( dimensions ); @@ -914,8 +881,9 @@ bool tnlGrid< 2, Real, Device, Index > :: write( const MeshFunction& function, { if( this->getNumberOfCells() != function. getSize() ) { - cerr << "The size ( " << function. getSize() << " ) of the mesh function " << function. getName() - << " does not agree with the DOFs ( " << this->getNumberOfCells() << " ) of the mesh " << this -> getName() << "." << endl; + cerr << "The size ( " << function. getSize() + << " ) of a mesh function does not agree with the DOFs ( " + << this->getNumberOfCells() << " ) of a mesh." << endl; return false; } fstream file; diff --git a/src/mesh/tnlGrid3D.h b/src/mesh/grids/tnlGrid3D.h similarity index 99% rename from src/mesh/tnlGrid3D.h rename to src/mesh/grids/tnlGrid3D.h index b11c880f08126e167542d78bf81ccc1abde873cd..d5c46c714e18df8c06d556a1566d8e1560f670bf 100644 --- a/src/mesh/tnlGrid3D.h +++ b/src/mesh/grids/tnlGrid3D.h @@ -310,6 +310,6 @@ class tnlGrid< 3, Real, Device, Index > : public tnlObject }; -#include <mesh/tnlGrid3D_impl.h> +#include <mesh/grids/tnlGrid3D_impl.h> #endif /* SRC_MESH_TNLGRID3D_H_ */ diff --git a/src/mesh/tnlGrid3D_impl.h b/src/mesh/grids/tnlGrid3D_impl.h similarity index 87% rename from src/mesh/tnlGrid3D_impl.h rename to src/mesh/grids/tnlGrid3D_impl.h index 147f038e595789a7d6ce4d0d4d4b74aa0fb18a4c..377500c4e6f8b4a6b3f23357e55deb0acdd764e7 100644 --- a/src/mesh/tnlGrid3D_impl.h +++ b/src/mesh/grids/tnlGrid3D_impl.h @@ -209,16 +209,13 @@ Index tnlGrid< 3, Real, Device, Index > :: getCellIndex( const CoordinatesType& { tnlAssert( cellCoordinates.x() >= 0 && cellCoordinates.x() < this->getDimensions().x(), cerr << "cellCoordinates.x() = " << cellCoordinates.x() - << " this->getDimensions().x() = " << this->getDimensions().x() - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().x() = " << this->getDimensions().x() ); tnlAssert( cellCoordinates.y() >= 0 && cellCoordinates.y() < this->getDimensions().y(), cerr << "cellCoordinates.y() = " << cellCoordinates.y() - << " this->getDimensions().y() = " << this->getDimensions().y() - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().y() = " << this->getDimensions().y() ); tnlAssert( cellCoordinates.z() >= 0 && cellCoordinates.z() < this->getDimensions().z(), cerr << "cellCoordinates.z() = " << cellCoordinates.z() - << " this->getDimensions().z() = " << this->getDimensions().z() - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().z() = " << this->getDimensions().z() ); return ( cellCoordinates.z() * this->dimensions.y() + cellCoordinates.y() ) * this->dimensions.x() + cellCoordinates.x(); } @@ -231,8 +228,7 @@ tnlGrid< 3, Real, Device, Index > :: getCellCoordinates( const Index cellIndex ) { tnlAssert( cellIndex >= 0 && cellIndex < this->getNumberOfCells(), cerr << " cellIndex = " << cellIndex - << " this->getNumberOfCells() = " << this->getNumberOfCells() - << " this->getName() " << this->getName(); ); + << " this->getNumberOfCells() = " << this->getNumberOfCells() ); return CoordinatesType( cellIndex % this->dimensions.x(), ( cellIndex / this->dimensions.x() ) % this->dimensions.y(), @@ -251,32 +247,26 @@ Index tnlGrid< 3, Real, Device, Index >::getFaceIndex( const CoordinatesType& fa { tnlAssert( faceCoordinates.x() >= 0 && faceCoordinates.x() < this->getDimensions().x() + 1, cerr << "faceCoordinates.x() = " << faceCoordinates.x() - << " this->getDimensions().x() + 1 = " << this->getDimensions().x() + 1 - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().x() + 1 = " << this->getDimensions().x() + 1 ); tnlAssert( faceCoordinates.y() >= 0 && faceCoordinates.y() < this->getDimensions().y(), cerr << "faceCoordinates.y() = " << faceCoordinates.y() - << " this->getDimensions().y() = " << this->getDimensions().y() - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().y() = " << this->getDimensions().y() ); tnlAssert( faceCoordinates.z() >= 0 && faceCoordinates.z() < this->getDimensions().z(), cerr << "faceCoordinates.z() = " << faceCoordinates.z() - << " this->getDimensions().z() = " << this->getDimensions().z() - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().z() = " << this->getDimensions().z() ); return ( faceCoordinates.z() * this->getDimensions().y() + faceCoordinates.y() ) * ( this->getDimensions().x() + 1 ) + faceCoordinates.x(); } if( ny ) { tnlAssert( faceCoordinates.x() >= 0 && faceCoordinates.x() < this->getDimensions().x(), cerr << "faceCoordinates.x() = " << faceCoordinates.x() - << " this->getDimensions().x() = " << this->getDimensions().x() - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().x() = " << this->getDimensions().x() ); tnlAssert( faceCoordinates.y() >= 0 && faceCoordinates.y() < this->getDimensions().y() + 1, cerr << "faceCoordinates.y() = " << faceCoordinates.y() - << " this->getDimensions().y() + 1 = " << this->getDimensions().y() + 1 - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().y() + 1 = " << this->getDimensions().y() + 1 ); tnlAssert( faceCoordinates.z() >= 0 && faceCoordinates.z() < this->getDimensions().z(), cerr << "faceCoordinates.z() = " << faceCoordinates.z() - << " this->getDimensions().z() = " << this->getDimensions().z() - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().z() = " << this->getDimensions().z() ); return this->numberOfNxFaces + ( faceCoordinates.z() * ( this->getDimensions().y() + 1 ) + faceCoordinates.y() ) * this->getDimensions().x() + faceCoordinates.x(); } @@ -284,16 +274,13 @@ Index tnlGrid< 3, Real, Device, Index >::getFaceIndex( const CoordinatesType& fa { tnlAssert( faceCoordinates.x() >= 0 && faceCoordinates.x() < this->getDimensions().x(), cerr << "faceCoordinates.x() = " << faceCoordinates.x() - << " this->getDimensions().x() = " << this->getDimensions().x() - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().x() = " << this->getDimensions().x() ); tnlAssert( faceCoordinates.y() >= 0 && faceCoordinates.y() < this->getDimensions().y(), cerr << "faceCoordinates.y() = " << faceCoordinates.y() - << " this->getDimensions().y()= " << this->getDimensions().y() - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().y()= " << this->getDimensions().y() ); tnlAssert( faceCoordinates.z() >= 0 && faceCoordinates.z() < this->getDimensions().z() + 1, cerr << "faceCoordinates.z() = " << faceCoordinates.z() - << " this->getDimensions().z() + 1 = " << this->getDimensions().z() + 1 - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().z() + 1 = " << this->getDimensions().z() + 1 ); return this->numberOfNxAndNyFaces + ( faceCoordinates.z() * this->getDimensions().y() + faceCoordinates.y() ) * this->getDimensions().x() + faceCoordinates.x(); } @@ -308,8 +295,7 @@ tnlGrid< 3, Real, Device, Index >::getFaceCoordinates( const Index faceIndex, in { tnlAssert( faceIndex >= 0 && faceIndex < this->getNumberOfFaces(), cerr << " faceIndex = " << faceIndex - << " this->getNumberOfFaces() = " << this->getNumberOfFaces() - << " this->getName() " << this->getName(); ); + << " this->getNumberOfFaces() = " << this->getNumberOfFaces() ); if( faceIndex < this->numberOfNxFaces ) { nx = 1; @@ -352,32 +338,26 @@ Index tnlGrid< 3, Real, Device, Index > :: getEdgeIndex( const CoordinatesType& { tnlAssert( edgeCoordinates.x() >= 0 && edgeCoordinates.x() < this->getDimensions().x(), cerr << "edgeCoordinates.x() = " << edgeCoordinates.x() - << " this->getDimensions().x() = " << this->getDimensions().x() - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().x() = " << this->getDimensions().x() ); tnlAssert( edgeCoordinates.y() >= 0 && edgeCoordinates.y() < this->getDimensions().y() + 1, cerr << "edgeCoordinates.y() = " << edgeCoordinates.y() - << " this->getDimensions().y() + 1 = " << this->getDimensions().y() + 1 - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().y() + 1 = " << this->getDimensions().y() + 1 ); tnlAssert( edgeCoordinates.z() >= 0 && edgeCoordinates.z() < this->getDimensions().z() + 1, cerr << "edgeCoordinates.z() = " << edgeCoordinates.z() - << " this->getDimensions().z() + 1 = " << this->getDimensions().z() + 1 - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().z() + 1 = " << this->getDimensions().z() + 1 ); return ( edgeCoordinates.z() * ( this->getDimensions().y() + 1 ) + edgeCoordinates.y() ) * this->getDimensions().x() + edgeCoordinates.x(); } if( dy ) { tnlAssert( edgeCoordinates.x() >= 0 && edgeCoordinates.x() < this->getDimensions().x() + 1, cerr << "edgeCoordinates.x() = " << edgeCoordinates.x() - << " this->getDimensions().x() + 1 = " << this->getDimensions().x() + 1 - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().x() + 1 = " << this->getDimensions().x() + 1 ); tnlAssert( edgeCoordinates.y() >= 0 && edgeCoordinates.y() < this->getDimensions().y(), cerr << "edgeCoordinates.y() = " << edgeCoordinates.y() - << " this->getDimensions().y() = " << this->getDimensions().y() - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().y() = " << this->getDimensions().y() ); tnlAssert( edgeCoordinates.z() >= 0 && edgeCoordinates.z() < this->getDimensions().z() + 1, cerr << "edgeCoordinates.z() = " << edgeCoordinates.z() - << " this->getDimensions().z() + 1 = " << this->getDimensions().z() + 1 - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().z() + 1 = " << this->getDimensions().z() + 1; ); return this->numberOfDxEdges + ( edgeCoordinates.z() * this->getDimensions().y() + edgeCoordinates.y() ) * ( this->getDimensions().x() + 1 ) + edgeCoordinates.x(); } @@ -385,16 +365,13 @@ Index tnlGrid< 3, Real, Device, Index > :: getEdgeIndex( const CoordinatesType& { tnlAssert( edgeCoordinates.x() >= 0 && edgeCoordinates.x() < this->getDimensions().x() + 1, cerr << "edgeCoordinates.x() = " << edgeCoordinates.x() - << " this->getDimensions().x() = " << this->getDimensions().x() - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().x() = " << this->getDimensions().x() ); tnlAssert( edgeCoordinates.y() >= 0 && edgeCoordinates.y() < this->getDimensions().y() + 1, cerr << "edgeCoordinates.y() = " << edgeCoordinates.y() - << " this->getDimensions().y() + 1 = " << this->getDimensions().y() + 1 - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().y() + 1 = " << this->getDimensions().y() + 1 ); tnlAssert( edgeCoordinates.z() >= 0 && edgeCoordinates.z() < this->getDimensions().z(), cerr << "edgeCoordinates.z() = " << edgeCoordinates.z() - << " this->getDimensions().z() = " << this->getDimensions().z() - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().z() = " << this->getDimensions().z() ); return this->numberOfDxAndDyEdges + ( edgeCoordinates.z() * ( this->getDimensions().y() + 1 ) + edgeCoordinates.y() ) * ( this->getDimensions().x() + 1 ) + edgeCoordinates.x(); } @@ -409,8 +386,7 @@ tnlGrid< 3, Real, Device, Index > :: getEdgeCoordinates( const Index edgeIndex, { tnlAssert( edgeIndex >= 0 && edgeIndex < this->getNumberOfEdges(), cerr << " edgeIndex = " << edgeIndex - << " this->getNumberOfEdges() = " << this->getNumberOfEdges() - << " this->getName() " << this->getName(); ); + << " this->getNumberOfEdges() = " << this->getNumberOfEdges() ); if( edgeIndex < this->numberOfDxEdges ) { dx = 1; @@ -452,16 +428,13 @@ Index tnlGrid< 3, Real, Device, Index > :: getVertexIndex( const CoordinatesType { tnlAssert( vertexCoordinates.x() >= 0 && vertexCoordinates.x() < this->getDimensions().x() + 1, cerr << "vertexCoordinates.x() = " << vertexCoordinates.x() - << " this->getDimensions().x() + 1 = " << this->getDimensions().x() + 1 - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().x() + 1 = " << this->getDimensions().x() + 1 ); tnlAssert( vertexCoordinates.y() >= 0 && vertexCoordinates.y() < this->getDimensions().y() + 1, cerr << "vertexCoordinates.y() = " << vertexCoordinates.y() - << " this->getDimensions().y() + 1 = " << this->getDimensions().y() + 1 - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().y() + 1 = " << this->getDimensions().y() + 1 ); tnlAssert( vertexCoordinates.z() >= 0 && vertexCoordinates.z() < this->getDimensions().z() + 1, cerr << "vertexCoordinates.z() = " << vertexCoordinates.z() - << " this->getDimensions().z() + 1 = " << this->getDimensions().z() + 1 - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().z() + 1 = " << this->getDimensions().z() + 1 ); return ( vertexCoordinates.z() * ( this->getDimensions().y() + 1 ) + vertexCoordinates.y() ) * ( this->getDimensions().x() + 1 ) + vertexCoordinates.x(); } @@ -475,8 +448,7 @@ tnlGrid< 3, Real, Device, Index > :: getVertexCoordinates( const Index vertexInd { tnlAssert( vertexIndex >= 0 && vertexIndex < this->getNumberOfVertices(), cerr << " vertexIndex = " << vertexIndex - << " this->getNumberOfVertices() = " << this->getNumberOfVertices() - << " this->getName() " << this->getName(); ); + << " this->getNumberOfVertices() = " << this->getNumberOfVertices() ); const IndexType auxX = this->getDimensions().x() + 1; const IndexType auxY = this->getDimensions().y() + 1; const IndexType auxZ = this->getDimensions().z() + 1; @@ -502,8 +474,7 @@ Index tnlGrid< 3, Real, Device, Index > :: getCellNextToCell( const IndexType& c << " dx = " << dx << " dy = " << dy << " dz = " << dz - << " this->getNumberOfCells() = " << this->getNumberOfCells() - << " this->getName() " << this->getName(); ); + << " this->getNumberOfCells() = " << this->getNumberOfCells() ); return cellIndex + dx + dy * this->getDimensions().x() + dz * this->cellZNeighboursStep; @@ -533,8 +504,7 @@ Index tnlGrid< 3, Real, Device, Index >::getFaceNextToCell( const IndexType& cel << " nx = " << nx << " ny = " << ny << " nz = " << nz - << " this->getNumberOfCells() = " << this->getNumberOfCells() - << " this->getName() " << this->getName(); ); + << " this->getNumberOfCells() = " << this->getNumberOfCells() ); return result; } @@ -582,8 +552,7 @@ Index tnlGrid< 3, Real, Device, Index >::getCellNextToFace( const IndexType& fac << " nx = " << nx << " ny = " << ny << " nz = " << nz - << " this->getNumberOfCells() = " << this->getNumberOfCells() - << " this->getName() " << this->getName(); ); + << " this->getNumberOfCells() = " << this->getNumberOfCells() ); return result; } @@ -768,16 +737,13 @@ Vertex tnlGrid< 3, Real, Device, Index > :: getCellCenter( const CoordinatesType { tnlAssert( cellCoordinates.x() >= 0 && cellCoordinates.x() < this->getDimensions().x(), cerr << "cellCoordinates.x() = " << cellCoordinates.x() - << " this->getDimensions().x() = " << this->getDimensions().x() - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().x() = " << this->getDimensions().x() ); tnlAssert( cellCoordinates.y() >= 0 && cellCoordinates.y() < this->getDimensions().y(), cerr << "cellCoordinates.y() = " << cellCoordinates.y() - << " this->getDimensions().y() = " << this->getDimensions().y() - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().y() = " << this->getDimensions().y() ); tnlAssert( cellCoordinates.z() >= 0 && cellCoordinates.z() < this->getDimensions().z(), cerr << "cellCoordinates.z() = " << cellCoordinates.z() - << " this->getDimensions().z() = " << this->getDimensions().z() - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().z() = " << this->getDimensions().z() ); return Vertex( this->origin.x() + ( cellCoordinates.x() + 0.5 ) * this->cellProportions.x(), @@ -794,8 +760,7 @@ Vertex tnlGrid< 3, Real, Device, Index >::getCellCenter( const IndexType& cellIn { tnlAssert( cellIndex >= 0 && cellIndex < this->getNumberOfCells(), cerr << " cellIndex = " << cellIndex - << " this->getNumberOfCells() = " << this->getNumberOfCells() - << " this->getName() " << this->getName(); ); + << " this->getNumberOfCells() = " << this->getNumberOfCells() ); return this->getCellCenter< VertexType >( this->getCellCoordinates( cellIndex ) ); } @@ -811,16 +776,13 @@ Vertex tnlGrid< 3, Real, Device, Index > :: getFaceCenter( const CoordinatesType { tnlAssert( faceCoordinates.x() >= 0 && faceCoordinates.x() < this->getDimensions().x() + 1, cerr << "faceCoordinates.x() = " << faceCoordinates.x() - << " this->getDimensions().x() + 1 = " << this->getDimensions().x() + 1 - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().x() + 1 = " << this->getDimensions().x() + 1 ); tnlAssert( faceCoordinates.y() >= 0 && faceCoordinates.y() < this->getDimensions().y(), cerr << "faceCoordinates.y() = " << faceCoordinates.y() - << " this->getDimensions().y() = " << this->getDimensions().y() - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().y() = " << this->getDimensions().y() ); tnlAssert( faceCoordinates.z() >= 0 && faceCoordinates.z() < this->getDimensions().z(), cerr << "faceCoordinates.z() = " << faceCoordinates.z() - << " this->getDimensions().z() = " << this->getDimensions().z() - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().z() = " << this->getDimensions().z() ); return Vertex( this->origin.x() + faceCoordinates.x() * this->cellProportions().x(), this->origin.y() + ( faceCoordinates.y() + 0.5 ) * this->cellProportions().y(), this->origin.z() + ( faceCoordinates.y() + 0.5 ) * this->cellProportions().z() ); @@ -829,16 +791,13 @@ Vertex tnlGrid< 3, Real, Device, Index > :: getFaceCenter( const CoordinatesType { tnlAssert( faceCoordinates.x() >= 0 && faceCoordinates.x() < this->getDimensions().x(), cerr << "faceCoordinates.x() = " << faceCoordinates.x() - << " this->getDimensions().x() = " << this->getDimensions().x() - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().x() = " << this->getDimensions().x() ); tnlAssert( faceCoordinates.y() >= 0 && faceCoordinates.y() < this->getDimensions().y() + 1, cerr << "faceCoordinates.y() = " << faceCoordinates.y() - << " this->getDimensions().y() + 1 = " << this->getDimensions().y() + 1 - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().y() + 1 = " << this->getDimensions().y() + 1 ); tnlAssert( faceCoordinates.z() >= 0 && faceCoordinates.z() < this->getDimensions().z(), cerr << "faceCoordinates.z() = " << faceCoordinates.z() - << " this->getDimensions().z() = " << this->getDimensions().z() - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().z() = " << this->getDimensions().z() ); return Vertex( this->origin.x() + ( faceCoordinates.x() + 0.5 ) * this->cellProportions().x(), this->origin.y() + faceCoordinates.y() * this->cellProportions().y(), @@ -848,16 +807,13 @@ Vertex tnlGrid< 3, Real, Device, Index > :: getFaceCenter( const CoordinatesType { tnlAssert( faceCoordinates.x() >= 0 && faceCoordinates.x() < this->getDimensions().x(), cerr << "faceCoordinates.x() = " << faceCoordinates.x() - << " this->getDimensions().x() = " << this->getDimensions().x() - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().x() = " << this->getDimensions().x() ); tnlAssert( faceCoordinates.y() >= 0 && faceCoordinates.y() < this->getDimensions().y(), cerr << "faceCoordinates.y() = " << faceCoordinates.y() - << " this->getDimensions().y()= " << this->getDimensions().y() - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().y()= " << this->getDimensions().y() ); tnlAssert( faceCoordinates.z() >= 0 && faceCoordinates.z() < this->getDimensions().z() + 1, cerr << "faceCoordinates.z() = " << faceCoordinates.z() - << " this->getDimensions().z() + 1 = " << this->getDimensions().z() + 1 - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().z() + 1 = " << this->getDimensions().z() + 1 ); return Vertex( this->origin.x() + ( faceCoordinates.x() + 0.5 ) * this->cellProportions().x(), this->origin.y() + ( faceCoordinates.y() + 0.5 ) * this->cellProportions().y(), this->origin.z() + faceCoordinates.z() * this->cellProportions().z() ); @@ -876,16 +832,13 @@ Vertex tnlGrid< 3, Real, Device, Index > :: getEdgeCenter( const CoordinatesType { tnlAssert( edgeCoordinates.x() >= 0 && edgeCoordinates.x() < this->getDimensions().x(), cerr << "edgeCoordinates.x() = " << edgeCoordinates.x() - << " this->getDimensions().x() = " << this->getDimensions().x() - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().x() = " << this->getDimensions().x() ); tnlAssert( edgeCoordinates.y() >= 0 && edgeCoordinates.y() < this->getDimensions().y() + 1, cerr << "edgeCoordinates.y() = " << edgeCoordinates.y() - << " this->getDimensions().y() + 1 = " << this->getDimensions().y() + 1 - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().y() + 1 = " << this->getDimensions().y() + 1 ); tnlAssert( edgeCoordinates.z() >= 0 && edgeCoordinates.z() < this->getDimensions().z() + 1, cerr << "edgeCoordinates.z() = " << edgeCoordinates.z() - << " this->getDimensions().z() + 1 = " << this->getDimensions().z() + 1 - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().z() + 1 = " << this->getDimensions().z() + 1 ); return Vertex( this->origin.x() + ( edgeCoordinates.x() + 0.5 ) * this->cellProportions().x(), this->origin.y() + edgeCoordinates.y() * this->cellProportions().y(), this->origin.z() + edgeCoordinates.z() * this->cellProportions().z() ); @@ -894,16 +847,13 @@ Vertex tnlGrid< 3, Real, Device, Index > :: getEdgeCenter( const CoordinatesType { tnlAssert( edgeCoordinates.x() >= 0 && edgeCoordinates.x() < this->getDimensions().x() + 1, cerr << "edgeCoordinates.x() = " << edgeCoordinates.x() - << " this->getDimensions().x() + 1 = " << this->getDimensions().x() + 1 - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().x() + 1 = " << this->getDimensions().x() + 1 ); tnlAssert( edgeCoordinates.y() >= 0 && edgeCoordinates.y() < this->getDimensions().y(), cerr << "edgeCoordinates.y() = " << edgeCoordinates.y() - << " this->getDimensions().y() = " << this->getDimensions().y() - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().y() = " << this->getDimensions().y() ); tnlAssert( edgeCoordinates.z() >= 0 && edgeCoordinates.z() < this->getDimensions().z() + 1, cerr << "edgeCoordinates.z() = " << edgeCoordinates.z() - << " this->getDimensions().z() + 1 = " << this->getDimensions().z() + 1 - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().z() + 1 = " << this->getDimensions().z() + 1 ); return Vertex( this->origin.x() + edgeCoordinates.x() * this->cellProportions().x(), this->origin.y() + ( edgeCoordinates.y() + 0.5 ) * this->cellProportions().y(), this->origin.z() + edgeCoordinates.z() * this->cellProportions().z() ); @@ -912,16 +862,13 @@ Vertex tnlGrid< 3, Real, Device, Index > :: getEdgeCenter( const CoordinatesType { tnlAssert( edgeCoordinates.x() >= 0 && edgeCoordinates.x() < this->getDimensions().x() + 1, cerr << "edgeCoordinates.x() = " << edgeCoordinates.x() - << " this->getDimensions().x() = " << this->getDimensions().x() - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().x() = " << this->getDimensions().x() ); tnlAssert( edgeCoordinates.y() >= 0 && edgeCoordinates.y() < this->getDimensions().y() + 1, cerr << "edgeCoordinates.y() = " << edgeCoordinates.y() - << " this->getDimensions().y() + 1 = " << this->getDimensions().y() + 1 - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().y() + 1 = " << this->getDimensions().y() + 1 ); tnlAssert( edgeCoordinates.z() >= 0 && edgeCoordinates.z() < this->getDimensions().z(), cerr << "edgeCoordinates.z() = " << edgeCoordinates.z() - << " this->getDimensions().z() = " << this->getDimensions().z() - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().z() = " << this->getDimensions().z() ); return Vertex( this->origin.x() + edgeCoordinates.x() * this->cellProportions().x(), this->origin.y() + edgeCoordinates.y() * this->cellProportions().y(), this->origin.z() + ( edgeCoordinates.z() + 0.5 ) * this->cellProportions().z() ); @@ -937,16 +884,13 @@ Vertex tnlGrid< 3, Real, Device, Index >::getVertex( const CoordinatesType& vert { tnlAssert( vertexCoordinates.x() >= 0 && vertexCoordinates.x() < this->getDimensions().x() + 1, cerr << "vertexCoordinates.x() = " << vertexCoordinates.x() - << " this->getDimensions().x() = " << this->getDimensions().x() - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().x() = " << this->getDimensions().x() ); tnlAssert( vertexCoordinates.y() >= 0 && vertexCoordinates.y() < this->getDimensions().y() + 1, cerr << "vertexCoordinates.y() = " << vertexCoordinates.y() - << " this->getDimensions().y() = " << this->getDimensions().y() - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().y() = " << this->getDimensions().y() ); tnlAssert( vertexCoordinates.z() >= 0 && vertexCoordinates.z() < this->getDimensions().z() + 1, cerr << "vertexCoordinates.z() = " << vertexCoordinates.z() - << " this->getDimensions().z() = " << this->getDimensions().z() - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().z() = " << this->getDimensions().z() ); return Vertex( this->origin.x() + vertexCoordinates.x() * this->cellProportions.x(), this->origin.y() + vertexCoordinates.y() * this->cellProportions.y(), @@ -1003,16 +947,13 @@ bool tnlGrid< 3, Real, Device, Index > :: isBoundaryCell( const CoordinatesType& { tnlAssert( cellCoordinates.x() >= 0 && cellCoordinates.x() < this->getDimensions().x(), cerr << "cellCoordinates.x() = " << cellCoordinates.x() - << " this->getDimensions().x() = " << this->getDimensions().x() - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().x() = " << this->getDimensions().x() ); tnlAssert( cellCoordinates.y() >= 0 && cellCoordinates.y() < this->getDimensions().y(), cerr << "cellCoordinates.y() = " << cellCoordinates.y() - << " this->getDimensions().y() = " << this->getDimensions().y() - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().y() = " << this->getDimensions().y() ); tnlAssert( cellCoordinates.z() >= 0 && cellCoordinates.z() < this->getDimensions().z(), cerr << "cellCoordinates.z() = " << cellCoordinates.z() - << " this->getDimensions().z() = " << this->getDimensions().z() - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().z() = " << this->getDimensions().z() ); if( cellCoordinates.x() == 0 || cellCoordinates.x() == this->getDimensions().x() - 1 || @@ -1032,8 +973,7 @@ isBoundaryCell( const IndexType& cellIndex ) const { tnlAssert( cellIndex >= 0 && cellIndex < this->getNumberOfCells(), cerr << " cellIndex = " << cellIndex - << " this->getNumberOfCells() = " << this->getNumberOfCells() - << " this->getName() " << this->getName(); ); + << " this->getNumberOfCells() = " << this->getNumberOfCells() ); return this->isBoundaryCell( this->getCellCoordinates( cellIndex ) ); } @@ -1049,12 +989,10 @@ bool tnlGrid< 3, Real, Device, Index > :: isBoundaryFace( const CoordinatesType& { tnlAssert( faceCoordinates.x() >= 0 && faceCoordinates.x() < this->getDimensions().x() + 1, cerr << "faceCoordinates.x() = " << faceCoordinates.x() - << " this->getDimensions().x() + 1 = " << this->getDimensions().x() + 1 - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().x() + 1 = " << this->getDimensions().x() + 1 ); tnlAssert( faceCoordinates.y() >= 0 && faceCoordinates.y() < this->getDimensions().y(), cerr << "faceCoordinates.y() = " << faceCoordinates.y() - << " this->getDimensions().y() = " << this->getDimensions().y() - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().y() = " << this->getDimensions().y() ); if( faceCoordinates.x() == 0 || faceCoordinates.x() == this->getDimensions().y() ) return true; return false; @@ -1063,12 +1001,10 @@ bool tnlGrid< 3, Real, Device, Index > :: isBoundaryFace( const CoordinatesType& { tnlAssert( faceCoordinates.x() >= 0 && faceCoordinates.x() < this->getDimensions().x(), cerr << "faceCoordinates.x() = " << faceCoordinates.x() - << " this->getDimensions().x() = " << this->getDimensions().x() - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().x() = " << this->getDimensions().x() ); tnlAssert( faceCoordinates.y() >= 0 && faceCoordinates.y() < this->getDimensions().y() + 1, cerr << "faceCoordinates.y() = " << faceCoordinates.y() - << " this->getDimensions().y() + 1 = " << this->getDimensions().y() + 1 - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().y() + 1 = " << this->getDimensions().y() + 1 ); if( faceCoordinates.y() == 0 || faceCoordinates.y() == this->getDimensions().y() ) return true; return false; @@ -1077,16 +1013,13 @@ bool tnlGrid< 3, Real, Device, Index > :: isBoundaryFace( const CoordinatesType& { tnlAssert( faceCoordinates.x() >= 0 && faceCoordinates.x() < this->getDimensions().x(), cerr << "faceCoordinates.x() = " << faceCoordinates.x() - << " this->getDimensions().x() = " << this->getDimensions().x() - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().x() = " << this->getDimensions().x() ); tnlAssert( faceCoordinates.y() >= 0 && faceCoordinates.y() < this->getDimensions().y(), cerr << "faceCoordinates.y() = " << faceCoordinates.y() - << " this->getDimensions().y()= " << this->getDimensions().y() - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().y()= " << this->getDimensions().y() ); tnlAssert( faceCoordinates.z() >= 0 && faceCoordinates.z() < this->getDimensions().z() + 1, cerr << "faceCoordinates.z() = " << faceCoordinates.z() - << " this->getDimensions().z() + 1 = " << this->getDimensions().z() + 1 - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().z() + 1 = " << this->getDimensions().z() + 1 ); if( faceCoordinates.z() == 0 || faceCoordinates.z() == this->getDimensions().z() ) return true; return false; @@ -1105,16 +1038,13 @@ bool tnlGrid< 3, Real, Device, Index >::isBoundaryEdge( const CoordinatesType& e { tnlAssert( edgeCoordinates.x() >= 0 && edgeCoordinates.x() < this->getDimensions().x(), cerr << "edgeCoordinates.x() = " << edgeCoordinates.x() - << " this->getDimensions().x() = " << this->getDimensions().x() - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().x() = " << this->getDimensions().x() ); tnlAssert( edgeCoordinates.y() >= 0 && edgeCoordinates.y() < this->getDimensions().y() + 1, cerr << "edgeCoordinates.y() = " << edgeCoordinates.y() - << " this->getDimensions().y() + 1 = " << this->getDimensions().y() + 1 - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().y() + 1 = " << this->getDimensions().y() + 1 ); tnlAssert( edgeCoordinates.z() >= 0 && edgeCoordinates.z() < this->getDimensions().z() + 1, cerr << "edgeCoordinates.z() = " << edgeCoordinates.z() - << " this->getDimensions().z() + 1 = " << this->getDimensions().z() + 1 - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().z() + 1 = " << this->getDimensions().z() + 1 ); if( edgeCoordinates.y() == 0 || edgeCoordinates.y() == this->getDimensions().y() || edgeCoordinates.z() == 0 || edgeCoordinates.z() == this->getDimensions().z() ) return true; @@ -1124,16 +1054,13 @@ bool tnlGrid< 3, Real, Device, Index >::isBoundaryEdge( const CoordinatesType& e { tnlAssert( edgeCoordinates.x() >= 0 && edgeCoordinates.x() < this->getDimensions().x() + 1, cerr << "edgeCoordinates.x() = " << edgeCoordinates.x() - << " this->getDimensions().x() + 1 = " << this->getDimensions().x() + 1 - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().x() + 1 = " << this->getDimensions().x() + 1 ); tnlAssert( edgeCoordinates.y() >= 0 && edgeCoordinates.y() < this->getDimensions().y(), cerr << "edgeCoordinates.y() = " << edgeCoordinates.y() - << " this->getDimensions().y() = " << this->getDimensions().y() - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().y() = " << this->getDimensions().y() ); tnlAssert( edgeCoordinates.z() >= 0 && edgeCoordinates.z() < this->getDimensions().z() + 1, cerr << "edgeCoordinates.z() = " << edgeCoordinates.z() - << " this->getDimensions().z() + 1 = " << this->getDimensions().z() + 1 - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().z() + 1 = " << this->getDimensions().z() + 1 ); if( edgeCoordinates.x() == 0 || edgeCoordinates.x() == this->getDimensions().x() || edgeCoordinates.z() == 0 || edgeCoordinates.z() == this->getDimensions().z() ) return true; @@ -1144,16 +1071,13 @@ bool tnlGrid< 3, Real, Device, Index >::isBoundaryEdge( const CoordinatesType& e { tnlAssert( edgeCoordinates.x() >= 0 && edgeCoordinates.x() < this->getDimensions().x() + 1, cerr << "edgeCoordinates.x() = " << edgeCoordinates.x() - << " this->getDimensions().x() = " << this->getDimensions().x() - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().x() = " << this->getDimensions().x() ); tnlAssert( edgeCoordinates.y() >= 0 && edgeCoordinates.y() < this->getDimensions().y() + 1, cerr << "edgeCoordinates.y() = " << edgeCoordinates.y() - << " this->getDimensions().y() + 1 = " << this->getDimensions().y() + 1 - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().y() + 1 = " << this->getDimensions().y() + 1 ); tnlAssert( edgeCoordinates.z() >= 0 && edgeCoordinates.z() < this->getDimensions().z(), cerr << "edgeCoordinates.z() = " << edgeCoordinates.z() - << " this->getDimensions().z() = " << this->getDimensions().z() - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().z() = " << this->getDimensions().z() ); if( edgeCoordinates.x() == 0 || edgeCoordinates.x() == this->getDimensions().x() || edgeCoordinates.y() == 0 || edgeCoordinates.y() == this->getDimensions().y() ) return true; @@ -1169,16 +1093,13 @@ bool tnlGrid< 3, Real, Device, Index > :: isBoundaryVertex( const CoordinatesTyp { tnlAssert( vertexCoordinates.x() >= 0 && vertexCoordinates.x() < this->getDimensions().x() + 1, cerr << "vertexCoordinates.x() = " << vertexCoordinates.x() - << " this->getDimensions().x() + 1 = " << this->getDimensions().x() + 1 - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().x() + 1 = " << this->getDimensions().x() + 1 ); tnlAssert( vertexCoordinates.y() >= 0 && vertexCoordinates.y() < this->getDimensions().y() + 1, cerr << "vertexCoordinates.y() = " << vertexCoordinates.y() - << " this->getDimensions().y() + 1 = " << this->getDimensions().y() + 1 - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().y() + 1 = " << this->getDimensions().y() + 1 ); tnlAssert( vertexCoordinates.z() >= 0 && vertexCoordinates.z() < this->getDimensions().z() + 1, cerr << "vertexCoordinates.z() = " << vertexCoordinates.z() - << " this->getDimensions().z() + 1 = " << this->getDimensions().z() + 1 - << " this->getName() = " << this->getName(); ); + << " this->getDimensions().z() + 1 = " << this->getDimensions().z() + 1 ); if( vertexCoordinates.x() == 0 || vertexCoordinates.x() == this->getDimensions().x() || vertexCoordinates.y() == 0 || vertexCoordinates.y() == this->getDimensions().y() || @@ -1269,8 +1190,7 @@ bool tnlGrid< 3, Real, Device, Index > :: save( tnlFile& file ) const ! this->proportions.save( file ) || ! this->dimensions.save( file ) ) { - cerr << "I was not able to save the domain description of the tnlGrid " - << this -> getName() << endl; + cerr << "I was not able to save the domain description of a tnlGrid." << endl; return false; } return true; @@ -1288,8 +1208,7 @@ bool tnlGrid< 3, Real, Device, Index > :: load( tnlFile& file ) ! this->proportions.load( file ) || ! dimensions.load( file ) ) { - cerr << "I was not able to load the domain description of the tnlGrid " - << this -> getName() << endl; + cerr << "I was not able to load the domain description of a tnlGrid." << endl; return false; } this->setDimensions( dimensions ); @@ -1332,8 +1251,8 @@ bool tnlGrid< 3, Real, Device, Index > :: write( const MeshFunction& function, { if( this -> getNumberOfCells() != function. getSize() ) { - cerr << "The size ( " << function. getSize() << " ) of the mesh function " << function. getName() - << " does not agree with the DOFs ( " << this -> getNumberOfCells() << " ) of the mesh " << this -> getName() << "." << endl; + cerr << "The size ( " << function. getSize() + << " ) of a mesh function does not agree with the DOFs ( " << this -> getNumberOfCells() << " ) of a mesh." << endl; return false; } fstream file; diff --git a/src/mesh/tnlGrid_impl.cpp b/src/mesh/grids/tnlGrid_impl.cpp similarity index 100% rename from src/mesh/tnlGrid_impl.cpp rename to src/mesh/grids/tnlGrid_impl.cpp diff --git a/src/mesh/tnlTraverser_Grid1D.h b/src/mesh/grids/tnlTraverser_Grid1D.h similarity index 98% rename from src/mesh/tnlTraverser_Grid1D.h rename to src/mesh/grids/tnlTraverser_Grid1D.h index dc0a3f36b08f7560aebb327ecb87fa58868b3a22..e27b04ecd64753dda7ad1a7efd06088b9d5a98e8 100644 --- a/src/mesh/tnlTraverser_Grid1D.h +++ b/src/mesh/grids/tnlTraverser_Grid1D.h @@ -117,6 +117,6 @@ class tnlTraverser< tnlGrid< 1, Real, tnlCuda, Index >, 0 > }; -#include <mesh/tnlTraverser_Grid1D_impl.h> +#include <mesh/grids/tnlTraverser_Grid1D_impl.h> #endif /* TNLTRAVERSER_GRID1D_H_ */ diff --git a/src/mesh/tnlTraverser_Grid1D_impl.h b/src/mesh/grids/tnlTraverser_Grid1D_impl.h similarity index 100% rename from src/mesh/tnlTraverser_Grid1D_impl.h rename to src/mesh/grids/tnlTraverser_Grid1D_impl.h diff --git a/src/mesh/tnlTraverser_Grid2D.h b/src/mesh/grids/tnlTraverser_Grid2D.h similarity index 99% rename from src/mesh/tnlTraverser_Grid2D.h rename to src/mesh/grids/tnlTraverser_Grid2D.h index ee520c0dba4a3132e75327e77e3f373f65929c3d..6ee46fb0a5a47d034dba0c7e8d10258ea50dc47a 100644 --- a/src/mesh/tnlTraverser_Grid2D.h +++ b/src/mesh/grids/tnlTraverser_Grid2D.h @@ -155,6 +155,6 @@ class tnlTraverser< tnlGrid< 2, Real, tnlCuda, Index >, 0 > }; -#include <mesh/tnlTraverser_Grid2D_impl.h> +#include <mesh/grids/tnlTraverser_Grid2D_impl.h> #endif /* TNLTRAVERSER_GRID2D_H_ */ diff --git a/src/mesh/tnlTraverser_Grid2D_impl.h b/src/mesh/grids/tnlTraverser_Grid2D_impl.h similarity index 99% rename from src/mesh/tnlTraverser_Grid2D_impl.h rename to src/mesh/grids/tnlTraverser_Grid2D_impl.h index 4d8efa2df82898134c560b3c9458f6d71b313dfe..83ff0e81b357caaa003255bcfdd4b5de5370a8f5 100644 --- a/src/mesh/tnlTraverser_Grid2D_impl.h +++ b/src/mesh/grids/tnlTraverser_Grid2D_impl.h @@ -205,7 +205,7 @@ processInteriorEntities( const GridType& grid, const IndexType& ySize = grid.getDimensions().y(); #ifdef HAVE_OPENMP -//#pragma omp parallel for + //#pragma omp parallel for #endif for( coordinates.y() = 1; coordinates.y() < ySize; coordinates.y() ++ ) for( coordinates.x() = 1; coordinates.x() < xSize; coordinates.x() ++ ) diff --git a/src/mesh/tnlTraverser_Grid3D.h b/src/mesh/grids/tnlTraverser_Grid3D.h similarity index 99% rename from src/mesh/tnlTraverser_Grid3D.h rename to src/mesh/grids/tnlTraverser_Grid3D.h index 5f4c29c655e35ec9c1d648ce5ea352645297aaac..694754558b1ed094defba33fbe50b42e341fa6e8 100644 --- a/src/mesh/tnlTraverser_Grid3D.h +++ b/src/mesh/grids/tnlTraverser_Grid3D.h @@ -200,6 +200,6 @@ class tnlTraverser< tnlGrid< 3, Real, tnlCuda, Index >, 0 > }; -#include <mesh/tnlTraverser_Grid3D_impl.h> +#include <mesh/grids/tnlTraverser_Grid3D_impl.h> #endif /* TNLTRAVERSER_GRID3D_H_ */ diff --git a/src/mesh/tnlTraverser_Grid3D_impl.h b/src/mesh/grids/tnlTraverser_Grid3D_impl.h similarity index 100% rename from src/mesh/tnlTraverser_Grid3D_impl.h rename to src/mesh/grids/tnlTraverser_Grid3D_impl.h diff --git a/src/mesh/initializer/CMakeLists.txt b/src/mesh/initializer/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..e4ed7a57e1803a448a62862a2c259c83d56c0dca --- /dev/null +++ b/src/mesh/initializer/CMakeLists.txt @@ -0,0 +1,13 @@ +SET( headers tnlMeshEntityInitializer.h + tnlMeshEntitySeed.h + tnlMeshEntitySeedKey.h + tnlMeshInitializer.h + tnlMeshSubentitySeedCreator.h + tnlMeshSuperentityStorageInitializer.h + ) + +SET( CURRENT_DIR ${CMAKE_SOURCE_DIR}/src/mesh/initializer ) +SET( tnl_mesh_initializer_SOURCES + PARENT_SCOPE ) + +INSTALL( FILES ${headers} DESTINATION include/tnl-${tnlVersion}/mesh/initializer ) \ No newline at end of file diff --git a/src/mesh/initializer/tnlMeshEntityInitializer.h b/src/mesh/initializer/tnlMeshEntityInitializer.h new file mode 100644 index 0000000000000000000000000000000000000000..064de82f76d7e021f8c94a3b5658fc5cf881d77b --- /dev/null +++ b/src/mesh/initializer/tnlMeshEntityInitializer.h @@ -0,0 +1,549 @@ +/*************************************************************************** + tnlMeshEntityInitializer.h - description + ------------------- + begin : Feb 23, 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 TNLMESHENTITYINITIALIZER_H_ +#define TNLMESHENTITYINITIALIZER_H_ + +#include <core/tnlStaticFor.h> +#include <mesh/initializer/tnlMeshSuperentityStorageInitializer.h> +#include <mesh/initializer/tnlMeshSubentitySeedCreator.h> + +#include "tnlMeshEntitySeed.h" + +template< typename MeshConfig > +class tnlMeshInitializer; + +template< typename MeshConfig, + typename EntityTopology, + typename DimensionsTag, + bool SubentityStorage = tnlMeshSubentityTraits< MeshConfig, EntityTopology, DimensionsTag::value >::storageEnabled, + bool SubentityOrientationStorage = tnlMeshTraits< MeshConfig >::template SubentityTraits< EntityTopology, DimensionsTag::value >::orientationEnabled, + bool SuperentityStorage = tnlMeshSuperentityTraits< MeshConfig, + typename tnlMeshSubentityTraits< MeshConfig, EntityTopology, DimensionsTag::value >::SubentityTopology, + EntityTopology::dimensions >::storageEnabled > +class tnlMeshEntityInitializerLayer; + +template< typename MeshConfig, + typename EntityTopology > +class tnlMeshEntityInitializer + : public tnlMeshEntityInitializerLayer< MeshConfig, + EntityTopology, + tnlDimensionsTag< EntityTopology::dimensions - 1 > > +{ + typedef tnlDimensionsTag< EntityTopology::dimensions > DimensionsTag; + private: + + typedef tnlMeshEntityInitializerLayer< MeshConfig, + EntityTopology, + tnlDimensionsTag< EntityTopology::dimensions - 1 > > BaseType; + + typedef + tnlMeshEntityInitializerLayer< MeshConfig, + EntityTopology, + tnlDimensionsTag< EntityTopology::dimensions - 1 > > SubentityBaseType; + typedef + tnlMeshSuperentityStorageInitializerLayer< MeshConfig, + EntityTopology, + typename + tnlMeshTraits< MeshConfig >::DimensionsTag > SuperentityBaseType; + + static const int Dimensions = DimensionsTag::value; + typedef tnlMeshTraits< MeshConfig > MeshTraits; + typedef typename MeshTraits::GlobalIndexType GlobalIndexType; + typedef typename MeshTraits::LocalIndexType LocalIndexType; + typedef typename MeshTraits::template EntityTraits< Dimensions > EntityTraits; + + typedef typename EntityTraits::EntityType EntityType; + typedef typename MeshTraits::template SubentityTraits< EntityTopology, 0 > SubvertexTraits; + + + typedef tnlMeshInitializer< MeshConfig > InitializerType; + typedef tnlMeshEntitySeed< MeshConfig, EntityTopology > SeedType; + + template< typename > class SubentitiesCreator; + + public: + + //using SuperentityBaseType::setNumberOfSuperentities; + + static tnlString getType() {}; + + tnlMeshEntityInitializer() : entity(0), entityIndex( -1 ) {} + + static void initEntity( EntityType &entity, GlobalIndexType entityIndex, const SeedType &entitySeed, InitializerType &initializer) + { + entity = EntityType( entitySeed ); + BaseType::initSubentities( entity, entityIndex, entitySeed, initializer ); + } + + template< typename SuperentityDimensionTag > + typename tnlMeshSuperentityTraits< MeshConfig, EntityTopology, SuperentityDimensionTag::value >::SharedContainerType& getSuperentityContainer( SuperentityDimensionTag ) + { + return this->entity->template getSuperentitiesIndices< SuperentityDimensionTag::value >(); + } + + static void setEntityVertex( EntityType& entity, + LocalIndexType localIndex, + GlobalIndexType globalIndex ) + { + entity.setVertexIndex( localIndex, globalIndex ); + } + + private: + EntityType *entity; + GlobalIndexType entityIndex; + +}; + +template< typename MeshConfig > +class tnlMeshEntityInitializer< MeshConfig, tnlMeshVertexTopology > +{ + public: + typedef typename tnlMeshTraits< MeshConfig >::VertexType VertexType; + typedef typename tnlMeshTraits< MeshConfig >::PointType PointType; + typedef tnlMeshInitializer< MeshConfig > InitializerType; + + static tnlString getType() {}; + + static void setVertexPoint( VertexType& vertex, + const PointType& point, + InitializerType& initializer ) + { + initializer.setVertexPoint( vertex, point ); + } +}; + + +/**** + * Mesh entity initializer layer with specializations + * + * SUBENTITY STORAGE SUBENTITY ORIENTATION SUPERENTITY STORAGE + * TRUE FALSE TRUE + */ +template< typename MeshConfig, + typename EntityTopology, + typename DimensionsTag > +class tnlMeshEntityInitializerLayer< MeshConfig, + EntityTopology, + DimensionsTag, + true, + false, + true > + : public tnlMeshEntityInitializerLayer< MeshConfig, + EntityTopology, + typename DimensionsTag::Decrement > +{ + typedef tnlMeshEntityInitializerLayer< MeshConfig, + EntityTopology, + typename DimensionsTag::Decrement > BaseType; + + static const int Dimensions = DimensionsTag::value; + typedef tnlMeshTraits< MeshConfig > MeshTraits; + typedef typename MeshTraits:: template SubentityTraits< EntityTopology, Dimensions > SubentityTraits; + typedef typename SubentityTraits::SubentityContainerType SubentityContainerType; + typedef typename SubentityTraits::AccessArrayType SharedContainerType; + typedef typename SharedContainerType::ElementType GlobalIndexType; + + typedef tnlMeshInitializer< MeshConfig > InitializerType; + typedef tnlMeshEntityInitializer< MeshConfig, EntityTopology > EntityInitializerType; + typedef tnlDimensionsTag< EntityTopology::dimensions > EntityDimensionsTag; + typedef tnlMeshEntity< MeshConfig, EntityTopology > EntityType; + typedef tnlMeshEntitySeed< MeshConfig, EntityTopology > SeedType; + typedef tnlMeshSubentitySeedsCreator< MeshConfig, EntityTopology, DimensionsTag > SubentitySeedsCreatorType; + typedef typename SubentityTraits::IdArrayType IdArrayType; + typedef typename MeshTraits::LocalIndexType LocalIndexType; + + protected: + static void initSubentities( EntityType& entity, GlobalIndexType entityIndex, const SeedType& entitySeed, + InitializerType& meshInitializer ) + { + //cout << " Initiating subentities with " << DimensionsTag::value << " dimensions ... " << endl; + auto subentitySeeds = SubentitySeedsCreatorType::create( entitySeed ); + + IdArrayType& subentityIdsArray = InitializerType::template subentityIdsArray< DimensionsTag >( entity ); + for( LocalIndexType i = 0; i < subentitySeeds.getSize(); i++ ) + { + //cout << " Adding subentity " << subentityIdsArray[ i ] << endl; + subentityIdsArray[ i ] = meshInitializer.findEntitySeedIndex( subentitySeeds[ i ] ); + meshInitializer. + template getSuperentityInitializer< DimensionsTag >(). + addSuperentity( EntityDimensionsTag(), subentityIdsArray[ i ], entityIndex ); + } + BaseType::initSubentities( entity, entityIndex, entitySeed, meshInitializer ); + } +}; + +/**** + * Mesh entity initializer layer with specializations + * + * SUBENTITY STORAGE SUBENTITY ORIENTATION SUPERENTITY STORAGE + * TRUE TRUE TRUE + */ +template< typename MeshConfig, + typename EntityTopology, + typename DimensionsTag > +class tnlMeshEntityInitializerLayer< MeshConfig, + EntityTopology, + DimensionsTag, + true, + true, + true > + : public tnlMeshEntityInitializerLayer< MeshConfig, + EntityTopology, + typename DimensionsTag::Decrement > +{ + typedef tnlMeshEntityInitializerLayer< MeshConfig, + EntityTopology, + typename DimensionsTag::Decrement > BaseType; + + typedef tnlMeshSubentityTraits< MeshConfig, EntityTopology, DimensionsTag::value > SubentitiesTraits; + typedef typename SubentitiesTraits::SubentityContainerType SubentityContainerType; + typedef typename SubentitiesTraits::AccessArrayType SharedContainerType; + typedef typename SharedContainerType::ElementType GlobalIndexType; + + typedef tnlMeshInitializer< MeshConfig > InitializerType; + typedef tnlMeshEntityInitializer< MeshConfig, EntityTopology > EntityInitializerType; + typedef tnlDimensionsTag< EntityTopology::dimensions > EntityDimensionsTag; + typedef tnlMeshEntity< MeshConfig, EntityTopology > EntityType; + typedef tnlMeshEntitySeed< MeshConfig, EntityTopology > SeedType; + typedef tnlMeshSubentitySeedsCreator< MeshConfig, EntityTopology, DimensionsTag > SubentitySeedsCreatorType; + typedef typename tnlMeshTraits< MeshConfig >::template SubentityTraits< EntityTopology, DimensionsTag::value >::IdArrayType IdArrayType; + typedef typename tnlMeshTraits< MeshConfig >::LocalIndexType LocalIndexType; + typedef typename SubentitiesTraits::OrientationArrayType OrientationArrayType; + + protected: + static void initSubentities( EntityType& entity, GlobalIndexType entityIndex, const SeedType& entitySeed, + InitializerType& meshInitializer ) + { + //cout << " Initiating subentities with " << DimensionsTag::value << " dimensions ... " << endl; + auto subentitySeeds = SubentitySeedsCreatorType::create( entitySeed ); + + IdArrayType& subentityIdsArray = InitializerType::template subentityIdsArray< DimensionsTag >( entity ); + OrientationArrayType &subentityOrientationsArray = InitializerType::template subentityOrientationsArray< DimensionsTag >( entity ); + for( LocalIndexType i = 0; i < subentitySeeds.getSize(); i++ ) + { + //cout << " Adding subentity " << subentityIdsArray[ i ] << endl; + GlobalIndexType subentityIndex = meshInitializer.findEntitySeedIndex( subentitySeeds[ i ] ); + subentityIdsArray[ i ] = subentityIndex; + subentityOrientationsArray[ i ] = meshInitializer.template getReferenceOrientation< DimensionsTag >( subentityIndex ).createOrientation( subentitySeeds[ i ] ); + //cout << " Subentity orientation = " << subentityOrientationsArray[ i ].getSubvertexPermutation() << endl; + meshInitializer. + template getSuperentityInitializer< DimensionsTag >(). + addSuperentity( EntityDimensionsTag(), subentityIdsArray[ i ], entityIndex ); + } + + BaseType::initSubentities( entity, entityIndex, entitySeed, meshInitializer ); + } +}; + +/**** + * Mesh entity initializer layer with specializations + * + * SUBENTITY STORAGE SUBENTITY ORIENTATION SUPERENTITY STORAGE + * TRUE TRUE FALSE + */ +template< typename MeshConfig, + typename EntityTopology, + typename DimensionsTag > +class tnlMeshEntityInitializerLayer< MeshConfig, + EntityTopology, + DimensionsTag, + true, + true, + false > + : public tnlMeshEntityInitializerLayer< MeshConfig, + EntityTopology, + typename DimensionsTag::Decrement > +{ + typedef tnlMeshEntityInitializerLayer< MeshConfig, + EntityTopology, + typename DimensionsTag::Decrement > BaseType; + + typedef tnlMeshSubentityTraits< MeshConfig, EntityTopology, DimensionsTag::value > SubentitiesTraits; + typedef typename SubentitiesTraits::SubentityContainerType SubentityContainerType; + typedef typename SubentitiesTraits::SharedContainerType SharedContainerType; + typedef typename SharedContainerType::ElementType GlobalIndexType; + + typedef tnlMeshInitializer< MeshConfig > InitializerType; + typedef tnlMeshEntityInitializer< MeshConfig, EntityTopology > EntityInitializerType; + typedef tnlDimensionsTag< EntityTopology::dimensions > EntityDimensionsTag; + typedef tnlMeshEntity< MeshConfig, EntityTopology > EntityType; + typedef tnlMeshEntitySeed< MeshConfig, EntityTopology > SeedType; + typedef tnlMeshSubentitySeedsCreator< MeshConfig, EntityTopology, DimensionsTag > SubentitySeedsCreatorType; + typedef typename tnlMeshTraits< MeshConfig >::template SubentityTraits< EntityTopology, DimensionsTag >::IdArrayType IdArrayType; + typedef typename tnlMeshTraits< MeshConfig >::LocalIndexType LocalIndexType; + typedef typename SubentitiesTraits::OrientationArrayType OrientationArrayType; + + protected: + static void initSubentities( EntityType& entity, GlobalIndexType entityIndex, const SeedType& entitySeed, + InitializerType& meshInitializer ) + { + //cout << " Initiating subentities with " << DimensionsTag::value << " dimensions ... " << endl; + auto subentitySeeds = SubentitySeedsCreatorType::create( entitySeed ); + + IdArrayType& subentityIdsArray = InitializerType::template subentityIdsArray< DimensionsTag >( entity ); + OrientationArrayType &subentityOrientationsArray = InitializerType::template subentityOrientationsArray< DimensionsTag >( entity ); + for( LocalIndexType i = 0; i < subentitySeeds.getSize(); i++ ) + { + //cout << " Adding subentity " << subentityIdsArray[ i ] << endl; + subentityIdsArray[ i ] = meshInitializer.findEntitySeedIndex( subentitySeeds[ i ] ); + subentityOrientationsArray[ i ] = meshInitializer.template getReferenceOrientation< DimensionsTag >( subentitySeeds[ i ] ).createOrientation( subentitySeeds[ i ] ); + } + BaseType::initSubentities( entity, entityIndex, entitySeed, meshInitializer ); + } +}; + + +template< typename MeshConfig, + typename EntityTopology, + typename DimensionsTag > +class tnlMeshEntityInitializerLayer< MeshConfig, + EntityTopology, + DimensionsTag, + true, + false, + false > + : public tnlMeshEntityInitializerLayer< MeshConfig, + EntityTopology, + typename DimensionsTag::Decrement > +{ + typedef tnlMeshEntityInitializerLayer< MeshConfig, + EntityTopology, + typename DimensionsTag::Decrement > BaseType; + + typedef typename tnlMeshSubentityTraits< MeshConfig, + EntityTopology, + DimensionsTag::value >::SubentityContainerType SubentityContainerType; + typedef typename tnlMeshSubentityTraits< MeshConfig, + EntityTopology, + DimensionsTag::value >::SharedContainerType SharedContainerType; + typedef typename SharedContainerType::ElementType GlobalIndexType; + + typedef tnlMeshInitializer< MeshConfig > InitializerType; + typedef tnlMeshEntityInitializer< MeshConfig, EntityTopology > EntityInitializerType; + typedef tnlMeshEntity< MeshConfig, EntityTopology > EntityType; + typedef tnlMeshEntitySeed< MeshConfig, EntityTopology > SeedType; + typedef tnlMeshSubentitySeedsCreator< MeshConfig, EntityTopology, DimensionsTag > SubentitySeedsCreatorType; + typedef typename tnlMeshTraits< MeshConfig >::template SubentityTraits< EntityTopology, DimensionsTag >::IdArrayType IdArrayType; + typedef typename tnlMeshTraits< MeshConfig >::LocalIndexType LocalIndexType; + + protected: + static void initSubentities( EntityType& entity, GlobalIndexType entityIndex, const SeedType& entitySeed, + InitializerType& meshInitializer ) + { + //cout << " Initiating subentities with " << DimensionsTag::value << " dimensions ... " << endl; + auto subentitySeeds = SubentitySeedsCreatorType::create( entitySeed ); + + IdArrayType& subentityIdsArray = InitializerType::template subentityIdsArray< DimensionsTag >( entity ); + for( LocalIndexType i = 0; i < subentitySeeds.getSize(); i++) + subentityIdsArray[ i ] = meshInitializer.findEntitySeedIndex( subentitySeeds[ i ] ); + + BaseType::initSubentities(entity, entityIndex, entitySeed, meshInitializer); + } +}; + +template< typename MeshConfig, + typename EntityTopology, + typename DimensionsTag > +class tnlMeshEntityInitializerLayer< MeshConfig, + EntityTopology, + DimensionsTag, + false, + false, + true > + : public tnlMeshEntityInitializerLayer< MeshConfig, + EntityTopology, + typename DimensionsTag::Decrement > +{ + typedef tnlMeshEntityInitializerLayer< MeshConfig, + EntityTopology, + typename DimensionsTag::Decrement > BaseType; + + typedef typename tnlMeshSubentityTraits< MeshConfig, + EntityTopology, + DimensionsTag::value >::SubentityContainerType SubentityContainerType; + typedef typename tnlMeshSubentityTraits< MeshConfig, + EntityTopology, + DimensionsTag::value >::SharedContainerType SharedContainerType; + typedef typename SharedContainerType::DataType GlobalIndexType; + + typedef tnlMeshInitializer< MeshConfig > InitializerType; + typedef tnlMeshEntityInitializer< MeshConfig, EntityTopology > EntityInitializerType; + typedef tnlDimensionsTag< EntityTopology::dimensions > EntityDimensionsTag; + typedef tnlMeshEntity< MeshConfig, EntityTopology > EntityType; + typedef tnlMeshEntitySeed< MeshConfig, EntityTopology > SeedType; + typedef tnlMeshSubentitySeedsCreator< MeshConfig, EntityTopology, DimensionsTag > SubentitySeedsCreatorType; + typedef typename tnlMeshTraits< MeshConfig >::template SubentityTraits< EntityTopology, DimensionsTag >::IdArrayType IdArrayType; + typedef typename tnlMeshTraits< MeshConfig >::LocalIndexType LocalIndexType; + + + protected: + + static void initSubentities( EntityType& entity, GlobalIndexType entityIndex, const SeedType& entitySeed, + InitializerType& meshInitializer ) + { + //cout << " Initiating subentities with " << DimensionsTag::value << " dimensions ... " << endl; + auto subentitySeeds = SubentitySeedsCreatorType::create( entitySeed ); + IdArrayType& subentityIdsArray = InitializerType::template subentityIdsArray< DimensionsTag >( entity ); + for( LocalIndexType i = 0; i < subentitySeeds.getSize(); i++) + { + GlobalIndexType subentityIndex = meshInitializer.findEntitySeedIndex( subentitySeeds[ i ] ); + meshInitializer. + template getSuperentityInitializer< DimensionsTag >(). + addSuperentity( EntityDimensionsTag(), subentityIndex, entityIndex ); + } + BaseType::initSubentities( entity, entityIndex, entitySeed, meshInitializer ); + } +}; + +template< typename MeshConfig, + typename EntityTopology, + typename DimensionsTag > +class tnlMeshEntityInitializerLayer< MeshConfig, + EntityTopology, + DimensionsTag, + false, + false, + false > + : public tnlMeshEntityInitializerLayer< MeshConfig, + EntityTopology, + typename DimensionsTag::Decrement > +{}; + +template< typename MeshConfig, + typename EntityTopology > +class tnlMeshEntityInitializerLayer< MeshConfig, + EntityTopology, + tnlDimensionsTag< 0 >, + true, + false, + true > +{ + typedef tnlDimensionsTag< 0 > DimensionsTag; + typedef tnlMeshSubentityTraits< MeshConfig, + EntityTopology, + DimensionsTag::value > SubentitiesTraits; + + typedef typename SubentitiesTraits::AccessArrayType SharedContainerType; + typedef typename SharedContainerType::ElementType GlobalIndexType; + + typedef tnlMeshInitializer< MeshConfig > InitializerType; + typedef tnlMeshEntityInitializer< MeshConfig, EntityTopology > EntityInitializerType; + typedef tnlDimensionsTag< EntityTopology::dimensions > EntityDimensionsTag; + typedef tnlMeshEntity< MeshConfig, EntityTopology > EntityType; + typedef tnlMeshEntitySeed< MeshConfig, EntityTopology > SeedType; + typedef tnlMeshSubentitySeedsCreator< MeshConfig, EntityTopology, DimensionsTag > SubentitySeedsCreatorType; + typedef typename tnlMeshTraits< MeshConfig >::template SubentityTraits< EntityTopology, DimensionsTag::value >::IdArrayType IdArrayType; + typedef typename tnlMeshTraits< MeshConfig >::LocalIndexType LocalIndexType; + + + protected: + + static void initSubentities( EntityType& entity, GlobalIndexType entityIndex, const SeedType& entitySeed, + InitializerType& meshInitializer ) + { + //cout << " Initiating subentities with " << DimensionsTag::value << " dimensions ... " << endl; + const IdArrayType &subentityIdsArray = InitializerType::template subentityIdsArray< DimensionsTag >(entity); + for( LocalIndexType i = 0; i < subentityIdsArray.getSize(); i++ ) + meshInitializer.template getSuperentityInitializer< DimensionsTag >().addSuperentity( EntityDimensionsTag(), subentityIdsArray[ i ], entityIndex); + } + +}; + +template< typename MeshConfig, + typename EntityTopology > +class tnlMeshEntityInitializerLayer< MeshConfig, + EntityTopology, + tnlDimensionsTag< 0 >, + true, + false, + false > +{ + typedef tnlMeshInitializer< MeshConfig > InitializerType; + typedef tnlMeshEntityInitializer< MeshConfig, + EntityTopology > EntityInitializerType; + typedef tnlDimensionsTag< 0 > DimensionsTag; + typedef tnlMeshSubentityTraits< MeshConfig, + EntityTopology, + DimensionsTag::value > SubentitiesTraits; + typedef typename SubentitiesTraits::SharedContainerType SharedContainerType; + typedef typename SharedContainerType::ElementType GlobalIndexType; + typedef tnlMeshEntity< MeshConfig, EntityTopology > EntityType; + typedef tnlMeshEntitySeed< MeshConfig, EntityTopology > SeedType; + typedef tnlMeshSubentitySeedsCreator< MeshConfig, EntityTopology, DimensionsTag > SubentitySeedsCreatorType; + typedef typename tnlMeshTraits< MeshConfig >::template SubentityTraits< EntityTopology, DimensionsTag >::IdArrayType IdArrayType; + typedef typename tnlMeshTraits< MeshConfig >::LocalIndexType LocalIndexType; + + + protected: + + static void initSubentities( EntityType& entity, GlobalIndexType entityIndex, const SeedType& entitySeed, + InitializerType& meshInitializer ) {}; + +}; + +template< typename MeshConfig, + typename EntityTopology, + bool SuperEntityStorage > +class tnlMeshEntityInitializerLayer< MeshConfig, + EntityTopology, + tnlDimensionsTag< 0 >, + false, + true, + SuperEntityStorage > // Forces termination of recursive inheritance (prevents compiler from generating huge error logs) +{ + typedef tnlMeshInitializer< MeshConfig > InitializerType; + typedef tnlMeshEntityInitializer< MeshConfig, EntityTopology > EntityInitializerType; + typedef tnlDimensionsTag< 0 > DimensionsTag; + typedef tnlMeshSubentityTraits< MeshConfig, + EntityTopology, + DimensionsTag::value > SubentitiesTraits; + typedef typename SubentitiesTraits::SharedContainerType SharedContainerType; + typedef typename SharedContainerType::ElementType GlobalIndexType; + typedef tnlMeshEntity< MeshConfig, EntityTopology > EntityType; + + protected: + static void initSubentities( EntityType& entity, GlobalIndexType entityIndex, EntityInitializerType&, InitializerType& ) {} +}; + +template< typename MeshConfig, + typename EntityTopology, + bool SuperEntityStorage > +class tnlMeshEntityInitializerLayer< MeshConfig, + EntityTopology, + tnlDimensionsTag< 0 >, + false, + false, + SuperEntityStorage > // Forces termination of recursive inheritance (prevents compiler from generating huge error logs) +{ + typedef tnlMeshInitializer< MeshConfig > InitializerType; + typedef tnlMeshEntityInitializer< MeshConfig, EntityTopology > EntityInitializerType; + typedef tnlDimensionsTag< 0 > DimensionsTag; + typedef tnlMeshSubentityTraits< MeshConfig, + EntityTopology, + DimensionsTag::value > SubentitiesTraits; + typedef typename SubentitiesTraits::SharedContainerType SharedContainerType; + typedef typename SharedContainerType::ElementType GlobalIndexType; + typedef tnlMeshEntity< MeshConfig, EntityTopology > EntityType; + + protected: + void initSubentities( EntityType& entity, GlobalIndexType entityIndex, EntityInitializerType&, + InitializerType& ) {} +}; + + +#endif /* TNLMESHENTITYINITIALIZER_H_ */ diff --git a/src/mesh/initializer/tnlMeshEntitySeed.h b/src/mesh/initializer/tnlMeshEntitySeed.h new file mode 100644 index 0000000000000000000000000000000000000000..d3e25036ece15c7d8cbb7e2101751cb77ce81d6c --- /dev/null +++ b/src/mesh/initializer/tnlMeshEntitySeed.h @@ -0,0 +1,79 @@ +/*************************************************************************** + tnlMeshEntitySeed.h - description + ------------------- + begin : Aug 18, 2015 + copyright : (C) 2015 by Tomas Oberhuber et al. + 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 TNLMESHENTITYSEED_H +#define TNLMESHENTITYSEED_H + +#include <mesh/traits/tnlMeshTraits.h> + +template< typename MeshConfig, + typename EntityTopology > +class tnlMeshEntitySeed +{ + typedef tnlMeshTraits< MeshConfig > MeshConfigTraits; + typedef typename tnlMeshTraits< MeshConfig >::template SubentityTraits< EntityTopology, 0 > SubvertexTraits; + + public: + typedef typename tnlMeshTraits< MeshConfig >::GlobalIndexType GlobalIndexType; + typedef typename tnlMeshTraits< MeshConfig >::LocalIndexType LocalIndexType; + typedef typename tnlMeshTraits< MeshConfig >::IdArrayAccessorType IdArrayAccessorType; + typedef typename SubvertexTraits::IdArrayType IdArrayType; + + static tnlString getType() { return tnlString( "tnlMeshEntitySeed<>" ); } + + static constexpr LocalIndexType getCornersCount() + { + return SubvertexTraits::count; + } + + void setCornerId( LocalIndexType cornerIndex, GlobalIndexType pointIndex ) + { + tnlAssert( 0 <= cornerIndex && cornerIndex < getCornersCount(), cerr << "cornerIndex = " << cornerIndex ); + tnlAssert( 0 <= pointIndex, cerr << "pointIndex = " << pointIndex ); + + this->cornerIds[ cornerIndex ] = pointIndex; + } + + IdArrayAccessorType getCornerIds() + { + IdArrayAccessorType accessor; + accessor.bind( this->corners.getData(), this->corners.getSize() ); + return accessor; + } + + + const IdArrayAccessorType getCornerIds() const + { + IdArrayAccessorType accessor; + accessor.bind( this->cornerIds.getData(), this->cornerIds.getSize() ); + return accessor; + } + + private: + + IdArrayType cornerIds; +}; + +template< typename MeshConfig, typename EntityTopology > +ostream& operator << ( ostream& str, const tnlMeshEntitySeed< MeshConfig, EntityTopology >& e ) +{ + str << e.getCornerIds(); + return str; +}; + +#endif /* TNLMESHENTITYSEED_H */ + diff --git a/src/mesh/initializer/tnlMeshEntitySeedKey.h b/src/mesh/initializer/tnlMeshEntitySeedKey.h new file mode 100644 index 0000000000000000000000000000000000000000..5220d8a3bd8632d56b45bb21bf0ed826a0880910 --- /dev/null +++ b/src/mesh/initializer/tnlMeshEntitySeedKey.h @@ -0,0 +1,80 @@ +/*************************************************************************** + tnlMeshEntitySeedKey.h - description + ------------------- + begin : Feb 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 TNLMESHENTITYSEEDKEY_H_ +#define TNLMESHENTITYSEEDKEY_H_ + +#include <mesh/tnlDimensionsTag.h> + +template< typename MeshConfig, + typename EntityTopology > +class tnlMeshEntitySeed; + +template< typename MeshConfig, + typename EntityTopology, + int Dimensions > +class tnlMeshSubentityTraits; + +/**** + * Unique identification of a mesh entity by its vertices. + * Uniqueness is preserved for entities of the same type only. + */ +template< typename MeshConfig, + typename EntityTopology > +class tnlMeshEntitySeedKey +{ + typedef + tnlMeshEntitySeed< MeshConfig, EntityTopology > EntitySeedType; + + typedef typename + tnlMeshSubentityTraits< MeshConfig, + EntityTopology, + 0 >::StorageArrayType StorageArrayType; + + public: + + explicit tnlMeshEntitySeedKey( const EntitySeedType& entitySeed ) + { + for( typename StorageArrayType::IndexType i = 0; + i < entitySeed.getCornersCount(); + i++ ) + this->sortedCorners[ i ] = entitySeed.getCornerIds()[ i ]; + sortedCorners.sort( ); + } + + bool operator<( const tnlMeshEntitySeedKey& other ) const + { + for( typename StorageArrayType::IndexType i = 0; + i < StorageArrayType::size; + i++) + { + if( sortedCorners[ i ] < other.sortedCorners[ i ] ) + return true; + else + if( sortedCorners[ i ] > other.sortedCorners[ i ] ) + return false; + } + return false; + } + + private: + + StorageArrayType sortedCorners; +}; + + +#endif /* TNLMESHENTITYKSEEDEY_H_ */ diff --git a/src/mesh/initializer/tnlMeshInitializer.h b/src/mesh/initializer/tnlMeshInitializer.h new file mode 100644 index 0000000000000000000000000000000000000000..5eb5f5d00978ee5f765ccf2cccccc605a94c7c78 --- /dev/null +++ b/src/mesh/initializer/tnlMeshInitializer.h @@ -0,0 +1,630 @@ +/*************************************************************************** + tnlMeshInitializer.h - description + ------------------- + begin : Feb 23, 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 TNLMESHINITIALIZER_H_ +#define TNLMESHINITIALIZER_H_ + +#include <mesh/tnlDimensionsTag.h> +#include <mesh/traits/tnlMeshEntityTraits.h> +#include <mesh/traits/tnlMeshSubentityTraits.h> +#include <mesh/traits/tnlMeshSuperentityTraits.h> +#include <mesh/initializer/tnlMeshEntityInitializer.h> +#include <mesh/tnlMesh.h> +#include <mesh/initializer/tnlMeshSubentitySeedCreator.h> +#include <mesh/initializer/tnlMeshSuperentityStorageInitializer.h> +#include <mesh/tnlMeshEntityReferenceOrientation.h> +#include <mesh/initializer/tnlMeshEntitySeed.h> +#include <mesh/initializer/tnlMeshEntitySeedKey.h> + +template< typename MeshConfig > +class tnlMesh; + +template< typename MeshConfig, + typename DimensionsTag, + bool EntityStorage = + tnlMeshEntityTraits< MeshConfig, DimensionsTag::value >::storageEnabled, + bool EntityReferenceOrientationStorage = + tnlMeshTraits< MeshConfig >::template EntityTraits< DimensionsTag::value >::orientationNeeded > +class tnlMeshInitializerLayer; + + +template< typename MeshConfig, + typename EntityTopology> +class tnlMeshEntityInitializer; + +template< typename MeshConfig > +class tnlMeshInitializer + : public tnlMeshInitializerLayer< MeshConfig, + typename tnlMeshTraits< MeshConfig >::DimensionsTag > +{ + public: + + typedef tnlMesh< MeshConfig > MeshType; + typedef tnlMeshTraits< MeshConfig > MeshTraits; + static const int Dimensions = MeshTraits::meshDimensions; + typedef tnlDimensionsTag< Dimensions > DimensionsTag; + typedef tnlMeshInitializerLayer< MeshConfig, DimensionsTag > BaseType; + typedef typename MeshTraits::PointArrayType PointArrayType; + typedef typename MeshTraits::CellSeedArrayType CellSeedArrayType; + typedef typename MeshTraits::GlobalIndexType GlobalIndexType; + + template< typename DimensionsTag, typename SuperdimensionsTag > using SuperentityStorageNetwork = + typename MeshTraits::template SuperentityTraits< + typename MeshTraits::template EntityTraits< DimensionsTag::value >::EntityTopology, + SuperdimensionsTag::value >::StorageNetworkType; + + + tnlMeshInitializer() + : verbose( false ), mesh( 0 ) + {} + + void setVerbose( bool verbose ) + { + this->verbose = verbose; + } + + bool createMesh( const PointArrayType& points, + const CellSeedArrayType& cellSeeds, + MeshType& mesh ) + { + cout << "======= Starting mesh initiation ========" << endl; + this->mesh = &mesh; + + cout << "========= Creating entity seeds =============" << endl; + BaseType::createEntitySeedsFromCellSeeds( cellSeeds ); + + cout << "========= Creating entity reference orientations =============" << endl; + BaseType::createEntityReferenceOrientations(); + + cout << "====== Initiating entities ==============" << endl; + BaseType::initEntities( *this, points, cellSeeds ); + + return true; + } + + template<typename SubDimensionsTag, typename EntityType > + static typename MeshTraits::template SubentityTraits< typename EntityType::EntityTopology, SubDimensionsTag::value >::IdArrayType& + subentityIdsArray( EntityType& entity ) + { + return entity.template subentityIdsArray< SubDimensionsTag::value >(); + } + + template< typename SuperDimensionsTag, typename MeshEntity> + static typename MeshTraits::IdArrayAccessorType& + superentityIdsArray( MeshEntity& entity ) + { + return entity.template superentityIdsArray< SuperDimensionsTag::value >(); + } + + template<typename SubDimensionsTag, typename MeshEntity > + static typename MeshTraits::template SubentityTraits< typename MeshEntity::EntityTopology, SubDimensionsTag::value >::OrientationArrayType& + subentityOrientationsArray( MeshEntity &entity ) + { + return entity.template subentityOrientationsArray< SubDimensionsTag::value >(); + } + + template< typename DimensionsTag > + typename MeshTraits::template EntityTraits< DimensionsTag::value >::StorageArrayType& + meshEntitiesArray() + { + return mesh->template entitiesArray< DimensionsTag >(); + } + + template< typename DimensionsTag, typename SuperDimensionsTag > + typename MeshTraits::GlobalIdArrayType& + meshSuperentityIdsArray() + { + return mesh->template superentityIdsArray< DimensionsTag, SuperDimensionsTag >(); + } + + template< typename EntityTopology, typename SuperdimensionsTag > + typename MeshTraits::template SuperentityTraits< EntityTopology, SuperdimensionsTag::value >::StorageNetworkType& + meshSuperentityStorageNetwork() + { + return mesh->template getSuperentityStorageNetwork< EntityTopology, SuperdimensionsTag >(); + } + + static void + setVertexPoint( typename MeshType::VertexType& vertex, const typename MeshType::PointType& point ) + { + vertex.setPoint( point ); + } + + template< typename DimensionsTag > + tnlMeshSuperentityStorageInitializer< MeshConfig, typename MeshTraits::template EntityTraits< DimensionsTag::value >::EntityTopology >& + getSuperentityInitializer() + { + return BaseType::getSuperentityInitializer( DimensionsTag() ); + } + + + template< typename DimensionsTag > + const tnlMeshEntityReferenceOrientation< MeshConfig, typename MeshTraits::template EntityTraits< DimensionsTag::value >::EntityTopology >& + getReferenceOrientation( GlobalIndexType index) const + { + return BaseType::getReferenceOrientation( DimensionsTag(), index); + } + + protected: + + bool verbose; + + MeshType* mesh; +}; + +/**** + * Mesh initializer layer for cells + * - entities storage must turned on (cells must always be stored ) + * - entities orientation does not make sense for cells => it is turned off + */ +template< typename MeshConfig > +class tnlMeshInitializerLayer< MeshConfig, + typename tnlMeshTraits< MeshConfig >::DimensionsTag, + true, + false > + : public tnlMeshInitializerLayer< MeshConfig, + typename tnlMeshTraits< MeshConfig >::DimensionsTag::Decrement > +{ + typedef tnlMeshTraits< MeshConfig > MeshTraits; + static const int Dimensions = MeshTraits::meshDimensions; + typedef tnlDimensionsTag< Dimensions > DimensionsTag; + typedef tnlMeshInitializerLayer< MeshConfig, typename DimensionsTag::Decrement > BaseType; + + typedef tnlMesh< MeshConfig > MeshType; + typedef typename MeshTraits::template EntityTraits< Dimensions > EntityTraits; + typedef typename EntityTraits::EntityTopology EntityTopology; + typedef typename MeshTraits::GlobalIndexType GlobalIndexType; + typedef typename MeshTraits::CellTopology CellTopology; + typedef typename EntityTraits::StorageArrayType StorageArrayType; + + typedef tnlMeshInitializer< MeshConfig > InitializerType; + typedef tnlMeshEntityInitializer< MeshConfig, EntityTopology > EntityInitializerType; + typedef tnlMeshEntityInitializer< MeshConfig, EntityTopology > CellInitializerType; + typedef tnlArray< CellInitializerType, tnlHost, GlobalIndexType > CellInitializerContainerType; + typedef typename MeshTraits::CellSeedArrayType CellSeedArrayType; + typedef typename MeshTraits::LocalIndexType LocalIndexType; + typedef typename MeshTraits::PointArrayType PointArrayType; + typedef tnlMeshEntitySeed< MeshConfig, CellTopology > SeedType; + typedef tnlMeshSuperentityStorageInitializer< MeshConfig, EntityTopology > SuperentityInitializerType; + + public: + + void createEntitySeedsFromCellSeeds( const CellSeedArrayType& cellSeeds ) + { + BaseType::createEntitySeedsFromCellSeeds( cellSeeds ); + } + + void initEntities( InitializerType &initializer, const PointArrayType &points, const CellSeedArrayType &cellSeeds) + { + StorageArrayType &entityArray = initializer.template meshEntitiesArray< DimensionsTag >(); + //cout << " Initiating entities with " << DimensionsTag::value << " dimensions ... " << endl; + entityArray.setSize( cellSeeds.getSize() ); + for( GlobalIndexType i = 0; i < entityArray.getSize(); i++ ) + { + //cout << " Initiating entity " << i << endl; + EntityInitializerType::initEntity( entityArray[i], i, cellSeeds[i], initializer ); + } + /*** + * There are no superentities in this layer storing mesh cells. + */ + + BaseType::initEntities( initializer, points ); + } + + using BaseType::findEntitySeedIndex; + GlobalIndexType findEntitySeedIndex( const SeedType& seed ) const + { + return this->seedsIndexedSet.find( seed ); + } + + using BaseType::getSuperentityInitializer; + SuperentityInitializerType& getSuperentityInitializer( DimensionsTag ) + { + return this->superentityInitializer; + } + + bool checkCells() + { + typedef typename tnlMeshEntity< MeshConfig, EntityTopology >::template SubentitiesTraits< 0 >::LocalIndexType LocalIndexType; + const GlobalIndexType numberOfVertices( this->getMesh().getNumberOfVertices() ); + for( GlobalIndexType cell = 0; + cell < this->getMesh().getNumberOfCells(); + cell++ ) + for( LocalIndexType i = 0; + i < this->getMesh().getCell( cell ).getNumberOfVertices(); + i++ ) + { + if( this->getMesh().getCell( cell ).getVerticesIndices()[ i ] == - 1 ) + { + cerr << "The cell number " << cell << " does not have properly set vertex index number " << i << "." << endl; + return false; + } + if( this->getMesh().getCell( cell ).getVerticesIndices()[ i ] >= numberOfVertices ) + { + cerr << "The cell number " << cell << " does not have properly set vertex index number " << i + << ". The index " << this->getMesh().getCell( cell ).getVerticesIndices()[ i ] + << "is higher than the number of all vertices ( " << numberOfVertices + << " )." << endl; + return false; + } + } + return true; + } + + private: + typedef typename tnlMeshEntityTraits< MeshConfig, DimensionsTag::value >::SeedIndexedSetType SeedIndexedSet; + + SeedIndexedSet seedsIndexedSet; + SuperentityInitializerType superentityInitializer; +}; + +/**** + * Mesh initializer layer for other mesh entities than cells + * - entities storage is turned on + * - entities orientation storage is turned off + */ +template< typename MeshConfig, + typename DimensionsTag > +class tnlMeshInitializerLayer< MeshConfig, + DimensionsTag, + true, + false > + : public tnlMeshInitializerLayer< MeshConfig, + typename DimensionsTag::Decrement > +{ + typedef tnlMeshTraits< MeshConfig > MeshTraits; + static const int Dimensions = DimensionsTag::value; + typedef tnlMeshInitializerLayer< MeshConfig, typename DimensionsTag::Decrement > BaseType; + + typedef tnlMesh< MeshConfig > MeshType; + typedef typename MeshTraits::template EntityTraits< Dimensions > EntityTraits; + typedef typename EntityTraits::EntityTopology EntityTopology; + typedef typename MeshTraits::GlobalIndexType GlobalIndexType; + typedef typename MeshTraits::CellTopology CellTopology; + typedef typename EntityTraits::StorageArrayType StorageArrayType; + + typedef tnlMeshInitializer< MeshConfig > InitializerType; + typedef tnlMeshEntityInitializer< MeshConfig, EntityTopology > EntityInitializerType; + typedef tnlMeshEntityInitializer< MeshConfig, EntityTopology > CellInitializerType; + typedef tnlArray< CellInitializerType, tnlHost, GlobalIndexType > CellInitializerContainerType; + typedef typename EntityTraits::SeedArrayType EntitySeedArrayType; + typedef typename MeshTraits::CellSeedArrayType CellSeedArrayType; + typedef typename MeshTraits::LocalIndexType LocalIndexType; + typedef typename MeshTraits::PointArrayType PointArrayType; + typedef tnlMeshEntitySeed< MeshConfig, EntityTopology > SeedType; + typedef tnlMeshSuperentityStorageInitializer< MeshConfig, EntityTopology > SuperentityInitializerType; + + typedef typename + tnlMeshSubentityTraits< MeshConfig, + typename MeshConfig::CellTopology, + DimensionsTag::value >::SubentityContainerType SubentitiesContainerType; + + public: + + using BaseType::getEntityInitializer; + EntityInitializerType& getEntityInitializer( DimensionsTag, GlobalIndexType index ) + { + //return entityInitializerContainer[ index ]; + } + + void createEntitySeedsFromCellSeeds( const CellSeedArrayType& cellSeeds ) + { + typedef tnlMeshSubentitySeedsCreator< MeshConfig, CellTopology, DimensionsTag > SubentitySeedsCreator; + //cout << " Creating mesh entities with " << DimensionsTag::value << " dimensions ... " << endl; + for( GlobalIndexType i = 0; i < cellSeeds.getSize(); i++ ) + { + //cout << " Creating mesh entities from cell number " << i << " : " << cellSeeds[ i ] << endl; + typedef typename SubentitySeedsCreator::SubentitySeedArray SubentitySeedArray; + SubentitySeedArray subentytiSeeds( SubentitySeedsCreator::create( cellSeeds[ i ] ) ); + for( LocalIndexType j = 0; j < subentytiSeeds.getSize(); j++ ) + { + //cout << "Creating subentity seed no. " << j << " : " << subentytiSeeds[ j ] << endl; + //tnlMeshEntitySeed< tnlMeshConfigBase< CellTopology >, EntityTopology >& entitySeed = subentytiSeeds[ j ]; + this->seedsIndexedSet.insert( subentytiSeeds[ j ] ); + } + } + BaseType::createEntitySeedsFromCellSeeds( cellSeeds ); + } + + using BaseType::findEntitySeedIndex; + GlobalIndexType findEntitySeedIndex( const SeedType& seed ) const + { + GlobalIndexType index; + this->seedsIndexedSet.find( seed, index ); + return index; + } + + using BaseType::getSuperentityInitializer; + SuperentityInitializerType& getSuperentityInitializer( DimensionsTag ) + { + return this->superentityInitializer; + } + + void initEntities( InitializerType& initializer, const PointArrayType& points ) + { + StorageArrayType &entityArray = initializer.template meshEntitiesArray< DimensionsTag >(); + //cout << " Initiating entities with " << DimensionsTag::value << " dimensions ... " << endl; + entityArray.setSize( this->seedsIndexedSet.getSize() ); + EntitySeedArrayType seedsArray; + seedsArray.setSize( this->seedsIndexedSet.getSize() ); + this->seedsIndexedSet.toArray( seedsArray ); + for( GlobalIndexType i = 0; i < this->seedsIndexedSet.getSize(); i++ ) + { + //cout << " Initiating entity " << i << endl; + EntityInitializerType::initEntity( entityArray[ i ], i, seedsArray[ i ], initializer ); + } + this->seedsIndexedSet.reset(); + + this->superentityInitializer.initSuperentities( initializer ); + + BaseType::initEntities(initializer, points); + } + + void createEntityReferenceOrientations() const {} + private: + + typedef typename tnlMeshEntityTraits< MeshConfig, DimensionsTag::value >::SeedIndexedSetType SeedIndexedSet; + SeedIndexedSet seedsIndexedSet; + SuperentityInitializerType superentityInitializer; +}; + +/**** + * Mesh initializer layer for other mesh entities than cells + * - entities storage is turned on + * - entities orientation storage is turned on + */ +template< typename MeshConfig, + typename DimensionsTag > +class tnlMeshInitializerLayer< MeshConfig, + DimensionsTag, + true, + true > + : public tnlMeshInitializerLayer< MeshConfig, + typename DimensionsTag::Decrement > +{ + typedef tnlMeshInitializerLayer< MeshConfig, + typename DimensionsTag::Decrement > BaseType; + typedef tnlMesh< MeshConfig > MeshType; + typedef typename MeshType::MeshTraits MeshTraits; + + typedef typename MeshType::template EntityTraits< DimensionsTag::value > EntityTraits; + typedef typename EntityTraits::EntityTopology EntityTopology; + typedef typename EntityTraits::EntityType EntityType; + typedef typename EntityTraits::StorageArrayType ContainerType; + typedef typename EntityTraits::UniqueContainerType UniqueContainerType; + typedef typename ContainerType::IndexType GlobalIndexType; + typedef typename MeshTraits::CellTopology CellTopology; + + typedef tnlMeshInitializer< MeshConfig > InitializerType; + typedef tnlMeshEntityInitializer< MeshConfig, CellTopology > CellInitializerType; + typedef tnlMeshEntityInitializer< MeshConfig, EntityTopology > EntityInitializerType; + typedef tnlArray< EntityInitializerType, tnlHost, GlobalIndexType > EntityInitializerContainerType; + typedef typename MeshTraits::CellSeedArrayType CellSeedArrayType; + typedef typename MeshTraits::LocalIndexType LocalIndexType; + typedef typename MeshTraits::PointArrayType PointArrayType; + typedef typename EntityTraits::StorageArrayType EntityArrayType; + typedef typename EntityTraits::SeedArrayType SeedArrayType; + typedef tnlMeshEntitySeed< MeshConfig, EntityTopology > SeedType; + typedef tnlMeshSuperentityStorageInitializer< MeshConfig, EntityTopology > SuperentityInitializerType; + typedef typename EntityTraits::ReferenceOrientationType ReferenceOrientationType; + typedef typename EntityTraits::ReferenceOrientationArrayType ReferenceOrientationArrayType; + + + typedef typename + tnlMeshSubentityTraits< MeshConfig, + typename MeshConfig::CellTopology, + DimensionsTag::value >::SubentityContainerType SubentitiesContainerType; + + public: + + using BaseType::getEntityInitializer; + EntityInitializerType& getEntityInitializer( DimensionsTag, GlobalIndexType index ) + { + //return entityInitializerContainer[ index ]; + } + + void createEntitySeedsFromCellSeeds( const CellSeedArrayType& cellSeeds ) + { + typedef tnlMeshSubentitySeedsCreator< MeshConfig, CellTopology, DimensionsTag > SubentitySeedsCreator; + //cout << " Creating mesh entities with " << DimensionsTag::value << " dimensions ... " << endl; + for( GlobalIndexType i = 0; i < cellSeeds.getSize(); i++ ) + { + //cout << " Creating mesh entities from cell number " << i << " : " << cellSeeds[ i ] << endl; + typedef typename SubentitySeedsCreator::SubentitySeedArray SubentitySeedArray; + SubentitySeedArray subentytiSeeds( SubentitySeedsCreator::create( cellSeeds[ i ] ) ); + for( LocalIndexType j = 0; j < subentytiSeeds.getSize(); j++ ) + { + //cout << "Creating subentity seed no. " << j << " : " << subentytiSeeds[ j ] << endl; + //tnlMeshEntitySeed< tnlMeshConfigBase< CellTopology >, EntityTopology >& entitySeed = subentytiSeeds[ j ]; + this->seedsIndexedSet.insert( subentytiSeeds[ j ] ); + } + } + BaseType::createEntitySeedsFromCellSeeds( cellSeeds ); + } + + using BaseType::findEntitySeedIndex; + GlobalIndexType findEntitySeedIndex( const SeedType& seed ) const + { + GlobalIndexType index; + this->seedsIndexedSet.find( seed, index ); + return index; + } + + using BaseType::getSuperentityInitializer; + SuperentityInitializerType& getSuperentityInitializer( DimensionsTag ) + { + return this->superentityInitializer; + } + + void initEntities( InitializerType& initializer, const PointArrayType& points ) + { + EntityArrayType &entityArray = initializer.template meshEntitiesArray< DimensionsTag >(); + //cout << " Initiating entities with " << DimensionsTag::value << " dimensions ... " << endl; + entityArray.setSize( this->seedsIndexedSet.getSize() ); + SeedArrayType seedsArray; + seedsArray.setSize( this->seedsIndexedSet.getSize() ); + this->seedsIndexedSet.toArray( seedsArray ); + for( GlobalIndexType i = 0; i < this->seedsIndexedSet.getSize(); i++ ) + { + //cout << " Initiating entity " << i << endl; + EntityInitializerType::initEntity( entityArray[ i ], i, seedsArray[ i ], initializer ); + } + this->seedsIndexedSet.reset(); + + this->superentityInitializer.initSuperentities( initializer ); + + BaseType::initEntities(initializer, points); + } + + using BaseType::getReferenceOrientation; + const ReferenceOrientationType& getReferenceOrientation( DimensionsTag, GlobalIndexType index) const + { + return this->referenceOrientations[ index ]; + } + + void createEntityReferenceOrientations() + { + //cout << " Creating entity reference orientations with " << DimensionsTag::value << " dimensions ... " << endl; + SeedArrayType seedsArray; + seedsArray.setSize( this->seedsIndexedSet.getSize() ); + this->seedsIndexedSet.toArray( seedsArray ); + this->referenceOrientations.setSize( seedsArray.getSize() ); + for( GlobalIndexType i = 0; i < seedsArray.getSize(); i++ ) + { + //cout << " Creating reference orientation for entity " << i << endl; + this->referenceOrientations[ i ] = ReferenceOrientationType( seedsArray[ i ] ); + } + BaseType::createEntityReferenceOrientations(); + } + + private: + + typedef typename tnlMeshEntityTraits< MeshConfig, DimensionsTag::value >::SeedIndexedSetType SeedIndexedSet; + SeedIndexedSet seedsIndexedSet; + SuperentityInitializerType superentityInitializer; + ReferenceOrientationArrayType referenceOrientations; +}; + +/**** + * Mesh initializer layer for entities not being stored + */ +template< typename MeshConfig, + typename DimensionsTag > +class tnlMeshInitializerLayer< MeshConfig, + DimensionsTag, + false, + false > + : public tnlMeshInitializerLayer< MeshConfig, + typename DimensionsTag::Decrement > +{}; + +/**** + * Mesh initializer layer for vertices + * - vertices must always be stored + * - their orientation does not make sense + */ +template< typename MeshConfig > +class tnlMeshInitializerLayer< MeshConfig, + tnlDimensionsTag< 0 >, + true, + false > +{ + typedef tnlMesh< MeshConfig > MeshType; + typedef typename MeshType::MeshTraits MeshTraits; + typedef tnlDimensionsTag< 0 > DimensionsTag; + + typedef typename MeshType::template EntityTraits< DimensionsTag::value > EntityTraits; + typedef typename EntityTraits::EntityTopology EntityTopology; + typedef typename EntityTraits::StorageArrayType ContainerType; + typedef typename EntityTraits::AccessArrayType SharedContainerType; + typedef typename ContainerType::IndexType GlobalIndexType; + + typedef typename MeshTraits::CellTopology CellTopology; + + typedef tnlMeshInitializer< MeshConfig > InitializerType; + typedef tnlMeshEntityInitializer< MeshConfig, CellTopology > CellInitializerType; + typedef tnlMeshEntityInitializer< MeshConfig, EntityTopology > VertexInitializerType; + typedef tnlArray< VertexInitializerType, tnlHost, GlobalIndexType > VertexInitializerContainerType; + typedef typename tnlMeshTraits< MeshConfig >::CellSeedArrayType CellSeedArrayType; + typedef typename tnlMeshTraits< MeshConfig >::LocalIndexType LocalIndexType; + typedef typename tnlMeshTraits< MeshConfig >::PointArrayType PointArrayType; + typedef typename EntityTraits::StorageArrayType EntityArrayType; + typedef tnlMeshEntityInitializer< MeshConfig, EntityTopology > EntityInitializerType; + typedef tnlMeshSuperentityStorageInitializer< MeshConfig, EntityTopology > SuperentityInitializerType; + + public: + + void setMesh( MeshType& mesh ) + { + this->mesh = &mesh; + } + + MeshType& getMesh() + { + tnlAssert( this->mesh, ); + return *( this->mesh ); + } + + VertexInitializerType& getEntityInitializer( DimensionsTag, GlobalIndexType index ) + { + tnlAssert( index >= 0 && index < vertexInitializerContainer.getSize(), + cerr << " index = " << index + << " vertexInitializerContainer.getSize() = " << vertexInitializerContainer.getSize() << endl; ); + return vertexInitializerContainer[ index ]; + } + + void createEntitySeedsFromCellSeeds( const CellSeedArrayType& cellSeeds ){}; + + void initEntities( InitializerType& initializer, const PointArrayType& points ) + { + EntityArrayType &vertexArray = initializer.template meshEntitiesArray< DimensionsTag >(); + vertexArray.setSize( points.getSize() ); + for( GlobalIndexType i = 0; i < vertexArray.getSize(); i++ ) + EntityInitializerType::setVertexPoint( vertexArray[i], points[i], initializer ); + + superentityInitializer.initSuperentities( initializer ); + } + + void findEntitySeedIndex() const {} // This method is due to 'using BaseType::findEntityIndex;' in the derived class. + + void createEntityInitializers() + { + vertexInitializerContainer.setSize( this->getMesh().template getNumberOfEntities< DimensionsTag::value >() ); + } + + SuperentityInitializerType& getSuperentityInitializer( DimensionsTag ) + { + return this->superentityInitializer; + } + + void createEntityReferenceOrientations() const {} + + void getReferenceOrientation() const {} + + private: + + SuperentityInitializerType superentityInitializer; + + VertexInitializerContainerType vertexInitializerContainer; + + MeshType* mesh; +}; + + + + +#endif /* TNLMESHINITIALIZER_H_ */ diff --git a/src/mesh/initializer/tnlMeshSubentitySeedCreator.h b/src/mesh/initializer/tnlMeshSubentitySeedCreator.h new file mode 100644 index 0000000000000000000000000000000000000000..35dd6abbd7c23b6c760f9390e0df7c6ba8ad29cd --- /dev/null +++ b/src/mesh/initializer/tnlMeshSubentitySeedCreator.h @@ -0,0 +1,82 @@ +/*************************************************************************** + tnlMeshSubentitySeedCreator.h - description + ------------------- + begin : Aug 20, 2015 + copyright : (C) 2015 by Tomas Oberhuber et al. + 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 TNLMESHSUBENTITYSEEDCREATOR_H +#define TNLMESHSUBENTITYSEEDCREATOR_H + +#include <core/tnlStaticFor.h> + +template< typename MeshConfig, + typename EntityTopology, + typename SubDimensionsTag > +class tnlMeshSubentitySeedsCreator +{ + typedef typename tnlMeshTraits< MeshConfig >::LocalIndexType LocalIndexType; + typedef typename tnlMeshTraits< MeshConfig >::template SubentityTraits< EntityTopology, SubDimensionsTag::value > SubentityTraits; + typedef typename SubentityTraits::SubentityTopology SubentityTopology; + typedef typename tnlMeshTraits< MeshConfig >::IdArrayAccessorType IdArrayAccessorType; + typedef typename tnlMeshTraits< MeshConfig >::template SubentityTraits< SubentityTopology, 0 > SubentityVertexTraits; + + static const LocalIndexType SUBENTITIES_COUNT = SubentityTraits::count; + static const LocalIndexType SUBENTITY_VERTICES_COUNT = SubentityVertexTraits::count; + + public: + typedef typename SubentityTraits::SeedArrayType SubentitySeedArray; + typedef tnlMeshEntitySeed< MeshConfig, EntityTopology > EntitySeed; + //typedef typename tnlMeshEntityTraits< MeshConfig, SubDimensionsTag >::SeedIndexedSetType SeedIndexedSet; + + //template< typename SeedIndexedSet > + static SubentitySeedArray create( const EntitySeed &entitySeed ) + { + SubentitySeedArray subentitySeeds; + tnlStaticFor< LocalIndexType, 0, SUBENTITIES_COUNT, CreateSubentitySeeds >::exec( subentitySeeds, entitySeed.getCornerIds() ); + //tnlStaticFor< LocalIndexType, 0, SUBENTITIES_COUNT, CreateSubentitySeeds >::exec( indexedSet, entitySeed.getCornerIds() ); + + return subentitySeeds; + } + + private: + typedef tnlMeshEntitySeed< MeshConfig, SubentityTopology > SubentitySeed; + + template< LocalIndexType subentityIndex > + class CreateSubentitySeeds + { + public: + static void exec( SubentitySeedArray &subentitySeeds, IdArrayAccessorType vertexIds ) + //static void exec( SeedIndexedSet& indexedSet, IdArrayAccessorType vertexIds ) + { + //EntitySeed seed; + tnlStaticFor< LocalIndexType, 0, SUBENTITY_VERTICES_COUNT, SetSubentitySeedVertex >::exec( subentitySeeds[ subentityIndex ], vertexIds ); + //indexedSet.insert( seed ); + } + + private: + template< LocalIndexType subentityVertexIndex > + class SetSubentitySeedVertex + { + public: + static void exec( SubentitySeed &subentitySeed, IdArrayAccessorType vertexIds ) + { + static const LocalIndexType VERTEX_INDEX = SubentityTraits::template Vertex< subentityIndex, subentityVertexIndex >::index; + subentitySeed.setCornerId( subentityVertexIndex, vertexIds[ VERTEX_INDEX ] ); + } + }; + }; +}; + +#endif /* TNLMESHSUBENTITYSEEDCREATOR_H */ + diff --git a/src/mesh/initializer/tnlMeshSuperentityStorageInitializer.h b/src/mesh/initializer/tnlMeshSuperentityStorageInitializer.h new file mode 100644 index 0000000000000000000000000000000000000000..89c18bf540a2c9154a71c9e31855b7c1391db369 --- /dev/null +++ b/src/mesh/initializer/tnlMeshSuperentityStorageInitializer.h @@ -0,0 +1,203 @@ +/*************************************************************************** + tnlMeshSuperentityStorageInitializer.h - description + ------------------- + begin : Feb 27, 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 TNLMESHSUPERENTITYSTORAGEINITIALIZER_H_ +#define TNLMESHSUPERENTITYSTORAGEINITIALIZER_H_ + +#include <mesh/tnlDimensionsTag.h> +#include <algorithm> + +template< typename MeshConfig > +class tnlMeshInitializer; + +template< typename MeshConfig, + typename EntityTopology, + typename DimensionsTag, + bool SuperentityStorage = tnlMeshSuperentityTraits< MeshConfig, EntityTopology, DimensionsTag::value >::storageEnabled > +class tnlMeshSuperentityStorageInitializerLayer; + +template< typename MeshConfig, + typename EntityTopology > +class tnlMeshSuperentityStorageInitializer : + public tnlMeshSuperentityStorageInitializerLayer< MeshConfig, EntityTopology, tnlDimensionsTag< tnlMeshTraits< MeshConfig >::meshDimensions > > +{}; + +template< typename MeshConfig, + typename EntityTopology, + typename DimensionsTag > +class tnlMeshSuperentityStorageInitializerLayer< MeshConfig, + EntityTopology, + DimensionsTag, + true > + : public tnlMeshSuperentityStorageInitializerLayer< MeshConfig, + EntityTopology, + typename DimensionsTag::Decrement > +{ + typedef tnlMeshSuperentityStorageInitializerLayer< MeshConfig, + EntityTopology, + typename DimensionsTag::Decrement > BaseType; + + static const int Dimensions = DimensionsTag::value; + typedef tnlDimensionsTag< EntityTopology::dimensions > EntityDimensions; + + typedef tnlMeshTraits< MeshConfig > MeshTraits; + typedef typename MeshTraits::GlobalIdArrayType GlobalIdArrayType; + + typedef typename MeshTraits::GlobalIndexType GlobalIndexType; + typedef typename MeshTraits::LocalIndexType LocalIndexType; + typedef tnlMeshInitializer< MeshConfig > MeshInitializer; + typedef typename MeshTraits::template SuperentityTraits< EntityTopology, Dimensions > SuperentityTraits; + typedef typename SuperentityTraits::StorageNetworkType SuperentityStorageNetwork; + + public: + using BaseType::addSuperentity; + + void addSuperentity( DimensionsTag, GlobalIndexType entityIndex, GlobalIndexType superentityIndex) + { + //cout << "Adding superentity with " << DimensionsTag::value << " dimensions of enity with " << EntityDimensions::value << " ... " << endl; + indexPairs.push_back( IndexPair{ entityIndex, superentityIndex } ); + } + + using BaseType::initSuperentities; + void initSuperentities( MeshInitializer& meshInitializer ) + { + std::sort( indexPairs.begin(), + indexPairs.end(), + []( IndexPair pair0, IndexPair pair1 ){ return ( pair0.entityIndex < pair1.entityIndex ); } ); + + GlobalIdArrayType &superentityIdsArray = meshInitializer.template meshSuperentityIdsArray< EntityDimensions, DimensionsTag >(); + superentityIdsArray.setSize( static_cast< GlobalIndexType >( indexPairs.size() ) ); + GlobalIndexType currentBegin = 0; + GlobalIndexType lastEntityIndex = 0; + cout << "There are " << superentityIdsArray.getSize() << " superentities with " << DimensionsTag::value << " dimensions of enities with " << EntityDimensions::value << " ... " << endl; + for( GlobalIndexType i = 0; i < superentityIdsArray.getSize(); i++) + { + superentityIdsArray[ i ] = indexPairs[i].superentityIndex; + + //cout << "Adding superentity " << indexPairs[i].superentityIndex << " to entity " << lastEntityIndex << endl; + if( indexPairs[ i ].entityIndex != lastEntityIndex ) + { + meshInitializer.template superentityIdsArray< DimensionsTag >( meshInitializer.template meshEntitiesArray< EntityDimensions >()[ lastEntityIndex ] ).bind( superentityIdsArray, currentBegin, i - currentBegin ); + currentBegin = i; + lastEntityIndex = indexPairs[ i ].entityIndex; + } + } + + meshInitializer.template superentityIdsArray< DimensionsTag >( meshInitializer.template meshEntitiesArray< EntityDimensions >()[ lastEntityIndex ] ).bind( superentityIdsArray, currentBegin, superentityIdsArray.getSize() - currentBegin ); + indexPairs.clear(); + + /**** + * Network initializer + */ + SuperentityStorageNetwork& superentityStorageNetwork = meshInitializer.template meshSuperentityStorageNetwork< EntityTopology, DimensionsTag >(); + //GlobalIndexType lastEntityIndex( 0 ); + superentityStorageNetwork.setRanges( + meshInitializer.template meshEntitiesArray< EntityDimensions >().getSize(), + meshInitializer.template meshEntitiesArray< DimensionsTag >().getSize() ); + lastEntityIndex = 0; + typename SuperentityStorageNetwork::ValuesAllocationVectorType storageNetworkAllocationVector; + storageNetworkAllocationVector.setSize( meshInitializer.template meshEntitiesArray< EntityDimensions >().getSize() ); + storageNetworkAllocationVector.setValue( 0 ); + for( GlobalIndexType i = 0; i < superentityIdsArray.getSize(); i++) + { + if( indexPairs[ i ].entityIndex == lastEntityIndex ) + storageNetworkAllocationVector[ lastEntityIndex ]++; + else + lastEntityIndex++; + } + superentityStorageNetwork.allocate( storageNetworkAllocationVector ); + lastEntityIndex = 0; + LocalIndexType superentitiesCount( 0 ); + typename SuperentityStorageNetwork::ValuesAccessorType superentitiesIndecis = + superentityStorageNetwork.getValues( lastEntityIndex ); + for( GlobalIndexType i = 0; i < superentityIdsArray.getSize(); i++) + { + if( indexPairs[ i ].entityIndex != lastEntityIndex ) + { + superentitiesIndecis = superentityStorageNetwork.getValues( ++lastEntityIndex ); + superentitiesCount = 0; + } + superentitiesIndecis[ superentitiesCount++ ] = indexPairs[ i ].superentityIndex; + } + BaseType::initSuperentities( meshInitializer ); + } + + private: + struct IndexPair + { + GlobalIndexType entityIndex; + GlobalIndexType superentityIndex; + }; + + std::vector< IndexPair > indexPairs; + +}; + +template< typename MeshConfig, + typename EntityTopology, + typename DimensionsTag > +class tnlMeshSuperentityStorageInitializerLayer< MeshConfig, + EntityTopology, + DimensionsTag, + false > + : public tnlMeshSuperentityStorageInitializerLayer< MeshConfig, + EntityTopology, + typename DimensionsTag::Decrement > +{ + typedef tnlMeshSuperentityStorageInitializerLayer< MeshConfig, + EntityTopology, + typename DimensionsTag::Decrement > BaseType; + typedef tnlMeshInitializer< MeshConfig > MeshInitializerType; + + public: + void addSuperentity() {} // This method is due to 'using BaseType::...;' in the derived classes. + using BaseType::initSuperentities; + void initSuperentities( MeshInitializerType& ) {cerr << "***" << endl;} +}; + +template< typename MeshConfig, + typename EntityTopology > +class tnlMeshSuperentityStorageInitializerLayer< MeshConfig, + EntityTopology, + tnlDimensionsTag< EntityTopology::dimensions >, + true > +{ + typedef tnlMeshInitializer< MeshConfig > MeshInitializerType; + + public: + void addSuperentity() {} // This method is due to 'using BaseType::...;' in the derived classes. + void initSuperentities( MeshInitializerType& ) {} +}; + +template< typename MeshConfig, + typename EntityTopology > +class tnlMeshSuperentityStorageInitializerLayer< MeshConfig, + EntityTopology, + tnlDimensionsTag< EntityTopology::dimensions >, + false > +{ + typedef tnlMeshInitializer< MeshConfig > MeshInitializerType; + + public: + void addSuperentity() {} // This method is due to 'using BaseType::...;' in the derived classes. + void initSuperentities( MeshInitializerType& ) {} +}; + + + + +#endif /* TNLMESHSUPERENTITYSTORAGEINITIALIZER_H_ */ diff --git a/src/mesh/layers/tnlMeshStorageLayer.h b/src/mesh/layers/tnlMeshStorageLayer.h index 31722cd2a54fd79310af654e1fd23c518b8ec3e7..62ea6701c9a2871db2687aa45031177524ed0db0 100644 --- a/src/mesh/layers/tnlMeshStorageLayer.h +++ b/src/mesh/layers/tnlMeshStorageLayer.h @@ -20,200 +20,189 @@ #include <core/tnlFile.h> #include <mesh/traits/tnlMeshTraits.h> -#include <mesh/traits/tnlMeshEntitiesTraits.h> -#include <mesh/traits/tnlStorageTraits.h> - -template< typename DimensionsTraits, - typename Device, - typename ConfigTag, - typename EntityStorageTag = typename tnlMeshEntitiesTraits< ConfigTag, - DimensionsTraits >::EntityStorageTag > -class tnlMeshStorageTag; - -template< typename ConfigTag, - typename DimensionsTraits, - typename EntityStorageTag = typename tnlMeshEntitiesTraits< ConfigTag, - DimensionsTraits >::EntityStorageTag > +#include <mesh/traits/tnlMeshEntityTraits.h> +#include <mesh/traits/tnlMeshTraits.h> + +template< typename MeshConfig, + typename DimensionsTag, + bool EntityStorage = tnlMeshEntityTraits< MeshConfig, DimensionsTag::value >::storageEnabled > class tnlMeshStorageLayer; -template< typename ConfigTag > +template< typename MeshConfig > class tnlMeshStorageLayers - : public tnlMeshStorageLayer< ConfigTag, - typename tnlMeshTraits< ConfigTag >::DimensionsTraits > -{}; - - -template< typename ConfigTag, - typename DimensionsTraits > -class tnlMeshStorageLayer< ConfigTag, - DimensionsTraits, - tnlStorageTraits< true > > - : public tnlMeshStorageLayer< ConfigTag, typename DimensionsTraits::Previous > + : public tnlMeshStorageLayer< MeshConfig, typename tnlMeshTraits< MeshConfig >::DimensionsTag > { - typedef tnlMeshStorageLayer< ConfigTag, - typename DimensionsTraits::Previous > BaseType; +}; - typedef tnlMeshEntitiesTraits< ConfigTag, DimensionsTraits > Tag; - typedef typename Tag::ContainerType ContainerType; - typedef typename Tag::SharedContainerType SharedContainerType; - typedef typename ContainerType::IndexType GlobalIndexType; - typedef typename ContainerType::ElementType EntityType; - protected: +template< typename MeshConfig, + typename DimensionsTag > +class tnlMeshStorageLayer< MeshConfig, + DimensionsTag, + true > + : public tnlMeshStorageLayer< MeshConfig, typename DimensionsTag::Decrement >, + public tnlMeshSuperentityStorageLayers< MeshConfig, + typename tnlMeshTraits< MeshConfig >::template EntityTraits< DimensionsTag::value >::EntityTopology > +{ + public: - using BaseType::setNumberOfEntities; - using BaseType::getNumberOfEntities; - using BaseType::setEntity; - using BaseType::getEntity; - using BaseType::getEntities; + static const int Dimensions = DimensionsTag::value; + typedef tnlMeshStorageLayer< MeshConfig, typename DimensionsTag::Decrement > BaseType; + typedef tnlMeshSuperentityStorageLayers< MeshConfig, + typename tnlMeshTraits< MeshConfig >::template EntityTraits< DimensionsTag::value >::EntityTopology > SuperentityStorageBaseType; + typedef tnlMeshTraits< MeshConfig > MeshTraits; + typedef typename MeshTraits::template EntityTraits< Dimensions > EntityTraits; - tnlMeshStorageLayer() - { - this->entities.setName( tnlString( "tnlMeshStorageLayer < " ) + tnlString( DimensionsTraits::value ) + " >::entities" ); - this->sharedEntities.setName( tnlString( "tnlMeshStorageLayer < " ) + tnlString( DimensionsTraits::value ) + " >::sharedEntities" ); - } + typedef typename EntityTraits::StorageArrayType StorageArrayType; + typedef typename EntityTraits::AccessArrayType AccessArrayType; + typedef typename EntityTraits::GlobalIndexType GlobalIndexType; + typedef typename EntityTraits::EntityType EntityType; + typedef typename EntityTraits::EntityTopology EntityTopology; - /*~tnlMeshStorageLayer() - { - cout << "Destroying mesh storage layer with " << DimensionsTraits::value << " dimensions and " << this->entities.getSize() << " entities." << endl; - }*/ - bool setNumberOfEntities( DimensionsTraits, const GlobalIndexType size ) - { - if( ! this->entities.setSize( size ) ) - return false; - this->sharedEntities.bind( this->entities ); - return true; - } + using BaseType::getNumberOfEntities; + using BaseType::getEntity; + using BaseType::getEntities; - GlobalIndexType getNumberOfEntities( DimensionsTraits ) const - { - return this->entities.getSize(); - } + tnlMeshStorageLayer() + { + } - void setEntity( DimensionsTraits, - const GlobalIndexType entityIndex, - const EntityType& entity ) const - { - this->entities.setElement( entityIndex, entity ); - } + GlobalIndexType getNumberOfEntities( DimensionsTag ) const + { + return this->entities.getSize(); + } - EntityType& getEntity( DimensionsTraits, - const GlobalIndexType entityIndex ) - { - return this->entities[ entityIndex ]; - } + EntityType& getEntity( DimensionsTag, + const GlobalIndexType entityIndex ) + { + return this->entities[ entityIndex ]; + } - const EntityType& getEntity( DimensionsTraits, - const GlobalIndexType entityIndex ) const - { - return this->entities[ entityIndex ]; - } + const EntityType& getEntity( DimensionsTag, + const GlobalIndexType entityIndex ) const + { + return this->entities[ entityIndex ]; + } - SharedContainerType& getEntities( DimensionsTraits ) - { - return this->sharedEntities; - } + AccessArrayType& getEntities( DimensionsTag ) + { + return this->sharedEntities; + } - const SharedContainerType& getEntities( DimensionsTraits ) const - { - return this->sharedEntities; - } + const AccessArrayType& getEntities( DimensionsTag ) const + { + return this->sharedEntities; + } - bool save( tnlFile& file ) const - { - if( ! BaseType::save( file ) || - ! this->entities.save( file ) ) + bool save( tnlFile& file ) const { - cerr << "Saving of the mesh entities with " << DimensionsTraits::value << " dimensions failed." << endl; - return false; + if( ! BaseType::save( file ) || + ! this->entities.save( file ) ) + { + cerr << "Saving of the mesh entities with " << DimensionsTag::value << " dimensions failed." << endl; + return false; + } + return true; } - return true; - } - bool load( tnlFile& file ) - { - //cout << "Loading mesh layer with dimensions " << DimensionsTraits::value << endl; - if( ! BaseType::load( file ) || - ! this->entities.load( file ) ) + bool load( tnlFile& file ) { - cerr << "Loading of the mesh entities with " << DimensionsTraits::value << " dimensions failed." << endl; - return false; + //cout << "Loading mesh layer with dimensions " << DimensionsTag::value << endl; + if( ! BaseType::load( file ) || + ! this->entities.load( file ) ) + { + cerr << "Loading of the mesh entities with " << DimensionsTag::value << " dimensions failed." << endl; + return false; + } + this->entitiesAccess.bind( this->entities ); + return true; } - this->sharedEntities.bind( this->entities ); - return true; - } - void print( ostream& str ) const - { - BaseType::print( str ); - str << "The entities with " << DimensionsTraits::value << " dimensions are: " << endl; - for( GlobalIndexType i = 0; i < entities.getSize();i ++ ) + void print( ostream& str ) const { - str << i << " "; - entities[ i ].print( str ); - str << endl; + BaseType::print( str ); + str << "The entities with " << DimensionsTag::value << " dimensions are: " << endl; + for( GlobalIndexType i = 0; i < entities.getSize();i ++ ) + { + str << i << " "; + entities[ i ].print( str ); + str << endl; + } + SuperentityStorageBaseType::print( str ); } - } - bool operator==( const tnlMeshStorageLayer& meshLayer ) const - { - return ( BaseType::operator==( meshLayer ) && entities == meshLayer.entities ); - } + bool operator==( const tnlMeshStorageLayer& meshLayer ) const + { + return ( BaseType::operator==( meshLayer ) && entities == meshLayer.entities ); + } protected: - ContainerType entities; + StorageArrayType entities; - SharedContainerType sharedEntities; -}; + AccessArrayType entitiesAccess; + + // TODO: this is only for the mesh initializer - fix it + public: -template< typename ConfigTag, - typename DimensionsTraits > -class tnlMeshStorageLayer< ConfigTag, - DimensionsTraits, - tnlStorageTraits< false > > - : public tnlMeshStorageLayer< ConfigTag, - typename DimensionsTraits::Previous > -{ + using BaseType::entitiesArray; + + typename EntityTraits::StorageArrayType& entitiesArray( DimensionsTag ) + { + return entities; + } + + using BaseType::superentityIdsArray; + + template< typename SuperDimensionsTag > + typename MeshTraits::GlobalIdArrayType& superentityIdsArray( DimensionsTag ) + { + return SuperentityStorageBaseType::superentityIdsArray( SuperDimensionsTag() ); + } + + using BaseType::getSuperentityStorageNetwork; + template< typename SuperdimensionsTag > + typename MeshTraits::template SuperentityTraits< EntityTopology, SuperdimensionsTag::value >::StorageNetworkType& + getSuperentityStorageNetwork( tnlDimensionsTag< EntityTopology::dimensions > ) + { + return SuperentityStorageBaseType::getStorageNetwork( SuperdimensionsTag() ); + } }; -template< typename ConfigTag > -class tnlMeshStorageLayer< ConfigTag, - tnlDimensionsTraits< 0 >, - tnlStorageTraits< true > > +template< typename MeshConfig, + typename DimensionsTag > +class tnlMeshStorageLayer< MeshConfig, DimensionsTag, false > + : public tnlMeshStorageLayer< MeshConfig, typename DimensionsTag::Decrement > { - typedef tnlDimensionsTraits< 0 > DimensionsTraits; - - typedef tnlMeshEntitiesTraits< ConfigTag, - DimensionsTraits > Tag; - typedef typename Tag::ContainerType ContainerType; - typedef typename Tag::SharedContainerType SharedContainerType; - typedef typename ContainerType::IndexType GlobalIndexType; - typedef typename ContainerType::ElementType VertexType; - typedef typename VertexType::PointType PointType; +}; - protected: +template< typename MeshConfig > +class tnlMeshStorageLayer< MeshConfig, tnlDimensionsTag< 0 >, true > : + public tnlMeshSuperentityStorageLayers< MeshConfig, + tnlMeshVertexTopology > +{ + public: + + typedef tnlDimensionsTag< 0 > DimensionsTag; + + typedef tnlMeshSuperentityStorageLayers< MeshConfig, + tnlMeshVertexTopology > SuperentityStorageBaseType; + + typedef tnlMeshTraits< MeshConfig > MeshTraits; + typedef typename MeshTraits::template EntityTraits< 0 > EntityTraits; + + typedef typename EntityTraits::StorageArrayType StorageArrayType; + typedef typename EntityTraits::AccessArrayType AccessArrayType; + typedef typename EntityTraits::GlobalIndexType GlobalIndexType; + typedef typename EntityTraits::EntityType VertexType; + typedef typename VertexType::PointType PointType; + typedef tnlMeshVertexTopology EntityTopology; + tnlMeshStorageLayer() { - this->vertices.setName( tnlString( "tnlMeshStorageLayer < " ) + tnlString( DimensionsTraits::value ) + " >::vertices" ); - this->sharedVertices.setName( tnlString( "tnlMeshStorageLayer < " ) + tnlString( DimensionsTraits::value ) + " >::sharedVertices" ); - } - - /*~tnlMeshStorageLayer() - { - cout << "mesh storage layer: dimensions = " << DimensionsTraits::value << " entities = " << this->vertices.getSize() << endl; - }*/ - - - bool setNumberOfVertices( const GlobalIndexType size ) - { - if( ! this->vertices.setSize( size ) ) - return false; - this->sharedVertices.bind( this->vertices ); - return true; } GlobalIndexType getNumberOfVertices() const @@ -248,36 +237,30 @@ class tnlMeshStorageLayer< ConfigTag, * This is only for the completeness and compatibility * with higher dimensions entities storage layers. */ - bool setNumberOfEntities( DimensionsTraits, - const GlobalIndexType size ) - { - return this->vertices.setSize( size ); - } - GlobalIndexType getNumberOfEntities( DimensionsTraits ) const + GlobalIndexType getNumberOfEntities( DimensionsTag ) const { return this->vertices.getSize(); } - void setEntity( DimensionsTraits, - const GlobalIndexType entityIndex, - const VertexType& entity ) const + VertexType& getEntity( DimensionsTag, + const GlobalIndexType entityIndex ) { - this->vertices.setElement( entityIndex, entity ); + return this->vertices[ entityIndex ]; } - const VertexType& getEntity( DimensionsTraits, + const VertexType& getEntity( DimensionsTag, const GlobalIndexType entityIndex ) const { return this->vertices.getElement( entityIndex ); } - SharedContainerType& getEntities( DimensionsTraits ) + AccessArrayType& getEntities( DimensionsTag ) { return this->sharedVertices; } - const SharedContainerType& getEntities( DimensionsTraits ) const + const AccessArrayType& getEntities( DimensionsTag ) const { return this->sharedVertices; } @@ -286,7 +269,7 @@ class tnlMeshStorageLayer< ConfigTag, { if( ! this->vertices.save( file ) ) { - cerr << "Saving of the mesh entities with " << DimensionsTraits::value << " dimensions failed." << endl; + cerr << "Saving of the mesh entities with " << DimensionsTag::value << " dimensions failed." << endl; return false; } return true; @@ -296,20 +279,21 @@ class tnlMeshStorageLayer< ConfigTag, { if( ! this->vertices.load( file ) ) { - cerr << "Loading of the mesh entities with " << DimensionsTraits::value << " dimensions failed." << endl; + cerr << "Loading of the mesh entities with " << DimensionsTag::value << " dimensions failed." << endl; return false; } - this->sharedVertices.bind( this->vertices ); + this->verticesAccess.bind( this->vertices ); return true; } void print( ostream& str ) const - { + { str << "The mesh vertices are: " << endl; for( GlobalIndexType i = 0; i < vertices.getSize();i ++ ) { str << i << vertices[ i ] << endl; } + SuperentityStorageBaseType::print( str ); } bool operator==( const tnlMeshStorageLayer& meshLayer ) const @@ -319,22 +303,39 @@ class tnlMeshStorageLayer< ConfigTag, private: - ContainerType vertices; + StorageArrayType vertices; + + AccessArrayType verticesAccess; + + // TODO: this is only for the mesh initializer - fix it + public: + + typename EntityTraits::StorageArrayType& entitiesArray( DimensionsTag ) + { + return vertices; + } + + + template< typename SuperDimensionsTag > + typename MeshTraits::GlobalIdArrayType& superentityIdsArray( DimensionsTag ) + { + return SuperentityStorageBaseType::superentityIdsArray( SuperDimensionsTag() ); + } + + template< typename SuperdimensionsTag > + typename MeshTraits::template SuperentityTraits< EntityTopology, SuperdimensionsTag::value >::StorageNetworkType& getSuperentityStorageNetwork( tnlDimensionsTag< EntityTopology::dimensions > ) + { + return SuperentityStorageBaseType::getStorageNetwork( SuperdimensionsTag() ); + } - SharedContainerType sharedVertices; }; /**** * Forces termination of recursive inheritance (prevents compiler from generating huge error logs) */ -template< typename ConfigTag > -class tnlMeshStorageLayer< ConfigTag, - tnlDimensionsTraits< 0 >, - tnlStorageTraits< false > > +template< typename MeshConfig > +class tnlMeshStorageLayer< MeshConfig, tnlDimensionsTag< 0 >, false > { - protected: - - void setNumberOfEntities(); }; diff --git a/src/mesh/layers/tnlMeshSubentityStorageLayer.h b/src/mesh/layers/tnlMeshSubentityStorageLayer.h index ce7e54c82e714720723afd7aa125134657779056..89e96a859455819894674b432ae5760a19a1c83c 100644 --- a/src/mesh/layers/tnlMeshSubentityStorageLayer.h +++ b/src/mesh/layers/tnlMeshSubentityStorageLayer.h @@ -19,68 +19,66 @@ #define TNLMESHSUBENTITYSTORAGELAYER_H_ #include <core/tnlFile.h> -#include <mesh/traits/tnlDimensionsTraits.h> -#include <mesh/traits/tnlStorageTraits.h> -#include <mesh/traits/tnlMeshSubentitiesTraits.h> - -template< typename ConfigTag, - typename EntityTag, - typename DimensionTraits, - typename SubentityStorageTag = - typename tnlMeshSubentitiesTraits< ConfigTag, - EntityTag, - DimensionTraits >::SubentityStorageTag > +#include <mesh/tnlDimensionsTag.h> +#include <mesh/traits/tnlMeshSubentityTraits.h> +#include <mesh/tnlMeshEntityOrientation.h> + +template< typename MeshConfig, + typename EntityTopology, + typename DimensionsTag, + bool SubentityStorage = + tnlMeshTraits< MeshConfig >::template SubentityTraits< EntityTopology, DimensionsTag::value >::storageEnabled, + bool SubentityOrientationStorage = + tnlMeshTraits< MeshConfig >::template SubentityTraits< EntityTopology, DimensionsTag::value >::orientationEnabled > class tnlMeshSubentityStorageLayer; -template< typename ConfigTag, - typename EntityTag > +template< typename MeshConfig, + typename EntityTopology > class tnlMeshSubentityStorageLayers - : public tnlMeshSubentityStorageLayer< ConfigTag, - EntityTag, - tnlDimensionsTraits< EntityTag::dimensions - 1 > > + : public tnlMeshSubentityStorageLayer< MeshConfig, + EntityTopology, + tnlDimensionsTag< EntityTopology::dimensions - 1 > > { }; -template< typename ConfigTag, - typename EntityTag, - typename DimensionsTraits > -class tnlMeshSubentityStorageLayer< ConfigTag, - EntityTag, - DimensionsTraits, - tnlStorageTraits< true > > - : public tnlMeshSubentityStorageLayer< ConfigTag, - EntityTag, - typename DimensionsTraits::Previous > +template< typename MeshConfig, + typename EntityTopology, + typename DimensionsTag > +class tnlMeshSubentityStorageLayer< MeshConfig, + EntityTopology, + DimensionsTag, + true, + true > + : public tnlMeshSubentityStorageLayer< MeshConfig, + EntityTopology, + typename DimensionsTag::Decrement > { - typedef tnlMeshSubentityStorageLayer< ConfigTag, - EntityTag, - typename DimensionsTraits::Previous > BaseType; - - typedef tnlMeshSubentitiesTraits< ConfigTag, - EntityTag, - DimensionsTraits > SubentityTraits; + typedef tnlMeshSubentityStorageLayer< MeshConfig, + EntityTopology, + typename DimensionsTag::Decrement > BaseType; protected: - typedef typename SubentityTraits::ContainerType ContainerType; - typedef typename SubentityTraits::SharedContainerType SharedContainerType; - typedef typename ContainerType::ElementType GlobalIndexType; - typedef int LocalIndexType; + static const int Dimensions = DimensionsTag::value; + typedef tnlMeshTraits< MeshConfig > MeshTraits; + typedef typename MeshTraits::template SubentityTraits< EntityTopology, Dimensions > SubentityTraits; + typedef typename MeshTraits::GlobalIndexType GlobalIndexType; + typedef typename MeshTraits::LocalIndexType LocalIndexType; + typedef typename SubentityTraits::IdArrayType IdArrayType; + typedef typename SubentityTraits::OrientationArrayType OrientationArrayType; + typedef typename MeshTraits::IdPermutationArrayAccessorType IdPermutationArrayAccessorType; tnlMeshSubentityStorageLayer() { this->subentitiesIndices.setValue( -1 ); - this->sharedSubentitiesIndices.bind( this->subentitiesIndices ); - this->sharedSubentitiesIndices.setName( "sharedSubentitiesIndices" ); - //this->subentitiesIndices.setName( "subentitiesIndices" ); } - /*~tnlMeshSubentityStorageLayer() + ~tnlMeshSubentityStorageLayer() { - cout << " Destroying " << this->sharedSubentitiesIndices.getSize() << " subentities with "<< DimensionsTraits::value << " dimensions." << endl; - }*/ + //cout << " Destroying " << this->sharedSubentitiesIndices.getSize() << " subentities with "<< DimensionsTag::value << " dimensions." << endl; + } tnlMeshSubentityStorageLayer& operator = ( const tnlMeshSubentityStorageLayer& layer ) { @@ -94,7 +92,7 @@ class tnlMeshSubentityStorageLayer< ConfigTag, if( ! BaseType::save( file ) || ! this->subentitiesIndices.save( file ) ) { - cerr << "Saving of the entity subentities layer with " << DimensionsTraits::value << " failed." << endl; + cerr << "Saving of the entity subentities layer with " << DimensionsTag::value << " failed." << endl; return false; } return true; @@ -105,10 +103,9 @@ class tnlMeshSubentityStorageLayer< ConfigTag, if( ! BaseType::load( file ) || ! this->subentitiesIndices.load( file ) ) { - cerr << "Loading of the entity subentities layer with " << DimensionsTraits::value << " failed." << endl; + cerr << "Loading of the entity subentities layer with " << DimensionsTag::value << " failed." << endl; return false; } - this->sharedSubentitiesIndices.bind( this->subentitiesIndices ); return true; } @@ -116,7 +113,7 @@ class tnlMeshSubentityStorageLayer< ConfigTag, { BaseType::print( str ); str << endl; - str << "\t Subentities with " << DimensionsTraits::value << " dimensions are: " << subentitiesIndices << "."; + str << "\t Subentities with " << DimensionsTag::value << " dimensions are: " << subentitiesIndices << "."; } bool operator==( const tnlMeshSubentityStorageLayer& layer ) const @@ -130,88 +127,197 @@ class tnlMeshSubentityStorageLayer< ConfigTag, */ using BaseType::getSubentityIndex; using BaseType::setSubentityIndex; - using BaseType::getSubentitiesIndices; /**** * Define setter/getter for the current level of the subentities */ - void setSubentityIndex( DimensionsTraits, + void setSubentityIndex( DimensionsTag, const LocalIndexType localIndex, const GlobalIndexType globalIndex ) { this->subentitiesIndices[ localIndex ] = globalIndex; } - GlobalIndexType getSubentityIndex( DimensionsTraits, + GlobalIndexType getSubentityIndex( DimensionsTag, const LocalIndexType localIndex ) const { return this->subentitiesIndices[ localIndex ]; } - SharedContainerType& getSubentitiesIndices( DimensionsTraits ) + using BaseType::subentityIdsArray; + IdArrayType& subentityIdsArray( DimensionsTag ) { return this->subentitiesIndices; } + + using BaseType::subentityOrientation; + IdPermutationArrayAccessorType subentityOrientation( DimensionsTag, LocalIndexType index) const { - tnlAssert( this->subentitiesIndices.getData() == this->sharedSubentitiesIndices.getData(), ); - return this->sharedSubentitiesIndices; + tnlAssert( 0 <= index && index < SubentityTraits::count, ); + + return this->subentityOrientations[ index ].getSubvertexPermutation(); } - const SharedContainerType& getSubentitiesIndices( DimensionsTraits ) const + using BaseType::subentityOrientationsArray; + OrientationArrayType& subentityOrientationsArray( DimensionsTag ) { return this->subentityOrientations; } + + private: + IdArrayType subentitiesIndices; + + OrientationArrayType subentityOrientations; +}; + + +template< typename MeshConfig, + typename EntityTopology, + typename DimensionsTag > +class tnlMeshSubentityStorageLayer< MeshConfig, + EntityTopology, + DimensionsTag, + true, + false > + : public tnlMeshSubentityStorageLayer< MeshConfig, + EntityTopology, + typename DimensionsTag::Decrement > +{ + typedef tnlMeshSubentityStorageLayer< MeshConfig, + EntityTopology, + typename DimensionsTag::Decrement > BaseType; + + protected: + + static const int Dimensions = DimensionsTag::value; + typedef tnlMeshTraits< MeshConfig > MeshTraits; + typedef typename MeshTraits::template SubentityTraits< EntityTopology, Dimensions > SubentityTraits; + typedef typename MeshTraits::GlobalIndexType GlobalIndexType; + typedef typename MeshTraits::LocalIndexType LocalIndexType; + typedef typename SubentityTraits::IdArrayType IdArrayType; + typedef typename SubentityTraits::OrientationArrayType OrientationArrayType; + typedef typename MeshTraits::IdPermutationArrayAccessorType IdPermutationArrayAccessorType; + + tnlMeshSubentityStorageLayer() { - tnlAssert( this->subentitiesIndices.getData() == this->sharedSubentitiesIndices.getData(), ); - return this->sharedSubentitiesIndices; + this->subentitiesIndices.setValue( -1 ); } - private: - ContainerType subentitiesIndices; + ~tnlMeshSubentityStorageLayer() + { + //cout << " Destroying " << this->sharedSubentitiesIndices.getSize() << " subentities with "<< DimensionsTag::value << " dimensions." << endl; + } - SharedContainerType sharedSubentitiesIndices; + tnlMeshSubentityStorageLayer& operator = ( const tnlMeshSubentityStorageLayer& layer ) + { + BaseType::operator=( layer ); + this->subentitiesIndices = layer.subentitiesIndices; + return *this; + } -}; + bool save( tnlFile& file ) const + { + if( ! BaseType::save( file ) || + ! this->subentitiesIndices.save( file ) ) + { + cerr << "Saving of the entity subentities layer with " << DimensionsTag::value << " failed." << endl; + return false; + } + return true; + } + bool load( tnlFile& file ) + { + if( ! BaseType::load( file ) || + ! this->subentitiesIndices.load( file ) ) + { + cerr << "Loading of the entity subentities layer with " << DimensionsTag::value << " failed." << endl; + return false; + } + return true; + } -template< typename ConfigTag, - typename EntityTag, - typename DimensionsTraits > -class tnlMeshSubentityStorageLayer< ConfigTag, - EntityTag, - DimensionsTraits, - tnlStorageTraits< false > > - : public tnlMeshSubentityStorageLayer< ConfigTag, - EntityTag, - typename DimensionsTraits::Previous > + void print( ostream& str ) const + { + BaseType::print( str ); + str << endl; + str << "\t Subentities with " << DimensionsTag::value << " dimensions are: " << subentitiesIndices << "."; + } + + bool operator==( const tnlMeshSubentityStorageLayer& layer ) const + { + return ( BaseType::operator==( layer ) && + subentitiesIndices == layer.subentitiesIndices ); + } + + /**** + * Make visible setters and getters of the lower subentities + */ + using BaseType::getSubentityIndex; + using BaseType::setSubentityIndex; + + /**** + * Define setter/getter for the current level of the subentities + */ + void setSubentityIndex( DimensionsTag, + const LocalIndexType localIndex, + const GlobalIndexType globalIndex ) + { + this->subentitiesIndices[ localIndex ] = globalIndex; + } + + GlobalIndexType getSubentityIndex( DimensionsTag, + const LocalIndexType localIndex ) const + { + return this->subentitiesIndices[ localIndex ]; + } + + using BaseType::subentityIdsArray; + IdArrayType& subentityIdsArray( DimensionsTag ) { return this->subentitiesIndices; } + + using BaseType::subentityOrientationsArray; + void subentityOrientationsArray() {} + + private: + IdArrayType subentitiesIndices; +}; + +template< typename MeshConfig, + typename EntityTopology, + typename DimensionsTag > +class tnlMeshSubentityStorageLayer< MeshConfig, + EntityTopology, + DimensionsTag, + false, + false > + : public tnlMeshSubentityStorageLayer< MeshConfig, + EntityTopology, + typename DimensionsTag::Decrement > { }; -template< typename ConfigTag, - typename EntityTag > -class tnlMeshSubentityStorageLayer< ConfigTag, - EntityTag, - tnlDimensionsTraits< 0 >, - tnlStorageTraits< true > > +template< typename MeshConfig, + typename EntityTopology > +class tnlMeshSubentityStorageLayer< MeshConfig, + EntityTopology, + tnlDimensionsTag< 0 >, + true, + false > { - typedef tnlDimensionsTraits< 0 > DimensionsTraits; - - typedef tnlMeshSubentitiesTraits< ConfigTag, - EntityTag, - DimensionsTraits > SubentityTraits; + typedef tnlDimensionsTag< 0 > DimensionsTag; protected: - - typedef typename SubentityTraits::ContainerType ContainerType; - typedef typename SubentityTraits::SharedContainerType SharedContainerType; - typedef typename ContainerType::ElementType GlobalIndexType; - typedef int LocalIndexType; + static const int Dimensions = 0; + typedef tnlMeshTraits< MeshConfig > MeshTraits; + typedef typename MeshTraits::template SubentityTraits< EntityTopology, Dimensions > SubentityTraits; + typedef typename MeshTraits::GlobalIndexType GlobalIndexType; + typedef typename MeshTraits::LocalIndexType LocalIndexType; + typedef typename SubentityTraits::IdArrayType IdArrayType; tnlMeshSubentityStorageLayer() { this->verticesIndices.setValue( -1 ); - this->sharedVerticesIndices.bind( this->verticesIndices ); } - /*~tnlMeshSubentityStorageLayer() + ~tnlMeshSubentityStorageLayer() { - cout << " Destroying " << this->sharedVerticesIndices.getSize() << " subentities with "<< DimensionsTraits::value << " dimensions." << endl; - }*/ + //cout << " Destroying " << this->sharedVerticesIndices.getSize() << " subentities with "<< DimensionsTag::value << " dimensions." << endl; + } tnlMeshSubentityStorageLayer& operator = ( const tnlMeshSubentityStorageLayer& layer ) @@ -224,7 +330,7 @@ class tnlMeshSubentityStorageLayer< ConfigTag, { if( ! this->verticesIndices.save( file ) ) { - cerr << "Saving of the entity subentities layer with " << DimensionsTraits::value << " failed." << endl; + cerr << "Saving of the entity subentities layer with " << DimensionsTag::value << " failed." << endl; return false; } return true; @@ -234,16 +340,15 @@ class tnlMeshSubentityStorageLayer< ConfigTag, { if( ! this->verticesIndices.load( file ) ) { - cerr << "Loading of the entity subentities layer with " << DimensionsTraits::value << " failed." << endl; + cerr << "Loading of the entity subentities layer with " << DimensionsTag::value << " failed." << endl; return false; } - this->sharedVerticesIndices.bind( this->verticesIndices ); return true; } void print( ostream& str ) const { - str << "\t Subentities with " << DimensionsTraits::value << " dimensions are: " << this->verticesIndices << "."; + str << "\t Subentities with " << DimensionsTag::value << " dimensions are: " << this->verticesIndices << "."; } bool operator==( const tnlMeshSubentityStorageLayer& layer ) const @@ -251,43 +356,38 @@ class tnlMeshSubentityStorageLayer< ConfigTag, return ( verticesIndices == layer.verticesIndices ); } - GlobalIndexType getSubentityIndex( DimensionsTraits, + GlobalIndexType getSubentityIndex( DimensionsTag, const LocalIndexType localIndex ) const { return this->verticesIndices[ localIndex ]; } - void setSubentityIndex( DimensionsTraits, + void setSubentityIndex( DimensionsTag, const LocalIndexType localIndex, const GlobalIndexType globalIndex ) { this->verticesIndices[ localIndex ] = globalIndex; } - SharedContainerType& getSubentitiesIndices( DimensionsTraits ) - { - tnlAssert( this->verticesIndices.getData() == this->sharedVerticesIndices.getData(), ); - return this->sharedVerticesIndices; - } - - const SharedContainerType& getSubentitiesIndices( DimensionsTraits ) const - { - tnlAssert( this->verticesIndices.getData() == this->sharedVerticesIndices.getData(), ); - return this->sharedVerticesIndices; - } - - private: - - ContainerType verticesIndices; - - SharedContainerType sharedVerticesIndices; + IdArrayType& subentityIdsArray( DimensionsTag ) { return this->verticesIndices; } + + protected: + + /*** + * Necessary because of 'using TBase::...;' in the derived classes + */ + void subentityOrientation() {} + void subentityOrientationsArray() {} + + IdArrayType verticesIndices; }; -template< typename ConfigTag, - typename EntityTag > -class tnlMeshSubentityStorageLayer< ConfigTag, - EntityTag, - tnlDimensionsTraits< 0 >, - tnlStorageTraits< false > > +template< typename MeshConfig, + typename EntityTopology > +class tnlMeshSubentityStorageLayer< MeshConfig, + EntityTopology, + tnlDimensionsTag< 0 >, + false, + false > { public: diff --git a/src/mesh/layers/tnlMeshSuperentityAccess.h b/src/mesh/layers/tnlMeshSuperentityAccess.h new file mode 100644 index 0000000000000000000000000000000000000000..2c0679642573ae4534831d14985a4607cf8a0186 --- /dev/null +++ b/src/mesh/layers/tnlMeshSuperentityAccess.h @@ -0,0 +1,159 @@ +/*************************************************************************** + tnlMeshSuperentityAccess.h - description + ------------------- + begin : Aug 15, 2015 + copyright : (C) 2015 by Tomas Oberhuber et al. + 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 TNLSUPERENTITYACCESS_H +#define TNLSUPERENTITYACCESS_H + +#include <mesh/traits/tnlMeshTraits.h> + + +template< typename MeshConfig, + typename MeshEntity, + typename DimensionsTag, + bool SuperentityStorage = + tnlMeshTraits< MeshConfig >::template SuperentityTraits< MeshEntity, DimensionsTag::value >::storageEnabled > +class tnlMeshSuperentityAccessLayer; + + +template< typename MeshConfig, + typename MeshEntity > +class tnlMeshSuperentityAccess : + public tnlMeshSuperentityAccessLayer< MeshConfig, + MeshEntity, + tnlDimensionsTag< tnlMeshTraits< MeshConfig >::meshDimensions > > +{ + public: + typedef tnlMeshSuperentityAccessLayer< MeshConfig, + MeshEntity, + tnlDimensionsTag< tnlMeshTraits< MeshConfig >::meshDimensions > > BaseType; + + bool operator == ( const tnlMeshSuperentityAccess< MeshConfig, MeshEntity>& a ) const { return true; } // TODO: fix + + void print( ostream& str ) const + { + BaseType::print( str ); + }; + +}; + +template< typename MeshConfig, + typename MeshEntity, + typename Dimensions > +class tnlMeshSuperentityAccessLayer< MeshConfig, + MeshEntity, + Dimensions, + true > : + public tnlMeshSuperentityAccessLayer< MeshConfig, MeshEntity, typename Dimensions::Decrement > +{ + typedef tnlMeshSuperentityAccessLayer< MeshConfig, MeshEntity, typename Dimensions::Decrement > BaseType; + + public: + + typedef tnlMeshTraits< MeshConfig > MeshTraits; + typedef typename MeshTraits::template SuperentityTraits< MeshEntity, Dimensions::value > SuperentityTraits; + typedef typename MeshTraits::IdArrayAccessorType IdArrayAccessorType; + typedef typename SuperentityTraits::StorageNetworkType StorageNetworkType; + typedef typename SuperentityTraits::SuperentityAccessorType SuperentityAccessorType; + //typedef typename StorageNetworkType::PortsType SuperentityAccessorType; + + using BaseType::superentityIds; + IdArrayAccessorType superentityIds( Dimensions ) const { return m_superentityIndices; } + + using BaseType::superentityIdsArray; + IdArrayAccessorType &superentityIdsArray( Dimensions ) { return m_superentityIndices; } + + using BaseType::getSuperentityIndices; + const SuperentityAccessorType& getSuperentityIndices( Dimensions ) const + { + cerr << "###" << endl; + return this->superentityIndices; + } + + SuperentityAccessorType& getSuperentityIndices( Dimensions ) + { + cerr << "######" << endl; + return this->superentityIndices; + } + + void print( ostream& str ) const + { + str << "Superentities with " << Dimensions::value << " dimensions are: " << + this->superentityIndices << endl; + BaseType::print( str ); + } + + //bool operator == ( const tnlMeshSuperentityAccessLayer< MeshConfig, MeshEntity, Dimensions, tnlStorageTraits< true > >& l ) { return true; } // TODO: fix + + private: + IdArrayAccessorType m_superentityIndices; + + SuperentityAccessorType superentityIndices; + +}; + +template< typename MeshConfig, + typename MeshEntity, + typename Dimensions > +class tnlMeshSuperentityAccessLayer< MeshConfig, + MeshEntity, + Dimensions, + false > : + public tnlMeshSuperentityAccessLayer< MeshConfig, MeshEntity, typename Dimensions::Decrement > +{ +}; + +template< typename MeshConfig, + typename MeshEntity > +class tnlMeshSuperentityAccessLayer< MeshConfig, + MeshEntity, + tnlDimensionsTag< MeshEntity::dimensions >, + false > +{ + protected: + /*** + * Necessary because of 'using TBase::...;' in the derived classes + */ + void superentityIds() {} + void superentityIdsArray() {} + + void getSuperentityIndices() {}; + + void print( ostream& str ) const {}; +}; + +template< typename MeshConfig, + typename MeshEntity > +class tnlMeshSuperentityAccessLayer< MeshConfig, + MeshEntity, + tnlDimensionsTag< MeshEntity::dimensions >, + true > +{ + protected: + /*** + * Necessary because of 'using TBase::...;' in the derived classes + */ + void superentityIds() {} + void superentityIdsArray() {} + + void getSuperentityIndices() {}; + + void print( ostream& str ) const {}; +}; + + +#endif /* TNLSUPERENTITYACCESS_H */ + diff --git a/src/mesh/layers/tnlMeshSuperentityAccessor.h b/src/mesh/layers/tnlMeshSuperentityAccessor.h new file mode 100644 index 0000000000000000000000000000000000000000..35139059c6d22637d95bbf2d262df9a3255fe142 --- /dev/null +++ b/src/mesh/layers/tnlMeshSuperentityAccessor.h @@ -0,0 +1,76 @@ +/*************************************************************************** + tnlMeshSuperentityAccessor.h - description + ------------------- + begin : Sep 11, 2015 + copyright : (C) 2015 by Tomas Oberhuber et al. + 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 TNLMESHSUPERENTITYACCESSOR_H +#define TNLMESHSUPERENTITYACCESSOR_H + +template< typename IndexMultimapValues > +class tnlMeshSuperentityAccessor +{ + public: + + typedef typename IndexMultimapValues::IndexType GlobalIndexType; + typedef typename IndexMultimapValues::IndexType LocalIndexType; + + // TODO: Add LocalIndexType to EllpackIndexMultimap + + LocalIndexType getSupernetitiesCount() const + { + return this->indexes.getPortsCount(); + }; + + void setSuperentityIndex( const LocalIndexType localIndex, + const GlobalIndexType globalIndex ) + { + indexes.setOutput( localIndex, globalIndex ); + } + + GlobalIndexType getSuperentityIndex( const LocalIndexType localIndex ) const + { + return indexes.getOutput( localIndex ); + } + + GlobalIndexType& operator[]( const LocalIndexType localIndex ) + { + return this->indexes[ localIndex ]; + } + + const GlobalIndexType& operator[]( const LocalIndexType localIndex ) const + { + return this->indexes[ localIndex ]; + } + + void print( ostream& str ) const + { + str << indexes; + } + + protected: + + IndexMultimapValues indexes; + +}; + +template< typename IndexMultimapValues > +ostream& operator << ( ostream& str, const tnlMeshSuperentityAccessor< IndexMultimapValues >& superentityAccessor ) +{ + superentityAccessor.print( str ); + return str; +} + +#endif /* TNLMESHSUPERENTITYACCESSOR_H */ + diff --git a/src/mesh/layers/tnlMeshSuperentityStorageLayer.h b/src/mesh/layers/tnlMeshSuperentityStorageLayer.h index d7184117c9eff82b5c260307d25f69f2b183bde6..e31a839cc9f4835b598242114b3e6645ce176797 100644 --- a/src/mesh/layers/tnlMeshSuperentityStorageLayer.h +++ b/src/mesh/layers/tnlMeshSuperentityStorageLayer.h @@ -2,7 +2,7 @@ tnlMeshSuperentityStorageLayer.h - description ------------------- begin : Feb 13, 2014 - copyright : (C) 2014 by Tomas Oberhuber + copyright : (C) 2014 by Tomas Oberhuber et al. email : tomas.oberhuber@fjfi.cvut.cz ***************************************************************************/ @@ -19,55 +19,48 @@ #define TNLMESHSUPERENTITYSTORAGELAYER_H_ #include <core/tnlFile.h> -#include <mesh/traits/tnlDimensionsTraits.h> -#include <mesh/traits/tnlStorageTraits.h> +#include <mesh/tnlDimensionsTag.h> #include <mesh/traits/tnlMeshTraits.h> -#include <mesh/traits/tnlMeshSuperentitiesTraits.h> - -template< typename ConfigTag, - typename EntityTag, - typename DimensionsTraits, - typename SuperentityStorageTag = - typename tnlMeshSuperentitiesTraits< ConfigTag, - EntityTag, - DimensionsTraits >::SuperentityStorageTag > +#include <mesh/traits/tnlMeshSuperentityTraits.h> + +template< typename MeshConfig, + typename EntityTopology, + typename DimensionsTag, + bool SuperentityStorage = + tnlMeshSuperentityTraits< MeshConfig, EntityTopology, DimensionsTag::value >::storageEnabled > class tnlMeshSuperentityStorageLayer; -template< typename ConfigTag, - typename EntityTag > +template< typename MeshConfig, + typename EntityTopology > class tnlMeshSuperentityStorageLayers - : public tnlMeshSuperentityStorageLayer< ConfigTag, - EntityTag, - typename tnlMeshTraits< ConfigTag >::DimensionsTraits > + : public tnlMeshSuperentityStorageLayer< MeshConfig, + EntityTopology, + tnlDimensionsTag< tnlMeshTraits< MeshConfig >::meshDimensions > > { }; -template< typename ConfigTag, - typename EntityTag, - typename DimensionsTraits > -class tnlMeshSuperentityStorageLayer< ConfigTag, - EntityTag, - DimensionsTraits, - tnlStorageTraits< true > > - : public tnlMeshSuperentityStorageLayer< ConfigTag, - EntityTag, - typename DimensionsTraits::Previous > +template< typename MeshConfig, + typename EntityTopology, + typename DimensionsTag > +class tnlMeshSuperentityStorageLayer< MeshConfig, EntityTopology, DimensionsTag, true > + : public tnlMeshSuperentityStorageLayer< MeshConfig, EntityTopology, typename DimensionsTag::Decrement > { typedef - tnlMeshSuperentityStorageLayer< ConfigTag, - EntityTag, - typename DimensionsTraits::Previous > BaseType; + tnlMeshSuperentityStorageLayer< MeshConfig, EntityTopology, typename DimensionsTag::Decrement > BaseType; - typedef - tnlMeshSuperentitiesTraits< ConfigTag, EntityTag, DimensionsTraits > SuperentityTag; + static const int Dimensions = DimensionsTag::value; + typedef tnlMeshTraits< MeshConfig > MeshTraits; + typedef typename MeshTraits::template SuperentityTraits< EntityTopology, Dimensions > SuperentityTraits; protected: - typedef typename SuperentityTag::ContainerType ContainerType; - typedef typename SuperentityTag::SharedContainerType SharedContainerType; - typedef typename ContainerType::ElementType GlobalIndexType; - typedef int LocalIndexType; + typedef typename SuperentityTraits::StorageArrayType StorageArrayType; + typedef typename SuperentityTraits::AccessArrayType AccessArrayType; + typedef typename SuperentityTraits::GlobalIndexType GlobalIndexType; + typedef typename SuperentityTraits::LocalIndexType LocalIndexType; + typedef typename SuperentityTraits::StorageNetworkType StorageNetworkType; + /**** * Make visible setters and getters of the lower superentities */ @@ -79,13 +72,11 @@ class tnlMeshSuperentityStorageLayer< ConfigTag, tnlMeshSuperentityStorageLayer() { - this->superentitiesIndices.setName( tnlString( "tnlMeshSuperentityStorageLayer < " ) + tnlString( DimensionsTraits::value ) + " >::superentitiesIndices" ); - this->sharedSuperentitiesIndices.setName( tnlString( "tnlMeshSuperentityStorageLayer < " ) + tnlString( DimensionsTraits::value ) + " >::sharedSuperentitiesIndices" ); } /*~tnlMeshSuperentityStorageLayer() { - cerr << " Destroying " << this->superentitiesIndices.getSize() << " superentities with "<< DimensionsTraits::value << " dimensions." << endl; + cerr << " Destroying " << this->superentitiesIndices.getSize() << " superentities with "<< DimensionsTag::value << " dimensions." << endl; cerr << " this->superentitiesIndices.getName() = " << this->superentitiesIndices.getName() << endl; cerr << " this->sharedSuperentitiesIndices.getName() = " << this->sharedSuperentitiesIndices.getName() << endl; }*/ @@ -101,7 +92,7 @@ class tnlMeshSuperentityStorageLayer< ConfigTag, /**** * Define setter/getter for the current level of the superentities */ - bool setNumberOfSuperentities( DimensionsTraits, + bool setNumberOfSuperentities( DimensionsTag, const LocalIndexType size ) { if( ! this->superentitiesIndices.setSize( size ) ) @@ -111,30 +102,30 @@ class tnlMeshSuperentityStorageLayer< ConfigTag, return true; } - LocalIndexType getNumberOfSuperentities( DimensionsTraits ) const + LocalIndexType getNumberOfSuperentities( DimensionsTag ) const { return this->superentitiesIndices.getSize(); } - void setSuperentityIndex( DimensionsTraits, + void setSuperentityIndex( DimensionsTag, const LocalIndexType localIndex, const GlobalIndexType globalIndex ) { this->superentitiesIndices[ localIndex ] = globalIndex; } - GlobalIndexType getSuperentityIndex( DimensionsTraits, + GlobalIndexType getSuperentityIndex( DimensionsTag, const LocalIndexType localIndex ) const { return this->superentitiesIndices[ localIndex ]; } - SharedContainerType& getSuperentitiesIndices( DimensionsTraits ) + AccessArrayType& getSuperentitiesIndices( DimensionsTag ) { return this->sharedSuperentitiesIndices; } - const SharedContainerType& getSuperentitiesIndices( DimensionsTraits ) const + const AccessArrayType& getSuperentitiesIndices( DimensionsTag ) const { return this->sharedSuperentitiesIndices; } @@ -144,7 +135,7 @@ class tnlMeshSuperentityStorageLayer< ConfigTag, if( ! BaseType::save( file ) || ! this->superentitiesIndices.save( file ) ) { - //cerr << "Saving of the entity superentities layer with " << DimensionsTraits::value << " failed." << endl; + //cerr << "Saving of the entity superentities layer with " << DimensionsTag::value << " failed." << endl; return false; } return true; @@ -155,7 +146,7 @@ class tnlMeshSuperentityStorageLayer< ConfigTag, if( ! BaseType::load( file ) || ! this->superentitiesIndices.load( file ) ) { - //cerr << "Loading of the entity superentities layer with " << DimensionsTraits::value << " failed." << endl; + //cerr << "Loading of the entity superentities layer with " << DimensionsTag::value << " failed." << endl; return false; } return true; @@ -164,7 +155,7 @@ class tnlMeshSuperentityStorageLayer< ConfigTag, void print( ostream& str ) const { BaseType::print( str ); - str << endl << "\t Superentities with " << DimensionsTraits::value << " dimensions are: " << this->superentitiesIndices << "."; + str << endl << "\t Superentities with " << DimensionsTag::value << " dimensions are: " << this->superentitiesIndices << "."; } bool operator==( const tnlMeshSuperentityStorageLayer& layer ) const @@ -173,61 +164,71 @@ class tnlMeshSuperentityStorageLayer< ConfigTag, superentitiesIndices == layer.superentitiesIndices ); } - private: + private: - ContainerType superentitiesIndices; + StorageArrayType superentitiesIndices; - SharedContainerType sharedSuperentitiesIndices; + AccessArrayType sharedSuperentitiesIndices; + + StorageNetworkType storageNetwork; + + // TODO: this is only for the mesh initializer - fix it + public: + + using BaseType::superentityIdsArray; + typename tnlMeshTraits< MeshConfig >::GlobalIdArrayType& superentityIdsArray( DimensionsTag ) + { + return this->superentitiesIndices; + } + + using BaseType::getStorageNetwork; + StorageNetworkType& getStorageNetwork( DimensionsTag ) + { + return this->storageNetwork; + } }; -template< typename ConfigTag, - typename EntityTag, - typename DimensionsTraits > -class tnlMeshSuperentityStorageLayer< ConfigTag, - EntityTag, - DimensionsTraits, - tnlStorageTraits< false > > - : public tnlMeshSuperentityStorageLayer< ConfigTag, - EntityTag, - typename DimensionsTraits::Previous > +template< typename MeshConfig, + typename EntityTopology, + typename DimensionsTag > +class tnlMeshSuperentityStorageLayer< MeshConfig, EntityTopology, DimensionsTag, false > + : public tnlMeshSuperentityStorageLayer< MeshConfig, EntityTopology, typename DimensionsTag::Decrement > { public: }; -template< typename ConfigTag, - typename EntityTag > -class tnlMeshSuperentityStorageLayer< ConfigTag, - EntityTag, - tnlDimensionsTraits< EntityTag::dimensions >, - tnlStorageTraits< false > > +template< typename MeshConfig, + typename EntityTopology > +class tnlMeshSuperentityStorageLayer< MeshConfig, EntityTopology, tnlDimensionsTag< EntityTopology::dimensions >, false > { - typedef tnlDimensionsTraits< EntityTag::dimensions > DimensionsTraits; + static const int Dimensions = EntityTopology::dimensions; + typedef tnlDimensionsTag< EntityTopology::dimensions > DimensionsTag; - typedef tnlMeshSuperentitiesTraits< ConfigTag, - EntityTag, - DimensionsTraits > SuperentityTag; + typedef tnlMeshSuperentityTraits< MeshConfig, EntityTopology, Dimensions > SuperentityTraits; - typedef tnlMeshSuperentityStorageLayer< ConfigTag, - EntityTag, - DimensionsTraits, - tnlStorageTraits< false > > ThisType; + typedef tnlMeshSuperentityStorageLayer< MeshConfig, + EntityTopology, + DimensionsTag, + false > ThisType; protected: - typedef typename SuperentityTag::ContainerType ContainerType; + typedef typename SuperentityTraits::ContainerType ContainerType; typedef typename ContainerType::ElementType GlobalIndexType; typedef int LocalIndexType; + typedef typename SuperentityTraits::StorageNetworkType StorageNetworkType; + /**** * These methods are due to 'using BaseType::...;' in the derived classes. */ - bool setNumberOfSuperentities( DimensionsTraits, + bool setNumberOfSuperentities( DimensionsTag, const LocalIndexType size ); - LocalIndexType getNumberOfSuperentities( DimensionsTraits ) const; - GlobalIndexType getSuperentityIndex( DimensionsTraits, + LocalIndexType getNumberOfSuperentities( DimensionsTag ) const; + GlobalIndexType getSuperentityIndex( DimensionsTag, const LocalIndexType localIndex ){} - void setSuperentityIndex( DimensionsTraits, + void setSuperentityIndex( DimensionsTag, const LocalIndexType localIndex, const GlobalIndexType globalIndex ) {} @@ -251,41 +252,56 @@ class tnlMeshSuperentityStorageLayer< ConfigTag, { return true; } + + typename tnlMeshTraits< MeshConfig >::GlobalIdArrayType& superentityIdsArray( DimensionsTag ) + { + tnlAssert( false, ); + //return this->superentitiesIndices; + } + + StorageNetworkType& getStorageNetwork( DimensionsTag ) + { + tnlAssert( false, ); + //return this->storageNetwork; + } }; -template< typename ConfigTag, - typename EntityTag > -class tnlMeshSuperentityStorageLayer< ConfigTag, - EntityTag, - tnlDimensionsTraits< EntityTag::dimensions >, - tnlStorageTraits< true > > +template< typename MeshConfig, + typename EntityTopology > +class tnlMeshSuperentityStorageLayer< MeshConfig, + EntityTopology, + tnlDimensionsTag< EntityTopology::dimensions >, + true > { - typedef tnlDimensionsTraits< EntityTag::dimensions > DimensionsTraits; + static const int Dimensions = EntityTopology::dimensions; + typedef tnlDimensionsTag< Dimensions > DimensionsTag; - typedef tnlMeshSuperentitiesTraits< ConfigTag, - EntityTag, - DimensionsTraits > SuperentityTag; - typedef tnlMeshSuperentityStorageLayer< ConfigTag, - EntityTag, - DimensionsTraits, - tnlStorageTraits< true > > ThisType; + typedef tnlMeshSuperentityTraits< MeshConfig, + EntityTopology, + Dimensions > SuperentityTraits; + typedef tnlMeshSuperentityStorageLayer< MeshConfig, + EntityTopology, + DimensionsTag, + true > ThisType; protected: - typedef typename SuperentityTag::ContainerType ContainerType; - typedef typename ContainerType::ElementType GlobalIndexType; - typedef int LocalIndexType; + typedef typename SuperentityTraits::StorageArrayType StorageArrayType; + typedef typename SuperentityTraits::GlobalIndexType GlobalIndexType; + typedef typename SuperentityTraits::LocalIndexType LocalIndexType; + typedef typename SuperentityTraits::StorageNetworkType StorageNetworkType; + /**** * These methods are due to 'using BaseType::...;' in the derived classes. */ - bool setNumberOfSuperentities( DimensionsTraits, + bool setNumberOfSuperentities( DimensionsTag, const LocalIndexType size ); - LocalIndexType getNumberOfSuperentities( DimensionsTraits ) const; - GlobalIndexType getSuperentityIndex( DimensionsTraits, + LocalIndexType getNumberOfSuperentities( DimensionsTag ) const; + GlobalIndexType getSuperentityIndex( DimensionsTag, const LocalIndexType localIndex ){} - void setSuperentityIndex( DimensionsTraits, + void setSuperentityIndex( DimensionsTag, const LocalIndexType localIndex, const GlobalIndexType globalIndex ) {} @@ -296,9 +312,9 @@ class tnlMeshSuperentityStorageLayer< ConfigTag, return true; } - ContainerType& getSuperentitiesIndices(){} + StorageArrayType& getSuperentitiesIndices(){} - const ContainerType& getSuperentitiesIndices() const{} + const StorageArrayType& getSuperentitiesIndices() const{} bool save( tnlFile& file ) const { @@ -309,6 +325,20 @@ class tnlMeshSuperentityStorageLayer< ConfigTag, { return true; } + + typename tnlMeshTraits< MeshConfig >::GlobalIdArrayType& superentityIdsArray( DimensionsTag ) + { + tnlAssert( false, ); + //return this->superentitiesIndices; + } + + StorageNetworkType& getStorageNetwork( DimensionsTag ) + { + tnlAssert( false, ); + //return this->storageNetwork; + } + + }; #endif /* TNLMESHSUPERENTITYSTORAGELAYER_H_ */ diff --git a/src/mesh/tnlDimensionsTag.h b/src/mesh/tnlDimensionsTag.h new file mode 100644 index 0000000000000000000000000000000000000000..7014bc5d59dfaaceded4c8a5fffabc978e84a956 --- /dev/null +++ b/src/mesh/tnlDimensionsTag.h @@ -0,0 +1,59 @@ +/*************************************************************************** + tnlDimensionsTag.h - description + ------------------- + begin : Feb 11, 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 TNLDIMENSIONSTAG_H_ +#define TNLDIMENSIONSTAG_H_ + +#include <core/tnlAssert.h> + +/*** + * This tag or integer wrapper is necessary for C++ templates specializations. + * As th C++ standard says: + * + * A partially specialized non-type argument expression shall not involve + * a template parameter of the partial specialization except when the argument + * expression is a simple identifier. + * + * Therefore one cannot specialize the mesh layers just by integers saying the mesh + * layer dimensions but instead this tag must be used. This makes the code more difficult + * to read and we would like to avoid it if it is possible sometime. + * On the other hand, tnlDimensionTag is also used for method overloading when + * asking for different mesh entities. In this case it makes sense and it cannot be + * replaced. + */ + +template< int Dimensions > +class tnlDimensionsTag +{ + public: + + static const int value = Dimensions; + + typedef tnlDimensionsTag< Dimensions - 1 > Decrement; + + tnlStaticAssert( value >= 0, "The value of the dimensions cannot be negative." ); +}; + +template<> +class tnlDimensionsTag< 0 > +{ + public: + + static const int value = 0; +}; + +#endif /* TNLDIMENSIONSTAG_H_ */ diff --git a/src/mesh/tnlGrid.h b/src/mesh/tnlGrid.h index cece8b9a60039dc5741f21c8afc7431121a9cc05..dd3f5c1ac06ef10649358ae710c81ba563f7996b 100644 --- a/src/mesh/tnlGrid.h +++ b/src/mesh/tnlGrid.h @@ -32,8 +32,8 @@ class tnlGrid : public tnlObject { }; -#include <mesh/tnlGrid1D.h> -#include <mesh/tnlGrid2D.h> -#include <mesh/tnlGrid3D.h> +#include <mesh/grids/tnlGrid1D.h> +#include <mesh/grids/tnlGrid2D.h> +#include <mesh/grids/tnlGrid3D.h> #endif /* TNLGRID_H_ */ diff --git a/src/mesh/tnlMesh.h b/src/mesh/tnlMesh.h index 92d61ed7e60d0d5a4950a5b607ccd84f7028cfe4..71e55bbe5e88b051ca5a31aa014890063f0bf6d5 100644 --- a/src/mesh/tnlMesh.h +++ b/src/mesh/tnlMesh.h @@ -2,7 +2,7 @@ tnlMesh.h - description ------------------- begin : Feb 16, 2014 - copyright : (C) 2014 by Tomas Oberhuber + copyright : (C) 2014 by Tomas Oberhuber et al. email : tomas.oberhuber@fjfi.cvut.cz ***************************************************************************/ @@ -18,179 +18,97 @@ #ifndef TNLMESH_H_ #define TNLMESH_H_ +#include <ostream> #include <core/tnlObject.h> #include <mesh/tnlMeshEntity.h> +#include <mesh/traits/tnlMeshTraits.h> #include <mesh/layers/tnlMeshStorageLayer.h> +#include <mesh/config/tnlMeshConfigValidator.h> +#include <mesh/initializer/tnlMeshInitializer.h> -template< typename ConfigTag > -class tnlMesh : public tnlObject, - public tnlMeshStorageLayers< ConfigTag > +template< typename MeshConfig > //, + //typename Device = tnlHost > +class tnlMesh : public tnlObject/*, + public tnlMeshStorageLayers< MeshConfig >*/ { - //template<typename, typename, typename> friend class InitializerLayer; - //friend class IOReader<ConfigTag>; - - typedef tnlMeshStorageLayers<ConfigTag> BaseType; - public: - typedef ConfigTag Config; - typedef typename tnlMeshTraits< ConfigTag >::PointType PointType; - enum { dimensions = tnlMeshTraits< ConfigTag >::meshDimensions }; - - /*~tnlMesh() - { - cerr << "Destroying mesh " << this->getName() << endl; - }*/ - - static tnlString getType() - { - return tnlString( "tnlMesh< ") + ConfigTag::getType() + " >"; - } - - virtual tnlString getTypeVirtual() const - { - return this->getType(); - } - - using tnlObject::save; - using tnlObject::load; - - bool save( tnlFile& file ) const - { - if( ! tnlObject::save( file ) || - ! BaseType::save( file ) ) - { - cerr << "Mesh saving failed." << endl; - return false; - } - return true; - } - - bool load( tnlFile& file ) - { - if( ! tnlObject::load( file ) || - ! BaseType::load( file ) ) + + typedef MeshConfig Config; + typedef tnlMeshTraits< MeshConfig > MeshTraits; + typedef typename MeshTraits::DeviceType DeviceType; + typedef typename MeshTraits::GlobalIndexType GlobalIndexType; + typedef typename MeshTraits::LocalIndexType LocalIndexType; + typedef typename MeshTraits::CellType CellType; + typedef typename MeshTraits::VertexType VertexType; + typedef typename MeshTraits::PointType PointType; + static const int dimensions = MeshTraits::meshDimensions; + template< int Dimensions > using EntityTraits = typename MeshTraits::template EntityTraits< Dimensions >; + template< int Dimensions > using EntityType = typename EntityTraits< Dimensions >::EntityType; + + static tnlString getType(); + + virtual tnlString getTypeVirtual() const; + + static constexpr int getDimensions(); + + template< int Dimensions > + bool entitiesAvalable() const; + + GlobalIndexType getNumberOfCells() const; + + template< int Dimensions > + GlobalIndexType getNumberOfEntities() const; + + CellType& getCell( const GlobalIndexType entityIndex ); + + const CellType& getCell( const GlobalIndexType entityIndex ) const; + + template< int Dimensions > + EntityType< Dimensions >& getEntity( const GlobalIndexType entityIndex ); + + template< int Dimensions > + const EntityType< Dimensions >& getEntity( const GlobalIndexType entityIndex ) const; + + bool save( tnlFile& file ) const; + + bool load( tnlFile& file ); + + using tnlObject::load; + using tnlObject::save; + + void print( ostream& str ) const; + + bool operator==( const tnlMesh& mesh ) const; + + // TODO: this is only for mesh intializer - remove it if possible + template< typename DimensionsTag > + typename EntityTraits< DimensionsTag::value >::StorageArrayType& entitiesArray(); + + + template< typename DimensionsTag, typename SuperDimensionsTag > + typename tnlMeshTraits< MeshConfig >::GlobalIdArrayType& superentityIdsArray(); + + template< typename EntityTopology, typename SuperdimensionsTag > + typename MeshTraits::template SuperentityTraits< EntityTopology, SuperdimensionsTag::value >::StorageNetworkType& + getSuperentityStorageNetwork() { - cerr << "Mesh loading failed." << endl; - return false; + return entitiesStorage.template getSuperentityStorageNetwork< SuperdimensionsTag >( tnlDimensionsTag< EntityTopology::dimensions >() ); } - return true; - } - - template< int Dimensions > - struct EntitiesTraits - { - typedef tnlDimensionsTraits< Dimensions > DimensionsTraits; - typedef tnlMeshEntitiesTraits< ConfigTag, DimensionsTraits > MeshEntitiesTraits; - typedef typename MeshEntitiesTraits::Type Type; - typedef typename MeshEntitiesTraits::ContainerType ContainerType; - typedef typename MeshEntitiesTraits::SharedContainerType SharedContainerType; - typedef typename ContainerType::IndexType GlobalIndexType; - typedef typename ContainerType::ElementType EntityType; - enum { available = tnlMeshEntityStorage< ConfigTag, Dimensions >::enabled }; - }; - - using BaseType::setNumberOfVertices; - using BaseType::getNumberOfVertices; - using BaseType::setVertex; - using BaseType::getVertex; - - template< int Dimensions > - bool entitiesAvalable() const - { - return EntitiesTraits< Dimensions >::available; - } - - template< int Dimensions > - bool setNumberOfEntities( typename EntitiesTraits< Dimensions >::GlobalIndexType size ) - { - return BaseType::setNumberOfEntities( tnlDimensionsTraits< Dimensions >(), size ); - } - - template< int Dimensions > - typename EntitiesTraits< Dimensions >::GlobalIndexType getNumberOfEntities() const - { - return BaseType::getNumberOfEntities( tnlDimensionsTraits< Dimensions >() ); - } - - bool setNumberOfCells( typename EntitiesTraits< dimensions >::GlobalIndexType size ) - { - return BaseType::setNumberOfEntities( tnlDimensionsTraits< dimensions >(), size ); - } - - typename EntitiesTraits< dimensions >::GlobalIndexType getNumberOfCells() const - { - return BaseType::getNumberOfEntities( tnlDimensionsTraits< dimensions >() ); - } - - template< int Dimensions > - typename EntitiesTraits< Dimensions >::EntityType& - getEntity( const typename EntitiesTraits< Dimensions >::GlobalIndexType entityIndex ) - { - return BaseType::getEntity( tnlDimensionsTraits< Dimensions >(), entityIndex ); - } - - template< int Dimensions > - const typename EntitiesTraits< Dimensions >::EntityType& - getEntity( const typename EntitiesTraits< Dimensions >::GlobalIndexType entityIndex ) const - { - return BaseType::getEntity( tnlDimensionsTraits< Dimensions >(), entityIndex ); - } - - template< int Dimensions > - void setEntity( const typename EntitiesTraits< Dimensions >::GlobalIndexType entityIndex, - const typename EntitiesTraits< Dimensions >::EntityType& entity ) - { - BaseType::setEntity( tnlDimensionsTraits< Dimensions >(), entityIndex, entity ); - } - - template< int Dimensions > - typename EntitiesTraits< Dimensions >::SharedContainerType& getEntities() - { - return BaseType::getEntities( tnlDimensionsTraits< Dimensions >() ); - } - - template< int Dimensions > - const typename EntitiesTraits< Dimensions >::SharedContainerType& getEntities() const - { - return BaseType::getEntities( tnlDimensionsTraits< Dimensions >() ); - } - - typename EntitiesTraits< dimensions >::EntityType& - getCell( const typename EntitiesTraits< dimensions >::GlobalIndexType entityIndex ) - { - return BaseType::getEntity( tnlDimensionsTraits< dimensions >(), entityIndex ); - } - - const typename EntitiesTraits< dimensions >::EntityType& - getCell( const typename EntitiesTraits< dimensions >::GlobalIndexType entityIndex ) const - { - return BaseType::getEntity( tnlDimensionsTraits< dimensions >(), entityIndex ); - } - - void setCell( const typename EntitiesTraits< dimensions >::GlobalIndexType entityIndex, - const typename EntitiesTraits< dimensions >::EntityType& entity ) - { - BaseType::setEntity( tnlDimensionsTraits< dimensions >(), entityIndex, entity ); - } - - void print( ostream& str ) const - { - BaseType::print( str ); - } - - bool operator==( const tnlMesh& mesh ) const - { - return BaseType::operator==( mesh ); - } - - private: - - void init(); - - tnlStaticAssert( dimensions > 0, "The mesh dimesnions must be greater than 0." ); - tnlStaticAssert( EntitiesTraits< 0 >::available, "Vertices must always be stored" ); - tnlStaticAssert( EntitiesTraits< dimensions >::available, "Cells must always be stored" ); + + bool init( const typename MeshTraits::PointArrayType& points, + const typename MeshTraits::CellSeedArrayType& cellSeeds ); + + + protected: + + tnlMeshStorageLayers< MeshConfig > entitiesStorage; + + tnlMeshConfigValidator< MeshConfig > configValidator; }; +template< typename MeshConfig > +std::ostream& operator <<( std::ostream& str, const tnlMesh< MeshConfig >& mesh ); + +#include <mesh/tnlMesh_impl.h> #endif /* TNLMESH_H_ */ diff --git a/src/mesh/tnlMeshBuilder.h b/src/mesh/tnlMeshBuilder.h new file mode 100644 index 0000000000000000000000000000000000000000..884e980781ba56c6d7bf76ca2bc2321985903c9d --- /dev/null +++ b/src/mesh/tnlMeshBuilder.h @@ -0,0 +1,122 @@ +/*************************************************************************** + tnlMeshBuilder.h - description + ------------------- + begin : Aug 18, 2015 + copyright : (C) 2015 by Tomas Oberhuber et al. + 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 TNLMESHBUILDER_H +#define TNLMESHBUILDER_H + +#include <mesh/traits/tnlMeshTraits.h> + +template< typename Mesh > +class tnlMeshBuilder +{ + //static constexpr const char *CLASS_NAME = "MeshBuilder"; + + public: + typedef Mesh MeshType; + typedef typename MeshType::MeshTraits MeshTraits; + typedef typename MeshTraits::GlobalIndexType GlobalIndexType; + typedef typename MeshTraits::LocalIndexType LocalIndexType; + typedef typename MeshTraits::PointType PointType; + typedef typename MeshTraits::CellTopology CellTopology; + typedef typename MeshTraits::CellSeedType CellSeedType; + + bool setPointsCount( const GlobalIndexType& points ) + { + tnlAssert( 0 <= points, cerr << "pointsCount = " << points ); + this->points.setSize( points ); + this->pointsSet.setSize( points ); + pointsSet.setValue( false ); + return true; + } + + bool setCellsCount( const GlobalIndexType& cellsCount ) + { + tnlAssert( 0 <= cellsCount, cerr << "cellsCount = " << cellsCount ); + this->cellSeeds.setSize( cellsCount ); + return true; + } + + GlobalIndexType getPointsCount() const { return this->points.getSize(); } + + GlobalIndexType getCellsCount() const { return this->cellSeeds.getSize(); } + + void setPoint( GlobalIndexType index, + const PointType& point ) + { + tnlAssert( 0 <= index && index < getPointsCount(), cerr << "Index = " << index ); + + this->points[ index ] = point; + this->pointsSet[ index ] = true; + } + + CellSeedType& getCellSeed( GlobalIndexType index ) + { + tnlAssert( 0 <= index && index < getCellsCount(), cerr << "Index = " << index ); + + return this->cellSeeds[ index ]; + } + + bool build( MeshType& mesh ) const + { + if( ! this->validate() ) + return false; + if( ! mesh.init( this->points, this->cellSeeds ) ) + return false; + return true; + } + + private: + typedef typename MeshTraits::PointArrayType PointArrayType; + typedef typename MeshTraits::CellSeedArrayType CellSeedArrayType; + + bool validate() const + { + if( !allPointsSet() ) + { + cerr << "Mesh builder error: Not all points were set." << endl; + return false; + } + + for( GlobalIndexType i = 0; i < getCellsCount(); i++ ) + { + auto cornerIds = this->cellSeeds[ i ].getCornerIds(); + for( LocalIndexType j = 0; j < cornerIds.getSize(); j++ ) + if( cornerIds[ j ] < 0 || getPointsCount() <= cornerIds[ j ] ) + { + cerr << "Cell seed " << i << " is referencing unavailable point " << cornerIds[ j ] << endl; + return false; + } + } + return true; + } + + + bool allPointsSet() const + { + for( GlobalIndexType i = 0; i < this->points.getSize(); i++ ) + if (! this->pointsSet[ i ] ) + return false; + return true; + } + + PointArrayType points; + CellSeedArrayType cellSeeds; + tnlArray< bool, tnlHost, GlobalIndexType > pointsSet; +}; + +#endif /* TNLMESHBUILDER_H */ + diff --git a/src/mesh/tnlMeshEntity.h b/src/mesh/tnlMeshEntity.h index 1bfeb07b300ceb4bd61436fd23af0f2590a59407..368af21d737a1a6ab480cd60c35d87a7d7795214 100644 --- a/src/mesh/tnlMeshEntity.h +++ b/src/mesh/tnlMeshEntity.h @@ -2,7 +2,7 @@ tnlMeshEntity.h - description ------------------- begin : Feb 11, 2014 - copyright : (C) 2014 by Tomas Oberhuber + copyright : (C) 2014 by Tomas Oberhuber et al. email : tomas.oberhuber@fjfi.cvut.cz ***************************************************************************/ @@ -22,445 +22,216 @@ #include <core/tnlDynamicTypeTag.h> #include <mesh/tnlMeshEntityId.h> #include <mesh/traits/tnlMeshTraits.h> -#include <mesh/traits/tnlDimensionsTraits.h> -#include <mesh/topologies/tnlMeshVertexTag.h> +#include <mesh/tnlDimensionsTag.h> +#include <mesh/topologies/tnlMeshVertexTopology.h> #include <mesh/layers/tnlMeshSubentityStorageLayer.h> #include <mesh/layers/tnlMeshSuperentityStorageLayer.h> +#include <mesh/layers/tnlMeshSuperentityAccess.h> +#include <mesh/initializer/tnlMeshEntitySeed.h> -template< typename ConfigTag, - typename EntityTag > +template< typename MeshConfig > +class tnlMeshInitializer; + +template< typename MeshConfig, + typename EntityTopology_ > class tnlMeshEntity - : public tnlMeshSubentityStorageLayers< ConfigTag, EntityTag >, - public tnlMeshSuperentityStorageLayers< ConfigTag, EntityTag >, - public tnlMeshEntityId< typename ConfigTag::IdType, - typename ConfigTag::GlobalIndexType > + : public tnlMeshSubentityStorageLayers< MeshConfig, EntityTopology_ >, + public tnlMeshSuperentityAccess< MeshConfig, EntityTopology_ >, + public tnlMeshEntityId< typename MeshConfig::IdType, + typename MeshConfig::GlobalIndexType > { public: - static tnlString getType() - { - return tnlString( "tnlMesh< " ) + - //ConfigTag::getType() + ", " + - //EntityTag::getType() + ", " + - " >"; - } - - tnlString getTypeVirtual() const - { - return this->getType(); - } - - /*~tnlMeshEntity() - { - cerr << " Destroying entity with " << EntityTag::dimensions << " dimensions..." << endl; - }*/ - - bool save( tnlFile& file ) const - { - if( ! tnlMeshSubentityStorageLayers< ConfigTag, EntityTag >::save( file ) || - ! tnlMeshSuperentityStorageLayers< ConfigTag, EntityTag >::save( file ) ) - return false; - return true; - } - - bool load( tnlFile& file ) - { - if( ! tnlMeshSubentityStorageLayers< ConfigTag, EntityTag >::load( file ) || - ! tnlMeshSuperentityStorageLayers< ConfigTag, EntityTag >::load( file ) ) - return false; - return true; - } - - void print( ostream& str ) const - { - str << "\t Mesh entity dimensions: " << EntityTag::dimensions << endl; - tnlMeshSubentityStorageLayers< ConfigTag, EntityTag >::print( str ); - tnlMeshSuperentityStorageLayers< ConfigTag, EntityTag >::print( str ); - } - - bool operator==( const tnlMeshEntity& entity ) const - { - return ( tnlMeshSubentityStorageLayers< ConfigTag, EntityTag >::operator==( entity ) && - tnlMeshSuperentityStorageLayers< ConfigTag, EntityTag >::operator==( entity ) && - tnlMeshEntityId< typename ConfigTag::IdType, - typename ConfigTag::GlobalIndexType >::operator==( entity ) ); - } - - - /**** - * Entity typedefs - */ - typedef ConfigTag MeshConfigTag; - typedef EntityTag Tag; - enum { dimensions = Tag::dimensions }; - enum { meshDimensions = tnlMeshTraits< ConfigTag >::meshDimensions }; - - /**** - * Subentities - */ - template< int Dimensions > - struct SubentitiesTraits - { - typedef tnlDimensionsTraits< Dimensions > DimensionsTraits; - typedef tnlMeshSubentitiesTraits< ConfigTag, - EntityTag, - DimensionsTraits > SubentityTraits; - typedef typename SubentityTraits::ContainerType ContainerType; - typedef typename SubentityTraits::SharedContainerType SharedContainerType; - typedef typename ContainerType::ElementType GlobalIndexType; - typedef int LocalIndexType; - - // TODO: make this as: - // typedef typename Type::IndexType LocalIndexType - enum { available = tnlMeshSubentityStorage< ConfigTag, - EntityTag, - Dimensions >::enabled }; - enum { subentitiesCount = SubentityTraits::count }; - }; - - template< int Dimensions > - bool subentitiesAvailable() const - { - return SubentitiesTraits< Dimensions >::available; - }; - - template< int Dimensions > - typename SubentitiesTraits< Dimensions >::LocalIndexType getNumberOfSubentities() const - { - return SubentitiesTraits< Dimensions >::subentitiesCount; - }; - - template< int Dimensions > - void setSubentityIndex( const typename SubentitiesTraits< Dimensions >::LocalIndexType localIndex, - const typename SubentitiesTraits< Dimensions >::GlobalIndexType globalIndex ) - { - tnlAssert( 0 <= localIndex && - localIndex < SubentitiesTraits< Dimensions >::subentitiesCount, - cerr << "localIndex = " << localIndex - << " subentitiesCount = " - << SubentitiesTraits< Dimensions >::subentitiesCount ); - typedef tnlMeshSubentityStorageLayers< ConfigTag, EntityTag > SubentityBaseType; - SubentityBaseType::setSubentityIndex( tnlDimensionsTraits< Dimensions >(), - localIndex, - globalIndex ); - } - - template< int Dimensions > - typename SubentitiesTraits< Dimensions >::GlobalIndexType - getSubentityIndex( const typename SubentitiesTraits< Dimensions >::LocalIndexType localIndex) const - { - tnlAssert( 0 <= localIndex && - localIndex < SubentitiesTraits< Dimensions >::subentitiesCount, - cerr << "localIndex = " << localIndex - << " subentitiesCount = " - << SubentitiesTraits< Dimensions >::subentitiesCount ); - typedef tnlMeshSubentityStorageLayers< ConfigTag, EntityTag > SubentityBaseType; - return SubentityBaseType::getSubentityIndex( tnlDimensionsTraits< Dimensions >(), - localIndex ); - } - - template< int Dimensions > - typename SubentitiesTraits< Dimensions >::SharedContainerType& - getSubentitiesIndices() - { - typedef tnlMeshSubentityStorageLayers< ConfigTag, EntityTag > SubentityBaseType; - return SubentityBaseType::getSubentitiesIndices( tnlDimensionsTraits< Dimensions >() ); - } - - template< int Dimensions > - const typename SubentitiesTraits< Dimensions >::SharedContainerType& - getSubentitiesIndices() const - { - typedef tnlMeshSubentityStorageLayers< ConfigTag, EntityTag > SubentityBaseType; - return SubentityBaseType::getSubentitiesIndices( tnlDimensionsTraits< Dimensions >() ); - } - - /**** - * Superentities - */ - template< int Dimensions > - struct SuperentitiesTraits - { - typedef tnlDimensionsTraits< Dimensions > DimensionsTraits; - typedef tnlMeshSuperentitiesTraits< ConfigTag, - EntityTag, - DimensionsTraits > SuperentityTraits; - typedef typename SuperentityTraits::ContainerType ContainerType; - typedef typename SuperentityTraits::SharedContainerType SharedContainerType; - typedef typename ContainerType::ElementType GlobalIndexType; - typedef int LocalIndexType; - // TODO: make this as: - // typedef typename Type::IndexType LocalIndexType - enum { available = tnlMeshSuperentityStorage< ConfigTag, - EntityTag, - Dimensions >::enabled }; - }; - - template< int Dimensions > - bool setNumberOfSuperentities( const typename SuperentitiesTraits< Dimensions >::LocalIndexType size ) - { - tnlAssert( size >= 0, - cerr << "size = " << size << endl; ); - typedef tnlMeshSuperentityStorageLayers< ConfigTag, EntityTag > SuperentityBaseType; - return SuperentityBaseType::setNumberOfSuperentities( tnlDimensionsTraits< Dimensions >(), - size ); - } - - template< int Dimensions > - typename SuperentitiesTraits< Dimensions >::LocalIndexType getNumberOfSuperentities() const - { - typedef tnlMeshSuperentityStorageLayers< ConfigTag, EntityTag > SuperentityBaseType; - return SuperentityBaseType::getNumberOfSuperentities( tnlDimensionsTraits< Dimensions >() ); - } - - template< int Dimensions > - void setSuperentityIndex( const typename SuperentitiesTraits< Dimensions >::LocalIndexType localIndex, - const typename SuperentitiesTraits< Dimensions >::GlobalIndexType globalIndex ) - { - tnlAssert( localIndex < this->getNumberOfSuperentities< Dimensions >(), - cerr << " localIndex = " << localIndex - << " this->getNumberOfSuperentities< Dimensions >() = " << this->getNumberOfSuperentities< Dimensions >() << endl; ); - typedef tnlMeshSuperentityStorageLayers< ConfigTag, EntityTag > SuperentityBaseType; - SuperentityBaseType::setSuperentityIndex( tnlDimensionsTraits< Dimensions >(), - localIndex, - globalIndex ); - } - - template< int Dimensions > - typename SuperentitiesTraits< Dimensions >::GlobalIndexType - getSuperentityIndex( const typename SuperentitiesTraits< Dimensions >::LocalIndexType localIndex ) const - { - tnlAssert( localIndex < this->getNumberOfSuperentities< Dimensions >(), - cerr << " localIndex = " << localIndex - << " this->getNumberOfSuperentities< Dimensions >() = " << this->getNumberOfSuperentities< Dimensions >() << endl; ); - typedef tnlMeshSuperentityStorageLayers< ConfigTag, EntityTag > SuperentityBaseType; - return SuperentityBaseType::getSuperentityIndex( tnlDimensionsTraits< Dimensions >(), - localIndex ); - } - - template< int Dimensions > - typename SuperentitiesTraits< Dimensions >::SharedContainerType& getSuperentitiesIndices() - { - typedef tnlMeshSuperentityStorageLayers< ConfigTag, EntityTag > SuperentityBaseType; - return SuperentityBaseType::getSuperentitiesIndices( tnlDimensionsTraits< Dimensions >() ); - } - - template< int Dimensions > - const typename SuperentitiesTraits< Dimensions >::SharedContainerType& getSuperentitiesIndices() const - { - typedef tnlMeshSuperentityStorageLayers< ConfigTag, EntityTag > SuperentityBaseType; - return SuperentityBaseType::getSubentitiesIndices( tnlDimensionsTraits< Dimensions >() ); - } - - /**** - * Vertices - */ - enum { verticesCount = SubentitiesTraits< 0 >::subentitiesCount }; - typedef typename SubentitiesTraits< 0 >::ContainerType ContainerType; - typedef typename SubentitiesTraits< 0 >::SharedContainerType SharedContainerType; - typedef typename SubentitiesTraits< 0 >::GlobalIndexType GlobalIndexType; - typedef typename SubentitiesTraits< 0 >::LocalIndexType LocalIndexType; - - LocalIndexType getNumberOfVertices() const - { - return verticesCount; - } - - void setVertexIndex( const LocalIndexType localIndex, - const GlobalIndexType globalIndex ) - { - this->setSubentityIndex< 0 >( localIndex, globalIndex ); - } - - GlobalIndexType getVertexIndex( const LocalIndexType localIndex ) const - { - return this->getSubentityIndex< 0 >( localIndex ); - } - - SharedContainerType& getVerticesIndices() - { - return this->getSubentitiesIndices< 0 >(); - } - - const SharedContainerType& getVerticesIndices() const - { - return this->getSubentitiesIndices< 0 >(); - } + typedef tnlMeshTraits< MeshConfig > MeshTraits; + typedef EntityTopology_ EntityTopology; + typedef typename MeshTraits::GlobalIndexType GlobalIndexType; + typedef typename MeshTraits::LocalIndexType LocalIndexType; + typedef typename MeshTraits::IdPermutationArrayAccessorType IdPermutationArrayAccessorType; + typedef tnlMeshEntitySeed< MeshConfig, EntityTopology > SeedType; + + template< int Subdimensions > using SubentityTraits = + typename MeshTraits::template SubentityTraits< EntityTopology, Subdimensions >; + + template< int SuperDimensions > using SuperentityTraits = + typename MeshTraits::template SuperentityTraits< EntityTopology, SuperDimensions >; + + tnlMeshEntity( const SeedType& entitySeed ); + + tnlMeshEntity(); + + ~tnlMeshEntity(); + + static tnlString getType(); + + tnlString getTypeVirtual() const; + + bool save( tnlFile& file ) const; + + bool load( tnlFile& file ); + + void print( ostream& str ) const; + + bool operator==( const tnlMeshEntity& entity ) const; + + constexpr int getEntityDimensions() const; + + /**** + * Subentities + */ + template< int Subdimensions > + constexpr bool subentitiesAvailable() const; + + template< int Subdimensions > + constexpr LocalIndexType getNumberOfSubentities() const; + + template< int Subdimensions > + GlobalIndexType getSubentityIndex( const LocalIndexType localIndex) const; + + template< int Subdimensions > + typename SubentityTraits< Subdimensions >::AccessArrayType& getSubentitiesIndices(); + + template< int Subdimensions > + const typename SubentityTraits< Subdimensions >::AccessArrayType& getSubentitiesIndices() const; + + /**** + * Superentities + */ + template< int SuperDimensions > + LocalIndexType getNumberOfSuperentities() const; + + template< int SuperDimensions > + GlobalIndexType getSuperentityIndex( const LocalIndexType localIndex ) const; + + template< int SuperDimensions > + typename SuperentityTraits< SuperDimensions >::AccessArrayType& getSuperentitiesIndices(); + + template< int SuperDimensions > + const typename SuperentityTraits< SuperDimensions >::AccessArrayType& getSuperentitiesIndices() const; + + /**** + * Vertices + */ + constexpr LocalIndexType getNumberOfVertices() const; + + GlobalIndexType getVertexIndex( const LocalIndexType localIndex ) const; + + typename SubentityTraits< 0 >::AccessArrayType& getVerticesIndices(); + + const typename SubentityTraits< 0 >::AccessArrayType& getVerticesIndices() const; + + template< int Dimensions > + IdPermutationArrayAccessorType subentityOrientation( LocalIndexType index ) const; + + protected: + + /**** + * Methods for the mesh initialization + */ + typedef tnlMeshSuperentityAccess< MeshConfig, EntityTopology > SuperentityAccessBase; + typedef typename MeshTraits::IdArrayAccessorType IdArrayAccessorType; + typedef tnlMeshSubentityStorageLayers< MeshConfig, EntityTopology > SubentityStorageLayers; + + template< int Subdimensions > + void setSubentityIndex( const LocalIndexType localIndex, + const GlobalIndexType globalIndex ); + + template< int Subdimensions > + typename SubentityTraits< Subdimensions >::IdArrayType& subentityIdsArray(); + + template< int Superdimensions > + IdArrayAccessorType& superentityIdsArray(); + + template< int Subdimensions > + typename SubentityTraits< Subdimensions >::OrientationArrayType& subentityOrientationsArray(); + + friend tnlMeshInitializer< MeshConfig >; + }; -template< typename ConfigTag > -class tnlMeshEntity< ConfigTag, tnlMeshVertexTag > - : public tnlMeshSuperentityStorageLayers< ConfigTag, tnlMeshVertexTag >, - public tnlMeshEntityId< typename ConfigTag::IdType, - typename ConfigTag::GlobalIndexType > +/**** + * Vertex entity specialization + */ +template< typename MeshConfig > +class tnlMeshEntity< MeshConfig, tnlMeshVertexTopology > + : public tnlMeshSuperentityAccess< MeshConfig, tnlMeshVertexTopology >, + public tnlMeshEntityId< typename MeshConfig::IdType, + typename MeshConfig::GlobalIndexType > { public: - static tnlString getType() - { - return tnlString( "tnlMesh< " ) + - //ConfigTag::getType() + ", " + - //EntityTag::getType() + ", " + - " >"; - } - - tnlString getTypeVirtual() const - { - return this->getType(); - } - - /**** - * The entity typedefs - */ - typedef ConfigTag MeshConfigTag; - typedef tnlMeshVertexTag Tag; - typedef typename tnlMeshTraits< ConfigTag >::PointType PointType; - enum { dimensions = Tag::dimensions }; - enum { meshDimensions = tnlMeshTraits< ConfigTag >::meshDimensions }; - - /*~tnlMeshEntity() - { - cerr << " Destroying entity with " << tnlMeshVertexTag::dimensions << " dimensions..." << endl; - }*/ - - bool save( tnlFile& file ) const - { - if( ! tnlMeshSuperentityStorageLayers< ConfigTag, tnlMeshVertexTag >::save( file ) || - ! point.save( file ) ) - return false; - return true; - } - - bool load( tnlFile& file ) - { - if( ! tnlMeshSuperentityStorageLayers< ConfigTag, tnlMeshVertexTag >::load( file ) || - ! point.load( file ) ) - return false; - return true; - } - - void print( ostream& str ) const - { - str << "\t Mesh entity dimensions: " << tnlMeshVertexTag::dimensions << endl; - str << "\t Coordinates = ( " << point << " )"; - tnlMeshSuperentityStorageLayers< ConfigTag, tnlMeshVertexTag >::print( str ); - } - - bool operator==( const tnlMeshEntity& entity ) const - { - return ( tnlMeshSuperentityStorageLayers< ConfigTag, tnlMeshVertexTag >::operator==( entity ) && - tnlMeshEntityId< typename ConfigTag::IdType, - typename ConfigTag::GlobalIndexType >::operator==( entity ) && - point == entity.point ); - - } - - /**** - * Superentities - */ - template< int Dimensions > - struct SuperentitiesTraits - { - typedef tnlDimensionsTraits< Dimensions > DimensionsTraits; - typedef tnlMeshSuperentitiesTraits< ConfigTag, - tnlMeshVertexTag, - DimensionsTraits > SuperentityTraits; - typedef typename SuperentityTraits::ContainerType ContainerType; - typedef typename SuperentityTraits::SharedContainerType SharedContainerType; - typedef typename ContainerType::ElementType GlobalIndexType; - typedef int LocalIndexType; - // TODO: make this as: - // typedef typename Type::IndexType LocalIndexType - enum { available = tnlMeshSuperentityStorage< ConfigTag, - tnlMeshVertexTag, - Dimensions >::enabled }; - }; - template< int Dimensions > - bool setNumberOfSuperentities( const typename SuperentitiesTraits< Dimensions >::LocalIndexType size ) - { - tnlAssert( size >= 0, - cerr << "size = " << size << endl; ); - typedef tnlMeshSuperentityStorageLayers< ConfigTag, tnlMeshVertexTag > SuperentityBaseType; - return SuperentityBaseType::setNumberOfSuperentities( tnlDimensionsTraits< Dimensions >(), - size ); - } - - template< int Dimensions > - typename SuperentitiesTraits< Dimensions >::LocalIndexType getNumberOfSuperentities() const - { - typedef tnlMeshSuperentityStorageLayers< ConfigTag, tnlMeshVertexTag > SuperentityBaseType; - return SuperentityBaseType::getNumberOfSuperentities( tnlDimensionsTraits< Dimensions >() ); - } - - template< int Dimensions > - typename SuperentitiesTraits< Dimensions >::SharedContainerType& getSuperentitiesIndices() - { - typedef tnlMeshSuperentityStorageLayers< ConfigTag, tnlMeshVertexTag > SuperentityBaseType; - return SuperentityBaseType::getSuperentitiesIndices( tnlDimensionsTraits< Dimensions >() ); - } - - template< int Dimensions > - const typename SuperentitiesTraits< Dimensions >::SharedContainerType& getSuperentitiesIndeces() const - { - typedef tnlMeshSuperentityStorageLayers< ConfigTag, tnlMeshVertexTag > SuperentityBaseType; - return SuperentityBaseType::getSubentitiesIndices( tnlDimensionsTraits< Dimensions >() ); - } - - template< int Dimensions > - void setSuperentityIndex( const typename SuperentitiesTraits< Dimensions >::LocalIndexType localIndex, - const typename SuperentitiesTraits< Dimensions >::GlobalIndexType globalIndex ) - { - tnlAssert( localIndex < this->getNumberOfSuperentities< Dimensions >(), - cerr << " localIndex = " << localIndex - << " this->getNumberOfSuperentities< Dimensions >() = " << this->getNumberOfSuperentities< Dimensions >() << endl; ); - typedef tnlMeshSuperentityStorageLayers< ConfigTag, tnlMeshVertexTag > SuperentityBaseType; - SuperentityBaseType::setSuperentityIndex( tnlDimensionsTraits< Dimensions >(), - localIndex, - globalIndex ); - } - - template< int Dimensions > - typename SuperentitiesTraits< Dimensions >::GlobalIndexType - getSuperentityIndex( const typename SuperentitiesTraits< Dimensions >::LocalIndexType localIndex ) const - { - tnlAssert( localIndex < this->getNumberOfSuperentities< Dimensions >(), - cerr << " localIndex = " << localIndex - << " this->getNumberOfSuperentities< Dimensions >() = " << this->getNumberOfSuperentities< Dimensions >() << endl; ); - typedef tnlMeshSuperentityStorageLayers< ConfigTag, tnlMeshVertexTag > SuperentityBaseType; - return SuperentityBaseType::getSuperentityIndex( tnlDimensionsTraits< Dimensions >(), - localIndex ); - } - - /**** - * Points - */ - PointType getPoint() const { return this->point; } - - void setPoint( const PointType& point ) { this->point = point; } + typedef tnlMeshTraits< MeshConfig > MeshTraits; + typedef tnlMeshVertexTopology EntityTopology; + typedef typename MeshTraits::GlobalIndexType GlobalIndexType; + typedef typename MeshTraits::LocalIndexType LocalIndexType; + typedef typename MeshTraits::PointType PointType; + typedef typename MeshTraits::IdPermutationArrayAccessorType IdPermutationArrayAccessorType; + typedef tnlMeshEntitySeed< MeshConfig, EntityTopology > SeedType; + + template< int SuperDimensions > using SuperentityTraits = + typename MeshTraits::template SuperentityTraits< EntityTopology, SuperDimensions >; - protected: + static tnlString getType(); + + tnlString getTypeVirtual() const; + + ~tnlMeshEntity(); + + bool save( tnlFile& file ) const; + + bool load( tnlFile& file ); - PointType point; + void print( ostream& str ) const; + + bool operator==( const tnlMeshEntity& entity ) const; + + constexpr int getEntityDimensions() const; + + template< int Superdimensions > LocalIndexType getNumberOfSuperentities() const; + + template< int Superdimensions > + typename SuperentityTraits< Superdimensions >::AccessArrayType& getSuperentitiesIndices(); + + template< int Superdimensions > + const typename SuperentityTraits< Superdimensions >::AccessArrayType& getSuperentitiesIndeces() const; + + template< int Dimensions > + GlobalIndexType getSuperentityIndex( const LocalIndexType localIndex ) const; + + /**** + * Points + */ + PointType getPoint() const; + + void setPoint( const PointType& point ); + + protected: + + typedef typename MeshTraits::IdArrayAccessorType IdArrayAccessorType; + typedef tnlMeshSuperentityAccess< MeshConfig, tnlMeshVertexTopology > SuperentityAccessBase; + + template< int Superdimensions > + IdArrayAccessorType& superentityIdsArray(); + + PointType point; + + friend tnlMeshInitializer< MeshConfig >; }; -template< typename ConfigTag, - typename EntityTag > -ostream& operator <<( ostream& str, const tnlMeshEntity< ConfigTag, EntityTag >& entity ) -{ - entity.print( str ); - return str; -} +template< typename MeshConfig, + typename EntityTopology > +ostream& operator <<( ostream& str, const tnlMeshEntity< MeshConfig, EntityTopology >& entity ); /**** * This tells the compiler that theMeshEntity is a type with a dynamic memory allocation. - * It is necessary for the loading and the saving of the mesh enities arrays. + * It is necessary for the loading and the saving of the mesh entities arrays. */ -template< typename ConfigTag, - typename EntityTag > -struct tnlDynamicTypeTag< tnlMeshEntity< ConfigTag, EntityTag > > +template< typename MeshConfig, + typename EntityTopology > +struct tnlDynamicTypeTag< tnlMeshEntity< MeshConfig, EntityTopology > > { enum { value = true }; }; +#include <mesh/tnlMeshEntity_impl.h> #endif /* TNLMESHENTITY_H_ */ diff --git a/src/mesh/tnlMeshEntityInitializer.h b/src/mesh/tnlMeshEntityInitializer.h deleted file mode 100644 index 9647efd67c662d8661b2e14c325ed421e5e44c17..0000000000000000000000000000000000000000 --- a/src/mesh/tnlMeshEntityInitializer.h +++ /dev/null @@ -1,539 +0,0 @@ -/*************************************************************************** - tnlMeshEntityInitializer.h - description - ------------------- - begin : Feb 23, 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 TNLMESHENTITYINITIALIZER_H_ -#define TNLMESHENTITYINITIALIZER_H_ - -#include <core/tnlStaticFor.h> -#include <mesh/tnlMeshSuperentityInitializerLayer.h> - -template< typename ConfigTag > -class tnlMeshInitializer; - -template<typename ConfigTag, - typename EntityTag, - typename DimensionsTraits, - typename SubentityStorageTag = typename tnlMeshSubentitiesTraits< ConfigTag, - EntityTag, - DimensionsTraits >::SubentityStorageTag, - typename SuperentityStorageTag = typename tnlMeshSuperentitiesTraits< ConfigTag, - typename tnlMeshSubentitiesTraits< ConfigTag, - EntityTag, - DimensionsTraits >::SubentityTag, - tnlDimensionsTraits< EntityTag::dimensions > >::SuperentityStorageTag > -class tnlMeshEntityInitializerLayer; - -template< typename ConfigTag, - typename EntityTag > -class tnlMeshEntityInitializer - : public tnlMeshEntityInitializerLayer< ConfigTag, - EntityTag, - tnlDimensionsTraits< EntityTag::dimensions - 1 > >, - public tnlMeshSuperentityInitializerLayer< ConfigTag, - EntityTag, - typename tnlMeshTraits< ConfigTag >::DimensionsTraits > -{ - typedef tnlDimensionsTraits< EntityTag::dimensions > DimensionsTraits; - private: - - typedef - tnlMeshEntityInitializerLayer< ConfigTag, - EntityTag, - tnlDimensionsTraits< EntityTag::dimensions - 1 > > SubentityBaseType; - typedef - tnlMeshSuperentityInitializerLayer< ConfigTag, - EntityTag, - typename - tnlMeshTraits< ConfigTag >::DimensionsTraits > SuperentityBaseType; - - typedef typename tnlMeshEntitiesTraits< ConfigTag, DimensionsTraits >::Type EntityType; - typedef typename tnlMeshEntitiesTraits< ConfigTag, - DimensionsTraits >::ContainerType::IndexType GlobalIndexType; - - typedef tnlMeshSubentitiesTraits< ConfigTag, EntityTag, tnlDimensionsTraits< 0 > > SubvertexTag; - typedef typename SubvertexTag::ContainerType::ElementType VertexGlobalIndexType; - typedef typename SubvertexTag::ContainerType::IndexType VertexLocalIndexType; - - typedef tnlMeshInitializer< ConfigTag > InitializerType; - - template< typename > class SubentitiesCreator; - - public: - - //using SuperentityBaseType::setNumberOfSuperentities; - - static tnlString getType() {}; - - tnlMeshEntityInitializer() : entity(0), entityIndex( -1 ) {} - - void init( EntityType& entity, GlobalIndexType entityIndex ) - { - this->entity = &entity; - this->entityIndex = entityIndex; - } - - void initEntity( InitializerType &meshInitializer ) - { - tnlAssert( this->entity, ); - - this->entity->setId( entityIndex ); - - initSuperentities(); - initSubentities( meshInitializer ); - //cout << " Entity initiation done ... " << endl; - } - - template< typename SubentityDimensionsTag > - void createSubentities( typename tnlMeshSubentitiesTraits< ConfigTag, - EntityTag, - SubentityDimensionsTag >::SubentityContainerType& subentities ) const - { - SubentitiesCreator< SubentityDimensionsTag >::createSubentities( subentities, *entity ); - } - - GlobalIndexType getEntityIndex() const - { - tnlAssert( entityIndex >= 0, - cerr << "entityIndex = " << entityIndex ); - return this->entityIndex; - } - - template< typename SubentityDimensionTag > - typename tnlMeshSubentitiesTraits< ConfigTag, EntityTag, SubentityDimensionTag >::SharedContainerType& subentityContainer( SubentityDimensionTag ) - { - return this->entity->template getSubentitiesIndices< SubentityDimensionTag::value >(); - } - - template< typename SuperentityDimensionTag > - bool setNumberOfSuperentities( SuperentityDimensionTag, typename tnlMeshSuperentitiesTraits< ConfigTag, EntityTag, SuperentityDimensionTag >::ContainerType::IndexType size ) - { - return this->entity->template setNumberOfSuperentities< SuperentityDimensionTag::value >( size ); - } - - // TODO: check if we need the following two methods - /*template< typename SuperentityDimensionTag > - bool getSuperentityContainer( SuperentityDimensionTag, typename tnlMeshSuperentitiesTraits< ConfigTag, EntityTag, SuperentityDimensionTag >::ContainerType::IndexType size ) - { - return this->entity->template setNumberOfSuperentities< SuperentityDimensionTag::value >( size ); - }*/ - - template< typename SuperentityDimensionTag > - typename tnlMeshSuperentitiesTraits< ConfigTag, EntityTag, SuperentityDimensionTag >::SharedContainerType& getSuperentityContainer( SuperentityDimensionTag ) - { - return this->entity->template getSuperentitiesIndices< SuperentityDimensionTag::value >(); - } - - static void setEntityVertex( EntityType& entity, - VertexLocalIndexType localIndex, - VertexGlobalIndexType globalIndex ) - { - entity.setVertexIndex( localIndex, globalIndex ); - } - - private: - EntityType *entity; - GlobalIndexType entityIndex; - - void initSubentities( InitializerType& meshInitializer ) - { - //cout << " Initiating subentities of entity ... " << endl; - SubentityBaseType::initSubentities( *this, meshInitializer ); - } - - void initSuperentities() - { - //cout << " Initiating superentities..." << endl; - SuperentityBaseType::initSuperentities( *this) ; - } - - template< typename SubentityDimensionTag > - class SubentitiesCreator - { - typedef tnlMeshSubentitiesTraits< ConfigTag, EntityTag, SubentityDimensionTag > Tag; - typedef typename Tag::SubentityTag SubentityTag; - typedef typename Tag::SubentityType SubentityType; - typedef typename Tag::ContainerType::IndexType LocalIndexType; - - typedef typename - tnlMeshSubentitiesTraits< ConfigTag, - EntityTag, - SubentityDimensionTag >::SharedContainerType SubentitiesIndicesContainerType; - - typedef typename tnlMeshSubentitiesTraits< ConfigTag, - EntityTag, - SubentityDimensionTag>::SubentityContainerType - SubentityContainerType; - - enum { subentitiesCount = Tag::count }; - enum { subentityVerticesCount = tnlMeshSubentitiesTraits< ConfigTag, - SubentityTag, - tnlDimensionsTraits< 0 > >::count }; - - public: - static void createSubentities( SubentityContainerType& subentities, - const EntityType &entity ) - { - const SubentitiesIndicesContainerType& subvertexIndices = entity.template getSubentitiesIndices< 0 >(); - //cout << " entity = " << entity << endl; - //cout << " subvertexIndices = " << subvertexIndices << endl; - tnlStaticFor< LocalIndexType, 0, subentitiesCount, CreateSubentities >::exec( subentities, subvertexIndices ); - } - - private: - template< LocalIndexType subentityIndex > - class CreateSubentities - { - public: - static void exec( SubentityContainerType &subentities, - const SubentitiesIndicesContainerType& subvertexIndices ) - { - SubentityType &subentity = subentities[ subentityIndex ]; - tnlStaticFor< LocalIndexType, 0, subentityVerticesCount, SetSubentityVertex >::exec( subentity, subvertexIndices ); - } - - private: - template< LocalIndexType subentityVertexIndex > - class SetSubentityVertex - { - public: - static bool exec( SubentityType &subentity, - const SubentitiesIndicesContainerType& subvertexIndices ) - { - LocalIndexType vertexIndex = Tag::template Vertex< subentityIndex, subentityVertexIndex >::index; - //cout << " Setting subentity " << subentityIndex << " vertex " << subentityVertexIndex << " to " << subvertexIndices[ vertexIndex ] << endl; - tnlMeshEntityInitializer< ConfigTag, SubentityTag >::setEntityVertex( subentity, subentityVertexIndex, subvertexIndices[ vertexIndex ] ); - return true; - } - }; - }; - }; -}; - -template< typename ConfigTag > -class tnlMeshEntityInitializer< ConfigTag, tnlMeshVertexTag > - : public tnlMeshSuperentityInitializerLayer< ConfigTag, - tnlMeshVertexTag, - typename tnlMeshTraits< ConfigTag >::DimensionsTraits > -{ - typedef tnlDimensionsTraits< 0 > DimensionsTraits; - - typedef tnlMeshSuperentityInitializerLayer< ConfigTag, - tnlMeshVertexTag, - typename tnlMeshTraits< ConfigTag >::DimensionsTraits > SuperentityBaseType; - - typedef typename tnlMeshEntitiesTraits< ConfigTag, DimensionsTraits >::Type EntityType; - typedef typename tnlMeshEntitiesTraits< ConfigTag, DimensionsTraits >::ContainerType::IndexType GlobalIndexType; - - typedef tnlMeshInitializer< ConfigTag > InitializerType; - - public: - - tnlMeshEntityInitializer() : entity(0), entityIndex(-1) {} - - static tnlString getType() {}; - - void init( EntityType& entity, GlobalIndexType entityIndex ) - { - this->entity = &entity; - this->entityIndex = entityIndex; - } - - void initEntity(InitializerType &meshInitializer) - { - this->entity->setId( this->entityIndex ); - initSuperentities(); - //cout << "Vertex initiation done ... " << endl; - } - - template< typename SuperentityDimensionsTag > - bool setNumberOfSuperentities( SuperentityDimensionsTag, - const typename EntityType::template SuperentitiesTraits< SuperentityDimensionsTag::value >::ContainerType::IndexType size ) - { - return this->entity->template setNumberOfSuperentities< SuperentityDimensionsTag::value >( size ); - } - - template< typename SuperentityDimensionsTag > - typename tnlMeshSuperentitiesTraits< ConfigTag, - tnlMeshVertexTag, - SuperentityDimensionsTag >::SharedContainerType& - getSuperentityContainer( SuperentityDimensionsTag ) - { - return this->entity->template getSuperentitiesIndices< SuperentityDimensionsTag::value >(); - } - - private: - - EntityType *entity; - GlobalIndexType entityIndex; - - void initSuperentities() - { - //cout << " Initiating superentities of vertex ..." << endl; - SuperentityBaseType::initSuperentities(*this); - } -}; - -/**** - * Mesh entity initializer layer - */ - -template< typename ConfigTag, - typename EntityTag, - typename DimensionsTag > -class tnlMeshEntityInitializerLayer< ConfigTag, - EntityTag, - DimensionsTag, - tnlStorageTraits< true >, - tnlStorageTraits< true > > - : public tnlMeshEntityInitializerLayer< ConfigTag, - EntityTag, - typename DimensionsTag::Previous > -{ - typedef tnlMeshEntityInitializerLayer< ConfigTag, - EntityTag, - typename DimensionsTag::Previous > BaseType; - - typedef tnlMeshSubentitiesTraits< ConfigTag, EntityTag, DimensionsTag > SubentitiesTraits; - typedef typename SubentitiesTraits::SubentityContainerType SubentityContainerType; - typedef typename SubentitiesTraits::SharedContainerType SharedContainerType; - typedef typename SharedContainerType::ElementType GlobalIndexType; - - typedef tnlMeshInitializer< ConfigTag > InitializerType; - typedef tnlMeshEntityInitializer< ConfigTag, EntityTag > EntityInitializerType; - typedef tnlDimensionsTraits< EntityTag::dimensions > EntityDimensionsTraits; - - protected: - void initSubentities( EntityInitializerType& entityInitializer, - InitializerType& meshInitializer ) - { - SubentityContainerType subentities; - //cout << " Initiating subentities with " << DimensionsTag::value << " dimensions..." << endl; - entityInitializer.template createSubentities< DimensionsTag >( subentities ); - SharedContainerType& subentityContainer = entityInitializer.subentityContainer( DimensionsTag() ); - //cout << " Subentities = " << subentities << endl; - for( typename SubentityContainerType::IndexType i = 0; - i < subentities.getSize(); - i++ ) - { - GlobalIndexType subentityIndex = meshInitializer.findEntityIndex( subentities[ i ] ); - GlobalIndexType superentityIndex = entityInitializer.getEntityIndex(); - subentityContainer[ i ] = subentityIndex; - //cout << " Setting " << i << "-th subentity to " << subentityContainer[ i ] << endl; - meshInitializer.getEntityInitializer( DimensionsTag(), subentityIndex ).addSuperentity( EntityDimensionsTraits(), superentityIndex ); - } - - BaseType::initSubentities( entityInitializer, meshInitializer ); - } -}; - -template< typename ConfigTag, - typename EntityTag, - typename DimensionsTag > -class tnlMeshEntityInitializerLayer< ConfigTag, - EntityTag, - DimensionsTag, - tnlStorageTraits< true >, - tnlStorageTraits< false > > - : public tnlMeshEntityInitializerLayer< ConfigTag, - EntityTag, - typename DimensionsTag::Previous > -{ - typedef tnlMeshEntityInitializerLayer< ConfigTag, - EntityTag, - typename DimensionsTag::Previous > BaseType; - - typedef typename tnlMeshSubentitiesTraits< ConfigTag, - EntityTag, - DimensionsTag >::SubentityContainerType SubentityContainerType; - typedef typename tnlMeshSubentitiesTraits< ConfigTag, - EntityTag, - DimensionsTag >::SharedContainerType SharedContainerType; - - typedef tnlMeshInitializer< ConfigTag > InitializerType; - typedef tnlMeshEntityInitializer< ConfigTag, EntityTag > EntityInitializerType; - - protected: - void initSubentities( EntityInitializerType& entityInitializer, - InitializerType& meshInitializer ) - { - SubentityContainerType subentities; - //cout << " Initiating subentities with " << DimensionsTag::value << " dimensions..." << endl; - entityInitializer.template createSubentities< DimensionsTag >( subentities ); - SharedContainerType& subentityContainer = entityInitializer.subentityContainer( DimensionsTag() ); - for( typename SubentityContainerType::IndexType i = 0; - i < subentityContainer.getSize(); - i++ ) - { - subentityContainer[ i ] = meshInitializer.findEntityIndex( subentities[ i ] ); - //cout << " Setting " << i << "-th subentity to " << subentityContainer[ i ] << endl; - } - - BaseType::initSubentities( entityInitializer, meshInitializer ); - } -}; - -template< typename ConfigTag, - typename EntityTag, - typename DimensionsTag > -class tnlMeshEntityInitializerLayer< ConfigTag, - EntityTag, - DimensionsTag, - tnlStorageTraits< false >, - tnlStorageTraits< true > > - : public tnlMeshEntityInitializerLayer< ConfigTag, - EntityTag, - typename DimensionsTag::Previous > -{ - typedef tnlMeshEntityInitializerLayer< ConfigTag, - EntityTag, - typename DimensionsTag::Previous > BaseType; - - typedef typename tnlMeshSubentitiesTraits< ConfigTag, - EntityTag, - DimensionsTag >::SubentityContainerType SubentityContainerType; - typedef typename tnlMeshSubentitiesTraits< ConfigTag, - EntityTag, - DimensionsTag >::SharedContainerType SharedContainerType; - typedef typename SharedContainerType::DataType GlobalIndexType; - - typedef tnlMeshInitializer< ConfigTag > InitializerType; - typedef tnlMeshEntityInitializer< ConfigTag, EntityTag > EntityInitializerType; - typedef tnlDimensionsTraits< EntityTag::dimensions > EntityDimensionsTag; - - protected: - void initSubentities( EntityInitializerType& entityInitializer, - InitializerType& meshInitializer ) - { - SubentityContainerType subentities; - //cout << " Initiating subentities with " << DimensionsTag::value << " dimensions..." << endl; - entityInitializer.template createSubentities< DimensionsTag >( subentities ); - - for( typename SubentityContainerType::IndexType i = 0; - i < subentities.getSize(); - i++ ) - { - GlobalIndexType subentityIndex = meshInitializer.findEntityIndex( subentities[ i ] ); - GlobalIndexType superentityIndex = entityInitializer.getEntityIndex(); - //cout << " NOT setting " << i << "-th subentity to " << subentityIndex << endl; - meshInitializer.getEntityInitializer( DimensionsTag(), subentityIndex ).addSuperentity( EntityDimensionsTag(), superentityIndex ); - } - BaseType::initSubentities( entityInitializer, meshInitializer ); - } -}; - -template< typename ConfigTag, - typename EntityTag, - typename DimensionsTag > -class tnlMeshEntityInitializerLayer< ConfigTag, - EntityTag, - DimensionsTag, - tnlStorageTraits< false >, - tnlStorageTraits< false > > - : public tnlMeshEntityInitializerLayer< ConfigTag, - EntityTag, - typename DimensionsTag::Previous > -{}; - -template< typename ConfigTag, - typename EntityTag > -class tnlMeshEntityInitializerLayer< ConfigTag, - EntityTag, - tnlDimensionsTraits< 0 >, - tnlStorageTraits< true >, - tnlStorageTraits< true > > -{ - typedef tnlDimensionsTraits< 0 > DimensionsTag; - typedef tnlMeshSubentitiesTraits< ConfigTag, - EntityTag, - DimensionsTag > SubentitiesTraits; - - typedef typename SubentitiesTraits::SharedContainerType SharedContainerType; - typedef typename SharedContainerType::ElementType GlobalIndexType; - - typedef tnlMeshInitializer< ConfigTag > InitializerType; - typedef tnlMeshEntityInitializer< ConfigTag, EntityTag > EntityInitializerType; - typedef tnlDimensionsTraits< EntityTag::dimensions > EntityDimensionsTag; - - protected: - void initSubentities( EntityInitializerType &entityInitializer, - InitializerType &meshInitializer ) - { - //cout << " Initiating subentities with " << DimensionsTag::value << " dimensions..." << endl; - const SharedContainerType &subentityContainer = entityInitializer.subentityContainer( DimensionsTag() ); - for (typename SharedContainerType::IndexType i = 0; i < subentityContainer.getSize(); i++) - { - GlobalIndexType subentityIndex = subentityContainer[ i ]; - //cout << " Setting " << i << "-th subentity to " << subentityContainer[ i ] << endl; - tnlAssert( subentityIndex >= 0, - cerr << " subentityContainer = " << subentityContainer << endl; ); - GlobalIndexType superentityIndex = entityInitializer.getEntityIndex(); - tnlAssert( superentityIndex >= 0, ); - meshInitializer.getEntityInitializer( DimensionsTag(), subentityIndex).addSuperentity( EntityDimensionsTag(), superentityIndex ); - } - } -}; - -template< typename ConfigTag, - typename EntityTag > -class tnlMeshEntityInitializerLayer< ConfigTag, - EntityTag, - tnlDimensionsTraits< 0 >, - tnlStorageTraits< true >, - tnlStorageTraits< false > > -{ - typedef tnlMeshInitializer< ConfigTag > InitializerType; - typedef tnlMeshEntityInitializer< ConfigTag, - EntityTag > EntityInitializerType; - - protected: - - void initSubentities( EntityInitializerType&, InitializerType& ) {} -}; - -template< typename ConfigTag, - typename EntityTag > -class tnlMeshEntityInitializerLayer< ConfigTag, - EntityTag, - tnlDimensionsTraits< 0 >, - tnlStorageTraits< false >, - tnlStorageTraits< true > > // Forces termination of recursive inheritance (prevents compiler from generating huge error logs) -{ - typedef tnlMeshInitializer< ConfigTag > InitializerType; - typedef tnlMeshEntityInitializer< ConfigTag, EntityTag > EntityInitializerType; - - protected: - void initSubentities( EntityInitializerType&, InitializerType& ) {} -}; - -template< typename ConfigTag, - typename EntityTag > -class tnlMeshEntityInitializerLayer< ConfigTag, - EntityTag, - tnlDimensionsTraits< 0 >, - tnlStorageTraits< false >, - tnlStorageTraits< false > > // Forces termination of recursive inheritance (prevents compiler from generating huge error logs) -{ - typedef tnlMeshInitializer< ConfigTag > InitializerType; - typedef tnlMeshEntityInitializer< ConfigTag, EntityTag > EntityInitializerType; - - protected: - void initSubentities( EntityInitializerType&, - InitializerType& ) {} -}; - - -#endif /* TNLMESHENTITYINITIALIZER_H_ */ diff --git a/src/functors/tnlFunctionType.h b/src/mesh/tnlMeshEntityIntegrityChecker.h similarity index 66% rename from src/functors/tnlFunctionType.h rename to src/mesh/tnlMeshEntityIntegrityChecker.h index 33149ab8885fb1371bcbd33dc5158acd8c1dff80..028e140f8b17cbd540d3c946ee2ac6b35104abc0 100644 --- a/src/functors/tnlFunctionType.h +++ b/src/mesh/tnlMeshEntityIntegrityChecker.h @@ -1,8 +1,8 @@ /*************************************************************************** - tnlFunctionType.h - description + tnlMeshEntityIntegrityChecker.h - description ------------------- - begin : Jan 10, 2015 - copyright : (C) 2015 by oberhuber + begin : Mar 20, 2014 + copyright : (C) 2014 by Tomas Oberhuber email : tomas.oberhuber@fjfi.cvut.cz ***************************************************************************/ @@ -15,17 +15,20 @@ * * ***************************************************************************/ -#ifndef TNLFUNCTIONTYPE_H_ -#define TNLFUNCTIONTYPE_H_ +#ifndef TNLMESHENTITYINTEGRITYCHECKER_H_ +#define TNLMESHENTITYINTEGRITYCHECKER_H_ -enum tnlFunctionTypeEnum { tnlGeneralFunction, tnlDiscreteFunction, tnlAnalyticFunction }; - -template< typename Function > -class tnlFunctionType +template< typename MeshEntity > +class tnlMeshEntityIntegrityChecker { public: - enum { Type = tnlGeneralFunction }; + static bool checkEntity( const MeshEntity& entity ) + { + return true; + } + }; -#endif /* TNLFUNCTIONTYPE_H_ */ + +#endif /* TNLMESHENTITYINTEGRITYCHECKER_H_ */ diff --git a/src/mesh/traits/tnlStorageTraits.h b/src/mesh/tnlMeshEntityIntegrityCheckerLayer.h similarity index 75% rename from src/mesh/traits/tnlStorageTraits.h rename to src/mesh/tnlMeshEntityIntegrityCheckerLayer.h index b316a89fe6b8284746bf3f8f876822317b289bf3..0b221403a8cb8150edfe2032bc7a4a88688afde4 100644 --- a/src/mesh/traits/tnlStorageTraits.h +++ b/src/mesh/tnlMeshEntityIntegrityCheckerLayer.h @@ -1,7 +1,7 @@ /*************************************************************************** - tnlStorageTraits.h - description + tnlMeshEntityIntegrityCheckerLayer.h - description ------------------- - begin : Feb 11, 2014 + begin : Mar 23, 2014 copyright : (C) 2014 by Tomas Oberhuber email : tomas.oberhuber@fjfi.cvut.cz ***************************************************************************/ @@ -15,16 +15,10 @@ * * ***************************************************************************/ -#ifndef TNLSTORAGETRAITS_H_ -#define TNLSTORAGETRAITS_H_ +#ifndef TNLMESHENTITYINTEGRITYCHECKERLAYER_H_ +#define TNLMESHENTITYINTEGRITYCHECKERLAYER_H_ -template< bool storageEnabled > -class tnlStorageTraits -{ - public: - enum { enabled = storageEnabled }; -}; -#endif /* TNLSTORAGETRAITS_H_ */ +#endif /* TNLMESHENTITYINTEGRITYCHECKERLAYER_H_ */ diff --git a/src/mesh/tnlMeshEntityKey.h b/src/mesh/tnlMeshEntityKey.h deleted file mode 100644 index 0937caaa98a16a9d92ccc1e1dc4e4e5d30f9b658..0000000000000000000000000000000000000000 --- a/src/mesh/tnlMeshEntityKey.h +++ /dev/null @@ -1,73 +0,0 @@ -/*************************************************************************** - tnlMeshEntityKey.h - description - ------------------- - begin : Feb 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 TNLMESHENTITYKEY_H_ -#define TNLMESHENTITYKEY_H_ - -#include <mesh/tnlMeshEntity.h> -#include <mesh/traits/tnlMeshSubentitiesTraits.h> -#include <mesh/traits/tnlDimensionsTraits.h> - -/**** - * Unique identification of a mesh entity by its vertices. - * Uniqueness is preserved for entities of the same type only. - */ -template< typename ConfigTag, - typename EntityTag > -class tnlMeshEntityKey -{ - typedef - tnlMeshEntity< ConfigTag, EntityTag > EntityType; - - typedef typename - tnlMeshSubentitiesTraits< ConfigTag, - EntityTag, - tnlDimensionsTraits< 0 > >::ContainerType ContainerType; - - public: - - explicit tnlMeshEntityKey( const EntityType& entity ) - { - for( typename ContainerType::IndexType i = 0; - i < ContainerType::size; - i++ ) - vertexIDs[ i ] = entity.template getSubentityIndex<0>( i ); - vertexIDs.sort( ); - } - - bool operator<( const tnlMeshEntityKey& other ) const - { - for( typename ContainerType::IndexType i = 0; - i < ContainerType::size; - i++) - { - if( vertexIDs[ i ] < other.vertexIDs[ i ] ) - return true; - else - if( vertexIDs[ i ] > other.vertexIDs[ i ] ) - return false; - } - return false; - } - - private: - - ContainerType vertexIDs; -}; - - -#endif /* TNLMESHENTITYKEY_H_ */ diff --git a/src/mesh/tnlMeshEntityOrientation.h b/src/mesh/tnlMeshEntityOrientation.h new file mode 100644 index 0000000000000000000000000000000000000000..12ba48d04a8eb41e80ae1698f13483c9262d0121 --- /dev/null +++ b/src/mesh/tnlMeshEntityOrientation.h @@ -0,0 +1,54 @@ +/*************************************************************************** + tnlMeshEntityOrientation.h - description + ------------------- + begin : Aug 25, 2015 + copyright : (C) 2015 by Tomas Oberhuber et al. + 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 TNLMESHENTITYORIENTATION_H +#define TNLMESHENTITYORIENTATION_H + +#include <mesh/traits/tnlMeshTraits.h> + +template< typename MeshConfig, + typename EntityTopology> +class tnlMeshEntityOrientation +{ + template< typename, typename> friend class tnlMeshEntityReferenceOrientation; + + public: + typedef typename tnlMeshTraits< MeshConfig >::IdPermutationArrayAccessorType IdPermutationArrayAccessorType; + + IdPermutationArrayAccessorType getSubvertexPermutation() const + { + IdPermutationArrayAccessorType accessor; + accessor.bind( this->subvertexPermutation ); + return accessor; + //return this->subvertexPermutation.subarray( 0, this->subvertexPermutation.getSize() ); + } + + private: + typedef typename tnlMeshTraits< MeshConfig >::LocalIndexType LocalIndexType; + typedef typename tnlMeshTraits< MeshConfig >::template SubentityTraits< EntityTopology, 0 >::IdPermutationArrayType IdPermutationArrayType; + + void setPermutationValue( LocalIndexType index, LocalIndexType value ) + { + this->subvertexPermutation[ index ] = value; + } + + IdPermutationArrayType subvertexPermutation; +}; + + +#endif /* TNLMESHENTITYORIENTATION_H */ + diff --git a/src/mesh/tnlMeshEntityReferenceOrientation.h b/src/mesh/tnlMeshEntityReferenceOrientation.h new file mode 100644 index 0000000000000000000000000000000000000000..4cd6c8cb5e512a26ec9f61416fedad9fc261c3f7 --- /dev/null +++ b/src/mesh/tnlMeshEntityReferenceOrientation.h @@ -0,0 +1,63 @@ +/*************************************************************************** + tnlMeshEntityReferenceOrientation.h - description + ------------------- + begin : Aug 25, 2015 + copyright : (C) 2015 by Tomas Oberhuber et al. + 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 TNLMESHENTITYREFERENCEORIENTATION_H +#define TNLMESHENTITYREFERENCEORIENTATION_H + +template< typename MeshConfig, typename EntityTopology > +class tnlMeshEntityReferenceOrientation +{ + typedef typename tnlMeshTraits< MeshConfig >::LocalIndexType LocalIndexType; + typedef typename tnlMeshTraits< MeshConfig >::GlobalIndexType GlobalIndexType; + + public: + typedef tnlMeshEntitySeed< MeshConfig, EntityTopology > SeedType; + typedef tnlMeshEntityOrientation< MeshConfig, EntityTopology > EntityOrientation; + + tnlMeshEntityReferenceOrientation() = default; + + explicit tnlMeshEntityReferenceOrientation( const SeedType& referenceSeed ) + { + auto referenceCornerIds = referenceSeed.getCornerIds(); + for( LocalIndexType i = 0; i < referenceCornerIds.getSize(); i++ ) + { + tnlAssert( this->cornerIdsMap.find( referenceCornerIds[i]) == this->cornerIdsMap.end(), ); + this->cornerIdsMap.insert( std::make_pair( referenceCornerIds[i], i ) ); + } + } + + static tnlString getType(){}; + + EntityOrientation createOrientation( const SeedType& seed ) const + { + EntityOrientation result; + auto cornerIds = seed.getCornerIds(); + for( LocalIndexType i = 0; i < cornerIds.getSize(); i++ ) + { + tnlAssert( this->cornerIdsMap.find( cornerIds[ i ] ) != this->cornerIdsMap.end(), ); + result.setPermutationValue( i, this->cornerIdsMap.find( cornerIds[ i ])->second ); + } + return result; + } + + private: + std::map< GlobalIndexType, LocalIndexType > cornerIdsMap; +}; + + +#endif /* TNLMESHENTITYREFERENCEORIENTATION_H */ + diff --git a/src/mesh/tnlMeshEntity_impl.h b/src/mesh/tnlMeshEntity_impl.h new file mode 100644 index 0000000000000000000000000000000000000000..8b58e02acaab3f8c75f2d1e1bfd256b8020d7db9 --- /dev/null +++ b/src/mesh/tnlMeshEntity_impl.h @@ -0,0 +1,499 @@ +/*************************************************************************** + tnlMeshEntity_impl.h - description + ------------------- + begin : Sep 8, 2015 + copyright : (C) 2015 by Tomas Oberhuber et al. + 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 TNLMESHENTITY_IMPL_H +#define TNLMESHENTITY_IMPL_H + +#include "tnlMeshEntity.h" + + +template< typename MeshConfig, + typename EntityTopology > +tnlMeshEntity< MeshConfig, EntityTopology >:: +tnlMeshEntity( const SeedType& entitySeed ) +{ + typedef typename SeedType::LocalIndexType LocalIndexType; + for( LocalIndexType i = 0; i < entitySeed.getCornerIds().getSize(); i++ ) + this->template setSubentityIndex< 0 >( i, entitySeed.getCornerIds()[ i ] ); +} + + +template< typename MeshConfig, + typename EntityTopology > +tnlMeshEntity< MeshConfig, EntityTopology >:: +tnlMeshEntity() +{ +} + +template< typename MeshConfig, + typename EntityTopology > +tnlMeshEntity< MeshConfig, EntityTopology >:: +~tnlMeshEntity() +{ + //cerr << " Destroying entity with " << EntityTopology::dimensions << " dimensions..." << endl; +} + +template< typename MeshConfig, + typename EntityTopology > +tnlString +tnlMeshEntity< MeshConfig, EntityTopology >:: +getType() +{ + return tnlString( "tnlMesh< ... >" ); +} + +template< typename MeshConfig, + typename EntityTopology > +tnlString +tnlMeshEntity< MeshConfig, EntityTopology >:: +getTypeVirtual() const +{ + return this->getType(); +} + +template< typename MeshConfig, + typename EntityTopology > +bool +tnlMeshEntity< MeshConfig, EntityTopology >:: +save( tnlFile& file ) const +{ + if( ! tnlMeshSubentityStorageLayers< MeshConfig, EntityTopology >::save( file ) /*|| + ! tnlMeshSuperentityStorageLayers< MeshConfig, EntityTopology >::save( file )*/ ) + return false; + return true; +} + +template< typename MeshConfig, + typename EntityTopology > +bool +tnlMeshEntity< MeshConfig, EntityTopology >:: +load( tnlFile& file ) +{ + if( ! tnlMeshSubentityStorageLayers< MeshConfig, EntityTopology >::load( file ) /*|| + ! tnlMeshSuperentityStorageLayers< MeshConfig, EntityTopology >::load( file ) */ ) + return false; + return true; +} + +template< typename MeshConfig, + typename EntityTopology > +void +tnlMeshEntity< MeshConfig, EntityTopology >:: +print( ostream& str ) const +{ + str << "\t Mesh entity dimensions: " << EntityTopology::dimensions << endl; + tnlMeshSubentityStorageLayers< MeshConfig, EntityTopology >::print( str ); + tnlMeshSuperentityAccess< MeshConfig, EntityTopology >::print( str ); +} + +template< typename MeshConfig, + typename EntityTopology > +bool +tnlMeshEntity< MeshConfig, EntityTopology >:: +operator==( const tnlMeshEntity& entity ) const +{ + return ( tnlMeshSubentityStorageLayers< MeshConfig, EntityTopology >::operator==( entity ) && + tnlMeshSuperentityAccess< MeshConfig, EntityTopology >::operator==( entity ) && + tnlMeshEntityId< typename MeshConfig::IdType, + typename MeshConfig::GlobalIndexType >::operator==( entity ) ); +} + +template< typename MeshConfig, + typename EntityTopology > +constexpr int +tnlMeshEntity< MeshConfig, EntityTopology >:: +getEntityDimensions() const +{ + return EntityTopology::dimensions; +} + +/**** + * Subentities + */ +template< typename MeshConfig, + typename EntityTopology > + template< int Subdimensions > +constexpr bool +tnlMeshEntity< MeshConfig, EntityTopology >:: +subentitiesAvailable() const +{ + return SubentityTraits< Subdimensions >::storageEnabled; +}; + +template< typename MeshConfig, + typename EntityTopology > + template< int Subdimensions > +constexpr typename tnlMeshEntity< MeshConfig, EntityTopology >::LocalIndexType +tnlMeshEntity< MeshConfig, EntityTopology >:: +getNumberOfSubentities() const +{ + return SubentityTraits< Subdimensions >::count; +}; + +template< typename MeshConfig, + typename EntityTopology > + template< int Subdimensions > +typename tnlMeshEntity< MeshConfig, EntityTopology >::GlobalIndexType +tnlMeshEntity< MeshConfig, EntityTopology >:: +getSubentityIndex( const LocalIndexType localIndex) const +{ + static_assert( SubentityTraits< Subdimensions >::storageEnabled, "You try to get subentity which is not configured for storage." ); + tnlAssert( 0 <= localIndex && + localIndex < SubentityTraits< Subdimensions >::count, + cerr << "localIndex = " << localIndex + << " subentitiesCount = " + << SubentityTraits< Subdimensions >::count ); + typedef tnlMeshSubentityStorageLayers< MeshConfig, EntityTopology > SubentityBaseType; + return SubentityBaseType::getSubentityIndex( tnlDimensionsTag< Subdimensions >(), + localIndex ); +} + +template< typename MeshConfig, + typename EntityTopology > + template< int Subdimensions > +typename tnlMeshEntity< MeshConfig, EntityTopology >::template SubentityTraits< Subdimensions >::AccessArrayType& +tnlMeshEntity< MeshConfig, EntityTopology >:: + getSubentitiesIndices() +{ + static_assert( SubentityTraits< Subdimensions >::storageEnabled, "You try to get subentities which are not configured for storage." ); + typedef tnlMeshSubentityStorageLayers< MeshConfig, EntityTopology > SubentityBaseType; + return SubentityBaseType::getSubentitiesIndices( tnlDimensionsTag< Subdimensions >() ); +} + +template< typename MeshConfig, + typename EntityTopology > + template< int Subdimensions > +const typename tnlMeshEntity< MeshConfig, EntityTopology >::template SubentityTraits< Subdimensions >::AccessArrayType& +tnlMeshEntity< MeshConfig, EntityTopology >:: +getSubentitiesIndices() const +{ + static_assert( SubentityTraits< Subdimensions >::storageEnabled, "You try to set subentities which are not configured for storage." ); + typedef tnlMeshSubentityStorageLayers< MeshConfig, EntityTopology > SubentityBaseType; + return SubentityBaseType::getSubentitiesIndices( tnlDimensionsTag< Subdimensions >() ); +} + +template< typename MeshConfig, + typename EntityTopology > + template< int SuperDimensions > +typename tnlMeshEntity< MeshConfig, EntityTopology >::LocalIndexType +tnlMeshEntity< MeshConfig, EntityTopology >:: +getNumberOfSuperentities() const +{ + static_assert( SuperentityTraits< SuperDimensions >::available, "You try to get number of superentities which are not configured for storage." ); + typedef tnlMeshSuperentityAccess< MeshConfig, EntityTopology > SuperentityBaseType; + return SuperentityBaseType::getNumberOfSuperentities( tnlDimensionsTag< SuperDimensions >() ); +} + +template< typename MeshConfig, + typename EntityTopology > + template< int SuperDimensions > +typename tnlMeshEntity< MeshConfig, EntityTopology >::GlobalIndexType +tnlMeshEntity< MeshConfig, EntityTopology >:: +getSuperentityIndex( const LocalIndexType localIndex ) const +{ + static_assert( SuperentityTraits< SuperDimensions >::storageEnabled, "You try to get superentity which is not configured for storage." ); + tnlAssert( localIndex < this->getNumberOfSuperentities< SuperDimensions >(), + cerr << " localIndex = " << localIndex + << " this->getNumberOfSuperentities< Dimensions >() = " << this->getNumberOfSuperentities< SuperDimensions >() << endl; ); + typedef tnlMeshSuperentityAccess< MeshConfig, EntityTopology > SuperentityBaseType; + return SuperentityBaseType::getSuperentityIndex( tnlDimensionsTag< SuperDimensions >(), + localIndex ); +} + +template< typename MeshConfig, + typename EntityTopology > + template< int SuperDimensions > +typename tnlMeshEntity< MeshConfig, EntityTopology >::template SuperentityTraits< SuperDimensions >::AccessArrayType& +tnlMeshEntity< MeshConfig, EntityTopology >:: +getSuperentitiesIndices() +{ + static_assert( SuperentityTraits< SuperDimensions >::storageEnabled, "You try to get superentities which are not configured for storage." ); + typedef tnlMeshSuperentityAccess< MeshConfig, EntityTopology > SuperentityBaseType; + //return SuperentityBaseType::getSuperentitiesIndices( tnlDimensionsTag< Dimensions >() ); +} + +template< typename MeshConfig, + typename EntityTopology > + template< int SuperDimensions > +const typename tnlMeshEntity< MeshConfig, EntityTopology >::template SuperentityTraits< SuperDimensions >::AccessArrayType& +tnlMeshEntity< MeshConfig, EntityTopology >:: +getSuperentitiesIndices() const +{ + static_assert( SuperentityTraits< SuperDimensions >::storageEnabled, "You try to get superentities which are not configured for storage." ); + typedef tnlMeshSuperentityAccess< MeshConfig, EntityTopology > SuperentityBaseType; + return SuperentityBaseType::getSubentitiesIndices( tnlDimensionsTag< SuperDimensions >() ); +} + +template< typename MeshConfig, + typename EntityTopology > +constexpr typename tnlMeshEntity< MeshConfig, EntityTopology >::LocalIndexType +tnlMeshEntity< MeshConfig, EntityTopology >:: +getNumberOfVertices() const +{ + return SubentityTraits< 0 >::count; +} + +template< typename MeshConfig, + typename EntityTopology > +typename tnlMeshEntity< MeshConfig, EntityTopology >::GlobalIndexType +tnlMeshEntity< MeshConfig, EntityTopology >:: +getVertexIndex( const LocalIndexType localIndex ) const +{ + return this->getSubentityIndex< 0 >( localIndex ); +} + +template< typename MeshConfig, + typename EntityTopology > +typename tnlMeshEntity< MeshConfig, EntityTopology >::template SubentityTraits< 0 >::AccessArrayType& +tnlMeshEntity< MeshConfig, EntityTopology >:: +getVerticesIndices() +{ + return this->getSubentitiesIndices< 0 >(); +} + +template< typename MeshConfig, + typename EntityTopology > +const typename tnlMeshEntity< MeshConfig, EntityTopology >::template SubentityTraits< 0 >::AccessArrayType& +tnlMeshEntity< MeshConfig, EntityTopology >:: +getVerticesIndices() const +{ + return this->getSubentitiesIndices< 0 >(); +} + +template< typename MeshConfig, + typename EntityTopology > + template< int Dimensions > +typename tnlMeshEntity< MeshConfig, EntityTopology >::IdPermutationArrayAccessorType +tnlMeshEntity< MeshConfig, EntityTopology >:: +subentityOrientation( LocalIndexType index ) const +{ + static const LocalIndexType subentitiesCount = SubentityTraits< Dimensions >::count; + tnlAssert( 0 <= index && index < subentitiesCount, ); + + return SubentityStorageLayers::subentityOrientation( tnlDimensionsTag< Dimensions >(), index ); +} + +/**** + * Mesh initialization method + */ + +template< typename MeshConfig, + typename EntityTopology > + template< int Subdimensions > +void +tnlMeshEntity< MeshConfig, EntityTopology >:: +setSubentityIndex( const LocalIndexType localIndex, + const GlobalIndexType globalIndex ) +{ + static_assert( SubentityTraits< Subdimensions >::storageEnabled, "You try to set subentity which is not configured for storage." ); + tnlAssert( 0 <= localIndex && + localIndex < SubentityTraits< Subdimensions >::count, + cerr << "localIndex = " << localIndex + << " subentitiesCount = " + << SubentityTraits< Subdimensions >::count ); + typedef tnlMeshSubentityStorageLayers< MeshConfig, EntityTopology > SubentityBaseType; + SubentityBaseType::setSubentityIndex( tnlDimensionsTag< Subdimensions >(), + localIndex, + globalIndex ); +} + +template< typename MeshConfig, + typename EntityTopology > + template< int Subdimensions > +typename tnlMeshEntity< MeshConfig, EntityTopology >::template SubentityTraits< Subdimensions >::IdArrayType& +tnlMeshEntity< MeshConfig, EntityTopology >:: +subentityIdsArray() +{ + return SubentityStorageLayers::subentityIdsArray( tnlDimensionsTag< Subdimensions >() ); +} + +template< typename MeshConfig, + typename EntityTopology > + template< int Superdimensions > +typename tnlMeshEntity< MeshConfig, EntityTopology >::IdArrayAccessorType& +tnlMeshEntity< MeshConfig, EntityTopology >:: +superentityIdsArray() +{ + return SuperentityAccessBase::superentityIdsArray( tnlDimensionsTag< Superdimensions >()); +} + +template< typename MeshConfig, + typename EntityTopology > + template< int Subdimensions > +typename tnlMeshEntity< MeshConfig, EntityTopology >::template SubentityTraits< Subdimensions >::OrientationArrayType& +tnlMeshEntity< MeshConfig, EntityTopology >:: +subentityOrientationsArray() +{ + return SubentityStorageLayers::subentityOrientationsArray( tnlDimensionsTag< Subdimensions >() ); +} + +/**** + * Vertex entity specialization + */ +template< typename MeshConfig > +tnlString +tnlMeshEntity< MeshConfig, tnlMeshVertexTopology >:: +getType() +{ + return tnlString( "tnlMesh< ... >" ); +} + +template< typename MeshConfig > +tnlString +tnlMeshEntity< MeshConfig, tnlMeshVertexTopology >:: +getTypeVirtual() const +{ + return this->getType(); +} + +template< typename MeshConfig > +tnlMeshEntity< MeshConfig, tnlMeshVertexTopology >:: +~tnlMeshEntity() +{ + //cerr << " Destroying entity with " << tnlMeshVertexTopology::dimensions << " dimensions..." << endl; +} + +template< typename MeshConfig > +bool +tnlMeshEntity< MeshConfig, tnlMeshVertexTopology >:: +save( tnlFile& file ) const +{ + if( //! tnlMeshSuperentityStorageLayers< MeshConfig, tnlMeshVertexTopology >::save( file ) || + ! point.save( file ) ) + return false; + return true; +} + +template< typename MeshConfig > +bool +tnlMeshEntity< MeshConfig, tnlMeshVertexTopology >:: +load( tnlFile& file ) +{ + if( //! tnlMeshSuperentityStorageLayers< MeshConfig, tnlMeshVertexTopology >::load( file ) || + ! point.load( file ) ) + return false; + return true; +} + +template< typename MeshConfig > +void +tnlMeshEntity< MeshConfig, tnlMeshVertexTopology >:: +print( ostream& str ) const +{ + str << "\t Mesh entity dimensions: " << tnlMeshVertexTopology::dimensions << endl; + str << "\t Coordinates = ( " << point << " )"; + tnlMeshSuperentityAccess< MeshConfig, tnlMeshVertexTopology >::print( str ); +} + +template< typename MeshConfig > +bool +tnlMeshEntity< MeshConfig, tnlMeshVertexTopology >:: +operator==( const tnlMeshEntity& entity ) const +{ + return ( //tnlMeshSuperentityAccess< MeshConfig, tnlMeshVertexTopology >::operator==( entity ) && + tnlMeshEntityId< typename MeshConfig::IdType, + typename MeshConfig::GlobalIndexType >::operator==( entity ) && + point == entity.point ); +} + +template< typename MeshConfig > +constexpr int +tnlMeshEntity< MeshConfig, tnlMeshVertexTopology >:: +getEntityDimensions() const +{ + return EntityTopology::dimensions; +} + +template< typename MeshConfig > + template< int Superdimensions > +typename tnlMeshEntity< MeshConfig, tnlMeshVertexTopology >::LocalIndexType +tnlMeshEntity< MeshConfig, tnlMeshVertexTopology >:: +getNumberOfSuperentities() const +{ + typedef tnlMeshSuperentityAccess< MeshConfig, tnlMeshVertexTopology > SuperentityBaseType; + return SuperentityBaseType::getNumberOfSuperentities( tnlDimensionsTag< Superdimensions >() ); +} + +template< typename MeshConfig > + template< int Superdimensions > +typename tnlMeshEntity< MeshConfig, tnlMeshVertexTopology >::template SuperentityTraits< Superdimensions >::AccessArrayType& +tnlMeshEntity< MeshConfig, tnlMeshVertexTopology >:: +getSuperentitiesIndices() +{ + typedef tnlMeshSuperentityAccess< MeshConfig, tnlMeshVertexTopology > SuperentityBaseType; + return SuperentityBaseType::getSuperentitiesIndices( tnlDimensionsTag< Superdimensions >() ); +} + +template< typename MeshConfig > + template< int Superdimensions > +const typename tnlMeshEntity< MeshConfig, tnlMeshVertexTopology >::template SuperentityTraits< Superdimensions >::AccessArrayType& +tnlMeshEntity< MeshConfig, tnlMeshVertexTopology >:: +getSuperentitiesIndeces() const +{ + typedef tnlMeshSuperentityAccess< MeshConfig, tnlMeshVertexTopology > SuperentityBaseType; + return SuperentityBaseType::getSubentitiesIndices( tnlDimensionsTag< Superdimensions >() ); +} + +template< typename MeshConfig > + template< int Dimensions > +typename tnlMeshEntity< MeshConfig, tnlMeshVertexTopology >::GlobalIndexType +tnlMeshEntity< MeshConfig, tnlMeshVertexTopology >:: +getSuperentityIndex( const LocalIndexType localIndex ) const +{ + tnlAssert( localIndex < this->getNumberOfSuperentities< Dimensions >(), + cerr << " localIndex = " << localIndex + << " this->getNumberOfSuperentities< Dimensions >() = " << this->getNumberOfSuperentities< Dimensions >() << endl; ); + typedef tnlMeshSuperentityAccess< MeshConfig, tnlMeshVertexTopology > SuperentityBaseType; + return SuperentityBaseType::getSuperentityIndex( tnlDimensionsTag< Dimensions >(), + localIndex ); +} + +template< typename MeshConfig > +typename tnlMeshEntity< MeshConfig, tnlMeshVertexTopology >::PointType +tnlMeshEntity< MeshConfig, tnlMeshVertexTopology >:: +getPoint() const +{ + return this->point; +} + +template< typename MeshConfig > +void +tnlMeshEntity< MeshConfig, tnlMeshVertexTopology >:: +setPoint( const PointType& point ) +{ + this->point = point; +} + +template< typename MeshConfig > + template< int Superdimensions > +typename tnlMeshEntity< MeshConfig, tnlMeshVertexTopology >::MeshTraits::IdArrayAccessorType& +tnlMeshEntity< MeshConfig, tnlMeshVertexTopology >:: +superentityIdsArray() +{ + return SuperentityAccessBase::superentityIdsArray( tnlDimensionsTag< Superdimensions >()); +} + +template< typename MeshConfig, + typename EntityTopology > +ostream& operator <<( ostream& str, const tnlMeshEntity< MeshConfig, EntityTopology >& entity ) +{ + entity.print( str ); + return str; +} + +#endif /* TNLMESHENTITY_IMPL_H */ + diff --git a/src/mesh/tnlMeshInitializer.h b/src/mesh/tnlMeshInitializer.h deleted file mode 100644 index 0cee8179edb3fa1b92a9d533d66a493368f37796..0000000000000000000000000000000000000000 --- a/src/mesh/tnlMeshInitializer.h +++ /dev/null @@ -1,338 +0,0 @@ -/*************************************************************************** - tnlMeshInitializer.h - description - ------------------- - begin : Feb 23, 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 TNLMESHINITIALIZER_H_ -#define TNLMESHINITIALIZER_H_ - -#include <mesh/traits/tnlMeshEntitiesTraits.h> -#include <mesh/traits/tnlDimensionsTraits.h> -#include <mesh/traits/tnlMeshSubentitiesTraits.h> -#include <mesh/traits/tnlMeshSuperentitiesTraits.h> -#include <mesh/tnlMeshEntityInitializer.h> -#include <mesh/tnlMesh.h> -#include <mesh/traits/tnlStorageTraits.h> - -template< typename ConfigTag, - typename DimensionsTraits, - typename EntityStorageTag = typename tnlMeshEntitiesTraits< ConfigTag, - DimensionsTraits >::EntityStorageTag > -class tnlMeshInitializerLayer; - - -template< typename ConfigTag, - typename EntityTag> -class tnlMeshEntityInitializer; - -template< typename ConfigTag > -class tnlMeshInitializer - : public tnlMeshInitializerLayer< ConfigTag, - typename tnlMeshTraits< ConfigTag >::DimensionsTraits > -{ - typedef tnlMesh< ConfigTag > MeshType; - - public: - - bool initMesh( MeshType& mesh ) - { - //cout << "======= Starting mesh initiation ========" << endl; - this->setMesh( mesh ); - if( ! this->checkCells() ) - return false; - //cout << "========= Creating entities =============" << endl; - this->createEntitiesFromCells(); - this->createEntityInitializers(); - //cout << "====== Initiating entities ==============" << endl; - this->initEntities( *this ); - //cout << "Mesh initiation done..." << endl; - return true; - } -}; - -template< typename ConfigTag > -class tnlMeshInitializerLayer< ConfigTag, - typename tnlMeshTraits< ConfigTag >::DimensionsTraits, - tnlStorageTraits< true > > - : public tnlMeshInitializerLayer< ConfigTag, - typename tnlMeshTraits< ConfigTag >::DimensionsTraits::Previous > -{ - typedef typename tnlMeshTraits< ConfigTag >::DimensionsTraits DimensionsTraits; - - typedef tnlMeshInitializerLayer< ConfigTag, - typename DimensionsTraits::Previous > BaseType; - - typedef tnlMeshEntitiesTraits< ConfigTag, DimensionsTraits > Tag; - typedef typename Tag::Tag EntityTag; - typedef typename Tag::ContainerType ContainerType; - typedef typename ContainerType::IndexType GlobalIndexType; - - typedef tnlMeshInitializer< ConfigTag > InitializerType; - typedef tnlMeshEntityInitializer< ConfigTag, EntityTag > CellInitializerType; - typedef tnlArray< CellInitializerType, tnlHost, GlobalIndexType > CellInitializerContainerType; - - public: - using BaseType::getEntityInitializer; - CellInitializerType& getEntityInitializer( DimensionsTraits, GlobalIndexType index ) - { - return cellInitializerContainer[ index ]; - } - - protected: - - bool checkCells() - { - typedef typename tnlMeshEntity< ConfigTag, EntityTag >::template SubentitiesTraits< 0 >::LocalIndexType LocalIndexType; - for( GlobalIndexType cell = 0; - cell < this->getMesh().getNumberOfCells(); - cell++ ) - for( LocalIndexType i = 0; - i < this->getMesh().getCell( cell ).getNumberOfVertices(); - i++ ) - if( this->getMesh().getCell( cell ).getVerticesIndices()[ i ] == - 1 ) - { - cerr << "The cell number " << cell << " does not have properly set vertex index number " << i << "." << endl; - return false; - } - return true; - } - - void createEntitiesFromCells() - { - //cout << " Creating entities with " << DimensionsTraits::value << " dimensions..." << endl; - cellInitializerContainer.setSize( this->getMesh().getNumberOfCells() ); - for( GlobalIndexType cell = 0; - cell < this->getMesh().getNumberOfCells(); - cell++ ) - { - //cout << " Creating the cell number " << cell << endl; - CellInitializerType& cellInitializer = cellInitializerContainer[ cell ]; - - cellInitializer.init( this->getMesh().getCell( cell ), cell ); - BaseType::createEntitiesFromCells( cellInitializer ); - } - - } - - void initEntities( InitializerType& meshInitializer ) - { - //cout << " Initiating entities with " << DimensionsTraits::value << " dimensions..." << endl; - for( typename CellInitializerContainerType::IndexType i = 0; - i < cellInitializerContainer.getSize(); - i++ ) - { - //cout << " Initiating entity " << i << " with " << DimensionsTraits::value << " dimensions..." << endl; - cellInitializerContainer[ i ].initEntity( meshInitializer ); - } - cellInitializerContainer.reset(); - BaseType::initEntities( meshInitializer ); - } - - private: - CellInitializerContainerType cellInitializerContainer; -}; - - -template< typename ConfigTag, - typename DimensionsTraits > -class tnlMeshInitializerLayer< ConfigTag, - DimensionsTraits, - tnlStorageTraits< true > > - : public tnlMeshInitializerLayer< ConfigTag, - typename DimensionsTraits::Previous > -{ - typedef tnlMeshInitializerLayer< ConfigTag, - typename DimensionsTraits::Previous > BaseType; - - typedef tnlMeshEntitiesTraits< ConfigTag, DimensionsTraits > Tag; - typedef typename Tag::Tag EntityTag; - typedef typename Tag::Type EntityType; - typedef typename Tag::ContainerType ContainerType; - typedef typename Tag::UniqueContainerType UniqueContainerType; - typedef typename ContainerType::IndexType GlobalIndexType; - - typedef tnlMeshInitializer< ConfigTag > InitializerType; - typedef tnlMeshEntityInitializer< ConfigTag, - typename ConfigTag::CellTag > CellInitializerType; - typedef tnlMeshEntityInitializer< ConfigTag, EntityTag > EntityInitializerType; - typedef tnlArray< EntityInitializerType, tnlHost, GlobalIndexType > EntityInitializerContainerType; - - typedef typename - tnlMeshSubentitiesTraits< ConfigTag, - typename ConfigTag::CellTag, - DimensionsTraits >::SubentityContainerType SubentitiesContainerType; - - public: - - using BaseType::findEntityIndex; - GlobalIndexType findEntityIndex( EntityType &entity ) const - { - GlobalIndexType idx; - bool entityFound = uniqueContainer.find( entity, idx ); - tnlAssert( entityFound, - cerr << " entity = " << entity << endl; ); - return idx; - } - - using BaseType::getEntityInitializer; - EntityInitializerType& getEntityInitializer( DimensionsTraits, GlobalIndexType index ) - { - return entityInitializerContainer[ index ]; - } - - protected: - - void createEntitiesFromCells( const CellInitializerType& cellInitializer ) - { - //cout << " Creating entities with " << DimensionsTraits::value << " dimensions..." << endl; - SubentitiesContainerType subentities; - cellInitializer.template createSubentities< DimensionsTraits >( subentities ); - for( typename SubentitiesContainerType::IndexType i = 0; - i < subentities.getSize(); - i++ ) - { - //cout << " Inserting subentity " << endl << subentities[ i ] << endl; - uniqueContainer.insert( subentities[ i ] ); - } - //cout << " Container with entities with " << DimensionsTraits::value << " dimensions has: " << endl << this->uniqueContainer << endl; - BaseType::createEntitiesFromCells( cellInitializer ); - } - - void createEntityInitializers() - { - entityInitializerContainer.setSize( uniqueContainer.getSize() ); - BaseType::createEntityInitializers(); - } - - void initEntities( InitializerType &meshInitializer ) - { - //cout << " Initiating entities with " << DimensionsTraits::value << " dimensions..." << endl; - //cout << " Container with entities with " << DimensionsTraits::value << " dimensions has: " << endl << this->uniqueContainer << endl; - const GlobalIndexType numberOfEntities = uniqueContainer.getSize(); - this->getMesh().template setNumberOfEntities< DimensionsTraits::value >( numberOfEntities ); - uniqueContainer.toArray( this->getMesh().template getEntities< DimensionsTraits::value >() ); - uniqueContainer.reset(); - //cout << " this->getMesh().template getEntities< DimensionsTraits::value >() has: " << this->getMesh().template getEntities< DimensionsTraits::value >() << endl; - - //ContainerType& entityContainer = this->getMesh().entityContainer(DimensionsTraits()); - for( GlobalIndexType i = 0; - i < numberOfEntities; - i++) - { - //cout << "Initiating entity " << i << " with " << DimensionsTraits::value << " dimensions..." << endl; - EntityInitializerType& entityInitializer = entityInitializerContainer[ i ]; - //cout << "Initiating with entity " << this->getMesh().template getEntity< DimensionsTraits::value >( i ) << endl; - entityInitializer.init( this->getMesh().template getEntity< DimensionsTraits::value >( i ), i ); - entityInitializer.initEntity( meshInitializer ); - } - - entityInitializerContainer.reset(); - - BaseType::initEntities( meshInitializer ); - } - - private: - UniqueContainerType uniqueContainer; - EntityInitializerContainerType entityInitializerContainer; -}; - -template< typename ConfigTag, - typename DimensionsTraits > -class tnlMeshInitializerLayer< ConfigTag, - DimensionsTraits, - tnlStorageTraits< false > > - : public tnlMeshInitializerLayer< ConfigTag, - typename DimensionsTraits::Previous > -{}; - - -template< typename ConfigTag > -class tnlMeshInitializerLayer< ConfigTag, - tnlDimensionsTraits< 0 >, - tnlStorageTraits< true > > -{ - typedef tnlMesh< ConfigTag > MeshType; - typedef tnlDimensionsTraits< 0 > DimensionsTraits; - - typedef tnlMeshEntitiesTraits< ConfigTag, DimensionsTraits > Tag; - typedef typename Tag::Tag EntityTag; - typedef typename Tag::ContainerType ContainerType; - typedef typename Tag::SharedContainerType SharedContainerType; - typedef typename ContainerType::IndexType GlobalIndexType; - - typedef typename tnlMeshTraits< ConfigTag >::CellType CellType; - - typedef tnlMeshInitializer< ConfigTag > InitializerType; - typedef tnlMeshEntityInitializer< ConfigTag, - typename ConfigTag::CellTag > CellInitializerType; - typedef tnlMeshEntityInitializer< ConfigTag, EntityTag > VertexInitializerType; - typedef tnlArray< VertexInitializerType, tnlHost, GlobalIndexType > VertexInitializerContainerType; - - public: - - void setMesh( MeshType& mesh ) - { - this->mesh = &mesh; - } - - MeshType& getMesh() - { - tnlAssert( this->mesh, ); - return *( this->mesh ); - } - - VertexInitializerType& getEntityInitializer( DimensionsTraits, GlobalIndexType index ) - { - tnlAssert( index >= 0 && index < vertexInitializerContainer.getSize(), - cerr << " index = " << index - << " vertexInitializerContainer.getSize() = " << vertexInitializerContainer.getSize() << endl; ); - return vertexInitializerContainer[ index ]; - } - - protected: - void findEntityIndex() const {} // This method is due to 'using BaseType::findEntityIndex;' in the derived class. - void createEntitiesFromCells( const CellInitializerType& ) {} - - void createEntityInitializers() - { - vertexInitializerContainer.setSize( this->getMesh().template getNumberOfEntities< DimensionsTraits::value >() ); - } - - void initEntities( InitializerType& meshInitializer ) - { - //cout << " Initiating entities with " << DimensionsTraits::value << " dimensions..." << endl; - SharedContainerType& vertexContainer = this->getMesh().template getEntities< DimensionsTraits::value >(); - for( GlobalIndexType i = 0; - i < vertexContainer.getSize(); - i++ ) - { - //cout << "Initiating entity " << i << " with " << DimensionsTraits::value << " dimensions..." << endl; - VertexInitializerType& vertexInitializer = vertexInitializerContainer[ i ]; - vertexInitializer.init( vertexContainer[ i ], i ); - vertexInitializer.initEntity( meshInitializer ); - } - vertexInitializerContainer.reset(); - } - - private: - VertexInitializerContainerType vertexInitializerContainer; - - MeshType* mesh; -}; - - - - -#endif /* TNLMESHINITIALIZER_H_ */ diff --git a/src/mesh/traits/tnlMeshEntitiesTag.h b/src/mesh/tnlMeshIntegrityChecker.h similarity index 53% rename from src/mesh/traits/tnlMeshEntitiesTag.h rename to src/mesh/tnlMeshIntegrityChecker.h index 001d9b2fa34030a86145374bcc522258725f3ada..9cfd9e97ef528b2669e3dfba5235ecb98e3b865e 100644 --- a/src/mesh/traits/tnlMeshEntitiesTag.h +++ b/src/mesh/tnlMeshIntegrityChecker.h @@ -1,7 +1,7 @@ /*************************************************************************** - tnlMeshEntitiesTag.h - description + tnlMeshIntegrityChecker.h - description ------------------- - begin : Feb 13, 2014 + begin : Mar 20, 2014 copyright : (C) 2014 by Tomas Oberhuber email : tomas.oberhuber@fjfi.cvut.cz ***************************************************************************/ @@ -15,30 +15,28 @@ * * ***************************************************************************/ -#ifndef TNLMESHENTITIESTAG_H_ -#define TNLMESHENTITIESTAG_H_ +#ifndef TNLMESHINTEGRITYCHECKER_H_ +#define TNLMESHINTEGRITYCHECKER_H_ -#include <mesh/topologies/tnlMeshEntityTopology.h> -#include <mesh/traits/tnlMeshTraits.h> +#include <mesh/tnlMesh.h> +#include <mesh/tnlMeshIntegrityCheckerLayer.h> -template< typename ConfigTag, - typename DimensionsTraits > -class tnlMeshEntitiesTag +template< typename MeshType > +class tnlMeshIntegrityChecker +: public tnlMeshIntegrityCheckerLayer< MeshType, + tnlDimensionsTag< MeshType::Config::CellType::dimensions > > { - public: - - typedef typename tnlSubentities< typename ConfigTag::CellTag, - DimensionsTraits::value >::Tag Tag; -}; + typedef tnlDimensionsTag< MeshType::Config::CellType::dimensions > DimensionsTag; + typedef tnlMeshIntegrityCheckerLayer< MeshType, DimensionsTag > BaseType; -template< typename ConfigTag > -class tnlMeshEntitiesTag< ConfigTag, - typename tnlMeshTraits< ConfigTag >::DimensionsTraits > -{ public: - - typedef typename ConfigTag::CellTag Tag; + static bool checkMesh( const MeshType& mesh ) + { + if( ! BaseType::checkEntities( mesh ) ) + return false; + return true; + } }; -#endif /* TNLMESHENTITIESTAG_H_ */ +#endif /* TNLMESHINTEGRITYCHECKER_H_ */ diff --git a/src/mesh/tnlMeshIntegrityCheckerLayer.h b/src/mesh/tnlMeshIntegrityCheckerLayer.h new file mode 100644 index 0000000000000000000000000000000000000000..8d40a2eafa8049e3d8e42defffafae5b2f4c84e0 --- /dev/null +++ b/src/mesh/tnlMeshIntegrityCheckerLayer.h @@ -0,0 +1,106 @@ +/*************************************************************************** + tnlMeshIntegrityCheckerLayer.h - description + ------------------- + begin : Mar 21, 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 TNLMESHINTEGRITYCHECKERLAYER_H_ +#define TNLMESHINTEGRITYCHECKERLAYER_H_ + +#include <mesh/traits/tnlMeshEntityTraits.h> +#include <mesh/tnlDimensionsTag.h> + +template< typename MeshType, + typename DimensionsTag, + bool EntityStorageTag = tnlMeshEntityTraits< typename MeshType::Config, + DimensionsTag::value >::storageEnabled > +class tnlMeshIntegrityCheckerLayer; + +template< typename MeshType, + typename DimensionsTag > +class tnlMeshIntegrityCheckerLayer< MeshType, + DimensionsTag, + true > + : public tnlMeshIntegrityCheckerLayer< MeshType, + typename DimensionsTag::Decrement > +{ + public: + typedef tnlMeshIntegrityCheckerLayer< MeshType, + typename DimensionsTag::Decrement > BaseType; + enum { dimensions = DimensionsTag::value }; + + static bool checkEntities( const MeshType& mesh ) + { + typedef typename MeshType::template EntitiesTraits< dimensions >::ContainerType ContainerType; + typedef typename ContainerType::IndexType GlobalIndexType; + cout << "Checking entities with " << dimensions << " dimensions ..." << endl; + for( GlobalIndexType entityIdx = 0; + entityIdx < mesh.template getNumberOfEntities< dimensions >(); + entityIdx++ ) + { + cout << "Entity no. " << entityIdx << " \r" << flush; + } + cout << endl; + if( ! BaseType::checkEntities( mesh ) ) + return false; + return true; + } +}; + +template< typename MeshType > +class tnlMeshIntegrityCheckerLayer< MeshType, + tnlDimensionsTag< 0 >, + true > +{ + public: + enum { dimensions = 0 }; + + static bool checkEntities( const MeshType& mesh ) + { + typedef typename MeshType::template EntitiesTraits< dimensions >::ContainerType ContainerType; + typedef typename ContainerType::IndexType GlobalIndexType; + cout << "Checking entities with " << dimensions << " dimensions ..." << endl; + for( GlobalIndexType entityIdx = 0; + entityIdx < mesh.template getNumberOfEntities< dimensions >(); + entityIdx++ ) + { + cout << "Entity no. " << entityIdx << " \r" << flush; + } + cout << endl; + return true; + } + +}; + +template< typename MeshType, + typename DimensionsTag > +class tnlMeshIntegrityCheckerLayer< MeshType, + DimensionsTag, + false > + : public tnlMeshIntegrityCheckerLayer< MeshType, + typename DimensionsTag::Decrement > +{ + +}; + +template< typename MeshType > +class tnlMeshIntegrityCheckerLayer< MeshType, + tnlDimensionsTag< 0 >, + false > +{ + +}; + + +#endif /* TNLMESHINTEGRITYCHECKERLAYER_H_ */ diff --git a/src/mesh/tnlMeshReaderNetgen.h b/src/mesh/tnlMeshReaderNetgen.h index 10d1e4d3e6c4bf9dffbb2e36801f12c1da8b8760..007c607af973aded1d6be3cc342700c84ab1c098 100644 --- a/src/mesh/tnlMeshReaderNetgen.h +++ b/src/mesh/tnlMeshReaderNetgen.h @@ -22,14 +22,18 @@ #include <istream> #include <sstream> +#include <mesh/tnlMeshBuilder.h> + using namespace std; class tnlMeshReaderNetgen { public: - static bool detectDimensions( const tnlString& fileName, - int& dimensions ) + tnlMeshReaderNetgen() + : dimensions( 0 ){} + + bool detectMesh( const tnlString& fileName ) { fstream inputFile( fileName.getString() ); if( ! inputFile ) @@ -52,6 +56,11 @@ class tnlMeshReaderNetgen if( ! inputFile ) return false; getline( inputFile, line ); + iss.str( line ); + long int numberOfVertices; + iss >> numberOfVertices; + + //cout << "There are " << numberOfVertices << " vertices." << endl; /**** * Read the first vertex and compute number of components @@ -59,14 +68,60 @@ class tnlMeshReaderNetgen if( ! inputFile ) return false; getline( inputFile, line ); + iss.clear(); iss.str( line ); - dimensions = -1; + this->dimensions = -1; while( iss ) { double aux; iss >> aux; - dimensions++; + this->dimensions++; + } + + /**** + * Skip vertices + */ + long int verticesRead( 1 ); + while( verticesRead < numberOfVertices ) + { + getline( inputFile, line ); + if( ! inputFile ) + { + cerr << "The mesh file " << fileName << " is probably corrupted, some vertices are missing." << endl; + return false; + } + verticesRead++; + } + + /**** + * Skip whitespaces + */ + inputFile >> ws; + + /**** + * Get number of cells + */ + long int numberOfCells; + getline( inputFile, line ); + iss.clear(); + iss.str( line ); + iss >> numberOfCells; + //cout << "There are " << numberOfCells << " cells." << endl; + + /**** + * Get number of vertices in a cell + */ + getline( inputFile, line ); + iss.clear(); + iss.str( line ); + this->verticesInCell = -2; + while( iss ) + { + int aux; + iss >> aux; + this->verticesInCell++; } + //cout << "There are " << this->verticesInCell << " vertices in cell ..." << endl; return true; } @@ -76,6 +131,8 @@ class tnlMeshReaderNetgen bool verbose ) { typedef typename MeshType::PointType PointType; + typedef tnlMeshBuilder< MeshType > MeshBuilder; + const int dimensions = PointType::size; fstream inputFile( fileName.getString() ); @@ -85,6 +142,7 @@ class tnlMeshReaderNetgen return false; } + MeshBuilder meshBuilder; string line; istringstream iss; @@ -100,16 +158,16 @@ class tnlMeshReaderNetgen return false; getline( inputFile, line ); iss.str( line ); - typedef typename MeshType::template EntitiesTraits< 0 >::GlobalIndexType VertexIndexType; - VertexIndexType numberOfVertices; - iss >> numberOfVertices; - if( ! mesh.setNumberOfVertices( numberOfVertices ) ) + typedef typename MeshType::MeshTraits::template EntityTraits< 0 >::GlobalIndexType VertexIndexType; + VertexIndexType pointsCount; + iss >> pointsCount; + if( ! meshBuilder.setPointsCount( pointsCount ) ) { - cerr << "I am not able to allocate enough memory for " << numberOfVertices << " vertices." << endl; + cerr << "I am not able to allocate enough memory for " << pointsCount << " vertices." << endl; return false; } - for( VertexIndexType i = 0; i < numberOfVertices; i++ ) + for( VertexIndexType i = 0; i < pointsCount; i++ ) { getline( inputFile, line ); iss.clear(); @@ -117,10 +175,11 @@ class tnlMeshReaderNetgen PointType p; for( int d = 0; d < dimensions; d++ ) iss >> p[ d ]; - mesh.setVertex( i, p ); + //cout << "Setting point number " << i << " of " << pointsCount << endl; + meshBuilder.setPoint( i, p ); if( verbose ) - cout << numberOfVertices << " vertices expected ... " << i+1 << "/" << numberOfVertices << " \r" << flush; - const PointType& point = mesh.getVertex( i ).getPoint(); + cout << pointsCount << " vertices expected ... " << i+1 << "/" << pointsCount << " \r" << flush; + //const PointType& point = mesh.getVertex( i ).getPoint(); } if( verbose ) cout << endl; @@ -133,14 +192,18 @@ class tnlMeshReaderNetgen /**** * Read number of cells */ - typedef typename MeshType::template EntitiesTraits< dimensions >::GlobalIndexType CellIndexType; + typedef typename MeshType::MeshTraits::template EntityTraits< dimensions >::GlobalIndexType CellIndexType; if( ! inputFile ) + { + cerr << "I cannot read the mesh cells." << endl; return false; + } getline( inputFile, line ); + iss.clear(); iss.str( line ); - CellIndexType numberOfCells; - iss >> numberOfCells; - if( ! mesh.template setNumberOfEntities< dimensions >( numberOfCells ) ) + CellIndexType numberOfCells=atoi( line.data() ); + //iss >> numberOfCells; // TODO: I do not know why this does not work + if( ! meshBuilder.setCellsCount( numberOfCells ) ) { cerr << "I am not able to allocate enough memory for " << numberOfCells << " cells." << endl; return false; @@ -152,23 +215,36 @@ class tnlMeshReaderNetgen iss.str( line ); int subdomainIndex; iss >> subdomainIndex; - for( int cellVertex = 0; cellVertex < dimensions + 1; cellVertex++ ) + //cout << "Setting cell number " << i << " of " << numberOfCells << endl; + typedef typename MeshBuilder::CellSeedType CellSeedType; + for( int cellVertex = 0; cellVertex < CellSeedType::getCornersCount(); cellVertex++ ) { VertexIndexType vertexIdx; iss >> vertexIdx; - mesh.template getEntity< dimensions >( i ).setVertexIndex( cellVertex, vertexIdx ); + meshBuilder.getCellSeed( i ).setCornerId( cellVertex, vertexIdx - 1 ); } - cout << endl; if( verbose ) cout << numberOfCells << " cells expected ... " << i+1 << "/" << numberOfCells << " \r" << flush; } if( verbose ) cout << endl; + meshBuilder.build( mesh ); return true; } + int getDimensions() const + { + return this->dimensions; + } + + int getVerticesInCell() const + { + return this->verticesInCell; + } + protected: + int dimensions, verticesInCell; }; diff --git a/src/mesh/tnlMeshSuperentityInitializerLayer.h b/src/mesh/tnlMeshSuperentityInitializerLayer.h deleted file mode 100644 index dd0025712cc737d9ae3048887e72d443457b2bbf..0000000000000000000000000000000000000000 --- a/src/mesh/tnlMeshSuperentityInitializerLayer.h +++ /dev/null @@ -1,123 +0,0 @@ -/*************************************************************************** - tnlMeshSuperentityInitializerLayer.h - description - ------------------- - begin : Feb 27, 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 TNLMESHSUPERENTITYINITIALIZERLAYER_H_ -#define TNLMESHSUPERENTITYINITIALIZERLAYER_H_ - -#include <mesh/traits/tnlStorageTraits.h> -#include <mesh/traits/tnlDimensionsTraits.h> - -template< typename ConfigTag, - typename EntityTag > -class tnlMeshEntityInitializer; - -template< typename ConfigTag, - typename EntityTag, - typename DimensionsTag, - typename SuperentityStorageTag = typename tnlMeshSuperentitiesTraits< ConfigTag, EntityTag, DimensionsTag >::SuperentityStorageTag > -class tnlMeshSuperentityInitializerLayer; - -template< typename ConfigTag, - typename EntityTag, - typename DimensionsTag > -class tnlMeshSuperentityInitializerLayer< ConfigTag, - EntityTag, - DimensionsTag, - tnlStorageTraits< true > > - : public tnlMeshSuperentityInitializerLayer< ConfigTag, - EntityTag, - typename DimensionsTag::Previous > -{ - typedef tnlMeshSuperentityInitializerLayer< ConfigTag, - EntityTag, - typename DimensionsTag::Previous > BaseType; - - typedef typename tnlMeshSuperentitiesTraits< ConfigTag, - EntityTag, - DimensionsTag >::GrowableContainerType GrowableContainerType; - typedef typename GrowableContainerType::ElementType GlobalIndexType; - - typedef tnlMeshEntityInitializer< ConfigTag, EntityTag > EntityInitializerType; - - public: - - using BaseType::addSuperentity; - void addSuperentity( DimensionsTag, GlobalIndexType entityIndex ) - { - superentityContainer.Append( entityIndex ); - } - - protected: - void initSuperentities( EntityInitializerType& entityInitializer ) - { - entityInitializer.setNumberOfSuperentities( DimensionsTag(), - superentityContainer.getSize() ); - superentityContainer.toArray( entityInitializer.getSuperentityContainer( DimensionsTag()) ); - superentityContainer.reset(); - - BaseType::initSuperentities( entityInitializer ); - } - - private: - GrowableContainerType superentityContainer; -}; - -template< typename ConfigTag, - typename EntityTag, - typename DimensionsTag > -class tnlMeshSuperentityInitializerLayer< ConfigTag, - EntityTag, - DimensionsTag, - tnlStorageTraits< false > > - : public tnlMeshSuperentityInitializerLayer< ConfigTag, - EntityTag, - typename DimensionsTag::Previous > -{ -}; - -template< typename ConfigTag, - typename EntityTag > -class tnlMeshSuperentityInitializerLayer< ConfigTag, - EntityTag, - tnlDimensionsTraits< EntityTag::dimensions >, - tnlStorageTraits< true > > -{ - typedef tnlMeshEntityInitializer< ConfigTag, EntityTag > EntityInitializerType; - - protected: - void addSuperentity() {} // This method is due to 'using BaseType::...;' in the derived classes. - void initSuperentities( EntityInitializerType& ) {} -}; - -template< typename ConfigTag, - typename EntityTag > -class tnlMeshSuperentityInitializerLayer< ConfigTag, - EntityTag, - tnlDimensionsTraits< EntityTag::dimensions >, - tnlStorageTraits< false > > -{ - typedef tnlMeshEntityInitializer< ConfigTag, EntityTag > EntityInitializerType; - - protected: - void addSuperentity() {} // This method is due to 'using BaseType::...;' in the derived classes. - void initSuperentities( EntityInitializerType& ) {} -}; - - - - -#endif /* TNLMESHSUPERENTITYINITIALIZERLAYER_H_ */ diff --git a/src/mesh/tnlMeshWriterVTKLegacy.h b/src/mesh/tnlMeshWriterVTKLegacy.h new file mode 100644 index 0000000000000000000000000000000000000000..2ade5967e03c8507443fc775e1c66f80dbff2250 --- /dev/null +++ b/src/mesh/tnlMeshWriterVTKLegacy.h @@ -0,0 +1,136 @@ +/*************************************************************************** + tnlMeshWriterVTKLegacy.h - description + ------------------- + begin : Mar 20, 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 TNLMESHWRITERVTKLEGACY_H_ +#define TNLMESHWRITERVTKLEGACY_H_ + +#include <fstream> +#include <istream> +#include <sstream> +#include <iomanip> + +#include <mesh/topologies/tnlMeshTriangleTopology.h> +#include <mesh/topologies/tnlMeshQuadrilateralTopology.h> +#include <mesh/topologies/tnlMeshTetrahedronTopology.h> +#include <mesh/topologies/tnlMeshHexahedronTopology.h> +#include <mesh/tnlMeshEntity.h> + + +using namespace std; + +enum tnlVTKMeshEntities { tnlVTKVertex = 1, + tnlVTKPolyVertex = 2, + tnlVTKLine = 3, + tnlVTKPolyLine = 4, + tnlVTKTriangle = 5, + tnlVTKTriangleStrip = 6, + tnlVTKPolygon = 7, + tnlVTKPixel = 8, + tnlVTKQuad = 9, + tnlVTKTetra = 10, + tnlVTKVoxel = 11, + tnlVTKHexahedron = 12, + tnlVTKWedge = 13, + tnlVTKPyramid = 14 }; + +template< typename MeshEntity > +struct tnlMeshEntityVTKType{}; + +template< typename MeshConfig > struct tnlMeshEntityVTKType< tnlMeshEntity< MeshConfig, tnlMeshTriangleTopology > > { enum { VTKType = tnlVTKTriangle }; }; +template< typename MeshConfig > struct tnlMeshEntityVTKType< tnlMeshEntity< MeshConfig, tnlMeshQuadrilateralTopology > >{ enum { VTKType = tnlVTKQuad }; }; +template< typename MeshConfig > struct tnlMeshEntityVTKType< tnlMeshEntity< MeshConfig, tnlMeshTetrahedronTopology > > { enum { VTKType = tnlVTKTetra }; }; +template< typename MeshConfig > struct tnlMeshEntityVTKType< tnlMeshEntity< MeshConfig, tnlMeshHexahedronTopology > > { enum { VTKType = tnlVTKHexahedron }; }; + +class tnlMeshWriterVTKLegacy +{ + public: + + template< typename MeshType > + static bool write( const tnlString& fileName, + MeshType& mesh, + bool verbose ) + { + if( MeshType::dimensions > 3 ) + { + cerr << "You try to write mesh with " << MeshType::dimensions + << "dimensions but VTK legacy format supports only 1D, 2D and 3D meshes." << endl; + return false; + } + fstream outputFile; + outputFile.open( fileName.getString(), ios::out ); + if( ! outputFile ) + { + cerr << "I am not able to open the output file " << fileName << "." << endl; + return false; + } + outputFile << setprecision( 6 ); + outputFile << fixed; + + if( ! writeMesh( outputFile, mesh, verbose ) ) + return false; + } + + template< typename MeshType > + static bool writeMesh( ostream& file, + MeshType& mesh, + bool verbose ) + { + typedef typename MeshType::MeshTraits::CellType CellType; + file << "# vtk DataFile Version 2.0" << endl; + file << "TNL Mesh" << endl; + file << "ASCII" << endl; + file << "DATASET UNSTRUCTURED_GRID" << endl; + file << endl; + file << "POINTS " << mesh.template getNumberOfEntities< 0 >() << " double" << endl; + for( int i = 0; i < mesh.template getNumberOfEntities< 0 >(); i++ ) + { + mesh.template getEntity< 0 >( i ).getPoint().write( file ); + for( int j = MeshType::dimensions; j < 3; j++ ) + file << " 0.0"; + file << endl; + } + file << endl; + file << "CELLS " << mesh.template getNumberOfCells(); + long int listSize( 0 ); + for( int i = 0; i < mesh.template getNumberOfCells(); i++ ) + listSize += mesh.getCell( i ).template getNumberOfSubentities< 0 >() + 1; + file << " " << listSize << endl; + for( int i = 0; i < mesh.template getNumberOfCells(); i++ ) + { + int numberOfVertices = mesh.getCell( i ).template getNumberOfSubentities< 0 >(); + file << numberOfVertices << " "; + for( int j = 0; j < numberOfVertices - 1; j++ ) + file << mesh.getCell( i ).template getSubentityIndex< 0 >( j ) << " "; + file << mesh.getCell( i ).template getSubentityIndex< 0 >( numberOfVertices - 1 ) << endl; + } + file << endl; + file << "CELL_TYPES " << mesh.template getNumberOfCells() << endl; + for( int i = 0; i < mesh.template getNumberOfCells(); i++ ) + { + file << tnlMeshEntityVTKType< CellType >::VTKType << endl; + } + file << endl; + return true; + } + + +}; + + + +#endif /* TNLMESHWRITERVTKLEGACY_H_ */ diff --git a/src/mesh/tnlMesh_impl.h b/src/mesh/tnlMesh_impl.h new file mode 100644 index 0000000000000000000000000000000000000000..1647569566f666a4030f72f2790605efc0213319 --- /dev/null +++ b/src/mesh/tnlMesh_impl.h @@ -0,0 +1,190 @@ +/*************************************************************************** + tnlMesh_impl.h - description + ------------------- + begin : Sep 5, 2015 + copyright : (C) 2015 by Tomas Oberhuber et al. + 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 TNLMESH_IMPL_H +#define TNLMESH_IMPL_H + +#include "tnlMesh.h" + + +template< typename MeshConfig > +tnlString +tnlMesh< MeshConfig >:: +getType() +{ + return tnlString( "tnlMesh< ") + MeshConfig::getType() + " >"; +} + +template< typename MeshConfig > +tnlString +tnlMesh< MeshConfig >:: +getTypeVirtual() const +{ + return this->getType(); +} + +template< typename MeshConfig > +constexpr int +tnlMesh< MeshConfig >:: +getDimensions() +{ + return dimensions; +} + +template< typename MeshConfig > + template< int Dimensions > +bool +tnlMesh< MeshConfig >:: +entitiesAvalable() const +{ + return MeshTraits::template EntityTraits< Dimensions >::available; +} + +template< typename MeshConfig > + template< int Dimensions > +typename tnlMesh< MeshConfig >::GlobalIndexType +tnlMesh< MeshConfig >:: +getNumberOfEntities() const +{ + return entitiesStorage.getNumberOfEntities( tnlDimensionsTag< Dimensions >() ); +} + +template< typename MeshConfig > +typename tnlMesh< MeshConfig >::GlobalIndexType +tnlMesh< MeshConfig >:: +getNumberOfCells() const +{ + return entitiesStorage.getNumberOfEntities( tnlDimensionsTag< dimensions >() ); +} + +template< typename MeshConfig > +typename tnlMesh< MeshConfig >::CellType& +tnlMesh< MeshConfig >:: +getCell( const GlobalIndexType cellIndex ) +{ + return entitiesStorage.getEntity( tnlDimensionsTag< dimensions >(), cellIndex ); +} + +template< typename MeshConfig > +const typename tnlMesh< MeshConfig >::CellType& +tnlMesh< MeshConfig >:: +getCell( const GlobalIndexType cellIndex ) const +{ + return entitiesStorage.getEntity( tnlDimensionsTag< dimensions >(), cellIndex ); +} + +template< typename MeshConfig > + template< int Dimensions > +typename tnlMesh< MeshConfig >::template EntityType< Dimensions >& +tnlMesh< MeshConfig >:: +getEntity( const GlobalIndexType entityIndex ) +{ + return entitiesStorage.getEntity( tnlDimensionsTag< Dimensions >(), entityIndex ); +} + +template< typename MeshConfig > + template< int Dimensions > +const typename tnlMesh< MeshConfig >::template EntityType< Dimensions >& +tnlMesh< MeshConfig >:: +getEntity( const GlobalIndexType entityIndex ) const +{ + return entitiesStorage.getEntity( tnlDimensionsTag< Dimensions >(), entityIndex ); +} + +template< typename MeshConfig > +bool +tnlMesh< MeshConfig >:: +save( tnlFile& file ) const +{ + if( ! tnlObject::save( file ) || + ! entitiesStorage.save( file ) ) + { + cerr << "Mesh saving failed." << endl; + return false; + } + return true; +} + +template< typename MeshConfig > +bool +tnlMesh< MeshConfig >:: +load( tnlFile& file ) +{ + if( ! tnlObject::load( file ) || + ! entitiesStorage.load( file ) ) + { + cerr << "Mesh loading failed." << endl; + return false; + } + return true; +} + +template< typename MeshConfig > +void +tnlMesh< MeshConfig >:: +print( ostream& str ) const +{ + entitiesStorage.print( str ); +} + +template< typename MeshConfig > +bool +tnlMesh< MeshConfig >:: +operator==( const tnlMesh& mesh ) const +{ + return entitiesStorage.operator==( mesh.entitiesStorage ); +} + +template< typename MeshConfig > + template< typename DimensionsTag > +typename tnlMesh< MeshConfig >::template EntityTraits< DimensionsTag::value >::StorageArrayType& +tnlMesh< MeshConfig >:: +entitiesArray() +{ + return entitiesStorage.entitiesArray( DimensionsTag() ); +} + +template< typename MeshConfig > + template< typename DimensionsTag, typename SuperDimensionsTag > +typename tnlMesh< MeshConfig >::MeshTraits::GlobalIdArrayType& +tnlMesh< MeshConfig >:: +superentityIdsArray() +{ + return entitiesStorage.template superentityIdsArray< SuperDimensionsTag >( DimensionsTag() ); +} + +template< typename MeshConfig > +bool +tnlMesh< MeshConfig >:: +init( const typename tnlMesh< MeshConfig >::MeshTraits::PointArrayType& points, + const typename tnlMesh< MeshConfig >::MeshTraits::CellSeedArrayType& cellSeeds ) +{ + tnlMeshInitializer< MeshConfig> meshInitializer; + return meshInitializer.createMesh( points, cellSeeds, *this ); +} + + +template< typename MeshConfig > +std::ostream& operator <<( std::ostream& str, const tnlMesh< MeshConfig >& mesh ) +{ + mesh.print( str ); + return str; +} + +#endif /* TNLMESH_IMPL_H */ + diff --git a/src/mesh/topologies/CMakeLists.txt b/src/mesh/topologies/CMakeLists.txt index f99c65d84dc2db1c1c0201c64e255316bf91fb72..f0c8842ffa20d78ff96e1e8b6026d01f9e769302 100755 --- a/src/mesh/topologies/CMakeLists.txt +++ b/src/mesh/topologies/CMakeLists.txt @@ -1,9 +1,9 @@ -SET( headers tnlMeshEdgeTag.h +SET( headers tnlMeshEdgeTopology.h tnlMeshEntityTopology.h - tnlMeshHexahedronTag.h - tnlMeshQuadrilateralTag.h - tnlMeshTetrahedronTag.h - tnlMeshTriangleTag.h - tnlMeshVertexTag.h ) + tnlMeshHexahedronTopology.h + tnlMeshQuadrilateralTopology.h + tnlMeshTetrahedronTopology.h + tnlMeshTriangleTopology.h + tnlMeshVertexTopology.h ) INSTALL( FILES ${headers} DESTINATION include/tnl-${tnlVersion}/mesh/topologies ) \ No newline at end of file diff --git a/src/mesh/topologies/tnlMeshEdgeTag.h b/src/mesh/topologies/tnlMeshEdgeTopology.h similarity index 72% rename from src/mesh/topologies/tnlMeshEdgeTag.h rename to src/mesh/topologies/tnlMeshEdgeTopology.h index d28b1db24803f7c3569d2489ee366f4dbd9e0d0a..696bbe5d867acd13e91c48210b9951a499414293 100644 --- a/src/mesh/topologies/tnlMeshEdgeTag.h +++ b/src/mesh/topologies/tnlMeshEdgeTopology.h @@ -1,5 +1,5 @@ /*************************************************************************** - tnlMeshEdgeTag.h - description + tnlMeshEdgeTopology.h - description ------------------- begin : Feb 11, 2014 copyright : (C) 2014 by Tomas Oberhuber @@ -15,24 +15,24 @@ * * ***************************************************************************/ -#ifndef TNLMESHEDGETAG_H_ -#define TNLMESHEDGETAG_H_ +#ifndef TNLMESHEDGETOPOLOGY_H_ +#define TNLMESHEDGETOPOLOGY_H_ #include <mesh/topologies/tnlMeshEntityTopology.h> -#include <mesh/topologies/tnlMeshVertexTag.h> +#include <mesh/topologies/tnlMeshVertexTopology.h> -struct tnlMeshEdgeTag +struct tnlMeshEdgeTopology { - enum { dimensions = 1 }; + static const int dimensions = 1; }; template<> -struct tnlSubentities< tnlMeshEdgeTag, 0 > +struct tnlMeshSubtopology< tnlMeshEdgeTopology, 0 > { - typedef tnlMeshVertexTag Tag; + typedef tnlMeshVertexTopology Topology; - enum { count = 2 }; + static const int count = 2; }; -#endif /* TNLMESHEDGETAG_H_ */ +#endif /* TNLMESHEDGETOPOLOGY_H_ */ diff --git a/src/mesh/topologies/tnlMeshEntityTopology.h b/src/mesh/topologies/tnlMeshEntityTopology.h index 86db680c35ba1e1a6bec59d2c7ae164941056a89..1b1e660c0df562099d408408c4c563b18635cb2c 100644 --- a/src/mesh/topologies/tnlMeshEntityTopology.h +++ b/src/mesh/topologies/tnlMeshEntityTopology.h @@ -18,15 +18,35 @@ #ifndef TNLMESHENTITYTOPOLOGY_H_ #define TNLMESHENTITYTOPOLOGY_H_ -template< typename MeshEntityTag, +template< typename MeshEntityTopology, int SubentityDimension > -struct tnlSubentities; +struct tnlMeshSubtopology +{ +}; - -template< typename MeshEntityTag, - typename SubentityTag, +template< typename MeshEntityTopology, + typename SubentityTopology, int SubentityIndex, int SubentityVertexIndex > struct tnlSubentityVertex; + +template< typename MeshConfig, + int Dimensions > +class tnlMeshEntityTopology +{ + public: + + typedef typename tnlMeshSubtopology< typename MeshConfig::CellTopology, + Dimensions >::Topology Topology; +}; + +template< typename MeshConfig > +class tnlMeshEntityTopology< MeshConfig, + MeshConfig::CellTopology::dimensions > +{ + public: + + typedef typename MeshConfig::CellTopology Topology; +}; #endif /* TNLMESHENTITYTOPOLOGY_H_ */ diff --git a/src/mesh/topologies/tnlMeshHexahedronTag.h b/src/mesh/topologies/tnlMeshHexahedronTag.h deleted file mode 100644 index f944ff07c178dbf5d0e1066804888fad839b15d5..0000000000000000000000000000000000000000 --- a/src/mesh/topologies/tnlMeshHexahedronTag.h +++ /dev/null @@ -1,176 +0,0 @@ -/*************************************************************************** - tnlMeshHexahedronTag.h - description - ------------------- - begin : Feb 11, 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 TNLMESHHEXAHEDRONTAG_H_ -#define TNLMESHHEXAHEDRONTAG_H_ - -#include <mesh/topologies/tnlMeshQuadrilateralTag.h> - -struct tnlMeshHexahedronTag -{ - enum { dimensions = 3 }; -}; - -template<> -struct tnlSubentities< tnlMeshHexahedronTag, 0 > -{ - typedef tnlMeshVertexTag Tag; - - enum { count = 8 }; -}; - -template<> -struct tnlSubentities< tnlMeshHexahedronTag, 1 > -{ - typedef tnlMeshEdgeTag Tag; - - enum { count = 12 }; -}; - -template<> -struct tnlSubentities< tnlMeshHexahedronTag, 2 > -{ - typedef tnlMeshQuadrilateralTag Tag; - - enum { count = 6 }; -}; - -/**** - * Indexing of the vertices follows the VTK file format - * - * 7+---------------------------+6 - * /| /| - * / | / | - * / | / | - * / | / | - * 4+---------------------------+5 | - * | | | | - * | | | | - * | 3+----------------------|----+2 - * | / | / - * | / | / - * | / | / - * |/ |/ - * 0+---------------------------+1 - * - * - * The edges are indexed as follows: - * - * +---------------------------+ - * /| 10 /| - * 11/ | / | - * / | /9 | - * / 7| / |6 - * +---------------------------+ | - * | | 8 | | - * | | | | - * | +----------------------|----+ - * 4| / 2 |5 / - * | 3/ | / - * | / | /1 - * |/ |/ - * +---------------------------+ - * 0 - * - * The faces are indexed as follows (the indexed are positioned to - * the opposite corners of given face): - * - * +---------------------------+ - * /|5 3/| - * /4| /2| - * / | / | - * / | 5 / | - * +---------------------------+ | - * |1 | | | - * | |3 | | - * | +----------------------|----+ - * | / | 0/ - * | / | / - * |4/ |2/ - * |/0 1|/ - * +---------------------------+ - * - */ - -template<> struct tnlSubentityVertex< tnlMeshHexahedronTag, tnlMeshEdgeTag, 0, 0> { enum { index = 0 }; }; -template<> struct tnlSubentityVertex< tnlMeshHexahedronTag, tnlMeshEdgeTag, 0, 1> { enum { index = 1 }; }; - -template<> struct tnlSubentityVertex< tnlMeshHexahedronTag, tnlMeshEdgeTag, 1, 0> { enum { index = 1 }; }; -template<> struct tnlSubentityVertex< tnlMeshHexahedronTag, tnlMeshEdgeTag, 1, 1> { enum { index = 2 }; }; - -template<> struct tnlSubentityVertex< tnlMeshHexahedronTag, tnlMeshEdgeTag, 2, 0> { enum { index = 2 }; }; -template<> struct tnlSubentityVertex< tnlMeshHexahedronTag, tnlMeshEdgeTag, 2, 1> { enum { index = 3 }; }; - -template<> struct tnlSubentityVertex< tnlMeshHexahedronTag, tnlMeshEdgeTag, 3, 0> { enum { index = 3 }; }; -template<> struct tnlSubentityVertex< tnlMeshHexahedronTag, tnlMeshEdgeTag, 3, 1> { enum { index = 0 }; }; - -template<> struct tnlSubentityVertex< tnlMeshHexahedronTag, tnlMeshEdgeTag, 4, 0> { enum { index = 0 }; }; -template<> struct tnlSubentityVertex< tnlMeshHexahedronTag, tnlMeshEdgeTag, 4, 1> { enum { index = 4 }; }; - -template<> struct tnlSubentityVertex< tnlMeshHexahedronTag, tnlMeshEdgeTag, 5, 0> { enum { index = 1 }; }; -template<> struct tnlSubentityVertex< tnlMeshHexahedronTag, tnlMeshEdgeTag, 5, 1> { enum { index = 5 }; }; - -template<> struct tnlSubentityVertex< tnlMeshHexahedronTag, tnlMeshEdgeTag, 6, 0> { enum { index = 2 }; }; -template<> struct tnlSubentityVertex< tnlMeshHexahedronTag, tnlMeshEdgeTag, 6, 1> { enum { index = 6 }; }; - -template<> struct tnlSubentityVertex< tnlMeshHexahedronTag, tnlMeshEdgeTag, 7, 0> { enum { index = 3 }; }; -template<> struct tnlSubentityVertex< tnlMeshHexahedronTag, tnlMeshEdgeTag, 7, 1> { enum { index = 7 }; }; - -template<> struct tnlSubentityVertex< tnlMeshHexahedronTag, tnlMeshEdgeTag, 8, 0> { enum { index = 4 }; }; -template<> struct tnlSubentityVertex< tnlMeshHexahedronTag, tnlMeshEdgeTag, 8, 1> { enum { index = 5 }; }; - -template<> struct tnlSubentityVertex< tnlMeshHexahedronTag, tnlMeshEdgeTag, 9, 0> { enum { index = 5 }; }; -template<> struct tnlSubentityVertex< tnlMeshHexahedronTag, tnlMeshEdgeTag, 9, 1> { enum { index = 6 }; }; - -template<> struct tnlSubentityVertex< tnlMeshHexahedronTag, tnlMeshEdgeTag, 10, 0> { enum { index = 6 }; }; -template<> struct tnlSubentityVertex< tnlMeshHexahedronTag, tnlMeshEdgeTag, 10, 1> { enum { index = 7 }; }; - -template<> struct tnlSubentityVertex< tnlMeshHexahedronTag, tnlMeshEdgeTag, 11, 0> { enum { index = 7 }; }; -template<> struct tnlSubentityVertex< tnlMeshHexahedronTag, tnlMeshEdgeTag, 11, 1> { enum { index = 4 }; }; - - -template<> struct tnlSubentityVertex< tnlMeshHexahedronTag, tnlMeshQuadrilateralTag, 0, 0> { enum { index = 0 }; }; -template<> struct tnlSubentityVertex< tnlMeshHexahedronTag, tnlMeshQuadrilateralTag, 0, 1> { enum { index = 1 }; }; -template<> struct tnlSubentityVertex< tnlMeshHexahedronTag, tnlMeshQuadrilateralTag, 0, 2> { enum { index = 2 }; }; -template<> struct tnlSubentityVertex< tnlMeshHexahedronTag, tnlMeshQuadrilateralTag, 0, 3> { enum { index = 3 }; }; - -template<> struct tnlSubentityVertex< tnlMeshHexahedronTag, tnlMeshQuadrilateralTag, 1, 0> { enum { index = 0 }; }; -template<> struct tnlSubentityVertex< tnlMeshHexahedronTag, tnlMeshQuadrilateralTag, 1, 1> { enum { index = 1 }; }; -template<> struct tnlSubentityVertex< tnlMeshHexahedronTag, tnlMeshQuadrilateralTag, 1, 2> { enum { index = 5 }; }; -template<> struct tnlSubentityVertex< tnlMeshHexahedronTag, tnlMeshQuadrilateralTag, 1, 3> { enum { index = 4 }; }; - -template<> struct tnlSubentityVertex< tnlMeshHexahedronTag, tnlMeshQuadrilateralTag, 2, 0> { enum { index = 1 }; }; -template<> struct tnlSubentityVertex< tnlMeshHexahedronTag, tnlMeshQuadrilateralTag, 2, 1> { enum { index = 2 }; }; -template<> struct tnlSubentityVertex< tnlMeshHexahedronTag, tnlMeshQuadrilateralTag, 2, 2> { enum { index = 6 }; }; -template<> struct tnlSubentityVertex< tnlMeshHexahedronTag, tnlMeshQuadrilateralTag, 2, 3> { enum { index = 5 }; }; - -template<> struct tnlSubentityVertex< tnlMeshHexahedronTag, tnlMeshQuadrilateralTag, 3, 0> { enum { index = 2 }; }; -template<> struct tnlSubentityVertex< tnlMeshHexahedronTag, tnlMeshQuadrilateralTag, 3, 1> { enum { index = 3 }; }; -template<> struct tnlSubentityVertex< tnlMeshHexahedronTag, tnlMeshQuadrilateralTag, 3, 2> { enum { index = 7 }; }; -template<> struct tnlSubentityVertex< tnlMeshHexahedronTag, tnlMeshQuadrilateralTag, 3, 3> { enum { index = 6 }; }; - -template<> struct tnlSubentityVertex< tnlMeshHexahedronTag, tnlMeshQuadrilateralTag, 4, 0> { enum { index = 3 }; }; -template<> struct tnlSubentityVertex< tnlMeshHexahedronTag, tnlMeshQuadrilateralTag, 4, 1> { enum { index = 0 }; }; -template<> struct tnlSubentityVertex< tnlMeshHexahedronTag, tnlMeshQuadrilateralTag, 4, 2> { enum { index = 4 }; }; -template<> struct tnlSubentityVertex< tnlMeshHexahedronTag, tnlMeshQuadrilateralTag, 4, 3> { enum { index = 7 }; }; - -template<> struct tnlSubentityVertex< tnlMeshHexahedronTag, tnlMeshQuadrilateralTag, 5, 0> { enum { index = 4 }; }; -template<> struct tnlSubentityVertex< tnlMeshHexahedronTag, tnlMeshQuadrilateralTag, 5, 1> { enum { index = 5 }; }; -template<> struct tnlSubentityVertex< tnlMeshHexahedronTag, tnlMeshQuadrilateralTag, 5, 2> { enum { index = 6 }; }; -template<> struct tnlSubentityVertex< tnlMeshHexahedronTag, tnlMeshQuadrilateralTag, 5, 3> { enum { index = 7 }; }; - -#endif /* TNLMESHHEXAHEDRONTAG_H_ */ diff --git a/src/mesh/topologies/tnlMeshHexahedronTopology.h b/src/mesh/topologies/tnlMeshHexahedronTopology.h new file mode 100644 index 0000000000000000000000000000000000000000..0053a75df4e6333448e6984d84cda855a965e1be --- /dev/null +++ b/src/mesh/topologies/tnlMeshHexahedronTopology.h @@ -0,0 +1,176 @@ +/*************************************************************************** + tnlMeshHexahedronTopology.h - description + ------------------- + begin : Feb 11, 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 TNLMESHHEXAHEDRONTOPOLOGY_H_ +#define TNLMESHHEXAHEDRONTOPOLOGY_H_ + +#include <mesh/topologies/tnlMeshQuadrilateralTopology.h> + +struct tnlMeshHexahedronTopology +{ + static const int dimensions = 3; +}; + +template<> +struct tnlMeshSubtopology< tnlMeshHexahedronTopology, 0 > +{ + typedef tnlMeshVertexTopology Topology; + + static const int count = 8; +}; + +template<> +struct tnlMeshSubtopology< tnlMeshHexahedronTopology, 1 > +{ + typedef tnlMeshEdgeTopology Topology; + + static const int count = 12; +}; + +template<> +struct tnlMeshSubtopology< tnlMeshHexahedronTopology, 2 > +{ + typedef tnlMeshQuadrilateralTopology Topology; + + static const int count = 6; +}; + +/**** + * Indexing of the vertices follows the VTK file format + * + * 7+---------------------------+6 + * /| /| + * / | / | + * / | / | + * / | / | + * 4+---------------------------+5 | + * | | | | + * | | | | + * | 3+----------------------|----+2 + * | / | / + * | / | / + * | / | / + * |/ |/ + * 0+---------------------------+1 + * + * + * The edges are indexed as follows: + * + * +---------------------------+ + * /| 10 /| + * 11/ | / | + * / | /9 | + * / 7| / |6 + * +---------------------------+ | + * | | 8 | | + * | | | | + * | +----------------------|----+ + * 4| / 2 |5 / + * | 3/ | / + * | / | /1 + * |/ |/ + * +---------------------------+ + * 0 + * + * The faces are indexed as follows (the indexed are positioned to + * the opposite corners of given face): + * + * +---------------------------+ + * /|5 3/| + * /4| /2| + * / | / | + * / | 5 / | + * +---------------------------+ | + * |1 | | | + * | |3 | | + * | +----------------------|----+ + * | / | 0/ + * | / | / + * |4/ |2/ + * |/0 1|/ + * +---------------------------+ + * + */ + +template<> struct tnlSubentityVertex< tnlMeshHexahedronTopology, tnlMeshEdgeTopology, 0, 0> { enum { index = 0 }; }; +template<> struct tnlSubentityVertex< tnlMeshHexahedronTopology, tnlMeshEdgeTopology, 0, 1> { enum { index = 1 }; }; + +template<> struct tnlSubentityVertex< tnlMeshHexahedronTopology, tnlMeshEdgeTopology, 1, 0> { enum { index = 1 }; }; +template<> struct tnlSubentityVertex< tnlMeshHexahedronTopology, tnlMeshEdgeTopology, 1, 1> { enum { index = 2 }; }; + +template<> struct tnlSubentityVertex< tnlMeshHexahedronTopology, tnlMeshEdgeTopology, 2, 0> { enum { index = 2 }; }; +template<> struct tnlSubentityVertex< tnlMeshHexahedronTopology, tnlMeshEdgeTopology, 2, 1> { enum { index = 3 }; }; + +template<> struct tnlSubentityVertex< tnlMeshHexahedronTopology, tnlMeshEdgeTopology, 3, 0> { enum { index = 3 }; }; +template<> struct tnlSubentityVertex< tnlMeshHexahedronTopology, tnlMeshEdgeTopology, 3, 1> { enum { index = 0 }; }; + +template<> struct tnlSubentityVertex< tnlMeshHexahedronTopology, tnlMeshEdgeTopology, 4, 0> { enum { index = 0 }; }; +template<> struct tnlSubentityVertex< tnlMeshHexahedronTopology, tnlMeshEdgeTopology, 4, 1> { enum { index = 4 }; }; + +template<> struct tnlSubentityVertex< tnlMeshHexahedronTopology, tnlMeshEdgeTopology, 5, 0> { enum { index = 1 }; }; +template<> struct tnlSubentityVertex< tnlMeshHexahedronTopology, tnlMeshEdgeTopology, 5, 1> { enum { index = 5 }; }; + +template<> struct tnlSubentityVertex< tnlMeshHexahedronTopology, tnlMeshEdgeTopology, 6, 0> { enum { index = 2 }; }; +template<> struct tnlSubentityVertex< tnlMeshHexahedronTopology, tnlMeshEdgeTopology, 6, 1> { enum { index = 6 }; }; + +template<> struct tnlSubentityVertex< tnlMeshHexahedronTopology, tnlMeshEdgeTopology, 7, 0> { enum { index = 3 }; }; +template<> struct tnlSubentityVertex< tnlMeshHexahedronTopology, tnlMeshEdgeTopology, 7, 1> { enum { index = 7 }; }; + +template<> struct tnlSubentityVertex< tnlMeshHexahedronTopology, tnlMeshEdgeTopology, 8, 0> { enum { index = 4 }; }; +template<> struct tnlSubentityVertex< tnlMeshHexahedronTopology, tnlMeshEdgeTopology, 8, 1> { enum { index = 5 }; }; + +template<> struct tnlSubentityVertex< tnlMeshHexahedronTopology, tnlMeshEdgeTopology, 9, 0> { enum { index = 5 }; }; +template<> struct tnlSubentityVertex< tnlMeshHexahedronTopology, tnlMeshEdgeTopology, 9, 1> { enum { index = 6 }; }; + +template<> struct tnlSubentityVertex< tnlMeshHexahedronTopology, tnlMeshEdgeTopology, 10, 0> { enum { index = 6 }; }; +template<> struct tnlSubentityVertex< tnlMeshHexahedronTopology, tnlMeshEdgeTopology, 10, 1> { enum { index = 7 }; }; + +template<> struct tnlSubentityVertex< tnlMeshHexahedronTopology, tnlMeshEdgeTopology, 11, 0> { enum { index = 7 }; }; +template<> struct tnlSubentityVertex< tnlMeshHexahedronTopology, tnlMeshEdgeTopology, 11, 1> { enum { index = 4 }; }; + + +template<> struct tnlSubentityVertex< tnlMeshHexahedronTopology, tnlMeshQuadrilateralTopology, 0, 0> { enum { index = 0 }; }; +template<> struct tnlSubentityVertex< tnlMeshHexahedronTopology, tnlMeshQuadrilateralTopology, 0, 1> { enum { index = 1 }; }; +template<> struct tnlSubentityVertex< tnlMeshHexahedronTopology, tnlMeshQuadrilateralTopology, 0, 2> { enum { index = 2 }; }; +template<> struct tnlSubentityVertex< tnlMeshHexahedronTopology, tnlMeshQuadrilateralTopology, 0, 3> { enum { index = 3 }; }; + +template<> struct tnlSubentityVertex< tnlMeshHexahedronTopology, tnlMeshQuadrilateralTopology, 1, 0> { enum { index = 0 }; }; +template<> struct tnlSubentityVertex< tnlMeshHexahedronTopology, tnlMeshQuadrilateralTopology, 1, 1> { enum { index = 1 }; }; +template<> struct tnlSubentityVertex< tnlMeshHexahedronTopology, tnlMeshQuadrilateralTopology, 1, 2> { enum { index = 5 }; }; +template<> struct tnlSubentityVertex< tnlMeshHexahedronTopology, tnlMeshQuadrilateralTopology, 1, 3> { enum { index = 4 }; }; + +template<> struct tnlSubentityVertex< tnlMeshHexahedronTopology, tnlMeshQuadrilateralTopology, 2, 0> { enum { index = 1 }; }; +template<> struct tnlSubentityVertex< tnlMeshHexahedronTopology, tnlMeshQuadrilateralTopology, 2, 1> { enum { index = 2 }; }; +template<> struct tnlSubentityVertex< tnlMeshHexahedronTopology, tnlMeshQuadrilateralTopology, 2, 2> { enum { index = 6 }; }; +template<> struct tnlSubentityVertex< tnlMeshHexahedronTopology, tnlMeshQuadrilateralTopology, 2, 3> { enum { index = 5 }; }; + +template<> struct tnlSubentityVertex< tnlMeshHexahedronTopology, tnlMeshQuadrilateralTopology, 3, 0> { enum { index = 2 }; }; +template<> struct tnlSubentityVertex< tnlMeshHexahedronTopology, tnlMeshQuadrilateralTopology, 3, 1> { enum { index = 3 }; }; +template<> struct tnlSubentityVertex< tnlMeshHexahedronTopology, tnlMeshQuadrilateralTopology, 3, 2> { enum { index = 7 }; }; +template<> struct tnlSubentityVertex< tnlMeshHexahedronTopology, tnlMeshQuadrilateralTopology, 3, 3> { enum { index = 6 }; }; + +template<> struct tnlSubentityVertex< tnlMeshHexahedronTopology, tnlMeshQuadrilateralTopology, 4, 0> { enum { index = 3 }; }; +template<> struct tnlSubentityVertex< tnlMeshHexahedronTopology, tnlMeshQuadrilateralTopology, 4, 1> { enum { index = 0 }; }; +template<> struct tnlSubentityVertex< tnlMeshHexahedronTopology, tnlMeshQuadrilateralTopology, 4, 2> { enum { index = 4 }; }; +template<> struct tnlSubentityVertex< tnlMeshHexahedronTopology, tnlMeshQuadrilateralTopology, 4, 3> { enum { index = 7 }; }; + +template<> struct tnlSubentityVertex< tnlMeshHexahedronTopology, tnlMeshQuadrilateralTopology, 5, 0> { enum { index = 4 }; }; +template<> struct tnlSubentityVertex< tnlMeshHexahedronTopology, tnlMeshQuadrilateralTopology, 5, 1> { enum { index = 5 }; }; +template<> struct tnlSubentityVertex< tnlMeshHexahedronTopology, tnlMeshQuadrilateralTopology, 5, 2> { enum { index = 6 }; }; +template<> struct tnlSubentityVertex< tnlMeshHexahedronTopology, tnlMeshQuadrilateralTopology, 5, 3> { enum { index = 7 }; }; + +#endif /* TNLMESHHEXAHEDRONTOPOLOGY_H_ */ diff --git a/src/mesh/topologies/tnlMeshQuadrilateralTag.h b/src/mesh/topologies/tnlMeshQuadrilateralTopology.h similarity index 51% rename from src/mesh/topologies/tnlMeshQuadrilateralTag.h rename to src/mesh/topologies/tnlMeshQuadrilateralTopology.h index 71b5efe7d4395431aac58982ddc1ad4c79890833..7c09f35ee8e4ba0bbe05f3c7931d748070f08e5e 100644 --- a/src/mesh/topologies/tnlMeshQuadrilateralTag.h +++ b/src/mesh/topologies/tnlMeshQuadrilateralTopology.h @@ -1,5 +1,5 @@ /*************************************************************************** - tnlMeshQuadrilateralTag.h - description + tnlMeshQuadrilateralTopology.h - description ------------------- begin : Feb 11, 2014 copyright : (C) 2014 by Tomas Oberhuber @@ -15,31 +15,31 @@ * * ***************************************************************************/ -#ifndef TNLMESHQUADRILATERALTAG_H_ -#define TNLMESHQUADRILATERALTAG_H_ +#ifndef TNLMESHQUADRILATERALTOPOLOGY_H_ +#define TNLMESHQUADRILATERALTOPOLOGY_H_ -#include <mesh/topologies/tnlMeshEdgeTag.h> +#include <mesh/topologies/tnlMeshEdgeTopology.h> -struct tnlMeshQuadrilateralTag +struct tnlMeshQuadrilateralTopology { - enum { dimensions = 2 }; + static const int dimensions = 2; }; template<> -struct tnlSubentities< tnlMeshQuadrilateralTag, 0> +struct tnlMeshSubtopology< tnlMeshQuadrilateralTopology, 0 > { - typedef tnlMeshVertexTag Tag; + typedef tnlMeshVertexTopology Topology; - enum { count = 4 }; + static const int count = 4; }; template<> -struct tnlSubentities< tnlMeshQuadrilateralTag, 1> +struct tnlMeshSubtopology< tnlMeshQuadrilateralTopology, 1 > { - typedef tnlMeshEdgeTag Tag; + typedef tnlMeshEdgeTopology Topology; - enum { count = 4 }; + static const int count = 4; }; @@ -70,17 +70,17 @@ struct tnlSubentities< tnlMeshQuadrilateralTag, 1> * */ -template<> struct tnlSubentityVertex< tnlMeshQuadrilateralTag, tnlMeshEdgeTag, 0, 0> { enum { index = 0 }; }; -template<> struct tnlSubentityVertex< tnlMeshQuadrilateralTag, tnlMeshEdgeTag, 0, 1> { enum { index = 1 }; }; +template<> struct tnlSubentityVertex< tnlMeshQuadrilateralTopology, tnlMeshEdgeTopology, 0, 0> { enum { index = 0 }; }; +template<> struct tnlSubentityVertex< tnlMeshQuadrilateralTopology, tnlMeshEdgeTopology, 0, 1> { enum { index = 1 }; }; -template<> struct tnlSubentityVertex< tnlMeshQuadrilateralTag, tnlMeshEdgeTag, 1, 0> { enum { index = 1 }; }; -template<> struct tnlSubentityVertex< tnlMeshQuadrilateralTag, tnlMeshEdgeTag, 1, 1> { enum { index = 2 }; }; +template<> struct tnlSubentityVertex< tnlMeshQuadrilateralTopology, tnlMeshEdgeTopology, 1, 0> { enum { index = 1 }; }; +template<> struct tnlSubentityVertex< tnlMeshQuadrilateralTopology, tnlMeshEdgeTopology, 1, 1> { enum { index = 2 }; }; -template<> struct tnlSubentityVertex< tnlMeshQuadrilateralTag, tnlMeshEdgeTag, 2, 0> { enum { index = 2 }; }; -template<> struct tnlSubentityVertex< tnlMeshQuadrilateralTag, tnlMeshEdgeTag, 2, 1> { enum { index = 3 }; }; +template<> struct tnlSubentityVertex< tnlMeshQuadrilateralTopology, tnlMeshEdgeTopology, 2, 0> { enum { index = 2 }; }; +template<> struct tnlSubentityVertex< tnlMeshQuadrilateralTopology, tnlMeshEdgeTopology, 2, 1> { enum { index = 3 }; }; -template<> struct tnlSubentityVertex< tnlMeshQuadrilateralTag, tnlMeshEdgeTag, 3, 0> { enum { index = 3 }; }; -template<> struct tnlSubentityVertex< tnlMeshQuadrilateralTag, tnlMeshEdgeTag, 3, 1> { enum { index = 0 }; }; +template<> struct tnlSubentityVertex< tnlMeshQuadrilateralTopology, tnlMeshEdgeTopology, 3, 0> { enum { index = 3 }; }; +template<> struct tnlSubentityVertex< tnlMeshQuadrilateralTopology, tnlMeshEdgeTopology, 3, 1> { enum { index = 0 }; }; -#endif /* TNLMESHQUADRILATERALTAG_H_ */ +#endif /* TNLMESHQUADRILATERALTOPOLOGY_H_ */ diff --git a/src/mesh/topologies/tnlMeshSimplexTopology.h b/src/mesh/topologies/tnlMeshSimplexTopology.h new file mode 100644 index 0000000000000000000000000000000000000000..0089c036709de66b8df1238b51df37d989f1275b --- /dev/null +++ b/src/mesh/topologies/tnlMeshSimplexTopology.h @@ -0,0 +1,188 @@ +/*************************************************************************** + tnlMeshSimplexTopology.h - description + ------------------- + begin : Aug 29, 2015 + copyright : (C) 2015 by Tomas Oberhuber et al. + 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 TNLMESHSIMPLEXTOPOLOGY_H +#define TNLMESHSIMPLEXTOPOLOGY_H + + +template< int dimensions_ > +class tnlMeshSimplexTopology +{ + public: + static const int dimensions = dimensions_; +}; + +template< unsigned int n, unsigned int k > +class tnlStaticNumCombinations; + +template<unsigned int n, unsigned int k, unsigned int combinationIndex, unsigned int valueIndex> +class tnlCombinationValue; + +template< int dimensions, + int subtopologyDim > +class tnlMeshSubtopology< tnlMeshSimplexTopology< dimensions >, subtopologyDim > +{ + static_assert( 0 < subtopologyDim && subtopologyDim < dim, "invalid subtopology dimension" ); + + static const int topologyVertexCount = tnlMeshSubtopology< tnlMeshSimplexTopology< dimensions >, 0 >::count; + static const int subtopologyVertexCount = tnlMeshSubtopology< tnlMeshSimplexTopology< subtopologyDim >, 0>::count; + + public: + typedef tnlMeshSimplexTopology< subtopologyDim > Topology; + + static const int count = tnlNumCombinations< topologyVertexCount, subtopologyVertexCount >::value; +}; + +template< int dimensions > +class tnlMeshSubtopology< tnlMeshSimplexTopology< dimensions >, 0 > +{ + static_assert(0 < dim, "invalid dimension"); + + public: + typedef tnlMeshVertexTopology Topology; + + static const int count = dim + 1; +}; + + +template< int dimensions, + typename Subtopology, + int subtopologyIndex, + int vertexIndex > +struct tnlSubentityVertex< tnlMeshSimplexTopology< dimensions >, Subtopology, subtopologyIndex, vertexIndex > +{ + private: + static const int subtopologyCount = Subtopology< tnlMeshSimplexTopology< dimensions >, Subtopology::dimensions >::count; + static const int topologyVertexCount = Subtopology< tnlMeshSimplex< dimensions >, 0 >::count; + static const int subtopologyVertexCount = Subtopology< Subtopology, 0 >::count; + + static_assert(1 < dimensions, "subtopology vertex can be specified for topologies of dimension 2 or higher"); + static_assert(0 <= subtopologyIndex && subtopologyIndex < subtopologyCount, "invalid subtopology index"); + static_assert(0 <= vertexIndex && vertexIndex < subtopologyVertexCount, "invalid subtopology vertex index"); + + public: + static const int index = CombinationValue< topologyVertexCount, subtopologyVertexCount, subtopologyIndex, vertexIndex>::value; +}; + +template< unsigned int n, unsigned int k > +class tnlStaticNumCombinations +{ + static_assert(0 < k && k < n, "invalid argument"); + + public: + static const unsigned int value = tnlNumCombinations< n - 1, k - 1 >::value + tnlNumCombinations< n - 1, k >::value; +}; + +// Nummber of combinations (n choose k) +template< unsigned int n > +class tnlNumCombinations< n, 0 > +{ + static_assert(0 <= n, "invalid argument"); + + public: + static const unsigned int value = 1; +}; + +template< unsigned int n > +class tnlNumCombinations< n, n > +{ + static_assert(0 < n, "invalid argument"); + + public: + static const unsigned int value = 1; +}; + +// Compile-time generation of combinations +// Combinations are generated in lexicographical order. The following example shows generation of 2-combinations from set {0, 1, 2}: +// 0, 1 <-> CombinationValue<3, 2, 0, 0>::VALUE, CombinationValue<3, 2, 0, 1>::VALUE +// 0, 2 <-> CombinationValue<3, 2, 1, 0>::VALUE, CombinationValue<3, 2, 1, 1>::VALUE +// 1, 2 <-> CombinationValue<3, 2, 2, 0>::VALUE, CombinationValue<3, 2, 2, 1>::VALUE +template< unsigned int n, + unsigned int k, + unsigned int combinationIndex > +class tnlCombinationIncrement; + +template< unsigned int n, + unsigned int k, + unsigned int combinationIndex, + unsigned int valueIndex > +class tnlCombinationValue +{ + static_assert( combinationIndex < NumCombinations< n, k >::value, "invalid combination index" ); + static_assert( valueIndex < k, "invalid value index" ); + + static const unsigned int incrementValueIndex = tnlCombinationIncrement< n, k, combinationIndex - 1>::valueIndex; + + public: + static const unsigned int value = ( valueIndex < incrementValueIndex ? tnlCombinationValue< n, k, combinationIndex - 1, valueIndex >::value : + tnlCombinationValue< n, k, combinationIndex - 1, incrementValueIndex >::value + + valueIndex - incrementValueIndex + 1); +}; + +template< unsigned int n, + unsigned int k, + unsigned int valueIndex > +class tnlCombinationValue< n, k, 0, valueIndex > +{ + static_assert( valueIndex < k, "invalid value index" ); + + static const unsigned int incrementValueIndex = tnlCombinationIncrement< n, k, 0 >::valueIndex; + + public: + static const unsigned int value = valueIndex; +}; + +// The CombinationIncrement class determines value index of the particular combination which will be incremented when generating the next combination +template< unsigned int n, + unsigned int k, + unsigned int combinationIndex, + unsigned int valueIndex > +class tnlCombinationIncrementImpl +{ + static_assert( combinationIndex < tnlNumCombinations< n, k >::value - 1, "nothing to increment" ); + + static const bool incrementPossible = ( tnlCombinationValue< n, k, combinationIndex, valueIndex >::value + k - valueIndex < n ); + + public: + static const int valueIndex = ( incrementPossible ? valueIndex : tnlCombinationIncrementImpl< n, k, combinationIndex, valueIndex - 1 >::valueIndex ); +}; + +template< unsigned int n, + unsigned int k, + unsigned int combinationIndex > +class tnlCombinationIncrementImpl< n, k, combinationIndex, 0 > +{ + static_assert( combinationIndex < tnlNumCombinations<n, k>::value - 1, "nothing to increment" ); + + public: + static const int valueIndex = 0; +}; + +template< unsigned int n, + unsigned int k, + unsigned int combinationIndex > +class tnlCombinationIncrement +{ + static_assert( combinationIndex < tnlNumCombinations< n, k >::value - 1, "nothing to increment" ); + + public: + static const unsigned int valueIndex = tnlCombinationIncrementImpl< n, k, combinationIndex, k - 1 >::valueIndex; +}; + +#endif /* TNLMESHSIMPLEXTOPOLOGY_H */ + diff --git a/src/mesh/topologies/tnlMeshSubtopology.h b/src/mesh/topologies/tnlMeshSubtopology.h new file mode 100644 index 0000000000000000000000000000000000000000..f7b6affed98aa57bf50002094fbfc6ef057b5925 --- /dev/null +++ b/src/mesh/topologies/tnlMeshSubtopology.h @@ -0,0 +1,32 @@ +/*************************************************************************** + tnlMeshSubtopology.h - description + ------------------- + begin : Aug 29, 2015 + copyright : (C) 2015 by Tomas Oberhuber et al. + 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 TNLMESHSUBTOPOLOGY_H +#define TNLMESHSUBTOPOLOGY_H + +template< typename Topology, + int dimensions > +class tnlMeshSubtopology; + +template< typename Topology, + typename Subtopology, + int subtopologyIndex, + int vertexIndex > +struct tnlMeshSubtopologyVertex; + +#endif /* TNLMESHSUBTOPOLOGY_H */ + diff --git a/src/mesh/topologies/tnlMeshTetrahedronTag.h b/src/mesh/topologies/tnlMeshTetrahedronTag.h deleted file mode 100644 index da127168b01553d2e5e4c445ee710edd14304ea4..0000000000000000000000000000000000000000 --- a/src/mesh/topologies/tnlMeshTetrahedronTag.h +++ /dev/null @@ -1,89 +0,0 @@ -/*************************************************************************** - tnlMeshTetrahedronTag.h - description - ------------------- - begin : Feb 11, 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 TNLMESHTETRAHEDRONTAG_H_ -#define TNLMESHTETRAHEDRONTAG_H_ - -#include <mesh/topologies/tnlMeshTriangleTag.h> - -struct tnlMeshTetrahedronTag -{ - enum { dimensions = 3 }; -}; - -template<> -struct tnlSubentities< tnlMeshTetrahedronTag, 0 > -{ - typedef tnlMeshVertexTag Tag; - - enum { count = 4 }; -}; - -template<> -struct tnlSubentities< tnlMeshTetrahedronTag, 1 > -{ - typedef tnlMeshEdgeTag Tag; - - enum { count = 6 }; -}; - -template<> -struct tnlSubentities< tnlMeshTetrahedronTag, 2 > -{ - typedef tnlMeshTriangleTag Tag; - - enum { count = 4 }; -}; - - -template<> struct tnlSubentityVertex< tnlMeshTetrahedronTag, tnlMeshEdgeTag, 0, 0> { enum { index = 1 }; }; -template<> struct tnlSubentityVertex< tnlMeshTetrahedronTag, tnlMeshEdgeTag, 0, 1> { enum { index = 2 }; }; - -template<> struct tnlSubentityVertex< tnlMeshTetrahedronTag, tnlMeshEdgeTag, 1, 0> { enum { index = 2 }; }; -template<> struct tnlSubentityVertex< tnlMeshTetrahedronTag, tnlMeshEdgeTag, 1, 1> { enum { index = 0 }; }; - -template<> struct tnlSubentityVertex< tnlMeshTetrahedronTag, tnlMeshEdgeTag, 2, 0> { enum { index = 0 }; }; -template<> struct tnlSubentityVertex< tnlMeshTetrahedronTag, tnlMeshEdgeTag, 2, 1> { enum { index = 1 }; }; - -template<> struct tnlSubentityVertex< tnlMeshTetrahedronTag, tnlMeshEdgeTag, 3, 0> { enum { index = 0 }; }; -template<> struct tnlSubentityVertex< tnlMeshTetrahedronTag, tnlMeshEdgeTag, 3, 1> { enum { index = 3 }; }; - -template<> struct tnlSubentityVertex< tnlMeshTetrahedronTag, tnlMeshEdgeTag, 4, 0> { enum { index = 1 }; }; -template<> struct tnlSubentityVertex< tnlMeshTetrahedronTag, tnlMeshEdgeTag, 4, 1> { enum { index = 3 }; }; - -template<> struct tnlSubentityVertex< tnlMeshTetrahedronTag, tnlMeshEdgeTag, 5, 0> { enum { index = 2 }; }; -template<> struct tnlSubentityVertex< tnlMeshTetrahedronTag, tnlMeshEdgeTag, 5, 1> { enum { index = 3 }; }; - - -template<> struct tnlSubentityVertex< tnlMeshTetrahedronTag, tnlMeshTriangleTag, 0, 0> { enum { index = 0 }; }; -template<> struct tnlSubentityVertex< tnlMeshTetrahedronTag, tnlMeshTriangleTag, 0, 1> { enum { index = 1 }; }; -template<> struct tnlSubentityVertex< tnlMeshTetrahedronTag, tnlMeshTriangleTag, 0, 2> { enum { index = 2 }; }; - -template<> struct tnlSubentityVertex< tnlMeshTetrahedronTag, tnlMeshTriangleTag, 1, 0> { enum { index = 0 }; }; -template<> struct tnlSubentityVertex< tnlMeshTetrahedronTag, tnlMeshTriangleTag, 1, 1> { enum { index = 1 }; }; -template<> struct tnlSubentityVertex< tnlMeshTetrahedronTag, tnlMeshTriangleTag, 1, 2> { enum { index = 3 }; }; - -template<> struct tnlSubentityVertex< tnlMeshTetrahedronTag, tnlMeshTriangleTag, 2, 0> { enum { index = 1 }; }; -template<> struct tnlSubentityVertex< tnlMeshTetrahedronTag, tnlMeshTriangleTag, 2, 1> { enum { index = 2 }; }; -template<> struct tnlSubentityVertex< tnlMeshTetrahedronTag, tnlMeshTriangleTag, 2, 2> { enum { index = 3 }; }; - -template<> struct tnlSubentityVertex< tnlMeshTetrahedronTag, tnlMeshTriangleTag, 3, 0> { enum { index = 2 }; }; -template<> struct tnlSubentityVertex< tnlMeshTetrahedronTag, tnlMeshTriangleTag, 3, 1> { enum { index = 0 }; }; -template<> struct tnlSubentityVertex< tnlMeshTetrahedronTag, tnlMeshTriangleTag, 3, 2> { enum { index = 3 }; }; - - -#endif /* TNLMESHTETRAHEDRONTAG_H_ */ diff --git a/src/mesh/topologies/tnlMeshTetrahedronTopology.h b/src/mesh/topologies/tnlMeshTetrahedronTopology.h new file mode 100644 index 0000000000000000000000000000000000000000..c5a498d08381bd5035b2a66d3cf2014c9eb1b837 --- /dev/null +++ b/src/mesh/topologies/tnlMeshTetrahedronTopology.h @@ -0,0 +1,89 @@ +/*************************************************************************** + tnlMeshTetrahedronTopology.h - description + ------------------- + begin : Feb 11, 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 TNLMESHTETRAHEDRONTOPOLOGY_H_ +#define TNLMESHTETRAHEDRONTOPOLOGY_H_ + +#include <mesh/topologies/tnlMeshTriangleTopology.h> + +struct tnlMeshTetrahedronTopology +{ + static const int dimensions = 3; +}; + +template<> +struct tnlMeshSubtopology< tnlMeshTetrahedronTopology, 0 > +{ + typedef tnlMeshVertexTopology Topology; + + static const int count = 4; +}; + +template<> +struct tnlMeshSubtopology< tnlMeshTetrahedronTopology, 1 > +{ + typedef tnlMeshEdgeTopology Topology; + + static const int count = 6; +}; + +template<> +struct tnlMeshSubtopology< tnlMeshTetrahedronTopology, 2 > +{ + typedef tnlMeshTriangleTopology Topology; + + static const int count = 4; +}; + + +template<> struct tnlSubentityVertex< tnlMeshTetrahedronTopology, tnlMeshEdgeTopology, 0, 0> { enum { index = 1 }; }; +template<> struct tnlSubentityVertex< tnlMeshTetrahedronTopology, tnlMeshEdgeTopology, 0, 1> { enum { index = 2 }; }; + +template<> struct tnlSubentityVertex< tnlMeshTetrahedronTopology, tnlMeshEdgeTopology, 1, 0> { enum { index = 2 }; }; +template<> struct tnlSubentityVertex< tnlMeshTetrahedronTopology, tnlMeshEdgeTopology, 1, 1> { enum { index = 0 }; }; + +template<> struct tnlSubentityVertex< tnlMeshTetrahedronTopology, tnlMeshEdgeTopology, 2, 0> { enum { index = 0 }; }; +template<> struct tnlSubentityVertex< tnlMeshTetrahedronTopology, tnlMeshEdgeTopology, 2, 1> { enum { index = 1 }; }; + +template<> struct tnlSubentityVertex< tnlMeshTetrahedronTopology, tnlMeshEdgeTopology, 3, 0> { enum { index = 0 }; }; +template<> struct tnlSubentityVertex< tnlMeshTetrahedronTopology, tnlMeshEdgeTopology, 3, 1> { enum { index = 3 }; }; + +template<> struct tnlSubentityVertex< tnlMeshTetrahedronTopology, tnlMeshEdgeTopology, 4, 0> { enum { index = 1 }; }; +template<> struct tnlSubentityVertex< tnlMeshTetrahedronTopology, tnlMeshEdgeTopology, 4, 1> { enum { index = 3 }; }; + +template<> struct tnlSubentityVertex< tnlMeshTetrahedronTopology, tnlMeshEdgeTopology, 5, 0> { enum { index = 2 }; }; +template<> struct tnlSubentityVertex< tnlMeshTetrahedronTopology, tnlMeshEdgeTopology, 5, 1> { enum { index = 3 }; }; + + +template<> struct tnlSubentityVertex< tnlMeshTetrahedronTopology, tnlMeshTriangleTopology, 0, 0> { enum { index = 0 }; }; +template<> struct tnlSubentityVertex< tnlMeshTetrahedronTopology, tnlMeshTriangleTopology, 0, 1> { enum { index = 1 }; }; +template<> struct tnlSubentityVertex< tnlMeshTetrahedronTopology, tnlMeshTriangleTopology, 0, 2> { enum { index = 2 }; }; + +template<> struct tnlSubentityVertex< tnlMeshTetrahedronTopology, tnlMeshTriangleTopology, 1, 0> { enum { index = 0 }; }; +template<> struct tnlSubentityVertex< tnlMeshTetrahedronTopology, tnlMeshTriangleTopology, 1, 1> { enum { index = 1 }; }; +template<> struct tnlSubentityVertex< tnlMeshTetrahedronTopology, tnlMeshTriangleTopology, 1, 2> { enum { index = 3 }; }; + +template<> struct tnlSubentityVertex< tnlMeshTetrahedronTopology, tnlMeshTriangleTopology, 2, 0> { enum { index = 1 }; }; +template<> struct tnlSubentityVertex< tnlMeshTetrahedronTopology, tnlMeshTriangleTopology, 2, 1> { enum { index = 2 }; }; +template<> struct tnlSubentityVertex< tnlMeshTetrahedronTopology, tnlMeshTriangleTopology, 2, 2> { enum { index = 3 }; }; + +template<> struct tnlSubentityVertex< tnlMeshTetrahedronTopology, tnlMeshTriangleTopology, 3, 0> { enum { index = 2 }; }; +template<> struct tnlSubentityVertex< tnlMeshTetrahedronTopology, tnlMeshTriangleTopology, 3, 1> { enum { index = 0 }; }; +template<> struct tnlSubentityVertex< tnlMeshTetrahedronTopology, tnlMeshTriangleTopology, 3, 2> { enum { index = 3 }; }; + + +#endif /* TNLMESHTETRAHEDRONTOPOLOGY_H_ */ diff --git a/src/mesh/topologies/tnlMeshTriangleTag.h b/src/mesh/topologies/tnlMeshTriangleTag.h deleted file mode 100644 index fb629659fdf6d0757a40dcdf73dfa60c13530e2c..0000000000000000000000000000000000000000 --- a/src/mesh/topologies/tnlMeshTriangleTag.h +++ /dev/null @@ -1,56 +0,0 @@ -/*************************************************************************** - tnlMeshTriangleTag.h - description - ------------------- - begin : Feb 11, 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 TNLMESHTRIANGLETAG_H_ -#define TNLMESHTRIANGLETAG_H_ - -#include <mesh/topologies/tnlMeshEdgeTag.h> - -struct tnlMeshTriangleTag -{ - enum { dimensions = 2 }; -}; - - -template<> -struct tnlSubentities< tnlMeshTriangleTag, 0 > -{ - typedef tnlMeshVertexTag Tag; - - enum { count = 3 }; -}; - -template<> -struct tnlSubentities< tnlMeshTriangleTag, 1 > -{ - typedef tnlMeshEdgeTag Tag; - - enum { count = 3 }; -}; - - -template<> struct tnlSubentityVertex< tnlMeshTriangleTag, tnlMeshEdgeTag, 0, 0> { enum { index = 1 }; }; -template<> struct tnlSubentityVertex< tnlMeshTriangleTag, tnlMeshEdgeTag, 0, 1> { enum { index = 2 }; }; - -template<> struct tnlSubentityVertex< tnlMeshTriangleTag, tnlMeshEdgeTag, 1, 0> { enum { index = 2 }; }; -template<> struct tnlSubentityVertex< tnlMeshTriangleTag, tnlMeshEdgeTag, 1, 1> { enum { index = 0 }; }; - -template<> struct tnlSubentityVertex< tnlMeshTriangleTag, tnlMeshEdgeTag, 2, 0> { enum { index = 0 }; }; -template<> struct tnlSubentityVertex< tnlMeshTriangleTag, tnlMeshEdgeTag, 2, 1> { enum { index = 1 }; }; - - -#endif /* TNLMESHTRIANGLETAG_H_ */ diff --git a/src/mesh/topologies/tnlMeshTriangleTopology.h b/src/mesh/topologies/tnlMeshTriangleTopology.h new file mode 100644 index 0000000000000000000000000000000000000000..b80ca06373792d82db5fcb96b97bd5321594f7ca --- /dev/null +++ b/src/mesh/topologies/tnlMeshTriangleTopology.h @@ -0,0 +1,56 @@ +/*************************************************************************** + tnlMeshTriangleTopology.h - description + ------------------- + begin : Feb 11, 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 TNLMESHTRIANGLETOPOLOGY_H_ +#define TNLMESHTRIANGLETOPOLOGY_H_ + +#include <mesh/topologies/tnlMeshEdgeTopology.h> + +struct tnlMeshTriangleTopology +{ + static const int dimensions = 2; +}; + + +template<> +struct tnlMeshSubtopology< tnlMeshTriangleTopology, 0 > +{ + typedef tnlMeshVertexTopology Topology; + + static const int count = 3; +}; + +template<> +struct tnlMeshSubtopology< tnlMeshTriangleTopology, 1 > +{ + typedef tnlMeshEdgeTopology Topology; + + static const int count = 3; +}; + + +template<> struct tnlSubentityVertex< tnlMeshTriangleTopology, tnlMeshEdgeTopology, 0, 0> { enum { index = 1 }; }; +template<> struct tnlSubentityVertex< tnlMeshTriangleTopology, tnlMeshEdgeTopology, 0, 1> { enum { index = 2 }; }; + +template<> struct tnlSubentityVertex< tnlMeshTriangleTopology, tnlMeshEdgeTopology, 1, 0> { enum { index = 2 }; }; +template<> struct tnlSubentityVertex< tnlMeshTriangleTopology, tnlMeshEdgeTopology, 1, 1> { enum { index = 0 }; }; + +template<> struct tnlSubentityVertex< tnlMeshTriangleTopology, tnlMeshEdgeTopology, 2, 0> { enum { index = 0 }; }; +template<> struct tnlSubentityVertex< tnlMeshTriangleTopology, tnlMeshEdgeTopology, 2, 1> { enum { index = 1 }; }; + + +#endif /* TNLMESHTRIANGLETOPOLOGY_H_ */ diff --git a/src/mesh/topologies/tnlMeshVertexTag.h b/src/mesh/topologies/tnlMeshVertexTopology.h similarity index 80% rename from src/mesh/topologies/tnlMeshVertexTag.h rename to src/mesh/topologies/tnlMeshVertexTopology.h index 4737680768d9406cb45aabbe54cd1b8fc33aee6f..6fc81f962ca756886a94fb5061d594a494e6d690 100644 --- a/src/mesh/topologies/tnlMeshVertexTag.h +++ b/src/mesh/topologies/tnlMeshVertexTopology.h @@ -1,5 +1,5 @@ /*************************************************************************** - tnlMeshVertexTag.h - description + tnlMeshVertexTopology.h - description ------------------- begin : Feb 11, 2014 copyright : (C) 2014 by Tomas Oberhuber @@ -15,13 +15,13 @@ * * ***************************************************************************/ -#ifndef TNLMESHVERTEXTAG_H_ -#define TNLMESHVERTEXTAG_H_ +#ifndef TNLMESHVERTEXTOPOLOGY_H_ +#define TNLMESHVERTEXTOPOLOGY_H_ -struct tnlMeshVertexTag +struct tnlMeshVertexTopology { - enum { dimensions = 0 }; + static const int dimensions = 0; }; -#endif /* TNLMESHVERTEXTAG_H_ */ +#endif /* TNLMESHVERTEXTOPOLOGY_H_ */ diff --git a/src/mesh/traits/CMakeLists.txt b/src/mesh/traits/CMakeLists.txt index acf4304f70e27b7ef1e5d12175a9e8223e49aca5..48652e0c02dd57dbbd0b049fd3c24fcc8f6c693a 100755 --- a/src/mesh/traits/CMakeLists.txt +++ b/src/mesh/traits/CMakeLists.txt @@ -1,10 +1,7 @@ -SET( headers tnlDimensionsTraits.h - tnlMeshTraits.h - tnlStorageTraits.h - tnlMeshEntitiesTraits.h - tnlMeshEntitiesTag.h - tnlMeshSubentitiesTraits.h - tnlMeshSuperentitiesTraits.h +SET( headers tnlMeshTraits.h + tnlMeshEntityTraits.h + tnlMeshSubentityTraits.h + tnlMeshSuperentityTraits.h ) INSTALL( FILES ${headers} DESTINATION include/tnl-${tnlVersion}/mesh/traits ) \ No newline at end of file diff --git a/src/mesh/traits/tnlMeshEntitiesTraits.h b/src/mesh/traits/tnlMeshEntitiesTraits.h deleted file mode 100644 index bc6217b57c0db47abe16e373b2f2bd1ac64912b0..0000000000000000000000000000000000000000 --- a/src/mesh/traits/tnlMeshEntitiesTraits.h +++ /dev/null @@ -1,56 +0,0 @@ -/*************************************************************************** - tnlMeshEntitiesTraits.h - description - ------------------- - begin : Feb 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 TNLMESHENTITIESTRAITS_H_ -#define TNLMESHENTITIESTRAITS_H_ - -#include <core/arrays/tnlArray.h> -#include <core/arrays/tnlConstSharedArray.h> -#include <core/tnlIndexedSet.h> -#include <mesh/traits/tnlMeshEntitiesTag.h> -#include <mesh/config/tnlMeshConfigBase.h> -#include <mesh/tnlMeshEntityKey.h> - -template< typename ConfigTag, - typename DimensionsTraits > -class tnlMeshEntitiesTraits -{ - enum { storageEnabled = tnlMeshEntityStorage< ConfigTag, - DimensionsTraits::value>::enabled }; - - typedef typename ConfigTag::GlobalIndexType GlobalIndexType; - typedef typename ConfigTag::LocalIndexType LocalIndexType; - typedef typename tnlMeshEntitiesTag< ConfigTag, - DimensionsTraits >::Tag EntityTag; - typedef tnlMeshEntityKey< ConfigTag, EntityTag > Key; - - public: - - typedef EntityTag Tag; - typedef tnlMeshEntity< ConfigTag, Tag > Type; - - typedef tnlStorageTraits< storageEnabled > EntityStorageTag; - - typedef tnlArray< Type, tnlHost, GlobalIndexType > ContainerType; - typedef tnlSharedArray< Type, tnlHost, GlobalIndexType > SharedContainerType; - typedef tnlIndexedSet< Type, GlobalIndexType, Key > UniqueContainerType; - - typedef tnlConstSharedArray< Type, tnlHost, GlobalIndexType > SharedArrayType; -}; - - -#endif /* TNLMESHENTITIESTRAITS_H_ */ diff --git a/src/mesh/traits/tnlMeshEntityTraits.h b/src/mesh/traits/tnlMeshEntityTraits.h new file mode 100644 index 0000000000000000000000000000000000000000..6d5cc225cc9efe774c1f0052f199aa108e0ddb52 --- /dev/null +++ b/src/mesh/traits/tnlMeshEntityTraits.h @@ -0,0 +1,92 @@ +/*************************************************************************** + tnlMeshEntityTraits.h - description + ------------------- + begin : Feb 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 TNLMESHENTITYTRAITS_H_ +#define TNLMESHENTITYTRAITS_H_ + +#include <core/vectors/tnlStaticVector.h> +#include <core/arrays/tnlArray.h> +#include <core/arrays/tnlSharedArray.h> +#include <core/arrays/tnlConstSharedArray.h> +#include <core/tnlIndexedSet.h> +#include <mesh/topologies/tnlMeshEntityTopology.h> +#include <mesh/config/tnlMeshConfigBase.h> +#include <mesh/traits/tnlMeshTraits.h> + +template< typename MeshConfig, typename EntityTopology > class tnlMeshEntity; +template< typename MeshConfig, typename EntityTopology > class tnlMeshEntitySeed; +template< typename MeshConfig, typename EntityTopology > class tnlMeshEntitySeedKey; +template< typename MeshConfig, typename EntityTopology > class tnlMeshEntityReferenceOrientation; + +template< typename MeshConfig, + typename DimensionsTag, + typename SuperDimensionsTag = tnlDimensionsTag< MeshConfig::meshDimensions > > +class tnlMeshEntityOrientationNeeded +{ + static_assert( 0 <= DimensionsTag::value && DimensionsTag::value < MeshConfig::CellTopology::dimensions, "invalid dimensions" ); + static_assert( DimensionsTag::value < SuperDimensionsTag::value && SuperDimensionsTag::value <= MeshConfig::CellTopology::dimensions, "invalid superentity dimensions"); + + typedef typename tnlMeshTraits< MeshConfig >::template EntityTraits< SuperDimensionsTag::value >::EntityTopology SuperentityTopology; + + static const bool previousSuperDimensionsValue = tnlMeshEntityOrientationNeeded< MeshConfig, DimensionsTag, typename SuperDimensionsTag::Decrement >::value; + static const bool thisSuperDimensionsValue = tnlMeshTraits< MeshConfig >::template SubentityTraits< SuperentityTopology, DimensionsTag::value >::orientationEnabled; + + public: + static const bool value = ( previousSuperDimensionsValue || thisSuperDimensionsValue ); +}; + +template< typename MeshConfig, typename DimensionsTag > +class tnlMeshEntityOrientationNeeded< MeshConfig, DimensionsTag, DimensionsTag > +{ + static_assert( 0 <= DimensionsTag::value && DimensionsTag::value <= MeshConfig::CellTopology::dimensions, "invalid dimensions" ); + + public: + static const bool value = false; +}; + + +template< typename MeshConfig, + int Dimensions > +class tnlMeshEntityTraits +{ + public: + + static const bool storageEnabled = MeshConfig::entityStorage( Dimensions ); + static const bool orientationNeeded = tnlMeshEntityOrientationNeeded< MeshConfig, tnlDimensionsTag< Dimensions > >::value; + + typedef typename MeshConfig::GlobalIndexType GlobalIndexType; + typedef typename MeshConfig::LocalIndexType LocalIndexType; + typedef typename tnlMeshEntityTopology< MeshConfig, Dimensions >::Topology EntityTopology; + + typedef tnlMeshEntity< MeshConfig, EntityTopology > EntityType; + typedef tnlMeshEntitySeed< MeshConfig, EntityTopology > SeedType; + typedef tnlMeshEntityReferenceOrientation< MeshConfig, EntityTopology > ReferenceOrientationType; + typedef tnlMeshEntitySeedKey< MeshConfig, EntityTopology > Key; + + + typedef tnlArray< EntityType, tnlHost, GlobalIndexType > StorageArrayType; + typedef tnlSharedArray< EntityType, tnlHost, GlobalIndexType > AccessArrayType; + typedef tnlIndexedSet< EntityType, GlobalIndexType, Key > UniqueContainerType; + typedef tnlIndexedSet< SeedType, GlobalIndexType, Key > SeedIndexedSetType; + typedef tnlArray< SeedType, tnlHost, GlobalIndexType > SeedArrayType; + typedef tnlArray< ReferenceOrientationType, tnlHost, GlobalIndexType > ReferenceOrientationArrayType; + + typedef tnlConstSharedArray< EntityType, tnlHost, GlobalIndexType > SharedArrayType; +}; + + +#endif /* TNLMESHENTITYTRAITS_H_ */ diff --git a/src/mesh/traits/tnlMeshSubentitiesTraits.h b/src/mesh/traits/tnlMeshSubentitiesTraits.h deleted file mode 100644 index b520d32f4a0d719878634bfa6ab4e85570cbaba5..0000000000000000000000000000000000000000 --- a/src/mesh/traits/tnlMeshSubentitiesTraits.h +++ /dev/null @@ -1,68 +0,0 @@ -/*************************************************************************** - tnlMeshSubentitiesTraits.h - description - ------------------- - begin : Feb 12, 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 TNLMESHSUBENTITIESTRAITS_H_ -#define TNLMESHSUBENTITIESTRAITS_H_ - -#include <core/arrays/tnlStaticArray.h> -#include <core/arrays/tnlSharedArray.h> -#include <mesh/tnlMeshEntity.h> -#include <mesh/config/tnlMeshConfigBase.h> -#include <mesh/topologies/tnlMeshEntityTopology.h> - -template< typename ConfigTag, - typename EntityTag, - typename DimensionsTraits > -class tnlMeshSubentitiesTraits -{ - enum { storageEnabled = tnlMeshSubentityStorage< ConfigTag, - EntityTag, - DimensionsTraits::value >::enabled }; - - typedef typename ConfigTag::GlobalIndexType GlobalIndexType; - typedef typename ConfigTag::LocalIndexType LocalIndexType; - typedef tnlSubentities< EntityTag, DimensionsTraits::value > Tag; - -public: - typedef tnlMeshEntity< ConfigTag, EntityTag > EntityType; - typedef typename Tag::Tag SubentityTag; - typedef tnlMeshEntity< ConfigTag, SubentityTag > SubentityType; - - typedef tnlStorageTraits< storageEnabled > SubentityStorageTag; - - enum { count = Tag::count }; - - typedef tnlStaticArray< count, GlobalIndexType > ContainerType; - typedef tnlSharedArray< GlobalIndexType, - tnlHost, - LocalIndexType > SharedContainerType; - typedef tnlStaticArray< count, SubentityType > SubentityContainerType; - - template< LocalIndexType subentityIndex, - LocalIndexType subentityVertexIndex > - struct Vertex - { - enum { index = tnlSubentityVertex< EntityTag, - SubentityTag, - subentityIndex, - subentityVertexIndex>::index }; - }; -}; - - - -#endif /* TNLMESHSUBENTITIESTRAITS_H_ */ diff --git a/src/mesh/traits/tnlMeshSubentityTraits.h b/src/mesh/traits/tnlMeshSubentityTraits.h new file mode 100644 index 0000000000000000000000000000000000000000..d23c19c69dde59a23afad7ebef5c5e5070dd185c --- /dev/null +++ b/src/mesh/traits/tnlMeshSubentityTraits.h @@ -0,0 +1,75 @@ +/*************************************************************************** + tnlMeshSubentityTraits.h - description + ------------------- + begin : Feb 12, 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 TNLMESHSUBENTITYTRAITS_H_ +#define TNLMESHSUBENTITYTRAITS_H_ + +#include <core/arrays/tnlStaticArray.h> +#include <core/arrays/tnlSharedArray.h> +#include <mesh/tnlMeshEntity.h> +#include <mesh/config/tnlMeshConfigBase.h> +#include <mesh/topologies/tnlMeshEntityTopology.h> + + +template< typename MeshConfig, typename EntityTopology > class tnlMeshEntityOrientation; + +template< typename MeshConfig, + typename EntityTopology, + int Dimensions > +class tnlMeshSubentityTraits +{ + public: + static const bool storageEnabled = MeshConfig::subentityStorage( EntityTopology(), Dimensions ); + static const bool orientationEnabled = MeshConfig::subentityOrientationStorage( EntityTopology(), Dimensions ); + + typedef typename MeshConfig::GlobalIndexType GlobalIndexType; + typedef typename MeshConfig::LocalIndexType LocalIndexType; + typedef tnlMeshSubtopology< EntityTopology, Dimensions > Subtopology; + typedef typename Subtopology::Topology SubentityTopology; + typedef tnlMeshEntity< MeshConfig, SubentityTopology > SubentityType; + typedef tnlMeshEntitySeed< MeshConfig, SubentityTopology > Seed; + typedef tnlMeshEntityOrientation< MeshConfig, SubentityTopology > Orientation; + + + static const int count = Subtopology::count; + + typedef tnlStaticArray< count, GlobalIndexType > StorageArrayType; + typedef tnlSharedArray< GlobalIndexType, + tnlHost, + LocalIndexType > AccessArrayType; + typedef tnlStaticArray< count, GlobalIndexType > IdArrayType; + typedef tnlStaticArray< count, SubentityType > SubentityContainerType; + typedef tnlStaticArray< count, Seed > SeedArrayType; + typedef tnlStaticArray< count, Orientation > OrientationArrayType; + typedef tnlStaticArray< count, LocalIndexType > IdPermutationArrayType; + + template< LocalIndexType subentityIndex, + LocalIndexType subentityVertexIndex > + struct Vertex + { + enum { index = tnlSubentityVertex< EntityTopology, + SubentityTopology, + subentityIndex, + subentityVertexIndex>::index }; + }; + + static_assert( EntityTopology::dimensions > Dimensions, "You try to create subentities traits where subentity dimensions are not smaller than the entity dimensions." ); +}; + + + +#endif /* TNLMESHSUBENTITYTRAITS_H_ */ diff --git a/src/mesh/traits/tnlMeshSuperentitiesTraits.h b/src/mesh/traits/tnlMeshSuperentityTraits.h similarity index 54% rename from src/mesh/traits/tnlMeshSuperentitiesTraits.h rename to src/mesh/traits/tnlMeshSuperentityTraits.h index 3946114bd57242b0d32e426d328370aa81a44b45..9195241fb2fa4a87e860e1cac77ff5c42a14b29d 100644 --- a/src/mesh/traits/tnlMeshSuperentitiesTraits.h +++ b/src/mesh/traits/tnlMeshSuperentityTraits.h @@ -1,5 +1,5 @@ /*************************************************************************** - tnlMeshSuperentitiesTraits.h - description + tnlMeshSuperentityTraits.h - description ------------------- begin : Feb 13, 2014 copyright : (C) 2014 by Tomas Oberhuber @@ -15,8 +15,8 @@ * * ***************************************************************************/ -#ifndef TNLMESHSUPERENTITIESTRAITS_H_ -#define TNLMESHSUPERENTITIESTRAITS_H_ +#ifndef TNLMESHSUPERENTITYTRAITS_H_ +#define TNLMESHSUPERENTITYTRAITS_H_ #include <core/arrays/tnlArray.h> #include <core/arrays/tnlConstSharedArray.h> @@ -24,43 +24,43 @@ #include <mesh/tnlMeshEntity.h> #include <mesh/config/tnlMeshConfigBase.h> #include <mesh/topologies/tnlMeshEntityTopology.h> -#include <mesh/traits/tnlMeshEntitiesTraits.h> +#include <mesh/traits/tnlMeshEntityTraits.h> +#include <core/multimaps/tnlEllpackIndexMultimap.h> +#include <mesh/layers/tnlMeshSuperentityAccessor.h> -template< typename ConfigTag, - typename EntityTag, - typename DimensionsTraits > -class tnlMeshSuperentitiesTraits +template< typename MeshConfig, + typename EntityTopology, + int Dimensions > +class tnlMeshSuperentityTraits { - enum { storageEnabled = tnlMeshSuperentityStorage< ConfigTag, - EntityTag, - DimensionsTraits::value >::enabled }; - - typedef typename ConfigTag::GlobalIndexType GlobalIndexType; - typedef typename ConfigTag::LocalIndexType LocalIndexType; - public: + + typedef typename MeshConfig::GlobalIndexType GlobalIndexType; + typedef typename MeshConfig::LocalIndexType LocalIndexType; - typedef tnlMeshEntity< ConfigTag, EntityTag > EntityType; - typedef typename - tnlMeshEntitiesTraits< ConfigTag, - DimensionsTraits >::Tag SuperentityTag; - typedef typename - tnlMeshEntitiesTraits< ConfigTag, - DimensionsTraits >::Type SuperentityType; - typedef tnlStorageTraits< storageEnabled > SuperentityStorageTag; + static const bool storageEnabled = MeshConfig::template superentityStorage< EntityTopology >( EntityTopology(), Dimensions ); + //typedef tnlStorageTraits< storageEnabled > SuperentityStorageTag; + typedef tnlMeshEntity< MeshConfig, EntityTopology > EntityType; + typedef tnlMeshEntityTraits< MeshConfig, Dimensions > EntityTraits; + typedef typename EntityTraits::EntityTopology SuperentityTopology; + typedef typename EntityTraits::EntityType SuperentityType; + /**** * Type of container for storing of the superentities indecis. */ - typedef tnlArray< GlobalIndexType, tnlHost, LocalIndexType > ContainerType; - + typedef tnlArray< GlobalIndexType, tnlHost, LocalIndexType > StorageArrayType; + + typedef tnlEllpackIndexMultimap< GlobalIndexType, tnlHost > StorageNetworkType; + typedef tnlMeshSuperentityAccessor< typename StorageNetworkType::ValuesAccessorType > SuperentityAccessorType; + /**** * Type for passing the superentities indecis by the getSuperentitiesIndices() * method. We introduce it because of the compatibility with the subentities * which are usually stored in static array. */ - typedef tnlSharedArray< GlobalIndexType, tnlHost, LocalIndexType > SharedContainerType; + typedef tnlSharedArray< GlobalIndexType, tnlHost, LocalIndexType > AccessArrayType; /**** * This is used by the mesh initializer. @@ -70,4 +70,4 @@ class tnlMeshSuperentitiesTraits }; -#endif /* TNLMESHSUPERENTITIESTRAITS_H_ */ +#endif /* TNLMESHSUPERENTITYTRAITS_H_ */ diff --git a/src/mesh/traits/tnlMeshTraits.h b/src/mesh/traits/tnlMeshTraits.h index f324e03c10cd2e2776cfdf911f8a615a7bc8e9d8..d33f0503b59263c6fe47e572df87ee4c74a25f08 100644 --- a/src/mesh/traits/tnlMeshTraits.h +++ b/src/mesh/traits/tnlMeshTraits.h @@ -19,24 +19,55 @@ #define TNLMESHTRAITS_H_ #include <core/vectors/tnlStaticVector.h> -#include <mesh/traits/tnlDimensionsTraits.h> +#include <core/arrays/tnlArray.h> +#include <core/arrays/tnlSharedArray.h> +#include <core/arrays/tnlConstSharedArray.h> +#include <mesh/tnlDimensionsTag.h> -template< typename ConfigTag, - typename EntityTag > -class tnlMeshEntity; +struct tnlMeshVertexTopology; +template< typename MeshConfig, typename EntityTopology > class tnlMeshEntity; +template< typename MeshConfig, typename EntityTopology > class tnlMeshEntitySeed; +template< typename MeshConfig, int Dimensions > class tnlMeshEntityTraits; +template< typename MeshConfig, typename MeshEntity, int SubDimensions > class tnlMeshSubentityTraits; +template< typename MeshConfig, typename MeshEntity, int SuperDimensions > class tnlMeshSuperentityTraits; -template< typename ConfigTag > +template< typename MeshConfig, + typename Device = tnlHost > class tnlMeshTraits { public: + + static const int meshDimensions = MeshConfig::CellTopology::dimensions; + static const int worldDimensions = MeshConfig::worldDimensions; - enum { meshDimensions = ConfigTag::CellTag::dimensions }; + typedef Device DeviceType; + typedef typename MeshConfig::GlobalIndexType GlobalIndexType; + typedef typename MeshConfig::LocalIndexType LocalIndexType; + + typedef typename MeshConfig::CellTopology CellTopology; + typedef tnlMeshEntity< MeshConfig, CellTopology > CellType; + typedef tnlMeshEntity< MeshConfig, tnlMeshVertexTopology > VertexType; + typedef tnlStaticVector< worldDimensions, typename MeshConfig::RealType > PointType; + typedef tnlMeshEntitySeed< MeshConfig, CellTopology > CellSeedType; + + typedef tnlArray< PointType, tnlHost, GlobalIndexType > PointArrayType; + typedef tnlArray< CellSeedType, tnlHost, GlobalIndexType > CellSeedArrayType; + typedef tnlArray< GlobalIndexType, tnlHost, GlobalIndexType > GlobalIdArrayType; + typedef tnlConstSharedArray< GlobalIndexType, tnlHost, LocalIndexType > IdArrayAccessorType; + typedef tnlConstSharedArray< LocalIndexType, tnlHost, LocalIndexType > IdPermutationArrayAccessorType; + + template< int Dimensions > using EntityTraits = + tnlMeshEntityTraits< MeshConfig, Dimensions >; + + template< typename EntityTopology, int SubDimensions > using SubentityTraits = + tnlMeshSubentityTraits< MeshConfig, EntityTopology, SubDimensions >; + + template< typename EntityTopology, int SuperDimensions > using SuperentityTraits = + tnlMeshSuperentityTraits< MeshConfig, EntityTopology, SuperDimensions >; + + + typedef tnlDimensionsTag< meshDimensions > DimensionsTag; - enum { worldDimensions = ConfigTag::worldDimensions }; - - typedef tnlDimensionsTraits< meshDimensions > DimensionsTraits; - typedef tnlStaticVector< worldDimensions, typename ConfigTag::RealType > PointType; - typedef tnlMeshEntity< ConfigTag, typename ConfigTag::CellTag > CellType; }; diff --git a/src/operators/diffusion/tnlExactLinearDiffusion.h b/src/operators/diffusion/tnlExactLinearDiffusion.h index 28018f0684c68958eccfb10ca897ad277ac20536..c9339d121f0e3dbd211fb3391763c92cb35f514b 100644 --- a/src/operators/diffusion/tnlExactLinearDiffusion.h +++ b/src/operators/diffusion/tnlExactLinearDiffusion.h @@ -18,14 +18,14 @@ #ifndef TNLEXACTLINEARDIFFUSION_H_ #define TNLEXACTLINEARDIFFUSION_H_ -#include <functors/tnlFunctionType.h> +#include <functors/tnlFunction.h> template< int Dimensions > class tnlExactLinearDiffusion {}; template<> -class tnlExactLinearDiffusion< 1 > +class tnlExactLinearDiffusion< 1 > : public tnlFunction< tnlAnalyticFunction > { public: @@ -45,12 +45,12 @@ class tnlExactLinearDiffusion< 1 > }; template<> -class tnlExactLinearDiffusion< 2 > +class tnlExactLinearDiffusion< 2 > : public tnlFunction< tnlAnalyticFunction > { public: enum { Dimensions = 2 }; - + static tnlString getType(); #ifdef HAVE_NOT_CXX11 @@ -65,12 +65,12 @@ class tnlExactLinearDiffusion< 2 > }; template<> -class tnlExactLinearDiffusion< 3 > +class tnlExactLinearDiffusion< 3 > : public tnlFunction< tnlAnalyticFunction > { public: enum { Dimensions = 3 }; - + static tnlString getType(); #ifdef HAVE_NOT_CXX11 @@ -84,13 +84,6 @@ class tnlExactLinearDiffusion< 3 > const Real& time = 0.0 ); }; -template< int Dimensions > -class tnlFunctionType< tnlExactLinearDiffusion< Dimensions > > -{ - public: - enum { Type = tnlAnalyticFunction }; -}; - #include <operators/diffusion/tnlExactLinearDiffusion_impl.h> #endif /* TNLEXACTLINEARDIFFUSION_H_ */ diff --git a/src/operators/euler/fvm/tnlLaxFridrichs_impl.h b/src/operators/euler/fvm/tnlLaxFridrichs_impl.h index e38cd028f3de8d7a70ccc0dbd46957333f07ace1..c5b014ee6fa4d709e6487fca2357eb7f910bfa09 100644 --- a/src/operators/euler/fvm/tnlLaxFridrichs_impl.h +++ b/src/operators/euler/fvm/tnlLaxFridrichs_impl.h @@ -31,9 +31,6 @@ tnlLaxFridrichs< tnlGrid< 2, Real, Device, Index, GridGeometry >, mesh( 0 ), pressureGradient( 0 ) { - rho. setName( "Lax-Fridrichs:rho" ); - rho_u1. setName( "Lax-Fridrichs:rho_u1" ); - rho_u2. setName( "Lax-Fridrichs:rho_u2" ); } template< typename Real, @@ -99,7 +96,6 @@ template< typename Real, void tnlLaxFridrichs< tnlGrid< 2, Real, Device, Index, GridGeometry >, PressureGradient > :: setRho( Vector& rho ) { this->rho.bind( rho ); - this->rho.setName( tnlString( "bind Of " ) + rho. getName() ); } template< typename Real, @@ -111,7 +107,6 @@ template< typename Real, void tnlLaxFridrichs< tnlGrid< 2, Real, Device, Index, GridGeometry >, PressureGradient > :: setRhoU1( Vector& rho_u1 ) { this -> rho_u1. bind( rho_u1 ); - this -> rho_u1. setName( tnlString( "bind Of " ) + rho_u1. getName() ); } template< typename Real, @@ -123,7 +118,6 @@ template< typename Real, void tnlLaxFridrichs< tnlGrid< 2, Real, Device, Index, GridGeometry >, PressureGradient > :: setRhoU2( Vector& rho_u2 ) { this -> rho_u2. bind( rho_u2 ); - this -> rho_u2. setName( tnlString( "bind Of " ) + rho_u2. getName() ); } template< typename Real, @@ -135,7 +129,6 @@ template< typename Real, void tnlLaxFridrichs< tnlGrid< 2, Real, Device, Index, GridGeometry >, PressureGradient > :: setE( Vector& e ) { this->e.bind( e ); - this->e.setName( tnlString( "bind Of " ) + e.getName() ); } template< typename Real, @@ -349,7 +342,6 @@ template< typename Real, void tnlLaxFridrichs< tnlGrid< 2, Real, Device, Index, tnlIdenticalGridGeometry >, PressureGradient > :: setRho( Vector& rho ) { this -> rho. bind( rho ); - this -> rho. setName( tnlString( "bind Of " ) + rho. getName() ); } template< typename Real, @@ -360,7 +352,6 @@ template< typename Real, void tnlLaxFridrichs< tnlGrid< 2, Real, Device, Index, tnlIdenticalGridGeometry >, PressureGradient > :: setRhoU1( Vector& rho_u1 ) { this -> rho_u1. bind( rho_u1 ); - this -> rho_u1. setName( tnlString( "bind Of " ) + rho_u1. getName() ); } template< typename Real, @@ -371,7 +362,6 @@ template< typename Real, void tnlLaxFridrichs< tnlGrid< 2, Real, Device, Index, tnlIdenticalGridGeometry >, PressureGradient > :: setRhoU2( Vector& rho_u2 ) { this -> rho_u2. bind( rho_u2 ); - this -> rho_u2. setName( tnlString( "bind Of " ) + rho_u2. getName() ); } template< typename Real, @@ -382,7 +372,6 @@ template< typename Real, void tnlLaxFridrichs< tnlGrid< 2, Real, Device, Index, tnlIdenticalGridGeometry >, PressureGradient > :: setE( Vector& e ) { this->energy.bind( e ); - this->energy.setName( tnlString( "bind Of " ) + e.getName() ); } template< typename Real, @@ -393,7 +382,6 @@ template< typename Real, void tnlLaxFridrichs< tnlGrid< 2, Real, Device, Index, tnlIdenticalGridGeometry >, PressureGradient > :: setP( Vector& p ) { this->p.bind( p ); - this->p.setName( tnlString( "bind Of " ) + p.getName() ); } template< typename Real, diff --git a/src/operators/gradient/tnlCentralFDMGradient_impl.h b/src/operators/gradient/tnlCentralFDMGradient_impl.h index d8cc6bd3b9dc2696855601ede5f7612d3e0bbee9..41eac268a450bd5f87f17b4f66a56314553cfaa4 100644 --- a/src/operators/gradient/tnlCentralFDMGradient_impl.h +++ b/src/operators/gradient/tnlCentralFDMGradient_impl.h @@ -44,7 +44,6 @@ template< typename Real, void tnlCentralFDMGradient< tnlGrid< 2, Real, Device, Index, GridGeometry > > :: setFunction( Vector& f ) { this -> f. bind( f ); - this -> f. setName( tnlString( "bind Of " ) + f. getName() ); } template< typename Real, @@ -115,7 +114,6 @@ template< typename Real, typename Device, typename Index > void tnlCentralFDMGradient< tnlGrid< 2, Real, Device, Index, tnlIdenticalGridGeometry > > :: setFunction( Vector& f ) { this -> f. bind( f ); - this -> f. setName( tnlString( "bind Of " ) + f. getName() ); } template< typename Real, typename Device, typename Index > diff --git a/src/problems/tnlHeatEquationEocProblem.h b/src/problems/tnlHeatEquationEocProblem.h index e37868c262b1b69d4d753354871cdf68eb5e9421..199404347430d996f2ad9e54d0b45f8368e0bdab 100644 --- a/src/problems/tnlHeatEquationEocProblem.h +++ b/src/problems/tnlHeatEquationEocProblem.h @@ -2,7 +2,7 @@ tnlHeatEquationEocProblem.h - description ------------------- begin : Nov 22, 2014 - copyright : (C) 2014 by oberhuber + copyright : (C) 2014 by Tomas Oberhuber et al. email : tomas.oberhuber@fjfi.cvut.cz ***************************************************************************/ @@ -15,6 +15,13 @@ * * ***************************************************************************/ +/*** + * Authors: + * Oberhuber Tomas, tomas.oberhuber@fjfi.cvut.cz + * Szekely Ondrej, ondra.szekely@gmail.com + */ + + #ifndef TNLHEATEQUATIONEOCPROBLEM_H_ #define TNLHEATEQUATIONEOCPROBLEM_H_ diff --git a/src/problems/tnlHeatEquationEocProblem_impl.h b/src/problems/tnlHeatEquationEocProblem_impl.h index e7dd68285cb3f7f4675de7510fb5992a475c6645..0193cfd37dd5519548d2008a971e7605fadaf2f5 100644 --- a/src/problems/tnlHeatEquationEocProblem_impl.h +++ b/src/problems/tnlHeatEquationEocProblem_impl.h @@ -2,7 +2,7 @@ tnlHeatEquationEocProblem_impl.h - description ------------------- begin : Nov 22, 2014 - copyright : (C) 2014 by oberhuber + copyright : (C) 2014 by Tomas Oberhuber et al. email : tomas.oberhuber@fjfi.cvut.cz ***************************************************************************/ @@ -15,6 +15,13 @@ * * ***************************************************************************/ +/*** + * Authors: + * Oberhuber Tomas, tomas.oberhuber@fjfi.cvut.cz + * Szekely Ondrej, ondra.szekely@gmail.com + */ + + #ifndef TNLHEATEQUATIONEOCPROBLEM_IMPL_H_ #define TNLHEATEQUATIONEOCPROBLEM_IMPL_H_ diff --git a/src/problems/tnlHeatEquationEocRhs.h b/src/problems/tnlHeatEquationEocRhs.h index c7cd20d881dd902bb45dbd820fe880bd9b49a025..8971d002587b889e80165616cf82412b6eaca480 100644 --- a/src/problems/tnlHeatEquationEocRhs.h +++ b/src/problems/tnlHeatEquationEocRhs.h @@ -2,7 +2,7 @@ tnlHeatEquationEocRhs.h - description ------------------- begin : Sep 8, 2014 - copyright : (C) 2014 by oberhuber + copyright : (C) 2014 by Tomas Oberhuber et al. email : tomas.oberhuber@fjfi.cvut.cz ***************************************************************************/ @@ -15,10 +15,16 @@ * * ***************************************************************************/ +/*** + * Authors: + * Oberhuber Tomas, tomas.oberhuber@fjfi.cvut.cz + * Szekely Ondrej, ondra.szekely@gmail.com + */ + #ifndef TNLHEATEQUATIONEOCRHS_H_ #define TNLHEATEQUATIONEOCRHS_H_ -#include <functors/tnlFunctionType.h> +#include <functors/tnlFunction.h> template< typename ExactOperator, typename TestFunction > @@ -29,6 +35,9 @@ class tnlHeatEquationEocRhs typedef ExactOperator ExactOperatorType; typedef TestFunction TestFunctionType; + //static constexpr tnlFunctionType getFunctionType() { return tnlAnalyticFunction; } + enum { functionType = tnlAnalyticFunction }; + bool setup( const tnlParameterContainer& parameters, const tnlString& prefix = "" ) { @@ -53,6 +62,7 @@ class tnlHeatEquationEocRhs TestFunction testFunction; }; +/* template< typename ExactOperator, typename TestFunction > class tnlFunctionType< tnlHeatEquationEocRhs< ExactOperator, TestFunction > > @@ -61,5 +71,6 @@ class tnlFunctionType< tnlHeatEquationEocRhs< ExactOperator, TestFunction > > enum { Type = tnlAnalyticFunction }; }; +*/ #endif /* TNLHEATEQUATIONEOCRHS_H_ */ diff --git a/src/problems/tnlHeatEquationProblem.h b/src/problems/tnlHeatEquationProblem.h index 888f92c69371f118191d5cd95491622a5d77c304..7e32aa65f97a2dae146be50687b6714a6ff3fca9 100644 --- a/src/problems/tnlHeatEquationProblem.h +++ b/src/problems/tnlHeatEquationProblem.h @@ -2,7 +2,7 @@ tnlHeatEquationProblem.h - description ------------------- begin : Feb 23, 2013 - copyright : (C) 2013 by Tomas Oberhuber + copyright : (C) 2013 by Tomas Oberhuber et al. email : tomas.oberhuber@fjfi.cvut.cz ***************************************************************************/ @@ -15,6 +15,13 @@ * * ***************************************************************************/ +/*** + * Authors: + * Oberhuber Tomas, tomas.oberhuber@fjfi.cvut.cz + * Szekely Ondrej, ondra.szekely@gmail.com + */ + + #ifndef TNLHEATEQUATIONPROBLEM_H_ #define TNLHEATEQUATIONPROBLEM_H_ diff --git a/src/problems/tnlHeatEquationProblem_impl.h b/src/problems/tnlHeatEquationProblem_impl.h index e2e22d1ba76451d41a7f1510a484470a0c34e81f..5953cdf6566ccdf0a9a4f1c5bf30968fefc059cd 100644 --- a/src/problems/tnlHeatEquationProblem_impl.h +++ b/src/problems/tnlHeatEquationProblem_impl.h @@ -2,7 +2,7 @@ tnlHeatEquationProblem_impl.h - description ------------------- begin : Mar 10, 2013 - copyright : (C) 2013 by Tomas Oberhuber + copyright : (C) 2013 by Tomas Oberhuber et al. email : tomas.oberhuber@fjfi.cvut.cz ***************************************************************************/ @@ -15,6 +15,12 @@ * * ***************************************************************************/ +/*** + * Authors: + * Oberhuber Tomas, tomas.oberhuber@fjfi.cvut.cz + * Szekely Ondrej, ondra.szekely@gmail.com + */ + #ifndef TNLHEATEQUATIONPROBLEM_IMPL_H_ #define TNLHEATEQUATIONPROBLEM_IMPL_H_ diff --git a/src/solvers/cfd/navier-stokes/tnlNavierStokesSolver_impl.h b/src/solvers/cfd/navier-stokes/tnlNavierStokesSolver_impl.h index ff67a95f6aa12f93863a04afbc7750014a36ab35..085eadf14febf6d65334361dbd2d5b16693c51f9 100644 --- a/src/solvers/cfd/navier-stokes/tnlNavierStokesSolver_impl.h +++ b/src/solvers/cfd/navier-stokes/tnlNavierStokesSolver_impl.h @@ -33,11 +33,6 @@ tnlNavierStokesSolver< AdvectionScheme, DiffusionScheme, BoundaryConditions >::t R( 0.0 ), T( 0.0 ) { - this->rho.setName( "navier-stokes-rho" ); - this->u1.setName( "navier-stokes-u1"); - this->u2.setName( "navier-stokes-u2" ); - this->p.setName( "navier-stokes-p" ); - this->energy.setName( "navier-stokes-energy" ); } template< typename AdvectionScheme, diff --git a/src/solvers/linear/krylov/tnlGMRESSolver_impl.h b/src/solvers/linear/krylov/tnlGMRESSolver_impl.h index cbf970a2297203cbd94c2f2f4f8d44ff7c3e2e26..13582c94a8bfba630dd6d368a8a6fb3491f7dc38 100644 --- a/src/solvers/linear/krylov/tnlGMRESSolver_impl.h +++ b/src/solvers/linear/krylov/tnlGMRESSolver_impl.h @@ -21,16 +21,7 @@ template< typename Matrix, typename Preconditioner > tnlGMRESSolver< Matrix, Preconditioner > :: tnlGMRESSolver() -: tnlObject( "no-name" ), - _r( "tnlGMRESSolver::_r" ), - _w( "tnlGMRESSolver::_w" ), - _v( "tnlGMRESSolver::_v" ), - _M_tmp( "tnlGMRESSolver::_M_tmp" ), - _s( "tnlGMRESSolver::_s" ), - _cs( "tnlGMRESSolver::_cs" ), - _sn( "tnlGMRESSolver::_sn" ), - _H( "tnlGMRESSolver:_H" ), - size( 0 ), +: size( 0 ), restarting( 10 ), matrix( 0 ), preconditioner( 0 ) @@ -159,10 +150,7 @@ bool tnlGMRESSolver< Matrix, Preconditioner > :: solve( const Vector& b, Vector& this->resetIterations(); this->setResidue( beta / normb ); - tnlSharedVector< RealType, DeviceType, IndexType > vi; - //vi. setName( "tnlGMRESSolver::vi" ); - tnlSharedVector< RealType, DeviceType, IndexType > vk; - //vk. setName( "tnlGMRESSolver::vk" ); + tnlSharedVector< RealType, DeviceType, IndexType > vi, vk; while( this->nextIteration() ) { const IndexType m = restarting; @@ -321,15 +309,13 @@ void tnlGMRESSolver< Matrix, Preconditioner > :: update( IndexType k, tnlVector< RealType, DeviceType, IndexType >& v, Vector& x ) { - //dbgFunctionName( "tnlGMRESSolver", "Update" ); - tnlVector< RealType, tnlHost, IndexType > y( "tnlGMRESSolver::update:y" ); + tnlVector< RealType, tnlHost, IndexType > y; y. setSize( m + 1 ); IndexType i, j; for( i = 0; i <= m ; i ++ ) y[ i ] = s[ i ]; - //dbgCout_ARRAY( y, m + 1 ); // Backsolve: for( i = k; i >= 0; i--) { @@ -337,10 +323,8 @@ void tnlGMRESSolver< Matrix, Preconditioner > :: update( IndexType k, for( j = i - 1; j >= 0; j--) y[ j ] -= H[ j + i * ( m + 1 ) ] * y[ i ]; } - //dbgCout_ARRAY( y, m + 1 ); tnlSharedVector< RealType, DeviceType, IndexType > vi; - vi. setName( "tnlGMRESSolver::update:vi" ); for( i = 0; i <= k; i++) { vi. bind( &( v. getData()[ i * this->size ] ), x. getSize() ); diff --git a/src/solvers/ode/tnlEulerSolver_impl.h b/src/solvers/ode/tnlEulerSolver_impl.h index 2522596e58c280c4f66307d238b7e487963ff9f7..3bf46d9f17c1965839e961cecb6636113a146d4a 100644 --- a/src/solvers/ode/tnlEulerSolver_impl.h +++ b/src/solvers/ode/tnlEulerSolver_impl.h @@ -30,10 +30,8 @@ __global__ void updateUEuler( const Index size, template< typename Problem > tnlEulerSolver< Problem > :: tnlEulerSolver() -: k1( "tnlEulerSolver:k1" ), - cflCondition( 0.0 ) +: cflCondition( 0.0 ) { - //this->setName( "EulerSolver" ); }; template< typename Problem > diff --git a/src/solvers/ode/tnlMersonSolver_impl.h b/src/solvers/ode/tnlMersonSolver_impl.h index 95241e39acf21bc1868a09115d3a50fdf7b1bac5..bc512effd6a874b3458860ad78de26ebc8893bd2 100644 --- a/src/solvers/ode/tnlMersonSolver_impl.h +++ b/src/solvers/ode/tnlMersonSolver_impl.h @@ -89,13 +89,7 @@ __global__ void updateUMerson( const Index size, template< typename Problem > tnlMersonSolver< Problem > :: tnlMersonSolver() -: k1( "tnlMersonSolver:k1" ), - k2( "tnlMersonSolver:k2" ), - k3( "tnlMersonSolver:k3" ), - k4( "tnlMersonSolver:k4" ), - k5( "tnlMersonSolver:k5" ), - kAux( "tnlMersonSolver:kAux" ), - adaptivity( 0.00001 ) +: adaptivity( 0.00001 ) { }; diff --git a/src/solvers/pde/tnlExplicitUpdater_impl.h b/src/solvers/pde/tnlExplicitUpdater_impl.h index 35f80644ca7f3bec21172bd3ab12819410e8f432..4b8e06fc0310f25af259f643ea4c2eb53e1bdf8b 100644 --- a/src/solvers/pde/tnlExplicitUpdater_impl.h +++ b/src/solvers/pde/tnlExplicitUpdater_impl.h @@ -18,9 +18,9 @@ #ifndef TNLEXPLICITUPDATER_IMPL_H_ #define TNLEXPLICITUPDATER_IMPL_H_ -#include <mesh/tnlTraverser_Grid1D.h> -#include <mesh/tnlTraverser_Grid2D.h> -#include <mesh/tnlTraverser_Grid3D.h> +#include <mesh/grids/tnlTraverser_Grid1D.h> +#include <mesh/grids/tnlTraverser_Grid2D.h> +#include <mesh/grids/tnlTraverser_Grid3D.h> template< typename Mesh, typename DofVector, diff --git a/src/solvers/pde/tnlLinearSystemAssembler_impl.h b/src/solvers/pde/tnlLinearSystemAssembler_impl.h index a884e636311136b1b0f56b0bdf1c3ffa492c2862..b5e59ff96bdada188d0a886a354078940160a2b0 100644 --- a/src/solvers/pde/tnlLinearSystemAssembler_impl.h +++ b/src/solvers/pde/tnlLinearSystemAssembler_impl.h @@ -18,9 +18,9 @@ #ifndef TNLLINEARSYSTEMASSEMBLER_IMPL_H_ #define TNLLINEARSYSTEMASSEMBLER_IMPL_H_ -#include <mesh/tnlTraverser_Grid1D.h> -#include <mesh/tnlTraverser_Grid2D.h> -#include <mesh/tnlTraverser_Grid3D.h> +#include <mesh/grids/tnlTraverser_Grid1D.h> +#include <mesh/grids/tnlTraverser_Grid2D.h> +#include <mesh/grids/tnlTraverser_Grid3D.h> template< typename Mesh, typename DofVector, diff --git a/src/solvers/pde/tnlPDESolver_impl.h b/src/solvers/pde/tnlPDESolver_impl.h index b289344ab6f26a459906247d40da533d52052aeb..8c1cf924762dca784d7637213106a247fdd84002 100644 --- a/src/solvers/pde/tnlPDESolver_impl.h +++ b/src/solvers/pde/tnlPDESolver_impl.h @@ -34,8 +34,6 @@ tnlPDESolver() ioCpuTimer( 0 ), computeCpuTimer( 0 ) { - this->dofs.setName( "dofs" ); - this->meshDependentData.setName( "meshDependentData" ); } template< typename Problem, @@ -321,13 +319,13 @@ tnlPDESolver< Problem, TimeStepper >:: solve() { tnlAssert( timeStepper != 0, - cerr << "No time stepper was set in tnlPDESolver with name " << this -> getName() ); + cerr << "No time stepper was set in tnlPDESolver." ); tnlAssert( problem != 0, - cerr << "No problem was set in tnlPDESolver with name " << this -> getName() ); + cerr << "No problem was set in tnlPDESolver." ); if( snapshotPeriod == 0 ) { - cerr << "No snapshot tau was set in tnlPDESolver " << this -> getName() << "." << endl; + cerr << "No snapshot tau was set in tnlPDESolver." << endl; return false; } RealType t( this->initialTime ); diff --git a/src/solvers/tnlBuildConfigTags.h b/src/solvers/tnlBuildConfigTags.h index 5b094846fbe5899d9f72cb184da920f2f3bd76bc..f19daad01de69c449bf1c10cfe1102e6f8a53f64 100644 --- a/src/solvers/tnlBuildConfigTags.h +++ b/src/solvers/tnlBuildConfigTags.h @@ -1,5 +1,5 @@ /*************************************************************************** - tnlConfigTags.h - description + tnlMeshConfigs.h - description ------------------- begin : Jul 7, 2014 copyright : (C) 2014 by Tomas Oberhuber @@ -15,56 +15,56 @@ * * ***************************************************************************/ -#ifndef TNLCONFIGTAGS_H_ -#define TNLCONFIGTAGS_H_ +#ifndef TNLMeshConfigS_H_ +#define TNLMeshConfigS_H_ #include <mesh/tnlGrid.h> -class tnlDefaultBuildConfigTag{}; +class tnlDefaultBuildMeshConfig{}; /**** * All devices are enabled by default. Those which are not available * are disabled. */ -template< typename ConfigTag, typename Device > struct tnlConfigTagDevice{ enum { enabled = true }; }; +template< typename MeshConfig, typename Device > struct tnlMeshConfigDevice{ enum { enabled = true }; }; #ifndef HAVE_CUDA -template< typename ConfigTag > struct tnlConfigTagDevice< ConfigTag, tnlCuda >{ enum { enabled = false }; }; +template< typename MeshConfig > struct tnlMeshConfigDevice< MeshConfig, tnlCuda >{ enum { enabled = false }; }; #endif /**** * All real types are enabled by default. */ -template< typename ConfigTag, typename Real > struct tnlConfigTagReal{ enum { enabled = true }; }; +template< typename MeshConfig, typename Real > struct tnlMeshConfigReal{ enum { enabled = true }; }; /**** * All index types are enabled ba default. */ -template< typename ConfigTag, typename Index > struct tnlConfigTagIndex{ enum { enabled = true }; }; +template< typename MeshConfig, typename Index > struct tnlMeshConfigIndex{ enum { enabled = true }; }; /**** * The mesh type will be resolved by the tnlSolver by default. */ -template< typename ConfigTag > struct tnlConfigTagMeshResolve{ enum { enabled = true }; }; +template< typename MeshConfig > struct tnlMeshConfigMeshResolve{ enum { enabled = true }; }; /**** * 1, 2, and 3 dimensions are enabled by default */ -template< typename ConfigTag, int Dimensions > struct tnlConfigTagDimensions{ enum { enabled = false }; }; - template< typename ConfigTag > struct tnlConfigTagDimensions< ConfigTag, 1 >{ enum { enabled = true }; }; - template< typename ConfigTag > struct tnlConfigTagDimensions< ConfigTag, 2 >{ enum { enabled = true }; }; - template< typename ConfigTag > struct tnlConfigTagDimensions< ConfigTag, 3 >{ enum { enabled = true }; }; +template< typename MeshConfig, int Dimensions > struct tnlMeshConfigDimensions{ enum { enabled = false }; }; + template< typename MeshConfig > struct tnlMeshConfigDimensions< MeshConfig, 1 >{ enum { enabled = true }; }; + template< typename MeshConfig > struct tnlMeshConfigDimensions< MeshConfig, 2 >{ enum { enabled = true }; }; + template< typename MeshConfig > struct tnlMeshConfigDimensions< MeshConfig, 3 >{ enum { enabled = true }; }; /**** * Up to the exceptions enlisted below, all mesh types are disabled by default. */ -template< typename ConfigTag, typename MeshType > struct tnlConfigTagMesh{ enum { enabled = false }; }; +template< typename MeshConfig, typename MeshType > struct tnlMeshConfigMesh{ enum { enabled = false }; }; /**** * Use of tnlGrid is enabled for allowed dimensions by default. */ -template< typename ConfigTag, int Dimensions, typename Real, typename Device, typename Index > - struct tnlConfigTagMesh< ConfigTag, tnlGrid< Dimensions, Real, Device, Index > > - { enum { enabled = tnlConfigTagDimensions< ConfigTag, Dimensions >::enabled }; }; +template< typename MeshConfig, int Dimensions, typename Real, typename Device, typename Index > + struct tnlMeshConfigMesh< MeshConfig, tnlGrid< Dimensions, Real, Device, Index > > + { enum { enabled = tnlMeshConfigDimensions< MeshConfig, Dimensions >::enabled }; }; /**** * All time discretisations (explicit, semi-impicit and implicit ) are @@ -74,7 +74,7 @@ class tnlExplicitTimeDiscretisationTag{}; class tnlSemiImplicitTimeDiscretisationTag{}; class tnlImplicitTimeDiscretisationTag{}; -template< typename ConfigTag, typename TimeDiscretisation > struct tnlConfigTagTimeDiscretisation{ enum { enabled = true }; }; +template< typename MeshConfig, typename TimeDiscretisation > struct tnlMeshConfigTimeDiscretisation{ enum { enabled = true }; }; /**** * All explicit solvers are enabled by default @@ -82,7 +82,7 @@ template< typename ConfigTag, typename TimeDiscretisation > struct tnlConfigTagT class tnlExplicitEulerSolverTag{}; class tnlExplicitMersonSolverTag{}; -template< typename ConfigTag, typename ExplicitSolver > struct tnlConfigTagExplicitSolver{ enum { enabled = true }; }; +template< typename MeshConfig, typename ExplicitSolver > struct tnlMeshConfigExplicitSolver{ enum { enabled = true }; }; /**** * All semi-implicit solvers are enabled by default @@ -93,6 +93,6 @@ class tnlSemiImplicitCGSolverTag{}; class tnlSemiImplicitBICGStabSolverTag{}; class tnlSemiImplicitGMRESSolverTag{}; -template< typename ConfigTag, typename SemiImplicitSolver > struct tnlConfigTagSemiImplicitSolver{ enum { enabled = true }; }; +template< typename MeshConfig, typename SemiImplicitSolver > struct tnlMeshConfigSemiImplicitSolver{ enum { enabled = true }; }; -#endif /* TNLCONFIGTAGS_H_ */ +#endif /* TNLMeshConfigS_H_ */ diff --git a/src/solvers/tnlFastBuildConfigTag.h b/src/solvers/tnlFastBuildConfigTag.h index 23b603cf7a24e19262c6b9b0dba8dc02319b93b0..fb65b13c9dc8dd35980394a2b2ba0e2d68f85c06 100644 --- a/src/solvers/tnlFastBuildConfigTag.h +++ b/src/solvers/tnlFastBuildConfigTag.h @@ -1,5 +1,5 @@ /*************************************************************************** - tnlFastBuildConfig.h - description + tnlFastBuildConfigTag.h - description ------------------- begin : Jul 7, 2014 copyright : (C) 2014 by Tomas Oberhuber @@ -15,8 +15,8 @@ * * ***************************************************************************/ -#ifndef TNLFASTBUILDCONFIG_H_ -#define TNLFASTBUILDCONFIG_H_ +#ifndef TNLFASTBUILDCONFIGTAG_H_ +#define TNLFASTBUILDCONFIGTAG_H_ #include <solvers/tnlBuildConfigTags.h> @@ -30,35 +30,35 @@ class tnlFastBuildConfig /**** * Turn off support for float and long double. */ -template<> struct tnlConfigTagReal< tnlFastBuildConfig, float > { enum { enabled = false }; }; -template<> struct tnlConfigTagReal< tnlFastBuildConfig, long double > { enum { enabled = false }; }; +template<> struct tnlMeshConfigReal< tnlFastBuildConfig, float > { enum { enabled = false }; }; +template<> struct tnlMeshConfigReal< tnlFastBuildConfig, long double > { enum { enabled = false }; }; /**** * Turn off support for short int and long int indexing. */ -template<> struct tnlConfigTagIndex< tnlFastBuildConfig, short int >{ enum { enabled = false }; }; -template<> struct tnlConfigTagIndex< tnlFastBuildConfig, long int >{ enum { enabled = false }; }; +template<> struct tnlMeshConfigIndex< tnlFastBuildConfig, short int >{ enum { enabled = false }; }; +template<> struct tnlMeshConfigIndex< tnlFastBuildConfig, long int >{ enum { enabled = false }; }; /**** * Use of tnlGrid is enabled for allowed dimensions and Real, Device and Index types. */ template< int Dimensions, typename Real, typename Device, typename Index > - struct tnlConfigTagMesh< tnlFastBuildConfig, tnlGrid< Dimensions, Real, Device, Index > > - { enum { enabled = tnlConfigTagDimensions< tnlFastBuildConfig, Dimensions >::enabled && - tnlConfigTagReal< tnlFastBuildConfig, Real >::enabled && - tnlConfigTagDevice< tnlFastBuildConfig, Device >::enabled && - tnlConfigTagIndex< tnlFastBuildConfig, Index >::enabled }; }; + struct tnlMeshConfigMesh< tnlFastBuildConfig, tnlGrid< Dimensions, Real, Device, Index > > + { enum { enabled = tnlMeshConfigDimensions< tnlFastBuildConfig, Dimensions >::enabled && + tnlMeshConfigReal< tnlFastBuildConfig, Real >::enabled && + tnlMeshConfigDevice< tnlFastBuildConfig, Device >::enabled && + tnlMeshConfigIndex< tnlFastBuildConfig, Index >::enabled }; }; /**** * Please, chose your preferred time discretisation here. */ -template<> struct tnlConfigTagTimeDiscretisation< tnlFastBuildConfig, tnlExplicitTimeDiscretisationTag >{ enum { enabled = true }; }; -template<> struct tnlConfigTagTimeDiscretisation< tnlFastBuildConfig, tnlSemiImplicitTimeDiscretisationTag >{ enum { enabled = true }; }; -template<> struct tnlConfigTagTimeDiscretisation< tnlFastBuildConfig, tnlImplicitTimeDiscretisationTag >{ enum { enabled = false }; }; +template<> struct tnlMeshConfigTimeDiscretisation< tnlFastBuildConfig, tnlExplicitTimeDiscretisationTag >{ enum { enabled = true }; }; +template<> struct tnlMeshConfigTimeDiscretisation< tnlFastBuildConfig, tnlSemiImplicitTimeDiscretisationTag >{ enum { enabled = true }; }; +template<> struct tnlMeshConfigTimeDiscretisation< tnlFastBuildConfig, tnlImplicitTimeDiscretisationTag >{ enum { enabled = false }; }; /**** * Only the Runge-Kutta-Merson solver is enabled by default. */ -template<> struct tnlConfigTagExplicitSolver< tnlFastBuildConfig, tnlExplicitEulerSolverTag >{ enum { enabled = false }; }; +template<> struct tnlMeshConfigExplicitSolver< tnlFastBuildConfig, tnlExplicitEulerSolverTag >{ enum { enabled = false }; }; -#endif /* TNLDEFAULTCONFIG_H_ */ +#endif /* TNLFASTBUILDCONFIGTAG_H_ */ diff --git a/src/solvers/tnlMeshTypeResolver.h b/src/solvers/tnlMeshTypeResolver.h index f10b8d8ab383fdf8d0fb5000eb043f76d5e99c6d..702fab91e6bbc4dd9eafa5acdc5ed6c5e8a18d91 100644 --- a/src/solvers/tnlMeshTypeResolver.h +++ b/src/solvers/tnlMeshTypeResolver.h @@ -20,34 +20,34 @@ #include <config/tnlParameterContainer.h> -template< template< typename Real, typename Device, typename Index, typename MeshType, typename ConfigTag, typename SolverStarter > class ProblemSetter, +template< template< typename Real, typename Device, typename Index, typename MeshType, typename MeshConfig, typename SolverStarter > class ProblemSetter, typename Real, typename Device, typename Index, - typename ConfigTag, - bool ResolveMesh = tnlConfigTagMeshResolve< ConfigTag >::enabled > + typename MeshConfig, + bool ResolveMesh = tnlMeshConfigMeshResolve< MeshConfig >::enabled > class tnlMeshTypeResolver { }; -template< template< typename Real, typename Device, typename Index, typename MeshType, typename ConfigTag, typename SolverStarter > class ProblemSetter, +template< template< typename Real, typename Device, typename Index, typename MeshType, typename MeshConfig, typename SolverStarter > class ProblemSetter, typename Real, typename Device, typename Index, - typename ConfigTag > -class tnlMeshTypeResolver< ProblemSetter, Real, Device, Index, ConfigTag, false > + typename MeshConfig > +class tnlMeshTypeResolver< ProblemSetter, Real, Device, Index, MeshConfig, false > { public: static bool run( const tnlParameterContainer& parameters ); }; -template< template< typename Real, typename Device, typename Index, typename MeshType, typename ConfigTag, typename SolverStarter > class ProblemSetter, +template< template< typename Real, typename Device, typename Index, typename MeshType, typename MeshConfig, typename SolverStarter > class ProblemSetter, typename Real, typename Device, typename Index, - typename ConfigTag > -class tnlMeshTypeResolver< ProblemSetter, Real, Device, Index, ConfigTag, true > + typename MeshConfig > +class tnlMeshTypeResolver< ProblemSetter, Real, Device, Index, MeshConfig, true > { public: diff --git a/src/solvers/tnlMeshTypeResolver_impl.h b/src/solvers/tnlMeshTypeResolver_impl.h index 427fff4265038092bc344a84bcd7599a0faba6d8..a50b15df3a3eeb5351cb1447622dc426d490bba2 100644 --- a/src/solvers/tnlMeshTypeResolver_impl.h +++ b/src/solvers/tnlMeshTypeResolver_impl.h @@ -23,37 +23,37 @@ #include <mesh/tnlDummyMesh.h> #include <solvers/tnlSolverStarter.h> -template< template< typename Real, typename Device, typename Index, typename MeshType, typename ConfigTag, typename SolverStarter > class ProblemSetter, +template< template< typename Real, typename Device, typename Index, typename MeshType, typename MeshConfig, typename SolverStarter > class ProblemSetter, typename Real, typename Device, typename Index, typename MeshType, - typename ConfigTag, - bool MeshTypeSupported = tnlConfigTagMesh< ConfigTag, MeshType >::enabled > + typename MeshConfig, + bool MeshTypeSupported = tnlMeshConfigMesh< MeshConfig, MeshType >::enabled > class tnlMeshResolverTerminator{}; -template< template< typename Real, typename Device, typename Index, typename MeshType, typename ConfigTag, typename SolverStarter > class ProblemSetter, +template< template< typename Real, typename Device, typename Index, typename MeshType, typename MeshConfig, typename SolverStarter > class ProblemSetter, typename Real, typename Device, typename Index, - typename ConfigTag > -bool tnlMeshTypeResolver< ProblemSetter, Real, Device, Index, ConfigTag, false >::run( const tnlParameterContainer& parameters ) + typename MeshConfig > +bool tnlMeshTypeResolver< ProblemSetter, Real, Device, Index, MeshConfig, false >::run( const tnlParameterContainer& parameters ) { return ProblemSetter< Real, Device, Index, tnlDummyMesh< Real, Device, Index >, - ConfigTag, - tnlSolverStarter< ConfigTag > >::template run< Real, Device, Index, ConfigTag >( parameters ); + MeshConfig, + tnlSolverStarter< MeshConfig > >::template run< Real, Device, Index, MeshConfig >( parameters ); }; -template< template< typename Real, typename Device, typename Index, typename MeshType, typename ConfigTag, typename SolverStarter > class ProblemSetter, +template< template< typename Real, typename Device, typename Index, typename MeshType, typename MeshConfig, typename SolverStarter > class ProblemSetter, typename Real, typename Device, typename Index, - typename ConfigTag > -bool tnlMeshTypeResolver< ProblemSetter, Real, Device, Index, ConfigTag, true >::run( const tnlParameterContainer& parameters ) + typename MeshConfig > +bool tnlMeshTypeResolver< ProblemSetter, Real, Device, Index, MeshConfig, true >::run( const tnlParameterContainer& parameters ) { const tnlString& meshFileName = parameters.getParameter< tnlString >( "mesh" ); @@ -73,12 +73,12 @@ bool tnlMeshTypeResolver< ProblemSetter, Real, Device, Index, ConfigTag, true >: return resolveMeshDimensions( parameters, parsedMeshType ); } -template< template< typename Real, typename Device, typename Index, typename MeshType, typename ConfigTag, typename SolverStarter > class ProblemSetter, +template< template< typename Real, typename Device, typename Index, typename MeshType, typename MeshConfig, typename SolverStarter > class ProblemSetter, typename Real, typename Device, typename Index, - typename ConfigTag > -bool tnlMeshTypeResolver< ProblemSetter, Real, Device, Index, ConfigTag, true >::resolveMeshDimensions( const tnlParameterContainer& parameters, + typename MeshConfig > +bool tnlMeshTypeResolver< ProblemSetter, Real, Device, Index, MeshConfig, true >::resolveMeshDimensions( const tnlParameterContainer& parameters, const tnlList< tnlString >& parsedMeshType ) { int dimensions = atoi( parsedMeshType[ 1 ].getString() ); @@ -93,13 +93,13 @@ bool tnlMeshTypeResolver< ProblemSetter, Real, Device, Index, ConfigTag, true >: return false; } -template< template< typename Real, typename Device, typename Index, typename MeshType, typename ConfigTag, typename SolverStarter > class ProblemSetter, +template< template< typename Real, typename Device, typename Index, typename MeshType, typename MeshConfig, typename SolverStarter > class ProblemSetter, typename Real, typename Device, typename Index, - typename ConfigTag > + typename MeshConfig > template< int MeshDimensions > -bool tnlMeshTypeResolver< ProblemSetter, Real, Device, Index, ConfigTag, true >::resolveMeshRealType( const tnlParameterContainer& parameters, +bool tnlMeshTypeResolver< ProblemSetter, Real, Device, Index, MeshConfig, true >::resolveMeshRealType( const tnlParameterContainer& parameters, const tnlList< tnlString >& parsedMeshType ) { if( parsedMeshType[ 2 ] == "float" ) @@ -112,14 +112,14 @@ bool tnlMeshTypeResolver< ProblemSetter, Real, Device, Index, ConfigTag, true >: return false; } -template< template< typename Real, typename Device, typename Index, typename MeshType, typename ConfigTag, typename SolverStarter > class ProblemSetter, +template< template< typename Real, typename Device, typename Index, typename MeshType, typename MeshConfig, typename SolverStarter > class ProblemSetter, typename Real, typename Device, typename Index, - typename ConfigTag > + typename MeshConfig > template< int MeshDimensions, typename MeshRealType > -bool tnlMeshTypeResolver< ProblemSetter, Real, Device, Index, ConfigTag, 1 >::resolveMeshIndexType( const tnlParameterContainer& parameters, +bool tnlMeshTypeResolver< ProblemSetter, Real, Device, Index, MeshConfig, 1 >::resolveMeshIndexType( const tnlParameterContainer& parameters, const tnlList< tnlString >& parsedMeshType ) { if( parsedMeshType[ 4 ] == "short int" ) @@ -132,33 +132,33 @@ bool tnlMeshTypeResolver< ProblemSetter, Real, Device, Index, ConfigTag, 1 >::re return false; } -template< template< typename Real, typename Device, typename Index, typename MeshType, typename ConfigTag, typename SolverStarter > class ProblemSetter, +template< template< typename Real, typename Device, typename Index, typename MeshType, typename MeshConfig, typename SolverStarter > class ProblemSetter, typename Real, typename Device, typename Index, - typename ConfigTag > + typename MeshConfig > template< int MeshDimensions, typename MeshRealType, typename MeshIndexType > -bool tnlMeshTypeResolver< ProblemSetter, Real, Device, Index, ConfigTag, true >::resolveMeshType( const tnlParameterContainer& parameters, +bool tnlMeshTypeResolver< ProblemSetter, Real, Device, Index, MeshConfig, true >::resolveMeshType( const tnlParameterContainer& parameters, const tnlList< tnlString >& parsedMeshType ) { if( parsedMeshType[ 0 ] == "tnlGrid" ) { typedef tnlGrid< MeshDimensions, MeshRealType, Device, MeshIndexType > MeshType; - return tnlMeshResolverTerminator< ProblemSetter, Real, Device, Index, MeshType, ConfigTag >::run( parameters ); + return tnlMeshResolverTerminator< ProblemSetter, Real, Device, Index, MeshType, MeshConfig >::run( parameters ); } cerr << "Unknown mesh type " << parsedMeshType[ 0 ] << "." << endl; return false; } -template< template< typename Real, typename Device, typename Index, typename MeshType, typename ConfigTag, typename SolverStarter > class ProblemSetter, +template< template< typename Real, typename Device, typename Index, typename MeshType, typename MeshConfig, typename SolverStarter > class ProblemSetter, typename Real, typename Device, typename Index, typename MeshType, - typename ConfigTag > -class tnlMeshResolverTerminator< ProblemSetter, Real, Device, Index, MeshType, ConfigTag, false > + typename MeshConfig > +class tnlMeshResolverTerminator< ProblemSetter, Real, Device, Index, MeshType, MeshConfig, false > { public: static bool run( const tnlParameterContainer& parameters ) @@ -168,18 +168,18 @@ class tnlMeshResolverTerminator< ProblemSetter, Real, Device, Index, MeshType, C }; }; -template< template< typename Real, typename Device, typename Index, typename MeshType, typename ConfigTag, typename SolverStarter > class ProblemSetter, +template< template< typename Real, typename Device, typename Index, typename MeshType, typename MeshConfig, typename SolverStarter > class ProblemSetter, typename Real, typename Device, typename Index, typename MeshType, - typename ConfigTag > -class tnlMeshResolverTerminator< ProblemSetter, Real, Device, Index, MeshType, ConfigTag, true > + typename MeshConfig > +class tnlMeshResolverTerminator< ProblemSetter, Real, Device, Index, MeshType, MeshConfig, true > { public: static bool run( const tnlParameterContainer& parameters ) { - return ProblemSetter< Real, Device, Index, MeshType, ConfigTag, tnlSolverStarter< ConfigTag > >::run( parameters ); + return ProblemSetter< Real, Device, Index, MeshType, MeshConfig, tnlSolverStarter< MeshConfig > >::run( parameters ); } }; diff --git a/src/solvers/tnlSolver.h b/src/solvers/tnlSolver.h index 9e4040d87a48621acbe7750bb4f2164063c73c11..aeff94b70019f24eff84fa731f0c88ef96eea5e3 100644 --- a/src/solvers/tnlSolver.h +++ b/src/solvers/tnlSolver.h @@ -20,9 +20,9 @@ #include <solvers/tnlBuildConfigTags.h> -template< template< typename Real, typename Device, typename Index, typename MeshType, typename ConfigTag, typename SolverStarter > class ProblemSetter, +template< template< typename Real, typename Device, typename Index, typename MeshType, typename MeshConfig, typename SolverStarter > class ProblemSetter, template< typename ConfTag > class ProblemConfig, - typename ConfigTag = tnlDefaultBuildConfigTag > + typename MeshConfig = tnlDefaultBuildMeshConfig > class tnlSolver { public: diff --git a/src/solvers/tnlSolverConfig.h b/src/solvers/tnlSolverConfig.h index d266fa802125b33f36cd58c301bec62d5bbde270..446bb65632cb402d9836fe9e607fc1fb7887145d 100644 --- a/src/solvers/tnlSolverConfig.h +++ b/src/solvers/tnlSolverConfig.h @@ -20,7 +20,7 @@ #include <config/tnlConfigDescription.h> -template< typename ConfigTag, +template< typename MeshConfig, typename ProblemConfig > class tnlSolverConfig { diff --git a/src/solvers/tnlSolverConfig_impl.h b/src/solvers/tnlSolverConfig_impl.h index 329b0335918660845018b304f8191b543e7b302f..728de597cdac2464886583e69e9c03b86ac1ad04 100644 --- a/src/solvers/tnlSolverConfig_impl.h +++ b/src/solvers/tnlSolverConfig_impl.h @@ -24,9 +24,9 @@ #include <solvers/pde/tnlExplicitTimeStepper.h> #include <solvers/pde/tnlPDESolver.h> -template< typename ConfigTag, +template< typename MeshConfig, typename ProblemConfig > -bool tnlSolverConfig< ConfigTag, ProblemConfig >::configSetup( tnlConfigDescription& config ) +bool tnlSolverConfig< MeshConfig, ProblemConfig >::configSetup( tnlConfigDescription& config ) { typedef tnlDummyProblem< double, tnlHost, int > DummyProblem; @@ -37,11 +37,11 @@ bool tnlSolverConfig< ConfigTag, ProblemConfig >::configSetup( tnlConfigDescript config.addEntry< tnlString >( "real-type", "Precision of the floating point arithmetics.", "double" ); - if( tnlConfigTagReal< ConfigTag, float >::enabled ) + if( tnlMeshConfigReal< MeshConfig, float >::enabled ) config.addEntryEnum( "float" ); - if( tnlConfigTagReal< ConfigTag, double >::enabled ) + if( tnlMeshConfigReal< MeshConfig, double >::enabled ) config.addEntryEnum( "double" ); - if( tnlConfigTagReal< ConfigTag, long double >::enabled ) + if( tnlMeshConfigReal< MeshConfig, long double >::enabled ) config.addEntryEnum( "long-double" ); /**** @@ -50,10 +50,10 @@ bool tnlSolverConfig< ConfigTag, ProblemConfig >::configSetup( tnlConfigDescript config.addEntry< tnlString >( "device", "Device to use for the computations.", "host" ); - if( tnlConfigTagDevice< ConfigTag, tnlHost >::enabled ) + if( tnlMeshConfigDevice< MeshConfig, tnlHost >::enabled ) config.addEntryEnum( "host" ); #ifdef HAVE_CUDA - if( tnlConfigTagDevice< ConfigTag, tnlCuda >::enabled ) + if( tnlMeshConfigDevice< MeshConfig, tnlCuda >::enabled ) config.addEntryEnum( "cuda" ); #endif @@ -63,13 +63,13 @@ bool tnlSolverConfig< ConfigTag, ProblemConfig >::configSetup( tnlConfigDescript config.addEntry< tnlString >( "index-type", "Indexing type for arrays, vectors, matrices etc.", "int" ); - if( tnlConfigTagIndex< ConfigTag, short int >::enabled ) + if( tnlMeshConfigIndex< MeshConfig, short int >::enabled ) config.addEntryEnum( "short-int" ); - if( tnlConfigTagIndex< ConfigTag, int >::enabled ) + if( tnlMeshConfigIndex< MeshConfig, int >::enabled ) config.addEntryEnum( "int" ); - if( tnlConfigTagIndex< ConfigTag, long int >::enabled ) + if( tnlMeshConfigIndex< MeshConfig, long int >::enabled ) config.addEntryEnum( "long-int" ); /**** @@ -86,64 +86,64 @@ bool tnlSolverConfig< ConfigTag, ProblemConfig >::configSetup( tnlConfigDescript typedef tnlExplicitTimeStepper< DummyProblem, tnlEulerSolver > ExplicitTimeStepper; tnlPDESolver< DummyProblem, ExplicitTimeStepper >::configSetup( config ); ExplicitTimeStepper::configSetup( config ); - if( tnlConfigTagTimeDiscretisation< ConfigTag, tnlExplicitTimeDiscretisationTag >::enabled || - tnlConfigTagTimeDiscretisation< ConfigTag, tnlSemiImplicitTimeDiscretisationTag >::enabled || - tnlConfigTagTimeDiscretisation< ConfigTag, tnlImplicitTimeDiscretisationTag >::enabled ) + if( tnlMeshConfigTimeDiscretisation< MeshConfig, tnlExplicitTimeDiscretisationTag >::enabled || + tnlMeshConfigTimeDiscretisation< MeshConfig, tnlSemiImplicitTimeDiscretisationTag >::enabled || + tnlMeshConfigTimeDiscretisation< MeshConfig, tnlImplicitTimeDiscretisationTag >::enabled ) { config.addRequiredEntry< tnlString >( "time-discretisation", "Discratisation in time."); - if( tnlConfigTagTimeDiscretisation< ConfigTag, tnlExplicitTimeDiscretisationTag >::enabled ) + if( tnlMeshConfigTimeDiscretisation< MeshConfig, tnlExplicitTimeDiscretisationTag >::enabled ) config.addEntryEnum( "explicit" ); - if( tnlConfigTagTimeDiscretisation< ConfigTag, tnlSemiImplicitTimeDiscretisationTag >::enabled ) + if( tnlMeshConfigTimeDiscretisation< MeshConfig, tnlSemiImplicitTimeDiscretisationTag >::enabled ) config.addEntryEnum( "semi-implicit" ); - if( tnlConfigTagTimeDiscretisation< ConfigTag, tnlImplicitTimeDiscretisationTag >::enabled ) + if( tnlMeshConfigTimeDiscretisation< MeshConfig, tnlImplicitTimeDiscretisationTag >::enabled ) config.addEntryEnum( "implicit" ); } config.addRequiredEntry< tnlString >( "discrete-solver", "The solver of the discretised problem:" ); - if( tnlConfigTagTimeDiscretisation< ConfigTag, tnlExplicitTimeDiscretisationTag >::enabled ) + if( tnlMeshConfigTimeDiscretisation< MeshConfig, tnlExplicitTimeDiscretisationTag >::enabled ) { - if( tnlConfigTagExplicitSolver< ConfigTag, tnlExplicitEulerSolverTag >::enabled ) + if( tnlMeshConfigExplicitSolver< MeshConfig, tnlExplicitEulerSolverTag >::enabled ) config.addEntryEnum( "euler" ); - if( tnlConfigTagExplicitSolver< ConfigTag, tnlExplicitMersonSolverTag >::enabled ) + if( tnlMeshConfigExplicitSolver< MeshConfig, tnlExplicitMersonSolverTag >::enabled ) config.addEntryEnum( "merson" ); } - if( tnlConfigTagTimeDiscretisation< ConfigTag, tnlSemiImplicitTimeDiscretisationTag >::enabled ) + if( tnlMeshConfigTimeDiscretisation< MeshConfig, tnlSemiImplicitTimeDiscretisationTag >::enabled ) { - if( tnlConfigTagSemiImplicitSolver< ConfigTag, tnlSemiImplicitCGSolverTag >::enabled ) + if( tnlMeshConfigSemiImplicitSolver< MeshConfig, tnlSemiImplicitCGSolverTag >::enabled ) config.addEntryEnum( "cg" ); - if( tnlConfigTagSemiImplicitSolver< ConfigTag, tnlSemiImplicitBICGStabSolverTag >::enabled ) + if( tnlMeshConfigSemiImplicitSolver< MeshConfig, tnlSemiImplicitBICGStabSolverTag >::enabled ) config.addEntryEnum( "bicgstab" ); - if( tnlConfigTagSemiImplicitSolver< ConfigTag, tnlSemiImplicitGMRESSolverTag >::enabled ) + if( tnlMeshConfigSemiImplicitSolver< MeshConfig, tnlSemiImplicitGMRESSolverTag >::enabled ) config.addEntryEnum( "gmres" ); - if( tnlConfigTagSemiImplicitSolver< ConfigTag, tnlSemiImplicitSORSolverTag >::enabled ) + if( tnlMeshConfigSemiImplicitSolver< MeshConfig, tnlSemiImplicitSORSolverTag >::enabled ) config.addEntryEnum( "sor" ); } - if( tnlConfigTagTimeDiscretisation< ConfigTag, tnlExplicitTimeDiscretisationTag >::enabled || - tnlConfigTagTimeDiscretisation< ConfigTag, tnlSemiImplicitTimeDiscretisationTag >::enabled ) + if( tnlMeshConfigTimeDiscretisation< MeshConfig, tnlExplicitTimeDiscretisationTag >::enabled || + tnlMeshConfigTimeDiscretisation< MeshConfig, tnlSemiImplicitTimeDiscretisationTag >::enabled ) { config.addDelimiter( " === Iterative solvers parameters === " ); tnlIterativeSolver< double, int >::configSetup( config ); } - if( tnlConfigTagTimeDiscretisation< ConfigTag, tnlExplicitTimeDiscretisationTag >::enabled ) + if( tnlMeshConfigTimeDiscretisation< MeshConfig, tnlExplicitTimeDiscretisationTag >::enabled ) { config.addDelimiter( " === Explicit solvers parameters === " ); tnlExplicitSolver< tnlDummyProblem< double, tnlHost, int > >::configSetup( config ); - if( tnlConfigTagExplicitSolver< ConfigTag, tnlExplicitEulerSolverTag >::enabled ) + if( tnlMeshConfigExplicitSolver< MeshConfig, tnlExplicitEulerSolverTag >::enabled ) tnlEulerSolver< tnlDummyProblem< double, tnlHost, int > >::configSetup( config ); - if( tnlConfigTagExplicitSolver< ConfigTag, tnlExplicitMersonSolverTag >::enabled ) + if( tnlMeshConfigExplicitSolver< MeshConfig, tnlExplicitMersonSolverTag >::enabled ) tnlMersonSolver< tnlDummyProblem< double, tnlHost, int > >::configSetup( config ); } - if( tnlConfigTagTimeDiscretisation< ConfigTag, tnlSemiImplicitTimeDiscretisationTag >::enabled ) + if( tnlMeshConfigTimeDiscretisation< MeshConfig, tnlSemiImplicitTimeDiscretisationTag >::enabled ) { config.addDelimiter( " === Semi-implicit solvers parameters === " ); typedef tnlCSRMatrix< double, tnlHost, int > MatrixType; - if( tnlConfigTagSemiImplicitSolver< ConfigTag, tnlSemiImplicitCGSolverTag >::enabled ) + if( tnlMeshConfigSemiImplicitSolver< MeshConfig, tnlSemiImplicitCGSolverTag >::enabled ) tnlCGSolver< MatrixType >::configSetup( config ); - if( tnlConfigTagSemiImplicitSolver< ConfigTag, tnlSemiImplicitBICGStabSolverTag >::enabled ) + if( tnlMeshConfigSemiImplicitSolver< MeshConfig, tnlSemiImplicitBICGStabSolverTag >::enabled ) tnlBICGStabSolver< MatrixType >::configSetup( config ); - if( tnlConfigTagSemiImplicitSolver< ConfigTag, tnlSemiImplicitGMRESSolverTag >::enabled ) + if( tnlMeshConfigSemiImplicitSolver< MeshConfig, tnlSemiImplicitGMRESSolverTag >::enabled ) tnlGMRESSolver< MatrixType >::configSetup( config ); - if( tnlConfigTagSemiImplicitSolver< ConfigTag, tnlSemiImplicitSORSolverTag >::enabled ) + if( tnlMeshConfigSemiImplicitSolver< MeshConfig, tnlSemiImplicitSORSolverTag >::enabled ) tnlSORSolver< MatrixType >::configSetup( config ); } diff --git a/src/solvers/tnlSolverInitiator.h b/src/solvers/tnlSolverInitiator.h index 525d304c9d2bfea36396c2b0e35cbfae65903527..5cad3ee8150864a21a8b27d5bcd6f394de168514 100644 --- a/src/solvers/tnlSolverInitiator.h +++ b/src/solvers/tnlSolverInitiator.h @@ -22,8 +22,8 @@ #include <config/tnlParameterContainer.h> #include <solvers/tnlBuildConfigTags.h> -template< template< typename Real, typename Device, typename Index, typename MeshType, typename ConfigTag, typename SolverStarter > class ProblemSetter, - typename ConfigTag > +template< template< typename Real, typename Device, typename Index, typename MeshType, typename MeshConfig, typename SolverStarter > class ProblemSetter, + typename MeshConfig > class tnlSolverInitiator : public tnlObject { public: diff --git a/src/solvers/tnlSolverInitiator_impl.h b/src/solvers/tnlSolverInitiator_impl.h index 0876bd27527879a2a9cf4faaa071fc5f5bfa90df..634336602fc9e3f41638c7f50639e58a8b177ea8 100644 --- a/src/solvers/tnlSolverInitiator_impl.h +++ b/src/solvers/tnlSolverInitiator_impl.h @@ -25,48 +25,48 @@ #include <core/tnlHost.h> #include <core/tnlCuda.h> -template< template< typename Real, typename Device, typename Index, typename MeshType, typename ConfigTag, typename SolverStarter > class ProblemSetter, +template< template< typename Real, typename Device, typename Index, typename MeshType, typename MeshConfig, typename SolverStarter > class ProblemSetter, typename Real, - typename ConfigTag, - bool enabled = tnlConfigTagReal< ConfigTag, Real >::enabled > + typename MeshConfig, + bool enabled = tnlMeshConfigReal< MeshConfig, Real >::enabled > class tnlSolverInitiatorRealResolver{}; -template< template< typename Real, typename Device, typename Index, typename MeshType, typename ConfigTag, typename SolverStarter > class ProblemSetter, +template< template< typename Real, typename Device, typename Index, typename MeshType, typename MeshConfig, typename SolverStarter > class ProblemSetter, typename Real, typename Device, - typename ConfigTag, - bool enabled = tnlConfigTagDevice< ConfigTag, Device >::enabled > + typename MeshConfig, + bool enabled = tnlMeshConfigDevice< MeshConfig, Device >::enabled > class tnlSolverInitiatorDeviceResolver{}; -template< template< typename Real, typename Device, typename Index, typename MeshType, typename ConfigTag, typename SolverStarter > class ProblemSetter, +template< template< typename Real, typename Device, typename Index, typename MeshType, typename MeshConfig, typename SolverStarter > class ProblemSetter, typename Real, typename Device, typename Index, - typename ConfigTag, - bool enabled = tnlConfigTagIndex< ConfigTag, Index >::enabled > + typename MeshConfig, + bool enabled = tnlMeshConfigIndex< MeshConfig, Index >::enabled > class tnlSolverInitiatorIndexResolver{}; -template< template< typename Real, typename Device, typename Index, typename MeshType, typename ConfigTag, typename SolverStarter > class ProblemSetter, - typename ConfigTag > -bool tnlSolverInitiator< ProblemSetter, ConfigTag > :: run( const tnlParameterContainer& parameters ) +template< template< typename Real, typename Device, typename Index, typename MeshType, typename MeshConfig, typename SolverStarter > class ProblemSetter, + typename MeshConfig > +bool tnlSolverInitiator< ProblemSetter, MeshConfig > :: run( const tnlParameterContainer& parameters ) { const tnlString& realType = parameters. getParameter< tnlString >( "real-type" ); if( parameters. getParameter< int >( "verbose" ) ) cout << "Setting RealType to ... " << realType << endl; if( realType == "float" ) - return tnlSolverInitiatorRealResolver< ProblemSetter, float, ConfigTag >::run( parameters ); + return tnlSolverInitiatorRealResolver< ProblemSetter, float, MeshConfig >::run( parameters ); if( realType == "double" ) - return tnlSolverInitiatorRealResolver< ProblemSetter, double, ConfigTag >::run( parameters ); + return tnlSolverInitiatorRealResolver< ProblemSetter, double, MeshConfig >::run( parameters ); if( realType == "long-double" ) - return tnlSolverInitiatorRealResolver< ProblemSetter, long double, ConfigTag >::run( parameters ); + return tnlSolverInitiatorRealResolver< ProblemSetter, long double, MeshConfig >::run( parameters ); cerr << "The real type '" << realType << "' is not defined. " << endl; return false; }; -template< template< typename Real, typename Device, typename Index, typename MeshType, typename ConfigTag, typename SolverStarter > class ProblemSetter, +template< template< typename Real, typename Device, typename Index, typename MeshType, typename MeshConfig, typename SolverStarter > class ProblemSetter, typename Real, - typename ConfigTag > -class tnlSolverInitiatorRealResolver< ProblemSetter, Real, ConfigTag, true > + typename MeshConfig > +class tnlSolverInitiatorRealResolver< ProblemSetter, Real, MeshConfig, true > { public: static bool run( const tnlParameterContainer& parameters ) @@ -76,18 +76,18 @@ class tnlSolverInitiatorRealResolver< ProblemSetter, Real, ConfigTag, true > cout << "Setting DeviceType to ... " << device << endl; if( device == "host" ) - return tnlSolverInitiatorDeviceResolver< ProblemSetter, Real, tnlHost, ConfigTag >::run( parameters ); + return tnlSolverInitiatorDeviceResolver< ProblemSetter, Real, tnlHost, MeshConfig >::run( parameters ); if( device == "cuda" ) - return tnlSolverInitiatorDeviceResolver< ProblemSetter, Real, tnlCuda, ConfigTag >::run( parameters ); + return tnlSolverInitiatorDeviceResolver< ProblemSetter, Real, tnlCuda, MeshConfig >::run( parameters ); cerr << "The device '" << device << "' is not defined. " << endl; return false; } }; -template< template< typename Real, typename Device, typename Index, typename MeshType, typename ConfigTag, typename SolverStarter > class ProblemSetter, +template< template< typename Real, typename Device, typename Index, typename MeshType, typename MeshConfig, typename SolverStarter > class ProblemSetter, typename Real, - typename ConfigTag > -class tnlSolverInitiatorRealResolver< ProblemSetter, Real, ConfigTag, false > + typename MeshConfig > +class tnlSolverInitiatorRealResolver< ProblemSetter, Real, MeshConfig, false > { public: static bool run( const tnlParameterContainer& parameters ) @@ -97,11 +97,11 @@ class tnlSolverInitiatorRealResolver< ProblemSetter, Real, ConfigTag, false > } }; -template< template< typename Real, typename Device, typename Index, typename MeshType, typename ConfigTag, typename SolverStarter > class ProblemSetter, +template< template< typename Real, typename Device, typename Index, typename MeshType, typename MeshConfig, typename SolverStarter > class ProblemSetter, typename Real, typename Device, - typename ConfigTag > -class tnlSolverInitiatorDeviceResolver< ProblemSetter, Real, Device, ConfigTag, true > + typename MeshConfig > +class tnlSolverInitiatorDeviceResolver< ProblemSetter, Real, Device, MeshConfig, true > { public: static bool run( const tnlParameterContainer& parameters ) @@ -110,21 +110,21 @@ class tnlSolverInitiatorDeviceResolver< ProblemSetter, Real, Device, ConfigTag, if( parameters. getParameter< int >( "verbose" ) ) cout << "Setting IndexType to ... " << indexType << endl; if( indexType == "short-int" ) - return tnlSolverInitiatorIndexResolver< ProblemSetter, Real, Device, short int, ConfigTag >::run( parameters ); + return tnlSolverInitiatorIndexResolver< ProblemSetter, Real, Device, short int, MeshConfig >::run( parameters ); if( indexType == "int" ) - return tnlSolverInitiatorIndexResolver< ProblemSetter, Real, Device, int, ConfigTag >::run( parameters ); + return tnlSolverInitiatorIndexResolver< ProblemSetter, Real, Device, int, MeshConfig >::run( parameters ); if( indexType == "long int" ) - return tnlSolverInitiatorIndexResolver< ProblemSetter, Real, Device, long int, ConfigTag >::run( parameters ); + return tnlSolverInitiatorIndexResolver< ProblemSetter, Real, Device, long int, MeshConfig >::run( parameters ); cerr << "The index type '" << indexType << "' is not defined. " << endl; return false; } }; -template< template< typename Real, typename Device, typename Index, typename MeshType, typename ConfigTag, typename SolverStarter > class ProblemSetter, +template< template< typename Real, typename Device, typename Index, typename MeshType, typename MeshConfig, typename SolverStarter > class ProblemSetter, typename Real, typename Device, - typename ConfigTag > -class tnlSolverInitiatorDeviceResolver< ProblemSetter, Real, Device, ConfigTag, false > + typename MeshConfig > +class tnlSolverInitiatorDeviceResolver< ProblemSetter, Real, Device, MeshConfig, false > { public: static bool run( const tnlParameterContainer& parameters ) @@ -134,12 +134,12 @@ class tnlSolverInitiatorDeviceResolver< ProblemSetter, Real, Device, ConfigTag, } }; -template< template< typename Real, typename Device, typename Index, typename MeshType, typename ConfigTag, typename SolverStarter > class ProblemSetter, +template< template< typename Real, typename Device, typename Index, typename MeshType, typename MeshConfig, typename SolverStarter > class ProblemSetter, typename Real, typename Device, typename Index, - typename ConfigTag > -class tnlSolverInitiatorIndexResolver< ProblemSetter, Real, Device, Index, ConfigTag, false > + typename MeshConfig > +class tnlSolverInitiatorIndexResolver< ProblemSetter, Real, Device, Index, MeshConfig, false > { public: static bool run( const tnlParameterContainer& parameters ) @@ -149,17 +149,17 @@ class tnlSolverInitiatorIndexResolver< ProblemSetter, Real, Device, Index, Confi } }; -template< template< typename Real, typename Device, typename Index, typename MeshType, typename ConfigTag, typename SolverStarter > class ProblemSetter, +template< template< typename Real, typename Device, typename Index, typename MeshType, typename MeshConfig, typename SolverStarter > class ProblemSetter, typename Real, typename Device, typename Index, - typename ConfigTag > -class tnlSolverInitiatorIndexResolver< ProblemSetter, Real, Device, Index, ConfigTag, true > + typename MeshConfig > +class tnlSolverInitiatorIndexResolver< ProblemSetter, Real, Device, Index, MeshConfig, true > { public: static bool run( const tnlParameterContainer& parameters ) { - return tnlMeshTypeResolver< ProblemSetter, Real, Device, Index, ConfigTag >::run( parameters ); + return tnlMeshTypeResolver< ProblemSetter, Real, Device, Index, MeshConfig >::run( parameters ); } }; diff --git a/src/solvers/tnlSolverStarter.h b/src/solvers/tnlSolverStarter.h index a2f604bedc3b21d29e34b58d967b5708ee354abb..7b9bc2d8f3757487ac9f479ac274ab18ddef4ddd 100644 --- a/src/solvers/tnlSolverStarter.h +++ b/src/solvers/tnlSolverStarter.h @@ -23,7 +23,7 @@ #include <core/tnlTimerCPU.h> #include <ostream> -template< typename ConfigTag > +template< typename MeshConfig > class tnlSolverStarter { public: diff --git a/src/solvers/tnlSolverStarter_impl.h b/src/solvers/tnlSolverStarter_impl.h index 09e61c33e25d96b0d63cbe30891d21b274f7a296..7a2728e1aa3aba5ad730cf275c41cd9ecb0cf532 100644 --- a/src/solvers/tnlSolverStarter_impl.h +++ b/src/solvers/tnlSolverStarter_impl.h @@ -34,49 +34,49 @@ #include <solvers/ode/tnlODESolverMonitor.h> template< typename Problem, - typename ConfigTag, + typename MeshConfig, typename TimeStepper = typename Problem::TimeStepper > class tnlUserDefinedTimeDiscretisationSetter; template< typename Problem, typename TimeDiscretisation, - typename ConfigTag, - bool enabled = tnlConfigTagTimeDiscretisation< ConfigTag, TimeDiscretisation >::enabled > + typename MeshConfig, + bool enabled = tnlMeshConfigTimeDiscretisation< MeshConfig, TimeDiscretisation >::enabled > class tnlSolverStarterTimeDiscretisationSetter{}; template< typename Problem, typename ExplicitSolver, - typename ConfigTag, - bool enabled = tnlConfigTagExplicitSolver< ConfigTag, ExplicitSolver >::enabled > + typename MeshConfig, + bool enabled = tnlMeshConfigExplicitSolver< MeshConfig, ExplicitSolver >::enabled > class tnlSolverStarterExplicitSolverSetter{}; template< typename Problem, typename SemiImplicitSolver, - typename ConfigTag, - bool enabled = tnlConfigTagSemiImplicitSolver< ConfigTag, SemiImplicitSolver >::enabled > + typename MeshConfig, + bool enabled = tnlMeshConfigSemiImplicitSolver< MeshConfig, SemiImplicitSolver >::enabled > class tnlSolverStarterSemiImplicitSolverSetter{}; template< typename Problem, typename ExplicitSolver, typename TimeStepper, - typename ConfigTag > + typename MeshConfig > class tnlSolverStarterExplicitTimeStepperSetter; template< typename Problem, typename TimeStepper, - typename ConfigTag > + typename MeshConfig > class tnlSolverStarterSemiImplicitTimeStepperSetter; -template< typename ConfigTag > -tnlSolverStarter< ConfigTag > :: tnlSolverStarter() +template< typename MeshConfig > +tnlSolverStarter< MeshConfig > :: tnlSolverStarter() : logWidth( 80 ) { } -template< typename ConfigTag > +template< typename MeshConfig > template< typename Problem > -bool tnlSolverStarter< ConfigTag > :: run( const tnlParameterContainer& parameters ) +bool tnlSolverStarter< MeshConfig > :: run( const tnlParameterContainer& parameters ) { /**** * Create and set-up the problem @@ -88,11 +88,11 @@ bool tnlSolverStarter< ConfigTag > :: run( const tnlParameterContainer& paramete return false; } - return tnlUserDefinedTimeDiscretisationSetter< Problem, ConfigTag >::run( problem, parameters ); + return tnlUserDefinedTimeDiscretisationSetter< Problem, MeshConfig >::run( problem, parameters ); } template< typename Problem, - typename ConfigTag, + typename MeshConfig, typename TimeStepper > class tnlUserDefinedTimeDiscretisationSetter { @@ -106,14 +106,14 @@ class tnlUserDefinedTimeDiscretisationSetter cerr << "The time stepper initiation failed!" << endl; return false; } - tnlSolverStarter< ConfigTag > solverStarter; + tnlSolverStarter< MeshConfig > solverStarter; return solverStarter.template runPDESolver< Problem, TimeStepper >( problem, parameters, timeStepper ); } }; template< typename Problem, - typename ConfigTag > -class tnlUserDefinedTimeDiscretisationSetter< Problem, ConfigTag, void > + typename MeshConfig > +class tnlUserDefinedTimeDiscretisationSetter< Problem, MeshConfig, void > { public: static bool run( Problem& problem, @@ -124,11 +124,11 @@ class tnlUserDefinedTimeDiscretisationSetter< Problem, ConfigTag, void > */ const tnlString& timeDiscretisation = parameters. getParameter< tnlString>( "time-discretisation" ); if( timeDiscretisation == "explicit" ) - return tnlSolverStarterTimeDiscretisationSetter< Problem, tnlExplicitTimeDiscretisationTag, ConfigTag >::run( problem, parameters ); + return tnlSolverStarterTimeDiscretisationSetter< Problem, tnlExplicitTimeDiscretisationTag, MeshConfig >::run( problem, parameters ); if( timeDiscretisation == "semi-implicit" ) - return tnlSolverStarterTimeDiscretisationSetter< Problem, tnlSemiImplicitTimeDiscretisationTag, ConfigTag >::run( problem, parameters ); + return tnlSolverStarterTimeDiscretisationSetter< Problem, tnlSemiImplicitTimeDiscretisationTag, MeshConfig >::run( problem, parameters ); if( timeDiscretisation == "implicit" ) - return tnlSolverStarterTimeDiscretisationSetter< Problem, tnlImplicitTimeDiscretisationTag, ConfigTag >::run( problem, parameters ); + return tnlSolverStarterTimeDiscretisationSetter< Problem, tnlImplicitTimeDiscretisationTag, MeshConfig >::run( problem, parameters ); cerr << "Uknown time discretisation: " << timeDiscretisation << "." << endl; return false; } @@ -140,8 +140,8 @@ class tnlUserDefinedTimeDiscretisationSetter< Problem, ConfigTag, void > template< typename Problem, typename TimeDiscretisation, - typename ConfigTag > -class tnlSolverStarterTimeDiscretisationSetter< Problem, TimeDiscretisation, ConfigTag, false > + typename MeshConfig > +class tnlSolverStarterTimeDiscretisationSetter< Problem, TimeDiscretisation, MeshConfig, false > { public: static bool run( Problem& problem, @@ -153,8 +153,8 @@ class tnlSolverStarterTimeDiscretisationSetter< Problem, TimeDiscretisation, Con }; template< typename Problem, - typename ConfigTag > -class tnlSolverStarterTimeDiscretisationSetter< Problem, tnlExplicitTimeDiscretisationTag, ConfigTag, true > + typename MeshConfig > +class tnlSolverStarterTimeDiscretisationSetter< Problem, tnlExplicitTimeDiscretisationTag, MeshConfig, true > { public: static bool run( Problem& problem, @@ -168,16 +168,16 @@ class tnlSolverStarterTimeDiscretisationSetter< Problem, tnlExplicitTimeDiscreti return false; } if( discreteSolver == "euler" ) - return tnlSolverStarterExplicitSolverSetter< Problem, tnlExplicitEulerSolverTag, ConfigTag >::run( problem, parameters ); + return tnlSolverStarterExplicitSolverSetter< Problem, tnlExplicitEulerSolverTag, MeshConfig >::run( problem, parameters ); if( discreteSolver == "merson" ) - return tnlSolverStarterExplicitSolverSetter< Problem, tnlExplicitMersonSolverTag, ConfigTag >::run( problem, parameters ); + return tnlSolverStarterExplicitSolverSetter< Problem, tnlExplicitMersonSolverTag, MeshConfig >::run( problem, parameters ); return false; } }; template< typename Problem, - typename ConfigTag > -class tnlSolverStarterTimeDiscretisationSetter< Problem, tnlSemiImplicitTimeDiscretisationTag, ConfigTag, true > + typename MeshConfig > +class tnlSolverStarterTimeDiscretisationSetter< Problem, tnlSemiImplicitTimeDiscretisationTag, MeshConfig, true > { public: static bool run( Problem& problem, @@ -194,20 +194,20 @@ class tnlSolverStarterTimeDiscretisationSetter< Problem, tnlSemiImplicitTimeDisc } if( discreteSolver == "sor" ) - return tnlSolverStarterSemiImplicitSolverSetter< Problem, tnlSemiImplicitSORSolverTag, ConfigTag >::run( problem, parameters ); + return tnlSolverStarterSemiImplicitSolverSetter< Problem, tnlSemiImplicitSORSolverTag, MeshConfig >::run( problem, parameters ); if( discreteSolver == "cg" ) - return tnlSolverStarterSemiImplicitSolverSetter< Problem, tnlSemiImplicitCGSolverTag, ConfigTag >::run( problem, parameters ); + return tnlSolverStarterSemiImplicitSolverSetter< Problem, tnlSemiImplicitCGSolverTag, MeshConfig >::run( problem, parameters ); if( discreteSolver == "bicgstab" ) - return tnlSolverStarterSemiImplicitSolverSetter< Problem, tnlSemiImplicitBICGStabSolverTag, ConfigTag >::run( problem, parameters ); + return tnlSolverStarterSemiImplicitSolverSetter< Problem, tnlSemiImplicitBICGStabSolverTag, MeshConfig >::run( problem, parameters ); if( discreteSolver == "gmres" ) - return tnlSolverStarterSemiImplicitSolverSetter< Problem, tnlSemiImplicitGMRESSolverTag, ConfigTag >::run( problem, parameters ); + return tnlSolverStarterSemiImplicitSolverSetter< Problem, tnlSemiImplicitGMRESSolverTag, MeshConfig >::run( problem, parameters ); return false; } }; template< typename Problem, - typename ConfigTag > -class tnlSolverStarterTimeDiscretisationSetter< Problem, tnlImplicitTimeDiscretisationTag, ConfigTag, true > + typename MeshConfig > +class tnlSolverStarterTimeDiscretisationSetter< Problem, tnlImplicitTimeDiscretisationTag, MeshConfig, true > { public: static bool run( Problem& problem, @@ -224,8 +224,8 @@ class tnlSolverStarterTimeDiscretisationSetter< Problem, tnlImplicitTimeDiscreti template< typename Problem, typename ExplicitSolver, - typename ConfigTag > -class tnlSolverStarterExplicitSolverSetter< Problem, ExplicitSolver, ConfigTag, false > + typename MeshConfig > +class tnlSolverStarterExplicitSolverSetter< Problem, ExplicitSolver, MeshConfig, false > { public: static bool run( Problem& problem, @@ -237,8 +237,8 @@ class tnlSolverStarterExplicitSolverSetter< Problem, ExplicitSolver, ConfigTag, }; template< typename Problem, - typename ConfigTag > -class tnlSolverStarterExplicitSolverSetter< Problem, tnlExplicitEulerSolverTag, ConfigTag, true > + typename MeshConfig > +class tnlSolverStarterExplicitSolverSetter< Problem, tnlExplicitEulerSolverTag, MeshConfig, true > { public: static bool run( Problem& problem, @@ -249,13 +249,13 @@ class tnlSolverStarterExplicitSolverSetter< Problem, tnlExplicitEulerSolverTag, return tnlSolverStarterExplicitTimeStepperSetter< Problem, ExplicitSolver, TimeStepper, - ConfigTag >::run( problem, parameters ); + MeshConfig >::run( problem, parameters ); } }; template< typename Problem, - typename ConfigTag > -class tnlSolverStarterExplicitSolverSetter< Problem, tnlExplicitMersonSolverTag, ConfigTag, true > + typename MeshConfig > +class tnlSolverStarterExplicitSolverSetter< Problem, tnlExplicitMersonSolverTag, MeshConfig, true > { public: static bool run( Problem& problem, @@ -266,7 +266,7 @@ class tnlSolverStarterExplicitSolverSetter< Problem, tnlExplicitMersonSolverTag, return tnlSolverStarterExplicitTimeStepperSetter< Problem, ExplicitSolver, TimeStepper, - ConfigTag >::run( problem, parameters ); + MeshConfig >::run( problem, parameters ); } }; @@ -276,8 +276,8 @@ class tnlSolverStarterExplicitSolverSetter< Problem, tnlExplicitMersonSolverTag, template< typename Problem, typename SemiImplicitSolver, - typename ConfigTag > -class tnlSolverStarterSemiImplicitSolverSetter< Problem, SemiImplicitSolver, ConfigTag, false > + typename MeshConfig > +class tnlSolverStarterSemiImplicitSolverSetter< Problem, SemiImplicitSolver, MeshConfig, false > { public: static bool run( Problem& problem, @@ -289,8 +289,8 @@ class tnlSolverStarterSemiImplicitSolverSetter< Problem, SemiImplicitSolver, Con }; template< typename Problem, - typename ConfigTag > -class tnlSolverStarterSemiImplicitSolverSetter< Problem, tnlSemiImplicitSORSolverTag, ConfigTag, true > + typename MeshConfig > +class tnlSolverStarterSemiImplicitSolverSetter< Problem, tnlSemiImplicitSORSolverTag, MeshConfig, true > { public: static bool run( Problem& problem, @@ -301,13 +301,13 @@ class tnlSolverStarterSemiImplicitSolverSetter< Problem, tnlSemiImplicitSORSolve typedef tnlSemiImplicitTimeStepper< Problem, LinearSystemSolver > TimeStepper; return tnlSolverStarterSemiImplicitTimeStepperSetter< Problem, TimeStepper, - ConfigTag >::run( problem, parameters ); + MeshConfig >::run( problem, parameters ); } }; template< typename Problem, - typename ConfigTag > -class tnlSolverStarterSemiImplicitSolverSetter< Problem, tnlSemiImplicitCGSolverTag, ConfigTag, true > + typename MeshConfig > +class tnlSolverStarterSemiImplicitSolverSetter< Problem, tnlSemiImplicitCGSolverTag, MeshConfig, true > { public: static bool run( Problem& problem, @@ -318,13 +318,13 @@ class tnlSolverStarterSemiImplicitSolverSetter< Problem, tnlSemiImplicitCGSolver typedef tnlSemiImplicitTimeStepper< Problem, LinearSystemSolver > TimeStepper; return tnlSolverStarterSemiImplicitTimeStepperSetter< Problem, TimeStepper, - ConfigTag >::run( problem, parameters ); + MeshConfig >::run( problem, parameters ); } }; template< typename Problem, - typename ConfigTag > -class tnlSolverStarterSemiImplicitSolverSetter< Problem, tnlSemiImplicitBICGStabSolverTag, ConfigTag, true > + typename MeshConfig > +class tnlSolverStarterSemiImplicitSolverSetter< Problem, tnlSemiImplicitBICGStabSolverTag, MeshConfig, true > { public: static bool run( Problem& problem, @@ -335,13 +335,13 @@ class tnlSolverStarterSemiImplicitSolverSetter< Problem, tnlSemiImplicitBICGStab typedef tnlSemiImplicitTimeStepper< Problem, LinearSystemSolver > TimeStepper; return tnlSolverStarterSemiImplicitTimeStepperSetter< Problem, TimeStepper, - ConfigTag >::run( problem, parameters ); + MeshConfig >::run( problem, parameters ); } }; template< typename Problem, - typename ConfigTag > -class tnlSolverStarterSemiImplicitSolverSetter< Problem, tnlSemiImplicitGMRESSolverTag, ConfigTag, true > + typename MeshConfig > +class tnlSolverStarterSemiImplicitSolverSetter< Problem, tnlSemiImplicitGMRESSolverTag, MeshConfig, true > { public: static bool run( Problem& problem, @@ -352,7 +352,7 @@ class tnlSolverStarterSemiImplicitSolverSetter< Problem, tnlSemiImplicitGMRESSol typedef tnlSemiImplicitTimeStepper< Problem, LinearSystemSolver > TimeStepper; return tnlSolverStarterSemiImplicitTimeStepperSetter< Problem, TimeStepper, - ConfigTag >::run( problem, parameters ); + MeshConfig >::run( problem, parameters ); } }; @@ -363,7 +363,7 @@ class tnlSolverStarterSemiImplicitSolverSetter< Problem, tnlSemiImplicitGMRESSol template< typename Problem, typename ExplicitSolver, typename TimeStepper, - typename ConfigTag > + typename MeshConfig > class tnlSolverStarterExplicitTimeStepperSetter { public: @@ -393,7 +393,7 @@ class tnlSolverStarterExplicitTimeStepperSetter } timeStepper.setSolver( explicitSolver ); - tnlSolverStarter< ConfigTag > solverStarter; + tnlSolverStarter< MeshConfig > solverStarter; return solverStarter.template runPDESolver< Problem, TimeStepper >( problem, parameters, timeStepper ); }; }; @@ -403,7 +403,7 @@ class tnlSolverStarterExplicitTimeStepperSetter */ template< typename Problem, typename TimeStepper, - typename ConfigTag > + typename MeshConfig > class tnlSolverStarterSemiImplicitTimeStepperSetter { public: @@ -434,7 +434,7 @@ class tnlSolverStarterSemiImplicitTimeStepperSetter } timeStepper.setSolver( linearSystemSolver ); - tnlSolverStarter< ConfigTag > solverStarter; + tnlSolverStarter< MeshConfig > solverStarter; return solverStarter.template runPDESolver< Problem, TimeStepper >( problem, parameters, timeStepper ); }; }; @@ -445,9 +445,9 @@ class tnlSolverStarterSemiImplicitTimeStepperSetter #ifdef UNDEF -template< typename ConfigTag > +template< typename MeshConfig > template< typename Problem > -bool tnlSolverStarter< ConfigTag > :: setDiscreteSolver( Problem& problem, +bool tnlSolverStarter< MeshConfig > :: setDiscreteSolver( Problem& problem, const tnlParameterContainer& parameters ) { if( ( discreteSolver == "sor" || @@ -467,7 +467,6 @@ bool tnlSolverStarter< ConfigTag > :: setDiscreteSolver( Problem& problem, typename Problem :: DiscreteSolverPreconditioner > DiscreteSolver; DiscreteSolver solver; double omega = parameters. getParameter< double >( "sor-omega" ); - solver. setName( "sor-solver" ); solver. setOmega( omega ); //solver. setVerbose( this -> verbose ); return setSemiImplicitTimeDiscretisation< Problem >( problem, parameters, solver ); @@ -478,7 +477,6 @@ bool tnlSolverStarter< ConfigTag > :: setDiscreteSolver( Problem& problem, typedef tnlCGSolver< typename Problem :: DiscreteSolverMatrixType, typename Problem :: DiscreteSolverPreconditioner > DiscreteSolver; DiscreteSolver solver; - solver. setName( "cg-solver" ); //solver. setVerbose( this -> verbose ); return setSemiImplicitTimeDiscretisation< Problem >( problem, parameters, solver ); } @@ -488,7 +486,6 @@ bool tnlSolverStarter< ConfigTag > :: setDiscreteSolver( Problem& problem, typedef tnlBICGStabSolver< typename Problem :: DiscreteSolverMatrixType, typename Problem :: DiscreteSolverPreconditioner > DiscreteSolver; DiscreteSolver solver; - solver. setName( "bicg-solver" ); //solver. setVerbose( this -> verbose ); return setSemiImplicitTimeDiscretisation< Problem >( problem, parameters, solver ); } @@ -499,7 +496,6 @@ bool tnlSolverStarter< ConfigTag > :: setDiscreteSolver( Problem& problem, typename Problem :: DiscreteSolverPreconditioner > DiscreteSolver; DiscreteSolver solver; int restarting = parameters. getParameter< int >( "gmres-restarting" ); - solver. setName( "gmres-solver" ); solver. setRestarting( restarting ); //solver. setVerbose( this -> verbose ); return setSemiImplicitTimeDiscretisation< Problem >( problem, parameters, solver ); @@ -509,10 +505,10 @@ bool tnlSolverStarter< ConfigTag > :: setDiscreteSolver( Problem& problem, } #endif -template< typename ConfigTag > +template< typename MeshConfig > template< typename Problem, typename TimeStepper > -bool tnlSolverStarter< ConfigTag > :: runPDESolver( Problem& problem, +bool tnlSolverStarter< MeshConfig > :: runPDESolver( Problem& problem, const tnlParameterContainer& parameters, TimeStepper& timeStepper ) { @@ -625,9 +621,9 @@ bool tnlSolverStarter< ConfigTag > :: runPDESolver( Problem& problem, return returnCode; } -template< typename ConfigTag > +template< typename MeshConfig > template< typename Solver > -bool tnlSolverStarter< ConfigTag > :: writeEpilog( ostream& str, const Solver& solver ) +bool tnlSolverStarter< MeshConfig > :: writeEpilog( ostream& str, const Solver& solver ) { tnlLogger logger( logWidth, str ); logger.writeCurrentTime( "Finished at:" ); diff --git a/src/solvers/tnlSolver_impl.h b/src/solvers/tnlSolver_impl.h index 7fa9f6b970dd0c736b86282348b39d4f068ea1bd..33d9b2fe8b794321db5ec0089f459959ed0bfd1e 100644 --- a/src/solvers/tnlSolver_impl.h +++ b/src/solvers/tnlSolver_impl.h @@ -22,21 +22,21 @@ #include <solvers/tnlSolverStarter.h> #include <solvers/tnlSolverConfig.h> -template< template< typename Real, typename Device, typename Index, typename MeshType, typename ConfigTag, typename SolverStarter > class ProblemSetter, - template< typename ConfigTag > class ProblemConfig, - typename ConfigTag > +template< template< typename Real, typename Device, typename Index, typename MeshType, typename MeshConfig, typename SolverStarter > class ProblemSetter, + template< typename MeshConfig > class ProblemConfig, + typename MeshConfig > bool -tnlSolver< ProblemSetter, ProblemConfig, ConfigTag >:: +tnlSolver< ProblemSetter, ProblemConfig, MeshConfig >:: run( int argc, char* argv[] ) { tnlParameterContainer parameters; tnlConfigDescription configDescription; - ProblemConfig< ConfigTag >::configSetup( configDescription ); - tnlSolverConfig< ConfigTag, ProblemConfig< ConfigTag> >::configSetup( configDescription ); + ProblemConfig< MeshConfig >::configSetup( configDescription ); + tnlSolverConfig< MeshConfig, ProblemConfig< MeshConfig> >::configSetup( configDescription ); if( ! parseCommandLine( argc, argv, configDescription, parameters ) ) return false; - tnlSolverInitiator< ProblemSetter, ConfigTag > solverInitiator; + tnlSolverInitiator< ProblemSetter, MeshConfig > solverInitiator; return solverInitiator.run( parameters ); }; diff --git a/tests/benchmarks/tnl-cuda-benchmarks.h b/tests/benchmarks/tnl-cuda-benchmarks.h index 38c108b5d90aad5232d0428c8ffa1bb9878526e6..09993df3fbb2163268180269fca5a73d624f1892 100644 --- a/tests/benchmarks/tnl-cuda-benchmarks.h +++ b/tests/benchmarks/tnl-cuda-benchmarks.h @@ -21,12 +21,51 @@ #include <tnlConfig.h> #include <core/vectors/tnlVector.h> #include <core/tnlTimerRT.h> +#include <matrices/tnlSlicedEllpackMatrix.h> +#include <matrices/tnlEllpackMatrix.h> #ifdef HAVE_CUBLAS //#include <cublas.h> #endif +template< typename Matrix > +__global__ void setCudaTestMatrixKernel( Matrix* matrix, + const int elementsPerRow, + const int gridIdx ) +{ + const int rowIdx = ( gridIdx * tnlCuda::getMaxGridSize() + blockIdx.x ) * blockDim.x + threadIdx.x; + if( rowIdx >= matrix->getRows() ) + return; + int col = rowIdx - elementsPerRow / 2; + for( int element = 0; element < elementsPerRow; element++ ) + { + if( col + element >= 0 && + col + element < matrix->getColumns() ) + matrix->setElementFast( rowIdx, col + element, element + 1 ); + } +} +template< typename Matrix > +void setCudaTestMatrix( Matrix& matrix, + const int elementsPerRow ) +{ + typedef typename Matrix::IndexType IndexType; + typedef typename Matrix::RealType RealType; + Matrix* kernel_matrix = tnlCuda::passToDevice( matrix ); + dim3 cudaBlockSize( 256 ), cudaGridSize( tnlCuda::getMaxGridSize() ); + const IndexType cudaBlocks = roundUpDivision( matrix.getRows(), cudaBlockSize.x ); + const IndexType cudaGrids = roundUpDivision( cudaBlocks, tnlCuda::getMaxGridSize() ); + for( IndexType gridIdx = 0; gridIdx < cudaGrids; gridIdx++ ) + { + if( gridIdx == cudaGrids - 1 ) + cudaGridSize.x = cudaBlocks % tnlCuda::getMaxGridSize(); + setCudaTestMatrixKernel< Matrix > + <<< cudaGridSize, cudaBlockSize >>> + ( kernel_matrix, elementsPerRow, gridIdx ); + checkCudaDevice; + } + tnlCuda::freeFromDevice( kernel_matrix ); +} int main( int argc, char* argv[] ) { @@ -114,8 +153,7 @@ int main( int argc, char* argv[] ) timer.reset(); timer.start(); for( int i = 0; i < loops; i++ ) - resultDevice = deviceVector.scalarProduct( deviceVector ); - cout << "Time: " << timer.getTime() << endl; + resultDevice = deviceVector.scalarProduct( deviceVector2 ); timer.stop(); bandwidth = 2 * datasetSize / timer.getTime(); cout << "Time: " << timer.getTime() << " bandwidth: " << bandwidth << " GB/sec." << endl; @@ -142,8 +180,32 @@ int main( int argc, char* argv[] ) bandwidth = 2 * datasetSize / timer.getTime(); cout << "Time: " << timer.getTime() << " bandwidth: " << bandwidth << " GB/sec." << endl; #endif -#endif - + + cout << "Benchmarking L2 norm on CPU: "; + timer.reset(); + timer.start(); + for( int i = 0; i < loops; i++ ) + resultHost = hostVector.lpNorm( 2.0 ); + timer.stop(); + bandwidth = datasetSize / timer.getTime(); + cout << bandwidth << " GB/sec." << endl; + + cout << "Benchmarking L2 norm on GPU: " << endl; + timer.reset(); + timer.start(); + for( int i = 0; i < loops; i++ ) + resultDevice = deviceVector.lpNorm( 2.0 ); + + timer.stop(); + bandwidth = datasetSize / timer.getTime(); + cout << "Time: " << timer.getTime() << " bandwidth: " << bandwidth << " GB/sec." << endl; + if( resultHost != resultDevice ) + { + cerr << "Error. " << resultHost << " != " << resultDevice << endl; + //return EXIT_FAILURE; + } + + /* cout << "Benchmarking prefix-sum on CPU ..." << endl; timer.reset(); timer.start(); @@ -167,8 +229,73 @@ int main( int argc, char* argv[] ) { cerr << "Error in prefix sum at position " << i << ": " << hostVector.getElement( i ) << " != " << deviceVector.getElement( i ) << endl; } - +*/ + /**** + * Sliced Ellpack test + */ + const int elementsPerRow( 5 ); + typedef tnlEllpackMatrix< double, tnlCuda > DeviceMatrix; + tnlEllpackMatrix< double, tnlHost > hostMatrix; + DeviceMatrix deviceMatrix; + tnlVector< int, tnlHost, int > hostRowLengths; + tnlVector< int, tnlCuda, int > deviceRowLengths; + hostRowLengths.setSize( size ); + deviceRowLengths.setSize( size ); + hostMatrix.setDimensions( size, size ); + deviceMatrix.setDimensions( size, size ); + hostRowLengths.setValue( elementsPerRow ); + deviceRowLengths.setValue( elementsPerRow ); + hostMatrix.setCompressedRowsLengths( hostRowLengths ); + if( ! deviceMatrix.setCompressedRowsLengths( deviceRowLengths ) ) + { + cerr << "Unable to allocate matrix elements." << endl; + return false; + } + int elements( 0 ); + for( int row = 0; row < size; row++ ) + { + if( row % 100 == 0 ) + cout << "Row " << row << "/" << size << " \r" << flush; + int col = row - elementsPerRow / 2; + for( int element = 0; element < elementsPerRow; element++ ) + { + if( col + element >= 0 && col + element < size ) + { + hostMatrix.setElement( row, col + element, element + 1 ); + //deviceMatrix.setElement( row, col + element, 1.0 ); + elements++; + } + } + } + cout << endl; + setCudaTestMatrix< DeviceMatrix >( deviceMatrix, elementsPerRow ); + datasetSize = loops * elements * ( 2 * sizeof( Real ) + sizeof( int ) ) / oneGB; + hostVector.setValue( 1.0 ); + deviceVector.setValue( 1.0 ); + cout << "Benchmarking SpMV on CPU: "; + timer.reset(); + for( int i = 0; i < loops; i++ ) + hostMatrix.vectorProduct( hostVector, hostVector2 ); + timer.stop(); + double hostTime = timer.getTime(); + bandwidth = datasetSize / timer.getTime(); + cout << timer.getTime() << " => " << bandwidth << " GB/s" << endl; + + cout << "Benchmarking SpMV on GPU: "; + deviceVector2.setValue( 0.0 ); + timer.reset(); + for( int i = 0; i < loops; i++ ) + deviceMatrix.vectorProduct( deviceVector, deviceVector2 ); + timer.stop(); + + if( hostVector2 != deviceVector2 ) + cerr << "Error in Spmv kernel" << endl; + + bandwidth = datasetSize / timer.getTime(); + cout << timer.getTime() << " => " << bandwidth << " GB/s" << " speedup " << hostTime / timer.getTime() << endl; + return EXIT_SUCCESS; +#endif } #endif /* TNLCUDABENCHMARKS_H_ */ diff --git a/tests/unit-tests/CMakeLists.txt b/tests/unit-tests/CMakeLists.txt index 695b1433e2218c8e2c9c8bbfdaad1bdc5a190e46..d3ac6430a934c53876072e1e079823a67eeb2daa 100755 --- a/tests/unit-tests/CMakeLists.txt +++ b/tests/unit-tests/CMakeLists.txt @@ -15,6 +15,8 @@ ADD_TEST( core/vectors/tnlVectorOperationsTest${mpiExt}${debugExt} ${EXECUTABLE_ ADD_TEST( core/vectors/tnlVectorTest${mpiExt}${debugExt} ${EXECUTABLE_OUTPUT_PATH}/tnlVectorTest${mpiExt}${debugExt} ) ADD_TEST( core/vectors/tnlStaticVectorTest${mpiExt}${debugExt} ${EXECUTABLE_OUTPUT_PATH}/tnlStaticVectorTest${mpiExt}${debugExt} ) +ADD_TEST( core/multimaps/tnlEllpackIndexMultimapTest{mpiExt}${debugExt} ${EXECUTABLE_OUTPUT_PATH}/tnlEllpackIndexMultimapTest${mpiExt}${debugExt} ) + ADD_TEST( matrices/tnlDenseMatrixTest${mpiExt}${debugExt} ${EXECUTABLE_OUTPUT_PATH}/tnlDenseMatrixTest${mpiExt}${debugExt} ) ADD_TEST( matrices/tnlTridiagonalMatrixTest${mpiExt}${debugExt} ${EXECUTABLE_OUTPUT_PATH}/tnlTridiagonalMatrixTest${mpiExt}${debugExt} ) ADD_TEST( matrices/tnlMultidiagonalMatrixTest${mpiExt}${debugExt} ${EXECUTABLE_OUTPUT_PATH}/tnlMultidiagonalMatrixTest${mpiExt}${debugExt} ) diff --git a/tests/unit-tests/core/CMakeLists.txt b/tests/unit-tests/core/CMakeLists.txt index 90f40ff72cd23d748090409e454cf02445af8f09..ce4b4a913532c36528c9962225f4e2552bca1e7b 100755 --- a/tests/unit-tests/core/CMakeLists.txt +++ b/tests/unit-tests/core/CMakeLists.txt @@ -1,6 +1,7 @@ ADD_SUBDIRECTORY( arrays ) ADD_SUBDIRECTORY( cuda ) ADD_SUBDIRECTORY( vectors ) +ADD_SUBDIRECTORY( multimaps ) set( headers tnlFileTester.h tnlStringTester.h diff --git a/tests/unit-tests/core/arrays/tnlArrayTester.h b/tests/unit-tests/core/arrays/tnlArrayTester.h index e9dedf9999dd0361d7bef7a64cd867baf1f67dbd..2b8ea2120b006d097f1677d1fd6804908377116b 100644 --- a/tests/unit-tests/core/arrays/tnlArrayTester.h +++ b/tests/unit-tests/core/arrays/tnlArrayTester.h @@ -91,7 +91,7 @@ class tnlArrayTester : public CppUnit :: TestCase void testSetGetElement() { - tnlArray< ElementType, Device, IndexType > u( "tnlArrayTester :: u" ); + tnlArray< ElementType, Device, IndexType > u; u. setSize( 10 ); for( int i = 0; i < 10; i ++ ) u. setElement( i, i ); @@ -120,9 +120,9 @@ class tnlArrayTester : public CppUnit :: TestCase void testComparisonOperator() { - tnlArray< ElementType, Device, IndexType > u( "tnlArrayTester :: u" ); - tnlArray< ElementType, Device, IndexType > v( "tnlArrayTester :: v" ); - tnlArray< ElementType, Device, IndexType > w( "tnlArrayTester :: w" ); + tnlArray< ElementType, Device, IndexType > u; + tnlArray< ElementType, Device, IndexType > v; + tnlArray< ElementType, Device, IndexType > w; u. setSize( 10 ); v. setSize( 10 ); w. setSize( 10 ); @@ -142,8 +142,6 @@ class tnlArrayTester : public CppUnit :: TestCase { tnlArray< ElementType, Device, IndexType > u; tnlArray< ElementType, Device, IndexType > v; - u. setName( "tnlArrayTester :: testAssignmentOperator :: u" ); - v. setName( "tnlArrayTester :: testAssignmentOperator :: v" ); u. setSize( 10 ); v. setSize( 10 ); for( int i = 0; i < 10; i ++ ) @@ -170,7 +168,7 @@ class tnlArrayTester : public CppUnit :: TestCase void testGetSize() { - tnlArray< ElementType, Device, IndexType > u( "tnlArrayTester :: testSetSize - u" ); + tnlArray< ElementType, Device, IndexType > u; const int maxSize = 10; for( int i = 0; i < maxSize; i ++ ) u. setSize( i ); @@ -180,7 +178,7 @@ class tnlArrayTester : public CppUnit :: TestCase void testReset() { - tnlArray< ElementType, Device, IndexType > u( "tnlArrayTester :: testReset - u" ); + tnlArray< ElementType, Device, IndexType > u; u. setSize( 100 ); CPPUNIT_ASSERT( u. getSize() == 100 ); u. reset(); @@ -196,14 +194,14 @@ class tnlArrayTester : public CppUnit :: TestCase { for( int i = 0; i < 100; i ++ ) { - tnlArray< ElementType, Device, IndexType > u( "tnlArrayTester :: testSetSizeAndDestructor - u" ); + tnlArray< ElementType, Device, IndexType > u; u. setSize( i ); } } void testSaveAndLoad() { - tnlArray< ElementType, Device, IndexType > v( "test-array-v" ); + tnlArray< ElementType, Device, IndexType > v; v. setSize( 100 ); for( int i = 0; i < 100; i ++ ) v. setElement( i, 3.14147 ); @@ -211,7 +209,7 @@ class tnlArrayTester : public CppUnit :: TestCase file. open( "test-file.tnl", tnlWriteMode ); v. save( file ); file. close(); - tnlArray< ElementType, Device, IndexType > u( "test-array-u" ); + tnlArray< ElementType, Device, IndexType > u; file. open( "test-file.tnl", tnlReadMode ); u. load( file ); file. close(); @@ -220,7 +218,7 @@ class tnlArrayTester : public CppUnit :: TestCase void testUnusualStructures() { - tnlArray< testingClassForArrayTester >u ( "test-array" ); + tnlArray< testingClassForArrayTester >u; }; }; diff --git a/tests/unit-tests/core/arrays/tnlMultiArrayTester.h b/tests/unit-tests/core/arrays/tnlMultiArrayTester.h index d8df75763ed8341b2f9c6bb7b5288f5d8d47d800..be799d741dd9b96f4ebd7129e3f7df4db8005d64 100644 --- a/tests/unit-tests/core/arrays/tnlMultiArrayTester.h +++ b/tests/unit-tests/core/arrays/tnlMultiArrayTester.h @@ -138,7 +138,7 @@ class tnlMultiArrayTester : public CppUnit :: TestCase void testSetGetElement() { - tnlMultiArray< Dimensions, ElementType, Device, IndexType > u( "tnlMultiArrayTester :: u" ); + tnlMultiArray< Dimensions, ElementType, Device, IndexType > u; u. setDimensions( 10 ); if( Device::getDevice() == tnlHostDevice ) { @@ -161,9 +161,7 @@ class tnlMultiArrayTester : public CppUnit :: TestCase void testComparisonOperator() { - tnlMultiArray< Dimensions, ElementType, Device, IndexType > u( "tnlMultiArrayTester :: u" ); - tnlMultiArray< Dimensions, ElementType, Device, IndexType > v( "tnlMultiArrayTester :: v" ); - tnlMultiArray< Dimensions, ElementType, Device, IndexType > w( "tnlMultiArrayTester :: w" ); + tnlMultiArray< Dimensions, ElementType, Device, IndexType > u, v, w; u.setDimensions( 10 ); v.setDimensions( 10 ); w.setDimensions( 10 ); @@ -186,8 +184,6 @@ class tnlMultiArrayTester : public CppUnit :: TestCase { tnlMultiArray< Dimensions, ElementType, Device, IndexType > u; tnlMultiArray< Dimensions, ElementType, Device, IndexType > v; - u. setName( "tnlMultiArrayTester :: testEquivalenceOperator :: u" ); - v. setName( "tnlMultiArrayTester :: testEquivalenceOperator :: v" ); u. setDimensions( 10 ); v. setDimensions( 10 ); for( int i = 0; i < 10; i ++ ) @@ -199,7 +195,7 @@ class tnlMultiArrayTester : public CppUnit :: TestCase void testGetSize() { - tnlMultiArray< Dimensions, ElementType, Device, IndexType > u( "tnlMultiArrayTester :: testSetSize - u" ); + tnlMultiArray< Dimensions, ElementType, Device, IndexType > u; const int maxSize = 10; for( int i = 1; i < maxSize; i ++ ) u. setDimensions( i ); @@ -209,7 +205,7 @@ class tnlMultiArrayTester : public CppUnit :: TestCase void testReset() { - tnlMultiArray< Dimensions, ElementType, Device, IndexType > u( "tnlMultiArrayTester :: testReset - u" ); + tnlMultiArray< Dimensions, ElementType, Device, IndexType > u; u.setDimensions( 100 ); CPPUNIT_ASSERT( u. getDimensions().x() == 100 ); u.reset(); @@ -225,14 +221,14 @@ class tnlMultiArrayTester : public CppUnit :: TestCase { for( int i = 1; i < 100; i ++ ) { - tnlMultiArray< Dimensions, ElementType, Device, IndexType > u( "tnlMultiArrayTester :: testSetSizeAndDestructor - u" ); + tnlMultiArray< Dimensions, ElementType, Device, IndexType > u; u. setDimensions( i ); } } void testSaveAndLoad() { - tnlMultiArray< Dimensions, ElementType, Device, IndexType > v( "test-multi-array-v" ); + tnlMultiArray< Dimensions, ElementType, Device, IndexType > v; const int size( 10 ); CPPUNIT_ASSERT( v. setDimensions( size ) ); for( int i = 0; i < size; i ++ ) @@ -241,7 +237,7 @@ class tnlMultiArrayTester : public CppUnit :: TestCase file. open( "test-file.tnl", tnlWriteMode ); CPPUNIT_ASSERT( v. save( file ) ); file. close(); - tnlMultiArray< Dimensions, ElementType, Device, IndexType > u( "test-multi-array-u" ); + tnlMultiArray< Dimensions, ElementType, Device, IndexType > u; file. open( "test-file.tnl", tnlReadMode ); CPPUNIT_ASSERT( u. load( file ) ); file. close(); diff --git a/tests/unit-tests/core/arrays/tnlSharedArrayTester.h b/tests/unit-tests/core/arrays/tnlSharedArrayTester.h index 668203944b6fb5d17d04c4a35d7941006ebe06e0..20153f05fc2a3b4361130e90d419189a6235eaea 100644 --- a/tests/unit-tests/core/arrays/tnlSharedArrayTester.h +++ b/tests/unit-tests/core/arrays/tnlSharedArrayTester.h @@ -69,12 +69,7 @@ class tnlSharedArrayTester : public CppUnit :: TestCase void testComparisonOperator() { - tnlSharedArray< ElementType, Device, IndexType > u; - u. setName( "tnlSharedArrayTester :: u" ); - tnlSharedArray< ElementType, Device, IndexType > v; - v. setName( "tnlSharedArrayTester :: v" ); - tnlSharedArray< ElementType, Device, IndexType > w; - w. setName( "tnlSharedArrayTester :: w" ); + tnlSharedArray< ElementType, Device, IndexType > u, v, w; ElementType uData[ 10 ], vData[ 10 ], wData[ 10 ]; u. bind( uData, 10 ); v. bind( vData, 10 ); @@ -93,10 +88,7 @@ class tnlSharedArrayTester : public CppUnit :: TestCase void testAssignmentOperator() { - tnlSharedArray< ElementType, Device, IndexType > u; - tnlSharedArray< ElementType, Device, IndexType > v; - u. setName( "tnlSharedArrayTester :: u" ); - v. setName( "tnlSharedArrayTester :: v" ); + tnlSharedArray< ElementType, Device, IndexType > u, v; ElementType uData[ 10 ], vData[ 10 ]; u. bind( uData, 10 ); v. bind( vData, 10 ); diff --git a/tests/unit-tests/core/multimaps/CMakeLists.txt b/tests/unit-tests/core/multimaps/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..cb8216cc230c3a1ffd6ab36141a0171dd3428d92 --- /dev/null +++ b/tests/unit-tests/core/multimaps/CMakeLists.txt @@ -0,0 +1,5 @@ +set( headers tnlIndexMultimapTester.h ) + +ADD_EXECUTABLE( tnlEllpackIndexMultimapTest${mpiExt}${debugExt} ${headers} tnlEllpackIndexMultimapTest.cpp ) +TARGET_LINK_LIBRARIES( tnlEllpackIndexMultimapTest${mpiExt}${debugExt} ${CPPUNIT_LIBRARIES} + tnl${mpiExt}${debugExt}-0.1 ) \ No newline at end of file diff --git a/src/mesh/traits/tnlDimensionsTraits.h b/tests/unit-tests/core/multimaps/tnlEllpackIndexMultimapTest.cpp similarity index 54% rename from src/mesh/traits/tnlDimensionsTraits.h rename to tests/unit-tests/core/multimaps/tnlEllpackIndexMultimapTest.cpp index 25bfbc5db6bba202817837224b6bad942a7e3b64..b28bc7b83bab55a143bc0d1ec04c123bd4652f13 100644 --- a/src/mesh/traits/tnlDimensionsTraits.h +++ b/tests/unit-tests/core/multimaps/tnlEllpackIndexMultimapTest.cpp @@ -1,8 +1,8 @@ /*************************************************************************** - tnlDimensionsTraits.h - description + tnlEllpackIndexMultimapTest.cpp - description ------------------- - begin : Feb 11, 2014 - copyright : (C) 2014 by Tomas Oberhuber + begin : Sep 10, 2015 + copyright : (C) 2015 by Tomas Oberhuber email : tomas.oberhuber@fjfi.cvut.cz ***************************************************************************/ @@ -15,28 +15,23 @@ * * ***************************************************************************/ -#ifndef TNLDIMENSIONSTRAITS_H_ -#define TNLDIMENSIONSTRAITS_H_ +#include <tnlConfig.h> +#include <core/tnlHost.h> +#include <cstdlib> -#include <core/tnlAssert.h> +#include <core/multimaps/tnlEllpackIndexMultimap.h> +#include "tnlIndexMultimapTester.h" +#include "../../tnlUnitTestStarter.h" -template< int Dimensions > -class tnlDimensionsTraits +int main( int argc, char* argv[] ) { - public: - - enum { value = Dimensions }; - - typedef tnlDimensionsTraits< Dimensions - 1 > Previous; - - tnlStaticAssert( value >= 0, "The value of the dimensions cannot be negative." ); -}; - -template<> -class tnlDimensionsTraits< 0 > -{ - public: - enum { value = 0 }; -}; - -#endif /* TNLDIMENSIONSTRAITS_H_ */ +#ifdef HAVE_CPPUNIT + if( ! tnlUnitTestStarter :: run< tnlIndexMultimapTester< tnlEllpackIndexMultimap< int, tnlHost > > >() || + ! tnlUnitTestStarter :: run< tnlIndexMultimapTester< tnlEllpackIndexMultimap< long int, tnlHost > > >() + ) + return EXIT_FAILURE; + return EXIT_SUCCESS; +#else + return EXIT_FAILURE; +#endif +} diff --git a/tests/unit-tests/core/multimaps/tnlIndexMultimapTester.h b/tests/unit-tests/core/multimaps/tnlIndexMultimapTester.h new file mode 100644 index 0000000000000000000000000000000000000000..3dcb6626237b22d65886dd4cb1b64bf7044897d9 --- /dev/null +++ b/tests/unit-tests/core/multimaps/tnlIndexMultimapTester.h @@ -0,0 +1,1195 @@ +/*************************************************************************** + tnlIndexMultimapTester.h - description + ------------------- + begin : Sep 10, 2015 + copyright : (C) 2015 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 TNLINDEXMULTIMAPTESTER_H_ +#define TNLINDEXMULTIMAPTESTER_H_ + +template< typename Multimap, + typename TestSetup > +class tnlIndexMultimapTesterSetter +{ + public: + + static bool setup( Multimap& multimap ) + { + return true; + } +}; + +#ifdef HAVE_CPPUNIT +#include <cppunit/TestSuite.h> +#include <cppunit/TestResult.h> +#include <cppunit/TestCaller.h> +#include <cppunit/TestCase.h> +#include <cppunit/Message.h> +#include <core/tnlFile.h> +#include <core/vectors/tnlVector.h> + +#ifdef HAVE_CUDA +template< typename IndexMultimapType > +__global__ void tnlIndexMultimapTester__setElementFastTestCudaKernel( IndexMultimapType* graph, + bool* testResult ); +template< typename IndexMultimapType > +__global__ void tnlIndexMultimapTester__setElementFast_DiagonalIndexMultimapTestCudaKernel( IndexMultimapType* graph, + bool* testResult ); + +template< typename IndexMultimapType > +__global__ void tnlIndexMultimapTester__setElementFast_DenseIndexMultimapTestCudaKernel1( IndexMultimapType* graph, + bool* testResult ); + +template< typename IndexMultimapType > +__global__ void tnlIndexMultimapTester__setElementFast_DenseIndexMultimapTestCudaKernel2( IndexMultimapType* graph, + bool* testResult ); + +template< typename IndexMultimapType > +__global__ void tnlIndexMultimapTester__setElementFast_LowerTriangularIndexMultimapTestCudaKernel1( IndexMultimapType* graph, + bool* testResult ); + +template< typename IndexMultimapType > +__global__ void tnlIndexMultimapTester__setElementFast_LowerTriangularIndexMultimapTestCudaKernel2( IndexMultimapType* graph, + bool* testResult ); + +template< typename IndexMultimapType > +__global__ void tnlIndexMultimapTester__setRowFast_DiagonalIndexMultimapTestCudaKernel( IndexMultimapType* graph, + bool* testResult ); + +template< typename IndexMultimapType > +__global__ void tnlIndexMultimapTester__setRowFast_DenseIndexMultimapTestCudaKernel1( IndexMultimapType* graph, + bool* testResult ); + +template< typename IndexMultimapType > +__global__ void tnlIndexMultimapTester__setRowFast_DenseIndexMultimapTestCudaKernel2( IndexMultimapType* graph, + bool* testResult ); + +template< typename IndexMultimapType > +__global__ void tnlIndexMultimapTester__setRowFast_LowerTriangularIndexMultimapTestCudaKernel( IndexMultimapType* graph, + bool* testResult ); + +#endif + +class tnlIndexMultimapTestDefaultSetup +{}; + +template< typename IndexMultimap, + typename IndexMultimapSetup = tnlIndexMultimapTestDefaultSetup > +class tnlIndexMultimapTester : public CppUnit :: TestCase +{ + public: + typedef IndexMultimap IndexMultimapType; + typedef typename IndexMultimap::DeviceType DeviceType; + typedef typename IndexMultimap::IndexType IndexType; + typedef tnlIndexMultimapTester< IndexMultimapType, IndexMultimapSetup > TesterType; + typedef tnlIndexMultimapTesterSetter< IndexMultimapType, IndexMultimapSetup > IndexMultimapSetter; + typedef typename CppUnit::TestCaller< TesterType > TestCallerType; + + typedef typename IndexMultimapType::ValuesAllocationVectorType ValuesAllocationVectorType; + typedef typename IndexMultimapType::ValuesAccessorType ValuesAccessorType; + + tnlIndexMultimapTester(){}; + + virtual + ~tnlIndexMultimapTester(){}; + + static CppUnit :: Test* suite() + { + tnlString testSuiteName( "tnlIndexMultimapTester< " ); + testSuiteName += IndexMultimapType::getType() + " >"; + + CppUnit :: TestSuite* suiteOfTests = new CppUnit :: TestSuite( testSuiteName.getString() ); + CppUnit :: TestResult result; + + suiteOfTests->addTest( new TestCallerType( "setRangesTest", &TesterType::setRangesTest ) ); + //suiteOfTests->addTest( new TestCallerType( "setLikeTest", &TesterType::setLikeTest ) ); + suiteOfTests->addTest( new TestCallerType( "setElementTest", &TesterType::setElementTest ) ); + /*suiteOfTests->addTest( new TestCallerType( "setElementFastTest", &TesterType::setElementFastTest ) ); + suiteOfTests->addTest( new TestCallerType( "setElement_DiagonalIndexMultimapTest", &TesterType::setElement_DiagonalIndexMultimapTest ) ); + suiteOfTests->addTest( new TestCallerType( "setElementFast_DiagonalIndexMultimapTest", &TesterType::setElementFast_DiagonalIndexMultimapTest ) ); + suiteOfTests->addTest( new TestCallerType( "setElement_DenseIndexMultimapTest", &TesterType::setElement_DenseIndexMultimapTest ) ); + suiteOfTests->addTest( new TestCallerType( "setElementFast_DenseIndexMultimapTest", &TesterType::setElementFast_DenseIndexMultimapTest ) ); + suiteOfTests->addTest( new TestCallerType( "setElement_LowerTriangularIndexMultimapTest", &TesterType::setElement_LowerTriangularIndexMultimapTest ) ); + suiteOfTests->addTest( new TestCallerType( "setElementFast_LowerTriangularIndexMultimapTest", &TesterType::setElementFast_LowerTriangularIndexMultimapTest ) ); + suiteOfTests->addTest( new TestCallerType( "setRow_DiagonalIndexMultimapTest", &TesterType::setRow_DiagonalIndexMultimapTest ) ); + suiteOfTests->addTest( new TestCallerType( "setRowFast_DiagonalIndexMultimapTest", &TesterType::setRowFast_DiagonalIndexMultimapTest ) ); + suiteOfTests->addTest( new TestCallerType( "setRow_DenseIndexMultimapTest", &TesterType::setRow_DenseIndexMultimapTest ) ); + suiteOfTests->addTest( new TestCallerType( "setRowFast_DenseIndexMultimapTest", &TesterType::setRowFast_DenseIndexMultimapTest ) ); + suiteOfTests->addTest( new TestCallerType( "setRow_LowerTriangularIndexMultimapTest", &TesterType::setRow_LowerTriangularIndexMultimapTest ) ); + suiteOfTests->addTest( new TestCallerType( "setRowFast_LowerTriangularIndexMultimapTest", &TesterType::setRowFast_LowerTriangularIndexMultimapTest ) ); + suiteOfTests->addTest( new TestCallerType( "addElementTest", &TesterType::addElementTest ) ); + suiteOfTests->addTest( new TestCallerType( "vectorProduct_DiagonalIndexMultimapTest", &TesterType::vectorProduct_DiagonalIndexMultimapTest ) ); + suiteOfTests->addTest( new TestCallerType( "vectorProduct_DenseIndexMultimapTest", &TesterType::vectorProduct_DenseIndexMultimapTest ) ); + suiteOfTests->addTest( new TestCallerType( "vectorProduct_LowerTriangularIndexMultimapTest", &TesterType::vectorProduct_LowerTriangularIndexMultimapTest ) ); + /*suiteOfTests -> addTest( new TestCallerType( "graphTranspositionTest", &TesterType::graphTranspositionTest ) ); + suiteOfTests -> addTest( new TestCallerType( "addIndexMultimapTest", &TesterType::addIndexMultimapTest ) );*/ + + return suiteOfTests; + } + + void setRangesTest() + { + IndexMultimapType n; + IndexMultimapSetter::setup( n ); + n.setRanges( 10, 10 ); + CPPUNIT_ASSERT( n.getKeysRange() == 10 ); + CPPUNIT_ASSERT( n.getValuesRange() == 10 ); + } + + /*void setLikeTest() + { + IndexMultimapType m1, m2; + IndexMultimapSetter::setup( m1 ); + IndexMultimapSetter::setup( m2 ); + m1.setDimensions( 10, 10 ); + IndexVector rowLengths; + rowLengths.setSize( m1.getRows() ); + rowLengths.setValue( 5 ); + m1.setCompressedRowsLengths( rowLengths ); + m2.setLike( m1 ); + CPPUNIT_ASSERT( m1.getRows() == m2.getRows() ); + }*/ + + /**** + * Set element tests + */ + void setElementTest() + { + IndexMultimapType n; + IndexMultimapSetter::setup( n ); + n.setRanges( 10, 10 ); + + ValuesAllocationVectorType portsAllocationVector; + portsAllocationVector.setSize( n.getKeysRange() ); + portsAllocationVector.setValue( 7 ); + n.allocate( portsAllocationVector ); + + ValuesAccessorType p = n.getValues( 0 ); + for( int i = 0; i < 7; i++ ) + { + p.setOutput( i, i ); + //CPPUNIT_ASSERT( n.setPort( 0, i, i ) ); + } + + //CPPUNIT_ASSERT( m.setElement( 0, 8, 8 ) == false ); + + for( int i = 0; i < 7; i++ ) + CPPUNIT_ASSERT( p.getOutput( i ) == i ); + } +#ifdef UNDEF + + void setElementFastTest() + { + IndexMultimapType m; + IndexMultimapSetter::setup( m ); + m.setDimensions( 10, 10 ); + IndexVector rowLengths; + rowLengths.setSize( m.getRows() ); + rowLengths.setValue( 7 ); + m.setCompressedRowsLengths( rowLengths ); + + if( DeviceType::getDevice() == tnlHostDevice ) + { + for( int i = 0; i < 7; i++ ) + CPPUNIT_ASSERT( m.setElementFast( 0, i, i ) ); + //CPPUNIT_ASSERT( m.setElementFast( 0, 8, 8 ) == false ); + } + + if( DeviceType::getDevice() == tnlCudaDevice ) + { +#ifdef HAVE_CUDA + IndexMultimapType* kernel_graph = tnlCuda::passToDevice( m ); + bool testResult( true ); + bool* kernel_testResult = tnlCuda::passToDevice( testResult ); + checkCudaDevice; + dim3 cudaBlockSize( 256 ), cudaGridSize( 1 ); + tnlIndexMultimapTester__setElementFastTestCudaKernel< IndexMultimapType > + <<< cudaGridSize, cudaBlockSize >>> + ( kernel_graph, + kernel_testResult ); + CPPUNIT_ASSERT( tnlCuda::passFromDevice( kernel_testResult ) ); + tnlCuda::freeFromDevice( kernel_graph ); + tnlCuda::freeFromDevice( kernel_testResult ); + checkCudaDevice; +#endif + } + + for( int i = 0; i < 7; i++ ) + CPPUNIT_ASSERT( m.getElement( 0, i ) == i ); + } + + void setElement_DiagonalIndexMultimapTest() + { + IndexMultimapType m; + IndexMultimapSetter::setup( m ); + m.setDimensions( 10, 10 ); + IndexVector rowLengths; + rowLengths.setSize( m.getRows() ); + rowLengths.setValue( 7 ); + m.setCompressedRowsLengths( rowLengths ); + + for( int i = 0; i < 10; i++ ) + m.setElement( i, i, i ); + + for( int i = 0; i < 10; i++ ) + { + for( int j = 0; j < 10; j++ ) + { + if( i == j ) + CPPUNIT_ASSERT( m.getElement( i, j ) == i ); + else + CPPUNIT_ASSERT( m.getElement( i, j ) == 0 ); + } + } + } + + void setElementFast_DiagonalIndexMultimapTest() + { + IndexMultimapType m; + IndexMultimapSetter::setup( m ); + m.setDimensions( 10, 10 ); + IndexVector rowLengths; + rowLengths.setSize( m.getRows() ); + rowLengths.setValue( 7 ); + m.setCompressedRowsLengths( rowLengths ); + + if( DeviceType::DeviceType == ( int ) tnlHostDevice ) + { + for( int i = 0; i < 10; i++ ) + m.setElementFast( i, i, i ); + } + if( DeviceType::DeviceType == ( int ) tnlCudaDevice ) + { +#ifdef HAVE_CUDA + IndexMultimapType* kernel_graph = tnlCuda::passToDevice( m ); + bool testResult( true ); + bool* kernel_testResult = tnlCuda::passToDevice( testResult ); + checkCudaDevice; + dim3 cudaBlockSize( 256 ), cudaGridSize( 1 ); + tnlIndexMultimapTester__setElementFast_DiagonalIndexMultimapTestCudaKernel< IndexMultimapType > + <<< cudaGridSize, cudaBlockSize >>> + ( kernel_graph, + kernel_testResult ); + CPPUNIT_ASSERT( tnlCuda::passFromDevice( kernel_testResult ) ); + tnlCuda::freeFromDevice( kernel_graph ); + tnlCuda::freeFromDevice( kernel_testResult ); + checkCudaDevice; +#endif + } + + for( int i = 0; i < 10; i++ ) + { + for( int j = 0; j < 10; j++ ) + { + if( i == j ) + CPPUNIT_ASSERT( m.getElement( i, j ) == i ); + else + CPPUNIT_ASSERT( m.getElement( i, j ) == 0 ); + } + } + } + + void setElement_DenseIndexMultimapTest() + { + IndexMultimapType m; + IndexMultimapSetter::setup( m ); + m.setDimensions( 10, 10 ); + IndexVector rowLengths; + rowLengths.setSize( m.getRows() ); + rowLengths.setValue( 10 ); + m.setCompressedRowsLengths( rowLengths ); + + for( int i = 0; i < 10; i++ ) + m.setElement( i, i, i ); + for( int i = 0; i < 10; i++ ) + for( int j = 0; j < 10; j++ ) + m.addElement( i, j, 1, 0.5 ); + + for( int i = 0; i < 10; i++ ) + for( int j = 0; j < 10; j++ ) + if( i == j ) + CPPUNIT_ASSERT( m.getElement( i, j ) == 1.0+0.5*i ); + else + CPPUNIT_ASSERT( m.getElement( i, j ) == 1.0 ); + + m.reset(); + m.setDimensions( 10, 10 ); + m.setCompressedRowsLengths( rowLengths ); + for( int i = 9; i >= 0; i-- ) + for( int j = 9; j >= 0; j-- ) + m.setElement( i, j, i+j ); + + for( int i = 9; i >= 0; i-- ) + for( int j = 9; j >= 0; j-- ) + CPPUNIT_ASSERT( m.getElement( i, j ) == i+j ); + } + + void setElementFast_DenseIndexMultimapTest() + { + IndexMultimapType m; + IndexMultimapSetter::setup( m ); + m.setDimensions( 10, 10 ); + IndexVector rowLengths; + rowLengths.setSize( m.getRows() ); + rowLengths.setValue( 10 ); + m.setCompressedRowsLengths( rowLengths ); + + if( DeviceType::DeviceType == ( int ) tnlHostDevice ) + { + for( int i = 0; i < 10; i++ ) + m.setElementFast( i, i, i ); + for( int i = 0; i < 10; i++ ) + for( int j = 0; j < 10; j++ ) + m.addElementFast( i, j, 1, 0.5 ); + } + if( DeviceType::DeviceType == ( int ) tnlCudaDevice ) + { +#ifdef HAVE_CUDA + IndexMultimapType* kernel_graph = tnlCuda::passToDevice( m ); + bool testResult( true ); + bool* kernel_testResult = tnlCuda::passToDevice( testResult ); + checkCudaDevice; + dim3 cudaBlockSize( 256 ), cudaGridSize( 1 ); + tnlIndexMultimapTester__setElementFast_DenseIndexMultimapTestCudaKernel1< IndexMultimapType > + <<< cudaGridSize, cudaBlockSize >>> + ( kernel_graph, + kernel_testResult ); + CPPUNIT_ASSERT( tnlCuda::passFromDevice( kernel_testResult ) ); + tnlCuda::freeFromDevice( kernel_graph ); + tnlCuda::freeFromDevice( kernel_testResult ); + checkCudaDevice; +#endif + } + + for( int i = 0; i < 10; i++ ) + for( int j = 0; j < 10; j++ ) + if( i == j ) + CPPUNIT_ASSERT( m.getElement( i, j ) == 1.0+0.5*i ); + else + CPPUNIT_ASSERT( m.getElement( i, j ) == 1.0 ); + + m.reset(); + m.setDimensions( 10, 10 ); + m.setCompressedRowsLengths( rowLengths ); + if( DeviceType::DeviceType == ( int ) tnlHostDevice ) + { + for( int i = 9; i >= 0; i-- ) + for( int j = 9; j >= 0; j-- ) + m.setElementFast( i, j, i+j ); + } + if( DeviceType::DeviceType == ( int ) tnlCudaDevice ) + { +#ifdef HAVE_CUDA + IndexMultimapType* kernel_graph = tnlCuda::passToDevice( m ); + bool testResult( true ); + bool* kernel_testResult = tnlCuda::passToDevice( testResult ); + checkCudaDevice; + dim3 cudaBlockSize( 256 ), cudaGridSize( 1 ); + tnlIndexMultimapTester__setElementFast_DenseIndexMultimapTestCudaKernel2< IndexMultimapType > + <<< cudaGridSize, cudaBlockSize >>> + ( kernel_graph, + kernel_testResult ); + CPPUNIT_ASSERT( tnlCuda::passFromDevice( kernel_testResult ) ); + tnlCuda::freeFromDevice( kernel_graph ); + tnlCuda::freeFromDevice( kernel_testResult ); + checkCudaDevice; +#endif + } + + for( int i = 9; i >= 0; i-- ) + for( int j = 9; j >= 0; j-- ) + CPPUNIT_ASSERT( m.getElement( i, j ) == i+j ); + } + + + void setElement_LowerTriangularIndexMultimapTest() + { + IndexMultimapType m; + IndexMultimapSetter::setup( m ); + m.setDimensions( 10, 10 ); + IndexVector rowLengths; + rowLengths.setSize( m.getRows() ); + for( int i = 0; i < 10; i++ ) + rowLengths.setElement( i, i+1 ); + m.setCompressedRowsLengths( rowLengths ); + + for( int i = 0; i < 10; i++ ) + for( int j = 0; j <= i; j++ ) + m.setElement( i, j, i + j ); + + for( int i = 0; i < 10; i++ ) + for( int j = 0; j < 10; j++ ) + if( j <= i ) + CPPUNIT_ASSERT( m.getElement( i, j ) == i + j ); + else + CPPUNIT_ASSERT( m.getElement( i, j ) == 0 ); + + m.reset(); + m.setDimensions( 10, 10 ); + m.setCompressedRowsLengths( rowLengths ); + for( int i = 9; i >= 0; i-- ) + for( int j = i; j >= 0; j-- ) + m.setElement( i, j, i + j ); + + for( int i = 0; i < 10; i++ ) + for( int j = 0; j < 10; j++ ) + if( j <= i ) + CPPUNIT_ASSERT( m.getElement( i, j ) == i + j ); + else + CPPUNIT_ASSERT( m.getElement( i, j ) == 0 ); + } + + void setElementFast_LowerTriangularIndexMultimapTest() + { + IndexMultimapType m; + IndexMultimapSetter::setup( m ); + m.setDimensions( 10, 10 ); + IndexVector rowLengths; + rowLengths.setSize( m.getRows() ); + for( int i = 0; i < 10; i++ ) + rowLengths.setElement( i, i+1 ); + m.setCompressedRowsLengths( rowLengths ); + + if( DeviceType::DeviceType == ( int ) tnlHostDevice ) + { + for( int i = 0; i < 10; i++ ) + for( int j = 0; j <= i; j++ ) + m.setElementFast( i, j, i + j ); + } + if( DeviceType::DeviceType == ( int ) tnlCudaDevice ) + { +#ifdef HAVE_CUDA + IndexMultimapType* kernel_graph = tnlCuda::passToDevice( m ); + bool testResult( true ); + bool* kernel_testResult = tnlCuda::passToDevice( testResult ); + checkCudaDevice; + dim3 cudaBlockSize( 256 ), cudaGridSize( 1 ); + tnlIndexMultimapTester__setElementFast_LowerTriangularIndexMultimapTestCudaKernel1< IndexMultimapType > + <<< cudaGridSize, cudaBlockSize >>> + ( kernel_graph, + kernel_testResult ); + CPPUNIT_ASSERT( tnlCuda::passFromDevice( kernel_testResult ) ); + tnlCuda::freeFromDevice( kernel_graph ); + tnlCuda::freeFromDevice( kernel_testResult ); + checkCudaDevice; +#endif + } + + for( int i = 0; i < 10; i++ ) + for( int j = 0; j < 10; j++ ) + if( j <= i ) + CPPUNIT_ASSERT( m.getElement( i, j ) == i + j ); + else + CPPUNIT_ASSERT( m.getElement( i, j ) == 0 ); + + m.reset(); + m.setDimensions( 10, 10 ); + m.setCompressedRowsLengths( rowLengths ); + if( DeviceType::DeviceType == ( int ) tnlHostDevice ) + { + for( int i = 9; i >= 0; i-- ) + for( int j = i; j >= 0; j-- ) + m.setElementFast( i, j, i + j ); + } + if( DeviceType::DeviceType == ( int ) tnlCudaDevice ) + { +#ifdef HAVE_CUDA + IndexMultimapType* kernel_graph = tnlCuda::passToDevice( m ); + bool testResult( true ); + bool* kernel_testResult = tnlCuda::passToDevice( testResult ); + checkCudaDevice; + dim3 cudaBlockSize( 256 ), cudaGridSize( 1 ); + tnlIndexMultimapTester__setElementFast_LowerTriangularIndexMultimapTestCudaKernel2< IndexMultimapType > + <<< cudaGridSize, cudaBlockSize >>> + ( kernel_graph, + kernel_testResult ); + CPPUNIT_ASSERT( tnlCuda::passFromDevice( kernel_testResult ) ); + tnlCuda::freeFromDevice( kernel_graph ); + tnlCuda::freeFromDevice( kernel_testResult ); + checkCudaDevice; +#endif + } + + for( int i = 0; i < 10; i++ ) + for( int j = 0; j < 10; j++ ) + if( j <= i ) + CPPUNIT_ASSERT( m.getElement( i, j ) == i + j ); + else + CPPUNIT_ASSERT( m.getElement( i, j ) == 0 ); + } + + + void addElementTest() + { + IndexMultimapType m; + IndexMultimapSetter::setup( m ); + m.setDimensions( 10, 10 ); + IndexVector rowLengths; + rowLengths.setSize( m.getRows() ); + rowLengths.setValue( 7 ); + m.setCompressedRowsLengths( rowLengths ); + for( int i = 0; i < 10; i++ ) + m.setElement( i, i, i ); + for( int i = 0; i < 10; i++ ) + for( int j = 0; j < 10; j++ ) + if( abs( i - j ) <= 1 ) + m.addElement( i, j, 1 ); + + for( int i = 0; i < 10; i++ ) + for( int j = 0; j < 10; j++ ) + if( i == j ) + CPPUNIT_ASSERT( m.getElement( i, i ) == i + 1 ); + else + if( abs( i - j ) == 1 ) + CPPUNIT_ASSERT( m.getElement( i, j ) == 1 ); + else + CPPUNIT_ASSERT( m.getElement( i, j ) == 0 ); + } + + /**** + * Set row tests + */ + void setRow_DiagonalIndexMultimapTest() + { + IndexMultimapType m; + IndexMultimapSetter::setup( m ); + m.setDimensions( 10, 10 ); + IndexVector rowLengths; + rowLengths.setSize( m.getRows() ); + rowLengths.setValue( 7 ); + m.setCompressedRowsLengths( rowLengths ); + RealType values[ 1 ]; + IndexType columnIndexes[ 1 ]; + + for( int i = 0; i < 10; i++ ) + { + values[ 0 ] = i; + columnIndexes[ 0 ] = i; + m.setRow( i, columnIndexes, values, 1 ); + } + + for( int i = 0; i < 10; i++ ) + { + for( int j = 0; j < 10; j++ ) + { + if( i == j ) + CPPUNIT_ASSERT( m.getElement( i, j ) == i ); + else + CPPUNIT_ASSERT( m.getElement( i, j ) == 0 ); + } + } + } + + void setRowFast_DiagonalIndexMultimapTest() + { + IndexMultimapType m; + IndexMultimapSetter::setup( m ); + m.setDimensions( 10, 10 ); + IndexVector rowLengths; + rowLengths.setSize( m.getRows() ); + rowLengths.setValue( 7 ); + m.setCompressedRowsLengths( rowLengths ); + + + if( DeviceType::DeviceType == ( int ) tnlHostDevice ) + { + RealType values[ 1 ]; + IndexType columnIndexes[ 1 ]; + for( int i = 0; i < 10; i++ ) + { + values[ 0 ] = i; + columnIndexes[ 0 ] = i; + m.setRowFast( i, columnIndexes, values, 1 ); + } + } + if( DeviceType::DeviceType == ( int ) tnlCudaDevice ) + { +#ifdef HAVE_CUDA + IndexMultimapType* kernel_graph = tnlCuda::passToDevice( m ); + bool testResult( true ); + bool* kernel_testResult = tnlCuda::passToDevice( testResult ); + checkCudaDevice; + dim3 cudaBlockSize( 256 ), cudaGridSize( 1 ); + int sharedMemory = 100 * ( sizeof( IndexType ) + sizeof( RealType ) ); + tnlIndexMultimapTester__setRowFast_DiagonalIndexMultimapTestCudaKernel< IndexMultimapType > + <<< cudaGridSize, cudaBlockSize, sharedMemory >>> + ( kernel_graph, + kernel_testResult ); + CPPUNIT_ASSERT( tnlCuda::passFromDevice( kernel_testResult ) ); + tnlCuda::freeFromDevice( kernel_graph ); + tnlCuda::freeFromDevice( kernel_testResult ); + checkCudaDevice; +#endif + } + + for( int i = 0; i < 10; i++ ) + { + for( int j = 0; j < 10; j++ ) + { + if( i == j ) + CPPUNIT_ASSERT( m.getElement( i, j ) == i ); + else + CPPUNIT_ASSERT( m.getElement( i, j ) == 0 ); + } + } + } + + void setRow_DenseIndexMultimapTest() + { + IndexMultimapType m; + IndexMultimapSetter::setup( m ); + m.setDimensions( 10, 10 ); + IndexVector rowLengths; + rowLengths.setSize( m.getRows() ); + rowLengths.setValue( 10 ); + m.setCompressedRowsLengths( rowLengths ); + RealType values[ 10 ]; + IndexType columnIndexes[ 10 ]; + + for( int i = 0; i < 10; i++ ) + columnIndexes[ i ] = i; + for( int i = 0; i < 10; i++ ) + { + for( int j = 0; j < 10; j++ ) + if( i == j ) + values[ i ] = 1.0 + 0.5 * j; + else + values[ j ] = 1.0; + + m.setRow( i, columnIndexes, values, 10 ); + } + + for( int i = 0; i < 10; i++ ) + for( int j = 0; j < 10; j++ ) + if( i == j ) + CPPUNIT_ASSERT( m.getElement( i, j ) == 1.0+0.5*i ); + else + CPPUNIT_ASSERT( m.getElement( i, j ) == 1.0 ); + + m.reset(); + m.setDimensions( 10, 10 ); + m.setCompressedRowsLengths( rowLengths ); + for( int i = 9; i >= 0; i-- ) + { + for( int j = 9; j >= 0; j-- ) + values[ j ] = i+j; + m.setRow( i, columnIndexes, values, 10 ); + } + + for( int i = 9; i >= 0; i-- ) + for( int j = 9; j >= 0; j-- ) + CPPUNIT_ASSERT( m.getElement( i, j ) == i+j ); + } + + void setRowFast_DenseIndexMultimapTest() + { + IndexMultimapType m; + IndexMultimapSetter::setup( m ); + m.setDimensions( 10, 10 ); + IndexVector rowLengths; + rowLengths.setSize( m.getRows() ); + rowLengths.setValue( 10 ); + m.setCompressedRowsLengths( rowLengths ); + + RealType values[ 10 ]; + IndexType columnIndexes[ 10 ]; + for( int i = 0; i < 10; i++ ) + columnIndexes[ i ] = i; + + if( DeviceType::DeviceType == ( int ) tnlHostDevice ) + { + for( int i = 0; i < 10; i++ ) + { + for( int j = 0; j < 10; j++ ) + if( i == j ) + values[ i ] = 1.0 + 0.5 * j; + else + values[ j ] = 1.0; + + m.setRowFast( i, columnIndexes, values, 10 ); + } + } + if( DeviceType::DeviceType == ( int ) tnlCudaDevice ) + { +#ifdef HAVE_CUDA + IndexMultimapType* kernel_graph = tnlCuda::passToDevice( m ); + bool testResult( true ); + bool* kernel_testResult = tnlCuda::passToDevice( testResult ); + checkCudaDevice; + dim3 cudaBlockSize( 256 ), cudaGridSize( 1 ); + int sharedMemory = 100 * ( sizeof( IndexType ) + sizeof( RealType ) ); + tnlIndexMultimapTester__setRowFast_DenseIndexMultimapTestCudaKernel1< IndexMultimapType > + <<< cudaGridSize, cudaBlockSize, sharedMemory >>> + ( kernel_graph, + kernel_testResult ); + CPPUNIT_ASSERT( tnlCuda::passFromDevice( kernel_testResult ) ); + tnlCuda::freeFromDevice( kernel_graph ); + tnlCuda::freeFromDevice( kernel_testResult ); + checkCudaDevice; +#endif + } + + for( int i = 0; i < 10; i++ ) + for( int j = 0; j < 10; j++ ) + if( i == j ) + CPPUNIT_ASSERT( m.getElement( i, j ) == 1.0+0.5*i ); + else + CPPUNIT_ASSERT( m.getElement( i, j ) == 1.0 ); + + m.reset(); + m.setDimensions( 10, 10 ); + m.setCompressedRowsLengths( rowLengths ); + + if( DeviceType::DeviceType == ( int ) tnlHostDevice ) + { + for( int i = 9; i >= 0; i-- ) + { + for( int j = 9; j >= 0; j-- ) + values[ j ] = i+j; + m.setRowFast( i, columnIndexes, values, 10 ); + } + } + if( DeviceType::DeviceType == ( int ) tnlCudaDevice ) + { +#ifdef HAVE_CUDA + IndexMultimapType* kernel_graph = tnlCuda::passToDevice( m ); + bool testResult( true ); + bool* kernel_testResult = tnlCuda::passToDevice( testResult ); + checkCudaDevice; + dim3 cudaBlockSize( 256 ), cudaGridSize( 1 ); + int sharedMemory = 100 * ( sizeof( IndexType ) + sizeof( RealType ) ); + tnlIndexMultimapTester__setRowFast_DenseIndexMultimapTestCudaKernel2< IndexMultimapType > + <<< cudaGridSize, cudaBlockSize, sharedMemory >>> + ( kernel_graph, + kernel_testResult ); + CPPUNIT_ASSERT( tnlCuda::passFromDevice( kernel_testResult ) ); + tnlCuda::freeFromDevice( kernel_graph ); + tnlCuda::freeFromDevice( kernel_testResult ); + checkCudaDevice; +#endif + } + + for( int i = 9; i >= 0; i-- ) + for( int j = 9; j >= 0; j-- ) + CPPUNIT_ASSERT( m.getElement( i, j ) == i+j ); + } + + void setRow_LowerTriangularIndexMultimapTest() + { + IndexMultimapType m; + IndexMultimapSetter::setup( m ); + m.setDimensions( 10, 10 ); + IndexVector rowLengths; + rowLengths.setSize( m.getRows() ); + for( int i = 0; i < 10; i++ ) + rowLengths.setElement( i, i+1 ); + m.setCompressedRowsLengths( rowLengths ); + + + RealType values[ 10 ]; + IndexType columnIndexes[ 10 ]; + + for( int i = 0; i < 10; i++ ) + columnIndexes[ i ] = i; + + for( int i = 0; i < 10; i++ ) + { + for( int j = 0; j <= i; j++ ) + values[ j ] = i + j; + m.setRow( i, columnIndexes, values, i + 1 ); + } + + for( int i = 0; i < 10; i++ ) + for( int j = 0; j < 10; j++ ) + if( j <= i ) + CPPUNIT_ASSERT( m.getElement( i, j ) == i + j ); + else + CPPUNIT_ASSERT( m.getElement( i, j ) == 0 ); + + m.reset(); + m.setDimensions( 10, 10 ); + m.setCompressedRowsLengths( rowLengths ); + for( int i = 9; i >= 0; i-- ) + { + for( int j = i; j >= 0; j-- ) + values[ j ] = i + j; + m.setRow( i, columnIndexes, values, i + 1 ); + } + + for( int i = 0; i < 10; i++ ) + for( int j = 0; j < 10; j++ ) + if( j <= i ) + CPPUNIT_ASSERT( m.getElement( i, j ) == i + j ); + else + CPPUNIT_ASSERT( m.getElement( i, j ) == 0 ); + } + + void setRowFast_LowerTriangularIndexMultimapTest() + { + IndexMultimapType m; + IndexMultimapSetter::setup( m ); + m.setDimensions( 10, 10 ); + IndexVector rowLengths; + rowLengths.setSize( m.getRows() ); + for( int i = 0; i < 10; i++ ) + rowLengths.setElement( i, i+1 ); + m.setCompressedRowsLengths( rowLengths ); + + + RealType values[ 10 ]; + IndexType columnIndexes[ 10 ]; + for( int i = 0; i < 10; i++ ) + columnIndexes[ i ] = i; + + if( DeviceType::DeviceType == ( int ) tnlHostDevice ) + { + for( int i = 0; i < 10; i++ ) + { + for( int j = 0; j <= i; j++ ) + values[ j ] = i + j; + m.setRowFast( i, columnIndexes, values, i + 1 ); + } + } + if( DeviceType::DeviceType == ( int ) tnlCudaDevice ) + { +#ifdef HAVE_CUDA + IndexMultimapType* kernel_graph = tnlCuda::passToDevice( m ); + bool testResult( true ); + bool* kernel_testResult = tnlCuda::passToDevice( testResult ); + checkCudaDevice; + dim3 cudaBlockSize( 256 ), cudaGridSize( 1 ); + int sharedMemory = 100 * ( sizeof( IndexType ) + sizeof( RealType ) ); + tnlIndexMultimapTester__setRowFast_LowerTriangularIndexMultimapTestCudaKernel< IndexMultimapType > + <<< cudaGridSize, cudaBlockSize, sharedMemory >>> + ( kernel_graph, + kernel_testResult ); + CPPUNIT_ASSERT( tnlCuda::passFromDevice( kernel_testResult ) ); + tnlCuda::freeFromDevice( kernel_graph ); + tnlCuda::freeFromDevice( kernel_testResult ); + checkCudaDevice; +#endif + } + + for( int i = 0; i < 10; i++ ) + for( int j = 0; j < 10; j++ ) + if( j <= i ) + CPPUNIT_ASSERT( m.getElement( i, j ) == i + j ); + else + CPPUNIT_ASSERT( m.getElement( i, j ) == 0 ); + + m.reset(); + m.setDimensions( 10, 10 ); + m.setCompressedRowsLengths( rowLengths ); + + if( DeviceType::DeviceType == ( int ) tnlHostDevice ) + { + for( int i = 9; i >= 0; i-- ) + { + for( int j = i; j >= 0; j-- ) + values[ j ] = i + j; + m.setRowFast( i, columnIndexes, values, i + 1 ); + } + } + if( DeviceType::DeviceType == ( int ) tnlCudaDevice ) + { +#ifdef HAVE_CUDA + IndexMultimapType* kernel_graph = tnlCuda::passToDevice( m ); + bool testResult( true ); + bool* kernel_testResult = tnlCuda::passToDevice( testResult ); + checkCudaDevice; + dim3 cudaBlockSize( 256 ), cudaGridSize( 1 ); + int sharedMemory = 100 * ( sizeof( IndexType ) + sizeof( RealType ) ); + tnlIndexMultimapTester__setRowFast_LowerTriangularIndexMultimapTestCudaKernel< IndexMultimapType > + <<< cudaGridSize, cudaBlockSize, sharedMemory >>> + ( kernel_graph, + kernel_testResult ); + CPPUNIT_ASSERT( tnlCuda::passFromDevice( kernel_testResult ) ); + tnlCuda::freeFromDevice( kernel_graph ); + tnlCuda::freeFromDevice( kernel_testResult ); + checkCudaDevice; +#endif + } + + for( int i = 0; i < 10; i++ ) + for( int j = 0; j < 10; j++ ) + if( j <= i ) + CPPUNIT_ASSERT( m.getElement( i, j ) == i + j ); + else + CPPUNIT_ASSERT( m.getElement( i, j ) == 0 ); + } + + + void vectorProduct_DiagonalIndexMultimapTest() + { + const int size = 10; + VectorType v, w; + v.setSize( size ); + w.setSize( size ); + IndexMultimapType m; + IndexMultimapSetter::setup( m ); + m.setDimensions( size, size ); + IndexVector rowLengths; + rowLengths.setSize( m.getRows() ); + rowLengths.setValue( 7 ); + m.setCompressedRowsLengths( rowLengths ); + for( int i = 0; i < size; i++ ) + { + v.setElement( i, i ); + m.setElement( i, i, i ); + } + m.vectorProduct( v, w ); + + for( int i = 0; i < size; i++ ) + CPPUNIT_ASSERT( w.getElement( i ) == i*i ); + } + + void vectorProduct_DenseIndexMultimapTest() + { + const int size = 10; + VectorType v, w; + v.setSize( size ); + w.setSize( size ); + IndexMultimapType m; + IndexMultimapSetter::setup( m ); + m.setDimensions( size, size ); + IndexVector rowLengths; + rowLengths.setSize( m.getRows() ); + rowLengths.setValue( size ); + m.setCompressedRowsLengths( rowLengths ); + for( int i = 0; i < size; i++ ) + { + for( int j = 0; j < size; j++ ) + m.setElement( i, j, i ); + v.setElement( i, 1 ); + } + m.vectorProduct( v, w ); + + for( int i = 0; i < size; i++ ) + CPPUNIT_ASSERT( w.getElement( i ) == i*size ); + } + + void vectorProduct_LowerTriangularIndexMultimapTest() + { + const int size = 10; + VectorType v, w; + v.setSize( size ); + w.setSize( size ); + IndexMultimapType m; + IndexMultimapSetter::setup( m ); + m.setDimensions( size, size ); + IndexVector rowLengths; + rowLengths.setSize( m.getRows() ); + rowLengths.setValue( size ); + m.setCompressedRowsLengths( rowLengths ); + for( int i = 0; i < size; i++ ) + { + for( int j = 0; j <= i; j++ ) + m.setElement( i, j, i ); + v.setElement( i, 1 ); + } + m.vectorProduct( v, w ); + + for( int i = 0; i < size; i++ ) + CPPUNIT_ASSERT( w.getElement( i ) == i*( i + 1 ) ); + } + + + void addIndexMultimapTest() + { + } + + void graphTranspositionTest() + { + } +#endif + +}; + +#ifdef HAVE_CUDA + template< typename IndexMultimapType > + __global__ void tnlIndexMultimapTester__setElementFastTestCudaKernel( IndexMultimapType* graph, + bool* testResult ) + { + if( threadIdx.x == 0 ) + { + for( int i = 0; i < 7; i++ ) + if( graph->setElementFast( 0, i, i ) != true ) + testResult = false; + if( graph->setElementFast( 0, 8, 8 ) == true ) + testResult = false; + } + } + + template< typename IndexMultimapType > + __global__ void tnlIndexMultimapTester__setElementFast_DiagonalIndexMultimapTestCudaKernel( IndexMultimapType* graph, + bool* testResult ) + { + if( threadIdx.x < graph->getRows() ) + graph->setElementFast( threadIdx.x, threadIdx.x, threadIdx.x ); + } + + template< typename IndexMultimapType > + __global__ void tnlIndexMultimapTester__setElementFast_DenseIndexMultimapTestCudaKernel1( IndexMultimapType* graph, + bool* testResult ) + { + const typename IndexMultimapType::IndexType i = threadIdx.x; + if( i < graph->getRows() ) + { + graph->setElementFast( i, i, i ); + for( int j = 0; j < graph->getColumns(); j++ ) + graph->addElementFast( i, j, 1, 0.5 ); + } + } + + template< typename IndexMultimapType > + __global__ void tnlIndexMultimapTester__setElementFast_DenseIndexMultimapTestCudaKernel2( IndexMultimapType* graph, + bool* testResult ) + { + const typename IndexMultimapType::IndexType i = threadIdx.x; + if( i < graph->getRows() ) + { + for( int j = graph->getColumns() -1; j >= 0; j-- ) + graph->setElementFast( i, j, i + j ); + } + } + + template< typename IndexMultimapType > + __global__ void tnlIndexMultimapTester__setElementFast_LowerTriangularIndexMultimapTestCudaKernel1( IndexMultimapType* graph, + bool* testResult ) + { + const typename IndexMultimapType::IndexType i = threadIdx.x; + if( i < graph->getRows() ) + { + for( int j = 0; j <= i; j++ ) + graph->setElementFast( i, j, i + j ); + } + } + + template< typename IndexMultimapType > + __global__ void tnlIndexMultimapTester__setElementFast_LowerTriangularIndexMultimapTestCudaKernel2( IndexMultimapType* graph, + bool* testResult ) + { + const typename IndexMultimapType::IndexType i = threadIdx.x; + if( i < graph->getRows() ) + { + for( int j = i; j >= 0; j-- ) + graph->setElementFast( i, j, i + j ); + } + } + + /**** + * Set row tests kernels + */ + template< typename IndexMultimapType > + __global__ void tnlIndexMultimapTester__setRowFast_DiagonalIndexMultimapTestCudaKernel( IndexMultimapType* graph, + bool* testResult ) + { + typedef typename IndexMultimapType::RealType RealType; + typedef typename IndexMultimapType::IndexType IndexType; + + const IndexType row = threadIdx.x; + if( row >= graph->getRows() ) + return; + + IndexType* columnIndexes = getSharedMemory< IndexType >(); + RealType* valuesBase = ( RealType* ) & columnIndexes[ graph->getColumns() ]; + RealType* values = &valuesBase[ row ]; + + columnIndexes[ row ] = row; + values[ 0 ] = row; + + graph->setRowFast( row, &columnIndexes[ row ], values, 1 ); + } + + template< typename IndexMultimapType > + __global__ void tnlIndexMultimapTester__setRowFast_DenseIndexMultimapTestCudaKernel1( IndexMultimapType* graph, + bool* testResult ) + { + typedef typename IndexMultimapType::RealType RealType; + typedef typename IndexMultimapType::IndexType IndexType; + + const IndexType row = threadIdx.x; + if( row >= graph->getRows() ) + return; + + IndexType* columnIndexes = getSharedMemory< IndexType >(); + RealType* valuesBase = ( RealType* ) & columnIndexes[ graph->getColumns() ]; + RealType* values = &valuesBase[ row * graph->getColumns() ]; + + columnIndexes[ row ] = row; + + for( int i = 0; i < graph->getColumns(); i++ ) + { + if( i == row ) + values[ i ] = 1.0 + 0.5 * i; + else + values[ i ] = 1.0; + } + graph->setRowFast( row, columnIndexes, values, 10 ); + } + + template< typename IndexMultimapType > + __global__ void tnlIndexMultimapTester__setRowFast_DenseIndexMultimapTestCudaKernel2( IndexMultimapType* graph, + bool* testResult ) + { + typedef typename IndexMultimapType::RealType RealType; + typedef typename IndexMultimapType::IndexType IndexType; + + const IndexType row = threadIdx.x; + if( row >= graph->getRows() ) + return; + + IndexType* columnIndexes = getSharedMemory< IndexType >(); + RealType* valuesBase = ( RealType* ) & columnIndexes[ graph->getColumns() ]; + RealType* values = &valuesBase[ row * graph->getColumns() ]; + + columnIndexes[ row ] = row; + + for( int i = 0; i < graph->getColumns(); i++ ) + { + values[ i ] = row + i; + } + graph->setRowFast( row, columnIndexes, values, 10 ); + } + + template< typename IndexMultimapType > + __global__ void tnlIndexMultimapTester__setRowFast_LowerTriangularIndexMultimapTestCudaKernel( IndexMultimapType* graph, + bool* testResult ) + { + typedef typename IndexMultimapType::RealType RealType; + typedef typename IndexMultimapType::IndexType IndexType; + + const IndexType row = threadIdx.x; + if( row >= graph->getRows() ) + return; + + IndexType* columnIndexes = getSharedMemory< IndexType >(); + RealType* valuesBase = ( RealType* ) & columnIndexes[ graph->getColumns() ]; + RealType* values = &valuesBase[ row * graph->getColumns() ]; + + columnIndexes[ row ] = row; + + for( int i = 0; i <= row; i++ ) + { + values[ i ] = row + i; + } + graph->setRowFast( row, columnIndexes, values, row + 1 ); + } + +#endif + + +#endif + +#endif /* TNLINDEXMULTIMAPTESTER_H_ */ diff --git a/tests/unit-tests/core/vectors/tnlVectorOperationsTester.h b/tests/unit-tests/core/vectors/tnlVectorOperationsTester.h index ee7b3d0184626ec645d09149036446d9e993fc99..f452b8b10b875d98b65aa62822a72b05c33f401c 100644 --- a/tests/unit-tests/core/vectors/tnlVectorOperationsTester.h +++ b/tests/unit-tests/core/vectors/tnlVectorOperationsTester.h @@ -62,9 +62,9 @@ class tnlVectorOperationsTester : public CppUnit :: TestCase suiteOfTests -> addTest( new TestCallerType( "vectorScalarMultiplicationTest", &tnlVectorOperationsTester::vectorScalarMultiplicationTest ) ); suiteOfTests -> addTest( new TestCallerType( "getSclaraProductTest", &tnlVectorOperationsTester::getVectorScalarProductTest ) ); suiteOfTests -> addTest( new TestCallerType( "addVectorTest", &tnlVectorOperationsTester::addVectorTest ) ); - suiteOfTests -> addTest( new TestCallerType( "alphaXPlusBetaYTest", &tnlVectorOperationsTester::alphaXPlusBetaYTest ) ); + /*suiteOfTests -> addTest( new TestCallerType( "alphaXPlusBetaYTest", &tnlVectorOperationsTester::alphaXPlusBetaYTest ) ); suiteOfTests -> addTest( new TestCallerType( "alphaXPlusBetaZTest", &tnlVectorOperationsTester::alphaXPlusBetaZTest ) ); - suiteOfTests -> addTest( new TestCallerType( "alphaXPlusBetaZPlusYTest", &tnlVectorOperationsTester::alphaXPlusBetaZPlusYTest ) ); + suiteOfTests -> addTest( new TestCallerType( "alphaXPlusBetaZPlusYTest", &tnlVectorOperationsTester::alphaXPlusBetaZPlusYTest ) );*/ suiteOfTests -> addTest( new TestCallerType( "prefixSumTest", &tnlVectorOperationsTester::prefixSumTest ) ); suiteOfTests -> addTest( new TestCallerType( "exclusivePrefixSumTest", &tnlVectorOperationsTester::exclusivePrefixSumTest ) ); return suiteOfTests; @@ -325,7 +325,7 @@ class tnlVectorOperationsTester : public CppUnit :: TestCase CPPUNIT_ASSERT( y.getElement( i ) == 1.0 + 3.0 * i ); }; - void alphaXPlusBetaYTest() + /*void alphaXPlusBetaYTest() { const int size( 10000 ); tnlVector< Real, Device > x, y; @@ -368,14 +368,13 @@ class tnlVectorOperationsTester : public CppUnit :: TestCase for( int i = 0; i < size; i ++ ) CPPUNIT_ASSERT( y.getElement( i ) == -1.0 + 3.0 * i ); - }; + };*/ void prefixSumTest() { const int size( 10000 ); tnlVector< Real, Device > v; v.setSize( size ); - v.setName( "prefixSumTest::v" ); setOnesSequence( v ); v.computePrefixSum(); @@ -399,7 +398,6 @@ class tnlVectorOperationsTester : public CppUnit :: TestCase const int size( 10000 ); tnlVector< Real, Device > v; v.setSize( size ); - v.setName( "exclusivePrefixSumTest::v" ); setOnesSequence( v ); v.computeExclusivePrefixSum(); diff --git a/tests/unit-tests/matrices/tnlDenseMatrixTester.h b/tests/unit-tests/matrices/tnlDenseMatrixTester.h index e14257a4cbbd8de7846f33f19e6d7e87ffddc7d0..a4ea8c6cc6e4cf271284c8144a9ea133483c7240 100644 --- a/tests/unit-tests/matrices/tnlDenseMatrixTester.h +++ b/tests/unit-tests/matrices/tnlDenseMatrixTester.h @@ -176,7 +176,6 @@ class tnlDenseMatrixTester : public CppUnit :: TestCase m.setElement( i, i, i ); tnlVector< IndexType, tnlHost, IndexType > columns; - columns.setName( "tnlDenseMatrixTester:columns" ); tnlVector< RealType, tnlHost, IndexType > values; columns.setSize( 10 ); values.setSize( 10 ); @@ -209,7 +208,6 @@ class tnlDenseMatrixTester : public CppUnit :: TestCase m.setElement( i, i, i ); tnlVector< IndexType, Device, IndexType > columns; - columns.setName( "tnlDenseMatrixTester:columns" ); tnlVector< RealType, Device, IndexType > values; columns.setSize( 10 ); values.setSize( 10 ); diff --git a/tests/unit-tests/matrices/tnlRgCSRMatrixTester.h b/tests/unit-tests/matrices/tnlRgCSRMatrixTester.h index 4978d8e7c16ab8e1cc4caac36c9239fe94ef09d6..6b24cbb1b2a04e7837a4a28f0ea18963dcdff30d 100644 --- a/tests/unit-tests/matrices/tnlRgCSRMatrixTester.h +++ b/tests/unit-tests/matrices/tnlRgCSRMatrixTester.h @@ -94,8 +94,7 @@ template< class T > class tnlRgCSRMatrixTester : public CppUnit :: TestCase, { const int size = 12; tnlCSRMatrix< T > csrMatrix; - csrMatrix.setName( "test-matrix:Empty" ); - tnlRgCSRMatrix< T > argcsrMatrix( "test-matrix:Empty" ); + tnlRgCSRMatrix< T > argcsrMatrix; this -> setEmptyMatrix( csrMatrix, size ); argcsrMatrix. copyFrom( csrMatrix ); @@ -111,8 +110,7 @@ template< class T > class tnlRgCSRMatrixTester : public CppUnit :: TestCase, { const int size = 12; tnlCSRMatrix< T > csrMatrix; - csrMatrix.setName( "test-matrix:Diagonal" ); - tnlRgCSRMatrix< T > argcsrMatrix( "test-matrix:Diagonal" ); + tnlRgCSRMatrix< T > argcsrMatrix; this -> setDiagonalMatrix( csrMatrix, size ); argcsrMatrix. copyFrom( csrMatrix ); @@ -127,8 +125,7 @@ template< class T > class tnlRgCSRMatrixTester : public CppUnit :: TestCase, void ifTriDiagonalMatrixIsStoredProperly() { tnlCSRMatrix< T > csrMatrix; - csrMatrix.setName( "test-matrix:Tridiagonal" ); - tnlRgCSRMatrix< T > argcsrMatrix( "test-matrix:Tridiagonal" ); + tnlRgCSRMatrix< T > argcsrMatrix; int size = 12; this -> setTridiagonalMatrix( csrMatrix, size ); argcsrMatrix. copyFrom( csrMatrix ); @@ -145,8 +142,7 @@ template< class T > class tnlRgCSRMatrixTester : public CppUnit :: TestCase, void ifUpperTriangularMatrixIsStoredProperly() { tnlCSRMatrix< T > csrMatrix; - csrMatrix.setName( "test-matrix:upperTriangular" ); - tnlRgCSRMatrix< T > argcsrMatrix( "test-matrix:upperTriangular" ); + tnlRgCSRMatrix< T > argcsrMatrix; const int size = 12; this -> setUpperTriangularMatrix( csrMatrix, size ); argcsrMatrix. copyFrom( csrMatrix ); @@ -163,8 +159,7 @@ template< class T > class tnlRgCSRMatrixTester : public CppUnit :: TestCase, void ifFullMatrixIsStoredProperly() { tnlCSRMatrix< T > csrMatrix; - csrMatrix.setName( "test-matrix:upperTriangular" ); - tnlRgCSRMatrix< T > argcsrMatrix( "test-matrix:upperTriangular" ); + tnlRgCSRMatrix< T > argcsrMatrix; const int size = 12; this -> setUpperTriangularMatrix( csrMatrix, size ); argcsrMatrix. copyFrom( csrMatrix ); @@ -181,8 +176,7 @@ template< class T > class tnlRgCSRMatrixTester : public CppUnit :: TestCase, void ifBcsstk20MatrixIsStoredProperly() { tnlCSRMatrix< T > csrMatrix; - csrMatrix.setName( "test-matrix:upperTriangular" ); - tnlRgCSRMatrix< T > argcsrMatrix( "test-matrix:upperTriangular" ); + tnlRgCSRMatrix< T > argcsrMatrix; const int size = 12; this -> setBcsstk20Matrix( csrMatrix ); argcsrMatrix. copyFrom( csrMatrix ); @@ -200,12 +194,11 @@ template< class T > class tnlRgCSRMatrixTester : public CppUnit :: TestCase, { const int size = 35; tnlCSRMatrix< T > csrMatrix; - csrMatrix.setName( "test-matrix:Diagonal" ); - tnlRgCSRMatrix< T > argcsrMatrix( "test-matrix:Diagonal" ); + tnlRgCSRMatrix< T > argcsrMatrix; this -> setEmptyMatrix( csrMatrix, size ); argcsrMatrix. copyFrom( csrMatrix ); - tnlVector< T > x( "x" ), b1( "b1" ), b2( "b2" ); + tnlVector< T > x, b1, b2; x. setSize( size ); b1. setSize( size ); b2. setSize( size ); @@ -220,12 +213,11 @@ template< class T > class tnlRgCSRMatrixTester : public CppUnit :: TestCase, { const int size = 35; tnlCSRMatrix< T > csrMatrix; - csrMatrix.setName( "test-matrix:Diagonal" ); - tnlRgCSRMatrix< T > argcsrMatrix( "test-matrix:Diagonal" ); + tnlRgCSRMatrix< T > argcsrMatrix; this -> setDiagonalMatrix( csrMatrix, size ); argcsrMatrix. copyFrom( csrMatrix ); - tnlVector< T > x( "x" ), b1( "b1" ), b2( "b2" ); + tnlVector< T > x, b1, b2; x. setSize( size ); b1. setSize( size ); b2. setSize( size ); @@ -240,12 +232,11 @@ template< class T > class tnlRgCSRMatrixTester : public CppUnit :: TestCase, { const int size = 12; tnlCSRMatrix< T > csrMatrix; - csrMatrix.setName( "test-matrix:TriDiagonal" ); - tnlRgCSRMatrix< T > argcsrMatrix( "test-matrix:TriDiagonal" ); + tnlRgCSRMatrix< T > argcsrMatrix; this -> setTridiagonalMatrix( csrMatrix, size ); argcsrMatrix. copyFrom( csrMatrix ); - tnlVector< T > x( "x" ), b1( "b1" ), b2( "b2" ); + tnlVector< T > x, b1, b2; x. setSize( size ); b1. setSize( size ); b2. setSize( size ); @@ -260,12 +251,11 @@ template< class T > class tnlRgCSRMatrixTester : public CppUnit :: TestCase, { const int size = 12; tnlCSRMatrix< T > csrMatrix; - csrMatrix.setName( "test-matrix:TriDiagonal" ); - tnlRgCSRMatrix< T > argcsrMatrix( "test-matrix:TriDiagonal" ); + tnlRgCSRMatrix< T > argcsrMatrix; this -> setUpperTriangularMatrix( csrMatrix, size ); argcsrMatrix. copyFrom( csrMatrix ); - tnlVector< T > x( "x" ), b1( "b1" ), b2( "b2" ); + tnlVector< T > x, b1, b2; x. setSize( size ); b1. setSize( size ); b2. setSize( size ); @@ -280,12 +270,11 @@ template< class T > class tnlRgCSRMatrixTester : public CppUnit :: TestCase, { const int size = 12; tnlCSRMatrix< T > csrMatrix; - csrMatrix.setName( "test-matrix:TriDiagonal" ); - tnlRgCSRMatrix< T > argcsrMatrix( "test-matrix:TriDiagonal" ); + tnlRgCSRMatrix< T > argcsrMatrix; this -> setFullMatrix( csrMatrix, size ); argcsrMatrix. copyFrom( csrMatrix ); - tnlVector< T > x( "x" ), b1( "b1" ), b2( "b2" ); + tnlVector< T > x, b1, b2; x. setSize( size ); b1. setSize( size ); b2. setSize( size ); @@ -299,8 +288,7 @@ template< class T > class tnlRgCSRMatrixTester : public CppUnit :: TestCase, void ifSpmvWithBcsstk20MatrixWorks() { tnlCSRMatrix< T > csrMatrix; - csrMatrix.setName( "test-matrix:TriDiagonal" ); - tnlRgCSRMatrix< T > argcsrMatrix( "test-matrix:TriDiagonal" ); + tnlRgCSRMatrix< T > argcsrMatrix; this -> setBcsstk20Matrix( csrMatrix ); argcsrMatrix. copyFrom( csrMatrix ); const int size = csrMatrix. getRows(); diff --git a/tests/unit-tests/mesh/CMakeLists.txt b/tests/unit-tests/mesh/CMakeLists.txt index 66d04858d348c9cd46b44c1946d2e5b960d5cca6..d5f357e079b73fd2a5223c1e444fa44a0689b722 100755 --- a/tests/unit-tests/mesh/CMakeLists.txt +++ b/tests/unit-tests/mesh/CMakeLists.txt @@ -10,8 +10,8 @@ TARGET_LINK_LIBRARIES( tnlGridTest${mpiExt}${debugExt} ${CPPUNIT_LIBRARIES} #TARGET_LINK_LIBRARIES( tnlMeshEntityTest${mpiExt}${debugExt} ${CPPUNIT_LIBRARIES} # tnl${mpiExt}${debugExt}-0.1 ) -#ADD_EXECUTABLE( tnlMeshTest${mpiExt}${debugExt} ${headers} tnlMeshTest.cpp ) -#TARGET_LINK_LIBRARIES( tnlMeshTest${mpiExt}${debugExt} ${CPPUNIT_LIBRARIES} -# tnl${mpiExt}${debugExt}-0.1 ) +ADD_EXECUTABLE( tnlMeshTest${mpiExt}${debugExt} ${headers} tnlMeshTest.cpp ) +TARGET_LINK_LIBRARIES( tnlMeshTest${mpiExt}${debugExt} ${CPPUNIT_LIBRARIES} + tnl${mpiExt}${debugExt}-0.1 ) \ No newline at end of file diff --git a/tests/unit-tests/mesh/tnlMeshEntityTester.h b/tests/unit-tests/mesh/tnlMeshEntityTester.h index 415bec2180a904895b5aa35f47a3dab771286fbd..8a3928c27405b80bd30fc665f838e078e79eecbd 100644 --- a/tests/unit-tests/mesh/tnlMeshEntityTester.h +++ b/tests/unit-tests/mesh/tnlMeshEntityTester.h @@ -26,36 +26,48 @@ #include <cppunit/Message.h> #include <mesh/tnlMeshEntity.h> #include <mesh/config/tnlMeshConfigBase.h> -#include <mesh/topologies/tnlMeshVertexTag.h> -#include <mesh/topologies/tnlMeshEdgeTag.h> -#include <mesh/topologies/tnlMeshTriangleTag.h> -#include <mesh/topologies/tnlMeshTetrahedronTag.h> +#include <mesh/topologies/tnlMeshVertexTopology.h> +#include <mesh/topologies/tnlMeshEdgeTopology.h> +#include <mesh/topologies/tnlMeshTriangleTopology.h> +#include <mesh/topologies/tnlMeshTetrahedronTopology.h> - typedef tnlMeshConfigBase< 2, double, int, int, void > MeshConfigBaseType; - struct TestTriangleEntityTag : public MeshConfigBaseType - { - typedef tnlMeshTriangleTag CellTag; - }; - struct TestEdgeEntityTag : public MeshConfigBaseType - { - typedef tnlMeshEdgeTag CellTag; - }; - struct TestVertexEntityTag : public MeshConfigBaseType - { - typedef tnlMeshVertexTag CellTag; - }; - - template< int Dimensions > - struct tnlMeshSuperentityStorage< TestTriangleEntityTag, tnlMeshVertexTag, Dimensions > - { - enum { enabled = true }; - }; - - template< int Dimensions > - struct tnlMeshSuperentityStorage< TestTriangleEntityTag, tnlMeshEdgeTag, Dimensions > - { - enum { enabled = true }; - }; +//typedef tnlMeshConfigBase< tnlMeshTriangleTopology, 2, double, int, int, void > TestTriangleEntityTopology; +typedef tnlMeshConfigBase< tnlMeshEdgeTopology, 2, double, int, int, void > TestEdgeEntityTopology; +typedef tnlMeshConfigBase< tnlMeshVertexTopology, 2, double, int, int, void > TestVertexEntityTopology; + +class TestTriangleMeshConfig : public tnlMeshConfigBase< tnlMeshTriangleTopology > +{ + public: + + template< typename MeshEntity > + static constexpr bool subentityStorage( MeshEntity entity, int subentityDimensions ) + { + return true; + } + + template< typename MeshEntity > + static constexpr bool superentityStorage( MeshEntity entity, int superentityDimensions ) + { + return true; + } +}; + +class TestTetrahedronMeshConfig : public tnlMeshConfigBase< tnlMeshTetrahedronTopology > +{ + public: + + template< typename MeshEntity > + static constexpr bool subentityStorage( MeshEntity entity, int subentityDimensions ) + { + return true; + } + + template< typename MeshEntity > + static constexpr bool superentityStorage( MeshEntity entity, int superentityDimensions ) + { + return true; + } +}; template< typename RealType, typename Device, typename IndexType > class tnlMeshEntityTester : public CppUnit :: TestCase @@ -86,12 +98,8 @@ class tnlMeshEntityTester : public CppUnit :: TestCase void vertexMeshEntityTest() { - typedef tnlMeshConfigBase< 2, RealType, IndexType, IndexType, void > MeshConfigBaseType; - struct TestEntityTag : public MeshConfigBaseType - { - typedef tnlMeshEdgeTag CellTag; - }; - typedef tnlMeshEntity< TestEntityTag, tnlMeshVertexTag > VertexMeshEntityType; + typedef tnlMeshConfigBase< tnlMeshEdgeTopology, 2, RealType, IndexType, IndexType, void > TestEntityTopology; + typedef tnlMeshEntity< TestEntityTopology, tnlMeshVertexTopology > VertexMeshEntityType; typedef typename VertexMeshEntityType::PointType PointType; CPPUNIT_ASSERT( PointType::getType() == ( tnlStaticVector< 2, RealType >::getType() ) ); @@ -106,8 +114,8 @@ class tnlMeshEntityTester : public CppUnit :: TestCase void edgeMeshEntityTest() { - typedef tnlMeshEntity< TestEdgeEntityTag, tnlMeshEdgeTag > EdgeMeshEntityType; - typedef tnlMeshEntity< TestEdgeEntityTag, tnlMeshVertexTag > VertexMeshEntityType; + typedef tnlMeshEntity< TestEdgeEntityTopology, tnlMeshEdgeTopology > EdgeMeshEntityType; + typedef tnlMeshEntity< TestEdgeEntityTopology, tnlMeshVertexTopology > VertexMeshEntityType; typedef typename VertexMeshEntityType::PointType PointType; CPPUNIT_ASSERT( PointType::getType() == ( tnlStaticVector< 2, RealType >::getType() ) ); @@ -169,9 +177,12 @@ class tnlMeshEntityTester : public CppUnit :: TestCase void triangleMeshEntityTest() { - typedef tnlMeshEntity< TestTriangleEntityTag, tnlMeshTriangleTag > TriangleMeshEntityType; - typedef tnlMeshEntity< TestEdgeEntityTag, tnlMeshEdgeTag > EdgeMeshEntityType; - typedef tnlMeshEntity< TestVertexEntityTag, tnlMeshVertexTag > VertexMeshEntityType; + typedef tnlMeshEntity< TestTriangleMeshConfig, tnlMeshTriangleTopology > TriangleMeshEntityType; + + static_assert( TriangleMeshEntityType::SubentityTraits< 1 >::storageEnabled, "Testing triangular mesh does not store edges as required." ); + static_assert( TriangleMeshEntityType::SubentityTraits< 0 >::storageEnabled, "" ); + typedef tnlMeshEntity< TestEdgeEntityTopology, tnlMeshEdgeTopology > EdgeMeshEntityType; + typedef tnlMeshEntity< TestVertexEntityTopology, tnlMeshVertexTopology > VertexMeshEntityType; typedef typename VertexMeshEntityType::PointType PointType; CPPUNIT_ASSERT( PointType::getType() == ( tnlStaticVector< 2, RealType >::getType() ) ); @@ -192,19 +203,19 @@ class tnlMeshEntityTester : public CppUnit :: TestCase CPPUNIT_ASSERT( vertexEntities[ 2 ].getPoint() == point2 ); tnlStaticArray< 3, EdgeMeshEntityType > edgeEntities; - edgeEntities[ 0 ].setVertexIndex( 0, tnlSubentityVertex< tnlMeshTriangleTag, tnlMeshEdgeTag, 0, 0 >::index ); - edgeEntities[ 0 ].setVertexIndex( 1, tnlSubentityVertex< tnlMeshTriangleTag, tnlMeshEdgeTag, 0, 1 >::index ); - edgeEntities[ 1 ].setVertexIndex( 0, tnlSubentityVertex< tnlMeshTriangleTag, tnlMeshEdgeTag, 1, 0 >::index ); - edgeEntities[ 1 ].setVertexIndex( 1, tnlSubentityVertex< tnlMeshTriangleTag, tnlMeshEdgeTag, 1, 1 >::index ); - edgeEntities[ 2 ].setVertexIndex( 0, tnlSubentityVertex< tnlMeshTriangleTag, tnlMeshEdgeTag, 2, 0 >::index ); - edgeEntities[ 2 ].setVertexIndex( 1, tnlSubentityVertex< tnlMeshTriangleTag, tnlMeshEdgeTag, 2, 1 >::index ); - - CPPUNIT_ASSERT( edgeEntities[ 0 ].getVertexIndex( 0 ) == ( tnlSubentityVertex< tnlMeshTriangleTag, tnlMeshEdgeTag, 0, 0 >::index ) ); - CPPUNIT_ASSERT( edgeEntities[ 0 ].getVertexIndex( 1 ) == ( tnlSubentityVertex< tnlMeshTriangleTag, tnlMeshEdgeTag, 0, 1 >::index ) ); - CPPUNIT_ASSERT( edgeEntities[ 1 ].getVertexIndex( 0 ) == ( tnlSubentityVertex< tnlMeshTriangleTag, tnlMeshEdgeTag, 1, 0 >::index ) ); - CPPUNIT_ASSERT( edgeEntities[ 1 ].getVertexIndex( 1 ) == ( tnlSubentityVertex< tnlMeshTriangleTag, tnlMeshEdgeTag, 1, 1 >::index ) ); - CPPUNIT_ASSERT( edgeEntities[ 2 ].getVertexIndex( 0 ) == ( tnlSubentityVertex< tnlMeshTriangleTag, tnlMeshEdgeTag, 2, 0 >::index ) ); - CPPUNIT_ASSERT( edgeEntities[ 2 ].getVertexIndex( 1 ) == ( tnlSubentityVertex< tnlMeshTriangleTag, tnlMeshEdgeTag, 2, 1 >::index ) ); + edgeEntities[ 0 ].setVertexIndex( 0, tnlSubentityVertex< tnlMeshTriangleTopology, tnlMeshEdgeTopology, 0, 0 >::index ); + edgeEntities[ 0 ].setVertexIndex( 1, tnlSubentityVertex< tnlMeshTriangleTopology, tnlMeshEdgeTopology, 0, 1 >::index ); + edgeEntities[ 1 ].setVertexIndex( 0, tnlSubentityVertex< tnlMeshTriangleTopology, tnlMeshEdgeTopology, 1, 0 >::index ); + edgeEntities[ 1 ].setVertexIndex( 1, tnlSubentityVertex< tnlMeshTriangleTopology, tnlMeshEdgeTopology, 1, 1 >::index ); + edgeEntities[ 2 ].setVertexIndex( 0, tnlSubentityVertex< tnlMeshTriangleTopology, tnlMeshEdgeTopology, 2, 0 >::index ); + edgeEntities[ 2 ].setVertexIndex( 1, tnlSubentityVertex< tnlMeshTriangleTopology, tnlMeshEdgeTopology, 2, 1 >::index ); + + CPPUNIT_ASSERT( edgeEntities[ 0 ].getVertexIndex( 0 ) == ( tnlSubentityVertex< tnlMeshTriangleTopology, tnlMeshEdgeTopology, 0, 0 >::index ) ); + CPPUNIT_ASSERT( edgeEntities[ 0 ].getVertexIndex( 1 ) == ( tnlSubentityVertex< tnlMeshTriangleTopology, tnlMeshEdgeTopology, 0, 1 >::index ) ); + CPPUNIT_ASSERT( edgeEntities[ 1 ].getVertexIndex( 0 ) == ( tnlSubentityVertex< tnlMeshTriangleTopology, tnlMeshEdgeTopology, 1, 0 >::index ) ); + CPPUNIT_ASSERT( edgeEntities[ 1 ].getVertexIndex( 1 ) == ( tnlSubentityVertex< tnlMeshTriangleTopology, tnlMeshEdgeTopology, 1, 1 >::index ) ); + CPPUNIT_ASSERT( edgeEntities[ 2 ].getVertexIndex( 0 ) == ( tnlSubentityVertex< tnlMeshTriangleTopology, tnlMeshEdgeTopology, 2, 0 >::index ) ); + CPPUNIT_ASSERT( edgeEntities[ 2 ].getVertexIndex( 1 ) == ( tnlSubentityVertex< tnlMeshTriangleTopology, tnlMeshEdgeTopology, 2, 1 >::index ) ); TriangleMeshEntityType triangleEntity; @@ -227,27 +238,15 @@ class tnlMeshEntityTester : public CppUnit :: TestCase void tetrahedronMeshEntityTest() { - typedef tnlMeshConfigBase< 3, RealType, IndexType, IndexType, void > MeshConfigBaseType; - struct TestTetrahedronEntityTag : public MeshConfigBaseType - { - typedef tnlMeshTetrahedronTag CellTag; - }; - struct TestTriangleEntityTag : public MeshConfigBaseType - { - typedef tnlMeshTriangleTag CellTag; - }; - struct TestEdgeEntityTag : public MeshConfigBaseType - { - typedef tnlMeshEdgeTag CellTag; - }; - struct TestVertexEntityTag : public MeshConfigBaseType - { - typedef tnlMeshVertexTag CellTag; - }; - typedef tnlMeshEntity< TestTetrahedronEntityTag, tnlMeshTetrahedronTag > TetrahedronMeshEntityType; - typedef tnlMeshEntity< TestTriangleEntityTag, tnlMeshTriangleTag > TriangleMeshEntityType; - typedef tnlMeshEntity< TestEdgeEntityTag, tnlMeshEdgeTag > EdgeMeshEntityType; - typedef tnlMeshEntity< TestVertexEntityTag, tnlMeshVertexTag > VertexMeshEntityType; + //typedef tnlMeshConfigBase< tnlMeshTetrahedronTopology, 3, RealType, IndexType, IndexType, void > TestTetrahedronEntityTopology; + typedef tnlMeshConfigBase< tnlMeshTriangleTopology, 3, RealType, IndexType, IndexType, void > TestTriangleEntityTopology; + typedef tnlMeshConfigBase< tnlMeshEdgeTopology, 3, RealType, IndexType, IndexType, void > TestEdgeEntityTopology; + typedef tnlMeshConfigBase< tnlMeshVertexTopology, 3, RealType, IndexType, IndexType, void > TestVertexEntityTopology; + + typedef tnlMeshEntity< TestTetrahedronMeshConfig, tnlMeshTetrahedronTopology > TetrahedronMeshEntityType; + typedef tnlMeshEntity< TestTriangleMeshConfig, tnlMeshTriangleTopology > TriangleMeshEntityType; + typedef tnlMeshEntity< TestEdgeEntityTopology, tnlMeshEdgeTopology > EdgeMeshEntityType; + typedef tnlMeshEntity< TestVertexEntityTopology, tnlMeshVertexTopology > VertexMeshEntityType; typedef typename VertexMeshEntityType::PointType PointType; CPPUNIT_ASSERT( PointType::getType() == ( tnlStaticVector< 3, RealType >::getType() ) ); @@ -260,7 +259,7 @@ class tnlMeshEntityTester : public CppUnit :: TestCase point2( 0.0, 1.0, 0.0 ), point3( 0.0, 0.0, 1.0 ); - tnlStaticArray< tnlSubentities< tnlMeshTetrahedronTag, 0 >::count, + tnlStaticArray< tnlMeshSubtopology< tnlMeshTetrahedronTopology, 0 >::count, VertexMeshEntityType > vertexEntities; vertexEntities[ 0 ].setPoint( point0 ); @@ -273,58 +272,58 @@ class tnlMeshEntityTester : public CppUnit :: TestCase CPPUNIT_ASSERT( vertexEntities[ 2 ].getPoint() == point2 ); CPPUNIT_ASSERT( vertexEntities[ 3 ].getPoint() == point3 ); - tnlStaticArray< tnlSubentities< tnlMeshTetrahedronTag, 1 >::count, + tnlStaticArray< tnlMeshSubtopology< tnlMeshTetrahedronTopology, 1 >::count, EdgeMeshEntityType > edgeEntities; - edgeEntities[ 0 ].setVertexIndex( 0, tnlSubentityVertex< tnlMeshTetrahedronTag, tnlMeshEdgeTag, 0, 0 >::index ); - edgeEntities[ 0 ].setVertexIndex( 1, tnlSubentityVertex< tnlMeshTetrahedronTag, tnlMeshEdgeTag, 0, 1 >::index ); - edgeEntities[ 1 ].setVertexIndex( 0, tnlSubentityVertex< tnlMeshTetrahedronTag, tnlMeshEdgeTag, 1, 0 >::index ); - edgeEntities[ 1 ].setVertexIndex( 1, tnlSubentityVertex< tnlMeshTetrahedronTag, tnlMeshEdgeTag, 1, 1 >::index ); - edgeEntities[ 2 ].setVertexIndex( 0, tnlSubentityVertex< tnlMeshTetrahedronTag, tnlMeshEdgeTag, 2, 0 >::index ); - edgeEntities[ 2 ].setVertexIndex( 1, tnlSubentityVertex< tnlMeshTetrahedronTag, tnlMeshEdgeTag, 2, 1 >::index ); - edgeEntities[ 3 ].setVertexIndex( 0, tnlSubentityVertex< tnlMeshTetrahedronTag, tnlMeshEdgeTag, 3, 0 >::index ); - edgeEntities[ 3 ].setVertexIndex( 1, tnlSubentityVertex< tnlMeshTetrahedronTag, tnlMeshEdgeTag, 3, 1 >::index ); - edgeEntities[ 4 ].setVertexIndex( 0, tnlSubentityVertex< tnlMeshTetrahedronTag, tnlMeshEdgeTag, 4, 0 >::index ); - edgeEntities[ 4 ].setVertexIndex( 1, tnlSubentityVertex< tnlMeshTetrahedronTag, tnlMeshEdgeTag, 4, 1 >::index ); - edgeEntities[ 5 ].setVertexIndex( 0, tnlSubentityVertex< tnlMeshTetrahedronTag, tnlMeshEdgeTag, 5, 0 >::index ); - edgeEntities[ 5 ].setVertexIndex( 1, tnlSubentityVertex< tnlMeshTetrahedronTag, tnlMeshEdgeTag, 5, 1 >::index ); - - CPPUNIT_ASSERT( edgeEntities[ 0 ].getVertexIndex( 0 ) == ( tnlSubentityVertex< tnlMeshTetrahedronTag, tnlMeshEdgeTag, 0, 0 >::index ) ); - CPPUNIT_ASSERT( edgeEntities[ 0 ].getVertexIndex( 1 ) == ( tnlSubentityVertex< tnlMeshTetrahedronTag, tnlMeshEdgeTag, 0, 1 >::index ) ); - CPPUNIT_ASSERT( edgeEntities[ 1 ].getVertexIndex( 0 ) == ( tnlSubentityVertex< tnlMeshTetrahedronTag, tnlMeshEdgeTag, 1, 0 >::index ) ); - CPPUNIT_ASSERT( edgeEntities[ 1 ].getVertexIndex( 1 ) == ( tnlSubentityVertex< tnlMeshTetrahedronTag, tnlMeshEdgeTag, 1, 1 >::index ) ); - CPPUNIT_ASSERT( edgeEntities[ 2 ].getVertexIndex( 0 ) == ( tnlSubentityVertex< tnlMeshTetrahedronTag, tnlMeshEdgeTag, 2, 0 >::index ) ); - CPPUNIT_ASSERT( edgeEntities[ 2 ].getVertexIndex( 1 ) == ( tnlSubentityVertex< tnlMeshTetrahedronTag, tnlMeshEdgeTag, 2, 1 >::index ) ); - CPPUNIT_ASSERT( edgeEntities[ 3 ].getVertexIndex( 0 ) == ( tnlSubentityVertex< tnlMeshTetrahedronTag, tnlMeshEdgeTag, 3, 0 >::index ) ); - CPPUNIT_ASSERT( edgeEntities[ 3 ].getVertexIndex( 1 ) == ( tnlSubentityVertex< tnlMeshTetrahedronTag, tnlMeshEdgeTag, 3, 1 >::index ) ); - CPPUNIT_ASSERT( edgeEntities[ 4 ].getVertexIndex( 0 ) == ( tnlSubentityVertex< tnlMeshTetrahedronTag, tnlMeshEdgeTag, 4, 0 >::index ) ); - CPPUNIT_ASSERT( edgeEntities[ 4 ].getVertexIndex( 1 ) == ( tnlSubentityVertex< tnlMeshTetrahedronTag, tnlMeshEdgeTag, 4, 1 >::index ) ); - CPPUNIT_ASSERT( edgeEntities[ 5 ].getVertexIndex( 0 ) == ( tnlSubentityVertex< tnlMeshTetrahedronTag, tnlMeshEdgeTag, 5, 0 >::index ) ); - CPPUNIT_ASSERT( edgeEntities[ 5 ].getVertexIndex( 1 ) == ( tnlSubentityVertex< tnlMeshTetrahedronTag, tnlMeshEdgeTag, 5, 1 >::index ) ); - - tnlStaticArray< tnlSubentities< tnlMeshTetrahedronTag, 2 >::count, + edgeEntities[ 0 ].setVertexIndex( 0, tnlSubentityVertex< tnlMeshTetrahedronTopology, tnlMeshEdgeTopology, 0, 0 >::index ); + edgeEntities[ 0 ].setVertexIndex( 1, tnlSubentityVertex< tnlMeshTetrahedronTopology, tnlMeshEdgeTopology, 0, 1 >::index ); + edgeEntities[ 1 ].setVertexIndex( 0, tnlSubentityVertex< tnlMeshTetrahedronTopology, tnlMeshEdgeTopology, 1, 0 >::index ); + edgeEntities[ 1 ].setVertexIndex( 1, tnlSubentityVertex< tnlMeshTetrahedronTopology, tnlMeshEdgeTopology, 1, 1 >::index ); + edgeEntities[ 2 ].setVertexIndex( 0, tnlSubentityVertex< tnlMeshTetrahedronTopology, tnlMeshEdgeTopology, 2, 0 >::index ); + edgeEntities[ 2 ].setVertexIndex( 1, tnlSubentityVertex< tnlMeshTetrahedronTopology, tnlMeshEdgeTopology, 2, 1 >::index ); + edgeEntities[ 3 ].setVertexIndex( 0, tnlSubentityVertex< tnlMeshTetrahedronTopology, tnlMeshEdgeTopology, 3, 0 >::index ); + edgeEntities[ 3 ].setVertexIndex( 1, tnlSubentityVertex< tnlMeshTetrahedronTopology, tnlMeshEdgeTopology, 3, 1 >::index ); + edgeEntities[ 4 ].setVertexIndex( 0, tnlSubentityVertex< tnlMeshTetrahedronTopology, tnlMeshEdgeTopology, 4, 0 >::index ); + edgeEntities[ 4 ].setVertexIndex( 1, tnlSubentityVertex< tnlMeshTetrahedronTopology, tnlMeshEdgeTopology, 4, 1 >::index ); + edgeEntities[ 5 ].setVertexIndex( 0, tnlSubentityVertex< tnlMeshTetrahedronTopology, tnlMeshEdgeTopology, 5, 0 >::index ); + edgeEntities[ 5 ].setVertexIndex( 1, tnlSubentityVertex< tnlMeshTetrahedronTopology, tnlMeshEdgeTopology, 5, 1 >::index ); + + CPPUNIT_ASSERT( edgeEntities[ 0 ].getVertexIndex( 0 ) == ( tnlSubentityVertex< tnlMeshTetrahedronTopology, tnlMeshEdgeTopology, 0, 0 >::index ) ); + CPPUNIT_ASSERT( edgeEntities[ 0 ].getVertexIndex( 1 ) == ( tnlSubentityVertex< tnlMeshTetrahedronTopology, tnlMeshEdgeTopology, 0, 1 >::index ) ); + CPPUNIT_ASSERT( edgeEntities[ 1 ].getVertexIndex( 0 ) == ( tnlSubentityVertex< tnlMeshTetrahedronTopology, tnlMeshEdgeTopology, 1, 0 >::index ) ); + CPPUNIT_ASSERT( edgeEntities[ 1 ].getVertexIndex( 1 ) == ( tnlSubentityVertex< tnlMeshTetrahedronTopology, tnlMeshEdgeTopology, 1, 1 >::index ) ); + CPPUNIT_ASSERT( edgeEntities[ 2 ].getVertexIndex( 0 ) == ( tnlSubentityVertex< tnlMeshTetrahedronTopology, tnlMeshEdgeTopology, 2, 0 >::index ) ); + CPPUNIT_ASSERT( edgeEntities[ 2 ].getVertexIndex( 1 ) == ( tnlSubentityVertex< tnlMeshTetrahedronTopology, tnlMeshEdgeTopology, 2, 1 >::index ) ); + CPPUNIT_ASSERT( edgeEntities[ 3 ].getVertexIndex( 0 ) == ( tnlSubentityVertex< tnlMeshTetrahedronTopology, tnlMeshEdgeTopology, 3, 0 >::index ) ); + CPPUNIT_ASSERT( edgeEntities[ 3 ].getVertexIndex( 1 ) == ( tnlSubentityVertex< tnlMeshTetrahedronTopology, tnlMeshEdgeTopology, 3, 1 >::index ) ); + CPPUNIT_ASSERT( edgeEntities[ 4 ].getVertexIndex( 0 ) == ( tnlSubentityVertex< tnlMeshTetrahedronTopology, tnlMeshEdgeTopology, 4, 0 >::index ) ); + CPPUNIT_ASSERT( edgeEntities[ 4 ].getVertexIndex( 1 ) == ( tnlSubentityVertex< tnlMeshTetrahedronTopology, tnlMeshEdgeTopology, 4, 1 >::index ) ); + CPPUNIT_ASSERT( edgeEntities[ 5 ].getVertexIndex( 0 ) == ( tnlSubentityVertex< tnlMeshTetrahedronTopology, tnlMeshEdgeTopology, 5, 0 >::index ) ); + CPPUNIT_ASSERT( edgeEntities[ 5 ].getVertexIndex( 1 ) == ( tnlSubentityVertex< tnlMeshTetrahedronTopology, tnlMeshEdgeTopology, 5, 1 >::index ) ); + + tnlStaticArray< tnlMeshSubtopology< tnlMeshTetrahedronTopology, 2 >::count, TriangleMeshEntityType > triangleEntities; - triangleEntities[ 0 ].setVertexIndex( 0, tnlSubentityVertex< tnlMeshTetrahedronTag, tnlMeshTriangleTag, 0, 0 >::index ); - triangleEntities[ 0 ].setVertexIndex( 1, tnlSubentityVertex< tnlMeshTetrahedronTag, tnlMeshTriangleTag, 0, 1 >::index ); - triangleEntities[ 0 ].setVertexIndex( 2, tnlSubentityVertex< tnlMeshTetrahedronTag, tnlMeshTriangleTag, 0, 2 >::index ); - triangleEntities[ 1 ].setVertexIndex( 0, tnlSubentityVertex< tnlMeshTetrahedronTag, tnlMeshTriangleTag, 1, 0 >::index ); - triangleEntities[ 1 ].setVertexIndex( 1, tnlSubentityVertex< tnlMeshTetrahedronTag, tnlMeshTriangleTag, 1, 1 >::index ); - triangleEntities[ 1 ].setVertexIndex( 2, tnlSubentityVertex< tnlMeshTetrahedronTag, tnlMeshTriangleTag, 1, 2 >::index ); - triangleEntities[ 2 ].setVertexIndex( 0, tnlSubentityVertex< tnlMeshTetrahedronTag, tnlMeshTriangleTag, 2, 0 >::index ); - triangleEntities[ 2 ].setVertexIndex( 1, tnlSubentityVertex< tnlMeshTetrahedronTag, tnlMeshTriangleTag, 2, 1 >::index ); - triangleEntities[ 2 ].setVertexIndex( 2, tnlSubentityVertex< tnlMeshTetrahedronTag, tnlMeshTriangleTag, 2, 2 >::index ); - triangleEntities[ 3 ].setVertexIndex( 0, tnlSubentityVertex< tnlMeshTetrahedronTag, tnlMeshTriangleTag, 3, 0 >::index ); - triangleEntities[ 3 ].setVertexIndex( 1, tnlSubentityVertex< tnlMeshTetrahedronTag, tnlMeshTriangleTag, 3, 1 >::index ); - triangleEntities[ 3 ].setVertexIndex( 2, tnlSubentityVertex< tnlMeshTetrahedronTag, tnlMeshTriangleTag, 3, 2 >::index ); - - CPPUNIT_ASSERT( triangleEntities[ 0 ].getVertexIndex( 0 ) == ( tnlSubentityVertex< tnlMeshTetrahedronTag, tnlMeshTriangleTag, 0, 0 >::index ) ); - CPPUNIT_ASSERT( triangleEntities[ 0 ].getVertexIndex( 1 ) == ( tnlSubentityVertex< tnlMeshTetrahedronTag, tnlMeshTriangleTag, 0, 1 >::index ) ); - CPPUNIT_ASSERT( triangleEntities[ 0 ].getVertexIndex( 2 ) == ( tnlSubentityVertex< tnlMeshTetrahedronTag, tnlMeshTriangleTag, 0, 2 >::index ) ); - CPPUNIT_ASSERT( triangleEntities[ 1 ].getVertexIndex( 0 ) == ( tnlSubentityVertex< tnlMeshTetrahedronTag, tnlMeshTriangleTag, 1, 0 >::index ) ); - CPPUNIT_ASSERT( triangleEntities[ 1 ].getVertexIndex( 1 ) == ( tnlSubentityVertex< tnlMeshTetrahedronTag, tnlMeshTriangleTag, 1, 1 >::index ) ); - CPPUNIT_ASSERT( triangleEntities[ 1 ].getVertexIndex( 2 ) == ( tnlSubentityVertex< tnlMeshTetrahedronTag, tnlMeshTriangleTag, 1, 2 >::index ) ); - CPPUNIT_ASSERT( triangleEntities[ 2 ].getVertexIndex( 0 ) == ( tnlSubentityVertex< tnlMeshTetrahedronTag, tnlMeshTriangleTag, 2, 0 >::index ) ); - CPPUNIT_ASSERT( triangleEntities[ 2 ].getVertexIndex( 1 ) == ( tnlSubentityVertex< tnlMeshTetrahedronTag, tnlMeshTriangleTag, 2, 1 >::index ) ); - CPPUNIT_ASSERT( triangleEntities[ 2 ].getVertexIndex( 2 ) == ( tnlSubentityVertex< tnlMeshTetrahedronTag, tnlMeshTriangleTag, 2, 2 >::index ) ); + triangleEntities[ 0 ].setVertexIndex( 0, tnlSubentityVertex< tnlMeshTetrahedronTopology, tnlMeshTriangleTopology, 0, 0 >::index ); + triangleEntities[ 0 ].setVertexIndex( 1, tnlSubentityVertex< tnlMeshTetrahedronTopology, tnlMeshTriangleTopology, 0, 1 >::index ); + triangleEntities[ 0 ].setVertexIndex( 2, tnlSubentityVertex< tnlMeshTetrahedronTopology, tnlMeshTriangleTopology, 0, 2 >::index ); + triangleEntities[ 1 ].setVertexIndex( 0, tnlSubentityVertex< tnlMeshTetrahedronTopology, tnlMeshTriangleTopology, 1, 0 >::index ); + triangleEntities[ 1 ].setVertexIndex( 1, tnlSubentityVertex< tnlMeshTetrahedronTopology, tnlMeshTriangleTopology, 1, 1 >::index ); + triangleEntities[ 1 ].setVertexIndex( 2, tnlSubentityVertex< tnlMeshTetrahedronTopology, tnlMeshTriangleTopology, 1, 2 >::index ); + triangleEntities[ 2 ].setVertexIndex( 0, tnlSubentityVertex< tnlMeshTetrahedronTopology, tnlMeshTriangleTopology, 2, 0 >::index ); + triangleEntities[ 2 ].setVertexIndex( 1, tnlSubentityVertex< tnlMeshTetrahedronTopology, tnlMeshTriangleTopology, 2, 1 >::index ); + triangleEntities[ 2 ].setVertexIndex( 2, tnlSubentityVertex< tnlMeshTetrahedronTopology, tnlMeshTriangleTopology, 2, 2 >::index ); + triangleEntities[ 3 ].setVertexIndex( 0, tnlSubentityVertex< tnlMeshTetrahedronTopology, tnlMeshTriangleTopology, 3, 0 >::index ); + triangleEntities[ 3 ].setVertexIndex( 1, tnlSubentityVertex< tnlMeshTetrahedronTopology, tnlMeshTriangleTopology, 3, 1 >::index ); + triangleEntities[ 3 ].setVertexIndex( 2, tnlSubentityVertex< tnlMeshTetrahedronTopology, tnlMeshTriangleTopology, 3, 2 >::index ); + + CPPUNIT_ASSERT( triangleEntities[ 0 ].getVertexIndex( 0 ) == ( tnlSubentityVertex< tnlMeshTetrahedronTopology, tnlMeshTriangleTopology, 0, 0 >::index ) ); + CPPUNIT_ASSERT( triangleEntities[ 0 ].getVertexIndex( 1 ) == ( tnlSubentityVertex< tnlMeshTetrahedronTopology, tnlMeshTriangleTopology, 0, 1 >::index ) ); + CPPUNIT_ASSERT( triangleEntities[ 0 ].getVertexIndex( 2 ) == ( tnlSubentityVertex< tnlMeshTetrahedronTopology, tnlMeshTriangleTopology, 0, 2 >::index ) ); + CPPUNIT_ASSERT( triangleEntities[ 1 ].getVertexIndex( 0 ) == ( tnlSubentityVertex< tnlMeshTetrahedronTopology, tnlMeshTriangleTopology, 1, 0 >::index ) ); + CPPUNIT_ASSERT( triangleEntities[ 1 ].getVertexIndex( 1 ) == ( tnlSubentityVertex< tnlMeshTetrahedronTopology, tnlMeshTriangleTopology, 1, 1 >::index ) ); + CPPUNIT_ASSERT( triangleEntities[ 1 ].getVertexIndex( 2 ) == ( tnlSubentityVertex< tnlMeshTetrahedronTopology, tnlMeshTriangleTopology, 1, 2 >::index ) ); + CPPUNIT_ASSERT( triangleEntities[ 2 ].getVertexIndex( 0 ) == ( tnlSubentityVertex< tnlMeshTetrahedronTopology, tnlMeshTriangleTopology, 2, 0 >::index ) ); + CPPUNIT_ASSERT( triangleEntities[ 2 ].getVertexIndex( 1 ) == ( tnlSubentityVertex< tnlMeshTetrahedronTopology, tnlMeshTriangleTopology, 2, 1 >::index ) ); + CPPUNIT_ASSERT( triangleEntities[ 2 ].getVertexIndex( 2 ) == ( tnlSubentityVertex< tnlMeshTetrahedronTopology, tnlMeshTriangleTopology, 2, 2 >::index ) ); TetrahedronMeshEntityType tetrahedronEntity; tetrahedronEntity.setVertexIndex( 0, 0 ); @@ -365,9 +364,9 @@ class tnlMeshEntityTester : public CppUnit :: TestCase void twoTrianglesTest() { - typedef tnlMeshEntity< TestTriangleEntityTag, tnlMeshTriangleTag > TriangleMeshEntityType; - typedef tnlMeshEntity< TestTriangleEntityTag, tnlMeshEdgeTag > EdgeMeshEntityType; - typedef tnlMeshEntity< TestTriangleEntityTag, tnlMeshVertexTag > VertexMeshEntityType; + typedef tnlMeshEntity< TestTriangleMeshConfig, tnlMeshTriangleTopology > TriangleMeshEntityType; + typedef tnlMeshEntity< TestTriangleMeshConfig, tnlMeshEdgeTopology > EdgeMeshEntityType; + typedef tnlMeshEntity< TestTriangleMeshConfig, tnlMeshVertexTopology > VertexMeshEntityType; typedef typename VertexMeshEntityType::PointType PointType; CPPUNIT_ASSERT( PointType::getType() == ( tnlStaticVector< 2, RealType >::getType() ) ); @@ -457,7 +456,7 @@ class tnlMeshEntityTester : public CppUnit :: TestCase CPPUNIT_ASSERT( triangleEntities[ 1 ].template getSubentityIndex< 1 >( 1 ) == 3 ); CPPUNIT_ASSERT( triangleEntities[ 1 ].template getSubentityIndex< 1 >( 2 ) == 4 ); - vertexEntities[ 0 ].template setNumberOfSuperentities< 1 >( 2 ); + /*vertexEntities[ 0 ].template setNumberOfSuperentities< 1 >( 2 ); vertexEntities[ 0 ].template setSuperentityIndex< 1 >( 0, 2 ); vertexEntities[ 0 ].template setSuperentityIndex< 1 >( 1, 1 ); @@ -468,7 +467,7 @@ class tnlMeshEntityTester : public CppUnit :: TestCase vertexEntities[ 1 ].template setNumberOfSuperentities< 2 >( 2 ); vertexEntities[ 1 ].template setSuperentityIndex< 2 >( 0, 0 ); - vertexEntities[ 1 ].template setSuperentityIndex< 2 >( 1, 1 ); + vertexEntities[ 1 ].template setSuperentityIndex< 2 >( 1, 1 );*/ CPPUNIT_ASSERT( vertexEntities[ 0 ].template getNumberOfSuperentities< 1 >() == 2 ); CPPUNIT_ASSERT( vertexEntities[ 0 ].template getSuperentityIndex< 1 >( 0 ) == 2 ); @@ -483,12 +482,12 @@ class tnlMeshEntityTester : public CppUnit :: TestCase CPPUNIT_ASSERT( vertexEntities[ 1 ].template getSuperentityIndex< 2 >( 0 ) == 0 ); CPPUNIT_ASSERT( vertexEntities[ 1 ].template getSuperentityIndex< 2 >( 1 ) == 1 ); - edgeEntities[ 0 ].template setNumberOfSuperentities< 2 >( 2 ); + /*edgeEntities[ 0 ].template setNumberOfSuperentities< 2 >( 2 ); edgeEntities[ 0 ].template setSuperentityIndex< 2 >( 0, 0 ); - edgeEntities[ 0 ].template setSuperentityIndex< 2 >( 1, 1 ); + edgeEntities[ 0 ].template setSuperentityIndex< 2 >( 1, 1 );*/ - CPPUNIT_ASSERT( edgeEntities[ 0 ].template getNumberOfSuperentities< 2 >() == 2 ); - CPPUNIT_ASSERT( edgeEntities[ 0 ].template getSuperentityIndex< 2 >( 0 ) == 0 ); + /*CPPUNIT_ASSERT( edgeEntities[ 0 ].template getNumberOfSuperentities< 2 >() == 2 ); + CPPUNIT_ASSERT( edgeEntities[ 0 ].template getSuperentityIndex< 2 >( 0 ) == 0 );*/ }; }; diff --git a/tests/unit-tests/mesh/tnlMeshTest.cpp b/tests/unit-tests/mesh/tnlMeshTest.cpp index 0e7722090d62f6ab684da3d828f3dd20ad3ea158..38f77e55418b9c64ec0916764c21e70988f4a2db 100644 --- a/tests/unit-tests/mesh/tnlMeshTest.cpp +++ b/tests/unit-tests/mesh/tnlMeshTest.cpp @@ -28,7 +28,7 @@ int main( int argc, char* argv[] ) { #ifndef HAVE_NOT_CXX11 #ifdef HAVE_CPPUNIT - //tnlMeshTester< double, tnlHost, long int > t; + tnlMeshTester< double, tnlHost, long int > t; //t.regularMeshOfHexahedronsTest(); if( ! tnlUnitTestStarter :: run< tnlMeshTester< double, tnlHost, long int > >() ) diff --git a/tests/unit-tests/mesh/tnlMeshTester.h b/tests/unit-tests/mesh/tnlMeshTester.h index 7e9254e643eb3a01187f8e90da61c14a88e0349b..d7f2a9b44efd43de06fbf89439090c31dca6ab96 100644 --- a/tests/unit-tests/mesh/tnlMeshTester.h +++ b/tests/unit-tests/mesh/tnlMeshTester.h @@ -27,94 +27,53 @@ #include <mesh/tnlMesh.h> #include <mesh/tnlMeshEntity.h> #include <mesh/config/tnlMeshConfigBase.h> -#include <mesh/topologies/tnlMeshVertexTag.h> -#include <mesh/topologies/tnlMeshEdgeTag.h> -#include <mesh/topologies/tnlMeshTriangleTag.h> -#include <mesh/topologies/tnlMeshQuadrilateralTag.h> -#include <mesh/topologies/tnlMeshTetrahedronTag.h> -#include <mesh/topologies/tnlMeshHexahedronTag.h> -#include <mesh/tnlMeshInitializer.h> - - typedef tnlMeshConfigBase< 2, double, int, int, void > Mesh2dConfigBaseType; - struct TestTriangleMeshConfig : public Mesh2dConfigBaseType - { - typedef tnlMeshTriangleTag CellTag; - }; - - template< int Dimensions > - struct tnlMeshSuperentityStorage< TestTriangleMeshConfig, tnlMeshVertexTag, Dimensions > - { - enum { enabled = true }; - }; - - template< int Dimensions > - struct tnlMeshSuperentityStorage< TestTriangleMeshConfig, tnlMeshEdgeTag, Dimensions > - { - enum { enabled = true }; - }; - - struct TestQuadrilateralMeshConfig : public Mesh2dConfigBaseType - { - typedef tnlMeshQuadrilateralTag CellTag; - }; - - template< int Dimensions > - struct tnlMeshSuperentityStorage< TestQuadrilateralMeshConfig, tnlMeshVertexTag, Dimensions > - { - enum { enabled = true }; - }; - - template< int Dimensions > - struct tnlMeshSuperentityStorage< TestQuadrilateralMeshConfig, tnlMeshEdgeTag, Dimensions > - { - enum { enabled = true }; - }; - - typedef tnlMeshConfigBase< 3, double, int, int, void > Mesh3dConfigBaseType; - struct TestTetrahedronMeshConfig : public Mesh3dConfigBaseType - { - typedef tnlMeshTetrahedronTag CellTag; - }; - - template< int Dimensions > - struct tnlMeshSuperentityStorage< TestTetrahedronMeshConfig, tnlMeshVertexTag, Dimensions > - { - enum { enabled = true }; - }; - - template< int Dimensions > - struct tnlMeshSuperentityStorage< TestTetrahedronMeshConfig, tnlMeshEdgeTag, Dimensions > - { - enum { enabled = true }; - }; - - template< int Dimensions > - struct tnlMeshSuperentityStorage< TestTetrahedronMeshConfig, tnlMeshTriangleTag, Dimensions > - { - enum { enabled = true }; - }; - -struct TestHexahedronMeshConfig : public Mesh3dConfigBaseType +#include <mesh/topologies/tnlMeshVertexTopology.h> +#include <mesh/topologies/tnlMeshEdgeTopology.h> +#include <mesh/topologies/tnlMeshTriangleTopology.h> +#include <mesh/topologies/tnlMeshQuadrilateralTopology.h> +#include <mesh/topologies/tnlMeshTetrahedronTopology.h> +#include <mesh/topologies/tnlMeshHexahedronTopology.h> +#include <mesh/initializer/tnlMeshInitializer.h> +#include <mesh/tnlMeshBuilder.h> + +class TestTriangleMeshConfig : public tnlMeshConfigBase< tnlMeshTriangleTopology > { - typedef tnlMeshHexahedronTag CellTag; + public: + + static constexpr bool entityStorage( int dimensions ) { return true; }; + template< typename MeshEntity > static constexpr bool subentityStorage( MeshEntity, int SubentityDimensions ) { return true; }; + //template< typename MeshEntity > static constexpr bool subentityOrientationStorage( MeshEntity, int SubentityDimensions ) { return true; }; + template< typename MeshEntity > static constexpr bool superentityStorage( MeshEntity, int SuperentityDimensions ) { return true; }; }; -template< int Dimensions > -struct tnlMeshSuperentityStorage< TestHexahedronMeshConfig, tnlMeshVertexTag, Dimensions > +class TestQuadrilateralMeshConfig : public tnlMeshConfigBase< tnlMeshQuadrilateralTopology > { - enum { enabled = true }; + public: + + static constexpr bool entityStorage( int dimensions ) { return true; }; + template< typename MeshEntity > static constexpr bool subentityStorage( MeshEntity, int SubentityDimensions ) { return true; }; + template< typename MeshEntity > static constexpr bool subentityOrientationStorage( MeshEntity, int SubentityDimensions ) { return ( SubentityDimensions % 2 != 0 ); }; + template< typename MeshEntity > static constexpr bool superentityStorage( MeshEntity, int SuperentityDimensions ) { return true; }; }; -template< int Dimensions > -struct tnlMeshSuperentityStorage< TestHexahedronMeshConfig, tnlMeshEdgeTag, Dimensions > +class TestTetrahedronMeshConfig : public tnlMeshConfigBase< tnlMeshTetrahedronTopology > { - enum { enabled = true }; + public: + + static constexpr bool entityStorage( int dimensions ) { return true; }; + template< typename MeshEntity > static constexpr bool subentityStorage( MeshEntity, int SubentityDimensions ) { return true; }; + template< typename MeshEntity > static constexpr bool subentityOrientationStorage( MeshEntity, int SubentityDimensions ) { return ( SubentityDimensions % 2 != 0 ); }; + template< typename MeshEntity > static constexpr bool superentityStorage( MeshEntity, int SuperentityDimensions ) { return true; }; }; -template< int Dimensions > -struct tnlMeshSuperentityStorage< TestHexahedronMeshConfig, tnlMeshTriangleTag, Dimensions > +class TestHexahedronMeshConfig : public tnlMeshConfigBase< tnlMeshHexahedronTopology > { - enum { enabled = true }; + public: + + static constexpr bool entityStorage( int dimensions ) { return true; }; + template< typename MeshEntity > static constexpr bool subentityStorage( MeshEntity, int SubentityDimensions ) { return true; }; + template< typename MeshEntity > static constexpr bool subentityOrientationStorage( MeshEntity, int SubentityDimensions ) { return ( SubentityDimensions % 2 != 0 ); }; + template< typename MeshEntity > static constexpr bool superentityStorage( MeshEntity, int SuperentityDimensions ) { return true; }; }; template< typename RealType, typename Device, typename IndexType > @@ -134,19 +93,19 @@ class tnlMeshTester : public CppUnit :: TestCase CppUnit :: TestSuite* suiteOfTests = new CppUnit :: TestSuite( "tnlMeshTester" ); CppUnit :: TestResult result; - suiteOfTests -> addTest( new TestCallerType( "twoTrianglesTest", &TesterType::twoTrianglesTest ) ); - suiteOfTests -> addTest( new TestCallerType( "tetrahedronsTest", &TesterType::tetrahedronsTest ) ); - suiteOfTests -> addTest( new TestCallerType( "regularMeshOfTrianglesTest", &TesterType::regularMeshOfTrianglesTest ) ); - suiteOfTests -> addTest( new TestCallerType( "regularMeshOfQuadrilateralsTest", &TesterType::regularMeshOfQuadrilateralsTest ) ); - suiteOfTests -> addTest( new TestCallerType( "regularMeshOfHexahedronsTest", &TesterType::regularMeshOfHexahedronsTest ) ); + suiteOfTests->addTest( new TestCallerType( "twoTrianglesTest", &TesterType::twoTrianglesTest ) ); + suiteOfTests->addTest( new TestCallerType( "tetrahedronsTest", &TesterType::tetrahedronsTest ) ); + suiteOfTests->addTest( new TestCallerType( "regularMeshOfTrianglesTest", &TesterType::regularMeshOfTrianglesTest ) ); + suiteOfTests->addTest( new TestCallerType( "regularMeshOfQuadrilateralsTest", &TesterType::regularMeshOfQuadrilateralsTest ) ); + suiteOfTests->addTest( new TestCallerType( "regularMeshOfHexahedronsTest", &TesterType::regularMeshOfHexahedronsTest ) ); return suiteOfTests; } void twoTrianglesTest() { - typedef tnlMeshEntity< TestTriangleMeshConfig, tnlMeshTriangleTag > TriangleMeshEntityType; - typedef tnlMeshEntity< TestTriangleMeshConfig, tnlMeshEdgeTag > EdgeMeshEntityType; - typedef tnlMeshEntity< TestTriangleMeshConfig, tnlMeshVertexTag > VertexMeshEntityType; + typedef tnlMeshEntity< TestTriangleMeshConfig, tnlMeshTriangleTopology > TriangleMeshEntityType; + typedef tnlMeshEntity< TestTriangleMeshConfig, tnlMeshEdgeTopology > EdgeMeshEntityType; + typedef tnlMeshEntity< TestTriangleMeshConfig, tnlMeshVertexTopology > VertexMeshEntityType; typedef typename VertexMeshEntityType::PointType PointType; CPPUNIT_ASSERT( PointType::getType() == ( tnlStaticVector< 2, RealType >::getType() ) ); @@ -169,61 +128,59 @@ class tnlMeshTester : public CppUnit :: TestCase point0 edge2 point1 */ - tnlMesh< TestTriangleMeshConfig > mesh, mesh2; - mesh.setName( "mesh" ); - mesh.setNumberOfVertices( 4 ); - mesh.setVertex( 0, PointType( 0.0, 0.0 ) ); - mesh.setVertex( 1, PointType( 1.0, 0.0 ) ); - mesh.setVertex( 2, PointType( 0.0, 1.0 ) ); - mesh.setVertex( 3, PointType( 1.0, 1.0 ) ); - - mesh.setNumberOfEntities< 2 >( 2 ); - mesh.getEntity< 2 >( 0 ).setVertexIndex( 0, 0 ); - mesh.getEntity< 2 >( 0 ).setVertexIndex( 1, 1 ); - mesh.getEntity< 2 >( 0 ).setVertexIndex( 2, 2 ); - mesh.getEntity< 2 >( 1 ).setVertexIndex( 0, 1 ); - mesh.getEntity< 2 >( 1 ).setVertexIndex( 1, 2 ); - mesh.getEntity< 2 >( 1 ).setVertexIndex( 2, 3 ); - - tnlMeshInitializer< TestTriangleMeshConfig > meshInitializer; - meshInitializer.initMesh( mesh ); - + typedef tnlMesh< TestTriangleMeshConfig > TriangleTestMesh; + TriangleTestMesh mesh, mesh2; + tnlMeshBuilder< TriangleTestMesh > meshBuilder; + meshBuilder.setPointsCount( 4 ); + meshBuilder.setPoint( 0, PointType( 0.0, 0.0 ) ); + meshBuilder.setPoint( 1, PointType( 1.0, 0.0 ) ); + meshBuilder.setPoint( 2, PointType( 0.0, 1.0 ) ); + meshBuilder.setPoint( 3, PointType( 1.0, 1.0 ) ); + + meshBuilder.setCellsCount( 2 ); + meshBuilder.getCellSeed( 0 ).setCornerId( 0, 0 ); + meshBuilder.getCellSeed( 0 ).setCornerId( 1, 1 ); + meshBuilder.getCellSeed( 0 ).setCornerId( 2, 2 ); + meshBuilder.getCellSeed( 1 ).setCornerId( 0, 1 ); + meshBuilder.getCellSeed( 1 ).setCornerId( 1, 2 ); + meshBuilder.getCellSeed( 1 ).setCornerId( 2, 3 ); + meshBuilder.build( mesh ); + CPPUNIT_ASSERT( mesh.getNumberOfEntities< 2 >() == 2 ); CPPUNIT_ASSERT( mesh.getNumberOfEntities< 1 >() == 5 ); CPPUNIT_ASSERT( mesh.getNumberOfEntities< 0 >() == 4 ); - CPPUNIT_ASSERT( mesh.save( "mesh.tnl" ) ); - CPPUNIT_ASSERT( mesh2.load( "mesh.tnl" ) ); - CPPUNIT_ASSERT( mesh == mesh2 ); + //CPPUNIT_ASSERT( mesh.save( "mesh.tnl" ) ); + //CPPUNIT_ASSERT( mesh2.load( "mesh.tnl" ) ); + //CPPUNIT_ASSERT( mesh == mesh2 ); - //mesh2.setName( "mesh2" ); //mesh.print( cout ); //mesh2.print( cout ); - - }; void tetrahedronsTest() { - typedef tnlMeshEntity< TestTetrahedronMeshConfig, tnlMeshTriangleTag > TriangleMeshEntityType; - typedef tnlMeshEntity< TestTetrahedronMeshConfig, tnlMeshEdgeTag > EdgeMeshEntityType; - typedef tnlMeshEntity< TestTetrahedronMeshConfig, tnlMeshVertexTag > VertexMeshEntityType; + typedef tnlMeshEntity< TestTetrahedronMeshConfig, tnlMeshTriangleTopology > TriangleMeshEntityType; + typedef tnlMeshEntity< TestTetrahedronMeshConfig, tnlMeshEdgeTopology > EdgeMeshEntityType; + typedef tnlMeshEntity< TestTetrahedronMeshConfig, tnlMeshVertexTopology > VertexMeshEntityType; typedef typename VertexMeshEntityType::PointType PointType; - tnlMesh< TestTetrahedronMeshConfig > mesh, mesh2; - mesh.setNumberOfVertices( 13 ); - mesh.setVertex( 0, PointType( 0.000000, 0.000000, 0.000000 ) ); - mesh.setVertex( 1, PointType( 0.000000, 0.000000, 8.000000 ) ); - mesh.setVertex( 2, PointType( 0.000000, 8.000000, 0.000000 ) ); - mesh.setVertex( 3, PointType( 15.000000, 0.000000, 0.000000 ) ); - mesh.setVertex( 4, PointType( 0.000000, 8.000000, 8.000000 ) ); - mesh.setVertex( 5, PointType( 15.000000, 0.000000, 8.000000 ) ); - mesh.setVertex( 6, PointType( 15.000000, 8.000000, 0.000000 ) ); - mesh.setVertex( 7, PointType( 15.000000, 8.000000, 8.000000 ) ); - mesh.setVertex( 8, PointType( 7.470740, 8.000000, 8.000000 ) ); - mesh.setVertex( 9, PointType( 7.470740, 0.000000, 8.000000 ) ); - mesh.setVertex( 10, PointType( 7.504125, 8.000000, 0.000000 ) ); - mesh.setVertex( 11, PointType( 7.212720, 0.000000, 0.000000 ) ); - mesh.setVertex( 12, PointType( 11.184629, 3.987667, 3.985835 ) ); + typedef tnlMesh< TestTetrahedronMeshConfig > TestTetrahedronMesh; + TestTetrahedronMesh mesh; + tnlMeshBuilder< TestTetrahedronMesh > meshBuilder; + meshBuilder.setPointsCount( 13 ); + meshBuilder.setPoint( 0, PointType( 0.000000, 0.000000, 0.000000 ) ); + meshBuilder.setPoint( 1, PointType( 0.000000, 0.000000, 8.000000 ) ); + meshBuilder.setPoint( 2, PointType( 0.000000, 8.000000, 0.000000 ) ); + meshBuilder.setPoint( 3, PointType( 15.000000, 0.000000, 0.000000 ) ); + meshBuilder.setPoint( 4, PointType( 0.000000, 8.000000, 8.000000 ) ); + meshBuilder.setPoint( 5, PointType( 15.000000, 0.000000, 8.000000 ) ); + meshBuilder.setPoint( 6, PointType( 15.000000, 8.000000, 0.000000 ) ); + meshBuilder.setPoint( 7, PointType( 15.000000, 8.000000, 8.000000 ) ); + meshBuilder.setPoint( 8, PointType( 7.470740, 8.000000, 8.000000 ) ); + meshBuilder.setPoint( 9, PointType( 7.470740, 0.000000, 8.000000 ) ); + meshBuilder.setPoint( 10, PointType( 7.504125, 8.000000, 0.000000 ) ); + meshBuilder.setPoint( 11, PointType( 7.212720, 0.000000, 0.000000 ) ); + meshBuilder.setPoint( 12, PointType( 11.184629, 3.987667, 3.985835 ) ); /**** * Setup the following tetrahedrons: @@ -249,130 +206,128 @@ class tnlMeshTester : public CppUnit :: TestCase * 12 3 6 10 */ - mesh.setNumberOfEntities< 3 >( 18 ); - + meshBuilder.setCellsCount( 18 ); // 12 8 7 5 - mesh.getEntities< 3 >()[ 0 ].getVerticesIndices()[ 0 ] = 12; - mesh.getEntities< 3 >()[ 0 ].getVerticesIndices()[ 1 ] = 8; - mesh.getEntities< 3 >()[ 0 ].getVerticesIndices()[ 2 ] = 7; - mesh.getEntities< 3 >()[ 0 ].getVerticesIndices()[ 3 ] = 5; + meshBuilder.getCellSeed( 0 ).setCornerId( 0, 12 ); + meshBuilder.getCellSeed( 0 ).setCornerId( 1, 8 ); + meshBuilder.getCellSeed( 0 ).setCornerId( 2, 7 ); + meshBuilder.getCellSeed( 0 ).setCornerId( 3, 5 ); // 12 7 8 10 - mesh.getEntities< 3 >()[ 1 ].getVerticesIndices()[ 0 ] = 12; - mesh.getEntities< 3 >()[ 1 ].getVerticesIndices()[ 1 ] = 7; - mesh.getEntities< 3 >()[ 1 ].getVerticesIndices()[ 2 ] = 8; - mesh.getEntities< 3 >()[ 1 ].getVerticesIndices()[ 3 ] = 10; + meshBuilder.getCellSeed( 1 ).setCornerId( 0, 12 ); + meshBuilder.getCellSeed( 1 ).setCornerId( 1, 7 ); + meshBuilder.getCellSeed( 1 ).setCornerId( 2, 8 ); + meshBuilder.getCellSeed( 1 ).setCornerId( 3, 10 ); // 12 11 8 9 - mesh.getEntities< 3 >()[ 2 ].getVerticesIndices()[ 0 ] = 12; - mesh.getEntities< 3 >()[ 2 ].getVerticesIndices()[ 1 ] = 11; - mesh.getEntities< 3 >()[ 2 ].getVerticesIndices()[ 2 ] = 8; - mesh.getEntities< 3 >()[ 2 ].getVerticesIndices()[ 3 ] = 9; + meshBuilder.getCellSeed( 2 ).setCornerId( 0, 12 ); + meshBuilder.getCellSeed( 2 ).setCornerId( 1, 11 ); + meshBuilder.getCellSeed( 2 ).setCornerId( 2, 8 ); + meshBuilder.getCellSeed( 2 ).setCornerId( 3, 9 ); // 10 11 2 8 - mesh.getEntities< 3 >()[ 3 ].getVerticesIndices()[ 0 ] = 10; - mesh.getEntities< 3 >()[ 3 ].getVerticesIndices()[ 1 ] = 11; - mesh.getEntities< 3 >()[ 3 ].getVerticesIndices()[ 2 ] = 2; - mesh.getEntities< 3 >()[ 3 ].getVerticesIndices()[ 3 ] = 8; + meshBuilder.getCellSeed( 3 ).setCornerId( 0, 10 ); + meshBuilder.getCellSeed( 3 ).setCornerId( 1, 11 ); + meshBuilder.getCellSeed( 3 ).setCornerId( 2, 2 ); + meshBuilder.getCellSeed( 3 ).setCornerId( 3, 8 ); // 12 7 6 5 - mesh.getEntities< 3 >()[ 4 ].getVerticesIndices()[ 0 ] = 12; - mesh.getEntities< 3 >()[ 4 ].getVerticesIndices()[ 1 ] = 7; - mesh.getEntities< 3 >()[ 4 ].getVerticesIndices()[ 2 ] = 6; - mesh.getEntities< 3 >()[ 4 ].getVerticesIndices()[ 3 ] = 5; + meshBuilder.getCellSeed( 4 ).setCornerId( 0, 12 ); + meshBuilder.getCellSeed( 4 ).setCornerId( 1, 7 ); + meshBuilder.getCellSeed( 4 ).setCornerId( 2, 6 ); + meshBuilder.getCellSeed( 4 ).setCornerId( 3, 5 ); // 9 12 5 8 - mesh.getEntities< 3 >()[ 5 ].getVerticesIndices()[ 0 ] = 9; - mesh.getEntities< 3 >()[ 5 ].getVerticesIndices()[ 1 ] = 12; - mesh.getEntities< 3 >()[ 5 ].getVerticesIndices()[ 2 ] = 5; - mesh.getEntities< 3 >()[ 5 ].getVerticesIndices()[ 3 ] = 8; + meshBuilder.getCellSeed( 5 ).setCornerId( 0, 9 ); + meshBuilder.getCellSeed( 5 ).setCornerId( 1, 12 ); + meshBuilder.getCellSeed( 5 ).setCornerId( 2, 5 ); + meshBuilder.getCellSeed( 5 ).setCornerId( 3, 8 ); // 12 11 9 3 - mesh.getEntities< 3 >()[ 6 ].getVerticesIndices()[ 0 ] = 12; - mesh.getEntities< 3 >()[ 6 ].getVerticesIndices()[ 1 ] = 11; - mesh.getEntities< 3 >()[ 6 ].getVerticesIndices()[ 2 ] = 9; - mesh.getEntities< 3 >()[ 6 ].getVerticesIndices()[ 3 ] = 3; + meshBuilder.getCellSeed( 6 ).setCornerId( 0, 12 ); + meshBuilder.getCellSeed( 6 ).setCornerId( 1, 11 ); + meshBuilder.getCellSeed( 6 ).setCornerId( 2, 9 ); + meshBuilder.getCellSeed( 6 ).setCornerId( 3, 3 ); // 9 4 11 8 - mesh.getEntities< 3 >()[ 7 ].getVerticesIndices()[ 0 ] = 9; - mesh.getEntities< 3 >()[ 7 ].getVerticesIndices()[ 1 ] = 4; - mesh.getEntities< 3 >()[ 7 ].getVerticesIndices()[ 2 ] = 11; - mesh.getEntities< 3 >()[ 7 ].getVerticesIndices()[ 3 ] = 8; + meshBuilder.getCellSeed( 7 ).setCornerId( 0, 9 ); + meshBuilder.getCellSeed( 7 ).setCornerId( 1, 4 ); + meshBuilder.getCellSeed( 7 ).setCornerId( 2, 11 ); + meshBuilder.getCellSeed( 7 ).setCornerId( 3, 8 ); // 12 9 5 3 - mesh.getEntities< 3 >()[ 8 ].getVerticesIndices()[ 0 ] = 12; - mesh.getEntities< 3 >()[ 8 ].getVerticesIndices()[ 1 ] = 9; - mesh.getEntities< 3 >()[ 8 ].getVerticesIndices()[ 2 ] = 5; - mesh.getEntities< 3 >()[ 8 ].getVerticesIndices()[ 3 ] = 3; + meshBuilder.getCellSeed( 8 ).setCornerId( 0, 12 ); + meshBuilder.getCellSeed( 8 ).setCornerId( 1, 9 ); + meshBuilder.getCellSeed( 8 ).setCornerId( 2, 5 ); + meshBuilder.getCellSeed( 8 ).setCornerId( 3, 3 ); // 1 2 0 11 - mesh.getEntities< 3 >()[ 9 ].getVerticesIndices()[ 0 ] = 1; - mesh.getEntities< 3 >()[ 9 ].getVerticesIndices()[ 1 ] = 2; - mesh.getEntities< 3 >()[ 9 ].getVerticesIndices()[ 2 ] = 0; - mesh.getEntities< 3 >()[ 9 ].getVerticesIndices()[ 3 ] = 11; + meshBuilder.getCellSeed( 9 ).setCornerId( 0, 1 ); + meshBuilder.getCellSeed( 9 ).setCornerId( 1, 2 ); + meshBuilder.getCellSeed( 9 ).setCornerId( 2, 0 ); + meshBuilder.getCellSeed( 9 ).setCornerId( 3, 11 ); // 8 11 2 4 - mesh.getEntities< 3 >()[ 10 ].getVerticesIndices()[ 0 ] = 8; - mesh.getEntities< 3 >()[ 10 ].getVerticesIndices()[ 1 ] = 11; - mesh.getEntities< 3 >()[ 10 ].getVerticesIndices()[ 2 ] = 2; - mesh.getEntities< 3 >()[ 10 ].getVerticesIndices()[ 3 ] = 4; + meshBuilder.getCellSeed( 10 ).setCornerId( 0, 8 ); + meshBuilder.getCellSeed( 10 ).setCornerId( 1, 11 ); + meshBuilder.getCellSeed( 10 ).setCornerId( 2, 2 ); + meshBuilder.getCellSeed( 10 ).setCornerId( 3, 4 ); // 1 2 11 4 - mesh.getEntities< 3 >()[ 11 ].getVerticesIndices()[ 0 ] = 1; - mesh.getEntities< 3 >()[ 11 ].getVerticesIndices()[ 1 ] = 2; - mesh.getEntities< 3 >()[ 11 ].getVerticesIndices()[ 2 ] = 11; - mesh.getEntities< 3 >()[ 11 ].getVerticesIndices()[ 3 ] = 4; + meshBuilder.getCellSeed( 11 ).setCornerId( 0, 1 ); + meshBuilder.getCellSeed( 11 ).setCornerId( 1, 2 ); + meshBuilder.getCellSeed( 11 ).setCornerId( 2, 11 ); + meshBuilder.getCellSeed( 11 ).setCornerId( 3, 4 ); // 9 4 1 11 - mesh.getEntities< 3 >()[ 12 ].getVerticesIndices()[ 0 ] = 9; - mesh.getEntities< 3 >()[ 12 ].getVerticesIndices()[ 1 ] = 4; - mesh.getEntities< 3 >()[ 12 ].getVerticesIndices()[ 2 ] = 1; - mesh.getEntities< 3 >()[ 12 ].getVerticesIndices()[ 3 ] = 11; + meshBuilder.getCellSeed( 12 ).setCornerId( 0, 9 ); + meshBuilder.getCellSeed( 12 ).setCornerId( 1, 4 ); + meshBuilder.getCellSeed( 12 ).setCornerId( 2, 1 ); + meshBuilder.getCellSeed( 12 ).setCornerId( 3, 11 ); // 10 11 8 12 - mesh.getEntities< 3 >()[ 13 ].getVerticesIndices()[ 0 ] = 10; - mesh.getEntities< 3 >()[ 13 ].getVerticesIndices()[ 1 ] = 11; - mesh.getEntities< 3 >()[ 13 ].getVerticesIndices()[ 2 ] = 8; - mesh.getEntities< 3 >()[ 13 ].getVerticesIndices()[ 3 ] = 12; + meshBuilder.getCellSeed( 13 ).setCornerId( 0, 10 ); + meshBuilder.getCellSeed( 13 ).setCornerId( 1, 11 ); + meshBuilder.getCellSeed( 13 ).setCornerId( 2, 8 ); + meshBuilder.getCellSeed( 13 ).setCornerId( 3, 12 ); // 12 6 7 10 - mesh.getEntities< 3 >()[ 14 ].getVerticesIndices()[ 0 ] = 12; - mesh.getEntities< 3 >()[ 14 ].getVerticesIndices()[ 1 ] = 6; - mesh.getEntities< 3 >()[ 14 ].getVerticesIndices()[ 2 ] = 7; - mesh.getEntities< 3 >()[ 14 ].getVerticesIndices()[ 3 ] = 10; + meshBuilder.getCellSeed( 14 ).setCornerId( 0, 12 ); + meshBuilder.getCellSeed( 14 ).setCornerId( 1, 6 ); + meshBuilder.getCellSeed( 14 ).setCornerId( 2, 7 ); + meshBuilder.getCellSeed( 14 ).setCornerId( 3, 10 ); // 10 11 12 3 - mesh.getEntities< 3 >()[ 15 ].getVerticesIndices()[ 0 ] = 10; - mesh.getEntities< 3 >()[ 15 ].getVerticesIndices()[ 1 ] = 11; - mesh.getEntities< 3 >()[ 15 ].getVerticesIndices()[ 2 ] = 12; - mesh.getEntities< 3 >()[ 15 ].getVerticesIndices()[ 3 ] = 3; + meshBuilder.getCellSeed( 15 ).setCornerId( 0, 10 ); + meshBuilder.getCellSeed( 15 ).setCornerId( 1, 11 ); + meshBuilder.getCellSeed( 15 ).setCornerId( 2, 12 ); + meshBuilder.getCellSeed( 15 ).setCornerId( 3, 3 ); // 12 6 3 5 - mesh.getEntities< 3 >()[ 16 ].getVerticesIndices()[ 0 ] = 12; - mesh.getEntities< 3 >()[ 16 ].getVerticesIndices()[ 1 ] = 6; - mesh.getEntities< 3 >()[ 16 ].getVerticesIndices()[ 2 ] = 3; - mesh.getEntities< 3 >()[ 16 ].getVerticesIndices()[ 3 ] = 5; + meshBuilder.getCellSeed( 16 ).setCornerId( 0, 12 ); + meshBuilder.getCellSeed( 16 ).setCornerId( 1, 6 ); + meshBuilder.getCellSeed( 16 ).setCornerId( 2, 3 ); + meshBuilder.getCellSeed( 16 ).setCornerId( 3, 5 ); // 12 3 6 10 - mesh.getEntities< 3 >()[ 17 ].getVerticesIndices()[ 0 ] = 12; - mesh.getEntities< 3 >()[ 17 ].getVerticesIndices()[ 1 ] = 3; - mesh.getEntities< 3 >()[ 17 ].getVerticesIndices()[ 2 ] = 6; - mesh.getEntities< 3 >()[ 17 ].getVerticesIndices()[ 3 ] = 10; - - tnlMeshInitializer< TestTetrahedronMeshConfig > meshInitializer; - meshInitializer.initMesh( mesh ); + meshBuilder.getCellSeed( 17 ).setCornerId( 0, 12 ); + meshBuilder.getCellSeed( 17 ).setCornerId( 1, 3 ); + meshBuilder.getCellSeed( 17 ).setCornerId( 2, 6 ); + meshBuilder.getCellSeed( 17 ).setCornerId( 3, 10 ); + + meshBuilder.build( mesh ); - CPPUNIT_ASSERT( mesh.save( "mesh.tnl" ) ); + /*CPPUNIT_ASSERT( mesh.save( "mesh.tnl" ) ); CPPUNIT_ASSERT( mesh2.load( "mesh.tnl" ) ); - CPPUNIT_ASSERT( mesh == mesh2 ); + CPPUNIT_ASSERT( mesh == mesh2 );*/ //mesh.print( cout ); } void regularMeshOfTrianglesTest() { - typedef tnlMeshEntity< TestTriangleMeshConfig, tnlMeshTriangleTag > TriangleMeshEntityType; - typedef tnlMeshEntity< TestTriangleMeshConfig, tnlMeshEdgeTag > EdgeMeshEntityType; - typedef tnlMeshEntity< TestTriangleMeshConfig, tnlMeshVertexTag > VertexMeshEntityType; + typedef tnlMeshEntity< TestTriangleMeshConfig, tnlMeshTriangleTopology > TriangleMeshEntityType; + typedef tnlMeshEntity< TestTriangleMeshConfig, tnlMeshEdgeTopology > EdgeMeshEntityType; + typedef tnlMeshEntity< TestTriangleMeshConfig, tnlMeshVertexTopology > VertexMeshEntityType; typedef typename VertexMeshEntityType::PointType PointType; const IndexType xSize( 5 ), ySize( 5 ); @@ -382,16 +337,18 @@ class tnlMeshTester : public CppUnit :: TestCase const IndexType numberOfCells = 2*xSize * ySize; const IndexType numberOfVertices = ( xSize + 1 ) * ( ySize + 1 ); - tnlMesh< TestTriangleMeshConfig > mesh, mesh2; - mesh.setNumberOfCells( numberOfCells ); - mesh.setNumberOfVertices( numberOfVertices ); + typedef tnlMesh< TestTriangleMeshConfig > TestTriangleMesh; + tnlMesh< TestTriangleMeshConfig > mesh; + tnlMeshBuilder< TestTriangleMesh > meshBuilder; + meshBuilder.setPointsCount( numberOfVertices ); + meshBuilder.setCellsCount( numberOfCells ); /**** * Setup vertices */ for( IndexType i = 0; i <= xSize; i++ ) for( IndexType j = 0; j <= ySize; j++ ) - mesh.setVertex( j*xSize + i, PointType( i * hx, j * hy ) ); + meshBuilder.setPoint( j*xSize + i, PointType( i * hx, j * hy ) ); /**** * Setup cells @@ -404,27 +361,27 @@ class tnlMeshTester : public CppUnit :: TestCase IndexType vertex1 = j * xSize + i + 1; IndexType vertex2 = ( j + 1 ) * xSize + i; IndexType vertex3 = ( j + 1 ) * xSize + i + 1; - mesh.getEntities< 2 >()[ cellIdx ].getVerticesIndices()[ 0 ] = vertex0; - mesh.getEntities< 2 >()[ cellIdx ].getVerticesIndices()[ 1 ] = vertex1; - mesh.getEntities< 2 >()[ cellIdx++ ].getVerticesIndices()[ 2 ] = vertex2; - mesh.getEntities< 2 >()[ cellIdx ].getVerticesIndices()[ 0 ] = vertex1; - mesh.getEntities< 2 >()[ cellIdx ].getVerticesIndices()[ 1 ] = vertex2; - mesh.getEntities< 2 >()[ cellIdx++ ].getVerticesIndices()[ 2 ] = vertex3; + meshBuilder.getCellSeed( cellIdx ).setCornerId( 0, vertex0 ); + meshBuilder.getCellSeed( cellIdx ).setCornerId( 1, vertex1 ); + meshBuilder.getCellSeed( cellIdx++ ).setCornerId( 2, vertex2 ); + meshBuilder.getCellSeed( cellIdx ).setCornerId( 0, vertex1 ); + meshBuilder.getCellSeed( cellIdx ).setCornerId( 1, vertex2 ); + meshBuilder.getCellSeed( cellIdx++ ).setCornerId( 2, vertex3 ); } - tnlMeshInitializer< TestTriangleMeshConfig > meshInitializer; - meshInitializer.initMesh( mesh ); - CPPUNIT_ASSERT( mesh.save( "mesh-test.tnl" ) ); - CPPUNIT_ASSERT( mesh2.load( "mesh-test.tnl" ) ); - CPPUNIT_ASSERT( mesh == mesh2 ); + meshBuilder.build( mesh ); + //CPPUNIT_ASSERT( mesh.save( "mesh-test.tnl" ) ); + //CPPUNIT_ASSERT( mesh2.load( "mesh-test.tnl" ) ); + //CPPUNIT_ASSERT( mesh == mesh2 ); //mesh.print( cout ); } void regularMeshOfQuadrilateralsTest() { - typedef tnlMeshEntity< TestQuadrilateralMeshConfig, tnlMeshQuadrilateralTag > QuadrilateralMeshEntityType; - typedef tnlMeshEntity< TestQuadrilateralMeshConfig, tnlMeshEdgeTag > EdgeMeshEntityType; - typedef tnlMeshEntity< TestQuadrilateralMeshConfig, tnlMeshVertexTag > VertexMeshEntityType; +#ifdef UNDEF + typedef tnlMeshEntity< TestQuadrilateralMeshConfig, tnlMeshQuadrilateralTopology > QuadrilateralMeshEntityType; + typedef tnlMeshEntity< TestQuadrilateralMeshConfig, tnlMeshEdgeTopology > EdgeMeshEntityType; + typedef tnlMeshEntity< TestQuadrilateralMeshConfig, tnlMeshVertexTopology > VertexMeshEntityType; typedef typename VertexMeshEntityType::PointType PointType; const IndexType xSize( 5 ), ySize( 5 ); @@ -463,18 +420,20 @@ class tnlMeshTester : public CppUnit :: TestCase } tnlMeshInitializer< TestQuadrilateralMeshConfig > meshInitializer; - meshInitializer.initMesh( mesh ); + //meshInitializer.initMesh( mesh ); CPPUNIT_ASSERT( mesh.save( "mesh-test.tnl" ) ); CPPUNIT_ASSERT( mesh2.load( "mesh-test.tnl" ) ); CPPUNIT_ASSERT( mesh == mesh2 ); //mesh.print( cout ); +#endif } void regularMeshOfHexahedronsTest() { - typedef tnlMeshEntity< TestHexahedronMeshConfig, tnlMeshHexahedronTag > HexahedronMeshEntityType; - typedef tnlMeshEntity< TestHexahedronMeshConfig, tnlMeshEdgeTag > EdgeMeshEntityType; - typedef tnlMeshEntity< TestHexahedronMeshConfig, tnlMeshVertexTag > VertexMeshEntityType; +#ifdef UNDEF + typedef tnlMeshEntity< TestHexahedronMeshConfig, tnlMeshHexahedronTopology > HexahedronMeshEntityType; + typedef tnlMeshEntity< TestHexahedronMeshConfig, tnlMeshEdgeTopology > EdgeMeshEntityType; + typedef tnlMeshEntity< TestHexahedronMeshConfig, tnlMeshVertexTopology > VertexMeshEntityType; typedef typename VertexMeshEntityType::PointType PointType; const IndexType xSize( 5 ), ySize( 5 ), zSize( 5 ); @@ -525,11 +484,12 @@ class tnlMeshTester : public CppUnit :: TestCase } tnlMeshInitializer< TestHexahedronMeshConfig > meshInitializer; - meshInitializer.initMesh( mesh ); + //meshInitializer.initMesh( mesh ); /*CPPUNIT_ASSERT( mesh.save( "mesh-test.tnl" ) ); CPPUNIT_ASSERT( mesh2.load( "mesh-test.tnl" ) ); CPPUNIT_ASSERT( mesh == mesh2 );*/ //mesh.print( cout ); +#endif } diff --git a/tests/unit-tests/tnlApproximationError_impl.h b/tests/unit-tests/tnlApproximationError_impl.h index e82e954eeb22da04ddcc7f00906c32c869e071af..eff97c93b396b704636a99cc03b92e647fecc224 100644 --- a/tests/unit-tests/tnlApproximationError_impl.h +++ b/tests/unit-tests/tnlApproximationError_impl.h @@ -24,6 +24,7 @@ #include <matrices/tnlCSRMatrix.h> #include <matrices/tnlMatrixSetter.h> #include <solvers/pde/tnlLinearSystemAssembler.h> +#include <solvers/pde/tnlNoTimeDiscretisation.h> #include <operators/tnlExactOperatorEvaluator.h> template< typename Mesh, @@ -122,7 +123,7 @@ getError( const Mesh& mesh, if( ! matrix.setCompressedRowsLengths( rowLengths ) ) return; - tnlLinearSystemAssembler< Mesh, Vector, ApproximateOperator, BoundaryConditionsType, ConstantFunctionType, MatrixType > systemAssembler; + tnlLinearSystemAssembler< Mesh, Vector, ApproximateOperator, BoundaryConditionsType, ConstantFunctionType, tnlNoTimeDiscretisation, MatrixType > systemAssembler; systemAssembler.template assembly< Mesh::Dimensions >( 0.0, // time 1.0, // tau mesh, diff --git a/tools/share/.mgrid-view.cfg.desc.swp b/tools/share/.mgrid-view.cfg.desc.swp deleted file mode 100644 index 1e92d50bb94c0c0389ccabfd84c4cca5de9d7338..0000000000000000000000000000000000000000 Binary files a/tools/share/.mgrid-view.cfg.desc.swp and /dev/null differ diff --git a/tools/src/.compare-objects.h.swp b/tools/src/.compare-objects.h.swp deleted file mode 100644 index e45564de31a4b2fd3beb3dad2e90683e7e6a4c85..0000000000000000000000000000000000000000 Binary files a/tools/src/.compare-objects.h.swp and /dev/null differ diff --git a/tools/src/tnl-grid-setup.h b/tools/src/tnl-grid-setup.h index fdbc5d784068db8cbe12e2801e859fb85df3d95a..bd4521d2bea09ca094406d5adb4b6b1472658a09 100644 --- a/tools/src/tnl-grid-setup.h +++ b/tools/src/tnl-grid-setup.h @@ -41,7 +41,6 @@ bool setupGrid( const tnlParameterContainer& parameters ) typedef typename GridType::VertexType VertexType; typedef typename GridType::CoordinatesType CoordinatesType; GridType grid; - grid.setName( gridName ); grid.setDomain( VertexType( originX ), VertexType( proportionsX ) ); grid.setDimensions( CoordinatesType( sizeX ) ); if( ! grid.save( outputFile ) ) @@ -65,7 +64,6 @@ bool setupGrid( const tnlParameterContainer& parameters ) typedef typename GridType::VertexType VertexType; typedef typename GridType::CoordinatesType CoordinatesType; GridType grid; - grid.setName( gridName ); grid.setDomain( VertexType( originX, originY ), VertexType( proportionsX, proportionsY ) ); grid.setDimensions( CoordinatesType( sizeX, sizeY ) ); if( ! grid.save( outputFile ) ) @@ -92,7 +90,6 @@ bool setupGrid( const tnlParameterContainer& parameters ) typedef typename GridType::VertexType VertexType; typedef typename GridType::CoordinatesType CoordinatesType; GridType grid; - grid.setName( gridName ); grid.setDomain( VertexType( originX, originY, originZ ), VertexType( proportionsX, proportionsY, proportionsZ ) ); grid.setDimensions( CoordinatesType( sizeX, sizeY, sizeZ ) ); if( ! grid.save( outputFile ) ) diff --git a/tools/src/tnl-mesh-convert.cpp b/tools/src/tnl-mesh-convert.cpp index b3a233093840af0209253dd9a790de75021c4cb2..e13a0a6fb2957d639276c8f311a33ed234b81c8a 100644 --- a/tools/src/tnl-mesh-convert.cpp +++ b/tools/src/tnl-mesh-convert.cpp @@ -21,16 +21,13 @@ #include "tnlConfig.h" #include <config/tnlParameterContainer.h> -const char configFile[] = TNL_CONFIG_DIRECTORY "tnl-mesh-convert.cfg.desc"; - void configSetup( tnlConfigDescription& config ) { config.addDelimiter ( "General settings:" ); - config.addEntry< tnlString >( "output-file", "Output binary file in TNL format.", "mesh.tnl" ); - config.addEntry< int >( "verbose", "Set the verbosity of the program.", 1 ); - - config.addDelimiter ( "The mesh description:" ); - config.addEntry< tnlString >( "input-mesh-file", "Input file with the mesh." ); + config.addRequiredEntry< tnlString >( "input-file", "Input file with the mesh." ); + config.addEntry< tnlString >( "output-file", "Output mesh file in TNL or VTK format.", "mesh.tnl" ); + //config.addEntry< tnlString >( "output-format", "Output mesh file format.", "vtk" ); + config.addEntry< int >( "verbose", "Set the verbosity of the program.", 1 ); config.addEntry< tnlString >( "mesh-name", "The mesh name.", "tnl-mesh" ); } diff --git a/tools/src/tnl-mesh-convert.h b/tools/src/tnl-mesh-convert.h index 45df6bda6522358378e788e6c4202071345e1614..4578d7e3e45b0be1c80acdba49a7e8e7759837c9 100644 --- a/tools/src/tnl-mesh-convert.h +++ b/tools/src/tnl-mesh-convert.h @@ -20,64 +20,105 @@ #include <config/tnlParameterContainer.h> #include <mesh/tnlMeshReaderNetgen.h> +#include <mesh/tnlMeshWriterVTKLegacy.h> #include <mesh/config/tnlMeshConfigBase.h> -#include <mesh/topologies/tnlMeshTriangleTag.h> +#include <mesh/topologies/tnlMeshTriangleTopology.h> +#include <mesh/topologies/tnlMeshTetrahedronTopology.h> #include <mesh/tnlMesh.h> -#include <mesh/tnlMeshInitializer.h> +#include <mesh/initializer/tnlMeshInitializer.h> +#include <mesh/tnlMeshIntegrityChecker.h> #include <core/mfilename.h> -template< int Dimensions > -bool readMeshWithDimensions( const tnlParameterContainer& parameters ) +template< typename MeshReader, + typename MeshType > +bool convertMesh( const tnlParameterContainer& parameters ) { - const tnlString& inputFileName = parameters.getParameter< tnlString >( "input-mesh-file" ); - const tnlString fileExt = getFileExtension( inputFileName ); + const tnlString& inputFileName = parameters.getParameter< tnlString >( "input-file" ); + const tnlString& outputFileName = parameters.getParameter< tnlString >( "output-file" ); + const tnlString outputFileExt = getFileExtension( outputFileName ); - if( Dimensions == 2 ) - { - struct MeshConfig : public tnlMeshConfigBase< 2 > + MeshType mesh; + if( ! MeshReader::readMesh( inputFileName, mesh, true ) ) + return false; + /*tnlMeshInitializer< typename MeshType::Config > meshInitializer; + meshInitializer.setVerbose( true ); + if( ! meshInitializer.initMesh( mesh ) ) + return false; + if( ! tnlMeshIntegrityChecker< MeshType >::checkMesh( mesh ) ) + return false;*/ + cout << mesh << endl; + cout << "Writing the mesh to a file " << outputFileName << "." << endl; + if( outputFileExt == "tnl" ) + { + if( ! mesh.save( outputFileName ) ) { - typedef tnlMeshTriangleTag CellTag; - }; - tnlMesh< MeshConfig > mesh; - if( fileExt == "ng" && - ! tnlMeshReaderNetgen::readMesh<>( inputFileName, mesh, true ) ) + cerr << "I am not able to write the mesh into the file " << outputFileName << "." << endl; return false; - //if( ! tnlMeshInitializer< MeshConfig >::initMesh( mesh ) ) - // return false; - tnlString outputFile; - if( parameters.getParameter< tnlString >( "output-file", outputFile ) ) - { - cout << "Writing the mesh to the file " << outputFile << "." << endl; - if( ! mesh.save( outputFile ) ) - { - cerr << "I am not able to safe the mesh into the file " << outputFile << "." << endl; - return false; - } } } - return true; + if( outputFileExt == "vtk" ) + { + if( ! tnlMeshWriterVTKLegacy::write( outputFileName, mesh, true ) ) + { + cerr << "I am not able to write the mesh into the file " << outputFileName << "." << endl; + return false; + } + return true; + } } -bool convertMesh( const tnlParameterContainer& parameters ) +bool readNetgenMesh( const tnlParameterContainer& parameters ) { - tnlString inputFileName; - if( parameters.getParameter( "input-mesh-file", inputFileName ) ) + const tnlString& inputFileName = parameters.getParameter< tnlString >( "input-file" ); + + tnlMeshReaderNetgen meshReader; + if( ! meshReader.detectMesh( inputFileName ) ) + return false; + + cout << "Reading mesh with " << meshReader.getDimensions() << " dimensions..." << endl; + + if( meshReader.getDimensions() == 2 ) { - const tnlString fileExt = getFileExtension( inputFileName ); - if( fileExt == "ng" ) + if( meshReader.getVerticesInCell() == 3 ) { - int dimensions; - if( ! tnlMeshReaderNetgen::detectDimensions( inputFileName, dimensions ) ) - return false; - if( dimensions == 2 && - ! readMeshWithDimensions< 2 >( parameters ) ) - return false; - if( dimensions == 3 && - ! readMeshWithDimensions< 3 >( parameters ) ) - return false; + typedef tnlMesh< tnlMeshConfigBase< tnlMeshTriangleTopology > > MeshType; + cout << "Mesh consisting of triangles was detected ... " << endl; + return convertMesh< tnlMeshReaderNetgen, MeshType >( parameters ); } + if( meshReader.getVerticesInCell() == 4 ) + { + typedef tnlMesh< tnlMeshConfigBase< tnlMeshQuadrilateralTopology > > MeshType; + cout << "Mesh consisting of quadrilaterals was detected ... " << endl; + return convertMesh< tnlMeshReaderNetgen, MeshType >( parameters ); + } } - return true; + if( meshReader.getDimensions() == 3 ) + { + if( meshReader.getVerticesInCell() == 4 ) + { + typedef tnlMesh< tnlMeshConfigBase< tnlMeshTetrahedronTopology > > MeshType; + cout << "Mesh consisting of tetrahedrons was detected ... " << endl; + return convertMesh< tnlMeshReaderNetgen, MeshType >( parameters ); + } + if( meshReader.getVerticesInCell() == 8 ) + { + typedef tnlMesh< tnlMeshConfigBase< tnlMeshHexahedronTopology > > MeshType; + cout << "Mesh consisting of hexahedrons was detected ... " << endl; + return convertMesh< tnlMeshReaderNetgen, MeshType >( parameters ); + } + } + cerr << "Wrong mesh dimensions were detected ( " << meshReader.getDimensions() << " )." << endl; + return false; } +bool convertMesh( const tnlParameterContainer& parameters ) +{ + tnlString inputFileName = parameters.getParameter< tnlString >( "input-file" ); + + const tnlString fileExt = getFileExtension( inputFileName ); + if( fileExt == "ng" ) + return readNetgenMesh( parameters ); +} + + #endif /* TNL_MESH_CONVERT_H_ */ diff --git a/tools/src/tnl-view.cpp b/tools/src/tnl-view.cpp index 45a285f2fd3b95dcb30c4d0db3ade151233b3e01..ef63be37367c2aebfc21313eb340a3e90ff56683 100644 --- a/tools/src/tnl-view.cpp +++ b/tools/src/tnl-view.cpp @@ -28,7 +28,7 @@ /*#include <mesh/tnlMesh.h> #include <mesh/tnlMeshWriterNetgen.h> #include <mesh/config/tnlMeshConfigBase.h> -#include <mesh/topologies/tnlMeshTriangleTag.h>*/ +#include <mesh/topologies/tnlMeshTriangleTopology.h>*/ void setupConfig( tnlConfigDescription& config ) { @@ -119,7 +119,7 @@ int main( int argc, char* argv[] ) /*tnlString meshFile = parameters. getParameter< tnlString >( "mesh" ); struct MeshConfig : public tnlMeshConfigBase< 2 > { - typedef tnlMeshTriangleTag CellTag; + typedef tnlMeshTriangleTopology CellType; }; tnlMesh< MeshConfig > mesh; if( ! mesh.load( meshFile ) ) diff --git a/tools/tnl-quickstart/tnl-quickstart.py b/tools/tnl-quickstart/tnl-quickstart.py index bed01df046ada91ed847b1d4294493f448da9c91..75683a95b07f05a089dd9bd45be7974749c2e681 100644 --- a/tools/tnl-quickstart/tnl-quickstart.py +++ b/tools/tnl-quickstart/tnl-quickstart.py @@ -57,8 +57,7 @@ def generateMain( problemName, problemBaseName, operatorName ): file = open( problemBaseName + ".h", "w" ) file.write( "#include <tnlConfig.h>\n" ) file.write( "#include <solvers/tnlSolver.h>\n" ) - file.write( "#include <solvers/tnlConfigTags.h>\n" ) - file.write( "#include <solvers/tnlFastBuildConfig.h>\n" ) + file.write( "#include <solvers/tnlBuildConfigTags.h>\n" ) file.write( "#include <operators/tnlAnalyticDirichletBoundaryConditions.h>\n" ) file.write( "#include <operators/tnlDirichletBoundaryConditions.h>\n" ) file.write( "#include <operators/tnlAnalyticNeumannBoundaryConditions.h>\n" ) @@ -66,9 +65,10 @@ def generateMain( problemName, problemBaseName, operatorName ): file.write( "#include <functors/tnlConstantFunction.h>\n" ) file.write( "#include \"" + problemBaseName + "Problem.h\"\n" ) file.write( "#include \"" + operatorName + ".h\"\n" ) - file.write( "#include \"" + problemBaseName + "Rhs.h\"\n" ) + file.write( "#include \"" + problemBaseName + "Rhs.h\"\n" ) + file.write( "#include \"" + problemBaseName + "BuildConfigTag.h\"\n" ) file.write( "\n" ) - file.write( "typedef tnlFastBuildConfig BuildConfig;\n" ) + file.write( "typedef " + problemBaseName + "BuildConfigTag BuildConfig;\n" ) file.write( "\n" ) file.write( "/****\n" ) file.write( " * Uncoment the following (and comment the previous line) for the complete build.\n" ) @@ -375,17 +375,17 @@ def generateProblem( problemName, problemBaseName ): file.write( " Matrix& matrix )\n" ) file.write( "{\n" ) file.write( " const IndexType dofs = this->getDofs( mesh );\n" ) - file.write( " typedef typename Matrix::RowLengthsVector RowLengthsVectorType;\n" ) - file.write( " RowLengthsVectorType rowLengths;\n" ) + file.write( " typedef typename Matrix::CompressedRowsLengthsVector CompressedRowsLengthsVectorType;\n" ) + file.write( " CompressedRowsLengthsVectorType rowLengths;\n" ) file.write( " if( ! rowLengths.setSize( dofs ) )\n" ) file.write( " return false;\n" ) - file.write( " tnlMatrixSetter< MeshType, DifferentialOperator, BoundaryCondition, RowLengthsVectorType > matrixSetter;\n" ) - file.write( " matrixSetter.template getRowLengths< Mesh::Dimensions >( mesh,\n" ) - file.write( " differentialOperator,\n" ) - file.write( " boundaryCondition,\n" ) - file.write( " rowLengths );\n" ) + file.write( " tnlMatrixSetter< MeshType, DifferentialOperator, BoundaryCondition, CompressedRowsLengthsVectorType > matrixSetter;\n" ) + file.write( " matrixSetter.template getCompressedRowsLengths< Mesh::Dimensions >( mesh,\n" ) + file.write( " differentialOperator,\n" ) + file.write( " boundaryCondition,\n" ) + file.write( " rowLengths );\n" ) file.write( " matrix.setDimensions( dofs, dofs );\n" ) - file.write( " if( ! matrix.setRowLengths( rowLengths ) )\n" ) + file.write( " if( ! matrix.setCompressedRowsLengths( rowLengths ) )\n" ) file.write( " return false;\n" ) file.write( " return true;\n" ) file.write( "}\n" ) @@ -731,6 +731,54 @@ def generateRhs( problemBaseName ): file.write( "#endif /* " + problemBaseName + "RHS_H_ */\n" ) file.close() +def generateBuildConfigTags( problemBaseName ): + file = open( problemBaseName + "BuildConfigTag.h", "w" ) + file.write( "#ifndef " + problemBaseName + "BUILDCONFIGTAG_H_\n" ) + file.write( "#define " + problemBaseName + "BUILDCONFIGTAG_H_\n" ) + file.write( "\n" ) + file.write( "#include <solvers/tnlBuildConfigTags.h>\n" ) + file.write( "\n" ) + file.write( "class " + problemBaseName + "BuildConfigTag{};\n" ) + file.write( "\n" ) + file.write( "/****\n" ) + file.write( " * Turn off support for float and long double.\n" ) + file.write( " */\n" ) + file.write( "template<> struct tnlConfigTagReal< " + problemBaseName + "BuildConfigTag, float > { enum { enabled = false }; };\n" ) + file.write( "template<> struct tnlConfigTagReal< " + problemBaseName + "BuildConfigTag, long double > { enum { enabled = false }; };\n" ) + file.write( "\n" ) + file.write( "/****\n" ) + file.write( " * Turn off support for short int and long int indexing.\n" ) + file.write( " */\n" ) + file.write( "template<> struct tnlConfigTagIndex< " + problemBaseName + "BuildConfigTag, short int >{ enum { enabled = false }; };\n" ) + file.write( "template<> struct tnlConfigTagIndex< " + problemBaseName + "BuildConfigTag, long int >{ enum { enabled = false }; };\n" ) + file.write( "\n" ) + file.write( "/****\n" ) + file.write( " * Use of tnlGrid is enabled for allowed dimensions and Real, Device and Index types.\n" ) + file.write( " */\n" ) + file.write( "\n" ) + file.write( "template< int Dimensions, typename Real, typename Device, typename Index >\n" ) + file.write( " struct tnlConfigTagMesh< " + problemBaseName + "BuildConfigTag, tnlGrid< Dimensions, Real, Device, Index > >\n" ) + file.write( " { enum { enabled = tnlConfigTagDimensions< " + problemBaseName + "BuildConfigTag, Dimensions >::enabled &&\n" ) + file.write( " tnlConfigTagReal< " + problemBaseName + "BuildConfigTag, Real >::enabled &&\n" ) + file.write( " tnlConfigTagDevice< " + problemBaseName + "BuildConfigTag, Device >::enabled &&\n" ) + file.write( " tnlConfigTagIndex< " + problemBaseName + "BuildConfigTag, Index >::enabled }; };\n" ) + file.write( "\n" ) + file.write( "/****\n" ) + file.write( " * Please, chose your preferred time discretisation here.\n" ) + file.write( " */\n" ) + file.write( "template<> struct tnlConfigTagTimeDiscretisation< " + problemBaseName + "BuildConfigTag, tnlExplicitTimeDiscretisationTag >{ enum { enabled = true }; };\n" ) + file.write( "template<> struct tnlConfigTagTimeDiscretisation< " + problemBaseName + "BuildConfigTag, tnlSemiImplicitTimeDiscretisationTag >{ enum { enabled = true }; };\n" ) + file.write( "template<> struct tnlConfigTagTimeDiscretisation< " + problemBaseName + "BuildConfigTag, tnlImplicitTimeDiscretisationTag >{ enum { enabled = false }; };\n" ) + file.write( "\n" ) + file.write( "/****\n" ) + file.write( " * Only the Runge-Kutta-Merson solver is enabled by default.\n" ) + file.write( " */\n" ) + file.write( "template<> struct tnlConfigTagExplicitSolver< " + problemBaseName + "BuildConfigTag, tnlExplicitEulerSolverTag >{ enum { enabled = false }; };\n" ) + file.write( "\n" ) + file.write( "#endif /* " + problemBaseName + "BUILDCONFIGTAG_H_ */\n" ) + file.close() + + def generateRunScript( problemBaseName ): file = open( "run-" + problemBaseName, "w" ) file.write( "#!/usr/bin/env bash\n" ) @@ -764,4 +812,5 @@ generateMain( problemName, problemBaseName, operatorName ) generateProblem( problemName, problemBaseName ) generateOperator( operatorName ) generateRhs( problemBaseName ) +generateBuildConfigTags( problemBaseName ) generateRunScript( problemBaseName ) \ No newline at end of file