]> SALOME platform Git repositories - modules/homard.git/commitdiff
Salome HOME
Adding test for tuleap 28930
authoryoann.audouin <yoann.audouin@edf.fr>
Fri, 12 Jan 2024 15:53:10 +0000 (16:53 +0100)
committeryoann.audouin <yoann.audouin@edf.fr>
Fri, 12 Jan 2024 15:53:10 +0000 (16:53 +0100)
src/tests/Test/CMakeLists.txt
src/tests/Test/CTestTestfileInstall.cmake
src/tests/Test/test_2d_1d_mesh.py [new file with mode: 0644]

index 08bb134970a8fff99b152ac5b961857f120cdf60..cb620a85c23e9e5a6f39122a010e5116a1f43c24 100644 (file)
@@ -32,6 +32,7 @@ SET(HOMARD_TEST_FILES
   tutorial_5.py
   tutorial_6.py
   test_util.py
+  test_2d_1d_mesh.py
 )
 
 INSTALL(FILES ${HOMARD_TEST_FILES}
@@ -39,4 +40,4 @@ INSTALL(FILES ${HOMARD_TEST_FILES}
 
 INSTALL(FILES CTestTestfileInstall.cmake
         DESTINATION ${SALOME_HOMARD_INSTALL_TEST}
-        RENAME CTestTestfile.cmake)
\ No newline at end of file
+        RENAME CTestTestfile.cmake)
index 0e1eafcb2e0598b1491c00b938d9002ac37732ac..1618d8de1f15db5f20dfa0ea87c23083e8733325 100644 (file)
@@ -36,6 +36,7 @@ tutorial_3
 tutorial_4
 tutorial_5
 tutorial_6
+test_2d_1d_mesh
 )
 
 FOREACH(tfile ${HOMARD_TEST_FILES})
diff --git a/src/tests/Test/test_2d_1d_mesh.py b/src/tests/Test/test_2d_1d_mesh.py
new file mode 100644 (file)
index 0000000..a1ac556
--- /dev/null
@@ -0,0 +1,88 @@
+#!/usr/bin/env python
+
+###
+### This file is generated automatically by SALOME v9.11.0 with dump python functionality
+###
+
+import sys
+import salome
+from os import path
+import shutil
+from MEDLoader import *
+
+salome.salome_init()
+import salome_notebook
+notebook = salome_notebook.NoteBook()
+
+import tempfile
+tmp_folder = tempfile.mkdtemp()
+print("Temporary folder", tmp_folder)
+
+# Create mesh
+mesh_name = "mesh"
+
+arr = DataArrayDouble(list(range(10)))
+mesh = MEDCouplingUMesh(mesh_name, 1)
+
+
+coords = [0.,0., 1.,0., 2.,0., 3.,0., 4.,0., 5.,0., 6.,0., 7.,0.]
+
+mesh.allocateCells(7)
+
+for i in range(7):
+    mesh.insertNextCell(NORM_SEG2, [i,i+1])
+
+mesh.finishInsertingCells()
+
+coordsArr=DataArrayDouble(coords, len(coords)//2, 2)
+
+mesh.setCoords(coordsArr)
+mesh.setMeshDimension(2)
+
+mesh_file = path.join(tmp_folder, "mesh_2d_1d.med")
+#mesh_file = "mesh_2d_1d.med"
+
+WriteMesh(mesh_file, mesh, True)
+print("mesh_file ", mesh_file)
+
+###
+### HOMARD component
+###
+
+import HOMARD
+homard = salome.lcc.FindOrLoadComponent('FactoryServer','HOMARD')
+homard.UpdateStudy()
+#
+# Creation of the hypotheses
+# ==========================
+# Creation of the hypothesis Hypo_1
+Hypo_1 = homard.CreateHypothesis("Hypo_1")
+Hypo_1.SetUnifRefinUnRef(1)
+#
+# Creation of the cases
+# =====================
+# Creation of the case Case_1
+Case_1 = homard.CreateCase("Case_1", mesh_name, mesh_file)
+Case_1.SetDirName(tmp_folder)
+Case_1.SetConfType(0)
+Case_1.SetExtType(0)
+#
+# Creation of the iterations
+# ==========================
+# Creation of the iteration Iter_1
+Iter_1 = Case_1.NextIteration("Iter_1")
+Iter_1.AssociateHypo("Hypo_1")
+Iter_1.SetMeshName(mesh_name)
+refined_mesh = path.join(tmp_folder, "maill.01.med")
+Iter_1.SetMeshFile(refined_mesh)
+print("refined_mesh ", refined_mesh)
+codret = Iter_1.Compute(1, 1)
+
+ref_mesh = ReadUMeshFromFile(refined_mesh)
+coords = ref_mesh.getCoords()
+y_coords = coords.getValues()[1::2]
+
+## Checking that Y values are still zeros
+assert all([val<1e-8 for val in y_coords]), y_coords
+
+shutil.rmtree(tmp_folder)