From 3faa05a9a324907c8f1df8512b6f6975a5404c71 Mon Sep 17 00:00:00 2001 From: "yoann.audouin" Date: Fri, 12 Jan 2024 16:53:10 +0100 Subject: [PATCH] Adding test for tuleap 28930 --- src/tests/Test/CMakeLists.txt | 3 +- src/tests/Test/CTestTestfileInstall.cmake | 1 + src/tests/Test/test_2d_1d_mesh.py | 88 +++++++++++++++++++++++ 3 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 src/tests/Test/test_2d_1d_mesh.py diff --git a/src/tests/Test/CMakeLists.txt b/src/tests/Test/CMakeLists.txt index 08bb1349..cb620a85 100644 --- a/src/tests/Test/CMakeLists.txt +++ b/src/tests/Test/CMakeLists.txt @@ -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) diff --git a/src/tests/Test/CTestTestfileInstall.cmake b/src/tests/Test/CTestTestfileInstall.cmake index 0e1eafcb..1618d8de 100644 --- a/src/tests/Test/CTestTestfileInstall.cmake +++ b/src/tests/Test/CTestTestfileInstall.cmake @@ -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 index 00000000..a1ac556b --- /dev/null +++ b/src/tests/Test/test_2d_1d_mesh.py @@ -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) -- 2.39.2