def checkReplaceZone(self): """Check whether the zone could be replaced for boundary conditions.""" model = LocalizationModel("BoundaryZone", self.case) zone1 = Zone("BoundaryZone", label='entre1', localization="porte", nature='inlet') model.addZone(zone1) zone4 = Zone("BoundaryZone", label='hublot', localization="2 et 3", nature='symmetry') model.replaceZone(zone1, zone4) doc = '''<boundary_conditions> <boundary label="hublot" name="1" nature="symmetry"> 2 et 3 </boundary> </boundary_conditions>''' assert self.case.xmlGetNode('boundary_conditions') == self.xmlNodeFromString(doc),\ 'Could not replace zone in localizationModel for boundaries conditions'
def checkSetandGetNameLabelandCoefficients(self): """Check whether the head_losses markups could be set and get""" # we create a new zone for head losses loc = LocalizationModel("VolumicZone", self.case) zone = Zone("VolumicZone", label='toto', localization="1 or door", nature="head_losses") loc.addZone(zone) #we can test mdl = HeadLossesModel(self.case) mdl.getNameAndLocalizationZone() doc = '''<head_losses> <head_loss zone_id="2"> <kxx>0</kxx> <kyy>0</kyy> <kzz>0</kzz> <a11>0</a11> <a12>0</a12> <a13>0</a13> <a21>0</a21> <a22>0</a22> <a23>0</a23> <a31>0</a31> <a32>0</a32> <a33>0</a33> </head_loss> </head_losses>''' assert mdl.node_hloss == self.xmlNodeFromString(doc),\ 'Could not set zone_id and label for head losses' assert mdl.getNameAndLocalizationZone() == {'toto': (2, '1 or door')},\ 'Could not get zone_id, label and localization for head losses'
def checkSetLabelAndLocalization(self): """Check whether the zone could be replaced for boundary conditions.""" model = LocalizationModel("BoundaryZone", self.case) zone1 = Zone("BoundaryZone", label='entre1', localization="porte", nature='inlet') model.addZone(zone1) model.setLabel('entre1', 'entry1') doc = '''<boundary_conditions> <boundary label="entry1" name="1" nature="inlet"> porte </boundary> </boundary_conditions>''' assert self.case.xmlGetNode('boundary_conditions') == self.xmlNodeFromString(doc),\ 'Could not set Label' model.setLocalization('entry1', 'door') doc = '''<boundary_conditions> <boundary label="entry1" name="1" nature="inlet"> door </boundary> </boundary_conditions>''' assert self.case.xmlGetNode('boundary_conditions') == self.xmlNodeFromString(doc),\ 'Could not set Localization'
def checkSetandGetKCoefficients(self): """Check whether the head_losses could be set and get kxx, kyy, kzz""" # we create a new zone for head losses loc = LocalizationModel("VolumicZone", self.case) zone = Zone("VolumicZone", label='toto', localization="1 or door", nature="head_losses") loc.addZone(zone) mdl = HeadLossesModel(self.case) mdl.setKCoefficients('2', 10., 100., 1000.) doc = '''<head_losses> <head_loss zone_id="2"> <kxx>10</kxx> <kyy>100</kyy> <kzz>1000</kzz> <a11>0</a11> <a12>0</a12> <a13>0</a13> <a21>0</a21> <a22>0</a22> <a23>0</a23> <a31>0</a31> <a32>0</a32> <a33>0</a33> </head_loss> </head_losses>''' assert mdl.node_hloss == self.xmlNodeFromString(doc),\ 'Could not set kxx, kyy, kzz coefficients for head losses' assert mdl.getKCoefficients('2') == (10., 100., 1000.),\ 'Could not get kxx, kyy, kzz coefficients for head losses' mdl.setCoefficient('2', 'kyy', 555.) doc2 = '''<head_losses> <head_loss zone_id="2"> <kxx>10</kxx> <kyy>555</kyy> <kzz>1000</kzz> <a11>0</a11> <a12>0</a12> <a13>0</a13> <a21>0</a21> <a22>0</a22> <a23>0</a23> <a31>0</a31> <a32>0</a32> <a33>0</a33> </head_loss> </head_losses>''' assert mdl.node_hloss == self.xmlNodeFromString(doc2),\ 'Could not set one coefficient for head losses' assert mdl.getCoefficient('2', 'kyy') == 555.,\ 'Could not get one coefficient for head losses'
def checkSetandGetMatrix(self): """Check whether the head_losses could be set and get composantes of matrix""" # we create a new zone for head losses loc = LocalizationModel("VolumicZone", self.case) zone = Zone("VolumicZone", label='toto', localization="1 or door", nature="head_losses") loc.addZone(zone) mdl = HeadLossesModel(self.case) mdl.setMatrix('2', 1., 1.2, 1.5, 2., 2.2, 2.5, 3., 3.2, 3.5) doc = '''<head_losses> <head_loss zone_id="2"> <kxx>0</kxx> <kyy>0</kyy> <kzz>0</kzz> <a11>1</a11> <a12>1.2</a12> <a13>1.5</a13> <a21>2</a21> <a22>2.2</a22> <a23>2.5</a23> <a31>3</a31> <a32>3.2</a32> <a33>3.5</a33> </head_loss> </head_losses>''' assert mdl.node_hloss == self.xmlNodeFromString(doc),\ 'Could not set matrix for head losses' assert mdl.getMatrix('2') == (1., 1.2, 1.5, 2., 2.2, 2.5, 3., 3.2, 3.5),\ 'Could not get matrix for head losses' mdl.setMatrixComponent('2', 'a23', 2300.55) doc2 = '''<head_losses> <head_loss zone_id="2"> <kxx>0</kxx> <kyy>0</kyy> <kzz>0</kzz> <a11>1</a11> <a12>1.2</a12> <a13>1.5</a13> <a21>2</a21> <a22>2.2</a22> <a23>2300.55</a23> <a31>3</a31> <a32>3.2</a32> <a33>3.5</a33> </head_loss> </head_losses>''' assert mdl.node_hloss == self.xmlNodeFromString(doc2),\ 'Could not set one composant of the matrix for head losses' assert mdl.getMatrixComponent('2', 'a23') == 2300.55,\ 'Could not get one composant of the matrix for head losses'
def checkSetNature(self): """Check whether the zone could be replaced for boundary conditions.""" model = LocalizationModel("BoundaryZone", self.case) zone1 = Zone("BoundaryZone", label='entre1', localization="porte", nature='inlet') model.addZone(zone1) model.setNature('entre1','wall') doc = '''<boundary_conditions> <boundary label="entre1" name="1" nature="wall"> porte </boundary> <wall field_id="none" label="entre1"/> </boundary_conditions>''' assert self.case.xmlGetNode('boundary_conditions') == self.xmlNodeFromString(doc),\ 'Could not set Nature'
def slotAddFromSalome(self): """ When GUI is embeded in the Salome desktop. Add selection criteria from graphical selection in the VTK viwver, or in the ObjectBrowser. """ if self.case['salome']: from code_saturne.gui.case.SalomeHandler import BoundaryGroup, VolumeGroup log.debug("slotAddFromSalome: zoneType -> %s" % self.zoneType) if self.zoneType == 'VolumicZone': loc = VolumeGroup() elif self.zoneType == 'BoundaryZone': loc = BoundaryGroup() log.debug("slotAddFromSalome: selection criteria -> %s" % loc) if loc not in self.mdl.getLocalizationsZonesList() and loc != "" : zone = Zone(self.zoneType, localization = loc, case = self.case) self.mdl.addZone(zone) self.modelLocalization.addItem(zone)