Salome HOME
partage Eric a verifier . userASSDMultiple et inGetAttribut
authorpascale.noyret <pascale.noyret@edf.fr>
Fri, 27 Nov 2020 08:52:17 +0000 (09:52 +0100)
committerpascale.noyret <pascale.noyret@edf.fr>
Fri, 27 Nov 2020 08:52:17 +0000 (09:52 +0100)
14 files changed:
Accas/A_ASSD.py
Accas/__init__.py
Ihm/I_JDC.py
Ihm/I_MCSIMP.py
InterfaceQT4/eficas_go.py
InterfaceQT4/monWidgetPlusieursASSDIntoOrdonne.py
InterfaceQT4/monWidgetPlusieursCreeUserAssd.py
InterfaceQT4/monWidgetPlusieursIntoOrdonne.py
Noyau/N_ENTITE.py
Noyau/N_MCSIMP.py
Noyau/N_SIMP.py
Noyau/N_UserASSD.py
Noyau/N_UserASSDMultiple.py [new file with mode: 0644]
Vimmp/cata_CSAndCPS_v4.py

index 22c98794c6a0ea28a22379535861f67b41065a15..0c02a417f09c20ebc55555ba0a03501ca4da7b9f 100644 (file)
@@ -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
 
index 471d79857211801f8e6cf2cfb1485c047068fbf7..bed5e272f09575faa0e01182fc871917ae60a386 100644 (file)
@@ -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
index 58c9d8f1e32bbaf7c4935eb50d65ce8b0ffcc64f..3057b6ca0a794d6e545b3a6104831b288755f347 100644 (file)
@@ -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
index e3b26948615d63d2ea1173d0b9312db934adcd11..391bb8deaaf89d0a53e1d941d81a4e961d003a78 100644 (file)
@@ -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
index ded9b52fb1cbdad98aa7d3540a988d580ff223d4..e35d9fc22751b5465af9166836eff26e7a6b96b0 100755 (executable)
@@ -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 :
index de514a5ce58ec803ecd2fd9a9c9547ed5c000f70..f31573291e868228dda573dd897f78d9eed40ca0 100644 (file)
@@ -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)):
index 78226fb995edb7f2eb22198c93dfd92db02a892b..04ca30da467cdec57fd22deade2c4ec2de0447be 100644 (file)
@@ -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
index 10c0407c5bb1db9db5145bebed9c43b1a36b5db3..1b3bc6d7fdfc95d9e548ed6ab2616bf7517d4e02 100644 (file)
@@ -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)
index fc15bd7d017800f95212ea063c3811acb517d9b6..5715352034a827a82d123ca000945510ca7f12f6 100644 (file)
@@ -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)
 
index 83c7b41f775c2a89ebb3a1cb26efbb71c10248b4..61a028dd66b8962c53d7bfcdc6910cc16204bba1 100644 (file)
@@ -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)
index 40b8452de800b27d5f5bef6fbcdbb152ff086dfb..ff88a1d161ea410fa867926812f2c123dad8dcf1 100644 (file)
@@ -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
index 7bc6f048d92945395218bb10999ffd84ebcfa8f9..d18a96a101491ed252ed23d92bf305fbd46ce64a 100644 (file)
@@ -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 (file)
index 0000000..853a4bf
--- /dev/null
@@ -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)
+
index 3c11dee499b8b32fc1817d50eaa57066e5d46572..547f471df41ecd0a96404f1006a0abf983955723 100644 (file)
@@ -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',)
 }