def renameLabel(self, label, newLabel): """ """ if label == newLabel: return labels = self.getLabelsZonesList() Model().isInList(label, labels) Model().isNotInList(newLabel, labels)
def __setOnOffXML(self, name, value): """ Set value of 'on'/'off' xml attribute """ Model().isInList(value, ['on', 'off']) xmlNode = self.__node_ale.xmlInitNode(name) xmlNode['status'] = value
def renameName(self, codeNumber, newCodeNumber): """ """ if codeNumber == newCodeNumber: return labels = self.getLabelsZonesList() Model().isInt(newCodeNumber)
def getElectricalScalarType(self, scalarName): """ Return type of scalar for choice of color (for view) """ self.isInList(scalarName, self.getElectricalScalarsNameList()) models = self.case.xmlGetNode('thermophysical_models') node = models.xmlGetNode('joule_effect', 'model') n = node.xmlGetNode('variable', 'type', name=scalarName) Model().isInList(n['type'], ('user', 'thermal', 'model')) return n['type']
def getScalarType(self, scalar_name): """ Return type of scalar for choice of color (for view) """ self.isInList(scalar_name, self.getScalarNameList() + self.getThermalScalarName()) if scalar_name not in self.getScalarNameList(): node = self.node_therm.xmlGetNode('variable', name=scalar_name) else: node = self.scalar_node.xmlGetNode('variable', 'type', name=scalar_name) Model().isInList(node['type'], ('user', 'thermal')) return node['type']
def replaceZone(self, old_zone, new_zone): """ Replace a zone by another in the XML file """ if (new_zone.getNature() != old_zone.getNature()): if self.case['package'].name == 'code_saturne': Boundary(old_zone.getNature(), old_zone.getLabel(), self.case).delete() else: BoundaryNCFD(old_zone.getNature(), old_zone.getLabel(), self.case).delete() newLabel, newCodeNumber, newLocal = LocalizationModel.replaceZone( self, old_zone, new_zone) newNature = new_zone.getNature() Model().isInList(newNature, self.__natureList) node = self.__XMLBoundaryConditionsNode.xmlGetNode( 'boundary', label=old_zone.getLabel()) node['label'] = newLabel node['name'] = newCodeNumber node['nature'] = newNature node.xmlSetTextNode(newLocal) if self.case['package'].name == 'code_saturne': Boundary(new_zone.getNature(), new_zone.getLabel(), self.case) else: BoundaryNCFD(new_zone.getNature(), new_zone.getLabel(), self.case) else: label = old_zone.getLabel() codeNumber = old_zone.getCodeNumber() localis = old_zone.getLocalization() newLabel = new_zone.getLabel() if label != newLabel: self.setLabel(label, newLabel) newCodeNumber = new_zone.getCodeNumber() if codeNumber != newCodeNumber: self.setCodeNumber(codeNumber, newCodeNumber) newLocal = new_zone.getLocalization() if localis != newLocal: self.setLocalization(newLabel, newLocal)
def addZone(self, newZone=None): """ Add a new zone. Management of default values. """ if newZone == None: newZone = Zone(self._typeZone, case=self.case) zones = self.getZones() # Set localization if newZone.getLocalization() == newZone.defaultValues( )['localization']: oldLocalization = "" newLocalization = "" for zone in zones: oldLocalization = zone.getLocalization() if oldLocalization != "all[]": if newLocalization == "": newLocalization = oldLocalization else: newLocalization += " or " + oldLocalization if newLocalization == "": newLocalization = newZone.defaultValues()['localization'] if newLocalization != "all[]": newLocalization = "not (" + newLocalization + ")" newZone.setLocalization(newLocalization) else: # No control on localization is avaliable pass # Set code number if newZone.getCodeNumber() == newZone.defaultValues()['codeNumber']: newZone.setCodeNumber(self.getMaxCodeNumber() + 1) else: codes = [] for zone in zones: codes.append(zone.getCodeNumber()) Model().isNotInList(newZone.getCodeNumber(), codes) # Set label: search a free label (Type of newLabel is: "default_n") newLabel = newZone.getLabel() if newLabel == newZone.defaultValues()['label']: code = 1 inLabels = 1 while (inLabels): inLabels = 0 for zone in zones: if newLabel + str(code) == zone.getLabel(): inLabels = 1 break code += 1 newLabel = newLabel + str(code - 1) newZone.setLabel(newLabel) else: labels = [] for zone in zones: labels.append(zone.getLabel()) Model().isNotInList(newLabel, labels) # Set nature: nothing here, see other addZone reimplementation methods return newZone
def setLocalization(self, label, localization): """ Define a new localization for the current zone (zone.getLabel == label). """ labels = self.getLabelsZonesList() Model().isInList(label, labels)
def replaceLocalization(self, local, newLocal): """ """ if local == newLocal: return Model().isNotInList(newLocal, self.getLocalizationsZonesList())
def getMaxNumberNature(self, nature): """ Return maximum of nature number's values to put on name """ Model().isInList(nature, self._natureList)
def setNature(self, text): if Model().isInList(text, self._natureList): self._nature = text
def setCodeNumber(self, number): if Model().isPositiveInt(number): self._codeNumber = number
def setLocalization(self, text): if Model().isStr(text): self._localization = text
def setLabel(self, text): if Model().isStr(text): self._label = text