]> SALOME platform Git repositories - tools/paravisaddons_common.git/commitdiff
Salome HOME
[test] Adding test for ElectromagnetismStreamTraceur
authorYOANN AUDOUIN <B61570@dsp0919998.atlas.edf.fr>
Thu, 1 Apr 2021 08:03:03 +0000 (10:03 +0200)
committerYOANN AUDOUIN <B61570@dsp0919998.atlas.edf.fr>
Wed, 12 May 2021 12:05:06 +0000 (14:05 +0200)
src/ElectromagnetismStreamTraceur/CMakeLists.txt
src/ElectromagnetismStreamTraceur/Test/CMakeLists.txt [new file with mode: 0644]
src/ElectromagnetismStreamTraceur/Test/CTestTestfileInstall.cmake [new file with mode: 0644]
src/ElectromagnetismStreamTraceur/Test/test_maxwell_StreamLines_0.py [new file with mode: 0644]

index 9374ac2240001cb0412bc2fb27284a275efbf63f..4e289f6cae70f9ed45628be2a40ed16e190c16e7 100644 (file)
 
 cmake_minimum_required(VERSION 3.8)
 project(ElectromagnetismStreamTraceur)
-find_package(ParaView REQUIRED)
 
-include(GNUInstallDirs)
-set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}")
-set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}")
+IF(PARAVISADDONS_COMMON_BUILD_TESTS)
+  ADD_SUBDIRECTORY(Test)
+ENDIF(PARAVISADDONS_COMMON_BUILD_TESTS)
+
 set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}")
 
 set("_paraview_plugin_default_${CMAKE_PROJECT_NAME}" ON)
diff --git a/src/ElectromagnetismStreamTraceur/Test/CMakeLists.txt b/src/ElectromagnetismStreamTraceur/Test/CMakeLists.txt
new file mode 100644 (file)
index 0000000..d07e48e
--- /dev/null
@@ -0,0 +1,37 @@
+# Copyright (C) 2012-2020  CEA/DEN, EDF R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+# Author : Yoann Audouin (EDF)
+
+SET(test_maxwell_StreamLines_0_src
+  test_maxwell_StreamLines_0.py
+  )
+
+SALOME_GENERATE_TESTS_ENVIRONMENT(tests_env)
+
+ADD_TEST(ElectromagnetismStreamTraceur python test_maxwell_StreamLines_0.py)
+SET_TESTS_PROPERTIES(ElectromagnetismStreamTraceur PROPERTIES ENVIRONMENT "${tests_env}")
+
+# Application tests
+
+SET(TEST_INSTALL_DIRECTORY ${PARAVISADDONS_COMMON_INSTALL_TESTS}/ElectromagnetismStreamTraceur)
+INSTALL(FILES ${test_maxwell_StreamLines_0_src} DESTINATION ${TEST_INSTALL_DIRECTORY})
+
+INSTALL(FILES CTestTestfileInstall.cmake
+        DESTINATION ${TEST_INSTALL_DIRECTORY}
+        RENAME CTestTestfile.cmake)
diff --git a/src/ElectromagnetismStreamTraceur/Test/CTestTestfileInstall.cmake b/src/ElectromagnetismStreamTraceur/Test/CTestTestfileInstall.cmake
new file mode 100644 (file)
index 0000000..110a094
--- /dev/null
@@ -0,0 +1,31 @@
+# Copyright (C) 2015-2020  CEA/DEN, EDF R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+SET(TEST_NAMES
+  test_maxwell_StreamLines_0
+)
+
+FOREACH(tfile ${TEST_NAMES})
+  SET(TEST_NAME ${COMPONENT_NAME}_${tfile})
+  ADD_TEST(${TEST_NAME} python ${tfile}.py)
+  SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES
+    LABELS "${COMPONENT_NAME}"
+    TIMEOUT ${TIMEOUT}
+    )
+ENDFOREACH()
diff --git a/src/ElectromagnetismStreamTraceur/Test/test_maxwell_StreamLines_0.py b/src/ElectromagnetismStreamTraceur/Test/test_maxwell_StreamLines_0.py
new file mode 100644 (file)
index 0000000..ddf487d
--- /dev/null
@@ -0,0 +1,44 @@
+from paraview.simple import *
+from medcoupling import *
+#### disable automatic camera reset on 'Show'
+paraview.simple._DisableFirstRenderCameraReset()
+
+def MyAssert(clue):
+    if not clue:
+        raise RuntimeError("Assertion failed !")
+
+fname = "maxwell_streamline.med"
+
+arr = DataArrayDouble([0,1,2,3,4,5,6,7,8,9,10])
+m = MEDCouplingCMesh()
+m.setCoords(arr,arr,arr)
+m = m.buildUnstructured()
+
+m.changeSpaceDimension(3,0.)
+m.setName("mesh")
+f = MEDCouplingFieldDouble(ON_CELLS)
+f.setMesh(m)
+f.setName("field")
+arrf = DataArrayDouble(10*10*10,3)
+arrf[:,0] = 1 ; arrf[:,1] = 0 ; arrf[:,2] = 0
+f.setArray( arrf )
+f.getArray().setInfoOnComponents(["X","Y","Z"])
+f.checkConsistencyLight()
+f.write(fname)
+f2 = f.deepCopy()
+arrf2 = DataArrayDouble(10*10*10,3)
+arrf2[:,0] = 0 ; arrf2[:,1] = 1 ; arrf2[:,2] = 0
+f2.setArray( arrf2 )
+f2.setName("field2")
+WriteFieldUsingAlreadyWrittenMesh(fname,f2)
+
+testmed = MEDReader(FileName=fname)
+testmed.AllArrays = ['TS0/mesh/ComSup0/field@@][@@P0', 'TS0/mesh/ComSup0/field2@@][@@P0', 'TS0/mesh/ComSup0/mesh@@][@@P0']
+testmed.AllTimeSteps = ['0000']
+streamTraceur1 = LigneDeChamp(Input=testmed,SeedType='Point Cloud')
+streamTraceur1.SeedType.Radius = 1
+streamTraceur1.SeedType.Center = [ 7.23,7.26,3.42 ]
+streamTraceur1.Vectors = ['CELLS', "field"]
+streamTraceur1.UpdatePipeline()
+ds0 = servermanager.Fetch(streamTraceur1)
+MyAssert(ds0.GetNumberOfCells()==200)