Esempio n. 1
0
def temps_CPU(restant_old, temps_iter_old):
    """
       Fonction controlant le temps restant
    """
    __cpu = INFO_EXEC_ASTER(LISTE_INFO=("TEMPS_RESTANT",))
    TEMPS = __cpu['TEMPS_RESTANT', 1]
    DETRUIRE(CONCEPT=_F(NOM=__cpu), INFO=1)
    err = 0
    # Indique une execution interactive
    if (TEMPS > 1.E+9):
        return 0., 0., 0
    # Indique une execution en batch
    else:
        restant = TEMPS
        # Initialisation
        if (restant_old == 0.):
            temps_iter = -1.
        else:
            # Première mesure
            if (temps_iter_old == -1.):
                temps_iter = (restant_old - restant)
            # Mesure courante
            else:
                temps_iter = (temps_iter_old + (restant_old - restant)) / 2.
            if ((temps_iter > 0.96 * restant)or(restant < 0.)):
                err = 1
                msg = MessageLog.GetText('F', 'RECAL0_53')
                raise CPU_Exception, msg

    return restant, temps_iter, err
Esempio n. 2
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
Esempio n. 3
0
def make_mesh_mac(nb_l, nb_c):
    from code_aster.Cata.Commands import INFO_EXEC_ASTER
    _UL = INFO_EXEC_ASTER(LISTE_INFO='UNITE_LIBRE')
    unite = _UL['UNITE_LIBRE', 1]

    f = open('./fort.%s' % unite, 'w')

    f.writelines('TITRE : MAILLAGE CARRE POUR REPRESENTATION MAC_MODES\n')
    f.writelines('CREE PAR SCRIPT PYTHON AU FORMAT ASTER\n')
    f.writelines(' FINSF\n')
    f.writelines(' %\n')
    f.writelines(' COOR_3D\n')
    # Les noeuds sont appeles 'Ni1_i2' les mailles 'Mj1_j2' comme suit
    # N1_1    N1_2    N1_3    N1_4
    # M1_1    M1_2    M1_3
    # N2_1    N2_2    N2_3    N2_4
    # M2_1    M2_2    M2_3
    # N3_1    N3_2    N3_3    N3_4
    # dimension du MAC

    for ind_l in range(1, nb_l + 2):
        for ind_c in range(1, nb_c + 2):
            nom_no = 'N%s_%s' % (ind_l, ind_c)
            coordo_x = ind_c / (nb_c + 1.0)
            coordo_y = -ind_l / (nb_l + 1.0)
            coordo_z = 0.0
            f.writelines(' ' + nom_no.ljust(8) + '%22.14E%22.14E%22.14E' %
                         (coordo_x, coordo_y, coordo_z) + '\n')

    f.writelines(' FINSF\n')
    f.writelines(' %\n')
    f.writelines(' QUAD4\n')

    for ind_l in range(1, nb_l + 1):
        for ind_c in range(1, nb_c + 1):
            nom_maille = 'M%s_%s' % (ind_l, ind_c)
            nom_noeud_1 = 'N%s_%s' % (ind_l, ind_c)
            nom_noeud_2 = 'N%s_%s' % (ind_l, ind_c + 1)
            nom_noeud_3 = 'N%s_%s' % (ind_l + 1, ind_c + 1)
            nom_noeud_4 = 'N%s_%s' % (ind_l + 1, ind_c)

            f.writelines(' ' + nom_maille.ljust(8) + nom_noeud_1.ljust(8) +
                         nom_noeud_2.ljust(8) + nom_noeud_3.ljust(8) +
                         nom_noeud_4.ljust(8) + '\n')

    f.writelines(' FINSF\n')
    f.writelines(' %\n')
    f.writelines(' FIN\n')
    f.close()
    return unite
Esempio n. 4
0
    def _setinfo(self, ul):
        """Remplit les infos de l'unité 'ul'.
        """
        # ul peut etre un entier Aster
        try:
            unit = ul.valeur
        except:
            unit = int(ul)
        # Si la clé n'existe pas
        ini = False
        if not self.infos.has_key(unit):
            self.infos[unit] = {}
            self.infos[unit]['nom'] = ''
            self.infos[unit]['etat'] = '?'
            self.infos[unit]['etat_init'] = '?'
            ini = True

        __tab = INFO_EXEC_ASTER(UNITE=unit, LISTE_INFO=('ETAT_UNITE'))

        # O:ouvert, F:fermé, R:réservé
        self.infos[unit]['etat'] = __tab['ETAT_UNITE', 1].strip()[0]
        if ini:
            self.infos[unit]['etat_init'] = self.infos[unit]['etat']

        # nom du fichier
        if self.infos[unit]['etat'] in ['O', 'R']:
            nomfich = ''.join([__tab['NOMFIC%d' % i, 1]
                               for i in range(1, 5)]).strip()
        elif self.infos[unit]['etat'] == 'F':
            nomfich = 'fort.' + str(unit)
        else:
            message = "Etat de l'unité inconnu : %s" % self.infos[unit]['etat']
            print __tab.EXTR_TABLE()
            raise aster.error, "<F> <UniteAster._setinfo> %s" % message
        self.infos[unit]['nom'] = nomfich
        # print 'DEBUG infos[unit] = ', self.infos[unit]
        DETRUIRE(CONCEPT=_F(NOM=__tab), INFO=1)
Esempio n. 5
0
    def Libre(self, nom=None, action='RESERVER'):
        """Réserve/associe et retourne une unité libre en y associant, s'il est
        fourni, le fichier 'nom'.
        """
        __tab = INFO_EXEC_ASTER(LISTE_INFO=('UNITE_LIBRE'))
        unit = __tab['UNITE_LIBRE', 1]
        DETRUIRE(CONCEPT=_F(NOM=__tab), INFO=1)
        if nom == None:
            nom = 'fort.' + str(unit)

        # Si la clé existe, c'est que le fichier n'était pas libre
        if self.infos.has_key(unit):
            message = "Cette unité est déjà affectée au fichier %s" % \
                self.infos[unit]['nom']
            raise aster.error, "<F> <UniteAster.Libre> %s" % message

        DEFI_FICHIER(ACTION=action, UNITE=unit, FICHIER=nom.strip())
        self.infos[unit] = {}
        self.infos[unit]['nom'] = nom.strip()
        self.infos[unit]['etat'] = 'R'
        self.infos[unit]['etat_init'] = 'F'
        return unit
Esempio n. 6
0
 def get_unite_logique(self):
     _TUL = INFO_EXEC_ASTER(LISTE_INFO='UNITE_LIBRE')
     self.unite_logique = _TUL['UNITE_LIBRE', 1]
     DETRUIRE(CONCEPT=_F(NOM=(_TUL)), INFO=1)
     pass