]> SALOME platform Git repositories - modules/paravis.git/commitdiff
Salome HOME
Fix the filter ELGA field to surface (cell averaged) and add a test cbr/fix_elga_field_to_surface_averaged 8/head 9/head
authorChristophe Bourcier <christophe.bourcier@cea.fr>
Fri, 26 May 2023 12:48:43 +0000 (14:48 +0200)
committerChristophe Bourcier <christophe.bourcier@cea.fr>
Fri, 26 May 2023 12:48:43 +0000 (14:48 +0200)
CTestTestfileInstall.cmake
src/Plugins/GaussToCell/plugin/CMakeLists.txt
src/Plugins/GaussToCell/plugin/GaussToCellModule/vtkGaussToCell.cxx
src/Plugins/GaussToCell/plugin/Test/CMakeLists.txt [new file with mode: 0644]
src/Plugins/GaussToCell/plugin/Test/CTestTestfileInstall.cmake [new file with mode: 0644]
src/Plugins/GaussToCell/plugin/Test/PG_3D.med [new file with mode: 0644]
src/Plugins/GaussToCell/plugin/Test/test_GaussToCell.py [new file with mode: 0644]
src/Plugins/GaussToCell/plugin/Test/tests.set [new file with mode: 0644]
src/Plugins/GaussToCell/script/PG_3D.med [deleted file]

index 1bb7e38f0f533c37970e87f0851c94c3c9679c56..7c4715b206eb5b03d7ab3acb3481b2d371e84244 100644 (file)
@@ -20,3 +20,4 @@
 SUBDIRS(MEDReader)
 SUBDIRS(MEDWriter)
 SUBDIRS(VoroGauss)
+SUBDIRS(GaussToCell)
index 53ecae5d59a057b3ad31e211d2be36eee5074b02..7bc8eb3075ba1112257ed6d2d0551ae12d4a111c 100644 (file)
@@ -59,3 +59,7 @@ install(TARGETS GaussToCellPlugin
   LIBRARY DESTINATION lib/paraview
   ARCHIVE DESTINATION lib/paraview
   )
+
+IF(SALOME_BUILD_TESTS)
+  ADD_SUBDIRECTORY(Test)
+ENDIF(SALOME_BUILD_TESTS)
index 2232ad95c37076b7f73120fa36c5944a17f89824..115ee53663edf860c07a44d795db7e4538014ea9 100644 (file)
@@ -90,7 +90,7 @@ vtkStandardNewMacro(vtkGaussToCell)
 
 vtkInformationDoubleVectorKey *GetMEDReaderMetaDataIfAny()
 {
-  static const char ZE_KEY[]="vtkMEDReader::GAUSS_DATA";
+  static const char ZE_KEY[]="vtkFileSeriesGroupReader::GAUSS_DATA";
   MEDCoupling::GlobalDict *gd(MEDCoupling::GlobalDict::GetInstance());
   if(!gd->hasKey(ZE_KEY))
     return 0;
diff --git a/src/Plugins/GaussToCell/plugin/Test/CMakeLists.txt b/src/Plugins/GaussToCell/plugin/Test/CMakeLists.txt
new file mode 100644 (file)
index 0000000..3f5d70f
--- /dev/null
@@ -0,0 +1,38 @@
+# Copyright (C) 2012-2022  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)
+
+INCLUDE(tests.set)
+
+SALOME_GENERATE_TESTS_ENVIRONMENT(tests_env)
+
+FOREACH(tfile ${TEST_NAMES})
+ SET(TEST_NAME ${COMPONENT_NAME}_${tfile})
+ ADD_TEST(${TEST_NAME} python ${CMAKE_CURRENT_SOURCE_DIR}/${tfile}.py)
+ SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES ENVIRONMENT "${tests_env}")
+ENDFOREACH()
+
+# Application tests
+
+SET(TEST_INSTALL_DIRECTORY ${SALOME_INSTALL_SCRIPT_SCRIPTS}/test/GaussToCell)
+INSTALL(FILES ${all_src} tests.set DESTINATION ${TEST_INSTALL_DIRECTORY})
+
+INSTALL(FILES CTestTestfileInstall.cmake
+        DESTINATION ${TEST_INSTALL_DIRECTORY}
+        RENAME CTestTestfile.cmake)
diff --git a/src/Plugins/GaussToCell/plugin/Test/CTestTestfileInstall.cmake b/src/Plugins/GaussToCell/plugin/Test/CTestTestfileInstall.cmake
new file mode 100644 (file)
index 0000000..e3f1dad
--- /dev/null
@@ -0,0 +1,31 @@
+# Copyright (C) 2015-2022  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(COMPONENT_NAME PARAVIS)
+
+INCLUDE(tests.set)
+
+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/Plugins/GaussToCell/plugin/Test/PG_3D.med b/src/Plugins/GaussToCell/plugin/Test/PG_3D.med
new file mode 100644 (file)
index 0000000..9c7e51e
Binary files /dev/null and b/src/Plugins/GaussToCell/plugin/Test/PG_3D.med differ
diff --git a/src/Plugins/GaussToCell/plugin/Test/test_GaussToCell.py b/src/Plugins/GaussToCell/plugin/Test/test_GaussToCell.py
new file mode 100644 (file)
index 0000000..8436def
--- /dev/null
@@ -0,0 +1,79 @@
+# Copyright (C) 2017-2022  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
+
+from os import path, remove
+#### import the simple module from the paraview
+from paraview.simple import *
+#from pvsimple import *
+from vtk.util import numpy_support
+import numpy as np
+
+from medcoupling import *
+import MEDLoader as ml
+from MEDLoader import *
+
+import inspect
+data_dir = os.path.dirname(inspect.getfile(lambda: None))
+
+def MyAssert(clue):
+    if not clue:
+        raise RuntimeError("Assertion failed !")
+
+
+def test_fields(result, ref, field_name):
+    """
+    Test fields content of result from VoroGauss filter
+    """
+    ds0 = servermanager.Fetch(result)
+    block = ds0.GetBlock(0)
+
+    data = numpy_support.vtk_to_numpy(block.GetCellData().GetArray(field_name))
+
+    MyAssert(np.allclose(data, ref))
+
+
+###
+# Test of PG_3D.med
+###
+# create a new 'MED Reader'
+file_name = os.path.join(data_dir, "PG_3D.med")
+pG_3Dmed = MEDReader(registrationName='PG_3D.med', FileNames=file_name)
+pG_3Dmed.FieldsStatus = ['TS0/Extruded/ComSup0/Extruded@@][@@P0',
+                         'TS0/Extruded/ComSup0/MyFieldPG@@][@@GAUSS']
+print("Testing {}".format(file_name))
+pG_3Dmed.UpdatePipeline()
+
+fields = [('MyFieldPG_avg',
+           list(range(3, 445, 7))
+          ),
+          ('MyFieldPG_min',
+           list(range(0, 442, 7))
+          ),
+          ('MyFieldPG_max',
+           list(range(6, 448, 7))
+          )
+         ]
+
+# create a new 'ELGA field To Surface'
+eELGAfieldToSurfacecellaveraged1 = ELGAfieldToSurfacecellaveraged(registrationName='ELGAfieldToSurface2', Input=pG_3Dmed)
+eELGAfieldToSurfacecellaveraged1.UpdatePipeline()
+
+for field_name, ref in fields:
+    print(" ~> Field check for field {}".format(field_name))
+    test_fields(eELGAfieldToSurfacecellaveraged1, np.array(ref), field_name)
+
diff --git a/src/Plugins/GaussToCell/plugin/Test/tests.set b/src/Plugins/GaussToCell/plugin/Test/tests.set
new file mode 100644 (file)
index 0000000..5074925
--- /dev/null
@@ -0,0 +1,27 @@
+# Copyright (C) 2012-2022  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_GaussToCell
+  )
+
+SET(all_src
+  PG_3D.med
+  test_GaussToCell.py
+  )
diff --git a/src/Plugins/GaussToCell/script/PG_3D.med b/src/Plugins/GaussToCell/script/PG_3D.med
deleted file mode 100644 (file)
index 9c7e51e..0000000
Binary files a/src/Plugins/GaussToCell/script/PG_3D.med and /dev/null differ