FEM: code formating

This commit is contained in:
Bernd Hahnebach
2021-07-05 13:06:21 +02:00
parent 20a2ee5732
commit fb8c6f7abe
2 changed files with 18 additions and 16 deletions

View File

@@ -277,19 +277,21 @@ class GeometryElementsSelection(QtGui.QWidget):
# label
self._helpTextLbl = QtGui.QLabel()
self._helpTextLbl.setWordWrap(True)
helpTextPart1 = self.tr('Click on "Add" and select geometric elements to add them to the list.')
helpTextPart2 = self.tr("The following geometry elements are allowed to select: ") + "<b>" + self.sel_elem_text + "</b>"
helpTextPart3 = self.tr("If no geometry is added to the list, all remaining ones are used.")
helpTextPart1 = self.tr(
'Click on "Add" and select geometric elements to add them to the list.{}'
"The following geometry elements are allowed to select: {}{}{}"
.format("<br>", "<b>", self.sel_elem_text, "</b>")
)
helpTextEmpty = self.tr(
"{}If no geometry is added to the list, all remaining ones are used.".format("<br>")
)
if self.showHintEmptyList is True:
self._helpTextLbl.setText(
helpTextPart1 + "<br>" +
helpTextPart2 + "<br>" +
helpTextPart3
helpTextPart1 + helpTextEmpty
)
else:
self._helpTextLbl.setText(
helpTextPart1 + "<br>" +
helpTextPart2
helpTextPart1
)
# list
self.list_References = QtGui.QListWidget()
@@ -310,13 +312,13 @@ class GeometryElementsSelection(QtGui.QWidget):
mainLayout.addWidget(self.list_References)
# if only "Solid" is avail, std-sel-mode is obsolete
if "Solid" in self.sel_elem_types and len (self.sel_elem_types) == 1:
if "Solid" in self.sel_elem_types and len(self.sel_elem_types) == 1:
self.selection_mode_solid = True
else:
self.selection_mode_solid = False
# show radio buttons, if a solid and at least one nonsolid is allowed
if "Solid" in self.sel_elem_types and len (self.sel_elem_types) > 1:
if "Solid" in self.sel_elem_types and len(self.sel_elem_types) > 1:
self.rb_standard.setChecked(True)
self.rb_solid.setChecked(False)
mainLayout.addLayout(rbtnLayout)

View File

@@ -1662,13 +1662,13 @@ class FemInputWriterCcx(writerbase.FemInputWriter):
ccx_elset["ccx_mat_name"] = mat_obj.Material["Name"]
self.ccx_elsets.append(ccx_elset)
def is_DENSITY_card_needed(self):
def is_density_needed(self):
if self.analysis_type == "frequency":
return True
if self.selfweight_objects:
return True
if self.analysis_type == "thermomech" and not self.solver_obj.ThermoMechSteadyState:
return True
if self.selfweight_objects:
return True
return False
def write_materials(self, f):
@@ -1676,7 +1676,7 @@ class FemInputWriterCcx(writerbase.FemInputWriter):
f.write("** Materials\n")
f.write("** written by {} function\n".format(sys._getframe().f_code.co_name))
f.write("** Young\'s modulus unit is MPa = N/mm2\n")
if self.is_DENSITY_card_needed() is True:
if self.is_density_needed() is True:
f.write("** Density\'s unit is t/mm^3\n")
if self.analysis_type == "thermomech":
f.write("** Thermal conductivity unit is kW/mm/K = t*mm/K*s^3\n")
@@ -1692,7 +1692,7 @@ class FemInputWriterCcx(writerbase.FemInputWriter):
YM = FreeCAD.Units.Quantity(mat_obj.Material["YoungsModulus"])
YM_in_MPa = float(YM.getValueAs("MPa"))
PR = float(mat_obj.Material["PoissonRatio"])
if self.is_DENSITY_card_needed() is True:
if self.is_density_needed() is True:
density = FreeCAD.Units.Quantity(mat_obj.Material["Density"])
density_in_tonne_per_mm3 = float(density.getValueAs("t/mm^3"))
if self.analysis_type == "thermomech":
@@ -1717,7 +1717,7 @@ class FemInputWriterCcx(writerbase.FemInputWriter):
f.write("*ELASTIC\n")
f.write("{0:.0f}, {1:.3f}\n".format(YM_in_MPa, PR))
if self.is_DENSITY_card_needed() is True:
if self.is_density_needed() is True:
f.write("*DENSITY\n")
f.write("{0:.3e}\n".format(density_in_tonne_per_mm3))
if self.analysis_type == "thermomech":