Skip to content
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

[Shape opt] water drain response function #12830

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

DSchmoelz
Copy link
Contributor

📝 Description
Introduces a new geometrical response function which avoids ponding. Includes a node search to detect the ponds and their water volume. The response function value can be chosen as the water volume of the pond or the product of the water volume with the water level ("quadratic_height_penalization").

Example: Cosinus shaped shell - no filtering, using raw sensitivities

water_drain.mp4

Example: Initial flat shell, corner supported, vertical point load, objective strain energy, constraint water drain
left: constrained optimization, right: unconstrained optimization

water_drain_flat_shell.mp4
objective strain energy constraint water drain
Video_obj Video_con

🆕 Changelog

  • Added water drain response function
  • Avoids ponding, node search implemented to detect water volumes

@DSchmoelz DSchmoelz requested a review from a team as a code owner November 7, 2024 13:30
@DSchmoelz DSchmoelz self-assigned this Nov 7, 2024
Copy link
Member

@Igarizza Igarizza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DSchmoelz, nice feature! I have only minor comments and one suggestion to implement a FD test for a new response.

class KRATOS_API(SHAPE_OPTIMIZATION_APPLICATION) WaterDrainResponseFunctionUtility
{
public:
///@name Type Definitions
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would be nice to add some description and documentation to the class.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added some descriptions :)


mGravityDirection = ResponseSettings["gravity_direction"].GetVector();
const double direction_norm = norm_2(mGravityDirection);
KRATOS_ERROR_IF(direction_norm < std::numeric_limits<double>::epsilon()) << "WaterDrainResponseFunctionUtility: 'main_direction' vector norm is 0!" << std::endl;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

std::numeric_limits::epsilon() might be too small, consider use 1e-16 or so ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed to 1e-16

KRATOS_TRY;

BuiltinTimer timer;
KRATOS_INFO("ShapeOpt::WaterDrain") << "Starting LeveVolumes..." << std::endl;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
KRATOS_INFO("ShapeOpt::WaterDrain") << "Starting LeveVolumes..." << std::endl;
KRATOS_INFO("ShapeOpt::WaterDrain") << "Starting LevelVolumes..." << std::endl;

BuiltinTimer timer;
KRATOS_INFO("ShapeOpt::WaterDrain") << "Starting LeveVolumes..." << std::endl;

for (std::vector<Kratos::Volume>::size_type i = 0; i<mListOfVolumes.size(); i++) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Id it possible to parallelize such loops?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've parallelized the nested loop over the nodes inside this loop. The number of volumes/ponds is usually much smaller than the amount of nodes.

fyi: the response takes in total around 0.5s for a model with 120000 nodes. That is much faster than the matrix free vm mapper needs to do the mapping.

@sunethwarna
Copy link
Member

I agree with @Igarizza. I would add an FD test. This PR has 30k lines due to that large shape_change_results.json file. I would reduce the size by reducing the number of values being compared.

@DSchmoelz
Copy link
Contributor Author

DSchmoelz commented Nov 21, 2024

Thank you @Igarizza @sunethwarna for reviewing very quickly!

I've shrunk the test so that it only consists of 139 nodes, reducing the size of shape_change_results.json to 1.5k lines.

As discussed with @sunethwarna, a FD sensitivity test is right now not possible, because the derivatives of the nodal area are neglected. Additionally, one needs to take into account that the response function can only compute sensitivities for the infeasible nodes (nodes which are "under water"). Hence, a FD sensitivity test should also just be applied on these only.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants