Commit 242a0e51 authored by Jakub Klinkovský's avatar Jakub Klinkovský
Browse files

More tests for meshes

parent d2468f3d
Loading
Loading
Loading
Loading
+36 −15
Original line number Diff line number Diff line
@@ -3,22 +3,24 @@ SET_TARGET_PROPERTIES( BoundaryTagsTest${mpiExt}${debugExt} PROPERTIES COMPILE_F
TARGET_LINK_LIBRARIES( BoundaryTagsTest${mpiExt}${debugExt} ${GTEST_BOTH_LIBRARIES}
                                                           tnl${mpiExt}${debugExt}-${tnlVersion} )

IF( BUILD_CUDA )
if( BUILD_CUDA )
   # FIXME: nvcc fails with "Invalid memory reference" error, so we assume that ${CXX} is clang
   #CUDA_ADD_EXECUTABLE( MeshTest${mpiExt}${debugExt} ${headers} MeshTest.cu OPTIONS "${CXX_TESTS_FLAGS}" )
   #TARGET_LINK_LIBRARIES( MeshTest${mpiExt}${debugExt} ${GTEST_BOTH_LIBRARIES}
   #                                                        tnl${mpiExt}${debugExt}-${tnlVersion} )
   ADD_EXECUTABLE( MeshTest${mpiExt}${debugExt} ${headers} MeshTest.cpp )
   SET_TARGET_PROPERTIES( MeshTest${mpiExt}${debugExt} PROPERTIES COMPILE_FLAGS "${CXX_TESTS_FLAGS} -DHAVE_CUDA -x cuda --cuda-path=${CUDA_TOOLKIT_ROOT_DIR} --cuda-gpu-arch=sm_21" )
   TARGET_LINK_LIBRARIES( MeshTest${mpiExt}${debugExt} ${GTEST_BOTH_LIBRARIES}
   SET_TARGET_PROPERTIES( MeshTest${mpiExt}${debugExt} PROPERTIES COMPILE_FLAGS
                          "${CXX_TESTS_FLAGS} -DHAVE_CUDA -x cuda --cuda-path=${CUDA_TOOLKIT_ROOT_DIR} --cuda-gpu-arch=sm_21" )
   TARGET_LINK_LIBRARIES( MeshTest${mpiExt}${debugExt}
                          ${GTEST_BOTH_LIBRARIES}
                          tnl${mpiExt}${debugExt}-${tnlVersion}
                          cudart dl rt "-L ${CUDA_TOOLKIT_ROOT_DIR}/lib64/" )
ELSE( BUILD_CUDA )
else( BUILD_CUDA )
   ADD_EXECUTABLE( MeshTest${mpiExt}${debugExt} ${headers} MeshTest.cpp )
   SET_TARGET_PROPERTIES( MeshTest${mpiExt}${debugExt} PROPERTIES COMPILE_FLAGS "${CXX_TESTS_FLAGS}" )
   TARGET_LINK_LIBRARIES( MeshTest${mpiExt}${debugExt} ${GTEST_BOTH_LIBRARIES}
                                                              tnl${mpiExt}${debugExt}-${tnlVersion} )
ENDIF( BUILD_CUDA )
endif( BUILD_CUDA )

ADD_EXECUTABLE( MeshEntityTest${mpiExt}${debugExt} ${headers} MeshEntityTest.cpp )
SET_TARGET_PROPERTIES( MeshEntityTest${mpiExt}${debugExt} PROPERTIES COMPILE_FLAGS "${CXX_TESTS_FLAGS}" )
@@ -54,15 +56,34 @@ if( VTK_FOUND )

   AddCompilerFlag( "-DHAVE_VTK " )

   if( BUILD_CUDA )
      # FIXME: nvcc fails with "Invalid memory reference" error, so we assume that ${CXX} is clang
      #CUDA_ADD_EXECUTABLE( MeshReaderTest${mpiExt}${debugExt} ${headers} MeshTest.cu OPTIONS "${CXX_TESTS_FLAGS}" )
      #TARGET_LINK_LIBRARIES( MeshReaderTest${mpiExt}${debugExt} ${GTEST_BOTH_LIBRARIES}
      #                                                        vtkCommonCore
      #                                                        vtkIOLegacy
      #                                                        tnl${mpiExt}${debugExt}-${tnlVersion} )
      ADD_EXECUTABLE( MeshReaderTest${mpiExt}${debugExt} ${headers} MeshReaderTest.cpp )
      SET_TARGET_PROPERTIES( MeshReaderTest${mpiExt}${debugExt} PROPERTIES COMPILE_FLAGS
                             "${CXX_TESTS_FLAGS} -DHAVE_CUDA -x cuda --cuda-path=${CUDA_TOOLKIT_ROOT_DIR} --cuda-gpu-arch=sm_21" )
      TARGET_LINK_LIBRARIES( MeshReaderTest${mpiExt}${debugExt}
                             ${GTEST_BOTH_LIBRARIES}
                             vtkCommonCore
                             vtkIOLegacy
                             tnl${mpiExt}${debugExt}-${tnlVersion}
                             cudart dl rt "-L ${CUDA_TOOLKIT_ROOT_DIR}/lib64/" )
   else( BUILD_CUDA )
      add_executable( MeshReaderTest${mpiExt}${debugExt} MeshReaderTest.cpp )

      #target_link_libraries( MeshReaderTest${mpiExt}${debugExt}
      #                       ${VTK_LIBRARIES}
      #                       tnl${debugExt}-${tnlVersion} )
      target_link_libraries( MeshReaderTest${mpiExt}${debugExt}
                             ${GTEST_BOTH_LIBRARIES}
                             vtkCommonCore
                             vtkIOLegacy
                             tnl${debugExt}-${tnlVersion} )
   endif( BUILD_CUDA )

else( VTK_FOUND )
   message( "Please install VTK to enable the MeshReaderTest." )
+6 −3
Original line number Diff line number Diff line
@@ -5,6 +5,8 @@

#include <TNL/Debugging/MemoryUsage.h>

#include "MeshTest.h"

using namespace TNL;
using namespace TNL::Meshes;

@@ -118,9 +120,6 @@ public:
      if( ! loadMesh( fileName, mesh ) )
         return false;

      // TODO: add tests
      std::cout << "NOTE: there is no real test, but the file was loaded fine..." << std::endl;

      std::cout << "vertices: " << mesh.template getEntitiesCount< 0 >() << std::endl;
      std::cout << "faces: " << mesh.template getEntitiesCount< MeshType::getMeshDimension() - 1 >() << std::endl;
      std::cout << "cells: " << mesh.template getEntitiesCount< MeshType::getMeshDimension() >() << std::endl;
@@ -128,6 +127,10 @@ public:
      std::cout << "post-init\t";
      Debugging::printMemoryUsage();

#ifdef HAVE_GTEST 
      std::cout << "Running basic I/O tests..." << std::endl;
      testFinishedMesh( mesh );
#endif
//      mesh.save( "mesh-test.tnl" );

      return true;
+0 −4
Original line number Diff line number Diff line
#ifdef HAVE_GTEST 
#include "gtest/gtest.h"
#endif

#include "MeshTest.h"

int main( int argc, char* argv[] )
+5 −0
Original line number Diff line number Diff line
#pragma once

#ifdef HAVE_GTEST
#include <gtest/gtest.h>

#include <sstream>

#include <TNL/Meshes/Mesh.h>
@@ -112,6 +114,8 @@ void testMeshOnCuda( const Mesh& mesh )
   ASSERT_TRUE( dmesh1.save( "mesh.tnl" ) );
   ASSERT_TRUE( mesh2.load( "mesh.tnl" ) );
   EXPECT_EQ( mesh2, mesh );

   EXPECT_EQ( std::remove( "mesh.tnl" ), 0 );
#endif
}

@@ -121,6 +125,7 @@ void testFinishedMesh( const Mesh& mesh )
   Mesh mesh2;
   ASSERT_TRUE( mesh.save( "mesh.tnl" ) );
   ASSERT_TRUE( mesh2.load( "mesh.tnl" ) );
   EXPECT_EQ( std::remove( "mesh.tnl" ), 0 );
   ASSERT_EQ( mesh, mesh2 );
   compareStringRepresentation( mesh, mesh2 );
   testCopyAssignment( mesh );