FEM: solver z88, use single quotes instead of double ones
This commit is contained in:
@@ -140,14 +140,14 @@ class Results(run.Results):
|
||||
|
||||
def load_results_z88o2(self):
|
||||
disp_result_file = os.path.join(
|
||||
self.directory, 'z88o2.txt')
|
||||
self.directory, "z88o2.txt")
|
||||
if os.path.isfile(disp_result_file):
|
||||
result_name_prefix = 'Z88_' + self.solver.AnalysisType + '_'
|
||||
result_name_prefix = "Z88_" + self.solver.AnalysisType + "_"
|
||||
importZ88O2Results.import_z88_disp(
|
||||
disp_result_file, self.analysis, result_name_prefix)
|
||||
else:
|
||||
raise Exception(
|
||||
'FEM: No results found at {}!'.format(disp_result_file))
|
||||
"FEM: No results found at {}!".format(disp_result_file))
|
||||
|
||||
|
||||
class _Container(object):
|
||||
@@ -166,33 +166,33 @@ class _Container(object):
|
||||
"Missing prerequisite",
|
||||
message
|
||||
)
|
||||
raise Exception(message + '\n')
|
||||
raise Exception(message + "\n")
|
||||
|
||||
# get member, empty lists are not supported by z88
|
||||
# materials
|
||||
self.materials_linear = self.get_several_member(
|
||||
'Fem::Material'
|
||||
"Fem::Material"
|
||||
)
|
||||
self.materials_nonlinear = []
|
||||
|
||||
# geometries
|
||||
self.beam_sections = self.get_several_member(
|
||||
'Fem::FemElementGeometry1D'
|
||||
"Fem::FemElementGeometry1D"
|
||||
)
|
||||
self.beam_rotations = []
|
||||
self.fluid_sections = []
|
||||
self.shell_thicknesses = self.get_several_member(
|
||||
'Fem::FemElementGeometry2D'
|
||||
"Fem::FemElementGeometry2D"
|
||||
)
|
||||
|
||||
# constraints
|
||||
self.constraints_contact = []
|
||||
self.constraints_displacement = []
|
||||
self.constraints_fixed = self.get_several_member(
|
||||
'Fem::ConstraintFixed'
|
||||
"Fem::ConstraintFixed"
|
||||
)
|
||||
self.constraints_force = self.get_several_member(
|
||||
'Fem::ConstraintForce'
|
||||
"Fem::ConstraintForce"
|
||||
)
|
||||
self.constraints_heatflux = []
|
||||
self.constraints_initialtemperature = []
|
||||
|
||||
@@ -83,12 +83,12 @@ class FemInputWriterZ88(FemInputWriter.FemInputWriter):
|
||||
dir_name
|
||||
)
|
||||
from os.path import join
|
||||
self.file_name = join(self.dir_name, 'z88')
|
||||
self.file_name = join(self.dir_name, "z88")
|
||||
FreeCAD.Console.PrintLog(
|
||||
'FemInputWriterZ88 --> self.dir_name --> ' + self.dir_name + '\n'
|
||||
"FemInputWriterZ88 --> self.dir_name --> " + self.dir_name + "\n"
|
||||
)
|
||||
FreeCAD.Console.PrintMessage(
|
||||
'FemInputWriterZ88 --> self.file_name --> ' + self.file_name + '\n'
|
||||
"FemInputWriterZ88 --> self.file_name --> " + self.file_name + "\n"
|
||||
)
|
||||
|
||||
def write_z88_input(self):
|
||||
@@ -111,18 +111,18 @@ class FemInputWriterZ88(FemInputWriter.FemInputWriter):
|
||||
"Writing time input file: {} seconds"
|
||||
.format(round((time.clock() - timestart), 2))
|
||||
)
|
||||
FreeCAD.Console.PrintMessage(writing_time_string + ' \n\n')
|
||||
FreeCAD.Console.PrintMessage(writing_time_string + " \n\n")
|
||||
return self.dir_name
|
||||
|
||||
def set_z88_elparam(self):
|
||||
# TODO: param should be moved to the solver object like the known analysis
|
||||
z8804 = {'INTORD': '0', 'INTOS': '0', 'IHFLAG': '0', 'ISFLAG': '1'} # seg2 --> stab4
|
||||
z8824 = {'INTORD': '7', 'INTOS': '7', 'IHFLAG': '1', 'ISFLAG': '1'} # tria6 --> schale24
|
||||
z8823 = {'INTORD': '3', 'INTOS': '0', 'IHFLAG': '1', 'ISFLAG': '0'} # quad8 --> schale23
|
||||
z8817 = {'INTORD': '4', 'INTOS': '0', 'IHFLAG': '0', 'ISFLAG': '0'} # tetra4 --> volume17
|
||||
z8816 = {'INTORD': '4', 'INTOS': '0', 'IHFLAG': '0', 'ISFLAG': '0'} # tetra10 --> volume16
|
||||
z8801 = {'INTORD': '2', 'INTOS': '2', 'IHFLAG': '0', 'ISFLAG': '1'} # hexa8 --> volume1
|
||||
z8810 = {'INTORD': '3', 'INTOS': '0', 'IHFLAG': '0', 'ISFLAG': '0'} # hexa20 --> volume10
|
||||
z8804 = {"INTORD": "0", "INTOS": "0", "IHFLAG": "0", "ISFLAG": "1"} # seg2 --> stab4
|
||||
z8824 = {"INTORD": "7", "INTOS": "7", "IHFLAG": "1", "ISFLAG": "1"} # tria6 --> schale24
|
||||
z8823 = {"INTORD": "3", "INTOS": "0", "IHFLAG": "1", "ISFLAG": "0"} # quad8 --> schale23
|
||||
z8817 = {"INTORD": "4", "INTOS": "0", "IHFLAG": "0", "ISFLAG": "0"} # tetra4 --> volume17
|
||||
z8816 = {"INTORD": "4", "INTOS": "0", "IHFLAG": "0", "ISFLAG": "0"} # tetra10 --> volume16
|
||||
z8801 = {"INTORD": "2", "INTOS": "2", "IHFLAG": "0", "ISFLAG": "1"} # hexa8 --> volume1
|
||||
z8810 = {"INTORD": "3", "INTOS": "0", "IHFLAG": "0", "ISFLAG": "0"} # hexa20 --> volume10
|
||||
param = {4: z8804, 24: z8824, 23: z8823, 17: z8817, 16: z8816, 1: z8801, 10: z8810}
|
||||
# elemente 17, 16, 10, INTORD etc ... testen !!!
|
||||
self.z88_element_type = importZ88Mesh.get_z88_element_type(
|
||||
@@ -132,13 +132,13 @@ class FemInputWriterZ88(FemInputWriter.FemInputWriter):
|
||||
if self.z88_element_type in param:
|
||||
self.z88_elparam = param[self.z88_element_type]
|
||||
else:
|
||||
raise Exception('Element type not supported by Z88.')
|
||||
raise Exception("Element type not supported by Z88.")
|
||||
FreeCAD.Console.PrintMessage(self.z88_elparam)
|
||||
FreeCAD.Console.PrintMessage('\n')
|
||||
FreeCAD.Console.PrintMessage("\n")
|
||||
|
||||
def write_z88_mesh(self):
|
||||
mesh_file_path = self.file_name + 'i1.txt'
|
||||
f = open(mesh_file_path, 'w')
|
||||
mesh_file_path = self.file_name + "i1.txt"
|
||||
f = open(mesh_file_path, "w")
|
||||
importZ88Mesh.write_z88_mesh_to_file(
|
||||
self.femnodes_mesh,
|
||||
self.femelement_table,
|
||||
@@ -155,10 +155,10 @@ class FemInputWriterZ88(FemInputWriter.FemInputWriter):
|
||||
self.get_constraints_fixed_nodes()
|
||||
# write nodes to constraints_data (different from writing to file in ccxInpWriter
|
||||
for femobj in self.fixed_objects:
|
||||
for n in femobj['Nodes']:
|
||||
constraints_data.append((n, str(n) + ' 1 2 0\n'))
|
||||
constraints_data.append((n, str(n) + ' 2 2 0\n'))
|
||||
constraints_data.append((n, str(n) + ' 3 2 0\n'))
|
||||
for n in femobj["Nodes"]:
|
||||
constraints_data.append((n, str(n) + " 1 2 0\n"))
|
||||
constraints_data.append((n, str(n) + " 2 2 0\n"))
|
||||
constraints_data.append((n, str(n) + " 3 2 0\n"))
|
||||
|
||||
# forces constraints
|
||||
# check shape type of reference shape and get node loads
|
||||
@@ -166,69 +166,69 @@ class FemInputWriterZ88(FemInputWriter.FemInputWriter):
|
||||
# write node loads to constraints_data
|
||||
# a bit different from writing to file for ccxInpWriter
|
||||
for femobj in self.force_objects:
|
||||
# femobj --> dict, FreeCAD document object is femobj['Object']
|
||||
direction_vec = femobj['Object'].DirectionVector
|
||||
for ref_shape in femobj['NodeLoadTable']:
|
||||
# femobj --> dict, FreeCAD document object is femobj["Object"]
|
||||
direction_vec = femobj["Object"].DirectionVector
|
||||
for ref_shape in femobj["NodeLoadTable"]:
|
||||
for n in sorted(ref_shape[1]):
|
||||
node_load = ref_shape[1][n]
|
||||
if (direction_vec.x != 0.0):
|
||||
v1 = direction_vec.x * node_load
|
||||
constraints_data.append((n, str(n) + ' 1 1 ' + str(v1) + '\n'))
|
||||
constraints_data.append((n, str(n) + " 1 1 " + str(v1) + "\n"))
|
||||
if (direction_vec.y != 0.0):
|
||||
v2 = direction_vec.y * node_load
|
||||
constraints_data.append((n, str(n) + ' 2 1 ' + str(v2) + '\n'))
|
||||
constraints_data.append((n, str(n) + " 2 1 " + str(v2) + "\n"))
|
||||
if (direction_vec.z != 0.0):
|
||||
v3 = direction_vec.z * node_load
|
||||
constraints_data.append((n, str(n) + ' 3 1 ' + str(v3) + '\n'))
|
||||
constraints_data.append((n, str(n) + " 3 1 " + str(v3) + "\n"))
|
||||
|
||||
# write constraints_data to file
|
||||
contraints_file_path = self.file_name + 'i2.txt'
|
||||
f = open(contraints_file_path, 'w')
|
||||
f.write(str(len(constraints_data)) + '\n')
|
||||
contraints_file_path = self.file_name + "i2.txt"
|
||||
f = open(contraints_file_path, "w")
|
||||
f.write(str(len(constraints_data)) + "\n")
|
||||
for c in sorted(constraints_data):
|
||||
f.write(c[1])
|
||||
f.close()
|
||||
|
||||
def write_z88_face_loads(self):
|
||||
# not yet supported
|
||||
face_load_file_path = self.file_name + 'i5.txt'
|
||||
f = open(face_load_file_path, 'w')
|
||||
f.write(' 0')
|
||||
f.write('\n')
|
||||
face_load_file_path = self.file_name + "i5.txt"
|
||||
f = open(face_load_file_path, "w")
|
||||
f.write(" 0")
|
||||
f.write("\n")
|
||||
f.close()
|
||||
|
||||
def write_z88_materials(self):
|
||||
if len(self.material_objects) == 1:
|
||||
material_data_file_name = '51.txt'
|
||||
materials_file_path = self.file_name + 'mat.txt'
|
||||
fms = open(materials_file_path, 'w')
|
||||
fms.write('1\n')
|
||||
fms.write('1 ' + str(self.element_count) + ' ' + material_data_file_name)
|
||||
fms.write('\n')
|
||||
material_data_file_name = "51.txt"
|
||||
materials_file_path = self.file_name + "mat.txt"
|
||||
fms = open(materials_file_path, "w")
|
||||
fms.write("1\n")
|
||||
fms.write("1 " + str(self.element_count) + " " + material_data_file_name)
|
||||
fms.write("\n")
|
||||
fms.close()
|
||||
material_data_file_path = self.dir_name + '/' + material_data_file_name
|
||||
fmd = open(material_data_file_path, 'w')
|
||||
mat_obj = self.material_objects[0]['Object']
|
||||
YM = FreeCAD.Units.Quantity(mat_obj.Material['YoungsModulus'])
|
||||
YM_in_MPa = YM.getValueAs('MPa')
|
||||
PR = float(mat_obj.Material['PoissonRatio'])
|
||||
fmd.write('{0} {1:.3f}'.format(YM_in_MPa, PR))
|
||||
fmd.write('\n')
|
||||
material_data_file_path = self.dir_name + "/" + material_data_file_name
|
||||
fmd = open(material_data_file_path, "w")
|
||||
mat_obj = self.material_objects[0]["Object"]
|
||||
YM = FreeCAD.Units.Quantity(mat_obj.Material["YoungsModulus"])
|
||||
YM_in_MPa = YM.getValueAs("MPa")
|
||||
PR = float(mat_obj.Material["PoissonRatio"])
|
||||
fmd.write("{0} {1:.3f}".format(YM_in_MPa, PR))
|
||||
fmd.write("\n")
|
||||
fmd.close()
|
||||
else:
|
||||
FreeCAD.Console.PrintError("Multiple Materials for Z88 not yet supported!\n")
|
||||
|
||||
def write_z88_elements_properties(self):
|
||||
element_properties_file_path = self.file_name + 'elp.txt'
|
||||
element_properties_file_path = self.file_name + "elp.txt"
|
||||
elements_data = []
|
||||
if FemMeshTools.is_edge_femmesh(self.femmesh):
|
||||
if len(self.beamsection_objects) == 1:
|
||||
beam_obj = self.beamsection_objects[0]['Object']
|
||||
width = beam_obj.RectWidth.getValueAs('mm')
|
||||
height = beam_obj.RectHeight.getValueAs('mm')
|
||||
beam_obj = self.beamsection_objects[0]["Object"]
|
||||
width = beam_obj.RectWidth.getValueAs("mm")
|
||||
height = beam_obj.RectHeight.getValueAs("mm")
|
||||
area = str(width * height)
|
||||
elements_data.append(
|
||||
'1 ' + str(self.element_count) + ' ' + area + ' 0 0 0 0 0 0 '
|
||||
"1 " + str(self.element_count) + " " + area + " 0 0 0 0 0 0 "
|
||||
)
|
||||
FreeCAD.Console.PrintMessage(
|
||||
"Be aware, only trusses are supported for edge meshes!\n"
|
||||
@@ -237,51 +237,51 @@ class FemInputWriterZ88(FemInputWriter.FemInputWriter):
|
||||
FreeCAD.Console.PrintError("Multiple beamsections for Z88 not yet supported!\n")
|
||||
elif FemMeshTools.is_face_femmesh(self.femmesh):
|
||||
if len(self.shellthickness_objects) == 1:
|
||||
thick_obj = self.shellthickness_objects[0]['Object']
|
||||
thickness = str(thick_obj.Thickness.getValueAs('mm'))
|
||||
thick_obj = self.shellthickness_objects[0]["Object"]
|
||||
thickness = str(thick_obj.Thickness.getValueAs("mm"))
|
||||
elements_data.append(
|
||||
'1 ' + str(self.element_count) + ' ' + thickness + ' 0 0 0 0 0 0 '
|
||||
"1 " + str(self.element_count) + " " + thickness + " 0 0 0 0 0 0 "
|
||||
)
|
||||
else:
|
||||
FreeCAD.Console.PrintError(
|
||||
"Multiple thicknesses for Z88 not yet supported!\n"
|
||||
)
|
||||
elif FemMeshTools.is_solid_femmesh(self.femmesh):
|
||||
elements_data.append('1 ' + str(self.element_count) + ' 0 0 0 0 0 0 0')
|
||||
elements_data.append("1 " + str(self.element_count) + " 0 0 0 0 0 0 0")
|
||||
else:
|
||||
FreeCAD.Console.PrintError("Error!\n")
|
||||
f = open(element_properties_file_path, 'w')
|
||||
f.write(str(len(elements_data)) + '\n')
|
||||
f = open(element_properties_file_path, "w")
|
||||
f.write(str(len(elements_data)) + "\n")
|
||||
for e in elements_data:
|
||||
f.write(e)
|
||||
f.write('\n')
|
||||
f.write("\n")
|
||||
f.close()
|
||||
|
||||
def write_z88_integration_properties(self):
|
||||
integration_data = []
|
||||
integration_data.append('1 {} {} {}'.format(
|
||||
integration_data.append("1 {} {} {}".format(
|
||||
self.element_count,
|
||||
self.z88_elparam['INTORD'],
|
||||
self.z88_elparam['INTOS']
|
||||
self.z88_elparam["INTORD"],
|
||||
self.z88_elparam["INTOS"]
|
||||
))
|
||||
integration_properties_file_path = self.file_name + 'int.txt'
|
||||
f = open(integration_properties_file_path, 'w')
|
||||
f.write(str(len(integration_data)) + '\n')
|
||||
integration_properties_file_path = self.file_name + "int.txt"
|
||||
f = open(integration_properties_file_path, "w")
|
||||
f.write(str(len(integration_data)) + "\n")
|
||||
for i in integration_data:
|
||||
f.write(i)
|
||||
f.write('\n')
|
||||
f.write("\n")
|
||||
f.close()
|
||||
|
||||
def write_z88_solver_parameter(self):
|
||||
global z88_man_template
|
||||
z88_man_template = z88_man_template.replace(
|
||||
"$z88_param_ihflag", str(self.z88_elparam['IHFLAG'])
|
||||
"$z88_param_ihflag", str(self.z88_elparam["IHFLAG"])
|
||||
)
|
||||
z88_man_template = z88_man_template.replace(
|
||||
"$z88_param_isflag", str(self.z88_elparam['ISFLAG'])
|
||||
"$z88_param_isflag", str(self.z88_elparam["ISFLAG"])
|
||||
)
|
||||
solver_parameter_file_path = self.file_name + 'man.txt'
|
||||
f = open(solver_parameter_file_path, 'w')
|
||||
solver_parameter_file_path = self.file_name + "man.txt"
|
||||
f = open(solver_parameter_file_path, "w")
|
||||
f.write(z88_man_template)
|
||||
f.close()
|
||||
|
||||
@@ -293,14 +293,14 @@ class FemInputWriterZ88(FemInputWriter.FemInputWriter):
|
||||
"$z88_param_maxgs",
|
||||
str(self.z88_param_maxgs)
|
||||
)
|
||||
solver_parameter_file_path = self.file_name + '.dyn'
|
||||
f = open(solver_parameter_file_path, 'w')
|
||||
solver_parameter_file_path = self.file_name + ".dyn"
|
||||
f = open(solver_parameter_file_path, "w")
|
||||
f.write(z88_dyn_template)
|
||||
f.close()
|
||||
|
||||
|
||||
# for solver parameter file Z88man.txt
|
||||
z88_man_template = '''DYNAMIC START
|
||||
z88_man_template = """DYNAMIC START
|
||||
---------------------------------------------------------------------------
|
||||
Z88V14OS
|
||||
---------------------------------------------------------------------------
|
||||
@@ -336,10 +336,10 @@ STRESS START
|
||||
STRESS END
|
||||
|
||||
DYNAMIC END
|
||||
'''
|
||||
"""
|
||||
|
||||
# for memory parameter file z88.dyn
|
||||
z88_dyn_template = '''DYNAMIC START
|
||||
z88_dyn_template = """DYNAMIC START
|
||||
---------------------------------------------------------------------------
|
||||
Z88 new version 14OS Z88 neue Version 14OS
|
||||
---------------------------------------------------------------------------
|
||||
@@ -388,6 +388,6 @@ Entries for Cuthill-McKee Z88H Daten fuer Cuthill- McKee Programm
|
||||
|
||||
|
||||
DYNAMIC END
|
||||
'''
|
||||
"""
|
||||
|
||||
## @}
|
||||
|
||||
Reference in New Issue
Block a user