mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2024-12-27 09:50:34 +05:00
Modernisation du programme
This commit is contained in:
parent
bc7bb7e199
commit
2a904f692b
@ -17,12 +17,12 @@
|
|||||||
#
|
#
|
||||||
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||||
#
|
#
|
||||||
|
"""Statistiques maillage"""
|
||||||
|
|
||||||
|
import os
|
||||||
import logging
|
import logging
|
||||||
import SMESH
|
import SMESH
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
|
||||||
# --- statistiques maillage
|
|
||||||
|
|
||||||
def getStatsMaillageFissure(maillage, referencesMaillageFissure, maillageFissureParams):
|
def getStatsMaillageFissure(maillage, referencesMaillageFissure, maillageFissureParams):
|
||||||
"""
|
"""
|
||||||
@ -30,47 +30,60 @@ def getStatsMaillageFissure(maillage, referencesMaillageFissure, maillageFissure
|
|||||||
"""
|
"""
|
||||||
logging.debug('start')
|
logging.debug('start')
|
||||||
|
|
||||||
nomRep = '.'
|
|
||||||
if 'nomRep' in maillageFissureParams:
|
if 'nomRep' in maillageFissureParams:
|
||||||
nomRep = maillageFissureParams['nomRep']
|
nomRep = maillageFissureParams['nomRep']
|
||||||
|
else:
|
||||||
|
nomRep = os.path.curdir
|
||||||
|
|
||||||
nomFicFissure = maillageFissureParams['nomFicFissure']
|
nomFicFissure = maillageFissureParams['nomFicFissure']
|
||||||
fichierStatMaillageFissure = nomRep + '/' + nomFicFissure + '.res'
|
fichierStatMaillageFissure = os.path.join(nomRep, "{}.res".format(nomFicFissure))
|
||||||
fichierNewRef = nomRep + '/' + nomFicFissure + '.new'
|
fichierNewRef = os.path.join(nomRep, "{}.new".format(nomFicFissure))
|
||||||
logging.debug("fichierStatMaillageFissure=%s", fichierStatMaillageFissure)
|
logging.debug("fichierStatMaillageFissure=%s", fichierStatMaillageFissure)
|
||||||
|
|
||||||
OK = False
|
OK = False
|
||||||
if maillage is not None:
|
if maillage is not None:
|
||||||
mesures = maillage.GetMeshInfo()
|
mesures = maillage.GetMeshInfo()
|
||||||
d= {}
|
d_resu = dict()
|
||||||
for key, value in mesures.items():
|
for key, value in mesures.items():
|
||||||
logging.debug( "key: %s value: %s", key, value)
|
logging.debug( "key: %s value: %s", key, value)
|
||||||
d[str(key)] = value
|
d_resu[str(key)] = value
|
||||||
logging.debug("dico mesures %s", d)
|
logging.debug("dico mesures %s", d_resu)
|
||||||
|
|
||||||
f = open(fichierStatMaillageFissure, 'w')
|
text_2 = ""
|
||||||
f2 = open(fichierNewRef, 'w')
|
|
||||||
OK = True
|
OK = True
|
||||||
for key in ('Entity_Quad_Pyramid', 'Entity_Quad_Hexa', 'Entity_Quad_Quadrangle'):
|
with open(fichierStatMaillageFissure, "w") as fic_stat :
|
||||||
if d[key] != referencesMaillageFissure[key]:
|
for key in ('Entity_Quad_Quadrangle', 'Entity_Quad_Hexa'):
|
||||||
logging.info("Ecart: %s reference: %s calcul: %s", key, referencesMaillageFissure[key], d[key])
|
if d_resu[key] != referencesMaillageFissure[key]:
|
||||||
f.write("Ecart: " + key + " reference: " + str(referencesMaillageFissure[key]) + " calcul: " + str(d[key]) + '\n')
|
text = "Ecart"
|
||||||
OK = False
|
OK = False
|
||||||
else:
|
else:
|
||||||
logging.info("Valeur_OK: %s reference: %s calcul: %s", key, referencesMaillageFissure[key], d[key])
|
text = "Valeur_OK"
|
||||||
f.write("Valeur_OK: " + key + " reference: " + str(referencesMaillageFissure[key]) + " calcul: " + str(d[key]) + '\n')
|
text += ": {} reference: {} calcul: {}".format(key,referencesMaillageFissure[key],d_resu[key])
|
||||||
f2.write(key + " = " + str(d[key]) + ",\n")
|
logging.info(text)
|
||||||
|
fic_stat.write(text+"\n")
|
||||||
|
text_2 += " {} = {}, \\\n".format(key,d_resu[key])
|
||||||
tolerance = 0.05
|
tolerance = 0.05
|
||||||
for key in ('Entity_Quad_Penta', 'Entity_Quad_Tetra', 'Entity_Quad_Triangle', 'Entity_Quad_Edge', 'Entity_Node'):
|
for key in ('Entity_Node', 'Entity_Quad_Edge', 'Entity_Quad_Triangle', 'Entity_Quad_Tetra', 'Entity_Quad_Pyramid', 'Entity_Quad_Penta'):
|
||||||
if (d[key] < (1.0 - tolerance)*referencesMaillageFissure[key]) \
|
if (d_resu[key] < (1.0 - tolerance)*referencesMaillageFissure[key]) \
|
||||||
or (d[key] > (1.0 + tolerance)*referencesMaillageFissure[key]):
|
or (d_resu[key] > (1.0 + tolerance)*referencesMaillageFissure[key]):
|
||||||
logging.info("Ecart: %s reference: %s calcul: %s", key, referencesMaillageFissure[key], d[key])
|
text = "Ecart"
|
||||||
f.write("Ecart: " + key + " reference: " + str(referencesMaillageFissure[key]) + " calcul: " + str(d[key]) + '\n')
|
|
||||||
OK = False
|
OK = False
|
||||||
else:
|
else:
|
||||||
logging.info("Valeur_OK: %s reference: %s calcul: %s", key, referencesMaillageFissure[key], d[key])
|
text = "Valeur_OK"
|
||||||
f.write("Valeur_OK: " + key + " reference: " + str(referencesMaillageFissure[key]) + " calcul: " + str(d[key]) + '\n')
|
text += ": {} reference: {} calcul: {}".format(key,referencesMaillageFissure[key],d_resu[key])
|
||||||
f2.write(key + " = " + str(d[key]) + ",\n")
|
logging.info(text)
|
||||||
f.close()
|
fic_stat.write(text+"\n")
|
||||||
f2.close()
|
text_2 += " {} = {}, \\\n".format(key,d_resu[key])
|
||||||
|
|
||||||
|
# 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]+" \\")
|
||||||
|
|
||||||
|
if OK:
|
||||||
|
print ("Calcul cohérent avec la référence.")
|
||||||
|
else:
|
||||||
|
text = "Calcul différent de la référence.\n"
|
||||||
|
texte += "Voir le fichier {}".format(fichierStatMaillageFissure)
|
||||||
|
print (text)
|
||||||
|
|
||||||
return OK
|
return OK
|
||||||
|
Loading…
Reference in New Issue
Block a user