示例#1
0
    def setup(self, case):
        """
        Setup the widget
        """
        self.__case = case
        self.__boundary = None

        self.__case.undoStopGlobal()

        self.__model = MobileMeshModel(self.__case)
        self.notebook = NotebookModel(self.__case)

        self.__comboModel = ComboModel(self.comboMobilBoundary, 6, 1)
        self.__comboModel.addItem(self.tr("Fixed boundary"), "fixed_boundary")
        self.__comboModel.addItem(self.tr("Sliding boundary"),
                                  "sliding_boundary")
        self.__comboModel.addItem(self.tr("Internal coupling"),
                                  "internal_coupling")
        self.__comboModel.addItem(self.tr("External coupling"),
                                  "external_coupling")
        self.__comboModel.addItem(self.tr("Fixed velocity"), "fixed_velocity")
        self.__comboModel.addItem(self.tr("Fixed displacement"),
                                  "fixed_displacement")

        self.comboMobilBoundary.activated[str].connect(self.__slotCombo)
        self.pushButtonMobilBoundary.clicked.connect(self.__slotFormula)

        self.__case.undoStartGlobal()
    def setup(self, case):
        """
        Setup the widget
        """
        self.__case = case
        self.__boundary = None

        self.__case.undoStopGlobal()

        self.__model = MobileMeshModel(self.__case)

        self.__comboModel = ComboModel(self.comboMobilBoundary, 6, 1)
        self.__comboModel.addItem(self.tr("Fixed boundary"), "fixed_boundary")
        self.__comboModel.addItem(self.tr("Sliding boundary"), "sliding_boundary")
        self.__comboModel.addItem(self.tr("Internal coupling"), "internal_coupling")
        self.__comboModel.addItem(self.tr("External coupling"), "external_coupling")
        self.__comboModel.addItem(self.tr("Fixed velocity"), "fixed_velocity")
        self.__comboModel.addItem(self.tr("Fixed displacement"), "fixed_displacement")

        self.connect(self.comboMobilBoundary,
                     SIGNAL("activated(const QString&)"),
                     self.__slotCombo)
        self.connect(self.pushButtonMobilBoundary,
                     SIGNAL("clicked(bool)"),
                     self.__slotFormula)

        self.__case.undoStartGlobal()
示例#3
0
 def showWidget(self, boundary):
     """
     Show the widget
     """
     if MobileMeshModel(self.__case).getMethod() == "off":
         self.__boundary = boundary
         if self.__boundary.getVelocityChoice() == "on":
             self.groupBoxSliding.setChecked(True)
             checked = True
         else:
             self.groupBoxSliding.setChecked(False)
             checked = False
         self.__slotSlidingWall(checked)
         self.show()
     else:
         self.hideWidget()
示例#4
0
    def __init__(self, parent, case, browser):
        """
        Constructor
        """
        QWidget.__init__(self, parent)

        Ui_MobileMeshForm.__init__(self)
        self.setupUi(self)

        self.case = case
        self.case.undoStopGlobal()
        self.mdl = MobileMeshModel(self.case)
        self.browser = browser

        # Combo model VISCOSITY
        self.modelVISCOSITY = ComboModel(self.comboBoxVISCOSITY,2,1)

        self.modelVISCOSITY.addItem(self.tr("isotropic"), 'isotrop')
        self.modelVISCOSITY.addItem(self.tr("orthotropic"), 'orthotrop')

        # Connections
        self.connect(self.groupBoxALE, SIGNAL("clicked(bool)"), self.slotMethod)
        self.connect(self.lineEditNALINF, SIGNAL("textChanged(const QString &)"), self.slotNalinf)
        self.connect(self.comboBoxVISCOSITY, SIGNAL("activated(const QString&)"), self.slotViscosityType)
        self.connect(self.pushButtonFormula, SIGNAL("clicked(bool)"), self.slotFormula)

        # Validators
        validatorNALINF = IntValidator(self.lineEditNALINF, min=0)
        self.lineEditNALINF.setValidator(validatorNALINF)

        if self.mdl.getMethod() == 'on':
            self.groupBoxALE.setChecked(True)
            checked = True
        else:
            self.groupBoxALE.setChecked(False)
            checked = False

        self.slotMethod(checked)

        # Enable / disable formula state
        setGreenColor(self.pushButtonFormula, False)

        self.case.undoStartGlobal()
class BoundaryConditionsMobileMeshView(QWidget, Ui_BoundaryConditionsMobileMeshForm):
    """
    Boundary condifition for mobil mesh (ALE and/or Fluid-interaction)
    """
    def __init__(self, parent):
        """
        Constructor
        """
        QWidget.__init__(self, parent)

        Ui_BoundaryConditionsMobileMeshForm.__init__(self)
        self.setupUi(self)


    def setup(self, case):
        """
        Setup the widget
        """
        self.__case = case
        self.__boundary = None

        self.__case.undoStopGlobal()

        self.__model = MobileMeshModel(self.__case)

        self.__comboModel = ComboModel(self.comboMobilBoundary, 6, 1)
        self.__comboModel.addItem(self.tr("Fixed boundary"), "fixed_boundary")
        self.__comboModel.addItem(self.tr("Sliding boundary"), "sliding_boundary")
        self.__comboModel.addItem(self.tr("Internal coupling"), "internal_coupling")
        self.__comboModel.addItem(self.tr("External coupling"), "external_coupling")
        self.__comboModel.addItem(self.tr("Fixed velocity"), "fixed_velocity")
        self.__comboModel.addItem(self.tr("Fixed displacement"), "fixed_displacement")

        self.connect(self.comboMobilBoundary,
                     SIGNAL("activated(const QString&)"),
                     self.__slotCombo)
        self.connect(self.pushButtonMobilBoundary,
                     SIGNAL("clicked(bool)"),
                     self.__slotFormula)

        self.__case.undoStartGlobal()


    @pyqtSignature("const QString&")
    def __slotFormula(self, text):
        """
        Run formula editor.
        """
        exp = self.__boundary.getFormula()
        aleChoice = self.__boundary.getALEChoice();

        if aleChoice == "fixed_velocity":
            if not exp:
                exp = 'mesh_velocity_U ='
            req = [('mesh_velocity_U', 'Fixed velocity of the mesh'),
                   ('mesh_velocity_V', 'Fixed velocity of the mesh'),
                   ('mesh_velocity_W', 'Fixed velocity of the mesh')]
            exa = 'mesh_velocity_U = 1000;\nmesh_velocity_V = 1000;\nmesh_velocity_W = 1000;'
        elif aleChoice == "fixed_displacement":
            if not exp:
                exp = 'mesh_x ='
            req = [('mesh_x', 'Fixed displacement of the mesh'),
                   ('mesh_y', 'Fixed displacement of the mesh'),
                   ('mesh_z', 'Fixed displacement of the mesh')]
            exa = 'mesh_x = 1000;\nmesh_y = 1000;\nmesh_z = 1000;'

        symbs = [('dt', 'time step'),
                 ('t', 'current time'),
                 ('iter', 'number of iteration')]

        dialog = QMeiEditorView(self,
                                check_syntax = self.__case['package'].get_check_syntax(),
                                expression = exp,
                                required   = req,
                                symbols    = symbs,
                                examples   = exa)
        if dialog.exec_():
            result = dialog.get_result()
            log.debug("slotFormulaMobileMeshBoundary -> %s" % str(result))
            self.__boundary.setFormula(result)
            setGreenColor(self.pushButtonMobilBoundary, False)


    @pyqtSignature("const QString&")
    def __slotCombo(self, text):
        """
        Called when the combobox changed.
        """
        modelData = self.__comboModel.dicoV2M[str(text)]
        # Enable/disable formula button.
        isFormulaEnabled = modelData in ["fixed_velocity", "fixed_displacement"]
        self.pushButtonMobilBoundary.setEnabled(isFormulaEnabled)
        setGreenColor(self.pushButtonMobilBoundary, isFormulaEnabled)
        self.__boundary.setALEChoice(modelData)


    def showWidget(self, b):
        """
        Show the widget
        """
        if self.__model.getMethod() != "off":
            self.__boundary = Boundary("mobile_boundary", b.getLabel(), self.__case)
            modelData = self.__boundary.getALEChoice()
            self.__comboModel.setItem(str_model=modelData)
            isFormulaEnabled = modelData in ["fixed_velocity", "fixed_displacement"]
            self.pushButtonMobilBoundary.setEnabled(isFormulaEnabled)
            self.show()
        else:
            self.hideWidget()


    def hideWidget(self):
        """
        Hide all
        """
        self.hide()


    def tr(self, text):
        """
        Translation
        """
        return text
示例#6
0
    def __init__(self, parent, case):
        """
        Constructor
        """
        QWidget.__init__(self, parent)

        Ui_BoundaryConditionsForm.__init__(self)
        self.setupUi(self)
        self.__case = case

        self.__case.undoStopGlobal()

        # Model and QTreeView for Boundaries

        self.__modelBoundaries = StandardItemModelBoundaries()
        self.treeViewBoundaries.setModel(self.__modelBoundaries)
        self.treeViewBoundaries.setColumnWidth(2, 110)

        # Fill the model with the boundary zone

        if MobileMeshModel(self.__case).getMethod() == "off":
            if GroundwaterModel(self.__case).getGroundwaterModel() == "off":
                lst = ('wall', 'inlet', 'outlet', 'free_inlet_outlet',
                       'imposed_p_outlet')
            else:
                lst = ('groundwater')
        else:
            lst = ('wall', 'inlet', 'outlet', 'symmetry', 'free_inlet_outlet',
                   'imposed_p_outlet')

        d = LocalizationModel('BoundaryZone', self.__case)
        for zone in d.getZones():
            label = zone.getLabel()
            nature = zone.getNature()
            codeNumber = zone.getCodeNumber()
            local = zone.getLocalization()
            if nature in lst:
                self.__modelBoundaries.insertItem(label, codeNumber, nature,
                                                  local)

        self.treeViewBoundaries.clicked[QModelIndex].connect(
            self.__slotSelectBoundary)

        # Set the case for custom widgets
        self.roughWidget.setup(self.__case)
        self.slidingWidget.setup(self.__case)
        self.convectiveInletWidget.setup(self.__case)
        self.mappedInletWidget.setup(self.__case)
        self.velocityWidget.setup(self.__case)
        self.turbulenceWidget.setup(self.__case)
        self.compressibleOutletWidget.setup(self.__case)
        self.coalWidget.setup(self.__case)
        self.scalarsWidget.setup(self.__case)
        self.meteoWidget.setup(self.__case, self.velocityWidget,
                               self.turbulenceWidget, self.scalarsWidget)
        self.mobileMeshWidget.setup(self.__case)
        self.radiativeWidget.setup(self.__case)
        self.electricalWidget.setup(self.__case)
        self.hydraulicheadWidget.setup(self.__case)
        self.pressureWidget.setup(self.__case)
        self.externalHeadLossesWidget.setup(self.__case)

        self.__hideAllWidgets()

        self.__case.undoStartGlobal()
示例#7
0
class MobileMeshView(QWidget, Ui_MobileMeshForm):
    """
    Class to open Page.
    """
    viscosity_iso = """# Viscosity of the mesh allows to control the deformation
# of the mesh. Viscosity must be greater than zero.
# It could be isotropic (the same for all directions) or
# orthotropic.
#
# In the following example, a hight value of viscosity
# is imposed around a mobile cylinder.
# The viscosity is specfied for all cells
# on the initial mesh before any deformation.
#
xr2 = 1.5^2;
xcen = 5.0;
ycen = 0.;
zcen = 6.0;
xray2 = (x-xcen)^2 + (y-ycen)^2 + (z-zcen)^2;
mesh_viscosity_1 = 1;
if (xray2 < xr2) mesh_viscosity_1 = 1e10;
"""

    viscosity_ortho = """# Viscosity of the mesh allows to control the deformation
# of the mesh. Viscosity must be greater than zero.
# It could be isotropic (the same for all directions) or
# orthotropic.
#
# In the following example, a hight value of viscosity
# is imposed around a mobile cylinder.
# The viscosity is specfied for all cells
# on the initial mesh before any deformation.
#
xr2 = 1.5^2;
xcen = 5.0;
ycen = 0.;
zcen = 6.0;
xray2 = (x-xcen)^2 + (y-ycen)^2 + (z-zcen)^2;
mesh_viscosity_1 = 1;
mesh_viscosity_2 = 1;
mesh_viscosity_3 = 1;
if (xray2 < xr2) {
    mesh_viscosity_1 = 1e10;
    mesh_viscosity_2 = 1e10;
    mesh_viscosity_3 = 1e10;
}
"""

    def __init__(self, parent, case, browser):
        """
        Constructor
        """
        QWidget.__init__(self, parent)

        Ui_MobileMeshForm.__init__(self)
        self.setupUi(self)

        self.case = case
        self.case.undoStopGlobal()
        self.mdl = MobileMeshModel(self.case)
        self.browser = browser

        # Combo model VISCOSITY
        self.modelVISCOSITY = ComboModel(self.comboBoxVISCOSITY,2,1)

        self.modelVISCOSITY.addItem(self.tr("isotropic"), 'isotrop')
        self.modelVISCOSITY.addItem(self.tr("orthotropic"), 'orthotrop')

        # Connections
        self.connect(self.groupBoxALE, SIGNAL("clicked(bool)"), self.slotMethod)
        self.connect(self.lineEditNALINF, SIGNAL("textChanged(const QString &)"), self.slotNalinf)
        self.connect(self.comboBoxVISCOSITY, SIGNAL("activated(const QString&)"), self.slotViscosityType)
        self.connect(self.pushButtonFormula, SIGNAL("clicked(bool)"), self.slotFormula)

        # Validators
        validatorNALINF = IntValidator(self.lineEditNALINF, min=0)
        self.lineEditNALINF.setValidator(validatorNALINF)

        if self.mdl.getMethod() == 'on':
            self.groupBoxALE.setChecked(True)
            checked = True
        else:
            self.groupBoxALE.setChecked(False)
            checked = False

        self.slotMethod(checked)

        # Enable / disable formula state
        setGreenColor(self.pushButtonFormula, False)

        self.case.undoStartGlobal()


    @pyqtSignature("bool")
    def slotMethod(self, checked):
        """
        Private slot.

        Activates ALE method.

        @type checked: C{True} or C{False}
        @param checked: if C{True}, shows the QGroupBox ALE parameters
        """
        self.groupBoxALE.setFlat(not checked)
        if checked:
            self.frame.show()
            self.mdl.setMethod ("on")
            nalinf = self.mdl.getSubIterations()
            self.lineEditNALINF.setText(str(nalinf))
            value = self.mdl.getViscosity()
            self.modelVISCOSITY.setItem(str_model=value)
        else:
            self.frame.hide()
            self.mdl.setMethod("off")
        setGreenColor(self.pushButtonFormula, True)


    @pyqtSignature("const QString&")
    def slotNalinf(self, text):
        """
        Input viscosity type of mesh : isotrop or orthotrop.
        """
        if self.sender().validator().state == QValidator.Acceptable:
            nalinf = from_qvariant(text, int)
            self.mdl.setSubIterations(nalinf)


    @pyqtSignature("const QString&")
    def slotViscosityType(self, text):
        """
        Input viscosity type of mesh : isotrop or orthotrop.
        """
        self.viscosity_type = self.modelVISCOSITY.dicoV2M[str(text)]
        visco = self.viscosity_type
        self.mdl.setViscosity(visco)
        setGreenColor(self.pushButtonFormula, True)
        return visco


    @pyqtSignature("const QString&")
    def slotFormula(self, text):
        """
        Run formula editor.
        """
        exp = self.mdl.getFormula()

        if self.mdl.getViscosity() == 'isotrop':
            if not exp:
                exp = "mesh_viscosity_1 = 1;"
            req = [('mesh_viscosity_1', 'mesh viscosity')]
            exa = MobileMeshView.viscosity_iso
        else:
            if not exp:
                exp = "mesh_viscosity_1 = 1;\nmesh_viscosity_2 = 1;\nmesh_viscosity_3 = 1;"
            req = [('mesh_viscosity_1', 'mesh viscosity X'),
                   ('mesh_viscosity_2', 'mesh viscosity Y'),
                   ('mesh_viscosity_3', 'mesh viscosity Z')]
            exa = MobileMeshView.viscosity_ortho

        symb = [('x', "X cell's gravity center"),
                ('y', "Y cell's gravity center"),
                ('z', "Z cell's gravity center"),
                ('dt', 'time step'),
                ('t', 'current time'),
                ('iter', 'number of iteration')]

        dialog = QMeiEditorView(self,
                                check_syntax = self.case['package'].get_check_syntax(),
                                expression = exp,
                                required   = req,
                                symbols    = symb,
                                examples   = exa)
        if dialog.exec_():
            result = dialog.get_result()
            log.debug("slotFormulaMobileMeshView -> %s" % str(result))
            self.mdl.setFormula(result)
            setGreenColor(self.pushButtonFormula, False)


    def tr(self, text):
        """
        Translation
        """
        return text
示例#8
0
class BoundaryConditionsMobileMeshView(QWidget,
                                       Ui_BoundaryConditionsMobileMeshForm):
    """
    Boundary condifition for mobil mesh (ALE and/or Fluid-interaction)
    """
    def __init__(self, parent):
        """
        Constructor
        """
        QWidget.__init__(self, parent)

        Ui_BoundaryConditionsMobileMeshForm.__init__(self)
        self.setupUi(self)

    def setup(self, case):
        """
        Setup the widget
        """
        self.__case = case
        self.__boundary = None

        self.__case.undoStopGlobal()

        self.__model = MobileMeshModel(self.__case)
        self.notebook = NotebookModel(self.__case)

        self.__comboModel = ComboModel(self.comboMobilBoundary, 6, 1)
        self.__comboModel.addItem(self.tr("Fixed boundary"), "fixed_boundary")
        self.__comboModel.addItem(self.tr("Sliding boundary"),
                                  "sliding_boundary")
        self.__comboModel.addItem(self.tr("Internal coupling"),
                                  "internal_coupling")
        self.__comboModel.addItem(self.tr("External coupling"),
                                  "external_coupling")
        self.__comboModel.addItem(self.tr("Fixed velocity"), "fixed_velocity")
        self.__comboModel.addItem(self.tr("Fixed displacement"),
                                  "fixed_displacement")

        self.comboMobilBoundary.activated[str].connect(self.__slotCombo)
        self.pushButtonMobilBoundary.clicked.connect(self.__slotFormula)

        self.__case.undoStartGlobal()

    @pyqtSlot()
    def __slotFormula(self):
        """
        Run formula editor.
        """
        exp = self.__boundary.getFormula()
        aleChoice = self.__boundary.getALEChoice()

        if aleChoice == "fixed_velocity":
            if not exp:
                exp = 'mesh_velocity_U ='
            req = [('mesh_velocity_U', 'Fixed velocity of the mesh'),
                   ('mesh_velocity_V', 'Fixed velocity of the mesh'),
                   ('mesh_velocity_W', 'Fixed velocity of the mesh')]
            exa = 'mesh_velocity_U = 1000;\nmesh_velocity_V = 1000;\nmesh_velocity_W = 1000;'
        elif aleChoice == "fixed_displacement":
            if not exp:
                exp = 'mesh_x ='
            req = [('mesh_x', 'Fixed displacement of the mesh'),
                   ('mesh_y', 'Fixed displacement of the mesh'),
                   ('mesh_z', 'Fixed displacement of the mesh')]
            exa = 'mesh_x = 1000;\nmesh_y = 1000;\nmesh_z = 1000;'

        symbs = [('dt', 'time step'), ('t', 'current time'),
                 ('iter', 'number of iteration')]

        for (nme, val) in self.notebook.getNotebookList():
            symbs.append((nme, 'value (notebook) = ' + str(val)))

        dialog = QMeiEditorView(
            self,
            check_syntax=self.__case['package'].get_check_syntax(),
            expression=exp,
            required=req,
            symbols=symbs,
            examples=exa)
        if dialog.exec_():
            result = dialog.get_result()
            log.debug("slotFormulaMobileMeshBoundary -> %s" % str(result))
            self.__boundary.setFormula(str(result))
            self.pushButtonMobilBoundary.setStyleSheet(
                "background-color: green")
            self.pushButtonMobilBoundary.setToolTip(result)

    @pyqtSlot(str)
    def __slotCombo(self, text):
        """
        Called when the combobox changed.
        """
        modelData = self.__comboModel.dicoV2M[str(text)]

        if modelData == self.__boundary.getALEChoice():
            return

        self.__boundary.setALEChoice(modelData)
        exp = self.__boundary.getFormula()

        # Hide/Show formula button.
        # Formula is always reset when changing values, so set
        # color to red.
        if modelData in ["fixed_velocity", "fixed_displacement"]:
            self.pushButtonMobilBoundary.show()
        else:
            self.pushButtonMobilBoundary.hide()
        if exp:
            self.pushButtonMobilBoundary.setStyleSheet("background-color: red")
            self.pushButtonMobilBoundary.setToolTip(exp)
        else:
            self.pushButtonMobilBoundary.setStyleSheet("background-color: red")

    def showWidget(self, b):
        """
        Show the widget
        """
        if self.__model.getMethod() != "off":
            self.__boundary = Boundary("mobile_boundary", b.getLabel(),
                                       self.__case)
            modelData = self.__boundary.getALEChoice()
            self.__comboModel.setItem(str_model=modelData)
            if modelData in ["fixed_velocity", "fixed_displacement"]:
                self.pushButtonMobilBoundary.show()
            else:
                self.pushButtonMobilBoundary.hide()
            self.show()
        else:
            self.hideWidget()

    def hideWidget(self):
        """
        Hide all
        """
        self.hide()

    def tr(self, text):
        """
        Translation
        """
        return text