FEM: solver frame work, some code formating for better readable code

This commit is contained in:
Bernd Hahnebach
2019-03-15 21:06:03 +01:00
committed by Yorik van Havre
parent 792293a193
commit 55d1f4b89e
5 changed files with 169 additions and 78 deletions

View File

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

View File

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

View File

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

View File

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

View File

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