1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2014-2020 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):
31 logging.debug('start')
33 if 'nomRep' in maillageFissureParams:
34 nomRep = maillageFissureParams['nomRep']
36 nomRep = os.path.curdir
38 nomFicFissure = maillageFissureParams['nomFicFissure']
39 fichierStatMaillageFissure = os.path.join(nomRep, "{}.res".format(nomFicFissure))
40 fichierNewRef = os.path.join(nomRep, "{}.new".format(nomFicFissure))
41 logging.debug("fichierStatMaillageFissure=%s", fichierStatMaillageFissure)
44 if maillage is not None:
45 mesures = maillage.GetMeshInfo()
47 for key, value in mesures.items():
48 logging.debug( "key: %s value: %s", key, value)
49 d_resu[str(key)] = value
50 logging.debug("dico mesures %s", d_resu)
54 with open(fichierStatMaillageFissure, "w") as fic_stat :
55 for key in ('Entity_Quad_Quadrangle', 'Entity_Quad_Hexa'):
56 if d_resu[key] != referencesMaillageFissure[key]:
61 text += ": {} reference: {} calcul: {}".format(key,referencesMaillageFissure[key],d_resu[key])
63 fic_stat.write(text+"\n")
64 text_2 += " {} = {}, \\\n".format(key,d_resu[key])
66 for key in ('Entity_Node', 'Entity_Quad_Edge', 'Entity_Quad_Triangle', 'Entity_Quad_Tetra', 'Entity_Quad_Pyramid', 'Entity_Quad_Penta'):
67 if (d_resu[key] < (1.0 - tolerance)*referencesMaillageFissure[key]) \
68 or (d_resu[key] > (1.0 + tolerance)*referencesMaillageFissure[key]):
73 text += ": {} reference: {} calcul: {}".format(key,referencesMaillageFissure[key],d_resu[key])
75 fic_stat.write(text+"\n")
76 text_2 += " {} = {}, \\\n".format(key,d_resu[key])
78 # Résultats de référence pour intégration dans le python du cas pour une mise à jour
79 with open(fichierNewRef, "w") as fic_info :
80 fic_info.write(text_2[:-4]+" \\")
83 print ("Calcul cohérent avec la référence.")
85 text = "Calcul différent de la référence.\n"
86 text += "Voir le fichier {}\n".format(fichierStatMaillageFissure)
87 text += "La nouvelle référence est disponible dans le fichier :\n{}\n".format(fichierNewRef)
88 text += "Il faut l'insérer pour créer le dictionnaire 'referencesMaillageFissure' dans le paramétrage du cas."