From 55d1f4b89e29c716438b5c1d507727dfbe76f2c1 Mon Sep 17 00:00:00 2001 From: Bernd Hahnebach Date: Fri, 15 Mar 2019 21:06:03 +0100 Subject: [PATCH] FEM: solver frame work, some code formating for better readable code --- src/Mod/Fem/femsolver/calculix/tasks.py | 52 ++++++++++++-------- src/Mod/Fem/femsolver/calculix/writer.py | 54 +++++++++++++++------ src/Mod/Fem/femsolver/writerbase.py | 27 ++++++++--- src/Mod/Fem/femsolver/z88/tasks.py | 60 ++++++++++++++---------- src/Mod/Fem/femsolver/z88/writer.py | 54 +++++++++++++++------ 5 files changed, 169 insertions(+), 78 deletions(-) diff --git a/src/Mod/Fem/femsolver/calculix/tasks.py b/src/Mod/Fem/femsolver/calculix/tasks.py index 8dc26a6020..1d9e3f8f42 100644 --- a/src/Mod/Fem/femsolver/calculix/tasks.py +++ b/src/Mod/Fem/femsolver/calculix/tasks.py @@ -61,14 +61,26 @@ class Prepare(run.Prepare): self.pushStatus("Preparing input files...\n") c = _Container(self.analysis) w = writer.FemInputWriterCcx( - self.analysis, self.solver, c.mesh, c.materials_linear, - c.materials_nonlinear, c.fixed_constraints, - c.displacement_constraints, c.contact_constraints, - c.planerotation_constraints, c.transform_constraints, - c.selfweight_constraints, c.force_constraints, - c.pressure_constraints, c.temperature_constraints, - c.heatflux_constraints, c.initialtemperature_constraints, - c.beam_sections, c.beam_rotations, c.shell_thicknesses, c.fluid_sections, + self.analysis, + self.solver, + c.mesh, + c.materials_linear, + c.materials_nonlinear, + c.constraints_fixed, + c.constraints_displacement, + c.constraints_contact, + c.constraints_planerotation, + c.constraints_transform, + c.constraints_selfweight, + c.constraints_force, + c.constraints_pressure, + c.constraints_temperature, + c.constraints_heatflux, + c.constraints_initialtemperature, + c.beam_sections, + c.beam_rotations, + c.shell_thicknesses, + c.fluid_sections, self.directory) path = w.write_calculix_input_file() # report to user if task succeeded @@ -166,21 +178,23 @@ class _Container(object): # get member self.materials_linear = self.get_several_member('Fem::Material') self.materials_nonlinear = self.get_several_member('Fem::MaterialMechanicalNonlinear') - self.fixed_constraints = self.get_several_member('Fem::ConstraintFixed') - self.selfweight_constraints = self.get_several_member('Fem::ConstraintSelfWeight') - self.force_constraints = self.get_several_member('Fem::ConstraintForce') - self.pressure_constraints = self.get_several_member('Fem::ConstraintPressure') + self.beam_sections = self.get_several_member('Fem::FemElementGeometry1D') self.beam_rotations = self.get_several_member('Fem::FemElementRotation1D') self.fluid_sections = self.get_several_member('Fem::FemElementFluid1D') self.shell_thicknesses = self.get_several_member('Fem::FemElementGeometry2D') - self.displacement_constraints = self.get_several_member('Fem::ConstraintDisplacement') - self.temperature_constraints = self.get_several_member('Fem::ConstraintTemperature') - self.heatflux_constraints = self.get_several_member('Fem::ConstraintHeatflux') - self.initialtemperature_constraints = self.get_several_member('Fem::ConstraintInitialTemperature') - self.planerotation_constraints = self.get_several_member('Fem::ConstraintPlaneRotation') - self.contact_constraints = self.get_several_member('Fem::ConstraintContact') - self.transform_constraints = self.get_several_member('Fem::ConstraintTransform') + + self.constraints_contact = self.get_several_member('Fem::ConstraintContact') + self.constraints_displacement = self.get_several_member('Fem::ConstraintDisplacement') + self.constraints_fixed = self.get_several_member('Fem::ConstraintFixed') + self.constraints_force = self.get_several_member('Fem::ConstraintForce') + self.constraints_heatflux = self.get_several_member('Fem::ConstraintHeatflux') + self.constraints_initialtemperature = self.get_several_member('Fem::ConstraintInitialTemperature') + self.constraints_planerotation = self.get_several_member('Fem::ConstraintPlaneRotation') + self.constraints_pressure = self.get_several_member('Fem::ConstraintPressure') + self.constraints_selfweight = self.get_several_member('Fem::ConstraintSelfWeight') + self.constraints_temperature = self.get_several_member('Fem::ConstraintTemperature') + self.constraints_transform = self.get_several_member('Fem::ConstraintTransform') def get_several_member(self, t): return femutils.get_several_member(self.analysis, t) diff --git a/src/Mod/Fem/femsolver/calculix/writer.py b/src/Mod/Fem/femsolver/calculix/writer.py index e9d9e9bae6..a107bba381 100644 --- a/src/Mod/Fem/femsolver/calculix/writer.py +++ b/src/Mod/Fem/femsolver/calculix/writer.py @@ -39,25 +39,51 @@ import six class FemInputWriterCcx(FemInputWriter.FemInputWriter): def __init__(self, - analysis_obj, solver_obj, - mesh_obj, matlin_obj, matnonlin_obj, - fixed_obj, displacement_obj, - contact_obj, planerotation_obj, transform_obj, - selfweight_obj, force_obj, pressure_obj, - temperature_obj, heatflux_obj, initialtemperature_obj, - beamsection_obj, beamrotation_obj, shellthickness_obj, fluidsection_obj, + analysis_obj, + solver_obj, + mesh_obj, + matlin_obj, + matnonlin_obj, + fixed_obj, + displacement_obj, + contact_obj, + planerotation_obj, + transform_obj, + selfweight_obj, + force_obj, + pressure_obj, + temperature_obj, + heatflux_obj, + initialtemperature_obj, + beamsection_obj, + beamrotation_obj, + shellthickness_obj, + fluidsection_obj, dir_name=None ): FemInputWriter.FemInputWriter.__init__( self, - analysis_obj, solver_obj, - mesh_obj, matlin_obj, matnonlin_obj, - fixed_obj, displacement_obj, - contact_obj, planerotation_obj, transform_obj, - selfweight_obj, force_obj, pressure_obj, - temperature_obj, heatflux_obj, initialtemperature_obj, - beamsection_obj, beamrotation_obj, shellthickness_obj, fluidsection_obj, + analysis_obj, + solver_obj, + mesh_obj, + matlin_obj, + matnonlin_obj, + fixed_obj, + displacement_obj, + contact_obj, + planerotation_obj, + transform_obj, + selfweight_obj, + force_obj, + pressure_obj, + temperature_obj, + heatflux_obj, + initialtemperature_obj, + beamsection_obj, + beamrotation_obj, + shellthickness_obj, + fluidsection_obj, dir_name) # self.dir_name does have a slash at the end self.main_file_name = self.mesh_object.Name + '.inp' diff --git a/src/Mod/Fem/femsolver/writerbase.py b/src/Mod/Fem/femsolver/writerbase.py index 8fcb976a0b..4356b6002b 100644 --- a/src/Mod/Fem/femsolver/writerbase.py +++ b/src/Mod/Fem/femsolver/writerbase.py @@ -33,13 +33,26 @@ import os class FemInputWriter(): def __init__(self, - analysis_obj, solver_obj, - mesh_obj, matlin_obj, matnonlin_obj, - fixed_obj, displacement_obj, - contact_obj, planerotation_obj, transform_obj, - selfweight_obj, force_obj, pressure_obj, - temperature_obj, heatflux_obj, initialtemperature_obj, - beamsection_obj, beamrotation_obj, shellthickness_obj, fluidsection_obj, + analysis_obj, + solver_obj, + mesh_obj, + matlin_obj, + matnonlin_obj, + fixed_obj, + displacement_obj, + contact_obj, + planerotation_obj, + transform_obj, + selfweight_obj, + force_obj, + pressure_obj, + temperature_obj, + heatflux_obj, + initialtemperature_obj, + beamsection_obj, + beamrotation_obj, + shellthickness_obj, + fluidsection_obj, dir_name ): self.analysis = analysis_obj diff --git a/src/Mod/Fem/femsolver/z88/tasks.py b/src/Mod/Fem/femsolver/z88/tasks.py index d54825d978..8e7dfe7074 100644 --- a/src/Mod/Fem/femsolver/z88/tasks.py +++ b/src/Mod/Fem/femsolver/z88/tasks.py @@ -55,14 +55,26 @@ class Prepare(run.Prepare): self.pushStatus("Preparing input files...\n") c = _Container(self.analysis) w = writer.FemInputWriterZ88( - self.analysis, self.solver, c.mesh, c.materials_linear, - c.materials_nonlinear, c.fixed_constraints, - c.displacement_constraints, c.contact_constraints, - c.planerotation_constraints, c.transform_constraints, - c.selfweight_constraints, c.force_constraints, - c.pressure_constraints, c.temperature_constraints, - c.heatflux_constraints, c.initialtemperature_constraints, - c.beam_sections, c.beam_rotations, c.shell_thicknesses, c.fluid_sections, + self.analysis, + self.solver, + c.mesh, + c.materials_linear, + c.materials_nonlinear, + c.constraints_fixed, + c.constraints_displacement, + c.constraints_contact, + c.constraints_planerotation, + c.constraints_transform, + c.constraints_selfweight, + c.constraints_force, + c.constraints_pressure, + c.constraints_temperature, + c.constraints_heatflux, + c.constraints_initialtemperature, + c.beam_sections, + c.beam_rotations, + c.shell_thicknesses, + c.fluid_sections, self.directory) path = w.write_z88_input() # report to user if task succeeded @@ -149,26 +161,26 @@ class _Container(object): QtGui.QMessageBox.critical(None, "Missing prerequisite", message) raise Exception(message + '\n') - # get member + # get member, empty lists are not supported by z88 self.materials_linear = self.get_several_member('Fem::Material') - self.fixed_constraints = self.get_several_member('Fem::ConstraintFixed') - self.force_constraints = self.get_several_member('Fem::ConstraintForce') - self.beam_sections = self.get_several_member('Fem::FemElementGeometry1D') - self.shell_thicknesses = self.get_several_member('Fem::FemElementGeometry2D') - - # constraints not supported by z88 self.materials_nonlinear = [] - self.selfweight_constraints = [] - self.pressure_constraints = [] + + self.beam_sections = self.get_several_member('Fem::FemElementGeometry1D') self.beam_rotations = [] self.fluid_sections = [] - self.displacement_constraints = [] - self.temperature_constraints = [] - self.heatflux_constraints = [] - self.initialtemperature_constraints = [] - self.planerotation_constraints = [] - self.contact_constraints = [] - self.transform_constraints = [] + self.shell_thicknesses = self.get_several_member('Fem::FemElementGeometry2D') + + self.constraints_contact = [] + self.constraints_displacement = [] + self.constraints_fixed = self.get_several_member('Fem::ConstraintFixed') + self.constraints_force = self.get_several_member('Fem::ConstraintForce') + self.constraints_heatflux = [] + self.constraints_initialtemperature = [] + self.constraints_pressure = [] + self.constraints_planerotation = [] + self.constraints_selfweight = [] + self.constraints_temperature = [] + self.constraints_transform = [] def get_several_member(self, t): return femutils.get_several_member(self.analysis, t) diff --git a/src/Mod/Fem/femsolver/z88/writer.py b/src/Mod/Fem/femsolver/z88/writer.py index e141ab9f04..57e5ce68b7 100644 --- a/src/Mod/Fem/femsolver/z88/writer.py +++ b/src/Mod/Fem/femsolver/z88/writer.py @@ -35,25 +35,51 @@ from .. import writerbase as FemInputWriter class FemInputWriterZ88(FemInputWriter.FemInputWriter): def __init__(self, - analysis_obj, solver_obj, - mesh_obj, matlin_obj, matnonlin_obj, - fixed_obj, displacement_obj, - contact_obj, planerotation_obj, transform_obj, - selfweight_obj, force_obj, pressure_obj, - temperature_obj, heatflux_obj, initialtemperature_obj, - beamsection_obj, beamrotation_obj, shellthickness_obj, fluidsection_obj, + analysis_obj, + solver_obj, + mesh_obj, + matlin_obj, + matnonlin_obj, + fixed_obj, + displacement_obj, + contact_obj, + planerotation_obj, + transform_obj, + selfweight_obj, + force_obj, + pressure_obj, + temperature_obj, + heatflux_obj, + initialtemperature_obj, + beamsection_obj, + beamrotation_obj, + shellthickness_obj, + fluidsection_obj, dir_name=None ): FemInputWriter.FemInputWriter.__init__( self, - analysis_obj, solver_obj, - mesh_obj, matlin_obj, matnonlin_obj, - fixed_obj, displacement_obj, - contact_obj, planerotation_obj, transform_obj, - selfweight_obj, force_obj, pressure_obj, - temperature_obj, heatflux_obj, initialtemperature_obj, - beamsection_obj, beamrotation_obj, shellthickness_obj, fluidsection_obj, + analysis_obj, + solver_obj, + mesh_obj, + matlin_obj, + matnonlin_obj, + fixed_obj, + displacement_obj, + contact_obj, + planerotation_obj, + transform_obj, + selfweight_obj, + force_obj, + pressure_obj, + temperature_obj, + heatflux_obj, + initialtemperature_obj, + beamsection_obj, + beamrotation_obj, + shellthickness_obj, + fluidsection_obj, dir_name) # self.dir_name does have a slash at the end self.file_name = self.dir_name + 'z88'