FEM: code formating, flake8, make line breaks before binary operator, it really reads better :-)

This commit is contained in:
Bernd Hahnebach
2019-01-04 19:52:47 +01:00
committed by wmayer
parent 19cd5690e7
commit 86c7a85e3c
6 changed files with 43 additions and 30 deletions

View File

@@ -333,7 +333,8 @@ class ControlWidget(QtGui.QWidget):
self._directoryGrp.setDisabled(False)
self._writeBtt.setDisabled(False)
self._editBtt.setDisabled(
not machine.solver.Proxy.editSupported() or
machine.state < femsolver.run.PREPARE)
not machine.solver.Proxy.editSupported()
or machine.state < femsolver.run.PREPARE
)
## @}

View File

@@ -128,18 +128,18 @@ def make_femmesh(mesh_data):
if ('Nodes' in m) and (len(m['Nodes']) > 0):
FreeCAD.Console.PrintLog("Found: nodes\n")
if (
('Seg2Elem' in m) or
('Seg3Elem' in m) or
('Tria3Elem' in m) or
('Tria6Elem' in m) or
('Quad4Elem' in m) or
('Quad8Elem' in m) or
('Tetra4Elem' in m) or
('Tetra10Elem' in m) or
('Penta6Elem' in m) or
('Penta15Elem' in m) or
('Hexa8Elem' in m) or
('Hexa20Elem' in m)
('Seg2Elem' in m)
or ('Seg3Elem' in m)
or ('Tria3Elem' in m)
or ('Tria6Elem' in m)
or ('Quad4Elem' in m)
or ('Quad8Elem' in m)
or ('Tetra4Elem' in m)
or ('Tetra10Elem' in m)
or ('Penta6Elem' in m)
or ('Penta15Elem' in m)
or ('Hexa8Elem' in m)
or ('Hexa20Elem' in m)
):
nds = m['Nodes']

View File

@@ -345,11 +345,18 @@ def read_z88_mesh(z88_mesh_input):
# write z88 Mesh
def write_z88_mesh_to_file(femnodes_mesh, femelement_table, z88_element_type, f):
node_dimension = 3 # 2 for 2D not supported
if (z88_element_type == 4 or
z88_element_type == 17 or z88_element_type == 16 or
z88_element_type == 1 or z88_element_type == 10):
if (
z88_element_type == 4
or z88_element_type == 17
or z88_element_type == 16
or z88_element_type == 1
or z88_element_type == 10
):
node_dof = 3
elif z88_element_type == 23 or z88_element_type == 24:
elif (
z88_element_type == 23
or z88_element_type == 24
):
node_dof = 6 # schalenelemente
else:
print("Error: wrong z88_element_type")

View File

@@ -184,11 +184,9 @@ class Builder(object):
for solverSection in eqSection[self._ACTIVE_SOLVERS]:
if solverSection not in allSections:
allSections.append(solverSection)
if (BODY_FORCE in section and
section[BODY_FORCE] not in allSections):
if BODY_FORCE in section and section[BODY_FORCE] not in allSections:
allSections.append(section[BODY_FORCE])
if (INITIAL_CONDITION in section and
section[INITIAL_CONDITION] not in allSections):
if INITIAL_CONDITION in section and section[INITIAL_CONDITION] not in allSections:
allSections.append(section[INITIAL_CONDITION])
for name, section in self._boundaries.items():
section["Name"] = name
@@ -337,8 +335,10 @@ class _Writer(object):
return it.next()
def _isCollection(self, data):
return (not isinstance(data, six.string_types) and
isinstance(data, collections.Iterable))
return (
not isinstance(data, six.string_types)
and isinstance(data, collections.Iterable)
)
def _checkScalar(self, dataType):
if issubclass(dataType, int):

View File

@@ -187,8 +187,11 @@ class Machine(BaseTask):
self._confTasks()
self._isReset = False
self._pendingState = self.state
while (not self.aborted and not self.failed and
self._pendingState <= self.target):
while (
not self.aborted
and not self.failed
and self._pendingState <= self.target
):
task = self._getTask(self._pendingState)
self._runTask(task)
self.report.extend(task.report)
@@ -380,8 +383,11 @@ class _DocObserver(object):
def _checkEquation(self, obj):
for o in obj.Document.Objects:
if (FemUtils.is_derived_from(o, "Fem::FemSolverObject") and
hasattr(o, "Group") and obj in o.Group):
if (
FemUtils.is_derived_from(o, "Fem::FemSolverObject")
and hasattr(o, "Group")
and obj in o.Group
):
if o in _machines:
_machines[o].reset()

View File

@@ -108,8 +108,7 @@ def is_derived_from(obj, t):
'''returns True if an object or its inheritance chain is of a given TypeId (C++ objects) or Proxy.Type (Python objects)'''
# returns true for all FEM objects if given t == 'App::DocumentObject' since this is a father of the given object
# see https://forum.freecadweb.org/viewtopic.php?f=10&t=32625
if (hasattr(obj, "Proxy") and hasattr(obj.Proxy, "Type") and
obj.Proxy.Type == t):
if (hasattr(obj, "Proxy") and hasattr(obj.Proxy, "Type") and obj.Proxy.Type == t):
return True
return obj.isDerivedFrom(t)