FEM: calculix writer, improve floating point writing
This commit is contained in:
@@ -72,6 +72,8 @@ def write_meshdata_constraint(f, femobj, centrif_obj, ccxwriter):
|
||||
|
||||
def write_constraint(f, femobj, centrif_obj, ccxwriter):
|
||||
|
||||
# floats read from ccx should use {:.13G}, see comment in writer module
|
||||
|
||||
# get some data from the centrif_obj
|
||||
refobj = centrif_obj.RotationAxis[0][0]
|
||||
subobj = centrif_obj.RotationAxis[0][1][0]
|
||||
@@ -90,10 +92,6 @@ def write_constraint(f, femobj, centrif_obj, ccxwriter):
|
||||
|
||||
# write to file
|
||||
f.write("*DLOAD\n")
|
||||
# Why {:.13G} ...
|
||||
# ccx uses F20.0 FORTRAN input fields, see in dload.f in ccx's source
|
||||
# https://forum.freecadweb.org/viewtopic.php?f=18&t=22759&#p176578
|
||||
# example "{:.13G}".format(math.sqrt(2.)*-1e100) and count chars
|
||||
f.write(
|
||||
"{},CENTRIF,{:.13G},{:.13G},{:.13G},{:.13G},{:.13G},{:.13G},{:.13G}\n"
|
||||
.format(
|
||||
|
||||
@@ -66,6 +66,9 @@ def write_meshdata_constraint(f, femobj, contact_obj, ccxwriter):
|
||||
|
||||
|
||||
def write_constraint(f, femobj, contact_obj, ccxwriter):
|
||||
|
||||
# floats read from ccx should use {:.13G}, see comment in writer module
|
||||
|
||||
f.write(
|
||||
"*CONTACT PAIR, INTERACTION=INT{},TYPE=SURFACE TO SURFACE\n"
|
||||
.format(contact_obj.Name)
|
||||
@@ -76,9 +79,9 @@ def write_constraint(f, femobj, contact_obj, ccxwriter):
|
||||
f.write("*SURFACE INTERACTION, NAME=INT{}\n".format(contact_obj.Name))
|
||||
f.write("*SURFACE BEHAVIOR,PRESSURE-OVERCLOSURE=LINEAR\n")
|
||||
slope = contact_obj.Slope
|
||||
f.write("{} \n".format(slope))
|
||||
f.write("{:.13G}\n".format(slope))
|
||||
friction = contact_obj.Friction
|
||||
if friction > 0:
|
||||
f.write("*FRICTION \n")
|
||||
stick = (slope / 10.0)
|
||||
f.write("{}, {} \n".format(friction, stick))
|
||||
f.write("{:.13G}, {:.13G}\n".format(friction, stick))
|
||||
|
||||
@@ -61,30 +61,33 @@ def write_meshdata_constraint(f, femobj, disp_obj, ccxwriter):
|
||||
|
||||
|
||||
def write_constraint(f, femobj, disp_obj, ccxwriter):
|
||||
|
||||
# floats read from ccx should use {:.13G}, see comment in writer module
|
||||
|
||||
f.write("*BOUNDARY\n")
|
||||
if disp_obj.xFix:
|
||||
f.write("{},1\n".format(disp_obj.Name))
|
||||
elif not disp_obj.xFree:
|
||||
f.write("{},1,1,{}\n".format(disp_obj.Name, disp_obj.xDisplacement))
|
||||
f.write("{},1,1,{:.13G}\n".format(disp_obj.Name, disp_obj.xDisplacement))
|
||||
if disp_obj.yFix:
|
||||
f.write("{},2\n".format(disp_obj.Name))
|
||||
elif not disp_obj.yFree:
|
||||
f.write("{},2,2,{}\n".format(disp_obj.Name, disp_obj.yDisplacement))
|
||||
f.write("{},2,2,{:.13G}\n".format(disp_obj.Name, disp_obj.yDisplacement))
|
||||
if disp_obj.zFix:
|
||||
f.write("{},3\n".format(disp_obj.Name))
|
||||
elif not disp_obj.zFree:
|
||||
f.write("{},3,3,{}\n".format(disp_obj.Name, disp_obj.zDisplacement))
|
||||
f.write("{},3,3,{:.13G}\n".format(disp_obj.Name, disp_obj.zDisplacement))
|
||||
|
||||
if ccxwriter.beamsection_objects or ccxwriter.shellthickness_objects:
|
||||
if disp_obj.rotxFix:
|
||||
f.write("{},4\n".format(disp_obj.Name))
|
||||
elif not disp_obj.rotxFree:
|
||||
f.write("{},4,4,{}\n".format(disp_obj.Name, disp_obj.xRotation))
|
||||
f.write("{},4,4,{:.13G}\n".format(disp_obj.Name, disp_obj.xRotation))
|
||||
if disp_obj.rotyFix:
|
||||
f.write("{},5\n".format(disp_obj.Name))
|
||||
elif not disp_obj.rotyFree:
|
||||
f.write("{},5,5,{}\n".format(disp_obj.Name, disp_obj.yRotation))
|
||||
f.write("{},5,5,{:.13G}\n".format(disp_obj.Name, disp_obj.yRotation))
|
||||
if disp_obj.rotzFix:
|
||||
f.write("{},6\n".format(disp_obj.Name))
|
||||
elif not disp_obj.rotzFree:
|
||||
f.write("{},6,6,{}\n".format(disp_obj.Name, disp_obj.zRotation))
|
||||
f.write("{},6,6,{:.13G}\n".format(disp_obj.Name, disp_obj.zRotation))
|
||||
|
||||
@@ -74,6 +74,9 @@ def write_meshdata_constraint(f, femobj, fix_obj, ccxwriter):
|
||||
|
||||
|
||||
def write_constraint(f, femobj, fix_obj, ccxwriter):
|
||||
|
||||
# floats read from ccx should use {:.13G}, see comment in writer module
|
||||
|
||||
if (
|
||||
ccxwriter.femmesh.Volumes
|
||||
and (len(ccxwriter.shellthickness_objects) > 0 or len(ccxwriter.beamsection_objects) > 0)
|
||||
|
||||
@@ -43,6 +43,9 @@ def get_after_write_meshdata_constraint():
|
||||
|
||||
|
||||
def write_meshdata_constraint(f, femobj, force_obj, ccxwriter):
|
||||
|
||||
# floats read from ccx should use {:.13G}, see comment in writer module
|
||||
|
||||
direction_vec = femobj["Object"].DirectionVector
|
||||
for ref_shape in femobj["NodeLoadTable"]:
|
||||
f.write("** " + ref_shape[0] + "\n")
|
||||
|
||||
@@ -43,18 +43,21 @@ def get_after_write_meshdata_constraint():
|
||||
|
||||
|
||||
def write_meshdata_constraint(f, femobj, heatflux_obj, ccxwriter):
|
||||
|
||||
# floats read from ccx should use {:.13G}, see comment in writer module
|
||||
|
||||
if heatflux_obj.ConstraintType == "Convection":
|
||||
heatflux_key_word = "FILM"
|
||||
heatflux_facetype = "F"
|
||||
# SvdW: add factor to force heatflux to units system of t/mm/s/K
|
||||
heatflux_values = "{},{}".format(
|
||||
heatflux_values = "{:.13G},{:.13G}".format(
|
||||
heatflux_obj.AmbientTemp,
|
||||
heatflux_obj.FilmCoef * 0.001
|
||||
)
|
||||
elif heatflux_obj.ConstraintType == "DFlux":
|
||||
heatflux_key_word = "DFLUX"
|
||||
heatflux_facetype = "S"
|
||||
heatflux_values = "{}".format(heatflux_obj.DFlux * 0.001)
|
||||
heatflux_values = "{:.13G}".format(heatflux_obj.DFlux * 0.001)
|
||||
|
||||
f.write("*{}\n".format(heatflux_key_word))
|
||||
for ref_shape in femobj["HeatFluxFaceTable"]:
|
||||
|
||||
@@ -44,7 +44,10 @@ def get_after_write_constraint():
|
||||
|
||||
def write_constraint(f, femobj, inittemp_obj, ccxwriter):
|
||||
|
||||
f.write("{0},{1}\n".format(ccxwriter.ccx_nall, inittemp_obj.initialTemperature))
|
||||
# floats read from ccx should use {:.13G}, see comment in writer module
|
||||
|
||||
|
||||
f.write("{},{:.13G}\n".format(ccxwriter.ccx_nall, inittemp_obj.initialTemperature))
|
||||
|
||||
|
||||
# Should only be one object in the analysis
|
||||
|
||||
@@ -92,6 +92,17 @@ units_information = """*********************************************************
|
||||
"""
|
||||
|
||||
|
||||
# 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
|
||||
# https://forum.freecadweb.org/viewtopic.php?f=18&p=516518#p516433
|
||||
# https://forum.freecadweb.org/viewtopic.php?f=18&t=22759&#p176578
|
||||
# example "{:.13G}".format(math.sqrt(2.)*-1e100) and count chars
|
||||
# a property type is best checked in FreeCAD objects definition
|
||||
# see femobjects package for Python objects or in objects App
|
||||
|
||||
|
||||
class FemInputWriterCcx(writerbase.FemInputWriter):
|
||||
def __init__(
|
||||
self,
|
||||
|
||||
@@ -394,7 +394,7 @@ ConstraintFixed,3
|
||||
** Displacement constraint applied
|
||||
** ConstraintDisplacmentPrescribed
|
||||
*BOUNDARY
|
||||
ConstraintDisplacmentPrescribed,3,3,-250.0
|
||||
ConstraintDisplacmentPrescribed,3,3,-250
|
||||
|
||||
|
||||
***********************************************************
|
||||
|
||||
@@ -38369,7 +38369,7 @@ Efaces
|
||||
DEPConstraintContact,INDConstraintContact
|
||||
*SURFACE INTERACTION, NAME=INTConstraintContact
|
||||
*SURFACE BEHAVIOR,PRESSURE-OVERCLOSURE=LINEAR
|
||||
1000000.0
|
||||
1000000
|
||||
|
||||
***********************************************************
|
||||
** At least one step is needed to run an CalculiX analysis of FreeCAD
|
||||
|
||||
@@ -8205,7 +8205,7 @@ Evolumes
|
||||
** Initial temperature constraint
|
||||
*INITIAL CONDITIONS,TYPE=TEMPERATURE
|
||||
** ConstraintInitialTemperature
|
||||
Nall,273.0
|
||||
Nall,273
|
||||
|
||||
***********************************************************
|
||||
** Sections
|
||||
|
||||
@@ -125,7 +125,7 @@ Evolumes
|
||||
** Initial temperature constraint
|
||||
*INITIAL CONDITIONS,TYPE=TEMPERATURE
|
||||
** FemConstraintInitialTemperature
|
||||
Nall,300.0
|
||||
Nall,300
|
||||
|
||||
***********************************************************
|
||||
** Sections
|
||||
|
||||
Reference in New Issue
Block a user