]> SALOME platform Git repositories - tools/sat_salome.git/commitdiff
Salome HOME
spns #42665: MeshIO: GMSH and ANSYS
authorNabil Ghodbane <nabil.ghodbane@cea.fr>
Thu, 1 Aug 2024 14:26:43 +0000 (16:26 +0200)
committerNabil Ghodbane <nabil.ghodbane@cea.fr>
Fri, 23 Aug 2024 09:05:09 +0000 (11:05 +0200)
applications/SALOME-9.13.0-native.pyconf
applications/SALOME-master-native.pyconf
products/compil_scripts/meshio-4.3.13.sh
products/compil_scripts/meshio-5.3.4.sh
products/compil_scripts/meshio-5.3.5.sh
products/meshio.pyconf
products/patches/meshio-5.3.5.p01.gmsh_ansys.patch [new file with mode: 0644]

index 37d421238451e1d1f86f84447e888387a6d089f7..c7d2097c838992ee51013dfce4fad68c6ceec4d1 100644 (file)
@@ -237,7 +237,7 @@ __overwrite__ :
         'APPLICATION.products.cmake'            : 'native' # TTK requires cmake > 3.21
         'APPLICATION.products.cftime'           : 'native'
         'APPLICATION.products.h5py'             : 'native'
-        'APPLICATION.products.meshio'           : 'native'
+        'APPLICATION.products.meshio'           : {tag: '5.3.5' , base: 'no', section: 'version_5_3_5_no_pip'    }
         'APPLICATION.products.netCDF4'          : 'native'
         'APPLICATION.products.rich'             : 'native'
         'APPLICATION.products.cminpack'         : 'native'
@@ -292,7 +292,7 @@ __overwrite__ :
         'APPLICATION.products.h5py'             : 'native'
         'APPLICATION.products.markdown_it_py'   : 'native'
         'APPLICATION.products.mdurl'            : 'native'
-        'APPLICATION.products.meshio'           : 'native'
+        'APPLICATION.products.meshio'           : {tag: '5.3.5', base:  'no', section: 'version_5_3_5_no_pip'}
         'APPLICATION.products.netCDF4'          : 'native'
         'APPLICATION.products.rich'             : 'native'
         'APPLICATION.products.opencv'           : {tag: '3.2.0',     base: 'no', section: 'version_3_2_0_DB12'}
index 1c9df31ab51d5a9456189609d31941eef940098c..87c23ab751cd2133386a5fbf254917c5626242e2 100644 (file)
@@ -292,7 +292,7 @@ __overwrite__ :
         'APPLICATION.products.h5py'             : 'native'
         'APPLICATION.products.markdown_it_py'   : 'native'
         'APPLICATION.products.mdurl'            : 'native'
-        'APPLICATION.products.meshio'           : 'native'
+        'APPLICATION.products.meshio'           : {tag: '5.3.4', base:  'no', section: 'version_5_3_4_no_pip'}
         'APPLICATION.products.netCDF4'          : 'native'
         'APPLICATION.products.rich'             : 'native'
         'APPLICATION.products.opencv'           : {tag: '3.2.0',     base: 'no', section: 'version_3_2_0_DB12'}
index 94551a53c00bc319a629ff410e5b9e230c4f0796..1f9bf3967eabdf449bc928e62ef8f9e7dfb1834d 100755 (executable)
@@ -15,7 +15,9 @@ cd $BUILD_DIR
 export PYTHONPATH=${PRODUCT_INSTALL}/lib/python${PYTHON_VERSION}/site-packages:$PYTHONPATH
 export PATH=${PRODUCT_INSTALL}/bin:$PATH
 
-WHEELS=('cached_property-1.5.2-py2.py3-none-any.whl' 'meshio-4.3.13-py3-none-any.whl')
+WHEELS=('cached_property-1.5.2-py2.py3-none-any.whl'
+        'meshio-4.3.13-py3-none-any.whl'
+       )
 for WHEEL in "${WHEELS[@]}"; do
     ${PYTHONBIN} -m pip install --cache-dir=$BUILD_DIR/cache/pip  $SOURCE_DIR/$WHEEL --prefix=$PRODUCT_INSTALL
     if [ $? -ne 0 ]; then
@@ -24,5 +26,40 @@ for WHEEL in "${WHEELS[@]}"; do
     fi
 done
 
+# bos #42618 - https://github.com/nschloe/meshio/issues/1484
+fPy=$PRODUCT_INSTALL/lib/python${PYTHON_VERSION}/site-packages/meshio/gmsh/main.py
+if [ -f $fPy ]; then
+    sed -i 's/"gmsh": lambda f, m, \*\*kwargs: write(f, m, "4.1", \*\*kwargs)/"gmsh40": lambda f, m, \*\*kwargs: write(f, m, "4.0", \*\*kwargs)/g' $fPy
+    if [ $? -ne 0 ]; then
+        echo "FATAL: could not apply fixes to GMSH MeshIO driver"
+        exit 1
+    fi
+else
+    echo "FATAL: could not find GMSH MeshIO driver!"
+    exit 1
+fi
+
+# spns #42665
+fPy=$PRODUCT_INSTALL/lib/python${PYTHON_VERSION}/site-packages/meshio/ansys/_ansys.py
+if [ -f $fPy ]; then
+    statusCode=0
+    # retrieve line number
+    l=$(grep -nA0 "raise KeyError" $fPy|cut -d':' -f1)
+    L=$(($l+2))
+    sed -i 's/raise KeyError(/warn(/g' $fPy
+    statusCode=$(($statusCode+$?))
+    sed -i "${L}s/)/)\n                continue/g"  $fPy
+    statusCode=$(($statusCode+$?))
+    sed -i 's/(legal: {legal_keys})/(legal: {legal_keys}). Cell will be skipped!/g' $fPy
+    statusCode=$(($statusCode+$?))
+    if [ $statusCode -ne 0 ]; then
+        echo "FATAL: could not apply fixes to ANSYS MeshIO driver"
+        exit 1
+    fi
+else
+    echo "FATAL: could not find ANSYS MeshIO driver!"
+    exit 1
+fi
+
 echo
 echo "########## END"
index 19ec70706f731ef10455ff15d50f7df2a88c17db..756844b7c355ce5664852d4ee025a1e81869e236 100755 (executable)
@@ -34,5 +34,54 @@ case $LINUX_DISTRIBUTION in
         ;;
 esac
 
+pyVersionMajor=python$($PYTHONBIN -c 'import sys; print(".".join(map(str, sys.version_info[0:1])))')
+if [ $? -ne 0 ]; then
+    echo ERROR: Failed to extract major Python version -  assuming Python version equal to 3...
+    pyVersionMajor=python3
+fi
+
+echo INFO: Python version major: ${pyVersionMajor}
+if [ -f $PRODUCT_INSTALL/lib/python${PYTHON_VERSION}/site-packages/bin/meshio ]; then
+    sed -i "s%#\!.*python[0-9]*%#\!/usr/bin/env ${pyVersionMajor}%#g" $PRODUCT_INSTALL/lib/python${PYTHON_VERSION}/site-packages/bin/meshio
+else
+    echo "FATAL: could not find meshio runner!"
+    exit  1
+fi
+
+# bos #42618 - https://github.com/nschloe/meshio/issues/1484
+fPy=$PRODUCT_INSTALL/lib/python${PYTHON_VERSION}/site-packages/meshio/gmsh/main.py
+if [ -f $fPy ]; then
+    sed -i 's/"gmsh": lambda f, m, \*\*kwargs: write(f, m, "4.1", \*\*kwargs)/"gmsh40": lambda f, m, \*\*kwargs: write(f, m, "4.0", \*\*kwargs)/g' $fPy
+    if [ $? -ne 0 ]; then
+        echo "FATAL: could not apply fixes to GMSH MeshIO driver"
+        exit 1
+    fi
+else
+    echo "FATAL: could not find GMSH MeshIO driver!"
+    exit 1
+fi
+
+# spns #42665
+fPy=$PRODUCT_INSTALL/lib/python${PYTHON_VERSION}/site-packages/meshio/ansys/_ansys.py
+if [ -f $fPy ]; then
+    statusCode=0
+    # retrieve line number
+    l=$(grep -nA0 "raise KeyError" $fPy|cut -d':' -f1)
+    L=$(($l+2))
+    sed -i 's/raise KeyError(/warn(/g' $fPy
+    statusCode=$(($statusCode+$?))
+    sed -i "${L}s/)/)\n                continue/g"  $fPy
+    statusCode=$(($statusCode+$?))
+    sed -i 's/(legal: {legal_keys})/(legal: {legal_keys}). Cell will be skipped!/g' $fPy
+    statusCode=$(($statusCode+$?))
+    if [ $statusCode -ne 0 ]; then
+        echo "FATAL: could not apply fixes to ANSYS MeshIO driver"
+        exit 1
+    fi
+else
+    echo "FATAL: could not find ANSYS MeshIO driver!"
+    exit 1
+fi
+
 echo
 echo "########## END"
index 898f73e9eb09e2fda1f27f3854674199c1ca471d..02ae829288ae4802cae3f16c798b57788dcc2e7b 100755 (executable)
@@ -28,9 +28,10 @@ done
 
 pyVersionMajor=python$($PYTHONBIN -c 'import sys; print(".".join(map(str, sys.version_info[0:1])))')
 if [ $? -ne 0 ]; then
-         echo ERROR: Failed to extract major Python version -  assuming Python version equal to 3...
-         pyVersionMajor=python3
+    echo ERROR: Failed to extract major Python version -  assuming Python version equal to 3...
+    pyVersionMajor=python3
 fi
+
 echo INFO: Python version major: ${pyVersionMajor}
 if [ -f $PRODUCT_INSTALL/lib/python${PYTHON_VERSION}/site-packages/bin/meshio ]; then
     sed -i "s%#\!.*python[0-9]*%#\!/usr/bin/env ${pyVersionMajor}%#g" $PRODUCT_INSTALL/lib/python${PYTHON_VERSION}/site-packages/bin/meshio
@@ -39,5 +40,40 @@ else
     exit  1
 fi
 
+# bos #42618 - https://github.com/nschloe/meshio/issues/1484
+fPy=$PRODUCT_INSTALL/lib/python${PYTHON_VERSION}/site-packages/meshio/gmsh/main.py
+if [ -f $fPy ]; then
+    sed -i 's/"gmsh": lambda f, m, \*\*kwargs: write(f, m, "4.1", \*\*kwargs)/"gmsh40": lambda f, m, \*\*kwargs: write(f, m, "4.0", \*\*kwargs)/g' $fPy
+    if [ $? -ne 0 ]; then
+        echo "FATAL: could not apply fixes to GMSH MeshIO driver"
+        exit 1
+    fi
+else
+    echo "FATAL: could not find GMSH MeshIO driver!"
+    exit 1
+fi
+
+# spns #42665
+fPy=$PRODUCT_INSTALL/lib/python${PYTHON_VERSION}/site-packages/meshio/ansys/_ansys.py
+if [ -f $fPy ]; then
+    statusCode=0
+    # retrieve line number
+    l=$(grep -nA0 "raise KeyError" $fPy|cut -d':' -f1)
+    L=$(($l+2))
+    sed -i 's/raise KeyError(/warn(/g' $fPy
+    statusCode=$(($statusCode+$?))
+    sed -i "${L}s/)/)\n                continue/g"  $fPy
+    statusCode=$(($statusCode+$?))
+    sed -i 's/(legal: {legal_keys})/(legal: {legal_keys}). Cell will be skipped!/g' $fPy
+    statusCode=$(($statusCode+$?))
+    if [ $statusCode -ne 0 ]; then
+        echo "FATAL: could not apply fixes to ANSYS MeshIO driver"
+        exit 1
+    fi
+else
+    echo "FATAL: could not find ANSYS MeshIO driver!"
+    exit 1
+fi
+
 echo
 echo "########## END"
index 390a75d411b520fb30637d8814c0c3b4d95503a5..6d87618fa2b2a2e95a36a8555860c536d1498b28 100644 (file)
@@ -49,6 +49,7 @@ version_5_3_5_win :
 {
    compil_script: "meshio-5.3.5.bat"
    archive_info : {archive_name : "meshio-5.3.5.tar.gz"}
+   patches : ['meshio-5.3.5.p01.gmsh_ansys.patch']
    properties :
    {
      incremental : "yes"
diff --git a/products/patches/meshio-5.3.5.p01.gmsh_ansys.patch b/products/patches/meshio-5.3.5.p01.gmsh_ansys.patch
new file mode 100644 (file)
index 0000000..ade25ef
--- /dev/null
@@ -0,0 +1,25 @@
+--- meshio-5.3.5_ref/src/meshio/gmsh/main.py   2023-06-26 21:18:18.000000000 +0200
++++ meshio-5.3.5_dev/src/meshio/gmsh/main.py   2024-08-02 10:20:16.667483402 +0200
+@@ -108,6 +108,6 @@
+     read,
+     {
+         "gmsh22": lambda f, m, **kwargs: write(f, m, "2.2", **kwargs),
+-        "gmsh": lambda f, m, **kwargs: write(f, m, "4.1", **kwargs),
++        "gmsh40": lambda f, m, **kwargs: write(f, m, "4.0", **kwargs),
+     },
+ )
+--- meshio-5.3.5_ref/src/meshio/ansys/_ansys.py        2024-01-31 16:09:01.000000000 +0100
++++ meshio-5.3.5_dev/src/meshio/ansys/_ansys.py        2024-08-02 10:20:57.619917526 +0200
+@@ -446,9 +446,10 @@
+                 ansys_cell_type = meshio_to_ansys_type[cell_type]
+             except KeyError:
+                 legal_keys = ", ".join(meshio_to_ansys_type.keys())
+-                raise KeyError(
+-                    f"Illegal ANSYS cell type '{cell_type}'. (legal: {legal_keys})"
++                warn(
++                    f"Illegal ANSYS cell type '{cell_type}'. (legal: {legal_keys}). Skipping cell!"
+                 )
++                continue
+             fh.write(
+                 f"({key} (1 {first_index:x} {last_index:x} 1 {ansys_cell_type})(\n".encode()
+             )