Skip to content

Refactor Tet::choose_diagonal() #4117

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

Merged
merged 1 commit into from
Apr 23, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 4 additions & 10 deletions src/geom/cell_tet.C
Original file line number Diff line number Diff line change
Expand Up @@ -203,23 +203,17 @@ bool Tet::is_child_on_side_helper(const unsigned int /*c*/,

void Tet::choose_diagonal() const
{
// Check for uninitialized diagonal selection
// If uninitialized diagonal selection, select the shortest octahedron diagonal
if (this->_diagonal_selection==INVALID_DIAG)
{
Real diag_01_23 = (this->point(0) + this->point(1) - this->point(2) - this->point(3)).norm_sq();
Real diag_02_13 = (this->point(0) - this->point(1) + this->point(2) - this->point(3)).norm_sq();
Real diag_03_12 = (this->point(0) - this->point(1) - this->point(2) + this->point(3)).norm_sq();

this->_diagonal_selection=DIAG_02_13;
std::array<Real, 3> D = {diag_02_13, diag_03_12, diag_01_23};

if (diag_01_23 < diag_02_13 || diag_03_12 < diag_02_13)
{
if (diag_01_23 < diag_03_12)
this->_diagonal_selection=DIAG_01_23;

else
this->_diagonal_selection=DIAG_03_12;
}
this->_diagonal_selection =
Diagonal(std::distance(D.begin(), std::min_element(D.begin(), D.end())));
}
}

Expand Down