def create_resu(field, model, mat, char_cine=None):
    """
    Create an aster concept of results from an aster field obtained by a solve.
    Input:
        -field: aster displacement field
        -model: aster model
        -mat: aster assigned material
        -char_cine: dirichlet boundary conditions
    Output:
        -aster result
    """

    if char_cine:
        o2[AsterIter2] = CREA_RESU(OPERATION='AFFE',
                                   TYPE_RESU='EVOL_ELAS',
                                   NOM_CHAM='DEPL',
                                   EXCIT=_F(CHARGE=char_cine),
                                   AFFE=_F(
                                       CHAM_GD=field,
                                       MODELE=model,
                                       CHAM_MATER=mat,
                                       INST=0.,
                                   ))
    else:
        o2[AsterIter2] = CREA_RESU(OPERATION='AFFE',
                                   TYPE_RESU='EVOL_ELAS',
                                   NOM_CHAM='DEPL',
                                   AFFE=_F(
                                       CHAM_GD=field,
                                       MODELE=model,
                                       CHAM_MATER=mat,
                                       INST=0.,
                                   ))

    return resu
Exemplo n.º 2
0
    def output_resdef(self, resu, depl_deformed, tinit, tfin):
        """save the result to be used by a next calculation"""
        from code_aster.Cata.Commands import CREA_RESU
        _pdt_ini = self.coeur.temps_simu['T1']
        _pdt_fin = self.coeur.temps_simu['T4']

        if ((not tinit) and (not tfin)):
            _pdt_ini_out = _pdt_ini
            _pdt_fin_out = _pdt_fin
        else:
            _pdt_ini_out = tinit
            _pdt_fin_out = tfin

        depl_ini = self.extrChamp(resu, _pdt_ini)
        depl_fin = self.extrChamp(resu, _pdt_fin)

        depl_tot_ini = self.asseChamp(depl_deformed, depl_ini)
        depl_tot_fin = self.asseChamp(depl_deformed, depl_fin)

        self.deform_mesh_inverse(depl_deformed)

        __RESFIN = CREA_RESU(**self.cr(_pdt_ini_out, depl_tot_ini))
        CREA_RESU(**self.cr(_pdt_fin_out, depl_tot_fin, reuse=__RESFIN))
        self.res_def = __RESFIN
def compute_nodal_reaction_from_field_on_group(field,
                                               model,
                                               mat,
                                               group,
                                               charg,
                                               char_cine=None):
    """
    Compute nodal reaction from a displacement field on a specific group.
    Input:
        -field: aster displacement field
        -model: aster model,
        -mat: assigned material on a mesh
        -char_cine: dirichlet boundary conditions
        -group: group where the nodal reaction has to be computed
    Output:
        -asterField instance
    """
    ### Create result concept from the displacement field
    #resu = create_resu(field,model,mat,char_cine)

    if char_cine:
        resu = CREA_RESU(OPERATION='AFFE',
                         TYPE_RESU='EVOL_ELAS',
                         NOM_CHAM='DEPL',
                         EXCIT=_F(CHARGE=charg),
                         AFFE=_F(
                             CHAM_GD=field,
                             MODELE=model,
                             CHAM_MATER=mat,
                             INST=0.,
                         ))
    else:
        resu = CREA_RESU(OPERATION='AFFE',
                         TYPE_RESU='EVOL_ELAS',
                         NOM_CHAM='DEPL',
                         AFFE=_F(
                             CHAM_GD=field,
                             MODELE=model,
                             CHAM_MATER=mat,
                             INST=0.,
                         ))

    resu = CALC_CHAMP(
        FORCE='REAC_NODA',
        reuse=resu,
        MODELE=model,
        CHAM_MATER=mat,
        EXCIT=_F(CHARGE=charg),
        TOUT='OUI',
        RESULTAT=resu,
    )
    AsterIter = AsterCount.__next__()
    o[AsterIter] = CREA_CHAMP(
        OPERATION='EXTR',
        NOM_CHAM='REAC_NODA',
        TYPE_CHAM='NOEU_DEPL_R',
        RESULTAT=resu,
        INST=0.,
    )
    nodalrea = CREA_CHAMP(
        OPERATION='ASSE',
        TYPE_CHAM='NOEU_DEPL_R',
        MODELE=model,
        ASSE=_F(CHAM_GD=o[AsterIter], GROUP_MA=group),
    )

    DETRUIRE(CONCEPT=(_F(NOM=nodalrea), _F(NOM=resu)))
    return o[AsterIter]
Exemplo n.º 4
0
    def asse_champs_gauss(self, dic_champ_cont, dic_champ_var_int, dic_transfo,
                          resu):
        """
            Transformation et assemblage des champs aux points de Gauss.
        """
        from code_aster.Cata.Commands import LIRE_CHAMP, CREA_CHAMP, DETRUIRE
        from code_aster.Cata.Commands import CREA_RESU, MODI_REPERE

        info_mode_epx = self.info_mode_epx
        info_comp_epx = self.info_comp_epx
        dic_mc_cara = self.dic_mc_cara

        ll = len(dic_champ_cont.keys()) - 1
        nb_SIG1 = len(dic_champ_cont['SANS'].keys()) + ll
        ll = len(dic_champ_var_int.keys()) - 1
        nb_ECR1 = len(dic_champ_var_int['SANS'].keys()) + ll
        itot = len(resu.LIST_PARA()['INST'])
        __EFFG = [None] * itot
        __ECRG = [None] * itot
        __SIG1 = [None] * nb_SIG1
        __ECR1 = [None] * nb_ECR1
        dicAffe = []
        dicAffe3 = []

        lc = {
            'INFO': self.INFO,
            'UNITE': self.UNITE_MED,
            'MODELE': self.MODELE,
            'MAILLAGE': self.MAILLAGE,
            'PROL_ZERO': 'OUI',
        }
        cc = {
            'INFO': self.INFO,
            'MODELE': self.MODELE,
            'PROL_ZERO': 'OUI',
            'OPERATION': 'ASSE',
        }
        MasquerAlarme('MED_4')
        for i in xrange(itot):

            lc['NUME_PT'] = resu.LIST_PARA()['NUME_ORDRE'][i]

            dicAsse = []
            dicAsse3 = []
            dicDetr = []

            # CONTRAINTES

            lc['TYPE_CHAM'] = 'ELGA_SIEF_R'
            for mc_cara in dic_champ_cont.keys():
                j = 0
                if mc_cara == 'SANS':
                    for champ in dic_champ_cont[mc_cara].keys():
                        mode_epx = dic_champ_cont[mc_cara][champ]
                        nom_cmp = info_mode_epx[mode_epx]['NOM_CMP']
                        nom_cmp_med = info_mode_epx[mode_epx]['NOM_CMP_MED']
                        lcc = lc.copy()
                        lcc.update(
                            NOM_MED=champ,
                            NOM_CMP=nom_cmp,
                            NOM_CMP_MED=nom_cmp_med,
                        )
                        __SIG1[j] = LIRE_CHAMP(**lcc)

                        dicDetr.append({'NOM': __SIG1[j]})
                        dicAsse.append({
                            'TOUT': 'OUI',
                            'CHAM_GD': __SIG1[j],
                            'NOM_CMP': nom_cmp,
                            'CUMUL': 'OUI',
                            'COEF_R': 1.
                        })
                        j += 1
                else:
                    nb_champ_cara = len(dic_champ_cont[mc_cara].keys())
                    dicDetr_cara = []
                    if nb_champ_cara == 1:
                        champ = dic_champ_cont[mc_cara].keys()[0]
                        mode_epx = dic_champ_cont[mc_cara][champ]
                        nom_cmp = info_mode_epx[mode_epx]['NOM_CMP']
                        nom_cmp_med = info_mode_epx[mode_epx]['NOM_CMP_MED']
                        lcc = lc.copy()
                        lcc.update(
                            NOM_MED=champ,
                            NOM_CMP=nom_cmp,
                            NOM_CMP_MED=nom_cmp_med,
                        )
                        __SIG_AS = LIRE_CHAMP(**lcc)
                    else:
                        __SIG = [None] * nb_champ_cara
                        dicAsse_cara = []
                        for k, champ in enumerate(
                                dic_champ_cont[mc_cara].keys()):
                            mode_epx = dic_champ_cont[mc_cara][champ]
                            nom_cmp = info_mode_epx[mode_epx]['NOM_CMP']
                            nom_cmp_med = info_mode_epx[mode_epx][
                                'NOM_CMP_MED']
                            lcc = lc.copy()
                            lcc.update(
                                NOM_MED=champ,
                                NOM_CMP=nom_cmp,
                                NOM_CMP_MED=nom_cmp_med,
                            )
                            __SIG[k] = LIRE_CHAMP(**lcc)
                            dicAsse_cara.append({
                                'TOUT': 'OUI',
                                'CHAM_GD': __SIG[k],
                                'NOM_CMP': nom_cmp,
                                'CUMUL': 'OUI',
                                'COEF_R': 1.
                            })
                            dicDetr_cara.append({'NOM': __SIG[k]})
                        # assemblage
                        ccc = cc.copy()
                        ccc.update(
                            TYPE_CHAM='ELGA_SIEF_R',
                            ASSE=dicAsse_cara,
                        )
                        __SIG_AS = CREA_CHAMP(**ccc)
                    dicDetr_cara.append({'NOM': __SIG_AS})
                    cham_para = (dic_mc_cara[mc_cara]['CH_CARA'], __SIG_AS)
                    cham_fonc = dic_mc_cara[mc_cara]['CH_FONC']
                    # EVAL : passage des contraintes aux efforts
                    __SIG1[j] = CREA_CHAMP(
                        OPERATION='EVAL',
                        TYPE_CHAM='ELGA_NEUT_R',
                        CHAM_F=cham_fonc,
                        CHAM_PARA=cham_para,
                    )
                    dicDetr.append({'NOM': __SIG1[j]})
                    nom_cmp = dic_mc_cara[mc_cara]['NOM_CMP']
                    nom_cmp_f = dic_mc_cara[mc_cara]['NOM_CMP_F']
                    dicAsse.append({
                        'TOUT': 'OUI',
                        'CHAM_GD': __SIG1[j],
                        'NOM_CMP': nom_cmp_f,
                        'NOM_CMP_RESU': nom_cmp,
                        'CUMUL': 'OUI',
                        'COEF_R': 1.
                    })
                    DETRUIRE(CONCEPT=dicDetr_cara, INFO=1)
                    j += 1
            # VARIABLES INTERNES
            lc['TYPE_CHAM'] = 'ELGA_VARI_R'

            for compo in dic_champ_var_int.keys():
                j = 0
                if compo == 'SANS':
                    for champ in dic_champ_var_int[compo].keys():
                        loi = dic_champ_var_int[compo][champ]
                        nb_var_aster = info_comp_epx[loi]['NB_VAR_ASTER']
                        nom_cmp = info_comp_epx[loi][
                            'VAR_ASTER'][:nb_var_aster]
                        nom_cmp_med = info_comp_epx[loi][
                            'VAR_EPX'][:nb_var_aster]
                        lcc = lc.copy()
                        lcc.update(
                            NOM_MED=champ,
                            NOM_CMP=nom_cmp,
                            NOM_CMP_MED=nom_cmp_med,
                        )
                        __ECR1[j] = LIRE_CHAMP(**lcc)
                        dicAsse3.append({
                            'TOUT': 'OUI',
                            'CHAM_GD': __ECR1[j],
                            'NOM_CMP': nom_cmp,
                            'CUMUL': 'OUI',
                            'COEF_R': 1.
                        })
                        dicDetr.append({'NOM': __ECR1[j]})
                        j += 1
                else:
                    nb_champ_transfo = len(dic_champ_var_int[compo].keys())
                    dicDetr_transfo = []
                    if nb_champ_transfo == 1:
                        champ = dic_champ_var_int[compo].keys()[0]
                        loi = dic_champ_var_int[compo][champ]
                        nb_var_epx = info_comp_epx[loi]['NB_VAR_EPX']
                        nom_cmp = info_comp_epx[loi]['VAR_ASTER'][:nb_var_epx]
                        nom_cmp_med = info_comp_epx[loi][
                            'VAR_EPX'][:nb_var_epx]
                        lcc = lc.copy()
                        lcc.update(
                            NOM_MED=champ,
                            NOM_CMP=nom_cmp,
                            NOM_CMP_MED=nom_cmp_med,
                        )
                        __ECR_AS = LIRE_CHAMP(**lcc)
                    else:
                        __ECR = [None] * nb_champ_transfo
                        dicAsse_transfo = []
                        for k, champ in enumerate(
                                dic_champ_var_int[compo].keys()):
                            loi = dic_champ_var_int[compo][champ]
                            nb_var_epx = info_comp_epx[loi]['NB_VAR_EPX']
                            nom_cmp = info_comp_epx[loi][
                                'VAR_ASTER'][:nb_var_epx]
                            nom_cmp_med = info_comp_epx[loi][
                                'VAR_EPX'][:nb_var_epx]
                            lcc = lc.copy()
                            lcc.update(
                                NOM_MED=champ,
                                NOM_CMP=nom_cmp,
                                NOM_CMP_MED=nom_cmp_med,
                            )
                            __ECR[k] = LIRE_CHAMP(**lcc)

                            dicAsse_transfo.append({
                                'TOUT': 'OUI',
                                'CHAM_GD': __ECR[k],
                                'NOM_CMP': nom_cmp,
                                'CUMUL': 'OUI',
                                'COEF_R': 1.
                            })
                            dicDetr_transfo.append({'NOM': __ECR[k]})
                        # assemblage
                        ccc = cc.copy()
                        ccc.update(
                            TYPE_CHAM='ELGA_VARI_R',
                            ASSE=dicAsse_transfo,
                        )
                        __ECR_AS = CREA_CHAMP(**ccc)
                    dicDetr_transfo.append({'NOM': __ECR_AS})
                    cham_para = __ECR_AS
                    cham_fonc = dic_transfo[compo]['CH_FONC']
                    # EVAL : transormation EPX -> Aster
                    try:
                        __ECR1[j] = CREA_CHAMP(
                            OPERATION='EVAL',
                            TYPE_CHAM='ELGA_NEUT_R',
                            CHAM_F=cham_fonc,
                            CHAM_PARA=cham_para,
                        )
                        dicDetr.append({'NOM': __ECR1[j]})
                    except:
                        compor_aster = self.info_comp_epx[compo][
                            'COMPOR_ASTER']
                        UTMESS('F', 'PLEXUS_57', valk=compor_aster)
                    nom_cmp = dic_transfo[compo]['NOM_CMP']
                    nom_cmp_f = dic_transfo[compo]['NOM_CMP_F']
                    dicAsse3.append({
                        'TOUT': 'OUI',
                        'CHAM_GD': __ECR1[j],
                        'NOM_CMP': nom_cmp_f,
                        'NOM_CMP_RESU': nom_cmp,
                        'CUMUL': 'OUI',
                        'COEF_R': 1.
                    })
                    DETRUIRE(CONCEPT=dicDetr_transfo, INFO=1)
                    j += 1

            if dicAsse != []:
                ccc = cc.copy()
                ccc.update(
                    TYPE_CHAM='ELGA_SIEF_R',
                    ASSE=dicAsse,
                )
                __EFFG[i] = CREA_CHAMP(**ccc)

                dic = {
                    'MODELE': self.MODELE,
                    'INST': resu.LIST_PARA()['INST'][i],
                }
                if self.CHAM_MATER is not None:
                    dic['CHAM_MATER'] = self.CHAM_MATER
                if self.CARA_ELEM_CONCEPT is not None:
                    dic['CARA_ELEM'] = self.CARA_ELEM_CONCEPT

                dic['CHAM_GD'] = __EFFG[i]
                dicAffe.append(dic)

            if dicAsse3 != []:
                ccc = cc.copy()
                ccc.update(TYPE_CHAM='ELGA_VARI_R', ASSE=dicAsse3)
                __ECRG[i] = CREA_CHAMP(**ccc)

                dic2 = dic.copy()
                dic2['CHAM_GD'] = __ECRG[i]
                dicAffe3.append(dic2)

            if dicDetr != []:
                DETRUIRE(CONCEPT=dicDetr, INFO=1)
        RetablirAlarme('MED_4')

        MasquerAlarme('COMPOR2_26')
        MasquerAlarme('COMPOR2_23')

        if dicAffe != []:
            resu = CREA_RESU(
                reuse=resu,
                OPERATION='AFFE',
                TYPE_RESU='EVOL_NOLI',
                NOM_CHAM='SIEF_ELGA',
                AFFE=dicAffe,
            )

        if dicAffe3 != []:
            resu = CREA_RESU(
                reuse=resu,
                OPERATION='AFFE',
                TYPE_RESU='EVOL_NOLI',
                NOM_CHAM='VARI_ELGA',
                AFFE=dicAffe3,
            )
        RetablirAlarme('COMPOR2_26')
        RetablirAlarme('COMPOR2_23')

        if self.modi_repere['COQUE']:
            from code_aster.Cata.Commands import MODI_REPERE
            MODI_REPERE(RESULTAT=resu,
                        reuse=resu,
                        REPERE='COQUE_INTR_UTIL',
                        MODI_CHAM=_F(TYPE_CHAM='COQUE_GENE',
                                     NOM_CHAM='SIEF_ELGA',
                                     NOM_CMP=('NXX', 'NYY', 'NXY', 'MXX',
                                              'MYY', 'MXY', 'QX', 'QY')))
Exemplo n.º 5
0
def var_int_a2e(compor_gr, resu, mod, nume_ordre):
    """
        Transforme le champ VARI_ELGA pour correspondre aux attentes d'EPX
        Renvoie un résultat contenant les champs DEPL, SIEF_ELGA et VARI_ELGA
        transformé du NUME_ORDRE nume_ordre du résultat resu.
    """
    from code_aster.Cata.Commands import CREA_RESU

    # extraction des champs :

    __DEPL = CREA_CHAMP(
        OPERATION='EXTR',
        TYPE_CHAM='NOEU_DEPL_R',
        RESULTAT=resu,
        NOM_CHAM='DEPL',
        INST=nume_ordre,
    )
    __SIEF = CREA_CHAMP(
        OPERATION='EXTR',
        TYPE_CHAM='ELGA_SIEF_R',
        RESULTAT=resu,
        NOM_CHAM='SIEF_ELGA',
        INST=nume_ordre,
    )
    __VARI = CREA_CHAMP(
        OPERATION='EXTR',
        TYPE_CHAM='ELGA_VARI_R',
        RESULTAT=resu,
        NOM_CHAM='VARI_ELGA',
        INST=nume_ordre,
    )
    # transformation

    nb_compor = len(compor_gr)
    __VARICO = [None] * nb_compor
    asse = []
    for ico, compor in enumerate(compor_gr.keys()):
        gr_ma = compor_gr[compor]
        nb_var_epx = cata_compor[compor]['NB_VAR_EPX']
        nom_cmp = ['V%i' % ii for ii in range(1, nb_var_epx + 1)]
        if compor == 'VMIS_JOHN_COOK':
            tr_a2e_vmis_john_cook(__VARICO, ico, gr_ma, mod, __VARI,
                                  nume_ordre, resu)
        else:
            vale = [0.] * nb_var_epx
            __VARICO[ico] = CREA_CHAMP(OPERATION='AFFE',
                                       TYPE_CHAM='ELGA_VARI_R',
                                       MODELE=MODELE,
                                       PROL_ZERO='NON',
                                       AFFE=(_F(GROUP_MA='CUBE',
                                                NOM_CMP=nom_cmp,
                                                VALE=vale), ))
            UTMESS('A', 'PLEXUS_47', valk=compor)

        asse.append({
            'GROUP_MA': gr_ma,
            'CHAM_GD': __VARICO[ico],
            'NOM_CMP': nom_cmp,
            'CUMUL': 'NON',
            'COEF_R': 1.
        })
    if len(asse) == 0:
        UTMESS('A', 'PLEXUS_48')

    __VARITR = CREA_CHAMP(
        OPERATION='ASSE',
        MODELE=mod,
        TYPE_CHAM='ELGA_VARI_R',
        PROL_ZERO='OUI',
        ASSE=asse,
    )

    # construction du concept resultat
    MasquerAlarme('COMPOR2_23')
    __res = CREA_RESU(OPERATION='AFFE',
                      TYPE_RESU='EVOL_NOLI',
                      NOM_CHAM='DEPL',
                      AFFE=(_F(
                          CHAM_GD=__DEPL,
                          MODELE=mod,
                          INST=1.0,
                      ), ))

    __res = CREA_RESU(
        reuse=__res,
        OPERATION='AFFE',
        TYPE_RESU='EVOL_NOLI',
        NOM_CHAM='SIEF_ELGA',
        AFFE=_F(
            CHAM_GD=__SIEF,
            MODELE=mod,
            INST=1.0,
        ),
    )

    __res = CREA_RESU(
        reuse=__res,
        OPERATION='AFFE',
        TYPE_RESU='EVOL_NOLI',
        NOM_CHAM='VARI_ELGA',
        AFFE=_F(
            CHAM_GD=__VARITR,
            MODELE=mod,
            INST=1.0,
        ),
    )
    RetablirAlarme('COMPOR2_23')
    return __res