From 3eed97193b0f1c206be1b7887c93fb1779e6b14c Mon Sep 17 00:00:00 2001 From: "pascale.noyret" Date: Fri, 27 Nov 2020 09:52:17 +0100 Subject: [PATCH] partage Eric a verifier . userASSDMultiple et inGetAttribut --- Accas/A_ASSD.py | 2 + Accas/__init__.py | 2 +- Ihm/I_JDC.py | 6 +- Ihm/I_MCSIMP.py | 22 +++++-- InterfaceQT4/eficas_go.py | 6 +- .../monWidgetPlusieursASSDIntoOrdonne.py | 4 +- .../monWidgetPlusieursCreeUserAssd.py | 2 +- InterfaceQT4/monWidgetPlusieursIntoOrdonne.py | 6 +- Noyau/N_ENTITE.py | 2 +- Noyau/N_MCSIMP.py | 7 ++- Noyau/N_SIMP.py | 5 +- Noyau/N_UserASSD.py | 4 +- Noyau/N_UserASSDMultiple.py | 44 ++++++++++++++ Vimmp/cata_CSAndCPS_v4.py | 60 ++++++------------- 14 files changed, 108 insertions(+), 64 deletions(-) create mode 100644 Noyau/N_UserASSDMultiple.py diff --git a/Accas/A_ASSD.py b/Accas/A_ASSD.py index 22c98794..0c02a417 100644 --- a/Accas/A_ASSD.py +++ b/Accas/A_ASSD.py @@ -27,6 +27,7 @@ from Noyau import N_GEOM from Noyau import N_FONCTION from Noyau import N_CO from Noyau import N_UserASSD +from Noyau import N_UserASSDMultiple # On ajoute la classe ASSD dans l'heritage multiple pour recreer # une hierarchie d'heritage identique a celle de Noyau @@ -37,6 +38,7 @@ class ASSD(I_ASSD.ASSD,N_ASSD.ASSD):pass #class LASSD(I_LASSD.LASSD,N_LASSD.LASSD):pass class LASSD(I_LASSD.LASSD):pass class UserASSD(N_UserASSD.UserASSD,ASSD): pass +class UserASSDMultiple(N_UserASSDMultiple.UserASSDMultiple,UserASSD): pass class assd(N_ASSD.assd,I_ASSD.assd,ASSD):pass diff --git a/Accas/__init__.py b/Accas/__init__.py index 471d7985..bed5e272 100644 --- a/Accas/__init__.py +++ b/Accas/__init__.py @@ -72,7 +72,7 @@ from .A_ENSEMBLE import ENSEMBLE from .A_A_CLASSER import A_CLASSER from .A_AVANT import AVANT -from .A_ASSD import ASSD,assd, UserASSD +from .A_ASSD import ASSD,assd, UserASSD, UserASSDMultiple from .A_ASSD import GEOM,geom # Pour le moment on laisse fonction (ceinture et bretelles) from .A_ASSD import FONCTION, fonction diff --git a/Ihm/I_JDC.py b/Ihm/I_JDC.py index 58c9d8f1..3057b6ca 100644 --- a/Ihm/I_JDC.py +++ b/Ihm/I_JDC.py @@ -146,17 +146,17 @@ class JDC(I_OBJECT.OBJECT): etapeTraitee.isValid() def recalculeValiditeApresChangementGlobalJdc(self, motClef): - print ("je passe dans recalculeValiditeApresChangementGlobalJdc") + #print ("je passe dans recalculeValiditeApresChangementGlobalJdc") try : liste=self.getJdcRoot().cata.dict_condition[motClef.nom] except : liste=() for etapeTraitee in self.etapes : if etapeTraitee.nom not in liste: continue - #self.forceRecalculBloc(etapeTraitee) etapeTraitee.state='arecalculer' etapeTraitee.deepUpdateConditionBloc() etapeTraitee.isValid() + #print (etapeTraitee.nom ,etapeTraitee.isValid()) def activeBlocsGlobaux(self): for nomMotClef in self.mc_globaux : @@ -431,7 +431,7 @@ class JDC(I_OBJECT.OBJECT): if sd:return sd sd=self.getSdApresEtape(nom_sd,etape,avec) if sd:return sd - # Pour tenir compte des UserASSD + # Pour tenir compte des UserASSD # et des UserASSDMultiple a affiner if nom_sd in self.sdsDict.keys() : sd=self.sdsDict[nom_sd] return sd diff --git a/Ihm/I_MCSIMP.py b/Ihm/I_MCSIMP.py index e3b26948..391bb8de 100644 --- a/Ihm/I_MCSIMP.py +++ b/Ihm/I_MCSIMP.py @@ -210,7 +210,14 @@ class MCSIMP(I_OBJECT.OBJECT): return 1 return 0 - def waitUserAssdEnCreation(self): + def waitUserAssdMultiple(self): + for typ in self.definition.type: + if type(typ) == type or isinstance(typ,type): + if issubclass(typ,UserASSDMultiple) : + return 1 + return 0 + + def waitUserAssdOrAssdMultipleEnCreation(self): for typ in self.definition.type: if typ == 'createObject' : return 1 @@ -335,6 +342,9 @@ class MCSIMP(I_OBJECT.OBJECT): self.etape.deepUpdateConditionBloc() elif self.definition.position == 'global_jdc' : self.jdc.deepUpdateConditionBloc(self) + elif self.definition.position == 'inGetAttribut' : + print ('je suis ici') + self.jdc.deepUpdateConditionBloc(self) else: self.parent.updateConditionBloc() @@ -342,7 +352,7 @@ class MCSIMP(I_OBJECT.OBJECT): self.initModif() self.valeur = new_valeur self.val = new_valeur - if self.valeur and self.waitUserAssd() and not(self.waitUserAssdEnCreation()) : + if self.valeur and self.waitUserAssd() and not(self.waitUserAssdOrAssdMultipleEnCreation()) : if type(self.valeur) in (list,tuple): for v in self.valeur : v.ajoutUtilisePar(self) else : self.valeur.ajoutUtilisePar(self) @@ -622,11 +632,15 @@ class MCSIMP(I_OBJECT.OBJECT): """ if self.definition.position == 'global' : etape = self.getEtape() - if etape : + # on est oblige de verifier si le nom est dans etape + # car parfois l ordre des creations/destruction n est pas clair + # quand on a des blocs freres qui contiennent le meme mc global + # cas de NumericalMethod dans VIMMP + # if etape : + if etape and self.nom in etape.mc_globaux: del etape.mc_globaux[self.nom] elif self.definition.position == 'global_jdc' : # PNPNPN a debuger - print (self.nom) try : del self.jdc.mc_globaux[self.nom] except : pass diff --git a/InterfaceQT4/eficas_go.py b/InterfaceQT4/eficas_go.py index ded9b52f..e35d9fc2 100755 --- a/InterfaceQT4/eficas_go.py +++ b/InterfaceQT4/eficas_go.py @@ -117,6 +117,10 @@ def genereXML(code=None): from .editorSsIhm import JDCEditorSsIhm monEditeur=JDCEditorSsIhm(monEficasSsIhm,fichier) fichierXML=fichier[:fichier.rfind(".")]+'.xml' + print (monEditeur.jdc.isValid()) + if not(monEditeur.jdc.isValid()): + print ('Fichier comm non valide') + return monEditeur.XMLgenerator.gener(monEditeur.jdc) monEditeur.XMLgenerator.writeDefault(fichierXML) @@ -154,7 +158,7 @@ def validateFonction(laFonction, debug=False): if debug : print('Appel {} avec args={} et kwargs={}'.format( laFonction.__name__, args, kwargs)) laDefDeLaFonctionDansAccas = getattr(monEditor.readercata.cata,laFonctionName) objConstruit = laDefDeLaFonctionDansAccas.makeObjetPourVerifSignature(*args,**kwargs) - if (objConstruit.isValid(cr='oui')) : + if (objConstruit.isValid()) : ret = laFonction(*args, **kwargs) return ret else : diff --git a/InterfaceQT4/monWidgetPlusieursASSDIntoOrdonne.py b/InterfaceQT4/monWidgetPlusieursASSDIntoOrdonne.py index de514a5c..f3157329 100644 --- a/InterfaceQT4/monWidgetPlusieursASSDIntoOrdonne.py +++ b/InterfaceQT4/monWidgetPlusieursASSDIntoOrdonne.py @@ -54,8 +54,8 @@ class MonWidgetPlusieursASSDIntoOrdonne (MonWidgetPlusieursIntoOrdonne): return - if len(self.listeAAfficher)*20 > 400 : self.setMinimumHeight(400) - else : self.setMinimumHeight(len(self.listeAAfficher)*30) + if len(self.listeAAfficher)*30 > 400 : self.resize(self.width(),200) + else : self.resize(self.width(),len(self.listeAAfficher)*30) self.politique=PolitiquePlusieurs(self.node,self.editor) for i in range(1,len(self.listeAAfficher)+1): self.ajoutLE(i) for i in range(len(self.listeAAfficher)): diff --git a/InterfaceQT4/monWidgetPlusieursCreeUserAssd.py b/InterfaceQT4/monWidgetPlusieursCreeUserAssd.py index 78226fb9..04ca30da 100644 --- a/InterfaceQT4/monWidgetPlusieursCreeUserAssd.py +++ b/InterfaceQT4/monWidgetPlusieursCreeUserAssd.py @@ -92,7 +92,7 @@ class MonWidgetPlusieursCreeUserAssd ( MonWidgetPlusieursBase): self.selectionneNext() def selectionneNext(self): - print ('a programmer') + print ('selectionne Next a programmer') def leaveEventScrollArea(self,event): pass diff --git a/InterfaceQT4/monWidgetPlusieursIntoOrdonne.py b/InterfaceQT4/monWidgetPlusieursIntoOrdonne.py index 10c0407c..1b3bc6d7 100644 --- a/InterfaceQT4/monWidgetPlusieursIntoOrdonne.py +++ b/InterfaceQT4/monWidgetPlusieursIntoOrdonne.py @@ -110,9 +110,9 @@ class MonWidgetPlusieursIntoOrdonne (Ui_WidgetPlusieursIntoOrdonne, Feuille,Gere self.filtreListe() if len(self.listeAAfficher)*20 > 400 : self.setMinimumHeight(400) else : - if self.monSimpDef.min > len(self.listeAAfficher) : self.setMinimumHeight(self.monSimpDef.min*30+30) - elif self.monSimpDef.max > len(self.listeAAfficher) : self.setMinimumHeight(400) - else self.setMinimumHeight(len(self.listeAAfficher)*30+30) + if self.monSimpDef.min > len(self.listeAAfficher) : self.setMinimumHeight(self.monSimpDef.min*30+300) + elif self.monSimpDef.max > len(self.listeAAfficher) : self.setMinimumHeight(400) + else : self.setMinimumHeight(len(self.listeAAfficher)*30+30) self.adjustSize() self.politique=PolitiquePlusieurs(self.node,self.editor) diff --git a/Noyau/N_ENTITE.py b/Noyau/N_ENTITE.py index fc15bd7d..57153520 100644 --- a/Noyau/N_ENTITE.py +++ b/Noyau/N_ENTITE.py @@ -263,7 +263,7 @@ class ENTITE(object): def checkPosition(self): """Vérifie l'attribut position.""" - if self.position not in ('local', 'global', 'global_jdc'): + if self.position not in ('local', 'global', 'global_jdc', 'inGetAttribut'): self.cr.fatal(_(u"L'attribut 'position' doit valoir 'local', 'global' " u"ou 'global_jdc' : %r"), self.position) diff --git a/Noyau/N_MCSIMP.py b/Noyau/N_MCSIMP.py index 83c7b41f..61a028dd 100644 --- a/Noyau/N_MCSIMP.py +++ b/Noyau/N_MCSIMP.py @@ -28,6 +28,7 @@ from __future__ import absolute_import from copy import copy from Noyau.N_ASSD import ASSD +from Noyau.N_UserASSDMultiple import UserASSDMultiple from Noyau.N_CO import CO from . import N_OBJECT from .N_CONVERT import ConversionFactory @@ -70,13 +71,15 @@ class MCSIMP(N_OBJECT.OBJECT): # Le mot cle simple a été créé sans parent # est-ce possible ? print ('je suis dans le else sans parent du build') - print (poum) self.jdc = None self.cata = None self.niveau = None self.etape = None if self.definition.creeDesObjets : - self.convProto = ConversionFactory('UserASSD', self.definition.creeDesObjetsDeType) + if issubclass(self.definition.creeDesObjetsDeType, UserASSDMultiple) : + self.convProto = ConversionFactory('UserASSDMultiple', self.definition.creeDesObjetsDeType) + else : + self.convProto = ConversionFactory('UserASSD', self.definition.creeDesObjetsDeType) else : self.convProto = ConversionFactory('type', typ=self.definition.type) self.valeur = self.getValeurEffective(self.val) diff --git a/Noyau/N_SIMP.py b/Noyau/N_SIMP.py index 40b8452d..ff88a1d1 100644 --- a/Noyau/N_SIMP.py +++ b/Noyau/N_SIMP.py @@ -90,7 +90,10 @@ class SIMP(N_ENTITE.ENTITE): self.type = (typ,) for t in (self.type) : try : - if issubclass(t,Accas.UserASSD) : + if issubclass(t,Accas.UserASSDMultiple) : + creeDesObjetsDeType = t + self.utiliseUneReference = True + elif issubclass(t,Accas.UserASSD) : creeDesObjetsDeType = t self.utiliseUneReference = True except : pass diff --git a/Noyau/N_UserASSD.py b/Noyau/N_UserASSD.py index 7bc6f048..d18a96a1 100644 --- a/Noyau/N_UserASSD.py +++ b/Noyau/N_UserASSD.py @@ -44,7 +44,7 @@ class UserASSD(ASSD): """ def __init__(self,nom='sansNom'): - #print ('dans init de UserASSD pour ', nom, type(nom)) + print ('dans init de UserASSD pour ', nom, type(nom)) self.nom = nom self.jdc = CONTEXT.getCurrentJdC() self.parent = None @@ -61,7 +61,7 @@ class UserASSD(ASSD): self.parent= parent def initialiseNom(self,nom): - print ('je passe initialiseNom pour : ', self, nom, type(nom)) + #print ('je passe initialiseNom pour : ', self, nom, type(nom)) for (i,j) in self.jdc.sdsDict.items() : if j == self : del(self.jdc.sdsDict[i]) diff --git a/Noyau/N_UserASSDMultiple.py b/Noyau/N_UserASSDMultiple.py new file mode 100644 index 00000000..853a4bf4 --- /dev/null +++ b/Noyau/N_UserASSDMultiple.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# Copyright (C) 2007-2017 EDF R&D +# +# 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. +# +# 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 + +""" + +""" + +from __future__ import absolute_import +from __future__ import print_function +try : + from builtins import object +except : pass +import traceback +import sys + +from .N_UserASSD import UserASSD + +class UserASSDMultiple(UserASSD): + """ + Classe de base pour definir des types de structures de donnees definie par + l utilisateur + equivalent d un concept ASSD pour un SIMP ou un FACT + mais pouvant referencer 2 objets par exemple les groupes de mailles qui peuvent porter + le meme nom dans 2 maillages differents + """ + def __init__(self,nom='sansNom'): + UserASSD.__init__(self,nom) + diff --git a/Vimmp/cata_CSAndCPS_v4.py b/Vimmp/cata_CSAndCPS_v4.py index 3c11dee4..547f471d 100644 --- a/Vimmp/cata_CSAndCPS_v4.py +++ b/Vimmp/cata_CSAndCPS_v4.py @@ -83,6 +83,8 @@ dictTermeLE = { 'Lagrangian one-particle pdfFluid_Particle_Mass_Source_Field', 'Particle_Volumetric_Concentration_Modified_Fluid_Viscosity', 'Particle_Extra_Stress_Tensor'), + ('Particles','Particles') : ('Pas encore fait'), + ('Fields','Fields') : ('Pas encore fait'), } dictCodeConvertisseur = { @@ -91,56 +93,18 @@ dictCodeConvertisseur = { ('Fluent', 'OpenFOAM') : ('Fluent2CDM and CDM2OpenFoam'), } -#def prepareBlocSystemType(systemType) : -# condition = "SystemType == '" + systemType + "'" - #Identifier = SIMP(statut='o', typ=(modeleNumDuCompo,'createObject'),) -# ModelType = SIMP(statut='o', typ='TXM', into = ('Particles', 'Fields'),position='global') - #stl = SIMP (statut ='o', typ = simulatedTime) -# dicoArgs={} - -# first=1 -# for typeMod in ( 'Fields', 'Particles'): -# conditionType = "ModelType == '" + typeMod + "'" -# NumericalMethod = SIMP(statut='o',typ='TXM', into=dictTypModNumModNum[systemType, typeMod], -# position='global_jdc', intoXML=allValueInDict(dictTypModNumModNum)) -# if first : -# blocNumMethod_1 = BLOC(condition =conditionType, NumericalMethod=NumericalMethod) -# first=0 -# else : -# blocNumMethod_2 = BLOC(condition =conditionType, NumericalMethod=NumericalMethod) - #blocMeshRef = BLOC(condition = 'ModelType == "Fields" and NumericalMethod == "FV"', - # Mesh_Identifiers = SIMP (statut ='o', max ='**', typ = meshIdentifier),) - -# dicoBloc = {} -# for modeleNumerique in list(dictTypModNumModNum[systemType,typeMod]): -# conditionNum = "NumericalMethod == '" + modeleNumerique + "'" -# setCode = set() -# for code in dictCodeModeleNumerique.keys(): -# if modeleNumerique in dictCodeModeleNumerique[code]: setCode.add(code) -# Solver = SIMP(statut='o', typ='TXM', into=list(setCode), intoXML=list(dictCodeModeleNumerique.keys()) ) -# monNomBloc='b_ModelName_' + modeleNumerique.replace(' ','_') -# if setCode !=set(): dicoBloc[monNomBloc]=BLOC(condition=conditionNum, nomXML='b_ModelName',Solver=Solver) -# if setCode ==set(): print (condition, conditionNum) -# #dicoArgs['b_modelType'+typeMod] = BLOC(condition=conditionType, NumericalMethod=NumericalMethod,**dicoBloc) -# dicoArgs['b_modelType'+typeMod] = BLOC(condition=conditionType, **dicoBloc) -# #NumericalModel = FACT(statut='o', max= '**', Identifier=Identifier, ModelType=ModelType, -# NumericalModel = FACT(statut='o', max= '**', ModelType=ModelType, -# blocNumMethod_1 = blocNumMethod_1, blocNumMethod_2 = blocNumMethod_2, -# #blocMeshRef=blocMeshRef , Simulated_Time_Lapse=stl, **dicoArgs) -# **dicoArgs) -# return BLOC(condition=condition, nomXML='b_systemType', NumericalModel=NumericalModel) def prepareBlocSystemType(systemType) : condition = "SystemType == '" + systemType + "'" Identifier = SIMP(statut='o', typ=(modeleNumDuCompo,'createObject'),) SimulatedTimeLapse = SIMP (statut ='o', typ = simulatedTime) - ModelType = SIMP(statut='o', typ='TXM', into = ('Particles', 'Fields')) + ModelType = SIMP(statut='o', typ='TXM', into = ('Particles', 'Fields'), position='inGetAttribut') dicoArgs={} for typeMod in ('Particles', 'Fields'): conditionType = "ModelType == '" + typeMod + "'" NumericalMethod = SIMP(statut='o',typ='TXM', into=dictTypModNumModNum[systemType, typeMod], - position='global_jdc', intoXML=allValueInDict(dictTypModNumModNum)) + position='global', intoXML=allValueInDict(dictTypModNumModNum)) dicoBloc = {} for modeleNumerique in list(dictTypModNumModNum[systemType,typeMod]): conditionNum = "NumericalMethod == '" + modeleNumerique + "'" @@ -152,7 +116,8 @@ def prepareBlocSystemType(systemType) : if setCode !=set(): dicoBloc[monNomBloc]=BLOC(condition=conditionNum, nomXML='b_ModelName',Solver=Solver) dicoArgs['b_modelType'+typeMod] = BLOC(condition=conditionType, NumericalMethod=NumericalMethod,**dicoBloc) - blocMeshRef = BLOC(condition = 'ModelType == "Fields" and NumericalMethod == "FV"', + blocMeshRef = BLOC(condition = '(ModelType == "Fields") and (NumericalMethod == "FV")', + #blocMeshRef = BLOC(condition = 'NumericalMethod == "FV"', Mesh_Identifiers = SIMP (statut ='o', max ='**', typ = meshIdentifier),) dicoArgs['blocMeshRef'] = blocMeshRef NumericalModel = FACT(statut='o', max= '**', Identifier=Identifier, ModelType=ModelType, @@ -619,7 +584,14 @@ Interactions = PROC(nom='Interactions', Interaction = FACT( max = '**', origine = SIMP(typ=modeleNumDuCompo, statut='o'), destination = SIMP(typ=modeleNumDuCompo, statut='o'), -# PN a derouler avec une fonction + monBloc_FFFF = BLOC ( + condition = 'getEficasAttribut(origine,"ModelType") == "Fields" and getEficasAttribut(destination,"ModelType") == "Fields"' , + termeLE = SIMP(typ='TXM', statut='o', into = dictTermeLE['Fields','Particles'],fenetreIhm='menuDeroulant'), + ), + monBloc_DPDP = BLOC ( + condition = 'getEficasAttribut(origine,"ModelType") == "Particles" and getEficasAttribut(destination,"ModelType") == "Particles"' , + termeLE = SIMP(typ='TXM', statut='o', into = dictTermeLE['Particles','Fields'],fenetreIhm='menuDeroulant'), + ), monBloc_FFDP = BLOC ( condition = 'getEficasAttribut(origine,"ModelType") == "Fields" and getEficasAttribut(destination,"ModelType") == "Particles"' , termeLE = SIMP(typ='TXM', statut='o', into = dictTermeLE['Fields','Particles'],fenetreIhm='menuDeroulant'), @@ -651,7 +623,9 @@ Interactions = PROC(nom='Interactions', ), ) -dict_condition={'NumericalMethod' : ('Interactions', 'Component'), +dict_condition={ +'ModelType' : ('Interactions', 'Component'), +#'NumericalMethod' : ('Interactions', 'Component'), # 'TypeOfSolid' : ('Component',) } -- 2.39.2