Feature Request/Inquiry: MPC and RBE elements

About the development of the FEM module/workbench.

Moderator: bernd

fandaL
Posts: 440
Joined: Thu Jul 24, 2014 8:29 am

Re: Feature Request/Inquiry: MPC and RBE elements

Post by fandaL »

aerospaceweeb wrote: Sun Sep 12, 2021 12:39 am Is there a way to make a list of nodes in the FEM module, if that mesh entity isn't a gmsh created entity?
@bernd will know that. E.g., constraint fixed applied on the geometry will find nodes even if the mesh was imported, provided that node positions correspond to the geometry.
aerospaceweeb
Posts: 118
Joined: Fri Apr 09, 2021 3:26 am

Re: Feature Request/Inquiry: MPC and RBE elements

Post by aerospaceweeb »

@fandaL is there a way to make non-gmsh entities be "associated" to the geometry?

I've got bespoke meshing tools that play ball with a relatively massive pile of subroutines (pynastran stuff, but that's more eventually than now), but everything I'm using them to do is just creating FemMesh entities directly.

It feels like there's almost nothing here that's designed to play well with orphan meshes, which will be a problem for me personally going forward, as I very frequently run into cases where geometry is lost years ago, and all that's left of analysis are coarse meshes in bdf files.
heda
Veteran
Posts: 1348
Joined: Sat Dec 12, 2015 5:49 pm

Re: Feature Request/Inquiry: MPC and RBE elements

Post by heda »

don't really see the hurdle here, if you have a mesh, making a geometry out of that is not prohibitively hard - you have all the faces as points, so it is just an extra loop to make fc geometry out of it - and then you have the gui to hook bc's on the geometry.

for that reason I put in the "automatic" geometry creation in the fcmesher, it was only a couple of lines of code.

fc allows you to export a geometry and mesh that geometry completely outside of fc, import that mesh back into fc and it works the same with bc's as if the meshing was done through the fc gui, so no issues with hooking up geometry and mesh regardless of where/how the meshing is done afaik.
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: Feature Request/Inquiry: MPC and RBE elements

Post by bernd »

fandaL wrote: Sun Sep 12, 2021 6:51 pm
aerospaceweeb wrote: Sun Sep 12, 2021 12:39 am Is there a way to make a list of nodes in the FEM module, if that mesh entity isn't a gmsh created entity?
@bernd will know that. E.g., constraint fixed applied on the geometry will find nodes even if the mesh was imported, provided that node positions correspond to the geometry.
I do not really understand the question. Nothing in FEM dependends on gmsh, accept gmdh itself.

If you would like a mesh group, create one wirh python. The methods sre there.

Not sets can be defined with the node set tool as fandaL wrote. AFAIK a mesh group is not created. But at the moment you can not use them neither in calculix nor in mystran.

If you select the nodes directly in the mesh just create a real mesh group and access this group on solver writing. Can all be done in Python.

Make sure you know the difference between the gmsh gui mesh group which creates a mesh with mesh groups. But these mesh groups could be created by python without a meshing process.
aerospaceweeb
Posts: 118
Joined: Fri Apr 09, 2021 3:26 am

Re: Feature Request/Inquiry: MPC and RBE elements

Post by aerospaceweeb »

@Fandal

This works wonderfully.

Here's a demo problem where I made a bush spider rather than an RBE3.
MPC_Test.FCStd
(37.5 KiB) Downloaded 37 times
Here's a youtube link of how I made it
https://youtu.be/83tRnUEJEE8

and here's the python script that I ran after clicking on the node set that made it

Code: Select all

# App = FreeCAD, Gui = FreeCADGui
import FreeCAD, Part, Fem
Vector = App.Vector

def main(): # {{{

    # get nodelist that's clicked on
    node_set_entities = [] 
    for obj in Gui.Selection.getSelectionEx():
        if obj.TypeName == "Fem::FemSetNodesObject":
            node_set_entities.append(obj)

    if len(node_set_entities) > 1:
        raise ValueError("Too many node sets selected.")
    elif len(node_set_entities) == 0:
        raise ValueError("No node sets selected")

    # need to get the label of the mesh entity that's associated
    fem_mesh_name = node_set_entities[0].Object.FemMesh.Label

    # searching active doc for the mesh set linked label
    mesh_object = App.ActiveDocument.getObjectsByLabel(fem_mesh_name)
    if len(mesh_object) != 1:
        err_string = "More than one mesh object called " + fem_mesh_name
        raise ValueError(err_string)
    mesh_object = mesh_object[0].FemMesh

    # get the node IDs that I care about
    node_IDs = obj.Object.Nodes

    # compute "nodes" of the mesh entity
    nodes = {}
    for NID in node_IDs:
        nodes[NID] = list(mesh_object.Nodes[NID])

    # get the location of the central node of the spider
    x_bar = 0
    y_bar = 0
    z_bar = 0
    for NID in list(nodes.keys()):
        x_bar += nodes[NID][0]
        y_bar += nodes[NID][1]
        z_bar += nodes[NID][2]
    x_bar = x_bar / len(nodes.keys())
    y_bar = y_bar / len(nodes.keys())
    z_bar = z_bar / len(nodes.keys())

    # get highest NID in original mesh object
    NID_center = len(mesh_object.Nodes) + 1

    # create a new mesh entity for the bush spider
    bush_spider = Fem.FemMesh()
    # make a grid point, at the centeral location
    bush_spider.addNode(x_bar, y_bar, z_bar, NID_center)
    # add nodes, and make seg2 elements to the 
    for NID in list(nodes.keys()):
        nodes[NID][0]
        bush_spider.addNode(nodes[NID][0], nodes[NID][1], nodes[NID][2], NID)
        bush_spider.addEdge(NID, NID_center)
    print(bush_spider)

    # Making it render correctly
    doc = App.ActiveDocument
    obj = doc.addObject("Fem::FemMeshObject", "bush_spider")
    obj.FemMesh = bush_spider
    obj.Placement.Base = FreeCAD.Vector(0, 0, 0)
    obj.ViewObject.DisplayMode = "Faces, Wireframe & Nodes"
    obj.ViewObject.BackfaceCulling = False
    doc.recompute()

# }}}


if __name__ == '__main__':
    main()
and here's a link to the github of the macro
https://github.com/zchlrnr/FCMesher/blo ... ode_set.py

This is what they did in Nastran before v60, if I recall? That was in the early 90s I think it was, so you really do have to go way back to a time when this kind of element didn't outnumber regular elements by a large number.

I can easily make this create an RBE3... if that kind of object even existed.

I was thinking of just adding some logic to run over freeCAD that made it so that when I clicked on one of the bush elements, it picked all of them, but I didn't know how to do that.

Then I thought I could just make a button that exported every FEM item in the active document, if it was a FemMesh entity with the word "RBE3" in it. I got this to work super fast, and used it to test this puppy

Code: Select all

https://github.com/zchlrnr/FCMesher/blob/main/macros/make_rbe3_within_sphere.py
but it's very obviously a hack job.

Can anybody here point to a place where I can learn how to add a new element type?
aerospaceweeb
Posts: 118
Joined: Fri Apr 09, 2021 3:26 am

Re: Feature Request/Inquiry: MPC and RBE elements

Post by aerospaceweeb »

@heda

I'm sorry I missed this message. I saw fandaLs comment and have been blindly playing around with a spider maker since then.

If it's true that it's not prohibitively difficult or computationally expensive to simply make geometry out of the meshes, then that would solve almost all of the issues I mentioned, as you say.

I'd dare say that would even enable something like the "association" functions you see in all of the major pre/post tools like FeMap, Patran, Hypermesh, etc. It would certainly be better than the crap code I've been playing with to find/detect nodes with distance querying and kdtree usage. I didn't even know that FreeCAD could do that kind of model reverse-mapping to that extent. That puts it far away and beyond even commercial tools. I'm beyond impressed, and sad that I didn't figure that out sooner.

I'm terribly embarrassed to confess, I have no idea where that "automatic" geometry creation feature is at the moment. The fact that it's inside of the code that you graciously gifted me to learn from is a surprise to me.

Could you please show me where it is?
https://github.com/zchlrnr/FCMesher

Thank you so much Heda.
aerospaceweeb
Posts: 118
Joined: Fri Apr 09, 2021 3:26 am

Re: Feature Request/Inquiry: MPC and RBE elements

Post by aerospaceweeb »

@Bernd

Thank you so much, I apologize for the poor communication.
I didn't realize at the time that all I had to do was select ANY mesh entity, and the mesh > node set button would be accessible in the drop down menu.

At the time, I saw the different behavior for the selectable buttons in the FEM workbench and didn't understand why.

When I made a gmsh mesh, I saw that the three buttons for creating mesh regions and mesh groups became selectable.
gmsh_demo.png
gmsh_demo.png (154.58 KiB) Viewed 1902 times
But for the mesh entity that wasn't a gmsh mesh, the three buttons remained unselectable.
not_gmsh_created.png
not_gmsh_created.png (161.56 KiB) Viewed 1902 times
I then incorrectly thought that it meant that the gmsh let me make node sets but the regular one didn't, because I didn't realize that the node set button wasn't among those three.

I have now figured out how to make a node set, and am able to use it to create things like MPCs, spiders, and other critical element constructions.

Is there a similar thing for sets of elements?

Thank you so much.
heda
Veteran
Posts: 1348
Joined: Sat Dec 12, 2015 5:49 pm

Re: Feature Request/Inquiry: MPC and RBE elements

Post by heda »

no worries :D , we all have our aha & doh moments when diving into fc, part of the game and would be really strange otherwise.

in task_ruled.py and line 262

Code: Select all

            ruled = Part.makeRuledSurface(ed1, ed2)
            Part.show(ruled, 'RuledSurface')
ed1 & ed2 are the selected edges, that's it apart from caring for flipped edges

should be easy enough to code same functionality as in Part_Builder#Face_from_vertices giving faces and then joining them to a shell
User avatar
johnwang
Veteran
Posts: 1382
Joined: Sun Jan 27, 2019 12:41 am

Re: Feature Request/Inquiry: MPC and RBE elements

Post by johnwang »

aerospaceweeb wrote: Sun Sep 12, 2021 2:18 am Try running this macro after clicking on the mesh entity.

It will spit out the nastran card for the RBE3, with some issues.
I am trying to understand this RBE3. What the test case will be to compare with and without RBE3.

Without:
Fix the outer BC. Maybe the rectangle end given a force to pull
Fix the inner BC.

With RBE3
Fix the outer BC. Maybe the rectangle end given a force to pull
No need to anything for inner BC?
hfc series CAE workbenches for FreeCAD (hfcNastran95, hfcMystran, hfcFrame3DD, hfcSU2 and more)
Post Reply