FEM: calculix writer, continue improve floating point writing for constraints

This commit is contained in:
Bernd Hahnebach
2021-07-14 07:48:54 +02:00
parent 3777067694
commit bbbb8760ab
19 changed files with 289 additions and 267 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -556,22 +556,22 @@ FemConstraintFixed,3
** FemConstraintPressure
*DLOAD
** FemConstraintPressure: face load
3,P1,1000.0
6,P3,1000.0
9,P2,1000.0
36,P1,1000.0
38,P1,1000.0
56,P1,1000.0
61,P3,1000.0
67,P2,1000.0
68,P3,1000.0
75,P2,1000.0
76,P4,1000.0
78,P4,1000.0
79,P2,1000.0
90,P3,1000.0
105,P3,1000.0
125,P3,1000.0
3,P1,1000
6,P3,1000
9,P2,1000
36,P1,1000
38,P1,1000
56,P1,1000
61,P3,1000
67,P2,1000
68,P3,1000
75,P2,1000
76,P4,1000
78,P4,1000
79,P2,1000
90,P3,1000
105,P3,1000
125,P3,1000
***********************************************************
** Outputs --> frd file

View File

@@ -3425,24 +3425,24 @@ SOF, SOM, SOAREA
** ConstraintPressure
*DLOAD
** ConstraintPressure: face load
846,P3,100.0
861,P1,100.0
875,P4,100.0
883,P3,100.0
887,P1,100.0
888,P1,100.0
903,P1,100.0
929,P4,100.0
933,P3,100.0
936,P1,100.0
937,P1,100.0
940,P1,100.0
941,P1,100.0
946,P4,100.0
949,P2,100.0
951,P4,100.0
954,P3,100.0
955,P4,100.0
846,P3,100
861,P1,100
875,P4,100
883,P3,100
887,P1,100
888,P1,100
903,P1,100
929,P4,100
933,P3,100
936,P1,100
937,P1,100
940,P1,100
941,P1,100
946,P4,100
949,P2,100
951,P4,100
954,P3,100
955,P4,100
***********************************************************
** Outputs --> frd file

View File

@@ -2171,7 +2171,7 @@ ConstraintFixed,3
** Self weight Constraint
** ConstraintSelfWeight
*DLOAD
Eall,GRAV,9806,0.0,0.0,-1.0
Eall,GRAV,9806,0,0,-1
***********************************************************

View File

@@ -18607,7 +18607,7 @@ Evolumes
***********************************************************
** Tie Constraints
** ConstraintTie
*TIE, POSITION TOLERANCE=25.0, ADJUST=NO, NAME=TIEConstraintTie
*TIE, POSITION TOLERANCE=25, ADJUST=NO, NAME=TIEConstraintTie
TIE_DEPConstraintTie,TIE_INDConstraintTie
***********************************************************

View File

@@ -3632,10 +3632,10 @@ Evolumes
** Transform Constraints
** FemConstraintTransform1
*TRANSFORM, NSET=CylinFemConstraintTransform1, TYPE=C
10.000000,27.000000,10.000000,10.000000,7.000000,10.000000
10,27,10,10,7,10
** FemConstraintTransform2
*TRANSFORM, NSET=CylinFemConstraintTransform2, TYPE=C
190.000000,27.000000,10.000000,190.000000,7.000000,10.000000
190,27,10,190,7,10
***********************************************************
** At least one step is needed to run an CalculiX analysis of FreeCAD
@@ -3655,124 +3655,124 @@ FemConstraintDisplacment,1
** FemConstraintPressure
*DLOAD
** FemConstraintPressure: face load
1384,P3,10.0
1394,P2,10.0
1397,P2,10.0
1399,P1,10.0
1400,P1,10.0
1402,P2,10.0
1404,P2,10.0
1415,P4,10.0
1418,P1,10.0
1419,P2,10.0
1423,P2,10.0
1428,P2,10.0
1429,P1,10.0
1432,P4,10.0
1433,P3,10.0
1437,P4,10.0
1438,P2,10.0
1441,P2,10.0
1442,P3,10.0
1443,P3,10.0
1448,P4,10.0
1451,P4,10.0
1455,P2,10.0
1457,P4,10.0
1458,P1,10.0
1461,P3,10.0
1466,P3,10.0
1467,P3,10.0
1475,P1,10.0
1476,P1,10.0
1484,P1,10.0
1500,P1,10.0
1501,P2,10.0
1503,P1,10.0
1504,P1,10.0
1507,P2,10.0
1508,P1,10.0
1548,P1,10.0
1549,P4,10.0
1550,P3,10.0
1552,P4,10.0
1554,P1,10.0
1555,P1,10.0
1571,P3,10.0
1579,P2,10.0
1580,P1,10.0
1581,P4,10.0
1589,P3,10.0
1590,P3,10.0
1661,P1,10.0
1663,P3,10.0
1675,P1,10.0
1676,P4,10.0
1685,P4,10.0
1686,P2,10.0
1687,P3,10.0
1707,P4,10.0
1713,P1,10.0
1718,P4,10.0
1719,P2,10.0
1721,P2,10.0
1728,P1,10.0
1730,P4,10.0
1733,P3,10.0
1737,P1,10.0
1740,P4,10.0
1742,P3,10.0
1743,P1,10.0
1744,P1,10.0
1747,P1,10.0
1750,P4,10.0
1751,P4,10.0
1759,P1,10.0
1760,P3,10.0
1761,P4,10.0
1762,P2,10.0
1767,P3,10.0
1770,P1,10.0
1771,P1,10.0
1776,P3,10.0
1785,P4,10.0
1786,P1,10.0
1804,P4,10.0
1818,P1,10.0
1820,P2,10.0
1823,P3,10.0
1824,P4,10.0
1832,P1,10.0
1833,P4,10.0
1838,P3,10.0
1848,P1,10.0
1849,P3,10.0
1850,P2,10.0
1851,P2,10.0
1852,P4,10.0
1860,P4,10.0
1861,P1,10.0
1864,P3,10.0
1874,P4,10.0
1881,P3,10.0
1892,P2,10.0
1893,P2,10.0
1900,P1,10.0
1901,P3,10.0
1902,P1,10.0
1903,P2,10.0
1907,P3,10.0
1909,P1,10.0
1918,P4,10.0
1919,P2,10.0
1922,P3,10.0
1928,P3,10.0
1934,P4,10.0
1935,P4,10.0
1943,P3,10.0
1976,P4,10.0
1982,P2,10.0
1984,P4,10.0
1384,P3,10
1394,P2,10
1397,P2,10
1399,P1,10
1400,P1,10
1402,P2,10
1404,P2,10
1415,P4,10
1418,P1,10
1419,P2,10
1423,P2,10
1428,P2,10
1429,P1,10
1432,P4,10
1433,P3,10
1437,P4,10
1438,P2,10
1441,P2,10
1442,P3,10
1443,P3,10
1448,P4,10
1451,P4,10
1455,P2,10
1457,P4,10
1458,P1,10
1461,P3,10
1466,P3,10
1467,P3,10
1475,P1,10
1476,P1,10
1484,P1,10
1500,P1,10
1501,P2,10
1503,P1,10
1504,P1,10
1507,P2,10
1508,P1,10
1548,P1,10
1549,P4,10
1550,P3,10
1552,P4,10
1554,P1,10
1555,P1,10
1571,P3,10
1579,P2,10
1580,P1,10
1581,P4,10
1589,P3,10
1590,P3,10
1661,P1,10
1663,P3,10
1675,P1,10
1676,P4,10
1685,P4,10
1686,P2,10
1687,P3,10
1707,P4,10
1713,P1,10
1718,P4,10
1719,P2,10
1721,P2,10
1728,P1,10
1730,P4,10
1733,P3,10
1737,P1,10
1740,P4,10
1742,P3,10
1743,P1,10
1744,P1,10
1747,P1,10
1750,P4,10
1751,P4,10
1759,P1,10
1760,P3,10
1761,P4,10
1762,P2,10
1767,P3,10
1770,P1,10
1771,P1,10
1776,P3,10
1785,P4,10
1786,P1,10
1804,P4,10
1818,P1,10
1820,P2,10
1823,P3,10
1824,P4,10
1832,P1,10
1833,P4,10
1838,P3,10
1848,P1,10
1849,P3,10
1850,P2,10
1851,P2,10
1852,P4,10
1860,P4,10
1861,P1,10
1864,P3,10
1874,P4,10
1881,P3,10
1892,P2,10
1893,P2,10
1900,P1,10
1901,P3,10
1902,P1,10
1903,P2,10
1907,P3,10
1909,P1,10
1918,P4,10
1919,P2,10
1922,P3,10
1928,P3,10
1934,P4,10
1935,P4,10
1943,P3,10
1976,P4,10
1982,P2,10
1984,P4,10
***********************************************************
** Outputs --> frd file

View File

@@ -10976,7 +10976,7 @@ Evolumes
** Transform Constraints
** ConstraintTransform
*TRANSFORM, NSET=CylinConstraintTransform, TYPE=C
0.000000,0.000000,-35.000000,0.000000,0.000000,-15.000000
0,0,-35,0,0,-15
***********************************************************
** At least one step is needed to run an CalculiX analysis of FreeCAD

View File

@@ -1249,22 +1249,22 @@ ConstraintFixed,3
** ConstraintPressure
*DLOAD
** ConstraintPressure: face load
61,P3,1000.0
74,P3,1000.0
75,P3,1000.0
80,P2,1000.0
96,P3,1000.0
99,P3,1000.0
100,P4,1000.0
102,P3,1000.0
117,P3,1000.0
118,P3,1000.0
121,P3,1000.0
124,P4,1000.0
127,P2,1000.0
131,P4,1000.0
132,P4,1000.0
134,P2,1000.0
61,P3,1000
74,P3,1000
75,P3,1000
80,P2,1000
96,P3,1000
99,P3,1000
100,P4,1000
102,P3,1000
117,P3,1000
118,P3,1000
121,P3,1000
124,P4,1000
127,P2,1000
131,P4,1000
132,P4,1000
134,P2,1000
***********************************************************
** Outputs --> frd file

View File

@@ -20022,86 +20022,86 @@ ConstraintFixed,3
** ConstraintPressure
*DLOAD
** ConstraintPressure: face load
4796,P3,-130.0
4799,P4,-130.0
4872,P4,-130.0
4875,P1,-130.0
5260,P3,-130.0
5261,P4,-130.0
5286,P3,-130.0
5287,P3,-130.0
5527,P1,-130.0
5528,P3,-130.0
5647,P1,-130.0
5648,P1,-130.0
5886,P1,-130.0
5887,P1,-130.0
5993,P1,-130.0
5994,P1,-130.0
6114,P1,-130.0
6115,P1,-130.0
6591,P3,-130.0
6592,P3,-130.0
6685,P3,-130.0
6686,P3,-130.0
6827,P4,-130.0
6828,P4,-130.0
7016,P4,-130.0
7017,P4,-130.0
7221,P1,-130.0
7222,P1,-130.0
7360,P3,-130.0
7361,P3,-130.0
7863,P3,-130.0
7864,P3,-130.0
8589,P1,-130.0
8590,P3,-130.0
9169,P4,-130.0
9170,P4,-130.0
10527,P4,-130.0
10530,P1,-130.0
10580,P4,-130.0
10583,P1,-130.0
10735,P3,-130.0
10736,P3,-130.0
10741,P4,-130.0
10742,P3,-130.0
10753,P1,-130.0
10759,P4,-130.0
10791,P4,-130.0
10793,P1,-130.0
10811,P4,-130.0
10831,P4,-130.0
10832,P1,-130.0
10845,P1,-130.0
10846,P1,-130.0
10862,P4,-130.0
10865,P1,-130.0
10868,P3,-130.0
10869,P1,-130.0
10870,P3,-130.0
10871,P3,-130.0
10881,P1,-130.0
10882,P4,-130.0
10885,P1,-130.0
10886,P1,-130.0
10902,P1,-130.0
10903,P1,-130.0
10926,P1,-130.0
10927,P1,-130.0
10930,P1,-130.0
10933,P4,-130.0
11005,P1,-130.0
11006,P1,-130.0
11009,P1,-130.0
11010,P4,-130.0
11018,P1,-130.0
11019,P1,-130.0
11054,P4,-130.0
11055,P4,-130.0
11114,P3,-130.0
11157,P1,-130.0
11158,P4,-130.0
4796,P3,-130
4799,P4,-130
4872,P4,-130
4875,P1,-130
5260,P3,-130
5261,P4,-130
5286,P3,-130
5287,P3,-130
5527,P1,-130
5528,P3,-130
5647,P1,-130
5648,P1,-130
5886,P1,-130
5887,P1,-130
5993,P1,-130
5994,P1,-130
6114,P1,-130
6115,P1,-130
6591,P3,-130
6592,P3,-130
6685,P3,-130
6686,P3,-130
6827,P4,-130
6828,P4,-130
7016,P4,-130
7017,P4,-130
7221,P1,-130
7222,P1,-130
7360,P3,-130
7361,P3,-130
7863,P3,-130
7864,P3,-130
8589,P1,-130
8590,P3,-130
9169,P4,-130
9170,P4,-130
10527,P4,-130
10530,P1,-130
10580,P4,-130
10583,P1,-130
10735,P3,-130
10736,P3,-130
10741,P4,-130
10742,P3,-130
10753,P1,-130
10759,P4,-130
10791,P4,-130
10793,P1,-130
10811,P4,-130
10831,P4,-130
10832,P1,-130
10845,P1,-130
10846,P1,-130
10862,P4,-130
10865,P1,-130
10868,P3,-130
10869,P1,-130
10870,P3,-130
10871,P3,-130
10881,P1,-130
10882,P4,-130
10885,P1,-130
10886,P1,-130
10902,P1,-130
10903,P1,-130
10926,P1,-130
10927,P1,-130
10930,P1,-130
10933,P4,-130
11005,P1,-130
11006,P1,-130
11009,P1,-130
11010,P4,-130
11018,P1,-130
11019,P1,-130
11054,P4,-130
11055,P4,-130
11114,P3,-130
11157,P1,-130
11158,P4,-130
***********************************************************
** Outputs --> frd file

View File

@@ -8231,7 +8231,7 @@ ConstraintFixed,3
** Fixed temperature constraint applied
** ConstraintTemperature
*BOUNDARY
ConstraintTemperature,11,11,373.0
ConstraintTemperature,11,11,373
***********************************************************

View File

@@ -129,7 +129,7 @@ Eedges
** Self weight Constraint
** ConstraintSelfWeight
*DLOAD
Eall,GRAV,9806,0.0,0.0,-1.0
Eall,GRAV,9806,0,0,-1
***********************************************************