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
do you implement this in Vtk, in the result task panel or as macro?
Re: Access to nodal results on element by element basis
Same as reinforcement ratios and Mohr Coulomb. Available both in result object (type rx, ry, rz or mc in equation panel) and in VTK (for export to Paraview). Works nicely.
Re: Access to nodal results on element by element basis
So not as Macro
Re: Access to nodal results on element by element basis
So currently studying importCcxFrdResults(), readResult(), importToolsFem.make_femmesh(), ObjectsFem.makeMeshResult(), ObjectsFem.makeResultMechanical(), importToolsFem.fill_femtrsult_mechanical()
.......
to see how it relates to the App.ActiveDocument.Calculix_static_results.NodeNumbers.index(n) you mentioned.
A good, but tough, learning experience
.......
to see how it relates to the App.ActiveDocument.Calculix_static_results.NodeNumbers.index(n) you mentioned.
A good, but tough, learning experience
Re: Access to nodal results on element by element basis
If I would call my function from fill_femresult_mechanical(), like I did for the reinforcement ratios and Mohr Coulomb stress, then I guess I could simply pass the results object and inside my function extract stress by element nodes as follows?
Code: Select all
def MyFunction(results):
elements=results[“Penta15Elem”]
for elem in elements:
for n in elem:
sig1=results.PrincipalMax[n]
# etc.
Re: Access to nodal results on element by element basis
Well, that was completely wrong. Mesh information is stored in a Dictionary and results are separately stored in a PythonFeature objectHarryvL wrote: ↑Mon Jun 04, 2018 9:07 pm If I would call my function from fill_femresult_mechanical(), like I did for the reinforcement ratios and Mohr Coulomb stress, then I guess I could simply pass the results object and inside my function extract stress by element nodes as follows?
Code: Select all
def MyFunction(results): elements=results[“Penta15Elem”] for elem in elements: for n in elem: sig1=results.PrincipalMax[n] # etc.
So I need to pass both to my function:
Code: Select all
def fill_femresult_mechanical(results, result_set, span,mesh_data):
info_by_element(results, mesh_data)
return
def info_by_element(results, mesh_data):
print("results: {}".format(type(results))) #FeaturePython
print("mesh_data: {}".format(type(mesh_data))) #Dictionary
elements=mesh_data['Tetra10Elem']
for key in elements:
nodes=np.asarray(elements[key])
count=0
for node in nodes:
count+=1
print("element: {}, element node: {}, node number: {}, Max Principal Stress: {}".format(key, count, node, results.PrincipalMax[node]))
return
Re: Access to nodal results on element by element basis
global node number starts with 1, index of results with 0 AFAIK, but I did not had a deeper look at your code ...
Re: Access to nodal results on element by element basis
At first I thought I could access both the "global node numbers by element" and the "stress results" from the same results object.
I now understand that global numbers by element are stored in a nested Dictionary (a dictionary of dictionaries), where at the first level key = element type (e.g. 'Tetra10Elem') and the values are themselves Dictionaries with key = element number and the values are Tuples containing the nodes for that particular element (in this example 10 values for each element number)
The stress values are stored in the results object and these can simply be extracted as the attributes for that object, e.g. results.StressValues[n] is the von Mises stress at node n+1
I call my function indeed in fill_femresult_mechanical. However, as the nested dictionary with global node numbers per element (result_mesh) is not available there, I pass it as an extra parameter in the call of fill_femresult_mechanical in importCcxFrdResults.
Wow, that's a lot more difficult than what I am used to in an old-fashioned Finite Element program.
I may be missing a trick ... if so, then I am eager to be educated
Here the final test routine:
Code: Select all
def fill_femresult_mechanical(results, result_set, span, mesh_data):
#bulk of the code removed for clarity
info_by_element(results, mesh_data)
return results
def info_by_element(results, mesh_data):
print("results: {}".format(type(results))) #FeaturePython
print("mesh_data: {}".format(type(mesh_data))) #Dictionary
elements=mesh_data['Tetra10Elem']
print("number of nodes in results.PrincipalMax {}".format(len(results.StressValues)))
max_node = 0
for key in elements:
nodes = np.asarray(elements[key])
count = 0
for node in nodes:
count += 1
if node>max_node: max_node = node
print("element: {}, element node: {}, node number: {}, Max Principal Stress: {}".format(key, count, node, results.StressValues[node-1]))
print("number of nodes: {}".format(max_node))
return