コード例 #1
0
ファイル: sup_gmsh2.py プロジェクト: Irvise/ogaca
    def LIRE_GMSH(self,
                  UNITE_GMSH=19,
                  UNITE_MAILLAGE=20,
                  MODI_QUAD='NON',
                  CREA_GROUP_NO='OUI'):
        """
      Lecture du maillage (format Aster) a partir de sa definition
      (format sup_gmsh)
      UNITE_GMSH     = Numero d'unite logique pour le fichier msh
      UNITE_MAILLAGE = Numero d'unite logique pour le fichier mail
      MODI_QUAD      = 'OUI' si line->quad, 'NON' sinon
      CREA_GROUP_NO  = 'OUI' si on cree les group_no, 'NON' sinon
    """

        nom_gmsh = 'fort.' + repr(UNITE_GMSH)
        self.Create(nom_gmsh)

        PRE_GMSH(UNITE_GMSH=UNITE_GMSH, UNITE_MAILLAGE=UNITE_MAILLAGE)

        SMESH_00 = LIRE_MAILLAGE(UNITE=UNITE_MAILLAGE)
        DEFI_FICHIER(ACTION='LIBERER', UNITE=UNITE_GMSH)
        DEFI_FICHIER(ACTION='LIBERER', UNITE=UNITE_MAILLAGE)

        if MODI_QUAD == 'OUI' and self.order == 2:
            raise 'The finite elements are already of second order'

        if MODI_QUAD == 'OUI' and self.order <> 2:
            SMESH_01 = CREA_MAILLAGE(MAILLAGE=SMESH_00,
                                     LINE_QUAD=_F(TOUT='OUI'))
            DETRUIRE(CONCEPT=_F(NOM=SMESH_00), INFO=1)
            SMESH_00 = SMESH_01

        SMESH_00 = self.Name(SMESH_00, CREA_GROUP_NO)

        return SMESH_00
コード例 #2
0
def macro_opti_sec_crit_masse_ops(self,valeur,etat,gradient,fn_para,**args):
    self.set_icmd(1)
    self.DeclareOut('valeur',valeur)
    CREA_TABLE	= self.get_cmd('CREA_TABLE')
    
    
    __CAREL=AFFE_CARA_ELEM(MODELE=etat["MODELE"],
                         INFO=1,
                         POUTRE=etat["CATALOGUE"].POUTRE()
                        )
    __masse=POST_ELEM(MODELE=etat["MODELE"],CHAM_MATER=etat["CHAM_MATER"],CARA_ELEM=__CAREL,MASS_INER=_F(TOUT='OUI'))
    
    valeurret=__masse["MASSE",1]

    valeur=CREA_TABLE(LISTE=(	_F(PARA='R',LISTE_R=(valeurret,))));
    aster.affiche('MESSAGE',  'macro_opti_sec_crit_masse:Valeur du retour c%f'%valeur["R",1])
    if (gradient==None):
        return 0
    else:

        self.DeclareOut('gradient',gradient)

        tgradient=[]
        for gmaopti in etat["GMASECTIONPOSSIBLE"]:
            tgradient.append(1.)

        gradient=CREA_TABLE(LISTE=(	_F(PARA='R',LISTE_R=tgradient)));
        #print "gradient['R',1]",gradient['R',1]
        return 0
コード例 #3
0
    def correctPrestrain(self, sol, inst):
        from Cata.cata import POST_RELEVE_T, DETRUIRE, DEFI_FONCTION
        from Accas import _F

        tabfor = POST_RELEVE_T(ACTION=(_F(OPERATION='EXTRACTION',
                                          INTITULE='forc',
                                          RESULTAT=sol,
                                          NOM_CHAM='SIEF_ELNO',
                                          INST=(inst),
                                          GROUP_NO=(self.beamhead),
                                          NOM_CMP=(
                                              'N',
                                              'VY',
                                              'VZ',
                                              'MT',
                                              'MFY',
                                              'MFZ',
                                          ))))

        Fax = tabfor['N', 1]
        mult = self.Fv / Fax
        self.dt *= mult
        print "Bolt ", self.label, ": force Fax = ", Fax, ", resulting multiplier = ", mult

        blT = BoltedJoint.allTempRamps

        # re-create temperature ramp for beams
        DETRUIRE(CONCEPT=(_F(NOM=blT[self.label]), _F(NOM=tabfor)), INFO=1)

        blT[self.label] = DEFI_FONCTION(NOM_PARA='INST',
                                        VALE=(0, 0, self.steps, -self.dt),
                                        INTERPOL='LIN',
                                        PROL_DROITE='CONSTANT',
                                        PROL_GAUCHE='CONSTANT')
コード例 #4
0
ファイル: opti_section_poutre.py プロジェクト: Irvise/ogaca
def macro_opti_sec_redu_gr_ops(self, reuse, MAILLAGE, gr_simpli, association,
                               newassociation, **args):
    self.set_icmd(1)

    self.DeclareOut('MAILOUT', self.sd)

    mail_py = MAIL_PY()
    mail_py.FromAster(MAILLAGE)

    dico_gr = {}  #permet d inverser les groupe mail
    crea_gr = []
    detr_gr = []

    newassociation = {}

    for k, v in association.iteritems():
        listma = []
        for ma in mail_py.gma[k]:
            listma.append('M' + str(ma + 1))
        if not (dico_gr.has_key(v)):
            dico_gr[v] = []
        dico_gr[v].extend(listma)
        detr_gr.append(k)
    for k, v in dico_gr.iteritems():
        crea_gr.append(_F(TYPE_MAILLE='1D', NOM=k, MAILLE=v))
        newassociation[k] = [k]

    MAILOUT = DEFI_GROUP(reuse=self.reuse,
                         MAILLAGE=MAILLAGE,
                         CREA_GROUP_MA=crea_gr,
                         DETR_GROUP_MA=_F(NOM=detr_gr))

    return 0
コード例 #5
0
ファイル: opti_section_poutre.py プロジェクト: Irvise/ogaca
def macro_opti_sec_crit_masse_ops(self, valeur, etat, gradient, fn_para,
                                  **args):
    self.set_icmd(1)
    self.DeclareOut('valeur', valeur)
    CREA_TABLE = self.get_cmd('CREA_TABLE')

    __CAREL = AFFE_CARA_ELEM(MODELE=etat["MODELE"],
                             INFO=1,
                             POUTRE=etat["CATALOGUE"].POUTRE())
    __masse = POST_ELEM(MODELE=etat["MODELE"],
                        CHAM_MATER=etat["CHAM_MATER"],
                        CARA_ELEM=__CAREL,
                        MASS_INER=_F(TOUT='OUI'))

    valeurret = __masse["MASSE", 1]

    valeur = CREA_TABLE(LISTE=(_F(PARA='R', LISTE_R=(valeurret, ))))
    aster.affiche(
        'MESSAGE',
        'macro_opti_sec_crit_masse:Valeur du retour c%f' % valeur["R", 1])
    if (gradient == None):
        return 0
    else:

        self.DeclareOut('gradient', gradient)

        tgradient = []
        for gmaopti in etat["GMASECTIONPOSSIBLE"]:
            tgradient.append(1.)

        gradient = CREA_TABLE(LISTE=(_F(PARA='R', LISTE_R=tgradient)))
        #print "gradient['R',1]",gradient['R',1]
        return 0
コード例 #6
0
ファイル: opti_analytique.py プロジェクト: Irvise/ogaca
def macro_opti_ana_fn_mult_grad_ops(self,retour,gradient,alpha,**args):
    self.set_icmd(1)
    self.DeclareOut('retour',retour)
    CREA_TABLE	= self.get_cmd('CREA_TABLE')

    retour=CREA_TABLE(LISTE=(	_F(PARA='R',LISTE_R=(alpha*gradient['R',1],alpha*gradient['R',2]))));
    DETRUIRE(INFO=1,CONCEPT=_F(NOM=(gradient),),ALARME='NON');
    return 0
コード例 #7
0
 def section_generation_mail(self, nom, UNITE=80):
     v = self.section_catalogue[nom]
     __MAILT = self.__generation_maillage_aster(v, nom)
     IMPR_RESU(
         FORMAT='MED',
         UNITE=UNITE,
         RESU=_F(MAILLAGE=__MAILT),
     )
     DETRUIRE(INFO=1, CONCEPT=_F(NOM=(__MAILT), ))
コード例 #8
0
def macro_opti_sec_fn_mult_grad_ops(self,etat,retour,gradient,alpha,**args):
    self.set_icmd(1)
    self.DeclareOut('retour',retour)
    CREA_TABLE	= self.get_cmd('CREA_TABLE')
    
    listretour=[]
    for i in range(0,len(etat["GMASECTIONPOSSIBLE"])):
        listretour.append(gradient['R',i+1]*alpha)

    retour=CREA_TABLE(LISTE=(	_F(PARA='R',LISTE_R=listretour)));
    DETRUIRE(INFO=1,CONCEPT=_F(NOM=(gradient),),ALARME='NON');
    return 0
コード例 #9
0
ファイル: opti_section_poutre.py プロジェクト: Irvise/ogaca
def macro_opti_sec_fn_mult_grad_ops(self, etat, retour, gradient, alpha,
                                    **args):
    self.set_icmd(1)
    self.DeclareOut('retour', retour)
    CREA_TABLE = self.get_cmd('CREA_TABLE')

    listretour = []
    for i in range(0, len(etat["GMASECTIONPOSSIBLE"])):
        listretour.append(gradient['R', i + 1] * alpha)

    retour = CREA_TABLE(LISTE=(_F(PARA='R', LISTE_R=listretour)))
    DETRUIRE(INFO=1, CONCEPT=_F(NOM=(gradient), ), ALARME='NON')
    return 0
コード例 #10
0
ファイル: sup_gmsh2.py プロジェクト: Irvise/ogaca
    def Name(self, MA, CREA_GROUP_NO):

        l_gma = []
        l_mcf = []
        for gma in self.physicals.keys():
            l_gma.append(self.physicals[gma])
            l_mcf.append(_F(GROUP_MA=self.physicals[gma], NOM=gma))

        DEFI_GROUP(
            reuse=MA,
            MAILLAGE=MA,
            CREA_GROUP_MA=tuple(l_mcf),
        )

        SMESH_02 = CREA_MAILLAGE(
            MAILLAGE=MA,
            DETR_GROUP_MA=_F(GROUP_MA=tuple(l_gma)),
        )

        DETRUIRE(CONCEPT=_F(NOM=MA), INFO=1)

        if CREA_GROUP_NO == 'OUI':
            DEFI_GROUP(
                reuse=SMESH_02,
                MAILLAGE=SMESH_02,
                CREA_GROUP_NO=_F(TOUT_GROUP_MA='OUI'),
            )

        else:
            #    Traitement des GROUP_NO qui sont des points
            info_gno = SMESH_02.LIST_GROUP_NO()
            l_gno = []
            for gno in info_gno:
                if gno[1] == 1: l_gno.append(gno[0])

            l_gma = []
            for gma in self.physicals.keys():
                nom_gmsh = self.physicals[gma]
                if nom_gmsh in l_gno:
                    l_gma.append(gma)

            if l_gma:
                DEFI_GROUP(
                    reuse=SMESH_02,
                    MAILLAGE=SMESH_02,
                    CREA_GROUP_NO=_F(GROUP_MA=tuple(l_gma)),
                )

        return SMESH_02
コード例 #11
0
ファイル: opti_section_poutre.py プロジェクト: Irvise/ogaca
def macro_opti_sec_gene_gr_ops(self, reuse, MAILLAGE, gr_ini, gr_cree, prefixe,
                               **args):
    self.set_icmd(1)

    self.DeclareOut('MAILOUT', self.sd)

    mail_py = MAIL_PY()
    mail_py.FromAster(MAILLAGE)

    gr_cree['gr'] = []
    crea_gr = []

    print "debug", mail_py.gma
    for gr in gr_ini['gr']:
        print "debug", gr
        for ma in mail_py.gma[gr]:
            crea_gr.append(
                _F(TYPE_MAILLE='1D',
                   NOM="O" + str(ma + 1),
                   MAILLE='M' + str(ma + 1)))
            gr_cree['gr'].append(prefixe + str(ma + 1))

    MAILOUT = DEFI_GROUP(reuse=self.reuse,
                         MAILLAGE=MAILLAGE,
                         CREA_GROUP_MA=crea_gr)
    print "debug", gr_cree
    return 0
コード例 #12
0
ファイル: catalogue_beta3.py プロジェクト: freddupont/ogaca
 def POUTRE(self):
     retour=[]
     for grit,typeit in self.association.iteritems():
         carait=self.section_catalogue[typeit]
         #print carait
         retour.append(_F(GROUP_MA=grit,SECTION='GENERALE',CARA=self.__CARA,VALE=carait[2][:14]))
     return retour;
コード例 #13
0
def macro_opti_sec_redu_gr_ops(self,reuse,MAILLAGE,gr_simpli,association,newassociation,**args):
    self.set_icmd(1)
    
    self.DeclareOut('MAILOUT',self.sd)


    mail_py=MAIL_PY();
    mail_py.FromAster(MAILLAGE);
    
    dico_gr={} #permet d inverser les groupe mail
    crea_gr=[]
    detr_gr=[]
    
    newassociation={}

    for k,v in association.iteritems():
        listma=[]
        for ma in mail_py.gma[k]:
            listma.append('M'+str(ma+1))
        if not (dico_gr.has_key(v)):
            dico_gr[v]=[]
        dico_gr[v].extend(listma)
        detr_gr.append(k)
    for k,v in dico_gr.iteritems():
        crea_gr.append(_F(TYPE_MAILLE='1D',NOM=k,MAILLE=v))
        newassociation[k]=[k]

    MAILOUT=DEFI_GROUP(reuse=self.reuse,MAILLAGE=MAILLAGE,CREA_GROUP_MA=crea_gr,DETR_GROUP_MA=_F(NOM=detr_gr))
    
    return 0
コード例 #14
0
ファイル: opti_xfem.py プロジェクト: Irvise/ogaca
def lvl_sav_op(self, MAILLAGE, CHAM_GD, NOM, ITER, para, **args):

    ier = 0
    self.icmd = 1
    FORMULE = self.get_cmd('FORMULE')
    CREA_CHAMP = self.get_cmd('CREA_CHAMP')
    CREA_RESU = self.get_cmd('CREA_RESU')
    POST_ELEM = self.get_cmd('POST_ELEM')
    DEFI_CONSTANTE = self.get_cmd('DEFI_CONSTANTE')

    if ITER == -1:
        IMPR_RESU(
            FORMAT='MED',
            UNITE=81,
            RESU=_F(
                MAILLAGE=MAILLAGE,
                CHAM_GD=CHAM_GD,
            ),
        )
        EXEC_LOGICIEL(LOGICIEL='cp fort.81 ' + para['sortiepath'] + NOM +
                      '.i.med', )
        DEFI_FICHIER(
            ACTION='LIBERER',
            UNITE=81,
        )
        EXEC_LOGICIEL(LOGICIEL='rm fort.81 ')
    else:
        IMPR_RESU(
            FORMAT='MED',
            UNITE=81,
            RESU=_F(
                MAILLAGE=MAILLAGE,
                CHAM_GD=CHAM_GD,
            ),
        )
        EXEC_LOGICIEL(LOGICIEL='cp fort.81 ' + para['sortiepath'] + NOM +
                      '.i.med', )
        if ITER % para['freqsav'] == 0:
            EXEC_LOGICIEL(LOGICIEL='cp fort.81 ' + para['sortiepath'] + NOM +
                          '.%d.med' % ITER, )
        DEFI_FICHIER(
            ACTION='LIBERER',
            UNITE=81,
        )
        EXEC_LOGICIEL(LOGICIEL='rm fort.81 ')

    return ier
コード例 #15
0
ファイル: opti_analytique.py プロジェクト: Irvise/ogaca
def macro_opti_ana_fn_prod_scalaire_grad_ops(self,retour,etat,grad1,grad2,**args):
    self.set_icmd(1)
    self.DeclareOut('retour',retour)
    CREA_TABLE	= self.get_cmd('CREA_TABLE')

    retour=CREA_TABLE(LISTE=(	_F(PARA='R',LISTE_R=(grad1['R',1]*grad2['R',1]+grad1['R',2]*grad2['R',2]))));
    print "ok"
    return 0
コード例 #16
0
ファイル: sup_gmsh2.py プロジェクト: freddupont/ogaca
  def Name(self, MA, CREA_GROUP_NO) :

    l_gma = []
    l_mcf =  []
    for gma in self.physicals.keys() :
      l_gma.append(self.physicals[gma])
      l_mcf.append(_F(GROUP_MA = self.physicals[gma],NOM=gma))

    DEFI_GROUP(reuse = MA,
      MAILLAGE = MA,
      CREA_GROUP_MA = tuple(l_mcf),
      )

    SMESH_02 = CREA_MAILLAGE(
      MAILLAGE = MA,
      DETR_GROUP_MA = _F(GROUP_MA = tuple(l_gma)),
      )

    DETRUIRE(CONCEPT = _F(NOM = MA), INFO=1)

    if CREA_GROUP_NO == 'OUI' :
      DEFI_GROUP(reuse = SMESH_02,
        MAILLAGE = SMESH_02,
        CREA_GROUP_NO = _F(TOUT_GROUP_MA = 'OUI'),
        )

    else :
#    Traitement des GROUP_NO qui sont des points
      info_gno = SMESH_02.LIST_GROUP_NO()
      l_gno = []
      for gno in info_gno :
        if gno[1] == 1 : l_gno.append(gno[0])

      l_gma = []
      for gma in self.physicals.keys() :
        nom_gmsh = self.physicals[gma]
        if nom_gmsh in l_gno :
          l_gma.append(gma)

      if l_gma :
        DEFI_GROUP(reuse = SMESH_02,
          MAILLAGE = SMESH_02,
          CREA_GROUP_NO = _F(GROUP_MA = tuple(l_gma)),
          )

    return SMESH_02
コード例 #17
0
ファイル: opti_analytique.py プロジェクト: Irvise/ogaca
def macro_opti_ana_fn_evol_ops(self,etat,newetat,gradient,alpha,**args):
    self.set_icmd(1)
    #self.DeclareOut('retour',self.sd)
    CREA_TABLE	= self.get_cmd('CREA_TABLE')

    _retour=CREA_TABLE(LISTE=(	_F(PARA='R',LISTE_R=(etat['valeurs']['R',1]+alpha*gradient['R',1],etat['valeurs']['R',2]+alpha*gradient['R',2]))));
    newetat['valeurs']=_retour
    return 0
コード例 #18
0
def get_unite_libre():
    """
        Retoune une unité de fichier libre.
    """
    from code_aster.Cata.Commands import DETRUIRE, INFO_EXEC_ASTER
    _UL = INFO_EXEC_ASTER(LISTE_INFO='UNITE_LIBRE')
    unite = _UL['UNITE_LIBRE', 1]
    DETRUIRE(CONCEPT=(_F(NOM=_UL), ), INFO=1)
    return unite
コード例 #19
0
    def __section_generation_sec(self, sec, nom):
        __MAILT = self.__generation_maillage_aster(sec, nom)
        #IMPR_RESU(FORMAT='MED',UNITE=80,RESU=_F(MAILLAGE=__MAILT),);

        seccara = MACR_CARA_POUTRE(MAILLAGE=__MAILT,
                                   GROUP_MA_BORD='ext',
                                   GROUP_NO='GN')

        #IMPR_TABLE(TABLE=seccara)
        #on charge les valeur depuis la table aster
        Vex = []
        rot = False
        for a in self.__EXTRACTION:
            Vex.append(seccara[a, 2])
            #print a,seccara[a,2]
        if (Vex[14] > 1e-5 or Vex[14] < -1e-5):
            print "attention angle alpha different de zero :"
            if (Vex[14] > 46. or Vex[14] < -46.):
                print "Rotation de plus de 45 on corrige pour etre au plus proche du dessin initial"
                rot = True
                caratemp = [
                    Vex[0],  #AIRE
                    Vex[2],
                    Vex[1],  #'IY_PRIN_G','IZ_PRIN_G'
                    Vex[4],
                    Vex[3],  #'AY','AZ'
                    Vex[6],
                    Vex[5],  #'EY','EZ'
                    Vex[7],  #'CT'
                    Vex[9],
                    Vex[8],  #'Y_MAX','Z_MAX'
                    Vex[10],
                    Vex[11],  #'RT','JG'
                    Vex[13],
                    Vex[12],  #'IYR2_PRIN_G','IZR2_PRIN_G'
                    Vex[14],
                    Vex[15],
                    Vex[16]
                ]  #'ALPHA','CDG_X','CDG_Y'
                Vex = caratemp
                if (Vex[14] < 0):
                    Vex[14] = Vex[14] + 90.
                else:
                    Vex[14] = Vex[14] - 90.
                print "par default les section sont tourne de l angle ", Vex[
                    14]
            else:
                print "par default les section sont tourne de l angle ", Vex[
                    14]
        if (Vex[15] > 1e-5 or Vex[15] < -1e-5 or Vex[16] > 1e-5
                or Vex[16] < -1e-5):
            print "attention centre de gravite excentre par rapport au dessin"
            print "CDG_X:", Vex[15], " CDG_Y:", Vex[16]
            print "Les poutres sont par default place sur leur centre de gravite"
        newsec = [sec[0], sec[1], Vex, rot]
        self.section_catalogue[nom] = newsec
        DETRUIRE(INFO=1, CONCEPT=_F(NOM=(__MAILT, seccara), ))
コード例 #20
0
def area(mesh, group_ma_name):
    from Cata.cata import CREA_MAILLAGE, AFFE_MODELE, DEFI_MATERIAU, \
        AFFE_MATERIAU, AFFE_CARA_ELEM, POST_ELEM, DETRUIRE
    from Accas import _F

    tmpmesh = CREA_MAILLAGE(
        MAILLAGE=mesh,
        MODI_MAILLE=_F(
            GROUP_MA=group_ma_name,
            OPTION='TRIA6_7',
            #PREF_NOEUD='NT'
        ))

    dummod = AFFE_MODELE(
        MAILLAGE=tmpmesh,
        #VERIF='MAILLE',
        AFFE=(
            _F(
                GROUP_MA=(group_ma_name),  # '1out', '2in'),
                PHENOMENE='MECANIQUE',
                MODELISATION='COQUE_3D'), ),
    )

    dummat = DEFI_MATERIAU(ELAS=_F(
        E=210000.0,
        RHO=1,
        NU=0.0,
    ), )

    dmatass = AFFE_MATERIAU(
        MAILLAGE=tmpmesh,
        AFFE=_F(
            GROUP_MA=group_ma_name,
            MATER=dummat,
        ),
    )

    tmpcara = AFFE_CARA_ELEM(
        MODELE=dummod,
        COQUE=_F(
            GROUP_MA=group_ma_name,
            EPAIS=1.0,
        ),
    )

    tmptab = POST_ELEM(
        MASS_INER=_F(GROUP_MA=group_ma_name),
        CARA_ELEM=tmpcara,
        TITRE='tit_von_post_elem',
        MODELE=dummod,
        CHAM_MATER=dmatass,
    )
    #IMPR_TABLE(TABLE=tab_post,);
    print tmptab.EXTR_TABLE()
    A = tmptab['MASSE', 1]
    DETRUIRE(CONCEPT=(_F(NOM=(tmpmesh, dummod, dummat, dmatass, tmpcara,
                              tmptab))),
             INFO=1)
    return A
コード例 #21
0
 def BARRE(self):
     retour = []
     for grit, typeit in self.association.iteritems():
         carait = self.section_catalogue[typeit]
         retour.append(
             _F(GROUP_MA=gr,
                SECTION='GENERALE',
                CARA='A',
                VALE=carait[2][1]))
     return retour
コード例 #22
0
ファイル: catalogue_beta3.py プロジェクト: Irvise/ogaca
 def POUTRE(self):
     retour = []
     for grit, typeit in self.association.iteritems():
         carait = self.section_catalogue[typeit]
         #print carait
         retour.append(
             _F(GROUP_MA=grit,
                SECTION='GENERALE',
                CARA=self.__CARA,
                VALE=carait[2][:14]))
     return retour
コード例 #23
0
 def DDL_IMPO_NUT(self):
     from Accas import _F
     if self.nutface is None:
         return _F(GROUP_NO=self.beamnut,
                   DX=0.0,
                   DY=0.0,
                   DZ=0.0,
                   DRX=0.0,
                   DRY=0.0,
                   DRZ=0.0)
     else:
         return None
コード例 #24
0
def volume(mesh, group_ma_name):
    from Cata.cata import CREA_MAILLAGE, AFFE_MODELE, DEFI_MATERIAU, \
        AFFE_MATERIAU, AFFE_CARA_ELEM, POST_ELEM, DETRUIRE
    from Accas import _F

    dummod = AFFE_MODELE(
        MAILLAGE=mesh,
        #		    VERIF='MAILLE',
        AFFE=(
            _F(
                GROUP_MA=(group_ma_name),  # '1out', '2in'),
                PHENOMENE='MECANIQUE',
                MODELISATION='3D'), ),
    )

    dummat = DEFI_MATERIAU(ELAS=_F(
        E=210000.0,
        RHO=1,
        NU=0.0,
    ), )

    dmatass = AFFE_MATERIAU(
        MAILLAGE=mesh,
        AFFE=_F(
            GROUP_MA=group_ma_name,
            MATER=dummat,
        ),
    )

    tmptab = POST_ELEM(
        MASS_INER=_F(GROUP_MA=group_ma_name),
        TITRE='tit_von_post_elem',
        MODELE=dummod,
        CHAM_MATER=dmatass,
    )
    #IMPR_TABLE(TABLE=tab_post,);
    print tmptab.EXTR_TABLE()
    V = tmptab['MASSE', 1]
    DETRUIRE(CONCEPT=(_F(NOM=(dummod, dummat, dmatass, tmptab))), INFO=1)
    return V
コード例 #25
0
def macro_opti_sec_fn_prod_scalaire_grad_ops(self,retour,etat,grad1,grad2,**args):
    self.set_icmd(1)
    self.DeclareOut('retour',retour)
    CREA_TABLE	= self.get_cmd('CREA_TABLE')
    
    val=0.
    for i in range(0,len(etat["GMASECTIONPOSSIBLE"])):
        val=val+grad1['R',i+1]*grad2['R',i+1]


    retour=CREA_TABLE(LISTE=(	_F(PARA='R',LISTE_R=val)));
    print "ok"
    return 0
コード例 #26
0
ファイル: sup_gmsh2.py プロジェクト: freddupont/ogaca
  def LIRE_GMSH(self,
    UNITE_GMSH     = 19,
    UNITE_MAILLAGE = 20,
    MODI_QUAD      = 'NON',
    CREA_GROUP_NO  = 'OUI'
    ) :

    """
      Lecture du maillage (format Aster) a partir de sa definition
      (format sup_gmsh)
      UNITE_GMSH     = Numero d'unite logique pour le fichier msh
      UNITE_MAILLAGE = Numero d'unite logique pour le fichier mail
      MODI_QUAD      = 'OUI' si line->quad, 'NON' sinon
      CREA_GROUP_NO  = 'OUI' si on cree les group_no, 'NON' sinon
    """

    nom_gmsh = 'fort.' + repr(UNITE_GMSH)
    self.Create(nom_gmsh)

    PRE_GMSH(UNITE_GMSH=UNITE_GMSH, UNITE_MAILLAGE=UNITE_MAILLAGE)

    SMESH_00 = LIRE_MAILLAGE(UNITE = UNITE_MAILLAGE)
    DEFI_FICHIER(ACTION='LIBERER',UNITE = UNITE_GMSH)
    DEFI_FICHIER(ACTION='LIBERER',UNITE = UNITE_MAILLAGE)

    if MODI_QUAD == 'OUI' and self.order == 2 :
      raise 'The finite elements are already of second order'

    if MODI_QUAD == 'OUI' and self.order <> 2 :
      SMESH_01 = CREA_MAILLAGE(
        MAILLAGE = SMESH_00,
        LINE_QUAD = _F(TOUT = 'OUI')
        )
      DETRUIRE(CONCEPT=_F(NOM=SMESH_00), INFO=1)
      SMESH_00 = SMESH_01

    SMESH_00 = self.Name(SMESH_00,CREA_GROUP_NO)

    return SMESH_00
コード例 #27
0
ファイル: opti_section_poutre.py プロジェクト: Irvise/ogaca
def macro_opti_sec_fn_prod_scalaire_grad_ops(self, retour, etat, grad1, grad2,
                                             **args):
    self.set_icmd(1)
    self.DeclareOut('retour', retour)
    CREA_TABLE = self.get_cmd('CREA_TABLE')

    val = 0.
    for i in range(0, len(etat["GMASECTIONPOSSIBLE"])):
        val = val + grad1['R', i + 1] * grad2['R', i + 1]

    retour = CREA_TABLE(LISTE=(_F(PARA='R', LISTE_R=val)))
    print "ok"
    return 0
コード例 #28
0
ファイル: opti_xfem.py プロジェクト: freddupont/ogaca
def lvl_sav_op(self,MAILLAGE,CHAM_GD,NOM,ITER,para,**args):
	
	ier=0
	self.icmd=1
	FORMULE		= self.get_cmd('FORMULE')
	CREA_CHAMP	= self.get_cmd('CREA_CHAMP')
	CREA_RESU	= self.get_cmd('CREA_RESU')
	POST_ELEM	= self.get_cmd('POST_ELEM')
	DEFI_CONSTANTE	= self.get_cmd('DEFI_CONSTANTE')
	
	if ITER==-1:
		IMPR_RESU(FORMAT='MED',UNITE=81,RESU=_F(MAILLAGE=MAILLAGE,CHAM_GD=CHAM_GD,),);
		EXEC_LOGICIEL(LOGICIEL='cp fort.81 '+para['sortiepath']+NOM+'.i.med',);
		DEFI_FICHIER(ACTION='LIBERER',UNITE=81,)
		EXEC_LOGICIEL(LOGICIEL='rm fort.81 ')
	else :
		IMPR_RESU(FORMAT='MED',UNITE=81,RESU=_F(MAILLAGE=MAILLAGE,CHAM_GD=CHAM_GD,),);
		EXEC_LOGICIEL(LOGICIEL='cp fort.81 '+para['sortiepath']+NOM+'.i.med',);
		if ITER%para['freqsav']==0:
			EXEC_LOGICIEL(LOGICIEL='cp fort.81 '+para['sortiepath']+NOM+'.%d.med'%ITER,);
		DEFI_FICHIER(ACTION='LIBERER',UNITE=81,)
		EXEC_LOGICIEL(LOGICIEL='rm fort.81 ')
	
	return ier;
コード例 #29
0
 def LIAISON_RBE3_HEAD(self):
     from Accas import _F
     return _F(
         GROUP_NO_MAIT=self.beamhead,
         DDL_MAIT=(
             'DX',
             'DY',
             'DZ',
             'DRX',
             'DRY',
             'DRZ',
         ),
         GROUP_NO_ESCL=self.headface,
         DDL_ESCL='DX-DY-DZ',
         COEF_ESCL=1,
     )
コード例 #30
0
ファイル: catalogue_beta.py プロジェクト: freddupont/ogaca
 def POUTRE(self):
     retour=[]
     reverse_asso={}
     for grit,typeit in self.association.iteritems():
         if reverse_asso.has_key(typeit):
             if type(grit)==str:
                 reverse_asso[typeit].append(grit)
             else:
                 reverse_asso[typeit].extend(grit)
         else:
             reverse_asso[typeit]=[grit]
     for typeit,grit in reverse_asso.iteritems():
         carait=self.section_catalogue[typeit]
         #print carait
         retour.append(_F(GROUP_MA=grit,SECTION='GENERALE',CARA=self.__CARA,VALE=carait[2][:14]))
     return retour;
コード例 #31
0
def readMeshes(nMeshes):
    from Cata.cata import LIRE_MAILLAGE, ASSE_MAILLAGE, DETRUIRE
    from Accas import _F
    # read and assemble nMeshes mesh files (names are given in astk)
    m = [None] * nMeshes
    mesh = None
    for i in range(0, nMeshes):
        if i > 0:
            addmesh = LIRE_MAILLAGE(UNITE=20 + i, FORMAT='MED')
            m[i] = ASSE_MAILLAGE(MAILLAGE_1=m[i - 1],
                                 MAILLAGE_2=addmesh,
                                 OPERATION='SUPERPOSE')
            DETRUIRE(CONCEPT=(_F(NOM=(m[i - 1], addmesh))), INFO=1)
        else:
            m[i] = LIRE_MAILLAGE(UNITE=20 + i, FORMAT='MED')

    return m[nMeshes - 1]
コード例 #32
0
 def LIAISON_RBE3_NUT(self):
     from Accas import _F
     if not self.nutface is None:
         return _F(
             GROUP_NO_MAIT=self.beamnut,
             DDL_MAIT=(
                 'DX',
                 'DY',
                 'DZ',
                 'DRX',
                 'DRY',
                 'DRZ',
             ),
             GROUP_NO_ESCL=self.nutface,
             DDL_ESCL='DX-DY-DZ',
             COEF_ESCL=1,
         )
     else:
         return None
コード例 #33
0
ファイル: catalogue_beta.py プロジェクト: freddupont/ogaca
 def __section_generation_sec(self,sec,nom):
     __MAILT=self.__generation_maillage_aster(sec,nom)
     #IMPR_RESU(FORMAT='MED',UNITE=80,RESU=_F(MAILLAGE=__MAILT),);
     
     seccara=MACR_CARA_POUTRE(MAILLAGE=__MAILT,GROUP_MA_BORD='ext',GROUP_NO='GN');
     
     #IMPR_TABLE(TABLE=seccara)
     #on charge les valeur depuis la table aster
     Vex=[];
     rot=False
     for a in self.__EXTRACTION:
         Vex.append(seccara[a,2])
         #print a,seccara[a,2]
     if (Vex[14]>1e-5 or Vex[14]<-1e-5):
         print "attention angle alpha different de zero :"
         if (Vex[14]>46. or Vex[14]<-46.):
             print "Rotation de plus de 45 on corrige pour etre au plus proche du dessin initial"
             rot=True
             caratemp=[Vex[0],#AIRE
                       Vex[2],Vex[1],#'IY_PRIN_G','IZ_PRIN_G'
                       Vex[4],Vex[3],#'AY','AZ'
                       Vex[6],Vex[5],#'EY','EZ'
                       Vex[7],#'CT'
                       Vex[9],Vex[8],#'Y_MAX','Z_MAX'
                       Vex[10],Vex[11],#'RT','JG'
                       Vex[13],Vex[12],#'IYR2_PRIN_G','IZR2_PRIN_G'
                       Vex[14],Vex[15],Vex[16]]#'ALPHA','CDG_X','CDG_Y'
             Vex=caratemp
             if (Vex[14]<0):
                 Vex[14]=Vex[14]+90.
             else:
                 Vex[14]=Vex[14]-90.
             print "par default les section sont tourne de l angle ",Vex[14]
         else:
             print "par default les section sont tourne de l angle ",Vex[14]
     if (Vex[15]>1e-5 or Vex[15]<-1e-5 or Vex[16]>1e-5 or Vex[16]<-1e-5):
         print "attention centre de gravite excentre par rapport au dessin"
         print "CDG_X:",Vex[15]," CDG_Y:",Vex[16]
         print "Les poutres sont par default place sur leur centre de gravite"
     newsec=[sec[0],sec[1],Vex,rot];
     self.section_catalogue[nom]=newsec
     DETRUIRE(INFO=1,CONCEPT=_F(NOM=(__MAILT,seccara),));
コード例 #34
0
 def POUTRE(self):
     retour = []
     reverse_asso = {}
     for grit, typeit in self.association.iteritems():
         if reverse_asso.has_key(typeit):
             if type(grit) == str:
                 reverse_asso[typeit].append(grit)
             else:
                 reverse_asso[typeit].extend(grit)
         else:
             reverse_asso[typeit] = [grit]
     for typeit, grit in reverse_asso.iteritems():
         carait = self.section_catalogue[typeit]
         #print carait
         retour.append(
             _F(GROUP_MA=grit,
                SECTION='GENERALE',
                CARA=self.__CARA,
                VALE=carait[2][:14]))
     return retour
コード例 #35
0
def macro_opti_sec_gene_gr_ops(self,reuse,MAILLAGE,gr_ini,gr_cree,prefixe,**args):
    self.set_icmd(1)
    
    self.DeclareOut('MAILOUT',self.sd)


    mail_py=MAIL_PY();
    mail_py.FromAster(MAILLAGE);
    
    gr_cree['gr']=[]
    crea_gr=[]
    
    print "debug",mail_py.gma
    for gr in gr_ini['gr']:
        print "debug",gr
        for ma in mail_py.gma[gr]:
            crea_gr.append(_F(TYPE_MAILLE='1D',NOM="O"+str(ma+1),MAILLE='M'+str(ma+1)))
            gr_cree['gr'].append(prefixe+str(ma+1))

    MAILOUT=DEFI_GROUP(reuse=self.reuse,MAILLAGE=MAILLAGE,CREA_GROUP_MA=crea_gr)
    print "debug",gr_cree
    return 0
コード例 #36
0
def dynforces_ops(self, MODELE, MATR_MASS, MAILLAGE, FICHIER):
    # Define output and initialize error counter
    self.set_icmd(1)
    self.DeclareOut('CHDF', self.sd)

    model = MODELE
    matrm = MATR_MASS
    maillage = MAILLAGE
    fichier = FICHIER

    # create handler for mesh
    mm = MAIL_PY()
    mm.FromAster(maillage)

    # Noms des noeuds
    nodelabels = list(mm.correspondance_noeuds)
    nnodes = len(nodelabels)

    # right now, only read from file
    acc = dynforces_read_acc_from_file(fichier, mm)

    # multiply mass matrix times accelerations
    dynforces = dynforces_acc2frc(matrm, acc)

    # create dynamic loads right-hand side
    CHDF = AFFE_CHAR_MECA(MODELE=model,
                          FORCE_NODALE=([
                              _F(NOEUD=nodelabels[nn],
                                 FX=dynforces[nn][0],
                                 FY=dynforces[nn][1],
                                 FZ=dynforces[nn][2],
                                 MX=dynforces[nn][3],
                                 MY=dynforces[nn][4],
                                 MZ=dynforces[nn][5])
                              for nn in range(0, nnodes)
                          ]))
コード例 #37
0
def orientation_poutre_vy(GROUP_MA,MAILLAGE,MODELE,CARA_ELEM,CHAM_MATER,UNITE=80,SAUVEGARDE_CHAMP=True,RETOUR_TABLE=False,):
    """cree un fichier contenant un champs de l orientation local des poutres
    usage: orientation_poutre_vy(GROUP_MA,MAILLAGE,MODELE,CARA_ELEM,MATE,UNITE=80)
    """
    ######################################################
    #Champ local Y des poutres
    __CHVY=CREA_CHAMP(OPERATION='AFFE',TYPE_CHAM='ELNO_SIEF_R', MODELE=MODELE,PROL_ZERO='OUI',
                    AFFE=_F(GROUP_MA=GROUP_MA, NOM_CMP=('VY'),VALE=1.));
    __VYinst0=CREA_RESU(OPERATION='AFFE',
                     TYPE_RESU='EVOL_ELAS',
                     NOM_CHAM='SIEF_ELNO',
                     AFFE=_F(CHAM_GD=__CHVY,INST=-1)
                     )
    __DEPL=CREA_CHAMP(OPERATION='AFFE',TYPE_CHAM='NOEU_DEPL_R', MODELE=MODELE,PROL_ZERO='OUI',
                    AFFE=_F(TOUT='OUI', NOM_CMP=('DY'),VALE=1.));
    __VYinst0=CREA_RESU(reuse=__VYinst0,
                     OPERATION='AFFE',
                     TYPE_RESU='EVOL_ELAS',
                     NOM_CHAM='DEPL',
                     AFFE=_F(CHAM_GD=__DEPL,INST=-1)
                     )
    __VYinst0=CALC_ELEM(reuse =__VYinst0,
                   RESULTAT=__VYinst0,
                   MODELE=MODELE,
                   CHAM_MATER=CHAM_MATER,
                   CARA_ELEM=CARA_ELEM,
                   OPTION=('EFCA_ELNO'),);
    if (SAUVEGARDE_CHAMP):
	IMPR_RESU(FORMAT='MED',UNITE=UNITE,RESU=_F(MAILLAGE=MAILLAGE,RESULTAT=__VYi0,NOM_CHAM='EFCA_ELNO',),);
    if (RETOUR_TABLE):
        __CH=CREA_CHAMP(OPERATION='EXTR',RESULTAT=__VYinst0,TYPE_CHAM='ELNO_SIEF_R',NOM_CHAM='EFCA_ELNO',);
        #creation d un groupe contenant les noeuds hors du domaine
        __CHTX=__CH.EXTR_COMP('FX',[],1)
        __CHTY=__CH.EXTR_COMP('FY',[],1)
        __CHTZ=__CH.EXTR_COMP('FZ',[],1)
        
        inversionmail={}
        #output={}
        for i in range(0,len(__CHTX.maille)):
            if not(inversionmail.has_key(__CHTX.maille[i])):
                inversionmail[__CHTX.maille[i]]=[i]
                #output[__CHTX.maille[i]]=[__CHTX.valeurs[i]]
        for i in range(0,len(__CHTY.maille)):
            if inversionmail.has_key(__CHTY.maille[i]):
                if (len(inversionmail[__CHTY.maille[i]])==1):
                    inversionmail[__CHTY.maille[i]].append(i)
        for i in range(0,len(__CHTZ.maille)):
            if inversionmail.has_key(__CHTZ.maille[i]):
                if (len(inversionmail[__CHTZ.maille[i]])==2):
                    inversionmail[__CHTZ.maille[i]].append(i)
        
        output={}
        for k,v in inversionmail.iteritems():
            output[k]=numpy.array([__CHTX.valeurs[v[0]],__CHTY.valeurs[v[1]],__CHTZ.valeurs[v[2]]])
            assert(v[0]==v[1] and v[2]==v[1])
            
                
        #print "/n"*10
        #print __CHTX.__dict__;
        #print __CHTY.__dict__;
        #print __CHTZ.__dict__;
        #print inversionmail
        #print output
        DETRUIRE(INFO=1,CONCEPT=_F(NOM=(__CH),));
        DETRUIRE(INFO=1,CONCEPT=_F(NOM=(__CHVY,__VYinst0,__DEPL),));
        return output;
    DETRUIRE(INFO=1,CONCEPT=_F(NOM=(__CHVY,__VYinst0,__DEPL),));
コード例 #38
0
ファイル: opti_analytique.py プロジェクト: freddupont/ogaca
def macro_opti_ana_fn_detruire_gradient_ops(self,gradient,**args):
    self.set_icmd(1)
    DETRUIRE(INFO=1,CONCEPT=_F(NOM=(gradient),),ALARME='NON');
コード例 #39
0
ファイル: catalogue_beta3.py プロジェクト: freddupont/ogaca
 def section_generation_mail(self,nom,UNITE=80):
     v=self.section_catalogue[nom]
     __MAILT=self.__generation_maillage_aster(v,nom)
     IMPR_RESU(FORMAT='MED',UNITE=UNITE,RESU=_F(MAILLAGE=__MAILT),);
     DETRUIRE(INFO=1,CONCEPT=_F(NOM=(__MAILT),));
コード例 #40
0
ファイル: cms.py プロジェクト: EriveltonGualter/GSoC-MBDyn
def cms_write_mbdyn(data, maillage, cms_interface, cms_exposed_fact, \
		nshapes, ndynamic, sol_dynamic, nstatic, sol_static, \
		macm, mack, mmass):

	from Accas import _F

	# desired precision
	precision = data[1];

	diag_mass = (data[2] == 'OUI');
	rigb_mass = (data[3] == 'OUI');

        eps = data[4];
        
	# "cook" format specifiers based on precision
	IFMT = "%" + str(precision) + "d";
	RFMT = "%" + str(precision + 8) + "." + str(precision) + "e";

	# open output file
	# NOTE: overwrites existing files
	# NOTE: must be absolute path, otherwise I don't know
	# where it shows up...
	# if (data[0][0] != '/'):
	# 	print "***";
	# 	print "*** WARNING: MBDyn modal element data file needs absolute path"
	# 	print "***          file=\"" + data[0] + "\"";
	# 	print "***";
	outf = file(data[0], 'w');

	if (cms_exposed_fact['GROUP_NO'] != None):
		cms_exposed = cms_exposed_fact['GROUP_NO'];

	else:
		assert(cms_exposed_fact['TOUT'] == 'OUI');
		# NOTE: this name must be reserved to MBDyn (!?!)
		cms_exposed = 'MBDYN_TN';
		# NOTE: 1.e+38 to make sure we catch all (?!?)
		_ma = maillage

		# NOTE: hack to find out whether a mesh is 2D or 3D
		# create handler for mesh
		mm = MAIL_PY();
		mm.FromAster(maillage);

		# Coordonnees des noeuds
		coord = mm.cn;

		is_3D = 0;
		z0 = coord[0][2];
		for nn in range(1, mm.dime_maillage[0] - 1):
			if (coord[nn][2] != z0):
				is_3D = 1;
				break;

		if is_3D:
			# FIXME: only works if model is truly 3D :-(
			# TODO: test whether the mesh is 2D or z_cst
			_ma = DEFI_GROUP(reuse = _ma,
					 MAILLAGE = _ma,
						CREA_GROUP_NO = ( _F(
							NOM = cms_exposed,
							OPTION = 'ENV_SPHERE',
							POINT = ( 0.0, 0.0, 0.0 ),
							RAYON = 1.e+38,
							PRECISION = ( 1.e+38 ) ) ) );
		else:
			_ma = DEFI_GROUP(reuse = _ma,
					 MAILLAGE = _ma,
						CREA_GROUP_NO = ( _F(
							NOM = cms_exposed,
							OPTION = 'ENV_SPHERE',
							POINT = ( 0.0, 0.0 ),
							RAYON = 1.e+38,
							PRECISION = ( 1.e+38 ) ) ) );
		maillage = _ma;

	# create handler for mesh
	mm = MAIL_PY();
	mm.FromAster(maillage);

	# Coordonnees des noeuds
	coord = mm.cn;
	# Noms des noeuds
	linomno = list(mm.correspondance_noeuds);

	# Groupe de Noeuds
	exposed_id = mm.gno[cms_exposed];
	nexposed = len(exposed_id);

	# header
	outf.write("** MBDyn MODAL DATA FILE - generated by Aster\n");
	outf.write("** NODE SET '" + cms_exposed + "'\n");

	# record 1
	outf.write("** RECORD GROUP 1, HEADER\n");
	outf.write("**   REVISION,  NODE,  NORMAL, ATTACHMENT, CONSTRAINT, REJECTED MODES.\n");
	outf.write((" REV0       " + IFMT + "  " + IFMT + "  " + IFMT + "  " + IFMT + "  " + IFMT + "\n") \
		% (nexposed, ndynamic, nstatic, 0, 0) );
	outf.write("**\n");

	# record 2
	outf.write("** RECORD GROUP 2, FINITE ELEMENT NODE LIST\n")
	l = 0
	while l < nexposed:
		if ((l > 0) & ((l % 6) == 0)):
			outf.write("\n");
		outf.write(" " + linomno[exposed_id[l]]);
		l = l + 1;
	outf.write("\n");
	outf.write("**\n");

	# record 3 (optional, default to zero, so could be omitted)
	outf.write("** RECORD GROUP 3, INITIAL MODAL DISPLACEMENTS\n");
	for m in range(nshapes):
		if ((m > 0) & ((m % 6) == 0)):
			outf.write("\n");
		outf.write(RFMT % 0.0);
	outf.write("\n");
	outf.write("**\n");

	# record 4 (optional, default to zero, so could be omitted)
	outf.write("** RECORD GROUP 4, INITIAL MODAL VELOCITIES\n");
	for m in range(nshapes):
		if ((m > 0) & ((m % 6) == 0)):
			outf.write("\n");
		outf.write(RFMT % 0.0);
	outf.write("\n");
	outf.write("**\n");

	# record 5
	outf.write("** RECORD GROUP 5, NODAL X COORDINATES\n");
	n = 0;
	while n < nexposed:
		outf.write((RFMT + "\n") % coord[exposed_id[n]][0]);
		n = n + 1;
	outf.write("**\n");

	# record 6
	outf.write("** RECORD GROUP 6, NODAL Y COORDINATES\n");
	n = 0;
	while n < nexposed:
		outf.write((RFMT + "\n") % coord[exposed_id[n]][1]);
		n = n + 1;
	outf.write("**\n");

	# record 7
	outf.write("** RECORD GROUP 7, NODAL Z COORDINATES\n");
	n = 0;
	while n < nexposed:
		outf.write((RFMT + "\n") % coord[exposed_id[n]][2]);
		n = n + 1;
	outf.write("**\n");

	# record 8
	outf.write("** RECORD GROUP 8, MODE SHAPES\n");

	for m in range(ndynamic):
                idx = 0;
                _sd_tab = POST_RELEVE_T( ACTION = _F(INTITULE = 'Normal modes',
						GROUP_NO = cms_exposed,
						RESULTAT = sol_dynamic,
						NOM_CHAM = 'DEPL',
					             NUME_ORDRE = (m + 1,),
						TOUT_CMP = 'OUI',
						OPERATION = 'EXTRACTION' ) );

                # extract normal modes
                modes_sd = cms_extract_mode_shape(_sd_tab, eps);
                
		outf.write("**    NORMAL MODE SHAPE #  %d\n" % (m + 1));
		n = 0;
		while n < nexposed:
                        for j in range(modes_sd.shape[1]):
                                outf.write(RFMT % modes_sd[idx, j]);
                                
                        outf.write("\n");
                        
			n = n + 1;
			idx = idx + 1;

                del _sd_tab;
                del modes_sd;


	if nstatic > 0:
		for m in range(nstatic):
                        _ss_tab = POST_RELEVE_T(ACTION = _F(INTITULE = 'Static Shapes',
							GROUP_NO = cms_exposed,
							RESULTAT = sol_static,
                                                            NUME_ORDRE = (m + 1,),
							NOM_CHAM = 'DEPL',
							TOUT_CMP = 'OUI',
							OPERATION = 'EXTRACTION' ) );

                        # extract static shapes
                        modes_ss = cms_extract_mode_shape(_ss_tab, eps);

		idx = 0;
			outf.write("**    NORMAL MODE SHAPE #  %d (STATIC SHAPE #  %d)\n" % (ndynamic + m + 1, m + 1));
			n = 0;
			while n < nexposed:
                                for j in range(modes_ss.shape[1]):
                                        outf.write(RFMT % modes_ss[idx, j]);
                                
                                outf.write("\n");
                        
				n = n + 1;
				idx = idx + 1;

                        del _ss_tab;
                        del modes_ss;
コード例 #41
0
ファイル: opti_xfem.py プロジェクト: freddupont/ogaca
def xfem_dfo_compliance_ops(self,MAIL,MAILX,MODEX,MODEV,EXCIT,CHMATE,CHMATEV,NCAS,CHCOM,para,**args):
	ier=0
	self.icmd=1
	FORMULE		= self.get_cmd('FORMULE')
	CREA_CHAMP	= self.get_cmd('CREA_CHAMP')
	CREA_RESU	= self.get_cmd('CREA_RESU')
	POST_ELEM	= self.get_cmd('POST_ELEM')
	STAT_NON_LINE	= self.get_cmd('STAT_NON_LINE')
	DEFI_LIST_REEL	= self.get_cmd('DEFI_LIST_REEL')
	POST_CHAM_XFEM	= self.get_cmd('POST_CHAM_XFEM')
	CALC_ELEM	= self.get_cmd('CALC_ELEM')
	#STAT_NON_LINE	= self.get_cmd('STAT_NON_LINE')
	#STAT_NON_LINE	= self.get_cmd('STAT_NON_LINE')
	
	self.DeclareOut('compl',self.sd)
	self.DeclareOut('CHCOM',CHCOM)
	
	#Determination du volume en dehors de la forme
	
	#debug
	fopti=file('fort.3',"a");
	fopti.write( "lvl.dfo_compliance: entre dans la boucle");
	fopti.close();
	EXEC_LOGICIEL(LOGICIEL='cp fort.3 '+para['sortiepath']+'opti.temp.mess',);#sauvegarde du fichier


	############################################
	#Fonction dfo_compliance
	############################################

	#intitialisation xfem
	
	__L_INST=DEFI_LIST_REEL(DEBUT=0.0,
                      INTERVALLE=_F(JUSQU_A=1.0,
                                    NOMBRE=1),);


	###############
	##Calcul elastique fonction de la level set
	motscles={}	
	motscles['EXCIT']=[]
        for chargt in EXCIT   : motscles['EXCIT'].append(_F(CHARGE=chargt['CHARGE'],),)
	
	__RESUSTAT=STAT_NON_LINE(MODELE=MODEX,
			CHAM_MATER=CHMATE,
			COMP_ELAS=_F(RELATION='ELAS',
					TOUT='OUI',),
			INCREMENT=_F(LIST_INST=__L_INST),
			INFO=1,
			**motscles);

	__RES_XFEM=POST_CHAM_XFEM(MAILLAGE_SAIN = MAIL,
                        MAILLAGE_FISS = MAILX,
                        MODELE        = MODEX,
                        MODELE_VISU   = MODEV,
                        RESULTAT      = __RESUSTAT,
                        NOM_CHAM      = ('DEPL','SIEF_ELGA'),
                        INFO          = 1);
	
        #pour gagner du tepms pour le debugage
	#__RES_XFEM=LIRE_RESU(TYPE_RESU='EVOL_NOLI',UNITE=82,TOUT_ORDRE='OUI',
			#FORMAT='MED',MODELE=MODEV,
			#FORMAT_MED=(
				#_F(NOM_CHAM_MED='.9000034DEPL____________________',NOM_CHAM='DEPL'),
				#_F(NOM_CHAM_MED='.9000034SIEF_ELGA_______________',NOM_CHAM='SIEF_ELGA'),),
			#INFO=1);
			
	__RES_XFEM=CALC_ELEM(reuse =__RES_XFEM,
			RESULTAT=__RES_XFEM,
			#MODELE        = MOD_VISU,
			#GROUP_MA='MAFRPO',
			CHAM_MATER=CHMATEV,
			OPTION=('EPSI_ELGA_DEPL','EQUI_ELGA_SIGM'));
	

        #debug on saute l etape du calcul
	fopti=file('fort.3',"a");
	fopti.write( "lvl.dfo_compliance: etape 2\n");
	fopti.close();
	EXEC_LOGICIEL(LOGICIEL='cp fort.3 '+para['sortiepath']+'opti.temp.mess',);#sauvegarde du fichier

	IMPR_RESU(FORMAT='MED',UNITE=81,RESU=_F(MAILLAGE=MAILX,RESULTAT=__RES_XFEM,NOM_CHAM=('DEPL','SIEF_ELGA','EPSI_ELGA_DEPL','EQUI_ELGA_SIGM'),),);
	EXEC_LOGICIEL(LOGICIEL='cp fort.81 '+para['sortiepath']+'mecastat%d.i.med'%NCAS,);#sauvegarde du fichier
	DEFI_FICHIER(ACTION='LIBERER',UNITE=81,)
	EXEC_LOGICIEL(LOGICIEL='rm fort.81 ')
        

	#fin d un calcul elastique on indique les principaux resultats
	freselas=file('fort.11',"a");
	freselas.write( "resultat du calcul elastique pour le cas de charge %d\n"%(NCAS));
	freselas.close();
	
	__depl2=POST_ELEM(MINMAX=_F(TOUT='OUI',
                              NOM_CHAM='DEPL',
			      RESULTAT=__RES_XFEM,
                              NOM_CMP=('DX','DY','DZ'),),);
	IMPR_TABLE(TABLE=__depl2,UNITE=11);
	
	fopti=file('fort.3',"a");
	fopti.write( "lvl.dfo_compliance: depl2\n");
	fopti.close();
	EXEC_LOGICIEL(LOGICIEL='cp fort.3 '+para['sortiepath']+'opti.temp.mess',);#sauvegarde du fichier


	__cont=POST_ELEM(MINMAX=_F(GROUP_MA='MAP',
                              RESULTAT=__RES_XFEM,
                              NOM_CHAM='EQUI_ELGA_SIGM',NOM_CMP='VMIS'));
	IMPR_TABLE(TABLE=__cont,UNITE=11);

	fopti=file('fort.3',"a");
	fopti.write( "lvl.dfo_compliance: cont\n");
	fopti.close();
	EXEC_LOGICIEL(LOGICIEL='cp fort.3 '+para['sortiepath']+'opti.temp.mess',);#sauvegarde du fichier
	
	



	#F
	fopti=file('fort.3',"a");
	fopti.write( "lvl.dfo_compliance: debut siefnodeplno\n");
	fopti.close();
	EXEC_LOGICIEL(LOGICIEL='cp fort.3 '+para['sortiepath']+'opti.temp.mess',);#sauvegarde du fichier
	
	##Calcul l energie elastique
	
	#la recuperation du travail exterieur plante lamentablement
	#__RES_XFEM=CALC_NO(reuse =__RES_XFEM,
		#RESULTAT=__RES_XFEM,
		#CHAM_MATER=CHMATEV,
		#OPTION=('FORC_NODA'));
	
	
	#__enrgelas=POST_ELEM(RESULTAT=__RES_XFEM,
				#TRAV_EXT=_F(),INFO=2);
	#IMPR_TABLE(TABLE=__enrgelas,UNITE=11);

	
	###le calcul a partir des champs elga
	#__SIEFga=CREA_CHAMP(TYPE_CHAM='ELGA_SIEF_R', OPERATION='EXTR',RESULTAT=__RES_XFEM,NOM_CHAM='SIEF_ELGA',);
	#__EPSIga=CREA_CHAMP(TYPE_CHAM='ELGA_EPSI_R', OPERATION='EXTR',RESULTAT=__RES_XFEM,NOM_CHAM='EPSI_ELGA_DEPL',);
	
	################################
	###fonction opti vale compliance
	#__FENR= FORMULE(NOM_PARA= ('EPXX', 'EPYY', 'EPZZ','EPYZ', 'EPXY', 'EPXZ','SIXX','SIXY','SIXZ','SIYY','SIYZ','SIZZ',),
		#VALE='(EPXX*SIXX+EPYY*SIYY+EPZZ*SIZZ+2*(EPXY*SIXY+EPYZ*SIYZ+EPXZ*SIXZ))');
	
	#__CHFENR=CREA_CHAMP(OPERATION='AFFE',TYPE_CHAM='ELGA_NEUT_F', MODELE=MODEV,PROL_ZERO='OUI',
		#AFFE=_F(GROUP_MA='MAP', NOM_CMP=('X1'),VALE_F=__FENR));
	
	#__CHENRS=CREA_CHAMP( OPERATION='EVAL', TYPE_CHAM='ELGA_NEUT_R', CHAM_F=__CHFENR, CHAM_PARA=(__SIEFga,__EPSIga));

	#__CHENRS2=CREA_CHAMP(OPERATION='ASSE', TYPE_CHAM='ELGA_SIEF_R',MODELE=MODEV, PROL_ZERO='OUI', ASSE=_F(GROUP_MA='MAP', CHAM_GD=__CHENRS,NOM_CMP=('X1',), NOM_CMP_RESU = ('SIXX',)), )

	#__resucom=CREA_RESU(OPERATION='AFFE',TYPE_RESU='EVOL_ELAS',NOM_CHAM='SIEF_ELGA',AFFE=_F(CHAM_GD=__CHENRS2,MODELE=MODEV,INST=1),);


	#__compl1=POST_ELEM(MODELE=MODEV,RESULTAT=__resucom, INTEGRALE=_F(GROUP_MA='MAP',NOM_CHAM ='SIEF_ELGA',NOM_CMP ='SIXX'),);
	#tatemp=__compl1.EXTR_TABLE();
	#comp=tatemp.INTE_SIXX[0];
	#compl=CREA_TABLE(LISTE=(	_F(PARA='casdecharge',LISTE_I=(NCAS,),),
					#_F(PARA='critere',LISTE_R=(comp,),),
		#),);
	
	
	
	__RES_XFEM=CALC_ELEM(reuse =__RES_XFEM,
			RESULTAT=__RES_XFEM,
			#MODELE        = MOD_VISU,
			CHAM_MATER=CHMATEV,
			OPTION=('EPSI_ELNO_DEPL','SIEF_ELNO_ELGA'));
		
	#calcul a partir des champ elno
	__SIEFno=CREA_CHAMP(TYPE_CHAM='ELNO_SIEF_R', OPERATION='EXTR',RESULTAT=__RES_XFEM,NOM_CHAM='SIEF_ELNO_ELGA',);
	__EPSIno=CREA_CHAMP(TYPE_CHAM='ELNO_EPSI_R', OPERATION='EXTR',RESULTAT=__RES_XFEM,NOM_CHAM='EPSI_ELNO_DEPL',);
	
	###############################
	##fonction opti vale compliance
	__FENR= FORMULE(NOM_PARA= ('EPXX', 'EPYY', 'EPZZ','EPYZ', 'EPXY', 'EPXZ','SIXX','SIXY','SIXZ','SIYY','SIYZ','SIZZ',),
		VALE='(EPXX*SIXX+EPYY*SIYY+EPZZ*SIZZ+2*(EPXY*SIXY+EPYZ*SIYZ+EPXZ*SIXZ))');
	
	__CHFENR=CREA_CHAMP(OPERATION='AFFE',TYPE_CHAM='ELNO_NEUT_F', MODELE=MODEV,PROL_ZERO='OUI',
		AFFE=_F(GROUP_MA='MAP', NOM_CMP=('X1'),VALE_F=__FENR));
	
	__CHENRS=CREA_CHAMP( OPERATION='EVAL', TYPE_CHAM='ELNO_NEUT_R', CHAM_F=__CHFENR, CHAM_PARA=(__SIEFno,__EPSIno));

	__CHENRS2=CREA_CHAMP(OPERATION='ASSE', TYPE_CHAM='ELNO_SIEF_R',MODELE=MODEV, PROL_ZERO='OUI', ASSE=_F(GROUP_MA='MAP', CHAM_GD=__CHENRS,NOM_CMP=('X1',), NOM_CMP_RESU = ('SIXX',)), )

	__resucom=CREA_RESU(OPERATION='AFFE',TYPE_RESU='EVOL_ELAS',NOM_CHAM='SIEF_ELNO',AFFE=_F(CHAM_GD=__CHENRS2,MODELE=MODEV,INST=1),);


	__compl1=POST_ELEM(MODELE=MODEV,RESULTAT=__resucom, INTEGRALE=_F(GROUP_MA='MAP',NOM_CHAM ='SIEF_ELNO',NOM_CMP ='SIXX'),);
	tatemp=__compl1.EXTR_TABLE();
	comp=tatemp.INTE_SIXX[0];
	compl=CREA_TABLE(LISTE=(	_F(PARA='casdecharge',LISTE_I=(NCAS,),),
					_F(PARA='critere',LISTE_R=(comp,),),
		),);
	
	###############################
	##fin opti vale compliance
	#enregistrement de la valeur
	fopti=file('fort.11',"a");
	fopti.write( "lvl.dfo_compliance: Compliance :%g\n" %(comp));
	fopti.close();
	
	

	#debug
	fopti=file('fort.3',"a");
	fopti.write( "lvl.dfo_compliance: Compliance :%g\n" %(comp));
	fopti.close();
	EXEC_LOGICIEL(LOGICIEL='cp fort.3 '+para['sortiepath']+'opti.temp.mess',);#sauvegarde du fichier

	
	#calcul du champs
	#__RESUSTAT=CALC_NO(reuse =__RESUSTAT,RESULTAT=__RESUSTAT,OPTION='EPSI_NOEU_DEPL',EXCIT=_F(CHARGE=CHARGE,),);
	__EPSI=CREA_CHAMP(TYPE_CHAM='ELNO_EPSI_R', OPERATION='EXTR',RESULTAT=__RES_XFEM,NOM_CHAM='EPSI_ELNO_DEPL',);
	
	#################################
	__FMULT1= FORMULE(NOM_PARA= ('EPXX', 'EPYY', 'EPZZ','EPYZ', 'EPXY', 'EPXZ'), 
		VALE="para['Lambda']*(EPXX+EPYY+EPZZ)**2+para['Mu']*2.*(EPXX*EPXX+EPYY*EPYY+EPZZ*EPZZ+2*(EPXY+EPXZ+EPYZ)**2)")

	__CHFMU1=CREA_CHAMP(OPERATION='AFFE',TYPE_CHAM='ELNO_NEUT_F', MODELE=MODEV,PROL_ZERO='OUI',
		AFFE=_F(GROUP_MA='MAFRPO', NOM_CMP=('X1'),VALE_F=(__FMULT1)));
	
	#CHCOM=CREA_CHAMP( OPERATION='EVAL', TYPE_CHAM='NOEU_NEUT_R', CHAM_F=__CHFMU1, CHAM_PARA=(__EPSI,__CHYOUNG));
	CHCOM=CREA_CHAMP( OPERATION='EVAL', TYPE_CHAM='ELNO_NEUT_R', CHAM_F=__CHFMU1, CHAM_PARA=(__EPSI),INFO=1);
	
	#IMPR_CO(CONCEPT=_F(NOM=CHCOM));
	
	##calcul du champs
	#__RESUSTAT=CALC_NO(reuse =__RESUSTAT,RESULTAT=__RESUSTAT,OPTION='EPSI_NOEU_DEPL',EXCIT=_F(CHARGE=CHARGE,),);
	#__EPSI=CREA_CHAMP(TYPE_CHAM='NOEU_EPSI_R', OPERATION='EXTR',RESULTAT=__RESUSTAT,NOM_CHAM='EPSI_NOEU_DEPL',);
	
	##################################
	#__FMULT1= FORMULE(NOM_PARA= ('EPXX', 'EPYY', 'EPZZ','EPYZ', 'EPXY', 'EPXZ'), 
		#VALE="para['Lambda']*(EPXX+EPYY+EPZZ)**2+para['Mu']*2.*(EPXX*EPXX+EPYY*EPYY+EPZZ*EPZZ+2*(EPXY+EPXZ+EPYZ)**2)")

	#__CHFMU1=CREA_CHAMP(OPERATION='AFFE',TYPE_CHAM='NOEU_NEUT_F', MODELE=MODEMEC,PROL_ZERO='OUI',
		#AFFE=_F(TOUT='OUI', NOM_CMP=('X1'),VALE_F=__FMULT1));
	
	##CHCOM=CREA_CHAMP( OPERATION='EVAL', TYPE_CHAM='NOEU_NEUT_R', CHAM_F=__CHFMU1, CHAM_PARA=(__EPSI,__CHYOUNG));
	#CHCOM=CREA_CHAMP( OPERATION='EVAL', TYPE_CHAM='NOEU_NEUT_R', CHAM_F=__CHFMU1, CHAM_PARA=(__EPSI));
	

	############################################
	#Fin dfo_compliance
	############################################
		
	return ier
コード例 #42
0
def macro_opti_sec_crit_compliance_ops(self,valeur,etat,gradient,fn_para,**args):
    self.set_icmd(1)
    self.DeclareOut('valeur',valeur)
    CREA_TABLE	= self.get_cmd('CREA_TABLE')
    
    
    __CAREL=AFFE_CARA_ELEM(MODELE=etat["MODELE"],
                         INFO=1,
                         POUTRE=etat["CATALOGUE"].POUTRE()
                        )
    __Resu=MECA_STATIQUE(MODELE=etat["MODELE"],
                        CHAM_MATER=etat["CHAM_MATER"],
                        CARA_ELEM=__CAREL,
                        INST=0,
                        EXCIT=_F(CHARGE=fn_para["CHARGE"],),
                        );
    
    __tener=POST_ELEM(RESULTAT=__Resu,
                    MODELE=etat["MODELE"],
                    CHAM_MATER=etat["CHAM_MATER"],
                    CARA_ELEM=__CAREL,
                    ENER_POT=_F(TOUT='OUI'))
    valeurret=__tener['TOTALE',1]

    valeur=CREA_TABLE(LISTE=(	_F(PARA='R',LISTE_R=(valeurret,))));
    aster.affiche('MESSAGE',  'macro_opti_sec_crit_compliance:Valeur du retour c%f'%valeur["R",1])
    
    if (gradient==None):
        #print "macro_opti_sec_crit3_ops:no grad"
        return 0
    else:
        #print "macro_opti_sec_crit3_ops:grad"
        #print "test1"
        self.DeclareOut('gradient',gradient)
        
        
        __Resu=CALC_ELEM(reuse =__Resu,
                     RESULTAT=__Resu,
                     TOUT_ORDRE='OUI',
                     OPTION=('SIEF_ELNO','DEGE_ELNO'))#'EPSI_ELNO','EPSI_ELGA'))#SIGM_ELNO_DEPL
        
        
        __CHSIPO=CREA_CHAMP(OPERATION='EXTR',RESULTAT=__Resu,TYPE_CHAM='ELNO_SIEF_R',NOM_CHAM='SIEF_ELNO',INFO=1);
        __CHDEGE=CREA_CHAMP(OPERATION='EXTR',RESULTAT=__Resu,TYPE_CHAM='ELNO_EPSI_R',NOM_CHAM='DEGE_ELNO',INFO=1);
    
        __FE= FORMULE(NOM_PARA= ('N','EPXX','VY','GAXY','VZ','GAXZ','MT','GAT','MFY','KY','MFZ','KZ'),
                      VALE=("(N*EPXX+VY*GAXY+VZ*GAXZ+MT*GAT+MFY*KY+MFZ*KZ)/2."))
        __CHFE=CREA_CHAMP(OPERATION='AFFE',TYPE_CHAM='ELNO_NEUT_F', MODELE=etat["MODELE"],PROL_ZERO='OUI',
                        AFFE=_F(TOUT='OUI', NOM_CMP=('X1'),VALE_F=(__FE,)));
        
        __CHE=CREA_CHAMP( OPERATION='EVAL', TYPE_CHAM='ELNO_NEUT_R', CHAM_F=__CHFE, CHAM_PARA=(__CHSIPO,__CHDEGE));
        
        IMPR_RESU(FORMAT='MED',UNITE=80,RESU=_F(MAILLAGE=etat["MAIL"],CHAM_GD=__CHE,),);
        
        tgradient=[]
        for gmaopti in etat["GMASECTIONPOSSIBLE"]:
            CHTEN=0
            if type(gmaopti[0])==str:
                CHTEN=__CHE.EXTR_COMP('X1',[gmaopti[0]],1)
            else:
                CHTEN=__CHE.EXTR_COMP('X1',list(gmaopti[0]),1)
            Emoy=0
            if (len(CHTEN.valeurs)>0):
                Emoy=sum(CHTEN.valeurs)/len(CHTEN.valeurs)
                
            tgradient.append(Emoy)
            #print tgradient
        #print tgradient
        #print sum(tgradient)/len(tgradient)
        #print valeurret

        gradient=CREA_TABLE(LISTE=(	_F(PARA='R',LISTE_R=tgradient)));
        #print "gradient['R',1]",gradient['R',1]
        return 0
コード例 #43
0
ファイル: opti_section_poutre.py プロジェクト: Irvise/ogaca
def macro_opti_sec_crit_verif_local_ops(self, valeur, etat, gradient, fn_para,
                                        **args):
    self.set_icmd(1)
    self.DeclareOut('valeur', valeur)
    CREA_TABLE = self.get_cmd('CREA_TABLE')

    __CAREL = AFFE_CARA_ELEM(
        MODELE=etat["MODELE"],
        INFO=1,
        POUTRE=etat["CATALOGUE"].POUTRE(),
    )
    __Resu = MECA_STATIQUE(
        MODELE=etat["MODELE"],
        CHAM_MATER=etat["CHAM_MATER"],
        CARA_ELEM=__CAREL,
        INST=0,
        EXCIT=_F(CHARGE=fn_para["CHARGE"], ),
    )
    #__Resu=CALC_ELEM(reuse =__Resu,
    #             RESULTAT=__Resu,
    #             TOUT_ORDRE='OUI',
    #             OPTION=('SIEF_ELNO','SIPO_ELNO'))#SIGM_ELNO_DEPL

    #IMPR_RESU(FORMAT='MED',UNITE=80,RESU=_F(MAILLAGE=etat["MAIL"],RESULTAT=__Resu,),);
    #IMPR_RESU(FORMAT='RESULTAT',RESU=_F(MAILLAGE=etat["MAIL"],RESULTAT=__Resu,),);

    __CH = CREA_CHAMP(OPERATION='EXTR',
                      RESULTAT=__Resu,
                      TYPE_CHAM='ELGA_SIEF_R',
                      NOM_CHAM='SIEF_ELGA',
                      INFO=1)
    #ou ELGA ou ELNO?
    sigmamaxr = fn_para["sigmamax"]  #r pour resistance et d pour design
    sigmaminr = fn_para["sigmamin"]
    tgradient = []
    #on parcours tout les groupes a optimiser
    for gmaopti in etat["GMASECTIONPOSSIBLE"]:

        #on recupere tout les champs d'effort
        li = 0
        if type(gmaopti[0]) == str:
            li = [gmaopti[0]]
        else:
            li = list(gmaopti[0])
        CHTN = __CH.EXTR_COMP('N', li, 1)
        CHTMFY = __CH.EXTR_COMP('MFY', li, 1)
        CHTMFZ = __CH.EXTR_COMP('MFZ', li, 1)

        #on recupere les caracteristique de la section courrante
        listesection = gmaopti[1]
        nomsecactuel = etat["CATALOGUE"].association[gmaopti[0]]
        #position de cette section dans la liste
        ii = listesection.index(nomsecactuel)

        section_cara = etat["CATALOGUE"].get_section_cara_from_sectionname(
            nomsecactuel)
        smaxd = 0
        smind = 0
        for i in range(0, len(CHTN.maille)):
            stress = etat["CATALOGUE"].section_cara_contrainte(
                section_cara, CHTN.valeurs[i], CHTMFY.valeurs[i],
                CHTMFZ.valeurs[i])
            smind = min(smind, stress[0])
            smaxd = max(smaxd, stress[1])
            #print "debug ini",ii
            #print gmaopti[0],i,CHTN.valeurs[i],CHTMFY.valeurs[i],CHTMFZ.valeurs[i]
            #print stress
        aa = 0.
        if (smaxd > sigmamaxr or smind < sigmaminr):
            #print "debug section not ok"
            aa = 1
        else:
            #print "debug section ok"
            aa = -1

        cont = True

        while (cont):
            if ii + aa > len(listesection) - 1:
                cont = False
            elif ii + aa < 0:
                aa = aa + 1
                cont = False
            else:
                section_cara = etat[
                    "CATALOGUE"].get_section_cara_from_sectionname(
                        listesection[ii + aa])
                smaxd = 0
                smind = 0
                for i in range(0, len(CHTN.maille)):
                    stress = etat["CATALOGUE"].section_cara_contrainte(
                        section_cara, CHTN.valeurs[i], CHTMFY.valeurs[i],
                        CHTMFZ.valeurs[i])
                    smind = min(smind, stress[0])
                    smaxd = max(smaxd, stress[1])
                #print "debug try",ii+aa
                #print gmaopti[0],smind,smaxd
                if aa > 0:
                    if not (smaxd > sigmamaxr or smind < sigmaminr):
                        #print "debug trouve ok"
                        cont = False
                    else:
                        aa = aa + 1
                else:
                    if (smaxd > sigmamaxr or smind < sigmaminr):
                        #print "debug trouve notok"
                        aa = aa + 1
                        cont = False
                    else:
                        aa = aa - 1

        tgradient.append(-aa)
        #print "debug fin aa=",aa

    valeurret = 0.
    for a in tgradient:
        valeurret = valeurret - a
    #modif ici

    #print etat["GMASECTIONPOSSIBLE"]
    #aster.affiche('RESULTAT', "tgradient"+str(tgradient))
    #aster.affiche('RESULTAT', str(valeurret))
    #print valeurret

    valeur = CREA_TABLE(LISTE=(_F(PARA='R', LISTE_R=(valeurret, ))))
    aster.affiche(
        'MESSAGE', 'macro_opti_sec_crit_verif_local:Valeur du retour c%f' %
        valeur["R", 1])
    if (gradient == None):
        #print "macro_opti_sec_crit3_ops:no grad"
        return 0
    else:
        #print "macro_opti_sec_crit3_ops:grad"
        #print "test1"
        self.DeclareOut('gradient', gradient)
        #print "test2"
        gradient = CREA_TABLE(LISTE=(_F(PARA='R', LISTE_R=tgradient)))
        #print "gradient['R',1]",gradient['R',1]
        return 0
コード例 #44
0
ファイル: opti_analytique.py プロジェクト: freddupont/ogaca
def macro_opti_ana_fn_detruire_table_ops(self,table,**args):
    self.set_icmd(1)
    DETRUIRE(INFO=1,CONCEPT=_F(NOM=(table),),ALARME='NON');
コード例 #45
0
ファイル: opti_section_poutre.py プロジェクト: Irvise/ogaca
def macro_opti_sec_crit_compliance_ops(self, valeur, etat, gradient, fn_para,
                                       **args):
    self.set_icmd(1)
    self.DeclareOut('valeur', valeur)
    CREA_TABLE = self.get_cmd('CREA_TABLE')

    __CAREL = AFFE_CARA_ELEM(MODELE=etat["MODELE"],
                             INFO=1,
                             POUTRE=etat["CATALOGUE"].POUTRE())
    __Resu = MECA_STATIQUE(
        MODELE=etat["MODELE"],
        CHAM_MATER=etat["CHAM_MATER"],
        CARA_ELEM=__CAREL,
        INST=0,
        EXCIT=_F(CHARGE=fn_para["CHARGE"], ),
    )

    __tener = POST_ELEM(RESULTAT=__Resu,
                        MODELE=etat["MODELE"],
                        CHAM_MATER=etat["CHAM_MATER"],
                        CARA_ELEM=__CAREL,
                        ENER_POT=_F(TOUT='OUI'))
    valeurret = __tener['TOTALE', 1]

    valeur = CREA_TABLE(LISTE=(_F(PARA='R', LISTE_R=(valeurret, ))))
    aster.affiche(
        'MESSAGE',
        'macro_opti_sec_crit_compliance:Valeur du retour c%f' % valeur["R", 1])

    if (gradient == None):
        #print "macro_opti_sec_crit3_ops:no grad"
        return 0
    else:
        #print "macro_opti_sec_crit3_ops:grad"
        #print "test1"
        self.DeclareOut('gradient', gradient)

        __Resu = CALC_ELEM(
            reuse=__Resu,
            RESULTAT=__Resu,
            TOUT_ORDRE='OUI',
            OPTION=('SIEF_ELNO',
                    'DEGE_ELNO'))  #'EPSI_ELNO','EPSI_ELGA'))#SIGM_ELNO_DEPL

        __CHSIPO = CREA_CHAMP(OPERATION='EXTR',
                              RESULTAT=__Resu,
                              TYPE_CHAM='ELNO_SIEF_R',
                              NOM_CHAM='SIEF_ELNO',
                              INFO=1)
        __CHDEGE = CREA_CHAMP(OPERATION='EXTR',
                              RESULTAT=__Resu,
                              TYPE_CHAM='ELNO_EPSI_R',
                              NOM_CHAM='DEGE_ELNO',
                              INFO=1)

        __FE = FORMULE(
            NOM_PARA=('N', 'EPXX', 'VY', 'GAXY', 'VZ', 'GAXZ', 'MT', 'GAT',
                      'MFY', 'KY', 'MFZ', 'KZ'),
            VALE=("(N*EPXX+VY*GAXY+VZ*GAXZ+MT*GAT+MFY*KY+MFZ*KZ)/2."))
        __CHFE = CREA_CHAMP(OPERATION='AFFE',
                            TYPE_CHAM='ELNO_NEUT_F',
                            MODELE=etat["MODELE"],
                            PROL_ZERO='OUI',
                            AFFE=_F(TOUT='OUI',
                                    NOM_CMP=('X1'),
                                    VALE_F=(__FE, )))

        __CHE = CREA_CHAMP(OPERATION='EVAL',
                           TYPE_CHAM='ELNO_NEUT_R',
                           CHAM_F=__CHFE,
                           CHAM_PARA=(__CHSIPO, __CHDEGE))

        IMPR_RESU(
            FORMAT='MED',
            UNITE=80,
            RESU=_F(
                MAILLAGE=etat["MAIL"],
                CHAM_GD=__CHE,
            ),
        )

        tgradient = []
        for gmaopti in etat["GMASECTIONPOSSIBLE"]:
            CHTEN = 0
            if type(gmaopti[0]) == str:
                CHTEN = __CHE.EXTR_COMP('X1', [gmaopti[0]], 1)
            else:
                CHTEN = __CHE.EXTR_COMP('X1', list(gmaopti[0]), 1)
            Emoy = 0
            if (len(CHTEN.valeurs) > 0):
                Emoy = sum(CHTEN.valeurs) / len(CHTEN.valeurs)

            tgradient.append(Emoy)
            #print tgradient
        #print tgradient
        #print sum(tgradient)/len(tgradient)
        #print valeurret

        gradient = CREA_TABLE(LISTE=(_F(PARA='R', LISTE_R=tgradient)))
        #print "gradient['R',1]",gradient['R',1]
        return 0
コード例 #46
0
ファイル: opti_analytique.py プロジェクト: freddupont/ogaca
def macro_opti_ana_fn_detruire_etat_ops(self,etat,**args):
    self.set_icmd(1)
    DETRUIRE(INFO=1,CONCEPT=_F(NOM=(etat['valeurs']),),ALARME='NON');
コード例 #47
0
ファイル: cms.py プロジェクト: EriveltonGualter/GSoC-MBDyn
def cms_ops(self, MAILLAGE, INTERFACE, EXPOSED, MODELE, CARA_ELEM, CHAM_MATER, CHAR_MECA, OPTIONS, OUT, **args):

	from Accas import _F

	# Define output and initialize error counter
	self.set_icmd(1)
	self.DeclareOut('GENMOD', self.sd)


	maillage = MAILLAGE;
	cms_interface = INTERFACE;
	cms_exposed_fact = EXPOSED;
	model = MODELE;
	caele = CARA_ELEM;
	chmat = CHAM_MATER;
	chbc = CHAR_MECA;
	options = OPTIONS;
	out = OUT;

	if options != None:
		cms_nmax_freq = options['NMAX_FREQ'];

	if out['TYPE'] == 'MBDYN':
		type = 'MBDYN';
		fichier = "fort.%d" % out['UNITE'];
		precision = out['PRECISION'];
		diag_mass = out['DIAG_MASS'];
		rigb_mass = out['RIGB_MASS'];
                epsilon = out['MODE_SHAPE_EPSILON'];
		data = (fichier, precision, diag_mass, rigb_mass, epsilon);
	else:
		ier = 1;
		return ier;

	# if an interface exists, use it
	do_craig_bampton = 0;
	if cms_interface != None:
		do_craig_bampton = 1;	# the real one
		# do_craig_bampton = 0;	# for debugging

	if do_craig_bampton:
		# clamp all interface nodes
		# NOTE: the model might need to have other parts clamped
		_cms_chbc = AFFE_CHAR_MECA(MODELE = model,
						DDL_IMPO = ( _F( GROUP_NO = cms_interface,
								DX = 0., DY = 0., DZ = 0.,
								DRX = 0., DRY = 0., DRZ = 0. ) ) );

	#===============================================================================
	# compute element contributions to matrices, number equations
	# and prepare stiffness and mass matrices
	# NOTE: specific to CMS, adds only boundary conditions required
	# 	for Craig-Bampton
	if chbc == None:
		if do_craig_bampton:
			_matlock = CALC_MATR_ELEM(MODELE = model,
							CARA_ELEM = caele,
							CHAM_MATER = chmat,
							CHARGE = _cms_chbc,
							OPTION = 'RIGI_MECA' );
		else:
			_matlock = CALC_MATR_ELEM(MODELE = model,
							CARA_ELEM = caele,
							CHAM_MATER = chmat,
							OPTION = 'RIGI_MECA' );

	else:
		if do_craig_bampton:
			_matlock = CALC_MATR_ELEM(MODELE = model,
							CARA_ELEM = caele,
							CHAM_MATER = chmat,
							CHARGE = ( chbc, _cms_chbc),
							OPTION = 'RIGI_MECA' );
		else:
			_matlock = CALC_MATR_ELEM(MODELE = model,
							CARA_ELEM = caele,
							CHAM_MATER = chmat,
							CHARGE = chbc,
							OPTION = 'RIGI_MECA' );

	_matlocm = CALC_MATR_ELEM(MODELE = model,
					CARA_ELEM = caele,
					CHAM_MATER = chmat,
					OPTION = 'MASS_MECA' );

	_matmdiag = CALC_MATR_ELEM(MODELE = model,
				   CARA_ELEM = caele,
				   CHAM_MATER = chmat,
				   OPTION = 'MASS_MECA_DIAG' );
        
	_num = NUME_DDL(MATR_RIGI = _matlock);
        
	_matassk = ASSE_MATRICE(MATR_ELEM = _matlock,
	                        NUME_DDL = _num);
        
	_matassm = ASSE_MATRICE(MATR_ELEM = _matlocm,
	                        NUME_DDL = _num);

        _matassmdiag = ASSE_MATRICE(MATR_ELEM = _matmdiag,
	                            NUME_DDL = _num);

        _sol_dyn=CALC_MODES(TYPE_RESU='DYNAMIQUE',
                            OPTION='PLUS_PETITE',
                            SOLVEUR_MODAL=_F(METHODE='TRI_DIAG',
                                             DIM_SOUS_ESPACE=5*cms_nmax_freq,),
                            MATR_RIGI=_matassk,
                            MATR_MASS=_matassm,
                            CALC_FREQ=_F(NMAX_FREQ=cms_nmax_freq,),
                            NORM_MODE=_F(NORME='MASS_GENE',),
                            VERI_MODE=_F(STOP_ERREUR='NON',),);


	#===============================================================================
	# put together the modal and static solutions
	_sol_stat = 0;
	if do_craig_bampton:
		_sol_stat = MODE_STATIQUE(MATR_RIGI = _matassk,
						MATR_MASS = _matassm,
						MODE_STAT = _F( GROUP_NO = cms_interface,
							TOUT_CMP = 'OUI' ),
						INFO = 2 );

		_interfa = DEFI_INTERF_DYNA(NUME_DDL = _num,
						INTERFACE = _F(	NOM = 'INTERF',
								TYPE = 'CRAIGB',
								GROUP_NO = cms_interface ) );

		# NOTE: RITZ no longer allows MODE_STAT in CodeAster 10.X
		_bm = DEFI_BASE_MODALE(RITZ=(_F(MODE_MECA = _sol_dyn ),
					     _F( MODE_INTF = _sol_stat)),
				       INTERF_DYNA = _interfa,
				       NUME_REF = _num);

	else:
		_bm = DEFI_BASE_MODALE(RITZ = _F( MODE_MECA = _sol_dyn),
				       NUME_REF = _num );

	#===============================================================================
	# create macro-element
	GENMOD = MACR_ELEM_DYNA(BASE_MODALE = _bm,
				MATR_RIGI = _matassk,
				MATR_MASS = _matassm );

	rc = cms_write(GENMOD, _matassmdiag, maillage, cms_interface, cms_exposed_fact, _sol_dyn, _sol_stat, type, data, options);

	return rc;
コード例 #48
0
ファイル: catalogue_beta3.py プロジェクト: freddupont/ogaca
 def BARRE(self):
     retour=[]
     for grit,typeit in self.association.iteritems():
         carait=self.section_catalogue[typeit]
         retour.append(_F(GROUP_MA=gr,SECTION='GENERALE',CARA='A',VALE=carait[2][1]))
     return retour;
コード例 #49
0
ファイル: opti_xfem.py プロジェクト: freddupont/ogaca
def xfem_caleteval(self,MAIL,MODEB,TBFNBAR,VOLOBJ,TCRITOUT,NBITER,CONTR,XFEM_LVL,CHDFO,para,**args):
	ier=0
	self.icmd=1
	FORMULE		= self.get_cmd('FORMULE')
	CREA_CHAMP	= self.get_cmd('CREA_CHAMP')
	CREA_RESU	= self.get_cmd('CREA_RESU')
	POST_ELEM	= self.get_cmd('POST_ELEM')
	
	self.DeclareOut('TCRITOUT',TCRITOUT)
	self.DeclareOut('tab_fb',TBFNBAR)
	self.DeclareOut('notused',self.sd)
	self.DeclareOut('CHDFO',CHDFO)
	
	
	fopti=file('fort.3',"a");
	fopti.write('Debut de la fonction cal et eval nbiter:%d\n'%NBITER);
	
	#definition de la fonction barriere qui permet de ponderer les fonctions dans le cas de chargement multiple
	def lvl_barriere(x,para):
		return x**para['nbar'];
	
		
	#definition de la fonction barriere qui permet de ponderer les fonctions dans le cas de chargement multiple
	def lvl_der_barriere(x,para):
		if para['nbar']==1:
			return 1;
		return para['nbar']*(x**(para['nbar']-1));

	
	
	#affectation de la table de critere qui contient les resultats
	__CRITOUT=CREA_TABLE(LISTE=(	_F(PARA='casdecharge',LISTE_I=(0,1,),),
					_F(PARA='critere',LISTE_R=(1,1,),),
		),);
	
	#tab_crit=CALC_TABLE(reuse=tab_crit,TABLE=tab_crit,ACTION=_F(OPERATION='COMB',TABLE=TCRITINI,NOM_PARA=('casdecharge') ) )
	##je n ai pas zero dans ma table mais ce nest pas grave
	
	IMPR_TABLE(TABLE=__CRITOUT);
	funcobj=0;
		


	#association des groupes du mailage
        __CHLVL=CREA_CHAMP(OPERATION='EXTR',FISSURE=XFEM_LVL,TYPE_CHAM='NOEU_NEUT_R',NOM_CHAM='LNNO',);
	#creation d un groupe contenant les noeuds hors du domaine
	__CHLVLT=__CHLVL.EXTR_COMP('X1',[],1);
	#print CHLVLT.valeurs;
	#print CHLVLT.noeud;
	motscle={};
	motscle['NOEUD']=[]
	max=len(__CHLVLT.valeurs);
	for i in range(max):
		if __CHLVLT.valeurs[i]<0:
			motscle['NOEUD'].append('N'+str(__CHLVLT.noeud[i]));
	#print motscle['NOEUD'];
	MAIL=DEFI_GROUP(reuse=MAIL,MAILLAGE=MAIL,CREA_GROUP_NO=
		(_F(NOM="LVLNEG",**motscle),
		_F(NOM="LVLBLOQ",DIFFE=('LVLNEG',para['GRN_APPUIS'])),
		_F(NOM="TESTCHAR",INTERSEC=('LVLNEG',para['GRN_CHAR'])),
#		_F(NOM="TESTCHAR",DIFFE=('LVLNEG',para['GRN_CHAR'])),
		));
	MAIL=DEFI_GROUP(reuse=MAIL,MAILLAGE=MAIL,CREA_GROUP_MA=_F(NOM="manoneg",OPTION='APPUI_LACHE',GROUP_NO='LVLNEG'));
	
	#test si une maille de la surface exterieur charge est negative
	print "test si le groupe testchar a bien ete cree"
	liste=MAIL.LIST_GROUP_NO()
	print liste
	liste2=[];
	for a in liste:
		liste2.append(a[0])
	print liste2
	assert ("TESTCHAR" in liste2)==False, "Erreur toutes les charges ne sont pas reprisent"
	print "ok c est bon"

	###construction du model XFEM
	__MODXFEM=MODI_MODELE_XFEM(MODELE_IN=MODEB,FISSURE=XFEM_LVL,CONTACT='NON');
	__MVNEG=AFFE_CHAR_MECA(MODELE=MODEB,DDL_IMPO=_F(DX=0.0,DY=0.0,DZ=0.0,GROUP_NO='LVLBLOQ'),);
	__CHARXFEM=AFFE_CHAR_MECA(MODELE=__MODXFEM,LIAISON_XFEM='OUI',);

	#Creation des elements de post traitement
	__MA_XFEM=POST_MAIL_XFEM(MODELE=__MODXFEM,
			MAILLAGE_SAIN=MAIL);
	__MA_XFEM=DEFI_GROUP(reuse=__MA_XFEM,MAILLAGE=__MA_XFEM,
		CREA_GROUP_MA=(
		#_F(NOM="tout",TOUT='OUI'),
		_F(NOM="MAPtem",DIFFE=('enri','HEM','manoneg')),
		_F(NOM="MAP",UNION=('HEP','MAPtem')),
		_F(NOM="MAFRONT",OPTION='APPUI_LACHE',GROUP_NO='NFISSU'),
		_F(NOM="MAFRPO",INTERSEC=('HEP','MAFRONT')),
		));
	
	__MA=DEFI_MATERIAU (ELAS=_F(E=para['MAE'],NU=para['MANU'],RHO=para['RHO'],));
	__CHMATB=AFFE_MATERIAU(MAILLAGE=MAIL,AFFE=_F(TOUT='OUI',MATER=__MA,),);
	__CHMATV=AFFE_MATERIAU(MAILLAGE=__MA_XFEM,AFFE=_F(TOUT='OUI',MATER=__MA,),);
	
	__MODEV=AFFE_MODELE(MAILLAGE=__MA_XFEM,
			AFFE=_F(TOUT='OUI',
				PHENOMENE='MECANIQUE',
				MODELISATION='3D',),) ;


        #creation d un cham valant zero partout pour sommer les champs unitaires
	#__chdt=CREA_CHAMP( OPERATION='ASSE', TYPE_CHAM='NOEU_NEUT_R',MODELE=__MODEV, 
			#ASSE=(	_F(TOUT='OUI', CHAM_GD=CHLVL,CUMUL='OUI', COEF_R = 0),
				#), )
	__chdt=CREA_CHAMP(OPERATION='AFFE',TYPE_CHAM='ELNO_NEUT_R', MODELE=__MODEV,PROL_ZERO='OUI',
		AFFE=_F(TOUT='OUI', NOM_CMP=('X1'),VALE=0.));
	compteur=0;
	
	#sauvegarde de chaque derive de forme
	__CHTEMP=CREA_CHAMP( OPERATION='ASSE', TYPE_CHAM='ELNO_SIEF_R',MODELE=__MODEV, PROL_ZERO='OUI',
		ASSE=_F(TOUT='OUI', CHAM_GD=__chdt,NOM_CMP=('X1',), NOM_CMP_RESU = ('SIXX',)), )
	__fRESUS=CREA_RESU(OPERATION='AFFE',TYPE_RESU='EVOL_ELAS',NOM_CHAM='SIEF_NOEU',AFFE=_F(CHAM_GD=__CHTEMP,MODELE=__MODEV,INST=compteur),);
	DETRUIRE(INFO=1,CONCEPT=_F(NOM=(__CHTEMP),),);	

	#recuperation des differents type de contrainte
	for m in CONTR:
		compteur=compteur+1;
		fopti.write('lvl.caleteval: Contrainte n:%d \n'%compteur);

		fopti.close();
		EXEC_LOGICIEL(LOGICIEL='cp fort.3 '+para['sortiepath']+'opti.temp.mess',);#sauvegarde du fichier
		fopti=file('fort.3',"a");

		
		fopti.close();
		CHDFOI=CO("CHDFOI");#champ de deriver de forme en cour d iteration
		if m['TYPE']=="COMPLIANCE":
			__compl=XFEM_DFO_COMPLIANCE(MAIL=MAIL,MAILX=__MA_XFEM,MODEX=__MODXFEM,MODEV=__MODEV,NCAS=compteur,
				EXCIT=(
					_F(CHARGE=m['CHARGE']),_F(CHARGE=__MVNEG),_F(CHARGE=__CHARXFEM)),
				CHMATE=__CHMATB,CHMATEV=__CHMATV,CHCOM=CHDFOI,para=para);
		#elif m['TYPE']=="COMPLIANCE_MAXC":
			#__compl=LVL_DFO_COMPLIANCE_MAXC(MAIL=MAIL,MODEMEC=MODEMEC,CHARGE=m['CHARGE'],CHMATE=__CHMATE,NUMCAS=compteur,CHCOM=CHDFOI,para=para);
		
		fopti=file('fort.3',"a");
		__CRITOUT=CALC_TABLE(reuse =__CRITOUT,TABLE=__CRITOUT,ACTION=_F(OPERATION='COMB',TABLE=__compl,NOM_PARA=('casdecharge') ) )
		DETRUIRE(INFO=1,CONCEPT=_F(NOM=(__compl),),);
		

		tatemp=__CRITOUT.EXTR_TABLE();
		contval=tatemp.critere[compteur]
		fopti.write( "lvl.caleteval: Contrainte de la table:%g \n" %contval);			
					
		fopti.close();
		EXEC_LOGICIEL(LOGICIEL='cp fort.3 '+para['sortiepath']+'opti.temp.mess',);#sauvegarde du fichier
		fopti=file('fort.3',"a");


		#ecriture du concept dans le resultat
		__CHTEMP=CREA_CHAMP( OPERATION='ASSE', TYPE_CHAM='ELNO_SIEF_R',MODELE=__MODEV, PROL_ZERO='OUI', ASSE=_F(TOUT='OUI', CHAM_GD=CHDFOI,NOM_CMP=('X1',), NOM_CMP_RESU = ('SIXX',)), )
		__fRESUS=CREA_RESU(reuse=__fRESUS,OPERATION='AFFE',TYPE_RESU='EVOL_ELAS',NOM_CHAM='SIEF_NOEU',AFFE=_F(CHAM_GD=__CHTEMP,MODELE=__MODEV,INST=compteur),);
		IMPR_RESU(FORMAT='MED',UNITE=81,RESU=_F(MAILLAGE=__MA_XFEM,RESULTAT=__fRESUS,NOM_CHAM=('SIEF_NOEU',),),);
		DETRUIRE(INFO=1,CONCEPT=_F(NOM=(__CHTEMP),),);
		EXEC_LOGICIEL(LOGICIEL='cp fort.81 '+para['sortiepath']+'mecadfocomp.i.med',);#sauvegarde du fichier
		DEFI_FICHIER(ACTION='LIBERER',UNITE=81,)
		EXEC_LOGICIEL(LOGICIEL='rm fort.81 ')

		##assemblage des derives de forme pour le calcul de la derive unitaire
		cibcom=contval/m['CONTOBJ'];
		barcom=lvl_barriere(x=cibcom,para=para);
		funcobj=barcom+funcobj;
		coefcom=lvl_der_barriere(x=cibcom,para=para);
		fopti.write( "lvl.caleteval: bariere de la contrainte %g\n" %barcom);
		fopti.write( "lvl.caleteval: coef de la contrainte %g\n" %coefcom);

		fopti.close();
		EXEC_LOGICIEL(LOGICIEL='cp fort.3 '+para['sortiepath']+'opti.temp.mess',);#sauvegarde du fichier
		fopti=file('fort.3',"a");
	
		
		__chdt1=CREA_CHAMP( OPERATION='ASSE', TYPE_CHAM='ELNO_NEUT_R',MODELE=__MODEV,PROL_ZERO='OUI',
				ASSE=(	_F(GROUP_MA='MAFRPO', CHAM_GD=__chdt,CUMUL='OUI', COEF_R = 1),
					), )
		DETRUIRE(INFO=1,CONCEPT=_F(NOM=(__chdt),),);
		__chdt=CREA_CHAMP( OPERATION='ASSE', TYPE_CHAM='ELNO_NEUT_R',MODELE=__MODEV, PROL_ZERO='OUI',
			ASSE=(	
				#_F(TOUT='OUI', CHAM_GD=__chdt1,CUMUL='OUI', COEF_R = 1),
				_F(GROUP_MA='MAFRPO', CHAM_GD=__chdt1,CUMUL='OUI', COEF_R = 1),
				_F(GROUP_MA='MAFRPO', CHAM_GD=CHDFOI,CUMUL='OUI', COEF_R = coefcom)
				), INFO=1)
		DETRUIRE(INFO=1,CONCEPT=_F(NOM=(__chdt1,CHDFOI),),);
		LVL_SAV(MAILLAGE=__MA_XFEM,CHAM_GD=__chdt,NOM="CHDFOncontr%d.med"%compteur,ITER=NBITER,para=para);
	
	#projection du cham __chdt sur le maillage mail
	__CHTEMP=CREA_CHAMP( OPERATION='ASSE', TYPE_CHAM='ELNO_SIEF_R',MODELE=__MODEV, PROL_ZERO='OUI', ASSE=_F(TOUT='OUI', CHAM_GD=__chdt,NOM_CMP=('X1',), NOM_CMP_RESU = ('SIXX',)), )
	__RESUAP=CREA_RESU(OPERATION='AFFE',TYPE_RESU='EVOL_ELAS',NOM_CHAM='SIEF_ELNO',AFFE=_F(CHAM_GD=__CHTEMP,MODELE=__MODEV,INST=compteur),);
	
	__RESUP=PROJ_CHAMP(RESULTAT = __RESUAP,MODELE_1=__MODEV,MODELE_2=MODEB,
		TYPE_CHAM='NOEU',NOM_CHAM='SIEF_ELNO',ALARME='NON',INFO=1,
		VIS_A_VIS=(_F(GROUP_MA_1='MAFRPO',TOUT_2='OUI')))
	__chdtp=CREA_CHAMP(OPERATION='EXTR',TYPE_CHAM='NOEU_SIEF_R',RESULTAT=__RESUP,NOM_CHAM='SIEF_ELNO');
	__chdtpn=CREA_CHAMP(OPERATION='ASSE',TYPE_CHAM='NOEU_NEUT_R',MAILLAGE=MAIL,ASSE=_F(TOUT='OUI',CHAM_GD=__chdtp,NOM_CMP=('SIXX'),NOM_CMP_RESU=('X1')));
	#__chdtpnd=CREA_CHAMP(OPERATION='DISC',TYPE_CHAM='NOEU_NEUT_R',MODELE=MODEB,CHAM_GD=__chdtpn,);
	
	LVL_SAV(MAILLAGE=MAIL,CHAM_GD=__chdtpn,NOM="CHDFOPROJ.med",ITER=NBITER,para=para);

	
############################################
#fonction DFO_VOLUME
#############################################
	__MASS_3D=POST_ELEM(MODELE=__MODEV,CHAM_MATER=__CHMATV, MASS_INER=_F(GROUP_MA='MAP',),);
	tatemp=__MASS_3D.EXTR_TABLE();
	voli=tatemp.MASSE[0];
	fopti.write( "lvl.caleteval: masse:  %g\n" %voli);
	
	fopti.close();
	EXEC_LOGICIEL(LOGICIEL='cp fort.3 '+para['sortiepath']+'opti.temp.mess',);#sauvegarde du fichier
	fopti=file('fort.3',"a");
	
	__tab_temp=CREA_TABLE(LISTE=(	_F(PARA='casdecharge',LISTE_I=(0,),),
					_F(PARA='critere',LISTE_R=(voli,),),
		),);
	TCRITOUT=CALC_TABLE(TABLE=__CRITOUT,ACTION=_F(OPERATION='COMB',TABLE=__tab_temp, NOM_PARA=('casdecharge') ) )
	DETRUIRE(INFO=1,CONCEPT=_F(NOM=(__tab_temp),),);
		
	__CHVOL=CREA_CHAMP( OPERATION= 'AFFE',TYPE_CHAM='NOEU_NEUT_R' , MODELE=MODEB,
			AFFE= (
				_F(TOUT='OUI', NOM_CMP='X1', VALE=1.,),
			));

############################################
#fin DFO_VOLUME
#############################################
        MAIL=DEFI_GROUP(reuse=MAIL,MAILLAGE=MAIL,DETR_GROUP_NO=_F(NOM=('LVLNEG','LVLBLOQ')))
	MAIL=DEFI_GROUP(reuse=MAIL,MAILLAGE=MAIL,DETR_GROUP_MA=_F(NOM=('manoneg')))
	
	
	
	fopti.write( "lvl.caleteval: coef du volume -%g\n" %para['lag']);
	CHDFO=CREA_CHAMP( OPERATION='ASSE', TYPE_CHAM='NOEU_NEUT_R',MODELE=MODEB, 
		ASSE=(	_F(TOUT='OUI', CHAM_GD=__CHVOL,CUMUL='OUI', COEF_R = -para['lag']),
			_F(TOUT='OUI', CHAM_GD=__chdtpn,CUMUL='OUI', COEF_R = 1)
			), )


	#valeur de la fonction objectif
	tatemp=TCRITOUT.EXTR_TABLE();
	funcobj=(funcobj+para['lag']*tatemp.critere[0]);

	#fopti.write( "opti.caleteval: La fonction objectif vaut %g\n" %funcobj);
	tab_fb=CREA_TABLE(LISTE=(	_F(PARA='fnobject',LISTE_R=(funcobj,),),
				_F(PARA='nbiter',LISTE_I=(NBITER,),),
		),);
	
	fopti.write('lvl.caleteval:Fin de la fonction cal et eval funcobj:%g\n'%funcobj);

	fopti.close();
	EXEC_LOGICIEL(LOGICIEL='cp fort.3 '+para['sortiepath']+'opti.temp.mess',);#sauvegarde du fichier
	
	##ATTEntion cree la table TCRITOUT
	return ier
コード例 #50
0
def macro_opti_sec_crit_contrainte_local_ops(self,valeur,etat,gradient,fn_para,**args):
    self.set_icmd(1)
    self.DeclareOut('valeur',valeur)
    CREA_TABLE	= self.get_cmd('CREA_TABLE')
    
    
    __CAREL=AFFE_CARA_ELEM(MODELE=etat["MODELE"],
                         INFO=1,
                         POUTRE=etat["CATALOGUE"].POUTRE()
                        )
    __Resu=MECA_STATIQUE(MODELE=etat["MODELE"],
                        CHAM_MATER=etat["CHAM_MATER"],
                        CARA_ELEM=__CAREL,
                        INST=0,
                        EXCIT=_F(CHARGE=fn_para["CHARGE"],),
                        );
    __Resu=CALC_ELEM(reuse =__Resu,
                 RESULTAT=__Resu,
                 TOUT_ORDRE='OUI',
                 OPTION=('SIPO_ELNO',))#SIGM_ELNO_DEPL
    
    #IMPR_RESU(FORMAT='MED',UNITE=80,RESU=_F(MAILLAGE=etat["MAIL"],RESULTAT=__Resu,),);
    
    __CH=CREA_CHAMP(OPERATION='EXTR',RESULTAT=__Resu,TYPE_CHAM='ELNO_SIEF_R',NOM_CHAM='SIPO_ELNO',INFO=1);
    sigmamax=fn_para["sigmamax"]
    sigmamin=fn_para["sigmamin"]
    tgradient=[]
    for gmaopti in etat["GMASECTIONPOSSIBLE"]:
        li=0
        if type(gmaopti[0])==str:
            li=[gmaopti[0]]
        else:
            li=list(gmaopti[0])
        CHTSN=__CH.EXTR_COMP('SN',li,1)
        CHTSMFY=__CH.EXTR_COMP('SMFY',li,1)
        CHTSMFZ=__CH.EXTR_COMP('SMFZ',li,1)
        deltasigma=[]
        for i in range(0,len(CHTSN.maille)):
            #pp comme positive positive
            PP=CHTSN.valeurs[i]+CHTSMFY.valeurs[i]+CHTSMFZ.valeurs[i]
            MP=CHTSN.valeurs[i]-CHTSMFY.valeurs[i]+CHTSMFZ.valeurs[i]
            PM=CHTSN.valeurs[i]+CHTSMFY.valeurs[i]-CHTSMFZ.valeurs[i]
            MM=CHTSN.valeurs[i]-CHTSMFY.valeurs[i]-CHTSMFZ.valeurs[i]
            #print gmaopti[0],i,PP,MP,PM,MM
            
            deltasigma.append(max(PP-sigmamax,MP-sigmamax,PM-sigmamax,MM-sigmamax,sigmamin-PP,sigmamin-MP,sigmamin-PM,sigmamin-MM))
        deltasigmamax=max(deltasigma)
        if fn_para["augmentationpure"]:
            deltasigmamax=max(deltasigmamax,0.)
        #print deltasigmamax
        #print fn_para["secdeltasigma"]
        tgradient.append(-deltasigmamax/fn_para["secdeltasigma"])
        #print tgradient
    
    valeurret=0.
    for a in tgradient:
        if (a<0):
            valeurret=valeurret-a*fn_para["correction"]
        else:
            valeurret=valeurret+a
    #modif ici
    
    #print etat["GMASECTIONPOSSIBLE"]
    #aster.affiche('RESULTAT', "tgradient"+str(tgradient))
    #aster.affiche('RESULTAT', str(valeurret))
    #print valeurret

    valeur=CREA_TABLE(LISTE=(	_F(PARA='R',LISTE_R=(valeurret,))));
    aster.affiche('MESSAGE',  'macro_opti_sec_crit_veriflocal:Valeur du retour c%f'%valeur["R",1])
    if (gradient==None):
        #print "macro_opti_sec_crit3_ops:no grad"
        return 0
    else:
        #print "macro_opti_sec_crit3_ops:grad"
        #print "test1"
        self.DeclareOut('gradient',gradient)
        #print "test2"
        gradient=CREA_TABLE(LISTE=(	_F(PARA='R',LISTE_R=tgradient)));
        #print "gradient['R',1]",gradient['R',1]
        return 0
コード例 #51
0
def orientation_poutre_vy(
    GROUP_MA,
    MAILLAGE,
    MODELE,
    CARA_ELEM,
    CHAM_MATER,
    UNITE=80,
    SAUVEGARDE_CHAMP=True,
    RETOUR_TABLE=False,
):
    """cree un fichier contenant un champs de l orientation local des poutres
    usage: orientation_poutre_vy(GROUP_MA,MAILLAGE,MODELE,CARA_ELEM,MATE,UNITE=80)
    """
    ######################################################
    #Champ local Y des poutres
    __CHVY = CREA_CHAMP(OPERATION='AFFE',
                        TYPE_CHAM='ELNO_SIEF_R',
                        MODELE=MODELE,
                        PROL_ZERO='OUI',
                        AFFE=_F(GROUP_MA=GROUP_MA, NOM_CMP=('VY'), VALE=1.))
    __VYinst0 = CREA_RESU(OPERATION='AFFE',
                          TYPE_RESU='EVOL_ELAS',
                          NOM_CHAM='SIEF_ELNO',
                          AFFE=_F(CHAM_GD=__CHVY, INST=-1))
    __DEPL = CREA_CHAMP(OPERATION='AFFE',
                        TYPE_CHAM='NOEU_DEPL_R',
                        MODELE=MODELE,
                        PROL_ZERO='OUI',
                        AFFE=_F(TOUT='OUI', NOM_CMP=('DY'), VALE=1.))
    __VYinst0 = CREA_RESU(reuse=__VYinst0,
                          OPERATION='AFFE',
                          TYPE_RESU='EVOL_ELAS',
                          NOM_CHAM='DEPL',
                          AFFE=_F(CHAM_GD=__DEPL, INST=-1))
    __VYinst0 = CALC_ELEM(
        reuse=__VYinst0,
        RESULTAT=__VYinst0,
        MODELE=MODELE,
        CHAM_MATER=CHAM_MATER,
        CARA_ELEM=CARA_ELEM,
        OPTION=('EFCA_ELNO'),
    )
    if (SAUVEGARDE_CHAMP):
        IMPR_RESU(
            FORMAT='MED',
            UNITE=UNITE,
            RESU=_F(
                MAILLAGE=MAILLAGE,
                RESULTAT=__VYi0,
                NOM_CHAM='EFCA_ELNO',
            ),
        )
    if (RETOUR_TABLE):
        __CH = CREA_CHAMP(
            OPERATION='EXTR',
            RESULTAT=__VYinst0,
            TYPE_CHAM='ELNO_SIEF_R',
            NOM_CHAM='EFCA_ELNO',
        )
        #creation d un groupe contenant les noeuds hors du domaine
        __CHTX = __CH.EXTR_COMP('FX', [], 1)
        __CHTY = __CH.EXTR_COMP('FY', [], 1)
        __CHTZ = __CH.EXTR_COMP('FZ', [], 1)

        inversionmail = {}
        #output={}
        for i in range(0, len(__CHTX.maille)):
            if not (inversionmail.has_key(__CHTX.maille[i])):
                inversionmail[__CHTX.maille[i]] = [i]
                #output[__CHTX.maille[i]]=[__CHTX.valeurs[i]]
        for i in range(0, len(__CHTY.maille)):
            if inversionmail.has_key(__CHTY.maille[i]):
                if (len(inversionmail[__CHTY.maille[i]]) == 1):
                    inversionmail[__CHTY.maille[i]].append(i)
        for i in range(0, len(__CHTZ.maille)):
            if inversionmail.has_key(__CHTZ.maille[i]):
                if (len(inversionmail[__CHTZ.maille[i]]) == 2):
                    inversionmail[__CHTZ.maille[i]].append(i)

        output = {}
        for k, v in inversionmail.iteritems():
            output[k] = numpy.array([
                __CHTX.valeurs[v[0]], __CHTY.valeurs[v[1]],
                __CHTZ.valeurs[v[2]]
            ])
            assert (v[0] == v[1] and v[2] == v[1])

        #print "/n"*10
        #print __CHTX.__dict__;
        #print __CHTY.__dict__;
        #print __CHTZ.__dict__;
        #print inversionmail
        #print output
        DETRUIRE(INFO=1, CONCEPT=_F(NOM=(__CH), ))
        DETRUIRE(INFO=1, CONCEPT=_F(NOM=(__CHVY, __VYinst0, __DEPL), ))
        return output
    DETRUIRE(INFO=1, CONCEPT=_F(NOM=(__CHVY, __VYinst0, __DEPL), ))
コード例 #52
0
def macro_opti_sec_crit_verif_local_ops(self,valeur,etat,gradient,fn_para,**args):
    self.set_icmd(1)
    self.DeclareOut('valeur',valeur)
    CREA_TABLE	= self.get_cmd('CREA_TABLE')
    
    
    __CAREL=AFFE_CARA_ELEM(MODELE=etat["MODELE"],
                         INFO=1,
                         POUTRE=etat["CATALOGUE"].POUTRE(),
                        )
    __Resu=MECA_STATIQUE(MODELE=etat["MODELE"],
                        CHAM_MATER=etat["CHAM_MATER"],
                        CARA_ELEM=__CAREL,
                        INST=0,
                        EXCIT=_F(CHARGE=fn_para["CHARGE"],),
                        );
    #__Resu=CALC_ELEM(reuse =__Resu,
    #             RESULTAT=__Resu,
    #             TOUT_ORDRE='OUI',
    #             OPTION=('SIEF_ELNO','SIPO_ELNO'))#SIGM_ELNO_DEPL
    
    #IMPR_RESU(FORMAT='MED',UNITE=80,RESU=_F(MAILLAGE=etat["MAIL"],RESULTAT=__Resu,),);
    #IMPR_RESU(FORMAT='RESULTAT',RESU=_F(MAILLAGE=etat["MAIL"],RESULTAT=__Resu,),);
    
    __CH=CREA_CHAMP(OPERATION='EXTR',RESULTAT=__Resu,TYPE_CHAM='ELGA_SIEF_R',NOM_CHAM='SIEF_ELGA',INFO=1);#ou ELGA ou ELNO?
    sigmamaxr=fn_para["sigmamax"] #r pour resistance et d pour design
    sigmaminr=fn_para["sigmamin"]
    tgradient=[]
    #on parcours tout les groupes a optimiser
    for gmaopti in etat["GMASECTIONPOSSIBLE"]:
        
        #on recupere tout les champs d'effort
        li=0
        if type(gmaopti[0])==str:
            li=[gmaopti[0]]
        else:
            li=list(gmaopti[0])
        CHTN=__CH.EXTR_COMP('N',li,1)
        CHTMFY=__CH.EXTR_COMP('MFY',li,1)
        CHTMFZ=__CH.EXTR_COMP('MFZ',li,1)
        
        #on recupere les caracteristique de la section courrante
        listesection=gmaopti[1]
        nomsecactuel=etat["CATALOGUE"].association[gmaopti[0]]
        #position de cette section dans la liste
        ii=listesection.index(nomsecactuel)
        
        section_cara=etat["CATALOGUE"].get_section_cara_from_sectionname(nomsecactuel)
        smaxd=0
        smind=0
        for i in range(0,len(CHTN.maille)):
            stress=etat["CATALOGUE"].section_cara_contrainte(section_cara,CHTN.valeurs[i],CHTMFY.valeurs[i],CHTMFZ.valeurs[i])
            smind=min(smind,stress[0])
            smaxd=max(smaxd,stress[1])
            #print "debug ini",ii
            #print gmaopti[0],i,CHTN.valeurs[i],CHTMFY.valeurs[i],CHTMFZ.valeurs[i]
            #print stress
        aa=0.
        if (smaxd>sigmamaxr or smind<sigmaminr):
            #print "debug section not ok"
            aa=1
        else:
            #print "debug section ok"
            aa=-1
        
        cont=True
        
        while (cont):
            if ii+aa>len(listesection)-1:
                cont=False
            elif ii+aa<0:
                aa=aa+1
                cont=False
            else:
                section_cara=etat["CATALOGUE"].get_section_cara_from_sectionname(listesection[ii+aa])
                smaxd=0
                smind=0
                for i in range(0,len(CHTN.maille)):
                    stress=etat["CATALOGUE"].section_cara_contrainte(section_cara,CHTN.valeurs[i],CHTMFY.valeurs[i],CHTMFZ.valeurs[i])
                    smind=min(smind,stress[0])
                    smaxd=max(smaxd,stress[1])
                #print "debug try",ii+aa
                #print gmaopti[0],smind,smaxd
                if aa>0:
                    if not(smaxd>sigmamaxr or smind<sigmaminr):
                        #print "debug trouve ok"
                        cont=False
                    else:
                        aa=aa+1
                else:
                    if (smaxd>sigmamaxr or smind<sigmaminr):
                        #print "debug trouve notok"
                        aa=aa+1
                        cont=False
                    else:
                        aa=aa-1

        tgradient.append(-aa)
        #print "debug fin aa=",aa
    
    valeurret=0.
    for a in tgradient:
        valeurret=valeurret-a
    #modif ici
    
    #print etat["GMASECTIONPOSSIBLE"]
    #aster.affiche('RESULTAT', "tgradient"+str(tgradient))
    #aster.affiche('RESULTAT', str(valeurret))
    #print valeurret

    valeur=CREA_TABLE(LISTE=(	_F(PARA='R',LISTE_R=(valeurret,))));
    aster.affiche('MESSAGE',  'macro_opti_sec_crit_verif_local:Valeur du retour c%f'%valeur["R",1])
    if (gradient==None):
        #print "macro_opti_sec_crit3_ops:no grad"
        return 0
    else:
        #print "macro_opti_sec_crit3_ops:grad"
        #print "test1"
        self.DeclareOut('gradient',gradient)
        #print "test2"
        gradient=CREA_TABLE(LISTE=(	_F(PARA='R',LISTE_R=tgradient)));
        #print "gradient['R',1]",gradient['R',1]
        return 0