Access to nodal results on element by element basis
Moderator: bernd
Forum rules
and Helpful information for the FEM forum
and Helpful information for the FEM forum
Re: Access to nodal results on element by element basis
this huge dict is just a helper between the frd file loader and the generator of the FreeCAD document objects for the result and result mesh. It is not intended to work as an API, not at all. It has been there right from the beginning before I came to FEM. I do not like it too. Furthermore the calculation of some values from the results takes place there (vanMises). My idea was to move them away from the result input reader. But to be honest I did not spent really time on all this nor I do have a good idea how to make this better. May be some class would be better as this dict monstrous!
bernd
bernd
Re: Access to nodal results on element by element basis
The method readResult(frd_input) in importCcxFrdResults.py is very easy to read and is almost a user guide for the FRD file. The nested dict helps bring that clarity. So my comment was not intended as criticism. I just wondered if there is a simpler way to get to what I want. I am on a steep learning curve.
I place my function call in fill_femresult_mechanical, because it will return an array of nodal variables (similar to von Mises) that needs to be plotted and I can therefore mimic all the existing code for filling the Result and VTK objects. That's how I got the concrete Reinforcement Ratios and Mohr Coulomb stress to work.
PS: in finite element code, where there is a need to access global nodes on an element-by-element basis, you would typically use a multi-dimensional array, e.g.: global_node_number[element_number][local_node_number]. By the way, I am not at all suggesting to go back in time and use a FORTRAN design paradigm; although it would make me feel more comfortable
I place my function call in fill_femresult_mechanical, because it will return an array of nodal variables (similar to von Mises) that needs to be plotted and I can therefore mimic all the existing code for filling the Result and VTK objects. That's how I got the concrete Reinforcement Ratios and Mohr Coulomb stress to work.
PS: in finite element code, where there is a need to access global nodes on an element-by-element basis, you would typically use a multi-dimensional array, e.g.: global_node_number[element_number][local_node_number]. By the way, I am not at all suggesting to go back in time and use a FORTRAN design paradigm; although it would make me feel more comfortable
Re: Access to nodal results on element by element basis
I finally got the post processing routine to work for a single 3D Tetra10Elem. Next step: integrate it into FC and produce some pretty pictures
Re: Access to nodal results on element by element basis
I really like any comment about how to improve the code base of FEM.
As stated before I'm not happy with how result object is designed and implemented in FreeCAD FEM. There should be a smarter way. Imagine if we gone start element integration values and all the different FEM analysis types like mechanica, thermomech, thermo, electric, magnetic, fluid and so on, all have different result sets, We need to be more flexible in result object somehow ...HarryvL wrote: ↑Wed Jun 06, 2018 4:49 am PS: in finite element code, where there is a need to access global nodes on an element-by-element basis, you would typically use a multi-dimensional array, e.g.: global_node_number[element_number][local_node_number]. By the way, I am not at all suggesting to go back in time and use a FORTRAN design paradigm; although it would make me feel more comfortable
Re: Access to nodal results on element by element basis
Note to self and others:HarryvL wrote: ↑Sat Jun 02, 2018 9:45 am Hi, I want to do some post processing for which I need to cycle through the elements of the result mesh and for each element access the element nodal results and nodal coordinates. So not simply run through all nodes, but access them on an element by element basis. How can I best do that? Thanks. Harry
(EDIT: tidied up the following description)
mesh_data['Tetra10Elem'] ------- Dictionary where the "key" is the element_number and the "values" are the global_node_number Tuples
mesh_data['Nodes'] ---------------- Dictionary where the "key" is the global_node_number and the "values" are the node_coordinates Tuples
So I now use the following arrays to cycle through global nodes on an element-by-element basis:
elNodes=numpy.asarray(mesh_data['Tetra10Elem'].values()) --------- elNodes[i,j]=global node number of local node j in element i
noCoord=numpy.asarray(mesh_data['Nodes'].values()) ------------------ noCoord[i,j]=coordinate j (0=x,1=y,2=z) for global node i
these are the arrays typically available in a finite element code.
Last edited by HarryvL on Mon Jul 02, 2018 3:39 am, edited 1 time in total.
Re: Access to nodal results on element by element basis
Does it makes sense to directly add them somehow ?HarryvL wrote: ↑Fri Jun 29, 2018 4:51 amNote to self and others:HarryvL wrote: ↑Sat Jun 02, 2018 9:45 am Hi, I want to do some post processing for which I need to cycle through the elements of the result mesh and for each element access the element nodal results and nodal coordinates. So not simply run through all nodes, but access them on an element by element basis. How can I best do that? Thanks. Harry
elements=mesh_data['Tetra10Elem'] ------- Dictionary with key=element_number and values=global_node_number Tuples
elements=mesh_data['Nodes'] ---------------- Dictionary with key=global_node_number and values=node_coordinates Tuples
So I now use the following arrays to cycle through global nodes on an element-by-element basis:
elNodes=numpy.asarray(mesh_data['Tetra10Elem'].values()) --------- elNodes[i,j]=global node number of local node j in element i
noCoord=numpy.asarray(mesh_data['Nodes'].values()) ------------------ noCoord[i,j]=coordinate j (0=x,1=y,2=z) for global node i
these are the arrays typically available in a finite element code.
Re: Access to nodal results on element by element basis
do you mean use the dicts instead of the arrays in the computation?
Re: Access to nodal results on element by element basis
Add the missing arrays to the FreeCAD FemMesh as properties to be able to access them directly by for example
Code: Select all
App.ActiveDocument.HarrysBridgeMesh.FemMesh.elNodes
Code: Select all
App.ActiveDocument.HarrysBridgeMesh.FemMesh.noCoords
Re: Access to nodal results on element by element basis
Yes that would work and I guess make them available to the console and external scripts?
Re: Access to nodal results on element by element basis
open FEM 3D example from StartWorkBench an run the following code ...HarryvL wrote: ↑Fri Jun 29, 2018 4:51 amNote to self and others:HarryvL wrote: ↑Sat Jun 02, 2018 9:45 am Hi, I want to do some post processing for which I need to cycle through the elements of the result mesh and for each element access the element nodal results and nodal coordinates. So not simply run through all nodes, but access them on an element by element basis. How can I best do that? Thanks. Harry
(EDIT: tidied up the following description)
mesh_data['Tetra10Elem'] ------- Dictionary where the "key" is the element_number and the "values" are the global_node_number Tuples
mesh_data['Nodes'] ---------------- Dictionary where the "key" is the global_node_number and the "values" are the node_coordinates Tuples
So I now use the following arrays to cycle through global nodes on an element-by-element basis:
elNodes=numpy.asarray(mesh_data['Tetra10Elem'].values()) --------- elNodes[i,j]=global node number of local node j in element i
noCoord=numpy.asarray(mesh_data['Nodes'].values()) ------------------ noCoord[i,j]=coordinate j (0=x,1=y,2=z) for global node i
these are the arrays typically available in a finite element code.
Code: Select all
femmesh = App.ActiveDocument.Box_Mesh.FemMesh
elements = femmesh.Edges + femmesh.Faces + femmesh.Volumes
elNodes = {}
for e in elements:
elNodes[e] = femmesh.getElementNodes(e)
nodes = femmesh.Nodes
noCoord = {}
for n in nodes:
noCoord[n] = (nodes[n].x, nodes[n].y, nodes[n].z)
elNodes
noCoord