FEM: code formating, line length < 100, there still where some left

This commit is contained in:
Bernd Hahnebach
2019-05-27 22:27:51 +02:00
parent 63f3453189
commit d682d3ea6e
4 changed files with 33 additions and 10 deletions

View File

@@ -651,7 +651,10 @@ class _CommandFemMaterialMechanicalNonlinear(CommandManager):
# CalculiX solver or new frame work CalculiX solver
if solver_object \
and hasattr(solver_object, "Proxy") \
and (solver_object.Proxy.Type == 'Fem::FemSolverCalculixCcxTools' or solver_object.Proxy.Type == 'Fem::FemSolverObjectCalculix'):
and (
solver_object.Proxy.Type == 'Fem::FemSolverCalculixCcxTools'
or solver_object.Proxy.Type == 'Fem::FemSolverObjectCalculix'
):
print(
'Set MaterialNonlinearity and GeometricalNonlinearity to nonlinear for {}'
.format(solver_object.Label)

View File

@@ -207,7 +207,8 @@ class _ViewProviderFemMeshGmsh:
return True
def dragObject(self, selfvp, dragged_object):
if hasattr(dragged_object, "Proxy") and dragged_object.Proxy.Type == "Fem::FemMeshBoundaryLayer":
if hasattr(dragged_object, "Proxy") \
and dragged_object.Proxy.Type == "Fem::FemMeshBoundaryLayer":
objs = self.Object.MeshBoundaryLayerList
objs.remove(dragged_object)
self.Object.MeshBoundaryLayerList = objs

View File

@@ -650,7 +650,10 @@ class FemInputWriterCcx(writerbase.FemInputWriter):
f.write('** Young\'s modulus unit is MPa = N/mm2\n')
if self.analysis_type == "frequency" \
or self.selfweight_objects \
or (self.analysis_type == "thermomech" and not self.solver_obj.ThermoMechSteadyState):
or (
self.analysis_type == "thermomech"
and not self.solver_obj.ThermoMechSteadyState
):
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')
@@ -668,7 +671,10 @@ class FemInputWriterCcx(writerbase.FemInputWriter):
PR = float(mat_obj.Material['PoissonRatio'])
if self.analysis_type == "frequency" \
or self.selfweight_objects \
or (self.analysis_type == "thermomech" and not self.solver_obj.ThermoMechSteadyState):
or (
self.analysis_type == "thermomech"
and not self.solver_obj.ThermoMechSteadyState
):
density = FreeCAD.Units.Quantity(mat_obj.Material['Density'])
density_in_tonne_per_mm3 = float(density.getValueAs('t/mm^3'))
if self.analysis_type == "thermomech":
@@ -695,7 +701,10 @@ class FemInputWriterCcx(writerbase.FemInputWriter):
if self.analysis_type == "frequency" \
or self.selfweight_objects \
or (self.analysis_type == "thermomech" and not self.solver_obj.ThermoMechSteadyState):
or (
self.analysis_type == "thermomech"
and not self.solver_obj.ThermoMechSteadyState
):
f.write('*DENSITY\n')
f.write('{0:.3e}\n'.format(density_in_tonne_per_mm3))
if self.analysis_type == "thermomech":

View File

@@ -139,13 +139,17 @@ def compare_inp_files(
# for python3 problem with 1DFlow input
# TODO as soon as the 1DFlow result reading is fixed
# this should be triggered in the 1DFlow unit test
lf1 = [l for l in f1 if not (l.startswith('** written ') or l.startswith('** file ') or l.startswith('17671.0,1'))]
lf1 = [l for l in f1 if not (
l.startswith('** written ') or l.startswith('** file ') or l.startswith('17671.0,1')
)]
lf1 = force_unix_line_ends(lf1)
file2 = open(file_name2, 'r')
f2 = file2.readlines()
file2.close()
# TODO see comment on file1
lf2 = [l for l in f2 if not (l.startswith('** written ') or l.startswith('** file ') or l.startswith('17671.0,1'))]
lf2 = [l for l in f2 if not (
l.startswith('** written ') or l.startswith('** file ') or l.startswith('17671.0,1')
)]
lf2 = force_unix_line_ends(lf2)
import difflib
diff = difflib.unified_diff(lf1, lf2, n=0)
@@ -169,12 +173,16 @@ def compare_files(
file1.close()
# workaround to compare geos of elmer test and temporary file path
# (not only names change, path changes with operating system)
lf1 = [l for l in f1 if not (l.startswith('Merge "') or l.startswith('Save "') or l.startswith('// '))]
lf1 = [l for l in f1 if not (
l.startswith('Merge "') or l.startswith('Save "') or l.startswith('// ')
)]
lf1 = force_unix_line_ends(lf1)
file2 = open(file_name2, 'r')
f2 = file2.readlines()
file2.close()
lf2 = [l for l in f2 if not (l.startswith('Merge "') or l.startswith('Save "') or l.startswith('// '))]
lf2 = [l for l in f2 if not (
l.startswith('Merge "') or l.startswith('Save "') or l.startswith('// ')
)]
lf2 = force_unix_line_ends(lf2)
import difflib
diff = difflib.unified_diff(lf1, lf2, n=0)
@@ -270,7 +278,9 @@ def collect_python_modules(
)
else:
collected_modules.append(
femsubdir.replace('/', '.') + '.' + os.path.splitext(os.path.basename(pyfile))[0]
femsubdir.replace('/', '.') + '.' + os.path.splitext(
os.path.basename(pyfile)
)[0]
)
return collected_modules