예제 #1
0
def run_eficas_tool(mod, felt=None):
    """Run the Eficas editor"""
    fname = None
    if felt:
        fname = felt.read_fname()
    log_gui.debug("run_eficas_tool: filename=%s", fname)
    aster_s_gui.run_eficas(com_fname=fname)
 def update(self, value):
     """Update the field value and run the qt Wizard checking mechanism
     """
     log_gui.debug("update value of field %s with : %s", repr(self._name), value)
     wid = self._store_widget
     wid.setProperty("python-object", value)
     wid.emit(self._sig)
def update_mesh(mod, case, silent=False):
    """Update mesh using eficas"""
    comm = case.get(aster_s.CommFile) or case.get(aster_s.CommEntry)
    if not comm:
        mod.launch(ERROR, "The case has no command file")
        return
    smesh = case.get(aster_s.SMeshEntry)
    if not smesh:
        mod.launch(ERROR, "The case has no SMESH object")
        return
    aster_version = case.get(aster_s.AstkParams)["aster-version"]
    grps = None
    prev = None
    for vers in (aster_version, aster_s.ASTER_REFVERSION):
        if prev is not None:
            log_gui.warn("update-mesh failed using version '%s', try with '%s'.", prev, vers)
        try:
            log_gui.debug("update_mesh: call list_groups_with_eficas(%s, %s)",
                          comm.read_fname(), vers)
            grps = aster_s_gui.list_groups_with_eficas(comm.read_fname(), vers)
        except Exception, e:
            # ignore all eficas failure
            print "Traceback of failure:\n%s" % e
            log_gui.debug("Traceback of failure:\n%s", traceback.format_exc())
        if grps is not None:
            break
        prev = vers
예제 #4
0
def stop(mod, case):
    """Stop study case"""
    rjobs = mod.running_jobs
    name = case.read_name()
    log_gui.debug("stop: case name=%s", name)
    if not rjobs.is_free(name):
        rjobs.stop(name)
예제 #5
0
def read_as_text(mod, sfile):
    """Read as a text file"""
    content = ""
    fname = sfile.read_fname()
    #peter.zhang, for cygwin
    fname = fname.replace('\\', '/')
    fname = fname.replace('/cygdrive/', '')
    if fname.find(':/') < 0:
        fname = fname.replace('/', ':/', 1)
    log_gui.debug("read_as_text: filename = %s", fname)
    if fname:
        fid = open(fname)
        content = fid.read()
        fid.close()

    dia = qt.QDialog(mod.give_qtwid())
    dia.setSizePolicy(qt.QSizePolicy.Maximum,
                      qt.QSizePolicy.Maximum)  #XXX does not work!
    lay = qt.QVBoxLayout(dia)

    brw = qt.QTextBrowser()
    brw.setPlainText(content)
    lay.addWidget(brw)

    but = qt.QPushButton("Close")
    connect(but, SIG("clicked()"), dia.deleteLater)
    lay.addWidget(but)
    #dia.resize(dia.size())
    dia.show()
예제 #6
0
 def on_use_pair(self,state):
     if(state == qtc.Qt.Checked):
       self.use_nolinear = True
       self.pair_sel._tab.show()
     else:
       self.pair_sel._tab.hide()
       self.use_nolinear = False
     log_gui.debug("on_use_pair:%d",state)
예제 #7
0
 def update(self, value):
     """Update the field value and run the qt Wizard checking mechanism
     """
     log_gui.debug("update value of field %s with : %s", repr(self._name),
                   value)
     wid = self._store_widget
     wid.setProperty("python-object", value)
     wid.emit(self._sig)
예제 #8
0
 def flags(self, midx):
     """Tell to Qt mechanism that each cell is enabled and editable"""
     flags = qtc.Qt.ItemIsEditable | qtc.Qt.ItemIsEnabled
     if (midx.row() + 1 == self.rowCount(ROOT_MIDX)):
         flags = qtc.Qt.ItemIsSelectable
     else:
         flags = self._sel.flaglists[midx.row()][midx.column()]
     log_gui.debug("flags: %d row: %d column: %d",self._sel.flaglists[midx.row()][midx.column()],midx.row(),midx.column())
     return flags
예제 #9
0
 def set_pressure_type(self,typename):
     midx = self._sel.get_view().currentIndex()
     comb = self.sender()
     if (midx.row() + 1 == self.rowCount(ROOT_MIDX) or midx.column() + 1 == self.columnCount(ROOT_MIDX)):
        return
     else:
        cond = self._sel.give_cond(midx.row())
        cond[midx.column()] = typename
        log_gui.debug("set_pressure_type with want data %s cond_data %s", typename, cond)
        self._sel.notify_wizard()
     log_gui.debug("set_pressure_type with want data %s comb %s", typename, comb)
예제 #10
0
 def update(self):
     if self._job.status() is aster_s.ENDED:
         log_gui.debug("[DEBUG] RunningJob.update call job.get_diag")
         res, has_results = self._job.get_diag()
         log_gui.debug("[DEBUG] RunningJob.update res: %s, bool:%s", res,
                       has_results)
         #self._mod.notify_job_ended(self._name, res, has_results)
         self._job.terminate()
         self._mod.update()
         self._timer.stop()
         self._timer.deleteLater()
         self._rjobs.remove(self._name)
예제 #11
0
 def run_action_from(self, action_idx):
     """Run an action from its index"""
     try:
         self.actions.run(action_idx)
     except TypeError, err:
         log_gui.debug("Traceback of failure:\n%s", traceback.format_exc())
         corba_mesh_error = re.search("corba.*mesh", str(err),
                                      re.IGNORECASE) != None
         if corba_mesh_error:
             mess = "You must activate the SMESH component before using " \
                    "this case which refers to a Mesh object."
             self.launch(ERROR, mess)
         raise TypeError(err)
예제 #12
0
def run(mod, case):
    """Run study case"""
    name = case.read_name()
    log_gui.debug("run: case name=%s", name)
    if mod.running_jobs.is_busy(name):
        return
    comm = case.get(aster_s.CommFile) or case.get(aster_s.CommEntry)
    if comm is None:
        mod.launch(INFO, "This case has no command file!")
        return
    if case.has_changed():
        log_gui.info("The mesh is updating...")
        update_mesh(mod, case, silent=True)
예제 #13
0
    def accept(self, mesh):
        """Accept the mesh is valid"""
        ugeom = self._use_geom
        ctype = ExpStore.smesh
        if ugeom.isEnabled() and ugeom.isChecked():
            ctype = ExpStore.geom
        self._exp_store.use(ctype)

        exp = self._exp_store.give_compo_exp()
        is_valid = False
        if exp.validate(mesh, self._mod):
            is_valid = True
        log_gui.debug("ExploratorSelector.accept returns %s", is_valid)
        return is_valid
예제 #14
0
 def set_pressure_type(self,typename):
     midx = self._sel._tab.currentIndex()
     comb = self.sender()
     if (midx.row() + 1 == self.rowCount(ROOT_MIDX) or midx.column() + 1 == self.columnCount(ROOT_MIDX)):
        return
     else:
        cond = self._sel.give_cond(midx.row())
        cond[midx.column()] = typename
        log_gui.debug("set_pressure_type with want data %s row %s clomn %s cond_data %s", typename, midx.row(), midx.column(), cond)
        self._sel.notify_wizard()
        beg = self.index(midx.row(),midx.column() + 1)
        endind = self.index(midx.row(),midx.column() + 3)
        self.emit(SIG("dataChanged"),beg,endind)
     log_gui.debug("set_pressure_type with want data %s comb %s", typename, comb)
예제 #15
0
 def flags(self, midx):
     """Tell to Qt mechanism that each cell is enabled and editable"""
     flags = qtc.Qt.ItemIsEditable | qtc.Qt.ItemIsEnabled
     if (midx.row() + 1 == self.rowCount(ROOT_MIDX)):
         flags = qtc.Qt.ItemIsSelectable
     else:
         cond = self._sel.give_cond(midx.row())
         if(cond.__contains__(u"Pressure")):
            if(midx.column() > 2):
              flags = qtc.Qt.ItemIsSelectable
            else:
              flags = qtc.Qt.ItemIsEditable | qtc.Qt.ItemIsEnabled
     log_gui.debug("flags: %d row: %d column: %d",flags,midx.row(),midx.column())
     return flags
    def accept(self, mesh):
        """Accept the mesh is valid"""
        ugeom = self._use_geom
        ctype = ExpStore.smesh
        if ugeom.isEnabled() and ugeom.isChecked():
            ctype = ExpStore.geom
        self._exp_store.use(ctype)

        exp = self._exp_store.give_compo_exp()
        is_valid = False
        if exp.validate(mesh, self._mod):
            is_valid = True
        log_gui.debug("ExploratorSelector.accept returns %s", is_valid)
        return is_valid
예제 #17
0
def status(mod, case):
    """Ask study case status"""
    lines = []
    name = case.read_name()
    if mod.running_jobs.has(name):
        log_gui.debug("status: case name=%s is running", name)
        lines.append(u"The study case is running")
    else:
        lines.append(u"The study case is not running")
        astk_status = case.read_value()
        log_gui.debug("status: case name=%s is ended with status=%s", name, astk_status)
        if astk_status is not None:
            lines.append(u"The result given by ASTK is '%s'" % astk_status)
    mod.launch(INFO, os.linesep.join(lines))
def is_valid_mesh(cexp, mesh, mod):
    """A valid mesh needs to have groups for pressure"""
    is_valid = True
    log_gui.debug("is_valid_mesh %s / %s", mesh, mod)
    if not mesh:
        mess = "A mesh is required"
        mod.launch(aster_s_gui.ERROR, mess)
        is_valid = False
        return is_valid
    if not cexp.give("pressure").find_groups(mesh):
        mess = "At least a group without nodes need to be defined " \
               "on the selected object"
        mod.launch(aster_s_gui.ERROR, mess)
        is_valid = False
    return is_valid
 def run_action_from(self, action_idx):
     """Run an action from its index"""
     try:
         #print "Check Run"
         self.actions.run(action_idx)
     except TypeError, err:
         #print "Check TypeError"
         #print err
         log_gui.debug("Traceback of failure:\n%s", traceback.format_exc())
         corba_mesh_error = re.search("corba.*mesh", str(err), re.IGNORECASE) != None
         if corba_mesh_error:
             mess = "You must activate the SMESH component before using " \
                    "this case which refers to a Mesh object."
             self.launch(ERROR, mess)
         raise TypeError(err)
예제 #20
0
def is_valid_mesh(cexp, mesh, mod):
    """A valid mesh needs to have groups for pressure"""
    is_valid = True
    log_gui.debug("is_valid_mesh %s / %s", mesh, mod)
    if not mesh:
        mess = "A mesh is required"
        mod.launch(aster_s_gui.ERROR, mess)
        is_valid = False
        return is_valid
    if not cexp.give("pressure").find_groups(mesh):
        mess = "At least a group without nodes need to be defined " \
               "on the selected object"
        mod.launch(aster_s_gui.ERROR, mess)
        is_valid = False
    return is_valid
def run_stanley_tool(mod, base_elt, force_local=True):
    """Run the Stanley explorator"""
    aster_version = None
    server = None
    res_node = base_elt.node.parent
    if res_node:
       case_node = res_node.parent
       if case_node:
           case = AS.load_elt_from_node(case_node)
           aster_version = case.get(aster_s.AstkParams)["aster-version"]
           server        = case.get(aster_s.AstkParams)["server"]
    dname = base_elt.read_dname()
    log_gui.debug("run_stanley_tool: dname=%s aster_version=%s server=%s",
                  dname, aster_version, server)
    if dname is not None:
        aster_s.run_stanley(dname, aster_version, server, force_local)
예제 #22
0
    def save_linear(self): #保存到comm文件中
    
        comm = LS.CommWriter()
        comm.use(LS.Modelisation(self.get_sel_itm().get_model_type()))
        
        gm = LS.GrpMaterial()
        gm.clear_part()
        grp_material = comm.use(gm)
        #grp_material.add(LS.Material(self.get_material()))#material
        grp_material.add(LS.Material(self.get_material()))#material
        grp_material.add(LS.GroupMaterial(self.materials_conds))#grouop-material
        

        mech_consts = comm.use(LS.MechConstraints())
        bound_conds = mech_consts.add(LS.BoundConds())
        mesh = self.mesh
        exp = self.exp_store.give_exp("boundaries")
        
        log_gui.debug("save_linear %d", len(self.degrees_conds))
        if len(self.degrees_conds):
            for cond in self.degrees_conds:
                gname = str(cond[0])
                grp_type = exp.give_group_key(mesh, gname)
                bound_conds.add(LS.DplFromName(grp_type, gname, *cond[1:]))
        else:
            mess = "Warning: You have not defined boundary conditions  "
            self.mod.launch(aster_s_gui.INFO, mess)
            
        mech_consts.add(LS.BoundEnd(len("CHARC=AFFE_CHAR_MECA"),");"))
        mech_consts.add(LS.PressStart(0,"CHARF=AFFE_CHAR_MECA(MODELE=MODX,"))

        pressure = mech_consts.add(LS.Pressure() )#here
        forceface = mech_consts.add(LS.ForceFace() )#here 
        forcenodale = mech_consts.add(LS.ForceNodale() )#here
        
        for gname, ptype, v1,v2,v3,v4,v5,v6 in self.pressure_conds:
            if ptype =="Pressure":
                pressure.add(LS.GrpPres(str(gname), v1))
            elif ptype =="Force_Face":
                forceface.add(LS.ForceFaceArgs(str(gname), v1,v2,v3))
            elif ptype =="Force_Node":
                 forcenodale.add(LS.ForceNodaleArgs(str(gname), v1,v2,v3,v4,v5,v6,self.get_dim()))

        comm.write(self.comm_path)
        #self.add_case("linear-static")
        return True
예제 #23
0
    def valid_by_group(self):
        if(self._data.grouptypesel != 0):
            self._conds = self._data.degrees_conds
            cexp = self._data.exp_store
            exp = cexp.give_exp("pressure")
            mesh = self._data.mesh
            log_gui.debug("valid_by_group by group type %s, mesh %s", self._data.grouptypesel,mesh)
            grp_names = exp.find_groups(mesh)
            self._grp_names = grp_names
            self._valided = True
            
            dim = self._data.get_dim()
            if (len(grp_names)>0):
               if self._condition_type==0:
                  head_names =[u"Group", u"DX", u"DY"]
                  if (dim == WCD.Dim_Type.Three_Dim):
                     head_names.append(u"DZ")

            checklist = [qtc.Qt.Checked]*len(head_names)
            val_list = [.0]*(len(head_names)-1)
            self._default_cond = [grp_names[0]] + val_list
            self._default_check = checklist
            self._default_flag = [qtc.Qt.ItemIsEditable | qtc.Qt.ItemIsEnabled] + [qtc.Qt.ItemIsEditable | qtc.Qt.ItemIsEnabled | qtc.Qt.ItemIsUserCheckable] * (len(head_names) - 1) #第一列的数据不需要check 
            #self._default_flag = [qtc.Qt.ItemIsEditable | qtc.Qt.ItemIsEnabled] + [qtc.Qt.ItemIsEnabled | qtc.Qt.ItemIsUserCheckable] * (len(head_names) - 1) #第一列的数据不需要check 
            model = Ast_D_of_F_Model(self, head_names)
            self._tab.setModel(model)
            self._tab.setEnabled(True)
            self._tab.horizontalHeader().setClickable(True)
            self._tab.setItemDelegate(WC.ValueDelegate(self))
            self._tab.setItemDelegateForColumn(0,WC.AstGroupDelegate(self,self._grp_names))
            self.add_cond()
            
            icolumn = 0
            for iname in head_names:
                width = 80
                if icolumn > 0:
                   width = 60
                self._tab.setColumnWidth(icolumn,width) 
                icolumn += 1
            self.is_reseted = False
        else:
            self._build()
def run(mod, case):
    """Run study case"""
    name = case.read_name()
    log_gui.debug("run: case name=%s", name)
    if mod.running_jobs.is_busy(name):
        return
    comm = case.get(aster_s.CommFile) or case.get(aster_s.CommEntry)
    if comm is None:
        mod.launch(INFO, "This case has no command file!")
        return
    if case.has_changed():
        log_gui.info("The mesh is updating...")
        update_mesh(mod, case, silent=True)
    else:
        log_gui.debug("No mesh update required.")
    try:
        job = case.run()
        mod.running_jobs.add(name, job, refresh_time=2000.)
        case.write_value("RUNNING")
        mod.loginfo("Job '%s' submitted" % name)
    except EnvironmentError, error:
        job = None
        case.write_value("SUBMISSION ERROR")
        mod.loginfo("Submission failed")
        log_gui.debug("Traceback of failure:\n%s", traceback.format_exc())
예제 #25
0
 def setData(self, midx, value,  role = qtc.Qt.EditRole):
     if(role == qtc.Qt.CheckStateRole):
        state,_ = value.toInt()
        self._sel.checklists[midx.row()][midx.column()] = state
        log_gui.debug("setData before: %d row: %d column: %d",self._sel.flaglists[midx.row()][midx.column()],midx.row(),midx.column())
        if (state == qtc.Qt.Unchecked):
           #self._sel.flaglists[midx.row()][midx.column()] &= ~(qtc.Qt.ItemIsEditable) 
           self._sel.flaglists[midx.row()][midx.column()] = self._sel.flaglists[midx.row()][midx.column()] & (~(qtc.Qt.ItemIsEditable) )
           cond = self._sel.give_cond(midx.row())
           cond[midx.column()] = None
        else:
           #self._sel.flaglists[midx.row()][midx.column()] |= qtc.Qt.ItemIsEditable
           self._sel.flaglists[midx.row()][midx.column()] = self._sel.flaglists[midx.row()][midx.column()] | qtc.Qt.ItemIsEditable
           cond = self._sel.give_cond(midx.row())
           cond[midx.column()] = 0
        log_gui.debug("setData: %d row: %d column: %d ",self._sel.flaglists[midx.row()][midx.column()],midx.row(),midx.column())
        
        """row = 0
        for flist in self._sel.flaglists:
            column = 0
            for a in flist:
                log_gui.debug("row: %d column: %d flag: %d",row,column,self._sel.flaglists[row][column])
                column += 1
        row += 1"""
        return True
     else:
        log_gui.debug("setData: %d row: %d column: %d",self._sel.flaglists[midx.row()][midx.column()],midx.row(),midx.column())
        return WC.AstConditionsModel.setData(self,value,role)
예제 #26
0
    def valid_by_group(self):
        self._conds = self._data.pair_conds
        if(self._data.grouptypesel != 0):
            cexp = self._data.exp_store
            exp = cexp.give_exp("pressure")
            mesh = self._data.mesh
            log_gui.debug("Ast_Pair_Selector valid_by_group by group type %s, mesh %s", self._data.grouptypesel,mesh)
            grp_names = exp.find_groups(mesh)
            self._grp_names = grp_names
            self._grp_names.reverse()
            self._valided = True
            
            dim = self._data.get_dim()
            head_names =[u"Type", u"Mater group", u"Slave group", u"Friction Coefficient"]
            type_name = [u"bond", u"Frictionless", u"Friction"]

            self._default_cond = [type_name[0]] + [self._grp_names[0]] + [self._grp_names[0]] + [0]
            
            for i in self._default_cond:
              log_gui.debug("Ast_Pair_Selector _default_cond %s", i)

            model = Ast_Pair_Model(self, head_names)
            self._tab.setModel(model)
            self._tab.setEnabled(True)
            self._tab.horizontalHeader().setClickable(True)
            self._tab.setItemDelegate(WC.ValueDelegate(self))
            self._tab.setItemDelegateForColumn(0,WC.AstGroupDelegate(self,type_name))
            self._tab.setItemDelegateForColumn(1,WC.AstGroupDelegate(self,self._grp_names))
            self._tab.setItemDelegateForColumn(2,WC.AstGroupDelegate(self,self._grp_names))
            self.add_cond()
            
            width = [75,80,80,115,60,60,50,50]
            icolumn = 0
            for iname in head_names:
                self._tab.setColumnWidth(icolumn,width[icolumn]) 
                icolumn += 1
            self.is_reseted = False
        else:
            self._build()
 def __init__(self, wizard_page, name, initial_value):
     # A PushButton is used just for its signal without argument 'clicked()'
     # because custom signals can not be used:
     #
     # from PyQt4 import QtCore as qtc
     # from PyQt4 import QtGui as qt
     # app = qt.QApplication([])
     # wid = qt.QWidget()
     # page = qt.QWizardPage()
     # page.registerField("field*", wid, "prp", qtc.SIGNAL("updateField()"))
     # wiz = qt.QWizard()
     # wiz.addPage(page)
     # -> Object::connect: No such signal QWidget::updateField()
     #
     wid = qt.QPushButton()
     wid.setProperty("python-object", initial_value)
     # The Qt mechanism will check the property value when this signal
     # is emitted.
     wizard_page.registerField(name, wid, "python-object", self._sig)
     self._store_widget = wid
     self._name = name
     log_gui.debug("registerField (%s) with initial value : %s", repr(name), initial_value)
예제 #28
0
    def valid_by_group(self):
        self._conds = self._data.pressure_conds
        if(self._data.grouptypesel != 0):
            cexp = self._data.exp_store
            exp = cexp.give_exp("pressure")
            mesh = self._data.mesh
            log_gui.debug("valid_by_group by group type %s, mesh %s", self._data.grouptypesel,mesh)
            grp_names = exp.find_groups(mesh)
            self._grp_names = grp_names
            self._valided = True
            
            dim = self._data.get_dim()
            if (len(grp_names)>0):
               if self._condition_type==0:
                  head_names = copy.copy(self.head_name)
                  if (dim == WCD.Dim_Type.Three_Dim):
                     head_names.append(u"")
            log_gui.debug("valid_by_group head_names: %d",len(head_names))

            val_list = [.0]*(len(head_names) - 2)
            self._default_cond = [grp_names[0], u"Pressure"] + val_list
            model = Ast_Pressure_Model(self, head_names)
            self._tab.setModel(model)
            self._tab.setEnabled(True)
            self._tab.horizontalHeader().setClickable(True)
            self._tab.setItemDelegate(WC.ValueDelegate(self))
            self._tab.setItemDelegateForColumn(0, WC.AstGroupDelegate(self, self._grp_names)) 
            self._tab.setItemDelegateForColumn(1, WC.AstGroupDelegate(self, self._pressure_types)) 
            self.add_cond()
            
            width = [80,90,60,60,60,60,60,60,60,60,60,60]
            icolumn = 0
            for iname in head_names:
                self._tab.setColumnWidth(icolumn,width[icolumn]) 
                icolumn += 1
            self.is_reseted = False
        else:
            self._build()
예제 #29
0
 def __init__(self, wizard_page, name, initial_value):
     # A PushButton is used just for its signal without argument 'clicked()'
     # because custom signals can not be used:
     #
     # from PyQt4 import QtCore as qtc
     # from PyQt4 import QtGui as qt
     # app = qt.QApplication([])
     # wid = qt.QWidget()
     # page = qt.QWizardPage()
     # page.registerField("field*", wid, "prp", qtc.SIGNAL("updateField()"))
     # wiz = qt.QWizard()
     # wiz.addPage(page)
     # -> Object::connect: No such signal QWidget::updateField()
     #
     wid = qt.QPushButton()
     wid.setProperty("python-object", initial_value)
     # The Qt mechanism will check the property value when this signal
     # is emitted.
     wizard_page.registerField(name, wid, "python-object", self._sig)
     self._store_widget = wid
     self._name = name
     log_gui.debug("registerField (%s) with initial value : %s", repr(name),
                   initial_value)
def read_as_text(mod, sfile):
    """Read as a text file"""
    content = ""
    fname = sfile.read_fname()
    log_gui.debug("read_as_text: filename = %s", fname)
    if fname:
        fid = open(fname)
        content = fid.read()
        fid.close()

    dia = qt.QDialog(mod.give_qtwid())
    dia.setSizePolicy(qt.QSizePolicy.Maximum, qt.QSizePolicy.Maximum) #XXX does not work!
    lay = qt.QVBoxLayout(dia)

    brw = qt.QTextBrowser()
    brw.setPlainText(content)
    lay.addWidget(brw)

    but = qt.QPushButton("Close")
    connect(but, SIG("clicked()"), dia.deleteLater)
    lay.addWidget(but)
    #dia.resize(dia.size())
    dia.show()
예제 #31
0
    def valid_by_group(self):
        if (self._data.grouptypesel != 0):
            cexp = self._data.exp_store
            exp = cexp.give_exp("pressure")
            mesh = self._data.mesh
            log_gui.debug("valid_by_group by group type %s, mesh %s",
                          self._data.grouptypesel, mesh)
            grp_names = exp.find_groups(mesh)
            self._grp_names = grp_names
            self._valided = True
            dims = self._data.get_group_dims()
            head_names = [u"Group"] + [dim[0] for dim in dims]

            checklist = [False] * len(dims)
            self._default_cond = [grp_names[0]] + checklist

            if self._grp_names:
                #self._tab.setItemDelegateForColumn(0, WC.GroupDelegate(self, self._grp_names))
                for i in range(len(dims)):
                    self._tab.setItemDelegateForColumn(i + 1,
                                                       CheckDelegate(self))

            model = WC.AstConditionsModel(self, head_names)
            self._tab.setModel(model)
            self._tab.setEnabled(True)
            self._tab.horizontalHeader().setClickable(True)
            icolumn = 0
            for iname in head_names:
                width = 80
                if icolumn > 0:
                    width = 60
                self._tab.setColumnWidth(icolumn, width)
                icolumn += 1
            self.is_reseted = False
        else:
            self._build()
예제 #32
0
 def add_cond(self):
     """Add a condition to the table"""
     if not self._default_cond:
         return
     model = self._tab.model()
     conds = self._conds
     end_idx = len(conds)
     model.beginInsertRows(qtc.QModelIndex(), end_idx, end_idx)
     conds.append(list(self._default_cond))
     
     log_gui.debug("Ast_D_of_F_Selector conds num:%d",len(conds))
     log_gui.debug("Ast_D_of_F_Selector conds num:%d",len(self._conds))
     log_gui.debug("Ast_D_of_F_Selector conds num:%d",len(self._data.degrees_conds))
     
     self.checklists.append(list(self._default_check))
     self.flaglists.append(list(self._default_flag))
     model.endInsertRows()
     idx = model.index(end_idx, self._groupcolumn, ROOT_MIDX)
     self.notify_wizard()
 def _load_msh(self):
     """Load mesh from Aster module"""
     log_gui.debug("_load_msh begin")
     mod = self._mod
     mesh = mod.load_mesh_from_selection()
     if not mesh:
         mod.launch(GC.ERROR, "The selected entry is not a mesh "
             "or the SMESH component must be activated")
         return
     mdim = mesh.give_dim()
     if (mdim != self._model.dim):
         mess = self.no_dim_mess
         if type(mdim) is int:
             mess = self.dim_mess % (mdim, self._model.dim)
         mod.launch(GC.ERROR, mess)
         return
     self._lab.setText(mesh.read_name())
     self._exp_sel.notify(mesh)
     log_gui.debug("_load_msh update field with mesh = %s", mesh)
     self._wfield.update(mesh)
     log_gui.debug("_load_msh end")
예제 #34
0
 def _load_msh(self):
     """Load mesh from Aster module"""
     log_gui.debug("_load_msh begin")
     mod = self._mod
     mesh = mod.load_mesh_from_selection()
     if not mesh:
         mod.launch(
             GC.ERROR, "The selected entry is not a mesh "
             "or the SMESH component must be activated")
         return
     mdim = mesh.give_dim()
     if (mdim != self._model.dim):
         mess = self.no_dim_mess
         if type(mdim) is int:
             mess = self.dim_mess % (mdim, self._model.dim)
         mod.launch(GC.ERROR, mess)
         return
     self._lab.setText(mesh.read_name())
     self._exp_sel.notify(mesh)
     log_gui.debug("_load_msh update field with mesh = %s", mesh)
     self._wfield.update(mesh)
     log_gui.debug("_load_msh end")
 def validatePage(self):
     """Tell the mesh to use meshes or geometrical groups"""
     log_gui.debug("validateMeshPage called")
     mesh = self.give_field("mesh")
     log_gui.debug("mesh : %s", mesh)
     return self._esel.accept(mesh)
예제 #36
0
 def validatePage(self):
     """Tell the mesh to use meshes or geometrical groups"""
     log_gui.debug("validateMeshPage called")
     mesh = self.give_field("mesh")
     log_gui.debug("mesh : %s", mesh)
     return self._esel.accept(mesh)
def run_astk_tool(mod, case=None):
    """Run the ASTK client"""
    from_gui = salome_utils.getORBcfgInfo()[1:3]
    log_gui.debug("run_astk_tool: from_gui=%s", from_gui)
    aster_s.run_astk(case, from_gui)
예제 #38
0
    def save_nolinear(self):
        """Validate the wizard"""
        comm = LS.AstCommWriter()
        comm.use(LS.Modelisation(self.get_sel_itm().get_model_type()))
        gm = LS.GrpMaterial()
        gm.clear_part()
        grp_material = comm.use(gm)
            
        mech_consts = comm.use(LS.MechConstraints())
        bound_conds = mech_consts.add(LS.BoundConds())

        grp_material.add(LS.Material(self.get_material()))#material
        grp_material.add(LS.GroupMaterial(self.materials_conds))#grouop-material
        #####################BondContact#########
        bond_group=[]
        fric_group=[]
        fricless_group=[]
        grp_pair = self.pair_conds
        for g in grp_pair:
            if(str(g[0])==u"bond"):
               bond_group.append([str(g[1]),str(g[2])])
            if(str(g[0])==u"Friction"):
               fric_group.append([str(g[1]),str(g[2]),str(g[3])])
            if(str(g[0])==u"Frictionless"):
               fricless_group.append([str(g[1]),str(g[2]),"0.0"])
        
        bc=LS.BondContact(bond_group)
        bond_contact = comm.use(bc)
        bc.clear_part()
        
        #################################
        
        if(len(bond_group)):
             comm.use(WCD.HasBondContactKey("_F(CHARGE=CHA3)"))
        else:
             comm.use(WCD.HasBondContactKey(""))
        
        if(len(fric_group+fricless_group)):
             comm.use(WCD.HasfrictionContactKey("CONTACT = CONTA,"))
        else:
             comm.use(WCD.HasfrictionContactKey(""))
        #########################
        
        mc=LS.MechConstraints()
        mc.clear_consts()
        mech_consts = comm.use(mc)#start replace a line
        bound_conds = mech_consts.add(LS.BoundConds())#first sub section
        bound_conds.clear_consts()
        mesh = self.mesh
        exp = self.exp_store.give_exp("boundaries")
        
        log_gui.debug("save_nolinear %d", len(self.degrees_conds))
        if len(self.degrees_conds):
            for cond in self.degrees_conds:
                gname = str(cond[0])
                grp_type = exp.give_group_key(mesh, gname)
                bound_conds.add(LS.DplFromName(grp_type, gname, *cond[1:]))
        else:
            mess = "Warning: You have not defined boundary conditions  "
            self.mod.launch(aster_s_gui.INFO, mess)

        mech_consts.add(LS.BoundEnd(len("CHARC=AFFE_CHAR_MECA"),");"))
        mech_consts.add(LS.PressStart(0,"CHARF=AFFE_CHAR_MECA(MODELE=MODX,"))

        pressure = mech_consts.add(LS.Pressure() )#here
        forceface = mech_consts.add(LS.ForceFace() )#here 
        forcenodale = mech_consts.add(LS.ForceNodale() )#here
        
        for gname, ptype, v1,v2,v3,v4,v5,v6 in self.pressure_conds:
            if ptype =="Pressure":
                pressure.add(LS.GrpPres(str(gname), v1))
            elif ptype =="Force_Face":
                forceface.add(LS.ForceFaceArgs(str(gname), v1,v2,v3))
            elif ptype =="Force_Node":
                 forcenodale.add(LS.ForceNodaleArgs(str(gname), v1,v2))

        groups=set()
        for g in grp_pair:#todo:
            if(mesh.get_mesh_grounp_type(str(g[1])) != "VOLUME"):
                groups.add(str(g[1]))
            if(mesh.get_mesh_grounp_type(str(g[2])) != "VOLUME"):
                groups.add(str(g[2]))

        for g in groups:
            pressure.add_to_mesh_change(g)
            
        ##################
        par=[]
        tmp = exp.find_groups(mesh)
        for group_par in tmp:
            t = exp.give_group_key(mesh, group_par)
            print "@@@@1:",group_par,t
            if(t.__repr__()!="GROUP_NO"):
               par.append(group_par)
        par=str(par)
        par = par.replace('[','')
        par = par.replace(']','')
        comm.use(WCD.AllMeshGrounp(par))
        ##################
        
        contact=LS.Contact(fric_group+fricless_group)
        
        comm.use(contact)
        #contact.clear_part()
        comm.write(self.comm_path)
        return True
예제 #39
0
    def __init__(self, mod):
        desktop = mod.give_qtwid()
        qt.QDockWidget.__init__(self, desktop)
        self.data = MAData(mod)
        self.exp_store = self.data.exp_store

        self.setWindowTitle(u"Modal analysis")
        centralWidget = qt.QWidget(self)
        vlayout = qt.QVBoxLayout()
        centralWidget.setLayout(vlayout)
        label_for_model = qt.QLabel(
            u"What kind of model do you want to work on?", self)
        vlayout.addWidget(label_for_model)

        model_sel = WC.AstModelSel(self.data, self)
        model_sel.place(vlayout)

        vspacer = qt.QSpacerItem(20, 10, qt.QSizePolicy.Minimum,
                                 qt.QSizePolicy.Expanding)
        vlayout.addItem(vspacer)

        mesh_sel = WC.AstMeshSel(self.data, self)
        mesh_sel.place(vlayout)
        model_sel.add_related_component(mesh_sel)

        group_sel = WC.AstGroupTypeSel(self.data, self)
        connect(mesh_sel, SIG("mesh_valided"), group_sel.notify)
        model_sel.add_related_component(group_sel)

        group_sel.place(vlayout)

        vspacer = qt.QSpacerItem(20, 10, qt.QSizePolicy.Minimum,
                                 qt.QSizePolicy.Expanding)
        vlayout.addItem(vspacer)

        title = qt.QApplication.translate("", u"Elementary characteristics",
                                          None, qt.QApplication.UnicodeUTF8)
        log_gui.debug("title %s", title)

        grid = qt.QGridLayout()
        young = WC.YoungModulus()
        young.add_to(qt.QWidget(), grid, 0)

        dens = WC.Density()
        dens.add_to(qt.QWidget(), grid, 1)

        poisson = WC.PoissonRatio()
        poisson.add_to(qt.QWidget(), grid, 2)

        vlayout.addLayout(grid)

        vspacer = qt.QSpacerItem(20, 10, qt.QSizePolicy.Minimum,
                                 qt.QSizePolicy.Expanding)
        vlayout.addItem(vspacer)

        label_for_model = qt.QLabel(
            u"Adding imposed degrees of freedom on groups", self)
        vlayout.addWidget(label_for_model)

        degrees_sel = AstConditionsSelectorES(self.data, 0, self)
        #connect(group_sel,SIG("group_valided"),degrees_sel.valid_by_group)
        degrees_sel.add_to(vlayout)

        vspacer = qt.QSpacerItem(20, 10, qt.QSizePolicy.Minimum,
                                 qt.QSizePolicy.Expanding)
        vlayout.addItem(vspacer)

        group_sel.add_related_component(degrees_sel)

        mode_sel = AstModeSel(self.data, self)
        mode_sel.place(vlayout)

        hlayout = qt.QHBoxLayout()
        hspacer = qt.QSpacerItem(27, 20, qt.QSizePolicy.Expanding,
                                 qt.QSizePolicy.Minimum)
        hlayout.addItem(hspacer)
        btnok = qt.QPushButton("OK", centralWidget)
        btncancel = qt.QPushButton("Cancel", centralWidget)
        hlayout.addWidget(btnok)
        hlayout.addWidget(btncancel)
        vlayout.addLayout(hlayout)
        self.setWidget(centralWidget)
예제 #40
0
def run(mod, case):
    """Run study case"""
    name = case.read_name()
    log_gui.debug("run: case name=%s", name)
    if mod.running_jobs.is_busy(name):
        return
    comm = case.get(aster_s.CommFile) or case.get(aster_s.CommEntry)
    if comm is None:
        mod.launch(INFO, "This case has no command file!")
        return
    if case.has_changed():
        log_gui.info("The mesh is updating...")
        update_mesh(mod, case, silent=True)
    else:
        log_gui.debug("No mesh update required.")
    try:
        job = case.run()
        mod.running_jobs.add(name, job, refresh_time=2000.)
        case.write_value("RUNNING")
        mod.loginfo("Job '%s' submitted" % name)
    except EnvironmentError, error:
        job = None
        case.write_value("SUBMISSION ERROR")
        mod.loginfo("Submission failed")
        log_gui.debug("Traceback of failure:\n%s", traceback.format_exc())
    mod.update()
    return job

def stop(mod, case):
    """Stop study case"""