Help on writing constraint into a text file

About the development of the FEM module/workbench.

Moderator: bernd

Post Reply
User avatar
johnwang
Veteran
Posts: 1382
Joined: Sun Jan 27, 2019 12:41 am

Help on writing constraint into a text file

Post by johnwang »

Hi,

I use this macro to output constraint into a text file.

Code: Select all

from femsolver.writerbase import FemInputWriter as TestWriter
f = open("d:\\bj\\myFile.txt","w")
TestWriter.get_constraints_force_nodeloads()
f.write("\n***********************************************************\n")
TestWriter.FemInputWriter.write_nodeloads_constraints_force(f)
f.close()
Still needs some setting to make it right.

Thanks for help.

Regards,

John
writeforce.jpg
writeforce.jpg (92.16 KiB) Viewed 683 times
Last edited by johnwang on Thu Jul 16, 2020 6:42 am, edited 1 time in total.
hfc series CAE workbenches for FreeCAD (hfcNastran95, hfcMystran, hfcFrame3DD, hfcSU2 and more)
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: Help on writing constraint into a text file

Post by bernd »

Code: Select all

doc = App.ActiveDocument
solv = doc.CalculiXccxTools
anal = doc.Analysis
mesh = doc.FEMMeshGmsh
from femtools.membertools import AnalysisMember
memb = AnalysisMember(doc.Analysis)

from femsolver.writerbase import FemInputWriter
iwb = FemInputWriter(anal, solv, mesh, memb)
iwb.force_objects[0]['Object'].Name  # test
iwb.get_constraints_force_nodeloads()
for k, v in iwb.force_objects[0].items():
    print("key: {} --> value: {}".format(k,v))

Code: Select all

>>> 
>>> doc = App.ActiveDocument
>>> solv = doc.CalculiXccxTools
>>> anal = doc.Analysis
>>> mesh = doc.FEMMeshGmsh
>>> from femtools.membertools import AnalysisMember
>>> memb = AnalysisMember(doc.Analysis)
>>> 
>>> from femsolver.writerbase import FemInputWriter
>>> iwb = FemInputWriter(anal, solv, mesh, memb)
>>> iwb.force_objects[0]['Object'].Name  # test
'ConstraintForce'
>>> iwb.get_constraints_force_nodeloads()
>>> for k, v in iwb.force_objects[0].items():
...     print("key: {} --> value: {}".format(k,v))
... 
key: Object --> value: <Fem::ConstraintForce object>
key: RefShapeType --> value: Face
key: NodeLoadTable --> value: [('node loads on shape: Box:Face3', {1: 0.0, 13: 0.0, 549: 0.0, 19: 0.0023766628109127544, 552: 0.004881927437277405, 553: 0.004758231445081548, 108: 0.0, 113: 0.002381568634168793, 554: 0.0048917390837894875, 9: 0.0, 2: 0.0, 551: 0.0, 14: 0.002382441903518558, 555: 0.004763201807109001, 556: 0.004898455984516514, 97: 0.0, 102: 0.002380759903590443, 557: 0.004895091984660284, 57: 0.0, 5: 0.0, 548: 0.0, 63: 0.0023824419035185953, 558: 0.004763201807109075, 559: 0.004898455984516566, 112: 0.0, 118: 0.0023807599035904794, 560: 0.004895091984660332, 6: 0.0, 53: 0.0, 550: 0.0, 58: 0.0023807599035904573, 561: 0.004895091984660306, 562: 0.0047632018071090375, 101: 0.0, 107: 0.00238244190351858, 563: 0.004898455984516547, 10: 0.0, 544: 0.0, 15: 0.0023578560003181277, 564: 0.004909176250977378, 565: 0.004724750267169003, 520: 0.0, 566: 0.005067334331657206, 567: 0.005111678767851248, 568: 0.0050303461620677965, 11: 0.0, 531: 0.0, 16: 0.0045312860168278835, 569: 0.006898180283678759, 570: 0.009821041205048689, 571: 0.004927252784042872, 12: 0.0, 534: 0.0, 17: 0.004330927638495629, 572: 0.009692495917690626, 573: 0.0065846456929068275, 518: 0.0, 574: 0.010651323467415803, 575: 0.00930103766399876, 576: 0.008714006619261479, 540: 0.0, 18: 0.0023019873131292557, 577: 0.004555705367540455, 578: 0.004828752355303306, 579: 0.004732213837867193, 522: 0.0, 580: 0.005032029668538701, 581: 0.005005260825630044, 582: 0.005015435075985345, 54: 0.0, 547: 0.0, 59: 0.0023214553477295353, 583: 0.004634590706162331, 584: 0.004885089995435444, 521: 0.0, 585: 0.0050779667287757565, 586: 0.005118949306115074, 587: 0.005030346162067815, 55: 0.0, 528: 0.0, 60: 0.004392411406185963, 588: 0.009452845300676511, 589: 0.0067055467646187595, 590: 0.004868450016841961, 56: 0.0, 532: 0.0, 61: 0.004463874123373899, 591: 0.006794824407190722, 592: 0.009569207305069122, 516: 0.0, 593: 0.010165767076185772, 594: 0.008450901344191694, 595: 0.009007918876345116, 542: 0.0, 62: 0.002341003026954653, 596: 0.004890085241306842, 597: 0.004671953310771475, 598: 0.004869979755031181, 523: 0.0, 599: 0.00506509629535016, 600: 0.005088111685566548, 601: 0.005030346162067823, 98: 0.0, 545: 0.0, 103: 0.0023214553477295284, 602: 0.004634590706162317, 603: 0.004885089995435424, 604: 0.0050779667287757365, 605: 0.005118949306115051, 99: 0.0, 530: 0.0, 104: 0.004392411406185949, 606: 0.009452845300676487, 607: 0.006705546764618738, 608: 0.004868450016841944, 100: 0.0, 535: 0.0, 105: 0.004502060793236109, 609: 0.00685385818494483, 610: 0.009596106604049283, 519: 0.0, 611: 0.010154479705303712, 612: 0.00846504475435555, 613: 0.009184896374464572, 541: 0.0, 106: 0.0023505496944202023, 614: 0.004901385681733184, 615: 0.0047023470861289225, 616: 0.004903881076310221, 617: 0.005066850068310949, 618: 0.005102919671914484, 109: 0.0, 546: 0.0, 114: 0.0023064189718456324, 619: 0.004843596051549392, 620: 0.004559789088195127, 621: 0.005047347529324454, 622: 0.00502130530391138, 110: 0.0, 529: 0.0, 115: 0.004329030980336995, 623: 0.00658240109668649, 624: 0.00951135120380368, 625: 0.004737498340557114, 111: 0.0, 533: 0.0, 116: 0.004392411406185941, 626: 0.00945284530067648, 627: 0.006705546764618742, 517: 0.0, 628: 0.010242754117957224, 629: 0.008484859261244584, 630: 0.008193933248280423, 543: 0.0, 117: 0.002321455347729549, 631: 0.004634590706162349, 632: 0.00488508999543547, 633: 0.004868450016841968, 634: 0.005077966728775775, 635: 0.005118949306115087, 524: 0.0, 511: 0.0, 537: 0.0, 636: 0.007233555145505263, 637: 0.0068253821090392425, 638: 0.006286432170319548, 539: 0.0, 639: 0.006642768474366766, 640: 0.008187761920669074, 525: 0.0, 538: 0.0, 641: 0.008687018265554668, 642: 0.006937115175964891, 643: 0.00803737233090472, 644: 0.007073145671431488, 526: 0.0, 536: 0.0, 645: 0.006714200098724519, 646: 0.006623069407406082, 647: 0.006242672372977808, 648: 0.006299002925612498, 527: 0.0, 649: 0.007038812258234665, 650: 0.006194864802530222, 651: 0.006819350576231632, 512: 0.0, 652: 0.007624699976441917, 653: 0.007453719370079744, 654: 0.006329682650995731, 655: 0.0063893614550697125, 656: 0.007173829348259607, 657: 0.006579946577280694, 658: 0.007565651884948263, 659: 0.006256662938581387, 660: 0.006473281905388948, 513: 0.0, 661: 0.007475639194788449, 662: 0.007118481518063796, 663: 0.006294965659716319, 664: 0.006143297542735744, 665: 0.006858897951390776, 666: 0.006019614826249949, 667: 0.006610183120332994, 668: 0.00590606693580588, 669: 0.006546534532177505, 514: 0.0, 670: 0.007604417280445829, 671: 0.0063893614550696925, 672: 0.007534263589955398, 673: 0.00755608199321926, 674: 0.006322454168386803, 675: 0.006766999384128035, 676: 0.007876562073085357, 677: 0.006681504667988948, 678: 0.007090684242996016, 515: 0.0, 679: 0.007586622714211858, 680: 0.006389361455069683, 681: 0.007531892265611472, 682: 0.007515051374239617, 683: 0.006312934434743328, 684: 0.006730755899618525, 685: 0.007773757932466241, 686: 0.006666125911881184, 687: 0.007102456328815957, 688: 0.006681350806848619, 689: 0.006169232561899872, 690: 0.005913810875924753, 691: 0.005744771191936741, 692: 0.007018405153374904, 693: 0.0063595610176634286, 694: 0.006937037888823109, 695: 0.006250798185036722})]
>>> 
>>> 
User avatar
johnwang
Veteran
Posts: 1382
Joined: Sun Jan 27, 2019 12:41 am

Re: Help on writing constraint into a text file

Post by johnwang »

Cool.

Reduced the mesh number. 4 triangle elements on the face. 12 nodes total. Why there are 13 values? And the 1N force is distributed on the Face.
writeforce2.jpg
writeforce2.jpg (19.37 KiB) Viewed 670 times
writeforce1.jpg
writeforce1.jpg (118.29 KiB) Viewed 670 times
TestWriteforce.FCStd
(8.75 KiB) Downloaded 28 times
hfc series CAE workbenches for FreeCAD (hfcNastran95, hfcMystran, hfcFrame3DD, hfcSU2 and more)
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: Help on writing constraint into a text file

Post by bernd »

force constraint used DLOD which are node loads. Since you probably have a second order mesh there are nodes in between. You can show the nodes.

https://github.com/FreeCAD/FreeCAD/blob ... s.py#L1251


If you would like to have a element face node you should use constraint pressure.
User avatar
johnwang
Veteran
Posts: 1382
Joined: Sun Jan 27, 2019 12:41 am

Re: Help on writing constraint into a text file

Post by johnwang »

bernd wrote: Thu Jul 16, 2020 10:23 am force constraint used DLOD which are node loads. Since you probably have a second order mesh there are nodes in between. You can show the nodes.
I remember the default of meshing with gmsh is set at using second order, so 13 nodes is perfect.

Just a suggestion, maybe name the result mesh as FEMMeshGmshHi if meshed with second order.

Thank you very much.
hfc series CAE workbenches for FreeCAD (hfcNastran95, hfcMystran, hfcFrame3DD, hfcSU2 and more)
Post Reply