FEM: lgtm, various improvements
This commit is contained in:
@@ -49,11 +49,9 @@ def setup_cantileverbase(doc=None, solver='ccxtools'):
|
||||
# analysis
|
||||
analysis = ObjectsFem.makeAnalysis(doc, 'Analysis')
|
||||
|
||||
solver
|
||||
# solver
|
||||
# TODO How to pass multiple solver for one analysis in one doc
|
||||
if solver is None:
|
||||
pass # no solver is added
|
||||
elif solver is 'calculix':
|
||||
if solver == 'calculix':
|
||||
solver_object = analysis.addObject(
|
||||
ObjectsFem.makeSolverCalculix(doc, 'SolverCalculiX')
|
||||
)[0]
|
||||
@@ -62,7 +60,7 @@ def setup_cantileverbase(doc=None, solver='ccxtools'):
|
||||
solver_object.ThermoMechSteadyState = False
|
||||
solver_object.MatrixSolverType = 'default'
|
||||
solver_object.IterationsControlParameterTimeUse = False
|
||||
elif solver is 'ccxtools':
|
||||
elif solver == 'ccxtools':
|
||||
solver_object = analysis.addObject(
|
||||
ObjectsFem.makeSolverCalculixCcxTools(doc, 'CalculiXccxTools')
|
||||
)[0]
|
||||
@@ -72,9 +70,9 @@ def setup_cantileverbase(doc=None, solver='ccxtools'):
|
||||
solver_object.MatrixSolverType = 'default'
|
||||
solver_object.IterationsControlParameterTimeUse = False
|
||||
solver_object.WorkingDir = u''
|
||||
elif solver is 'elmer':
|
||||
elif solver == 'elmer':
|
||||
analysis.addObject(ObjectsFem.makeSolverElmer(doc, 'SolverElmer'))
|
||||
elif solver is 'z88':
|
||||
elif solver == 'z88':
|
||||
analysis.addObject(ObjectsFem.makeSolverZ88(doc, 'SolverZ88'))
|
||||
|
||||
# material
|
||||
|
||||
@@ -68,11 +68,9 @@ def setup_rcwall2d(doc=None, solver='ccxtools'):
|
||||
# analysis
|
||||
analysis = ObjectsFem.makeAnalysis(doc, 'Analysis')
|
||||
|
||||
solver
|
||||
# solver
|
||||
# TODO How to pass multiple solver for one analysis in one doc
|
||||
if solver is None:
|
||||
pass # no solver is added
|
||||
elif solver is 'calculix':
|
||||
if solver == 'calculix':
|
||||
solver = analysis.addObject(
|
||||
ObjectsFem.makeSolverCalculix(doc, 'SolverCalculiX')
|
||||
)[0]
|
||||
@@ -81,7 +79,7 @@ def setup_rcwall2d(doc=None, solver='ccxtools'):
|
||||
solver.ThermoMechSteadyState = False
|
||||
solver.MatrixSolverType = 'default'
|
||||
solver.IterationsControlParameterTimeUse = False
|
||||
elif solver is 'ccxtools':
|
||||
elif solver == 'ccxtools':
|
||||
solver = analysis.addObject(
|
||||
ObjectsFem.makeSolverCalculixCcxTools(doc, 'CalculiXccxTools')
|
||||
)[0]
|
||||
|
||||
@@ -141,8 +141,9 @@ def show_color_by_scalar_with_cutoff(resultobj, values, limit=None):
|
||||
def get_stats(res_obj, result_type):
|
||||
match_table = get_all_stats(res_obj)
|
||||
match_table["None"] = (0.0, 0.0, 0.0)
|
||||
stats = (0.0, 0.0, 0.0)
|
||||
stats = match_table[result_type]
|
||||
stats = ()
|
||||
if result_type in match_table:
|
||||
stats = match_table[result_type]
|
||||
return stats
|
||||
|
||||
|
||||
|
||||
@@ -108,12 +108,12 @@ class Solve(run.Solve):
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE)
|
||||
self.signalAbort.add(self._process.terminate)
|
||||
output = self._observeSolver(self._process)
|
||||
# output = self._observeSolver(self._process)
|
||||
self._process.communicate()
|
||||
self.signalAbort.remove(self._process.terminate)
|
||||
# if not self.aborted:
|
||||
# self._updateOutput(output)
|
||||
del output # get flake8 quiet
|
||||
# del output # get flake8 quiet
|
||||
|
||||
|
||||
class Results(run.Results):
|
||||
|
||||
@@ -227,10 +227,10 @@ class FemInputWriter():
|
||||
# check shape type of reference shape
|
||||
for femobj in self.force_objects:
|
||||
# femobj --> dict, FreeCAD document object is femobj['Object']
|
||||
FreeCAD.Console.PrintMessage(
|
||||
"Constraint force:" + ' ' + femobj['Object'].Name + '\n'
|
||||
)
|
||||
frc_obj = femobj['Object']
|
||||
FreeCAD.Console.PrintMessage(
|
||||
"Constraint force:" + ' ' + frc_obj.Name + '\n'
|
||||
)
|
||||
if femobj['RefShapeType'] == 'Vertex':
|
||||
FreeCAD.Console.PrintLog(
|
||||
"load on vertices --> we do not need the "
|
||||
|
||||
@@ -102,7 +102,7 @@ class Solve(run.Solve):
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE)
|
||||
self.signalAbort.add(self._process.terminate)
|
||||
output = self._observeSolver(self._process)
|
||||
# output = self._observeSolver(self._process)
|
||||
self._process.communicate()
|
||||
self.signalAbort.remove(self._process.terminate)
|
||||
|
||||
@@ -114,12 +114,12 @@ class Solve(run.Solve):
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE)
|
||||
self.signalAbort.add(self._process.terminate)
|
||||
output = self._observeSolver(self._process)
|
||||
# output = self._observeSolver(self._process)
|
||||
self._process.communicate()
|
||||
self.signalAbort.remove(self._process.terminate)
|
||||
# if not self.aborted:
|
||||
# self._updateOutput(output)
|
||||
del output # get flake8 quiet
|
||||
# del output # get flake8 quiet
|
||||
|
||||
|
||||
class Results(run.Results):
|
||||
|
||||
@@ -652,7 +652,6 @@ class FemToolsCcx(QtCore.QRunnable, QtCore.QObject):
|
||||
FreeCAD.Console.PrintMessage(
|
||||
"Dir given as parameter \'{}\' doesn't exist.\n".format(self.working_dir)
|
||||
)
|
||||
pass
|
||||
else:
|
||||
FreeCAD.Console.PrintError(
|
||||
"Dir given as parameter \'{}\' doesn't exist "
|
||||
@@ -891,7 +890,7 @@ class FemToolsCcx(QtCore.QRunnable, QtCore.QObject):
|
||||
ccx_stdout, ccx_stderr = p.communicate()
|
||||
if sys.version_info.major >= 3:
|
||||
ccx_stdout = ccx_stdout.decode()
|
||||
ccx_stderr = ccx_stderr.decode()
|
||||
# ccx_stderr = ccx_stderr.decode()
|
||||
m = re.search(r"(\d+).(\d+)", ccx_stdout)
|
||||
return (int(m.group(1)), int(m.group(2)))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user