smesh/src/Tools/blocFissure/gmu/getStatsMaillageFissure.py

91 lines
3.6 KiB
Python
Raw Normal View History

2014-01-09 14:20:44 +00:00
# -*- coding: utf-8 -*-
2020-04-15 17:49:00 +03:00
# Copyright (C) 2014-2020 EDF R&D
2019-02-14 14:55:47 +03:00
#
# 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
#
2021-01-20 19:16:13 +01:00
"""Statistiques maillage"""
2014-01-09 14:20:44 +00:00
2021-01-20 19:16:13 +01:00
import os
2014-01-09 14:20:44 +00:00
import logging
import SMESH
def getStatsMaillageFissure(maillage, referencesMaillageFissure, maillageFissureParams):
2021-03-17 18:46:40 +01:00
""""Statistiques maillage"""
2014-01-09 14:20:44 +00:00
logging.debug('start')
2017-03-20 13:27:30 +01:00
if 'nomRep' in maillageFissureParams:
2014-01-09 14:20:44 +00:00
nomRep = maillageFissureParams['nomRep']
2021-01-20 19:16:13 +01:00
else:
nomRep = os.path.curdir
2014-01-09 14:20:44 +00:00
nomFicFissure = maillageFissureParams['nomFicFissure']
2021-01-20 19:16:13 +01:00
fichierStatMaillageFissure = os.path.join(nomRep, "{}.res".format(nomFicFissure))
fichierNewRef = os.path.join(nomRep, "{}.new".format(nomFicFissure))
2014-01-09 14:20:44 +00:00
logging.debug("fichierStatMaillageFissure=%s", fichierStatMaillageFissure)
ok_maillage = False
2014-01-09 14:20:44 +00:00
if maillage is not None:
mesures = maillage.GetMeshInfo()
2021-01-20 19:16:13 +01:00
d_resu = dict()
2017-03-20 13:27:30 +01:00
for key, value in mesures.items():
2014-01-09 14:20:44 +00:00
logging.debug( "key: %s value: %s", key, value)
2021-01-20 19:16:13 +01:00
d_resu[str(key)] = value
logging.debug("dico mesures %s", d_resu)
2014-01-09 14:20:44 +00:00
2021-01-20 19:16:13 +01:00
text_2 = ""
ok_maillage = True
2021-01-20 19:16:13 +01:00
with open(fichierStatMaillageFissure, "w") as fic_stat :
for key in ('Entity_Quad_Quadrangle', 'Entity_Quad_Hexa'):
if d_resu[key] != referencesMaillageFissure[key]:
text = "Ecart"
ok_maillage = False
2021-01-20 19:16:13 +01:00
else:
text = "Valeur_OK"
text += ": {} reference: {} calcul: {}".format(key,referencesMaillageFissure[key],d_resu[key])
logging.info(text)
fic_stat.write(text+"\n")
text_2 += " {} = {}, \\\n".format(key,d_resu[key])
tolerance = 0.05
for key in ('Entity_Node', 'Entity_Quad_Edge', 'Entity_Quad_Triangle', 'Entity_Quad_Tetra', 'Entity_Quad_Pyramid', 'Entity_Quad_Penta'):
if (d_resu[key] < (1.0 - tolerance)*referencesMaillageFissure[key]) \
or (d_resu[key] > (1.0 + tolerance)*referencesMaillageFissure[key]):
text = "Ecart"
ok_maillage = False
2021-01-20 19:16:13 +01:00
else:
text = "Valeur_OK"
text += ": {} reference: {} calcul: {}".format(key,referencesMaillageFissure[key],d_resu[key])
logging.info(text)
fic_stat.write(text+"\n")
text_2 += " {} = {}, \\\n".format(key,d_resu[key])
if ok_maillage:
2021-03-17 18:46:40 +01:00
text = "Calcul cohérent avec la référence."
2021-01-20 19:16:13 +01:00
else:
text = "Calcul différent de la référence.\n"
2021-01-21 17:51:47 +01:00
text += "Voir le fichier {}\n".format(fichierStatMaillageFissure)
text += "La nouvelle référence est disponible dans le fichier :\n{}\n".format(fichierNewRef)
text += "Il faut l'insérer pour créer le dictionnaire 'referencesMaillageFissure' dans le paramétrage du cas."
2021-03-17 18:46:40 +01:00
# Résultats de référence pour intégration dans le python du cas pour une mise à jour
with open(fichierNewRef, "w") as fic_info :
fic_info.write(text_2[:-4]+" \\")
print (text)
2021-01-20 19:16:13 +01:00
return ok_maillage