FEM: calculix writer, continue improve floating point writing for constraints
This commit is contained in:
@@ -46,7 +46,6 @@ def write_constraint(f, femobj, inittemp_obj, ccxwriter):
|
||||
|
||||
# floats read from ccx should use {:.13G}, see comment in writer module
|
||||
|
||||
|
||||
f.write("{},{:.13G}\n".format(ccxwriter.ccx_nall, inittemp_obj.initialTemperature))
|
||||
|
||||
|
||||
|
||||
@@ -97,5 +97,8 @@ def write_meshdata_constraint(f, femobj, fric_obj, ccxwriter):
|
||||
|
||||
|
||||
def write_constraint(f, femobj, fric_obj, ccxwriter):
|
||||
|
||||
# floats read from ccx should use {:.13G}, see comment in writer module
|
||||
|
||||
f.write("*MPC\n")
|
||||
f.write("PLANE,{}\n".format(fric_obj.Name))
|
||||
|
||||
@@ -43,7 +43,12 @@ def get_after_write_meshdata_constraint():
|
||||
|
||||
|
||||
def write_meshdata_constraint(f, femobj, prs_obj, ccxwriter):
|
||||
|
||||
# floats read from ccx should use {:.13G}, see comment in writer module
|
||||
|
||||
rev = -1 if prs_obj.Reversed else 1
|
||||
press_rev = rev * prs_obj.Pressure
|
||||
|
||||
f.write("*DLOAD\n")
|
||||
for ref_shape in femobj["PressureFaces"]:
|
||||
# the loop is needed for compatibility reason
|
||||
@@ -52,12 +57,12 @@ def write_meshdata_constraint(f, femobj, prs_obj, ccxwriter):
|
||||
f.write("** " + ref_shape[0] + "\n")
|
||||
for face, fno in ref_shape[1]:
|
||||
if fno > 0: # solid mesh face
|
||||
f.write("{},P{},{}\n".format(face, fno, rev * prs_obj.Pressure))
|
||||
f.write("{},P{},{:.13G}\n".format(face, fno, press_rev))
|
||||
# on shell mesh face: fno == 0
|
||||
# normal of element face == face normal
|
||||
elif fno == 0:
|
||||
f.write("{},P,{}\n".format(face, rev * prs_obj.Pressure))
|
||||
f.write("{},P,{:.13G}\n".format(face, press_rev))
|
||||
# on shell mesh face: fno == -1
|
||||
# normal of element face opposite direction face normal
|
||||
elif fno == -1:
|
||||
f.write("{},P,{}\n".format(face, -1 * rev * prs_obj.Pressure))
|
||||
f.write("{},P,{:.13G}\n".format(face, -1 * press_rev))
|
||||
|
||||
@@ -61,6 +61,9 @@ def write_meshdata_constraint(f, femobj, sectionprint_obj, ccxwriter):
|
||||
|
||||
|
||||
def write_constraint(f, femobj, sectionprint_obj, ccxwriter):
|
||||
|
||||
# floats read from ccx should use {:.13G}, see comment in writer module
|
||||
|
||||
f.write(
|
||||
"*SECTION PRINT, SURFACE=SECTIONFACE{}, NAME=SECTIONPRINT{}\n"
|
||||
.format(sectionprint_obj.Name, sectionprint_obj.Name)
|
||||
|
||||
@@ -44,10 +44,12 @@ def get_after_write_constraint():
|
||||
|
||||
def write_constraint(f, femobj, selwei_obj, ccxwriter):
|
||||
|
||||
# floats read from ccx should use {:.13G}, see comment in writer module
|
||||
|
||||
f.write("*DLOAD\n")
|
||||
f.write(
|
||||
# elset, GRAV, magnitude, direction x, dir y ,dir z
|
||||
"{},GRAV,{},{},{},{}\n"
|
||||
"{},GRAV,{:.13G},{:.13G},{:.13G},{:.13G}\n"
|
||||
.format(
|
||||
ccxwriter.ccx_eall,
|
||||
ccxwriter.gravity, # actual magnitude of gravity vector
|
||||
|
||||
@@ -61,14 +61,17 @@ def get_after_write_constraint():
|
||||
|
||||
|
||||
def write_constraint(f, femobj, temp_obj, ccxwriter):
|
||||
|
||||
# floats read from ccx should use {:.13G}, see comment in writer module
|
||||
|
||||
NumberOfNodes = len(femobj["Nodes"])
|
||||
if temp_obj.ConstraintType == "Temperature":
|
||||
f.write("*BOUNDARY\n")
|
||||
f.write("{},11,11,{}\n".format(temp_obj.Name, temp_obj.Temperature))
|
||||
f.write("{},11,11,{:.13G}\n".format(temp_obj.Name, temp_obj.Temperature))
|
||||
f.write("\n")
|
||||
elif temp_obj.ConstraintType == "CFlux":
|
||||
f.write("*CFLUX\n")
|
||||
f.write("{},11,{}\n".format(
|
||||
f.write("{},11,{:.13G}\n".format(
|
||||
temp_obj.Name,
|
||||
temp_obj.CFlux * 0.001 / NumberOfNodes
|
||||
))
|
||||
|
||||
@@ -66,9 +66,12 @@ def write_meshdata_constraint(f, femobj, tie_obj, ccxwriter):
|
||||
|
||||
|
||||
def write_constraint(f, femobj, tie_obj, ccxwriter):
|
||||
tolerance = str(tie_obj.Tolerance.getValueAs("mm")).rstrip()
|
||||
|
||||
# floats read from ccx should use {:.13G}, see comment in writer module
|
||||
|
||||
tolerance = tie_obj.Tolerance.getValueAs("mm").Value
|
||||
f.write(
|
||||
"*TIE, POSITION TOLERANCE={}, ADJUST=NO, NAME=TIE{}\n"
|
||||
"*TIE, POSITION TOLERANCE={:.13G}, ADJUST=NO, NAME=TIE{}\n"
|
||||
.format(tolerance, tie_obj.Name)
|
||||
)
|
||||
ind_surf = "TIE_IND{}".format(tie_obj.Name)
|
||||
|
||||
@@ -67,6 +67,9 @@ def write_meshdata_constraint(f, femobj, trans_obj, ccxwriter):
|
||||
|
||||
|
||||
def write_constraint(f, femobj, trans_obj, ccxwriter):
|
||||
|
||||
# floats read from ccx should use {:.13G}, see comment in writer module
|
||||
|
||||
trans_name = ""
|
||||
trans_type = ""
|
||||
if trans_obj.TransformType == "Rectangular":
|
||||
@@ -82,7 +85,7 @@ def write_constraint(f, femobj, trans_obj, ccxwriter):
|
||||
trans_obj.Name,
|
||||
trans_type,
|
||||
))
|
||||
f.write("{:f},{:f},{:f},{:f},{:f},{:f}\n".format(
|
||||
f.write("{:.13G},{:.13G},{:.13G},{:.13G},{:.13G},{:.13G}\n".format(
|
||||
coords[0],
|
||||
coords[1],
|
||||
coords[2],
|
||||
|
||||
@@ -92,7 +92,7 @@ units_information = """*********************************************************
|
||||
"""
|
||||
|
||||
|
||||
# TODO
|
||||
# TODO
|
||||
# {0:.13G} or {:.13G} should be used on all places writing floating points to ccx
|
||||
# All floating points fields read from ccx are F20.0 FORTRAN input fields.
|
||||
# see in dload.f in ccx's source
|
||||
@@ -208,6 +208,7 @@ class FemInputWriterCcx(writerbase.FemInputWriter):
|
||||
|
||||
setstime = round((time_getsets - time_start), 3)
|
||||
writetime = round((time.process_time() - time_getsets), 3)
|
||||
all_time = round((setstime + writetime), 3)
|
||||
FreeCAD.Console.PrintMessage(
|
||||
"Getting mesh sets or groups time: {} seconds \n".format(setstime)
|
||||
)
|
||||
@@ -216,7 +217,7 @@ class FemInputWriterCcx(writerbase.FemInputWriter):
|
||||
)
|
||||
FreeCAD.Console.PrintMessage(
|
||||
"Overall time CalculiX input file: {} seconds \n\n"
|
||||
.format(setstime + writetime)
|
||||
.format(all_time)
|
||||
)
|
||||
|
||||
# return
|
||||
|
||||
Reference in New Issue
Block a user