1 #@ MODIF co_macr_elem_dyna SD DATE 17/01/2008 AUTEUR ZENTNER I.ZENTNER
2 # -*- coding: iso-8859-1 -*-
3 # CONFIGURATION MANAGEMENT OF EDF VERSION
4 # ======================================================================
5 # COPYRIGHT (C) 1991 - 2007 EDF R&D WWW.CODE-ASTER.ORG
6 # THIS PROGRAM IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY
7 # IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE AS PUBLISHED BY
8 # THE FREE SOFTWARE FOUNDATION; EITHER VERSION 2 OF THE LICENSE, OR
9 # (AT YOUR OPTION) ANY LATER VERSION.
11 # THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT
12 # WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF
13 # MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU
14 # GENERAL PUBLIC LICENSE FOR MORE DETAILS.
16 # YOU SHOULD HAVE RECEIVED A COPY OF THE GNU GENERAL PUBLIC LICENSE
17 # ALONG WITH THIS PROGRAM; IF NOT, WRITE TO EDF R&D CODE_ASTER,
18 # 1 AVENUE DU GENERAL DE GAULLE, 92141 CLAMART CEDEX, FRANCE.
19 # ======================================================================
23 from sd_macr_elem_dyna import sd_macr_elem_dyna
27 def VALE_triang2array(vect_VALE, dim, typ):
28 """Conversion (par recopie) de l'objet .VALE decrivant une matrice pleine
29 par sa triangulaire sup en Numeric.array plein.
31 triang_sup = Numeric.array(vect_VALE)
32 assert dim*(dim+1)/2 == len(triang_sup), \
33 'Matrice non pleine : %d*(%d+1)/2 != %d' % (dim, dim, len(triang_sup))
35 valeur = Numeric.zeros([dim, dim], typ)
36 for i in range(1, dim+1):
37 for j in range(1, i+1):
39 valeur[j-1, i-1]=triang_sup[k-1]
40 valeur = valeur + Numeric.transpose(valeur)
42 valeur[i, i] = 0.5 * valeur[i, i]
46 # -----------------------------------------------------------------------------
47 class macr_elem_dyna(ASSD, sd_macr_elem_dyna):
48 def NBRE_MODES(self) :
49 """ retourne le nombre de modes total, dynamiques et d'interface """
51 raise Accas.AsException("Erreur dans macr_elem_dyna.NBRE_MODES en PAR_LOT='OUI'")
52 nombase = self.MAEL_REFE.get()[0]
53 nbmode=Numeric.array(aster.getvectjev('%-19s' % nombase[0:8] + '.UTIL'))
57 return [nbmodtot,nbmoddyn,nbmodint]
59 def EXTR_MATR_GENE(self,typmat) :
60 """ retourne les valeurs des matrices generalisees reelles
61 dans un format Numerical Array
62 typmat='MASS_GENE' pour obtenir la matrice de masse generalisee
63 typmat='RIGI_GENE' pour obtenir la matrice de raideur generalisee
64 typmat='AMOR_GENE' pour obtenir la matrice d'amortissement generalisee
66 - self.valeurs : Numeric.array contenant les valeurs """
68 raise Accas.AsException("Erreur dans macr_elem_dyna.EXTR_MATR_GENE en PAR_LOT='OUI'")
70 if (typmat=='MASS_GENE') :
71 macr_elem = self.MAEL_MASS
72 elif (typmat=='RIGI_GENE') :
73 macr_elem = self.MAEL_RAID
74 elif (typmat=='AMOR_GENE') :
75 macr_elem = self.MAEL_AMOR
77 raise Accas.AsException("Le type de la matrice est incorrect")
79 desc=Numeric.array(macr_elem.DESC.get())
80 # On teste si le DESC du vecteur existe
82 raise Accas.AsException("L'objet matrice n'existe pas ou est mal cree par Code Aster")
84 matrice = VALE_triang2array(macr_elem.VALE.get(), desc[1], Numeric.Float)
87 def RECU_MATR_GENE(self,typmat,matrice) :
88 """ envoie les valeurs d'un Numerical Array dans des matrices generalisees
89 reelles definies dans jeveux
90 typmat='MASS_GENE' pour obtenir la matrice de masse generalisee
91 typmat='RIGI_GENE' pour obtenir la matrice de raideur generalisee
92 typmat='AMOR_GENE' pour obtenir la matrice d'amortissement generalisee
93 Attributs ne retourne rien """
95 raise Accas.AsException("Erreur dans macr_elem_dyna.RECU_MATR_GENE en PAR_LOT='OUI'")
97 nommacr=self.get_name()
98 if (typmat=='MASS_GENE') :
99 macr_elem = self.MAEL_MASS
100 elif (typmat=='RIGI_GENE') :
101 macr_elem = self.MAEL_RAID
102 elif (typmat=='AMOR_GENE') :
103 macr_elem = self.MAEL_AMOR
105 raise Accas.AsException("Le type de la matrice est incorrect")
106 nom_vale = macr_elem.VALE.nomj()
107 desc=Numeric.array(macr_elem.DESC.get())
109 # On teste si le DESC de la matrice jeveux existe
111 raise Accas.AsException("L'objet matrice n'existe pas ou est mal cree par Code Aster")
112 Numeric.asarray(matrice)
114 # On teste si la matrice python est de dimension 2
115 if (len(Numeric.shape(matrice))<>2):
116 raise Accas.AsException("La dimension de la matrice est incorrecte")
118 # On teste si les tailles de la matrice jeveux et python sont identiques
119 if (tuple([desc[1],desc[1]])<>Numeric.shape(matrice)) :
120 raise Accas.AsException("La dimension de la matrice est incorrecte")
121 taille=desc[1]*desc[1]/2.0+desc[1]/2.0
122 tmp=Numeric.zeros([int(taille)],Numeric.Float)
123 for j in range(desc[1]+1):
126 tmp[k]=matrice[j-1,i]
127 aster.putvectjev(nom_vale,len(tmp),tuple((
128 range(1,len(tmp)+1))),tuple(tmp),tuple(tmp),1)