-
Notifications
You must be signed in to change notification settings - Fork 250
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ShapeOpt] [WIP] Adding new response with stress aggregation for optimization #5682
base: master
Are you sure you want to change the base?
Conversation
still problems with thread safety
sensitivity needs to be computed before response function is finalized
Reset of thread number has to be done after finalizing adjoint solution, otherwise there is a segmentation fault
Observations regarding the problematic race conditions so far:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor
else: | ||
raise Exception("invalid response_type: " + response_type) | ||
|
||
self.sensitivity_builder = KratosMultiphysics.SensitivityBuilder(self.settings["sensitivity_settings"], self.main_model_part, self.response_function) | ||
self.sensitivity_builder.Initialize() | ||
|
||
self.max_number_of_threads = KratosMultiphysics.OpenMPUtils.GetNumThreads() | ||
KratosMultiphysics.OpenMPUtils.SetNumThreads(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
blocking until this is resolved
As you pointed out this should not go into Master
@@ -15,18 +15,23 @@ def CreateResponseFunction(response_id, response_settings, model): | |||
elif response_type == "eigenfrequency": | |||
return structural_response.EigenFrequencyResponseFunction(response_id, response_settings, model) | |||
|
|||
elif response_type == "adjoint_nodal_displacement": | |||
elif response_type == "adjoint_nodal_displacement" or\ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
elif response_type == "adjoint_nodal_displacement" or\ | |
elif response_type in ["adjoint_nodal_displacement", "adjoint_linear_strain_energy", ...]: |
this would be another alternative of doing this
FYI @MFusseder the mentioned bug might be relevant for you as well. |
Is dpKdpX also causing problems? Because that is calculated in all other adjoint structural responses as well and there it seems to work (because it is called in serial).
The calculation of stress values at element level is threadsafe - so i would not expect that the calculation of simply the values does create any problems - also not when called from within the adjoints element at the primal element. The finite differencing of derivatives w.r.t. node coordinates is not thread safe. Thats why i still guess that doing this in parallel is the root of the problem. |
After using this new response for some days I have a comment. Within |
As discussed in person: Indeed this is a problem. But for the sake of getting a first draft up and running, it was implemented this way. The main problem is, that the primal model part is only available in the |
This PR adds a new response function which allows for stress aggregation using the Kreisselmeier Steinhauser (KS) function.
By that, stress constraints may be considered over big parts of a structural domain whereas the given functionalities in Kratos only allowed for a single maximum value (whose location may heavily jump around). See figure below for an impression. There, a loaded hook structure is optimized for mass, while the stress in each element of the structure is not allowed to exceed a maximum value (dark red). The color plot shows the stresses on the surface for a constant value range. It can be seen, that the stresses significantly increase when reducing the mass (removing material). But they always stay within the specified limits.
This branch is not yet ready to be merged as it revealed an existing problem with thread safety in the current adjoint solution approach in case several elements are considered within the given stress response functions.
Also, this PR first requires an approval and merge of #4364.
Roadmap: