Skip to content
Permalink
Browse files

FEM: code formating, flake8, make line breaks before binary operator,…

… it really reads better :-)
  • Loading branch information...
berndhahnebach authored and wwmayer committed Jan 4, 2019
1 parent 19cd569 commit 86c7a85e3c83ef7171968c90bfea54a99cc0d821
@@ -333,7 +333,8 @@ def setRunning(self, machine):
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
)

## @}
@@ -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']
@@ -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")
@@ -184,11 +184,9 @@ def __iter__(self):
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 @@ def _getOnlyElement(self, collection):
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):
@@ -187,8 +187,11 @@ def run(self):
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 @@ def delegate():

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()

@@ -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)

0 comments on commit 86c7a85

Please sign in to comment.
You can’t perform that action at this time.