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

Replace the ".uid" in polarpoissonlikesolver.hpp. #196

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

PaulineVidal
Copy link
Collaborator

@PaulineVidal PaulineVidal commented Mar 19, 2025

I noticed that the static_analysis often fails on the polarpoissonlikesolver.hpp file because of the remaining .uid(). I tried to replace them.

Copy link
Member

Choose a reason for hiding this comment

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

Indeed this should silence the warnings but I am afraid we still have the same underlying problem. Calling the constructor https://ddc.mdls.fr/classddc_1_1DiscreteElement.html#af6776e89752caf2077e70f690502a5e5 should be done as a last resort. One should see uid() and this constructor as DDC exits.

Isn't there a function in splines that could get you the Idx<RCellDim> for example ? Is RCellDim the dimension of knots ?

Copy link
Member

@EmilyBourne EmilyBourne Mar 21, 2025

Choose a reason for hiding this comment

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

RCellDim is the dimension of the cells on which the bsplines are defined. It is declared here:

struct RCellDim
{
};

As it is inside this class I don't think it is dangerous to call this constructor.

That said in the places where - Idx<RCellDim>(0) is used it seems to me that some of the operations could be carried out directly with an Idx.

assert(ib_test_theta.uid() < BSplinesTheta::degree() + 1);
assert(ib_trial_r.uid() < BSplinesR::degree() + 1);
assert(ib_trial_theta.uid() < BSplinesTheta::degree() + 1);
assert((ib_test_r - Idx<RBasisSubset>(0)).value() < BSplinesR::degree() + 1);
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
assert((ib_test_r - Idx<RBasisSubset>(0)).value() < BSplinesR::degree() + 1);
assert(ib_test_r < Idx<RBasisSubset>(BSplinesR::degree() + 1));

Comment on lines +645 to +653
const std::size_t idx_trial_r_val = (idx_trial_r - m_idx_bsplines_r_front).value();
const std::size_t idx_trial_theta_val
= (idx_trial_theta - m_idx_bsplines_theta_front).value();
const std::size_t first_overlap_element_r_val
= idx_trial_r_val < BSplinesR::degree()
? 0
: idx_trial_r_val - BSplinesR::degree();

const Idx<RCellDim> first_overlap_element_r(first_overlap_element_r_val);
Copy link
Member

Choose a reason for hiding this comment

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

Are integers needed here? Is it not possible to do something like:

Suggested change
const std::size_t idx_trial_r_val = (idx_trial_r - m_idx_bsplines_r_front).value();
const std::size_t idx_trial_theta_val
= (idx_trial_theta - m_idx_bsplines_theta_front).value();
const std::size_t first_overlap_element_r_val
= idx_trial_r_val < BSplinesR::degree()
? 0
: idx_trial_r_val - BSplinesR::degree();
const Idx<RCellDim> first_overlap_element_r(first_overlap_element_r_val);
const Idx<RCellDim> first_overlap_element_r(
idx_trial_r < Idx<RCellDim>(BSplinesR::degree())
? Idx<RCellDim>(0)
: idx_trial_r - BSplinesR::degree());

?
Or is idx_trial_r the wrong type for this?

@EmilyBourne
Copy link
Member

EmilyBourne commented Mar 21, 2025

If you want to fix the warnings in this file then the 2 remaining warnings (which are easier to fix) should be addressed.

That said I was under the impression that we had agreed to leave this file as it is (with the warnings) for now as this code should be replaced in the coming months by a new implementation written by @etiennemlb . I think that a clean solution to these warnings involves more work than simply writing (ddc::select<BSplinesR>(idx_test) - m_idx_bsplines_r_front).value() instead of ddc::select<BSplinesR>(idx_test).uid() to ensure that the index types are used as intended

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

Successfully merging this pull request may close these issues.

3 participants