Example #1
0
class InitializationView(QWidget, Ui_InitializationForm):
    """
    """
    def __init__(self, parent, case, stbar):
        """
        Constructor
        """
        QWidget.__init__(self, parent)

        Ui_InitializationForm.__init__(self)
        self.setupUi(self)

        self.case = case
        self.parent = parent
        self.case.undoStopGlobal()

        self.init = InitializationModel(self.case)
        self.turb = TurbulenceModel(self.case)
        self.therm = ThermalScalarModel(self.case)
        self.th_sca = DefineUserScalarsModel(self.case)
        self.comp = CompressibleModel(self.case)
        self.volzone = LocalizationModel('VolumicZone', self.case)
        self.notebook = NotebookModel(self.case)

        # create group to control hide/show options
        self.turb_group = [
            self.labelTurbulence, self.pushButtonTurbulence,
            self.comboBoxTurbulence
        ]
        self.thermal_group = [self.labelThermal, self.pushButtonThermal]
        self.velocity_group = [self.labelVelocity, self.pushButtonVelocity]
        self.species_group = [
            self.labelSpecies, self.comboBoxSpecies, self.pushButtonSpecies
        ]
        self.meteo_group = [
            self.labelMeteo, self.comboBoxMeteo, self.pushButtonMeteo
        ]
        self.thermodynamic_list = [
            'Pressure', 'Density', 'Temperature', 'Energy'
        ]

        # 1/ Combo box models

        self.modelZone = ComboModel(self.comboBoxZone, 1, 1)
        if self.comp.getCompressibleModel() != 'off':
            self.groupBoxThermodynamic.show()
        else:
            self.groupBoxThermodynamic.hide()

        self.zone = ""
        zones = self.volzone.getZones()
        for zone in zones:
            if zone.getNature()['initialization'] == "on":
                label = zone.getLabel()
                name = str(zone.getCodeNumber())
                self.modelZone.addItem(self.tr(label), name)
                if label == "all_cells":
                    self.zone = name
                if not self.zone:
                    self.zone = name

        self.modelZone.setItem(str_model=self.zone)

        self.modelTurbulence = ComboModel(self.comboBoxTurbulence, 2, 1)
        self.modelTurbulence.addItem(self.tr("Initialization by formula"),
                                     'formula')
        self.modelTurbulence.addItem(
            self.tr("Initialization by reference value(s)"), 'reference_value')

        # 2/ Connections

        self.comboBoxZone.activated[str].connect(self.slotZone)
        self.comboBoxTurbulence.activated[str].connect(self.slotChoice)
        self.comboBoxSpecies.activated[str].connect(self.slotSpeciesChoice)
        self.comboBoxMeteo.activated[str].connect(self.slotMeteoChoice)
        self.checkBoxPressure.clicked.connect(self.slotPressure)
        self.checkBoxDensity.clicked.connect(self.slotDensity)
        self.checkBoxTemperature.clicked.connect(self.slotTemperature)
        self.checkBoxEnergy.clicked.connect(self.slotEnergy)
        self.pushButtonVelocity.clicked.connect(self.slotVelocityFormula)
        self.pushButtonThermal.clicked.connect(self.slotThermalFormula)
        self.pushButtonTurbulence.clicked.connect(self.slotTurbulenceFormula)
        self.pushButtonSpecies.clicked.connect(self.slotSpeciesFormula)
        self.pushButtonMeteo.clicked.connect(self.slotMeteoFormula)
        self.pushButtonPressure.clicked.connect(self.slotPressureFormula)
        self.pushButtonDensity.clicked.connect(self.slotDensityFormula)
        self.pushButtonTemperature.clicked.connect(self.slotTemperatureFormula)
        self.pushButtonEnergy.clicked.connect(self.slotEnergyFormula)
        self.pushButtonHydraulicHead.clicked.connect(
            self.slotHydraulicHeadFormula)

        choice = self.init.getInitialTurbulenceChoice(self.zone)
        self.modelTurbulence.setItem(str_model=choice)

        # species treatment
        self.modelSpecies = ComboModel(self.comboBoxSpecies, 1, 1)
        self.scalar = ""
        scalar_list = self.th_sca.getUserScalarNameList()
        for s in self.th_sca.getScalarsVarianceList():
            if s in scalar_list: scalar_list.remove(s)

        if scalar_list != []:
            self.scalar = scalar_list[0]
            for item in self.species_group:
                item.show()
            for scalar in scalar_list:
                self.modelSpecies.addItem(self.tr(scalar), scalar)
            self.modelSpecies.setItem(str_model=self.scalar)
            exp = self.init.getSpeciesFormula(self.zone, self.scalar)
            if exp:
                self.pushButtonSpecies.setStyleSheet("background-color: green")
                self.pushButtonSpecies.setToolTip(exp)
            else:
                self.pushButtonSpecies.setStyleSheet("background-color: red")
        else:
            for item in self.species_group:
                item.hide()

        # meteo
        self.modelMeteo = ComboModel(self.comboBoxMeteo, 1, 1)
        self.scalar_meteo = ""
        scalar_meteo_list = DefineUserScalarsModel(
            self.case).getMeteoScalarsNameList()
        if scalar_meteo_list != None and scalar_meteo_list != []:
            self.scalar_meteo = scalar_meteo_list[0]
            for item in self.meteo_group:
                item.show()
            for scalar in scalar_meteo_list:
                self.modelMeteo.addItem(self.tr(scalar), scalar)
            self.modelMeteo.setItem(str_model=self.scalar_meteo)
            exp = self.init.getMeteoFormula(self.zone, self.scalar_meteo)
            if exp:
                self.pushButtonMeteo.setStyleSheet("background-color: green")
                self.pushButtonMeteo.setToolTip(exp)
            else:
                self.pushButtonMeteo.setStyleSheet("background-color: red")
        else:
            for item in self.meteo_group:
                item.hide()

        if GroundwaterModel(self.case).getGroundwaterModel() == "off":
            self.labelHydraulicHead.hide()
            self.pushButtonHydraulicHead.hide()
    def __init__(self, parent, case):
        """
        Constructor
        """
        QWidget.__init__(self, parent)

        Ui_Turbulence.__init__(self)
        self.setupUi(self)

        self.case = case
        self.case.undoStopGlobal()
        self.mdl = TurbulenceModel(self.case)

        # Dico
        self.dicoM2V = {
            "none": 'none',
            "mixing_length": 'mixing length',
            "k-epsilon": 'k-epsilon',
            "rij-epsilon_ssg": 'Rij-epsilon SSG',
            "rij-epsilon_ebrsm": 'Rij-epsilon EBRSM',
            "k-epsilon_linear_production": 'k-epsilon linear production',
            "les_smagorinsky": 'LES (Smagorinsky)',
            "les_wale": 'LES (WALE)',
            "tchen": 'Tchen',
            "q2-q12": 'Q2-Q12',
            "r2-q12": 'R2-Q12',
            "r2-r12-tchen": 'R2-R12 Tchen',
            "separate_phase": 'separate phase',
            "separate_phase_cond": 'separate phase cond',
            "small_inclusions": 'small inclusions',
            "large_inclusions": 'large inclusions',
            "sgdh": 'SGDH',
            "ggdh": 'GGDH'
        }

        self.dicoV2M = {
            "none": 'none',
            "mixing length": 'mixing_length',
            "k-epsilon": 'k-epsilon',
            "Rij-epsilon SSG": 'rij-epsilon_ssg',
            "Rij-epsilon EBRSM": 'rij-epsilon_ebrsm',
            "k-epsilon linear production": 'k-epsilon_linear_production',
            "LES (Smagorinsky)": 'les_smagorinsky',
            "LES (WALE)": 'les_wale',
            "Tchen": 'tchen',
            "Q2-Q12": 'q2-q12',
            "R2-Q12": 'r2-q12',
            "R2-R12 Tchen": 'r2-r12-tchen',
            "separate phase": 'separate_phase',
            "separate phase cond": 'separate_phase_cond',
            "small inclusions": 'small_inclusions',
            "large inclusions": 'large_inclusions',
            "SGDH": 'sgdh',
            "GGDH": 'ggdh'
        }

        # Validators
        validatorMix = DoubleValidator(self.lineEditMixingLength, min=0.0)
        validatorMix.setExclusiveMin(False)
        self.lineEditMixingLength.setValidator(validatorMix)

        self.tableModelTurbulence = StandardItemModelTurbulence(
            self.mdl, self.case, self.dicoM2V, self.dicoV2M)
        self.tableViewTurbulence.setModel(self.tableModelTurbulence)
        self.tableViewTurbulence.resizeColumnsToContents()
        self.tableViewTurbulence.resizeRowsToContents()
        if QT_API == "PYQT4":
            self.tableViewTurbulence.verticalHeader().setResizeMode(
                QHeaderView.ResizeToContents)
            self.tableViewTurbulence.horizontalHeader().setResizeMode(
                QHeaderView.ResizeToContents)
            self.tableViewTurbulence.horizontalHeader().setResizeMode(
                0, QHeaderView.Stretch)
        elif QT_API == "PYQT5":
            self.tableViewTurbulence.verticalHeader().setSectionResizeMode(
                QHeaderView.ResizeToContents)
            self.tableViewTurbulence.horizontalHeader().setSectionResizeMode(
                QHeaderView.ResizeToContents)
            self.tableViewTurbulence.horizontalHeader().setSectionResizeMode(
                0, QHeaderView.Stretch)
        self.tableViewTurbulence.setSelectionBehavior(
            QAbstractItemView.SelectRows)
        self.tableViewTurbulence.setSelectionMode(
            QAbstractItemView.SingleSelection)

        delegateTurbulence = TurbulenceDelegate(self.tableViewTurbulence,
                                                self.mdl, self.dicoM2V,
                                                self.dicoV2M)
        delegateTurbFlux = TurbFluxDelegate(self.tableViewTurbulence, self.mdl,
                                            self.dicoM2V, self.dicoV2M)
        delegateCoupling = CouplingDelegate(self.tableViewTurbulence, self.mdl,
                                            self.dicoM2V, self.dicoV2M)
        self.tableViewTurbulence.setItemDelegateForColumn(
            2, delegateTurbulence)
        self.tableViewTurbulence.setItemDelegateForColumn(3, delegateTurbFlux)
        self.tableViewTurbulence.setItemDelegateForColumn(4, delegateCoupling)

        # Combo models
        self.modelContinuousCoupling = ComboModel(
            self.comboBoxContinuousCoupling, 3, 1)
        self.modelContinuousCoupling.addItem(self.tr('none'), 'none')
        self.modelContinuousCoupling.addItem(self.tr("separate phases"),
                                             "separate_phase")
        self.modelContinuousCoupling.addItem(self.tr("separate phases + cond"),
                                             "separate_phase_cond")

        # hide groupBoxMixingLength
        self.groupBoxMixingLength.hide()

        # Connect signals to slots
        self.tableModelTurbulence.dataChanged.connect(self.dataChanged)
        self.lineEditMixingLength.textChanged[str].connect(
            self.slotMixingLength)
        self.tableViewTurbulence.clicked.connect(self.slotChangeSelection)
        self.comboBoxContinuousCoupling.activated[str].connect(
            self.slotContinuousCoupling)

        # hide/show groupBoxContinuousCoupling
        if len(self.mdl.getContinuousFieldList()) >= 2:
            self.groupBoxContinuousCoupling.show()
            model = self.mdl.getContinuousCouplingModel()
            self.modelContinuousCoupling.setItem(str_model=model)
        else:
            self.groupBoxContinuousCoupling.hide()

        for fieldId in self.mdl.getFieldIdList():
            self.tableModelTurbulence.newItem(fieldId)

        self.case.undoStartGlobal()
class SolutionDomainView(QWidget, Ui_SolutionDomainForm):
    """
    """
    def __init__(self, parent, case, stbar, tree):
        """
        Constructor
        """
        QWidget.__init__(self, parent)
        Ui_SolutionDomainForm.__init__(self)
        self.setupUi(self)

        self.root = parent
        self.stbar = stbar
        self.case = case
        self.browser = tree

        self.case.undoStopGlobal()
        self.mdl = SolutionDomainModel(self.case)

        # 0) Mesh Input

        self.mesh_origin = self.mdl.getMeshOrigin()

        self.mesh_input = self.mdl.getMeshInput()

        if self.mesh_origin == "mesh_import":
            self.radioButtonImport.setChecked(True)
            self.radioButtonExists.setChecked(False)
            self.radioButtonCartesianMesh.setChecked(False)

            self.frameMeshInput.hide()
            self.frameMeshCartesian.hide()
            self.frameMeshImport.show()

        elif self.mesh_origin == "mesh_input":
            self.radioButtonImport.setChecked(False)
            self.radioButtonExists.setChecked(True)
            self.radioButtonCartesianMesh.setChecked(False)

            self.frameMeshImport.hide()
            self.frameMeshCartesian.hide()
            self.frameMeshInput.show()
            self.lineEditMeshInput.setText(self.mesh_input)

        elif self.mesh_origin == "mesh_cartesian":
            self.radioButtonImport.setChecked(False)
            self.radioButtonExists.setChecked(False)
            self.radioButtonCartesianMesh.setChecked(True)

            self.frameMeshInput.hide()
            self.frameMeshImport.hide()
            self.frameMeshCartesian.show()

        self.radioButtonImport.clicked.connect(self.slotSetImportMesh)
        self.radioButtonExists.clicked.connect(self.slotSetInputMesh)
        self.radioButtonCartesianMesh.clicked.connect(
            self.slotSetCartesianMesh)
        self.toolButtonMeshInput.pressed.connect(self.selectInputMesh)
        self.lineEditMeshInput.textChanged[str].connect(self.modifyInputMesh)

        self.cartParams = {
            "x_ncells": self.lineEditXNcells,
            "y_ncells": self.lineEditYNcells,
            "z_ncells": self.lineEditZNcells,
            "x_min": self.lineEditXmin,
            "x_max": self.lineEditXmax,
            "y_min": self.lineEditYmin,
            "y_max": self.lineEditYmax,
            "z_min": self.lineEditZmin,
            "z_max": self.lineEditZmax,
            "x_prog": self.lineEditXprog,
            "y_prog": self.lineEditYprog,
            "z_prog": self.lineEditZprog
        }

        # We use lambda to connect all 9 lineEdits to the same function.
        # val corresponds to the string, and "key=k" is necessary for the connect
        # method to evaluate 'k' during creation. Otherwise last value of 'k' is
        # used for all.
        for k in self.cartParams.keys():
            self.cartParams[k].textChanged[str].connect(
                lambda val, key=k: self.slotSetCartesianParam(val, key))
            # set validator
            if k.split("_")[1] == "ncells":
                _v = IntValidator(self.cartParams[k], min=1)
                self.cartParams[k].setValidator(_v)
            else:
                _v = DoubleValidator(self.cartParams[k])
                self.cartParams[k].setValidator(_v)

        self.cartParams["x_law"] = ComboModel(self.comboBoxXlaw, 3, 1)
        self.cartParams["y_law"] = ComboModel(self.comboBoxYlaw, 3, 1)
        self.cartParams["z_law"] = ComboModel(self.comboBoxZlaw, 3, 1)
        for k in ("x_law", "y_law", "z_law"):
            self.cartParams[k].addItem(self.tr("constant"), "constant")
            self.cartParams[k].addItem(self.tr("geometric"), "geometric")
            self.cartParams[k].addItem(self.tr("parabolic"), "parabolic")

        self.comboBoxXlaw.activated[str].connect(
            lambda val: self.slotSetCartesianParam(val, "x_law"))
        self.comboBoxYlaw.activated[str].connect(
            lambda val: self.slotSetCartesianParam(val, "y_law"))
        self.comboBoxZlaw.activated[str].connect(
            lambda val: self.slotSetCartesianParam(val, "z_law"))

        # Set initial values
        for k in self.cartParams.keys():
            d = k.split("_")[0] + "_direction"
            p = k.split("_")[1]
            val = self.mdl.getCartesianParam(d, p)
            self.slotSetCartesianParam(val, k)

        # 1) Meshes directory

        self.mesh_dirs = [None]

        d = self.mdl.getMeshDir()
        study_path = os.path.split(self.case['case_path'])[0]

        if d == None:
            d = os.path.join(study_path, 'MESH')
        elif not os.path.abspath(d):
            d = os.path.join(self.case['case_path'], d)

        if d != None:
            if os.path.isdir(d):
                self.lineEditMeshDir.setText(
                    RelOrAbsPath(d, self.case['case_path']))
                self.mesh_dirs[0] = d

        self.case['mesh_path'] = self.mesh_dirs[0]

        package = self.case['package']

        # User and global mesh directories

        for config_file in [
                package.get_user_configfile(),
                package.get_global_configfile()
        ]:
            cfg = configparser.ConfigParser()
            cfg.read(config_file)
            if cfg.has_option('run', 'meshpath'):
                cfg_mesh_dirs = cfg.get('run', 'meshpath').split(':')
                for d in cfg_mesh_dirs:
                    self.mesh_dirs.append(d)

        del (package)

        # 2) Meshes selection layout

        # 2.1) Model for meshes table
        self.modelMeshes = StandardItemModelMeshes(self.mdl)
        self.tableViewMeshes.setModel(self.modelMeshes)
        self.tableViewMeshes.resizeColumnsToContents()
        self.tableViewMeshes.resizeRowsToContents()

        delegateName = MeshNameDelegate(self.tableViewMeshes)
        self.tableViewMeshes.setItemDelegateForColumn(0, delegateName)

        delegateFormat = MeshFormatDelegate(self.tableViewMeshes,
                                            self._tableViewLayout)
        self.tableViewMeshes.setItemDelegateForColumn(1, delegateFormat)

        delegateNumber = MeshNumberDelegate(self.tableViewMeshes)
        self.tableViewMeshes.setItemDelegateForColumn(2, delegateNumber)

        delegateGroupFaces = GroupDelegate(self.tableViewMeshes)
        self.tableViewMeshes.setItemDelegateForColumn(4, delegateGroupFaces)

        delegateGroupCells = GroupDelegate(self.tableViewMeshes)
        self.tableViewMeshes.setItemDelegateForColumn(5, delegateGroupCells)

        self.groupBoxMeshes.resizeEvent = self.MeshesResizeEvent

        # 2.2) Connections

        self.pushButtonAddMesh.clicked.connect(self.slotSearchMesh)
        self.pushButtonDeleteMesh.clicked.connect(self.slotDeleteMesh)

        # 3) Initialize meshes list

        # 3.1) Meshes default directory

        self.toolButtonMeshDir.pressed.connect(self.searchDir)
        self.toolButtonMeshDirClear.pressed.connect(self.clearDir)

        # 3.2) Meshes list

        msg = ""
        nameList = self.mdl.getMeshList()
        log.debug("__init__ -> nameList = %s " % nameList)

        if nameList:
            for i in range(len(nameList)):
                mesh = nameList[i]
                if mesh[1] != None:
                    path = os.path.join(mesh[1], mesh[0])
                else:
                    path = mesh[0]
                if not os.path.isabs(path) and self.case['mesh_path'] != None:
                    path = os.path.join(self.case['mesh_path'], path)
                if not (os.path.isfile(path) and os.path.isabs(path)):
                    msg = msg + path + '\n'

        if msg != "":
            msg = msg + '\n'
            title = self.tr("WARNING")
            msg2 = self.tr(
                "The following mesh files are not present or\n" +
                "in the meshes directory search path:\n\n" + msg +
                "Verify existence and location of the mesh files,\n" +
                "and the 'Mesh Directory' section.")
            QMessageBox.warning(self, title, msg2)

        self._tableViewLayout()

        # Combomodels

        self.modelArg_cs_verif = ComboModel(self.comboBoxRunType, 4, 1)

        self.modelArg_cs_verif.addItem(self.tr("Import mesh only"), 'none')
        self.modelArg_cs_verif.addItem(self.tr("Mesh preprocessing only"),
                                       'mesh preprocess')
        self.modelArg_cs_verif.addItem(self.tr("Mesh quality criteria only"),
                                       'mesh quality')
        self.modelArg_cs_verif.addItem(self.tr("Standard Computation"),
                                       'standard')

        self.modelArg_cs_verif.setItem(str_model=self.case['run_type'])

        if self.mesh_input != None:
            self.modelArg_cs_verif.disableItem(str_model='none')
        else:
            self.modelArg_cs_verif.enableItem(str_model='none')

        self.comboBoxRunType.activated[str].connect(self.slotArgRunType)

        # Checkboxes

        self.checkBoxMeshRestart.setChecked(
            not self.mdl.getPreprocessOnRestart())
        self.checkBoxMeshRestart.clicked.connect(self.slotMeshRestart)

        self.checkBoxMeshSave.setChecked(self.mdl.getMeshSaveOnModify())
        self.checkBoxMeshSave.clicked.connect(self.slotMeshSaveOnModify)

        # Undo/redo

        self.case.undoStartGlobal()

        # Update tree

        self.browser.configureTree(self.case)
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
        self.notebook = NotebookModel(self.case)

        # 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.lineEditNALINF.textChanged[str].connect(self.slotNalinf)
        self.comboBoxVISCOSITY.activated[str].connect(self.slotViscosityType)
        self.pushButtonFormula.clicked.connect(self.slotFormula)

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

        # Settings
        nalinf = self.mdl.getSubIterations()
        self.lineEditNALINF.setText(str(nalinf))
        value = self.mdl.getViscosity()
        self.modelVISCOSITY.setItem(str_model=value)
        exp = self.mdl.getFormula()
        if exp:
            self.pushButtonFormula.setStyleSheet("background-color: green")
            self.pushButtonFormula.setToolTip(exp)
        else:
            self.pushButtonFormula.setStyleSheet("background-color: red")

        self.case.undoStartGlobal()
Example #5
0
    def __init__(self, parent, case):
        """
        Constructor
        """
        QWidget.__init__(self, parent)

        Ui_TimeStep.__init__(self)
        self.setupUi(self)

        self.case = case
        self.case.undoStopGlobal()
        self.mdl = TimeStepModel(self.case)

        # Combo box models

        self.modelTimeStepOption = ComboModel(self.comboBoxTimeStepOption, 3, 1)
        self.modelTimeStepOption.addItem(self.tr("Constant"), "constant")
        self.modelTimeStepOption.addItem(self.tr("Adaptive"), "uniform")
        self.modelTimeStepOption.addItem(self.tr("Steady"), "steady")

        self.modelTimeStop = ComboModel(self.comboBoxTimeStopType, 2, 1)
        self.modelTimeStop.addItem(self.tr("Number of time steps"), "iteration")
        self.modelTimeStop.addItem(self.tr("Time analysis (s)"), "time")

        # Validators

        validatorRefT   = DoubleValidator(self.lineEditReferenceTimeStep, min = 0.0)
        validatorNumT   = IntValidator(self.lineEditNumberTimeStep, min = 0)
        validatorAnaT   = DoubleValidator(self.lineEditTimeAnalysis)
        validatorDtMin  = DoubleValidator(self.lineEditDtMin, min = 0.0)
        validatorDtMax  = DoubleValidator(self.lineEditDtMax, min = 0.0)
        validatorIncMax = DoubleValidator(self.lineEditDtIncreasingMax, min = 0.0)
        validatorDecMax = DoubleValidator(self.lineEditDtDecreasingMax, min = 0.0)

        validatorRefT.setExclusiveMin(True)
        validatorNumT.setExclusiveMin(True)
        validatorDtMin.setExclusiveMin(True)
        validatorDtMax.setExclusiveMin(True)
        validatorIncMax.setExclusiveMin(True)
        validatorDecMax.setExclusiveMin(True)

        self.lineEditReferenceTimeStep.setValidator(validatorRefT)
        self.lineEditNumberTimeStep.setValidator(validatorNumT)
        self.lineEditTimeAnalysis.setValidator(validatorAnaT)
        self.lineEditDtMin.setValidator(validatorDtMin)
        self.lineEditDtMax.setValidator(validatorDtMax)
        self.lineEditDtIncreasingMax.setValidator(validatorIncMax)
        self.lineEditDtDecreasingMax.setValidator(validatorDecMax)

        # tableViewCourantFourier

        self.tableModelCourantFourier = StandardItemModelCourantFourier(self.mdl)
        self.tableViewCourantFourier.setModel(self.tableModelCourantFourier)
        self.tableViewCourantFourier.resizeColumnsToContents()
        self.tableViewCourantFourier.resizeRowsToContents()
        if QT_API == "PYQT4":
            self.tableViewCourantFourier.verticalHeader().setResizeMode(QHeaderView.ResizeToContents)
            self.tableViewCourantFourier.horizontalHeader().setResizeMode(QHeaderView.ResizeToContents)
            self.tableViewCourantFourier.horizontalHeader().setResizeMode(0,QHeaderView.Stretch)
        elif QT_API == "PYQT5":
            self.tableViewCourantFourier.verticalHeader().setSectionResizeMode(QHeaderView.ResizeToContents)
            self.tableViewCourantFourier.horizontalHeader().setSectionResizeMode(QHeaderView.ResizeToContents)
            self.tableViewCourantFourier.horizontalHeader().setSectionResizeMode(0,QHeaderView.Stretch)
        self.tableViewCourantFourier.setSelectionBehavior(QAbstractItemView.SelectRows)
        self.tableViewCourantFourier.setSelectionMode(QAbstractItemView.SingleSelection)

        delegateMaxFourier = ValueDelegate(self.tableViewCourantFourier)
        delegateMaxCourant = ValueDelegate(self.tableViewCourantFourier)

        self.tableViewCourantFourier.setItemDelegateForColumn(1, delegateMaxFourier)
        self.tableViewCourantFourier.setItemDelegateForColumn(2, delegateMaxCourant)

        # Connect signals to slots
        self.comboBoxTimeStepOption.activated[str].connect(self.slotTimeStepOption)
        self.comboBoxTimeStopType.activated[str].connect(self.slotTimeStop)
        self.lineEditReferenceTimeStep.textChanged[str].connect(self.slotReferenceTimeStep)
        self.lineEditNumberTimeStep.textChanged[str].connect(self.slotNumberTimeStep)
        self.lineEditTimeAnalysis.textChanged[str].connect(self.slotTimeAnalysis)
        self.lineEditDtMin.textChanged[str].connect(self.slotDtMin)
        self.lineEditDtMax.textChanged[str].connect(self.slotDtMax)
        self.lineEditDtIncreasingMax.textChanged[str].connect(self.slotDtIncreasingMax)
        self.lineEditDtDecreasingMax.textChanged[str].connect(self.slotDtDecreasingMax)
        self.tableModelCourantFourier.dataChanged.connect(self.dataChanged)

        # Initialize widget
        self.initializeVariables()

        self.case.undoStartGlobal()
class InterfacialForcesView(QWidget, Ui_InterfacialForces):
    """
    Main fields layout.
    """
    def __init__(self, parent, case, tree):
        """
        Constructor
        """
        QWidget.__init__(self, parent)

        Ui_InterfacialForces.__init__(self)
        self.setupUi(self)

        self.case = case
        self.browser = tree
        self.case.undoStopGlobal()
        self.mdl = InterfacialForcesModel(self.case)

        # Dico
        self.dicoM2V = {
            "none": 'None',
            "LLB_model": 'LLB model',
            "GTD_model": 'GTD model',
            "antal": 'Antal',
            "tomiyama": 'Tomiyama',
            "ishii": 'Ishii',
            "inclusions": 'Gobin et al.',
            "Wen_Yu": 'Wen and Yu',
            "standard": 'Standard',
            "zuber": 'Zuber',
            "coef_cst": 'Constant coefficient',
            "Tomiyama_SMD": 'Tomiyama SMD'
        }

        self.dicoV2M = {
            "None": 'none',
            "LLB model": 'LLB_model',
            "GTD model": 'GTD_model',
            "Antal": 'antal',
            "Tomiyama": 'tomiyama',
            "Ishii": 'ishii',
            "Gobin et al.": 'inclusions',
            "Wen and Yu": 'Wen_Yu',
            "Standard": 'standard',
            "Zuber": 'zuber',
            "Constant coefficient": 'coef_cst',
            "Tomiyama SMD": 'Tomiyama_SMD'
        }

        self.tableModelInterfacialForces = StandardItemModelInterfacialForces(
            self, self.mdl, self.dicoM2V, self.dicoV2M)
        self.tableViewInterfacialForces.setModel(
            self.tableModelInterfacialForces)
        self.tableViewInterfacialForces.resizeColumnsToContents()
        self.tableViewInterfacialForces.resizeRowsToContents()
        if QT_API == "PYQT4":
            self.tableViewInterfacialForces.verticalHeader().setResizeMode(
                QHeaderView.ResizeToContents)
            self.tableViewInterfacialForces.horizontalHeader().setResizeMode(
                QHeaderView.ResizeToContents)
            self.tableViewInterfacialForces.horizontalHeader().setResizeMode(
                0, QHeaderView.Stretch)
        elif QT_API == "PYQT5":
            self.tableViewInterfacialForces.verticalHeader(
            ).setSectionResizeMode(QHeaderView.ResizeToContents)
            self.tableViewInterfacialForces.horizontalHeader(
            ).setSectionResizeMode(QHeaderView.ResizeToContents)
            self.tableViewInterfacialForces.horizontalHeader(
            ).setSectionResizeMode(0, QHeaderView.Stretch)
        self.tableViewInterfacialForces.setSelectionBehavior(
            QAbstractItemView.SelectRows)
        self.tableViewInterfacialForces.setSelectionMode(
            QAbstractItemView.SingleSelection)

        delegateFielda = FieldDelegate(self.tableViewInterfacialForces,
                                       self.mdl)
        delegateFieldb = FieldDelegate(self.tableViewInterfacialForces,
                                       self.mdl)
        delegateDrag = DragDelegate(self.tableViewInterfacialForces, self.mdl,
                                    self.dicoM2V, self.dicoV2M)
        delegateAddedMass = AddedMassDelegate(self.tableViewInterfacialForces,
                                              self.mdl, self.dicoM2V,
                                              self.dicoV2M)
        delegateLift = LiftDelegate(self.tableViewInterfacialForces, self.mdl,
                                    self.dicoM2V, self.dicoV2M)
        delegateDispTurb = DispersionTurbulentDelegate(
            self.tableViewInterfacialForces, self.mdl, self.dicoM2V,
            self.dicoV2M)
        delegateWallForce = WallForceDelegate(self.tableViewInterfacialForces,
                                              self.mdl, self.dicoM2V,
                                              self.dicoV2M)

        self.tableViewInterfacialForces.setItemDelegateForColumn(
            0, delegateFielda)
        self.tableViewInterfacialForces.setItemDelegateForColumn(
            1, delegateFieldb)
        self.tableViewInterfacialForces.setItemDelegateForColumn(
            2, delegateDrag)
        self.tableViewInterfacialForces.setItemDelegateForColumn(
            3, delegateAddedMass)
        self.tableViewInterfacialForces.setItemDelegateForColumn(
            4, delegateLift)
        self.tableViewInterfacialForces.setItemDelegateForColumn(
            5, delegateDispTurb)
        self.tableViewInterfacialForces.setItemDelegateForColumn(
            6, delegateWallForce)

        # Combo models
        self.modelContinuousMomentumTransfer = ComboModel(
            self.comboBoxContinuousMomentumTransfer, 3, 1)
        self.modelContinuousMomentumTransfer.addItem(self.tr('none'), 'none')
        self.modelContinuousMomentumTransfer.addItem(
            self.tr('Large Interface Model'), 'Large_Interface_Model')
        self.modelContinuousMomentumTransfer.addItem(
            self.tr('Large Bubble Model'), 'Large_Bubble_Model')

        self.modelInterfacialMethod = ComboModel(
            self.comboBoxInterfacialMethod, 2, 1)
        self.modelInterfacialMethod.addItem(self.tr('Refined gradient method'),
                                            'refined_gradient')
        self.modelInterfacialMethod.addItem(
            self.tr('Refined gradient method with 2 criteria'),
            'refined_gradient_2_criteria')

        # hide/show groupBoxContinuousMomentumTransfer
        if len(self.mdl.getContinuousFieldList()) >= 2:
            self.groupBoxContinuousMomentumTransfer.show()
            model = self.mdl.getContinuousCouplingModel()
            self.modelContinuousMomentumTransfer.setItem(str_model=model)
            self.updateContinuousMomemtum()
        else:
            self.groupBoxContinuousMomentumTransfer.hide()

        if len(self.mdl.getDispersedFieldList()) > 0:
            self.groupBoxDispersedMomentumTransfer.show()
        else:
            self.groupBoxDispersedMomentumTransfer.hide()

        # Connect signals to slots
        self.pushButtonAdd.clicked.connect(self.slotAddForce)
        self.pushButtonDelete.clicked.connect(self.slotDeleteForce)
        self.comboBoxContinuousMomentumTransfer.activated[str].connect(
            self.slotContinuousMomentumTransfer)
        self.comboBoxInterfacialMethod.activated[str].connect(
            self.slotInterfacialMethod)
        self.checkBoxGradPCorrection.clicked.connect(self.slotGradPCorrection)
        self.tableModelInterfacialForces.dataChanged.connect(self.dataChanged)
        self.checkBoxBubblesForLIM.clicked.connect(self.slotBubblesForLIM)
        self.checkBoxInterfaceSharpening.clicked.connect(
            self.slotInterfaceSharpening)
        self.checkBoxUnsharpenedCells.clicked.connect(
            self.slotUnsharpenedCells)
        self.checkBoxSurfaceTension.clicked.connect(self.slotSurfaceTension)

        for force in self.mdl.getForceList():
            self.tableModelInterfacialForces.newItem(force)

        self.case.undoStartGlobal()
Example #7
0
class LagrangianAdvancedOptionsDialogView(
        QDialog, Ui_LagrangianAdvancedOptionsDialogForm):
    """
    Advanced dialog
    """
    def __init__(self, parent, case, default):
        """
        Constructor
        """
        QDialog.__init__(self, parent)

        Ui_LagrangianAdvancedOptionsDialogForm.__init__(self)
        self.setupUi(self)

        self.case = case
        self.case.undoStopGlobal()

        self.setWindowTitle(self.tr("Advanced options"))
        self.default = default
        self.result = self.default.copy()

        # Combo model
        self.modelNORDRE = ComboModel(self.comboBoxNORDRE, 2, 1)
        self.modelNORDRE.addItem(self.tr("first-order scheme"), "1")
        self.modelNORDRE.addItem(self.tr("second-order scheme"), "2")

        self.modelIDIRLA = ComboModel(self.comboBoxIDIRLA, 3, 1)
        self.modelIDIRLA.addItem(self.tr("X"), "1")
        self.modelIDIRLA.addItem(self.tr("Y"), "2")
        self.modelIDIRLA.addItem(self.tr("Z"), "3")

        # Connections
        self.comboBoxNORDRE.activated[str].connect(self.slotNORDRE)
        self.checkBoxIDISTU.clicked.connect(self.slotIDISTU)
        self.checkBoxIDIFFL.clicked.connect(self.slotIDIFFL)
        self.groupBoxModel.clicked[bool].connect(self.slotModel)
        self.lineEditMODCPL.textChanged[str].connect(self.slotMODCPL)
        self.comboBoxIDIRLA.activated[str].connect(self.slotIDIRLA)

        validatorMODCPL = IntValidator(self.lineEditMODCPL, min=1)
        self.lineEditMODCPL.setValidator(validatorMODCPL)

        # initialize Widgets
        order = str(self.result['scheme_order'])
        self.modelNORDRE.setItem(str_model=order)

        if self.result['turbulent_dispertion'] == "on":
            self.checkBoxIDISTU.setChecked(True)
        else:
            self.checkBoxIDISTU.setChecked(False)

        if self.result['fluid_particles_turbulent_diffusion'] == "on":
            self.checkBoxIDIFFL.setChecked(True)
        else:
            self.checkBoxIDIFFL.setChecked(False)

        value = self.result['complete_model_iteration']
        if value > 0:
            self.lineEditMODCPL.setText(str(value))

            direction = self.result['complete_model_direction']
            self.modelIDIRLA.setItem(str_model=str(direction))
        else:
            self.groupBoxModel.setChecked(False)

        self.case.undoStartGlobal()
    def __setBoundary(self, boundary):
        """
        Set the current boundary
        """
        self.__boundary = boundary

        self.nature = boundary.getNature()
        self.therm = ThermalScalarModel(self.__case)
        self.sca_mo = DefineUserScalarsModel(self.__case)
        self.comp = CompressibleModel(self.__case)
        self.atm = AtmosphericFlowsModel(self.__case)

        self.modelTypeThermal = ComboModel(self.comboBoxTypeThermal, 1, 1)
        self.modelTypeSpecies = ComboModel(self.comboBoxTypeSpecies, 1, 1)
        self.modelTypeMeteo = ComboModel(self.comboBoxTypeMeteo, 1, 1)

        self.modelTypeThermal.addItem(self.tr("Prescribed value"), 'dirichlet')
        self.modelTypeSpecies.addItem(self.tr("Prescribed value"), 'dirichlet')
        self.modelTypeMeteo.addItem(self.tr("Prescribed value"), 'dirichlet')

        self.modelTypeThermal.addItem(self.tr("Prescribed value  (user law)"),
                                      'dirichlet_formula')
        self.modelTypeSpecies.addItem(self.tr("Prescribed value (user law)"),
                                      'dirichlet_formula')
        self.modelTypeMeteo.addItem(self.tr("Prescribed value (user law)"),
                                    'dirichlet_formula')

        if self.nature == 'outlet':
            self.modelTypeThermal.addItem(self.tr("Prescribed flux"),
                                          'neumann')
            self.modelTypeSpecies.addItem(self.tr("Prescribed flux"),
                                          'neumann')
            self.modelTypeMeteo.addItem(self.tr("Prescribed flux"), 'neumann')
        elif self.nature == 'wall':
            self.modelTypeThermal.addItem(self.tr("Prescribed flux"),
                                          'neumann')
            self.modelTypeSpecies.addItem(self.tr("Prescribed flux"),
                                          'neumann')
            self.modelTypeMeteo.addItem(self.tr("Prescribed flux"), 'neumann')
            self.modelTypeThermal.addItem(
                self.tr("Prescribed flux (user law)"), 'neumann_formula')
            self.modelTypeSpecies.addItem(
                self.tr("Prescribed flux (user law)"), 'neumann_formula')
            self.modelTypeMeteo.addItem(self.tr("Prescribed flux (user law)"),
                                        'neumann_formula')
            self.modelTypeThermal.addItem(self.tr("Exchange coefficient"),
                                          'exchange_coefficient')
            self.modelTypeSpecies.addItem(self.tr("Exchange coefficient"),
                                          'exchange_coefficient')
            self.modelTypeMeteo.addItem(self.tr("Exchange coefficient"),
                                        'exchange_coefficient')
            self.modelTypeThermal.addItem(
                self.tr("Exchange coefficient (user law)"),
                'exchange_coefficient_formula')
            self.modelTypeSpecies.addItem(
                self.tr("Exchange coefficient (user law)"),
                'exchange_coefficient_formula')
            self.modelTypeMeteo.addItem(
                self.tr("Exchange coefficient (user law)"),
                'exchange_coefficient_formula')
        elif self.nature == 'groundwater':
            self.modelTypeSpecies.addItem(self.tr("Prescribed flux"),
                                          'neumann')

        self.species = ""
        self.species_list = self.sca_mo.getUserScalarNameList()
        for s in self.sca_mo.getScalarsVarianceList():
            if s in self.species_list:
                self.species_list.remove(s)

        self.species = ""
        if self.species_list != []:
            self.groupBoxSpecies.show()
            self.modelSpecies = ComboModel(self.comboBoxSpecies, 1, 1)
            for species in self.species_list:
                self.modelSpecies.addItem(self.tr(species), species)
            self.species = self.species_list[0]
            self.modelSpecies.setItem(str_model=self.species)
        else:
            self.groupBoxSpecies.hide()

        self.model_th = self.therm.getThermalScalarModel()
        if self.model_th != 'off' and self.comp.getCompressibleModel(
        ) == 'off':
            self.groupBoxThermal.show()
            self.modelThermal = ComboModel(self.comboBoxThermal, 1, 1)
            self.thermal = self.therm.getThermalScalarName()
            self.modelThermal.addItem(self.tr(self.thermal), self.thermal)
            self.modelThermal.setItem(str_model=self.thermal)
        else:
            self.groupBoxThermal.hide()

        self.meteo_list = ""
        self.meteo_list = self.sca_mo.getMeteoScalarsNameList()

        self.groupBoxMeteo.hide()

        if (self.atm.getAtmosphericFlowsModel() != "off"
                and self.nature == 'wall'):
            self.groupBoxThermal.hide()

        if (self.atm.getAtmosphericFlowsModel() != "off" and \
           (self.nature == 'inlet' or self.nature == 'outlet')):
            label = self.__boundary.getLabel()
            nature = "meteo_" + self.nature
            bb = Boundary(nature, label, self.__case)

            if bb.getMeteoDataStatus() == 'off':
                self.groupBoxMeteo.hide()
                self.groupBoxThermal.show()
                self.modelMeteo = ComboModel(self.comboBoxMeteo, 1, 1)
                if len(self.meteo_list) > 0:
                    self.groupBoxMeteo.show()
                    for m in self.meteo_list:
                        self.modelMeteo.addItem(self.tr(m), m)
                    self.meteo = self.meteo_list[0]
                    self.modelMeteo.setItem(str_model=self.meteo)
            else:
                self.groupBoxMeteo.hide()
                self.groupBoxThermal.hide()

        self.initializeVariables()
Example #9
0
class StartRestartAdvancedDialogView(QDialog,
                                     Ui_StartRestartAdvancedDialogForm):
    """
    Building of popup window for advanced options.
    """
    def __init__(self, parent, case, default):
        """
        Constructor
        """
        QDialog.__init__(self, parent)

        Ui_StartRestartAdvancedDialogForm.__init__(self)
        self.setupUi(self)

        self.case = case
        self.case.undoStopGlobal()

        self.setWindowTitle(self.tr("Advanced options"))
        self.default = default
        self.result = self.default.copy()

        # Combo models and items
        self.modelFreq = ComboModel(self.comboBoxFreq, 4, 1)

        self.modelFreq.addItem(self.tr("Never"), 'Never')
        self.modelFreq.addItem(self.tr("Only at the end of the calculation"),
                               'At the end')
        self.modelFreq.addItem(self.tr("4 restart checkpoints"), '4 output')
        self.modelFreq.addItem(self.tr("Checkpoints frequency :"), 'Frequency')

        # Connections

        self.comboBoxFreq.activated[str].connect(self.slotFreq)
        self.lineEditNSUIT.textChanged[str].connect(self.slotNsuit)

        # Validator

        validatorNSUIT = IntValidator(self.lineEditNSUIT, min=0)
        self.lineEditNSUIT.setValidator(validatorNSUIT)

        # Read of auxiliary file if calculation restart is asked

        if self.default['restart']:
            self.groupBoxRestart.show()

            if self.default['restart_with_auxiliary'] == 'on':
                self.checkBoxReadAuxFile.setChecked(True)
            else:
                self.checkBoxReadAuxFile.setChecked(False)
        else:
            self.groupBoxRestart.hide()

        # Frequency of rescue of restart file

        if self.default['restart_rescue'] == -2:
            self.nsuit = -2
            self.lineEditNSUIT.setDisabled(True)
            self.freq = 'Never'
        elif self.default['restart_rescue'] == -1:
            self.nsuit = -1
            self.lineEditNSUIT.setDisabled(True)
            self.freq = 'At the end'
        elif self.default['restart_rescue'] == 0:
            self.nsuit = 0
            self.lineEditNSUIT.setDisabled(True)
            self.freq = '4 output'
        else:
            self.nsuit = self.default['restart_rescue']
            self.lineEditNSUIT.setEnabled(True)
            self.freq = 'Frequency'
        self.modelFreq.setItem(str_model=self.freq)
        self.lineEditNSUIT.setText(str(self.nsuit))

        self.case.undoStartGlobal()
Example #10
0
 def createEditor(self, parent, option, index):
     editor = QComboBox(parent)
     self.modelCombo = ComboModel(editor, 1, 1)
     editor.installEventFilter(self)
     return editor
Example #11
0
    def __init__(self, parent, case):
        """
        Constructor
        """
        QWidget.__init__(self, parent)

        Ui_OutputFields.__init__(self)
        self.setupUi(self)

        self.case = case
        self.case.undoStopGlobal()
        self.mdl = OutputFieldsModel(self.case)

        # Combo box models
        self.modelField = ComboModel(self.comboBoxField, 1, 1)
        for fieldId in self.mdl.getFieldIdList():
            label = self.mdl.getLabel(fieldId)
            name = str(fieldId)
            self.modelField.addItem(self.tr(label), name)

        self.currentid = -1
        if len(self.mdl.getFieldIdList()) > 0:
            self.currentid = self.mdl.getFieldIdList()[0]
            self.modelField.setItem(str_model=self.currentid)

        self.tableModelGlobalVariables = StandardItemModelGlobalVariables(
            self, "none", self.mdl)
        self.tableViewGlobalVariables.setModel(self.tableModelGlobalVariables)
        self.tableViewGlobalVariables.resizeColumnsToContents()
        self.tableViewGlobalVariables.resizeRowsToContents()
        if QT_API == "PYQT4":
            self.tableViewGlobalVariables.horizontalHeader().setResizeMode(
                QHeaderView.ResizeToContents)
            self.tableViewGlobalVariables.horizontalHeader().setResizeMode(
                0, QHeaderView.Stretch)
        elif QT_API == "PYQT5":
            self.tableViewGlobalVariables.horizontalHeader(
            ).setSectionResizeMode(QHeaderView.ResizeToContents)
            self.tableViewGlobalVariables.horizontalHeader(
            ).setSectionResizeMode(0, QHeaderView.Stretch)
        self.tableViewGlobalVariables.setSelectionBehavior(
            QAbstractItemView.SelectRows)
        self.tableViewGlobalVariables.setSelectionMode(
            QAbstractItemView.SingleSelection)

        self.tableModelFieldsVariables = StandardItemModelGlobalVariables(
            self, self.currentid, self.mdl)
        self.tableViewFieldsVariables.setModel(self.tableModelFieldsVariables)
        self.tableViewFieldsVariables.resizeColumnsToContents()
        self.tableViewFieldsVariables.resizeRowsToContents()
        if QT_API == "PYQT4":
            self.tableViewFieldsVariables.horizontalHeader().setResizeMode(
                QHeaderView.ResizeToContents)
            self.tableViewFieldsVariables.horizontalHeader().setResizeMode(
                0, QHeaderView.Stretch)
        elif QT_API == "PYQT5":
            self.tableViewFieldsVariables.horizontalHeader(
            ).setSectionResizeMode(QHeaderView.ResizeToContents)
            self.tableViewFieldsVariables.horizontalHeader(
            ).setSectionResizeMode(0, QHeaderView.Stretch)
        self.tableViewFieldsVariables.setSelectionBehavior(
            QAbstractItemView.SelectRows)
        self.tableViewFieldsVariables.setSelectionMode(
            QAbstractItemView.SingleSelection)

        delegateNameG = NameDelegate(self.tableViewGlobalVariables)
        delegateNameF = NameDelegate(self.tableViewFieldsVariables)
        probesDelegateG = ProbesDelegate(self.tableViewGlobalVariables,
                                         self.mdl)
        probesDelegateF = ProbesDelegate(self.tableViewFieldsVariables,
                                         self.mdl)

        self.tableViewGlobalVariables.setItemDelegateForColumn(
            0, delegateNameG)
        self.tableViewGlobalVariables.setItemDelegateForColumn(
            3, probesDelegateG)
        self.tableViewFieldsVariables.setItemDelegateForColumn(
            0, delegateNameF)
        self.tableViewFieldsVariables.setItemDelegateForColumn(
            3, probesDelegateF)

        # Connect signals to slots
        self.tableModelGlobalVariables.dataChanged.connect(
            self.dataChangedGlobalVariables)
        self.tableModelFieldsVariables.dataChanged.connect(
            self.dataChangedFieldsVariables)
        self.comboBoxField.activated[str].connect(self.slotField)

        for var in self.mdl.getGlobalVariables():
            self.tableModelGlobalVariables.newItem("none", var)

        if (len(self.mdl.getFieldIdList()) > 0):
            self.groupBoxField.show()
            self.initializeVariables(self.currentid)
        else:
            self.groupBoxField.hide()

        self.case.undoStartGlobal()
Example #12
0
class PreprocessingView(QWidget, Ui_PreprocessingForm):
    """
    """
    def __init__(self, parent, case, stbar):
        """
        Constructor
        """
        QWidget.__init__(self, parent)
        Ui_PreprocessingForm.__init__(self)
        self.setupUi(self)

        self.stbar = stbar
        self.case = case
        self.case.undoStopGlobal()
        self.mdl = SolutionDomainModel(self.case)

        # 2) Meshe preprocessing layout

        # 2.2) Connections

        self.groupBoxWarp.clicked[bool].connect(self.slotFacesCutting)
        self.lineEditWarp.textChanged[str].connect(self.slotWarpParam)
        self.groupBoxMeshSmooth.clicked[bool].connect(self.slotMeshSmooth)
        self.lineEditMeshSmooth.textChanged[str].connect(
            self.slotMeshSmoothParam)

        # 2.3) Set up validators
        validatorWarp = DoubleValidator(self.lineEditWarp, min=0.0)
        self.lineEditWarp.setValidator(validatorWarp)
        validatorSmooth = DoubleValidator(self.lineEditMeshSmooth,
                                          min=0.0,
                                          max=90.0)
        self.lineEditMeshSmooth.setValidator(validatorSmooth)

        # 2.4) Faces to join selection (Custom Widgets)

        model = StandardItemModelFaces(self, self.mdl, 'face_joining')
        self.widgetFacesJoin.modelFaces = model
        self.widgetFacesJoin.tableView.setModel(model)

        # 2.5) Thin wall

        self.tableModelThinWall = StandardItemModelThinWall(self, self.mdl)
        self.tableViewThinWall.setModel(self.tableModelThinWall)
        if QT_API == "PYQT4":
            self.tableViewThinWall.horizontalHeader().setResizeMode(
                0, QHeaderView.Stretch)
            self.tableViewThinWall.horizontalHeader().setResizeMode(
                1, QHeaderView.Stretch)
        elif QT_API == "PYQT5":
            self.tableViewThinWall.horizontalHeader().setSectionResizeMode(
                0, QHeaderView.Stretch)
            self.tableViewThinWall.horizontalHeader().setSectionResizeMode(
                1, QHeaderView.Stretch)
        self.tableViewThinWall.resizeColumnsToContents()
        self.tableViewThinWall.resizeRowsToContents()
        self.tableViewThinWall.setSelectionBehavior(
            QAbstractItemView.SelectRows)
        self.tableViewThinWall.setSelectionMode(
            QAbstractItemView.SingleSelection)

        delegateLabel = MeshNumberDelegate(self.tableViewThinWall)
        delegateSupport = LineEditDelegateSelector(self.tableViewThinWall)

        self.tableViewThinWall.setItemDelegateForColumn(0, delegateLabel)
        self.tableViewThinWall.setItemDelegateForColumn(1, delegateSupport)

        # Connections
        self.pushButtonAddThinWall.clicked.connect(self.slotAddThinWall)
        self.pushButtonDeleteThinWall.clicked.connect(self.slotDeleteThinWall)

        # load values
        for tw in range(self.mdl.getThinWallSelectionsCount()):
            self.tableModelThinWall.newItem(tw)

        # 2.5) Extrude

        self.tableModelExtrude = StandardItemModelExtrude(self, self.mdl)
        self.tableViewExtrude.setModel(self.tableModelExtrude)
        if QT_API == "PYQT4":
            self.tableViewExtrude.horizontalHeader().setResizeMode(
                4, QHeaderView.Stretch)
        elif QT_API == "PYQT5":
            self.tableViewExtrude.horizontalHeader().setSectionResizeMode(
                4, QHeaderView.Stretch)
        self.tableViewExtrude.resizeColumnsToContents()
        self.tableViewExtrude.resizeRowsToContents()
        self.tableViewExtrude.setSelectionBehavior(
            QAbstractItemView.SelectRows)
        self.tableViewExtrude.setSelectionMode(
            QAbstractItemView.SingleSelection)

        delegateLabel = MeshNumberDelegate(self.tableViewExtrude)
        delegateLayer = IntDelegate(self.tableViewExtrude)
        delegateSupport = LineEditDelegateSelector(self.tableViewExtrude)
        delegateFloat = FloatDelegate(self.tableViewExtrude)

        self.tableViewExtrude.setItemDelegateForColumn(0, delegateLabel)  # Id
        self.tableViewExtrude.setItemDelegateForColumn(
            1, delegateLayer)  # nlayers
        self.tableViewExtrude.setItemDelegateForColumn(
            2, delegateFloat)  # thickness
        self.tableViewExtrude.setItemDelegateForColumn(3,
                                                       delegateFloat)  # reason
        self.tableViewExtrude.setItemDelegateForColumn(
            4, delegateSupport)  # criteria

        # Connections
        self.pushButtonAddExtrude.clicked.connect(self.slotAddExtrude)
        self.pushButtonDeleteExtrude.clicked.connect(self.slotDeleteExtrude)

        # load values
        for tw in range(self.mdl.getExtrudeSelectionsCount()):
            self.tableModelExtrude.newItem(tw)

        # 3) Periodicities

        self.perio_mode = ""

        # Model for periodicities

        model = StandardItemModelFaces(self, self.mdl, 'face_periodicity')
        self.widgetFacesPerio.modelFaces = model
        self.widgetFacesPerio.tableView.setModel(model)

        # Combo model for type of periodicity
        self.modelComboPeriod = ComboModel(self.comboBoxPeriodicity, 3, 1)
        self.modelComboPeriod.addItem(self.tr("Periodicity by translation"),
                                      "translation")
        self.modelComboPeriod.addItem(
            self.tr(
                "Periodicity by rotation (defined by angle and direction)"),
            "rotation")
        self.modelComboPeriod.addItem(
            self.tr("Composite periodicity (defined by matrix)"), "mixed")

        # Display
        self.groupBoxMode.hide()
        self.groupBoxTranslation.hide()
        self.groupBoxRotation.hide()
        self.groupBoxMixed.hide()

        # Set up validators

        # 4)
        self.lineEditTX.setValidator(DoubleValidator(self.lineEditTX))
        self.lineEditTY.setValidator(DoubleValidator(self.lineEditTY))
        self.lineEditTZ.setValidator(DoubleValidator(self.lineEditTZ))
        self.lineEditAngle.setValidator(DoubleValidator(self.lineEditAngle))
        self.lineEditDX.setValidator(DoubleValidator(self.lineEditDX))
        self.lineEditDY.setValidator(DoubleValidator(self.lineEditDY))
        self.lineEditDZ.setValidator(DoubleValidator(self.lineEditDZ))
        self.lineEditX1.setValidator(DoubleValidator(self.lineEditX1))
        self.lineEditY1.setValidator(DoubleValidator(self.lineEditY1))
        self.lineEditZ1.setValidator(DoubleValidator(self.lineEditZ1))
        self.lineEditM11.setValidator(DoubleValidator(self.lineEditM11))
        self.lineEditM12.setValidator(DoubleValidator(self.lineEditM12))
        self.lineEditM13.setValidator(DoubleValidator(self.lineEditM13))
        self.lineEditM14.setValidator(DoubleValidator(self.lineEditM14))
        self.lineEditM21.setValidator(DoubleValidator(self.lineEditM21))
        self.lineEditM22.setValidator(DoubleValidator(self.lineEditM22))
        self.lineEditM23.setValidator(DoubleValidator(self.lineEditM23))
        self.lineEditM24.setValidator(DoubleValidator(self.lineEditM24))
        self.lineEditM31.setValidator(DoubleValidator(self.lineEditM31))
        self.lineEditM32.setValidator(DoubleValidator(self.lineEditM32))
        self.lineEditM33.setValidator(DoubleValidator(self.lineEditM33))
        self.lineEditM34.setValidator(DoubleValidator(self.lineEditM34))

        # Connections

        selectionModel = self.widgetFacesPerio.tableView.selectionModel()
        selectionModel.selectionChanged.connect(self.slotUpdatePeriodicity)

        self.widgetFacesPerio.pushButtonDelete.clicked.connect(
            self.slotDeletePeriodicity)

        self.comboBoxPeriodicity.activated[str].connect(
            self.slotPeriodicityMode)

        self.lineEditTX.textChanged[str].connect(self.slotTranslationX)
        self.lineEditTY.textChanged[str].connect(self.slotTranslationY)
        self.lineEditTZ.textChanged[str].connect(self.slotTranslationZ)

        self.lineEditAngle.textChanged[str].connect(self.slotAngleRotation)

        self.lineEditDX.textChanged[str].connect(self.slotRotationX)
        self.lineEditDY.textChanged[str].connect(self.slotRotationY)
        self.lineEditDZ.textChanged[str].connect(self.slotRotationZ)

        self.lineEditX1.textChanged[str].connect(self.slotCenterRotationX1)
        self.lineEditY1.textChanged[str].connect(self.slotCenterRotationY1)
        self.lineEditZ1.textChanged[str].connect(self.slotCenterRotationZ1)

        self.lineEditM11.textChanged[str].connect(self.slotMatrix11)
        self.lineEditM12.textChanged[str].connect(self.slotMatrix12)
        self.lineEditM13.textChanged[str].connect(self.slotMatrix13)
        self.lineEditM14.textChanged[str].connect(self.slotMatrix14)
        self.lineEditM21.textChanged[str].connect(self.slotMatrix21)
        self.lineEditM22.textChanged[str].connect(self.slotMatrix22)
        self.lineEditM23.textChanged[str].connect(self.slotMatrix23)
        self.lineEditM24.textChanged[str].connect(self.slotMatrix24)
        self.lineEditM31.textChanged[str].connect(self.slotMatrix31)
        self.lineEditM32.textChanged[str].connect(self.slotMatrix32)
        self.lineEditM33.textChanged[str].connect(self.slotMatrix33)
        self.lineEditM34.textChanged[str].connect(self.slotMatrix34)
        self.tabWidget.currentChanged[int].connect(self.slotchanged)

        # Warped faces cutting

        if self.mdl.getCutStatus() == 'on':
            self.groupBoxWarp.setChecked(True)
            self.slotFacesCutting(True)
        else:
            self.groupBoxWarp.setChecked(False)
            self.slotFacesCutting(False)

        v = self.mdl.getCutAngle()
        self.warp = v
        self.lineEditWarp.setText(str(self.warp))

        # Mesh Smoothing

        if self.mdl.getSmoothingStatus() == 'on':
            self.groupBoxMeshSmooth.setChecked(True)
            self.slotMeshSmooth(True)
        else:
            self.groupBoxMeshSmooth.setChecked(False)
            self.slotMeshSmooth(False)

        v = self.mdl.getSmoothAngle()
        self.smooth = v
        self.lineEditMeshSmooth.setText(str(self.smooth))

        # tab Widget
        self.tabWidget.setCurrentIndex(self.case['current_tab'])

        self.case.undoStartGlobal()