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

[Core] Adding debug check in CheckAndCorrectZeroDiagonalValues #12782

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

Conversation

loumalouomega
Copy link
Member

📝 Description

Initial work for #12768.

Basically checks in debug that the daigonal terms exist instead of directly asign them. This will not actually fix the issue in not initialzed diagonals, but this is a first step.

🆕 Changelog

}
}
KRATOS_ERROR << "Diagonal term (" << Index << ", " << Index << ") is not defined in the system matrix" << std::endl;
#else
rA(Index, Index) = scale_factor;
Copy link
Member

Choose a reason for hiding this comment

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

isnt this still some find operation?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, what alternative there is?. Only executed in debug.

Copy link
Member

@RiccardoRossi RiccardoRossi Oct 24, 2024

Choose a reason for hiding this comment

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

well, i would use the following (surely to be slightly adapted to make it to compile)

auto pos = std::lower_bound(&Acolndices[col_begin],&Acolndices[col_end]);
if pos != &Acolndices[col_end] //it was found
     rValues[pos - &Acolndices[col_begin]] = scale_factor;
#ifdef _DEBUG
else
    KRATOS_ERROR ... 
#endif

this code shall be a bit faster than what you have, and it will use a binary search

if you do not like this, there is a function "find_element(i,i)" which will do the same as calling the lower bound.
i think my version should be slightly faster because we already have col_begin and col_end.

Copy link
Member Author

Choose a reason for hiding this comment

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

Anycase looks like we have tests failing in full debug, hurray

Copy link
Member

Choose a reason for hiding this comment

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

can you take a look to what are the cases failing? to know if it is a realistic scenario or just something we use in the tests (my bet is that there are constraints ... )

Copy link
Member Author

Choose a reason for hiding this comment

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

With your code:

[  FAILED  ] KratosCoreFastSuite.BasicDisplacementBlockBuilderAndSolver
[  FAILED  ] KratosCoreFastSuite.BasicDisplacementBlockBuilderAndSolverWithZeroContribution
[  FAILED  ] KratosCoreFastSuite.BasicDisplacementBlockBuilderAndSolverWithConstraints
[  FAILED  ] KratosCoreFastSuite.BasicDisplacementBlockBuilderAndSolverWithInactiveConstraints
[  FAILED  ] KratosCoreFastSuite.BasicDisplacementBlockBuilderAndSolverWithConstraintsAuxiliarNode
[  FAILED  ] KratosCoreFastSuite.BasicDisplacementBlockBuilderAndSolverWithConstraintsAuxiliarNodeInverted
[  FAILED  ] KratosCoreFastSuite.BasicDisplacementBlockBuilderAndSolverAllDoFsMaster
[  FAILED  ] KratosCoreFastSuite.BasicDisplacementBlockBuilderAndSolverAllDoFsMasterFromStructureSide
[  FAILED  ] KratosCoreFastSuite.BasicDisplacementEliminationBuilderAndSolverWithZeroContribution

Copy link
Member

Choose a reason for hiding this comment

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

my code was wrong. it should be

pos - &Acolndices[0]

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, still failing

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, still failing

Wait it was my fault, testing

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay now it only fails in Debug (in my machine) and the failing tests are the same:

[  FAILED  ] KratosCoreFastSuite.BasicDisplacementBlockBuilderAndSolver
[  FAILED  ] KratosCoreFastSuite.BasicDisplacementBlockBuilderAndSolverWithZeroContribution
[  FAILED  ] KratosCoreFastSuite.BasicDisplacementBlockBuilderAndSolverWithConstraints
[  FAILED  ] KratosCoreFastSuite.BasicDisplacementBlockBuilderAndSolverWithInactiveConstraints
[  FAILED  ] KratosCoreFastSuite.BasicDisplacementBlockBuilderAndSolverAllDoFsMaster
[  FAILED  ] KratosCoreFastSuite.BasicDisplacementEliminationBuilderAndSolverWithZeroContribution

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

Successfully merging this pull request may close these issues.

3 participants