I'm adding nodal masses to 3D structures in order to manipulate the vibrational behavior of the structure itself and want to perform the eigenvalue analysis. It worked until a new build of Kratos of some days or weeks ago, but now I don't get results any more. In the following is listed the code of how the nodal masses are assigned.
simulation.Initialize()
solver = simulation._GetSolver()
computing_model_part = solver.GetComputingModelPart()
stiffness = 0.0
damping = 0.0
computing_model_part = solver.GetComputingModelPart()
element = computing_model_part.CreateNewElement("NodalConcentratedElement3D1N", 99999, [1], None)
element.SetValue(NODAL_MASS, mass)
element.SetValue(NODAL_STIFFNESS, [0, stiffness, 0])
element.SetValue(NODAL_DAMPING_RATIO , [0, damping, 0])
simulation.RunSolutionLoop()
simulation.Finalize()
As I understood, the simulation runs through until simulation.Finalize(). In the following is listed the code of Finalize. The only error message I get is "Speicherzugriffsfehler".
def Finalize(self):
super(StructuralMechanicsAnalysisWithEigenPostProcessing,self).Finalize()
main_model_part_name = self.project_parameters["solver_settings"]["model_part_name"].GetString()
main_model_part = self.model[main_model_part_name]
self.Lambda = main_model_part.ProcessInfo[sm.EIGENVALUE_VECTOR]
mass_process = sm.TotalStructuralMassProcess(main_model_part)
mass_process.Execute()
self.mass = main_model_part.ProcessInfo[km.NODAL_MASS]
Any idea of what is wrong and how to fix this?
Thanks in advance!
I don't know german, what is "Speicherzugriffsfehler"?
I don't know german, what is "Speicherzugriffsfehler"?
memory access error
@veiguf I recently did some changes in the TotalStructuralMassProcess
Could you try to run the simulation without executing this process?
Otherwise can you attach a simple example?
I I think the TotalStructuralMassProcess is not the problem. Attached you can find now an example. In this example, I deactivated this process already.
Cantilever3D.zip
We are adding point masses (without stiffness or damping) to an existing structure with the following commands:
computing_model_part.CreateNewElement("NodalConcentratedElement3D1N", 9999999, [10], None) element.SetValue(km.NODAL_MASS, m[ii])
element.SetValue(sm.NODAL_STIFFNESS, [0, stiffness, 0])
element.SetValue(sm.NODAL_DAMPING_RATIO, [0, damping, 0])
In order to access the values for the eigenvalues and mass we wrote the following Finalize function within the class StructuralMechanicsAnalysisWithEigenPostProcessing:
class StructuralMechanicsAnalysisWithEigenPostProcessing(StructuralMechanicsAnalysis):
def Finalize(self):
super(StructuralMechanicsAnalysisWithEigenPostProcessing,self).Finalize()
main_model_part_name = self.project_parameters["solver_settings"]["model_part_name"].GetString()
main_model_part = self.model[main_model_part_name]
self.Lambda = main_model_part.ProcessInfo[sm.EIGENVALUE_VECTOR]
We are getting the memory access error at super(StructuralMechanicsAnalysisWithEigenPostProcessing,self).Finalize() and specifically in
kratos/kratos/python_scripts.py in the function Finalize at line 108 in our second process: PostProcessEigenvaluesProcess (which is defined in EigenvalueParameters.json).
The error is still there even if we "turn off" everything to do with mass calculation. Further, the proper eigenvalues are printed to the output window before the error.
Therefore I am thinking has something to do with the Finalize class with added nodes.
Any ideas what this could be? Is this the same problem I was having here: https://github.com/KratosMultiphysics/Kratos/issues/2959
Thanks in advance!
I am trying to run the case you provided but it is too large to be run in debug.
Can you please provide a case with this problem but that is smaller?
this is the reason it is failing:
~~~
System Solve Time: 440.478
Traceback (most recent call last):
File "Cantilever3D.py", line 51, in
simulation.Finalize()
File "Cantilever3D.py", line 22, in Finalize
super(StructuralMechanicsAnalysisWithEigenPostProcessing,self).Finalize()
File "/home/philippb/software/Kratos_Master/kratos/python_scripts/analysis_stage.py", line 108, in Finalize
process.ExecuteFinalize()
File "/home/philippb/software/Kratos_Master/applications/StructuralMechanicsApplication/python_scripts/postprocess_eigenvalues_process.py", line 63, in ExecuteFinalize
self.model_part, self.settings).Execute()
RuntimeError: Error: Tryining to get the properties of Element #9999999, which are uninitialized.
in kratos/includes/element.h:1029:Element::PropertiesType& Element::GetProperties()
kratos/includes/gid_mesh_container.h:307:void GidMeshContainer::WriteMesh(GiD_FILE, bool)
kratos/includes/gid_io.h:1419:void GidIO
~~~
Gid uses the properties to visualize the different regions of the ModelPart. I.e. it will crash if an element / a condition doesn't have a property
If this was working before I honestly don't know why...
@loumalouomega do you have a clue?
In any case, just give the element a property and you should be fine
Thanks for the rapid response!
Are we not giving the element properties when we do the following:
for ii in range(len(MassNodes)):
element = computing_model_part.CreateNewElement("NodalConcentratedElement3D1N", 9999999+ii, [MassNodes[ii]], None)
element.SetValue(km.NODAL_MASS, m[ii])
element.SetValue(sm.NODAL_STIFFNESS, [0, stiffness, 0])
element.SetValue(sm.NODAL_DAMPING_RATIO, [0, damping, 0])
Does it want geometry or material?
P.S.
Strangely enough it was indeed working...
Sorry I was too quick! It runs now with the following code:
for ii in range(len(MassNodes)):
element = computing_model_part.CreateNewElement("NodalConcentratedElement3D1N", 9999999+ii, [MassNodes[ii]], mp.GetProperties()[0])
element.SetValue(km.NODAL_MASS, m[ii])
element.SetValue(sm.NODAL_STIFFNESS, [0, stiffness, 0])
element.SetValue(sm.NODAL_DAMPING_RATIO, [0, damping, 0])
Thanks for your help!
@e-dub yep thats what I meant.
Now you are providing properties
Is this solved then?
I was able to solve it by adding a property set as written above to the creation of the new mass elements. As a mass element does not really have a material or other properties defined in the property sets, I do not know if it makes sense. Though, as is with a property set, it will be consistent with the other elements in Kratos.
Thanks for your help!