FEM: code formating, Python flake8: E211, E305

This commit is contained in:
Bernd Hahnebach
2018-01-01 20:50:56 +01:00
committed by wmayer
parent 0c0a7824e1
commit 0e65035ed4
7 changed files with 20 additions and 16 deletions

View File

@@ -107,7 +107,7 @@ class _TaskPanelFemSolverCalculix:
ccx_binary = self.ccx_prefs.GetString("ccxBinaryPath", "")
if ccx_binary:
self.CalculixBinary = ccx_binary
print ("Using CalculiX binary path from FEM preferences: {}".format(ccx_binary))
print("Using CalculiX binary path from FEM preferences: {}".format(ccx_binary))
else:
from platform import system
if system() == 'Linux':
@@ -192,12 +192,12 @@ class _TaskPanelFemSolverCalculix:
self.form.l_time.setText('Time: {0:4.1f}: '.format(time.time() - self.Start))
def calculixError(self, error):
print ("Error() {}".format(error))
print("Error() {}".format(error))
self.femConsoleMessage("CalculiX execute error: {}".format(error), "#FF0000")
def calculixStarted(self):
print ("calculixStarted()")
print (self.Calculix.state())
print("calculixStarted()")
print(self.Calculix.state())
self.form.pb_run_ccx.setText("Break CalculiX")
def calculixStateChanged(self, newState):
@@ -209,8 +209,8 @@ class _TaskPanelFemSolverCalculix:
self.femConsoleMessage("CalculiX stopped.")
def calculixFinished(self, exitCode):
print ("calculixFinished() {}".format(exitCode))
print (self.Calculix.state())
print("calculixFinished() {}".format(exitCode))
print(self.Calculix.state())
# Restore previous cwd
QtCore.QDir.setCurrent(self.cwd)
@@ -292,7 +292,7 @@ class _TaskPanelFemSolverCalculix:
self.ext_editor_process.start(ext_editor_path, [filename])
def editCalculixInputFile(self):
print ('editCalculixInputFile {}'.format(self.inp_file_name))
print('editCalculixInputFile {}'.format(self.inp_file_name))
if self.ccx_prefs.GetBool("UseInternalEditor", True):
FemGui.open(self.inp_file_name)
else:
@@ -300,18 +300,18 @@ class _TaskPanelFemSolverCalculix:
if ext_editor_path:
self.start_ext_editor(ext_editor_path, self.inp_file_name)
else:
print ("External editor is not defined in FEM preferences. Falling back to internal editor")
print("External editor is not defined in FEM preferences. Falling back to internal editor")
FemGui.open(self.inp_file_name)
def runCalculix(self):
print ('runCalculix')
print('runCalculix')
self.Start = time.time()
self.femConsoleMessage("CalculiX binary: {}".format(self.CalculixBinary))
self.femConsoleMessage("Run CalculiX...")
# run Calculix
print ('run CalculiX at: {} with: {}'.format(self.CalculixBinary, os.path.splitext(self.inp_file_name)[0]))
print('run CalculiX at: {} with: {}'.format(self.CalculixBinary, os.path.splitext(self.inp_file_name)[0]))
# change cwd because ccx may crash if directory has no write permission
# there is also a limit of the length of file names so jump to the document directory
self.cwd = QtCore.QDir.currentPath()
@@ -343,8 +343,8 @@ class _TaskPanelFemSolverCalculix:
try:
os.makedirs(wd)
except:
print ("Dir \'{}\' from FEM preferences doesn't exist and cannot be created.".format(wd))
print("Dir \'{}\' from FEM preferences doesn't exist and cannot be created.".format(wd))
import tempfile
wd = tempfile.gettempdir()
print ("Dir \'{}\' will be used instead.".format(wd))
print("Dir \'{}\' will be used instead.".format(wd))
return wd

View File

@@ -629,7 +629,7 @@ class _CommandFemSolverRun(CommandManager):
if ret_code == 0:
self.fea.load_results()
else:
print ("CalculiX failed ccx finished with error {}".format(ret_code))
print("CalculiX failed ccx finished with error {}".format(ret_code))
self.solver = self.selobj
if hasattr(self.solver, "SolverType") and self.solver.SolverType == "FemSolverCalculix":

View File

@@ -172,6 +172,7 @@ def write_fenics_mesh_scalar_cellfunctions(name, cell_array, attributenode, enco
elif encoding == ENCODING_HDF5:
pass
"""
Example: mesh with two topologies and one mesh function for the facet one

View File

@@ -253,7 +253,7 @@ class GmshTools():
# print (' No mesh group objects.')
pass
else:
print (' Mesh group objects, we need to get the elements.')
print(' Mesh group objects, we need to get the elements.')
for mg in self.mesh_obj.MeshGroupList:
new_group_elements = FemMeshTools.get_mesh_group_elements(mg, self.part_obj)
for ge in new_group_elements:
@@ -285,7 +285,7 @@ class GmshTools():
# print (' No mesh regions.')
pass
else:
print (' Mesh regions, we need to get the elements.')
print(' Mesh regions, we need to get the elements.')
# by the use of MeshRegion object and a BooleanSplitCompound there could be problems with node numbers see
# http://forum.freecadweb.org/viewtopic.php?f=18&t=18780&start=40#p149467
# http://forum.freecadweb.org/viewtopic.php?f=18&t=18780&p=149520#p149520
@@ -346,7 +346,7 @@ class GmshTools():
# print (' No mesh boundary layer setting document object.')
pass
else:
print (' Mesh boundary layers, we need to get the elements.')
print(' Mesh boundary layers, we need to get the elements.')
if self.part_obj.Shape.ShapeType == 'Compound':
# see http://forum.freecadweb.org/viewtopic.php?f=18&t=18780&start=40#p149467 and http://forum.freecadweb.org/viewtopic.php?f=18&t=18780&p=149520#p149520
err = "Gmsh could return unexpected meshes for a boolean split tools Compound. It is strongly recommended to extract the shape to mesh from the Compound and use this one."

View File

@@ -34,6 +34,7 @@ if App.GuiUp:
import FreeCADGui as Gui
from PyGui import FemSelectionWidgets
class Proxy(equationbase.BaseProxy):
def __init__(self, obj):

View File

@@ -229,6 +229,7 @@ class FemInputWriterZ88(FemInputWriter.FemInputWriter):
f.write(z88_dyn_template)
f.close()
# for solver parameter file Z88man.txt
z88_man_template = '''DYNAMIC START
---------------------------------------------------------------------------

View File

@@ -1304,6 +1304,7 @@ def create_test_results():
shutil.copyfile(dat_result_file, dat_Flow1D_thermomech_test_result_file)
print('Flow1D thermomech results copied to the appropriate FEM test dirs in: ' + temp_dir)
'''
update the results of FEM unit tests: