1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2014-2021 EDF R&D
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License, or (at your option) any later version.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 """Statistiques maillage"""
27 def getStatsMaillageFissure(maillage, referencesMaillageFissure, maillageFissureParams):
28 """"Statistiques maillage"""
30 logging.debug('start')
32 if 'nomRep' in maillageFissureParams:
33 nomRep = maillageFissureParams['nomRep']
35 nomRep = os.path.curdir
37 nomFicFissure = maillageFissureParams['nomFicFissure']
38 fichierStatMaillageFissure = os.path.join(nomRep, "{}.res".format(nomFicFissure))
39 fichierNewRef = os.path.join(nomRep, "{}.new".format(nomFicFissure))
40 logging.debug("fichierStatMaillageFissure=%s", fichierStatMaillageFissure)
43 if maillage is not None:
44 mesures = maillage.GetMeshInfo()
46 for key, value in mesures.items():
47 logging.debug( "key: %s value: %s", key, value)
48 d_resu[str(key)] = value
49 logging.debug("dico mesures %s", d_resu)
53 with open(fichierStatMaillageFissure, "w") as fic_stat :
54 for key in ('Entity_Quad_Quadrangle', 'Entity_Quad_Hexa'):
55 if d_resu[key] != referencesMaillageFissure[key]:
60 text += ": {} reference: {} calcul: {}".format(key,referencesMaillageFissure[key],d_resu[key])
62 fic_stat.write(text+"\n")
63 text_2 += " {} = {}, \\\n".format(key,d_resu[key])
65 for key in ('Entity_Node', 'Entity_Quad_Edge', 'Entity_Quad_Triangle', 'Entity_Quad_Tetra', 'Entity_Quad_Pyramid', 'Entity_Quad_Penta'):
66 if (d_resu[key] < (1.0 - tolerance)*referencesMaillageFissure[key]) \
67 or (d_resu[key] > (1.0 + tolerance)*referencesMaillageFissure[key]):
72 text += ": {} reference: {} calcul: {}".format(key,referencesMaillageFissure[key],d_resu[key])
74 fic_stat.write(text+"\n")
75 text_2 += " {} = {}, \\\n".format(key,d_resu[key])
78 text = "Calcul cohérent avec la référence."
80 text = "Calcul différent de la référence.\n"
81 text += "Voir le fichier {}\n".format(fichierStatMaillageFissure)
82 text += "La nouvelle référence est disponible dans le fichier :\n{}\n".format(fichierNewRef)
83 text += "Il faut l'insérer pour créer le dictionnaire 'referencesMaillageFissure' dans le paramétrage du cas."
84 # Résultats de référence pour intégration dans le python du cas pour une mise à jour
85 with open(fichierNewRef, "w") as fic_info :
86 fic_info.write(text_2[:-4]+" \\")