Skip to content

Add variant of geins taking insertion mode to C interface#39

Open
fdrmrc wants to merge 1 commit into
sfilippone:developmentfrom
fdrmrc:geins_v
Open

Add variant of geins taking insertion mode to C interface#39
fdrmrc wants to merge 1 commit into
sfilippone:developmentfrom
fdrmrc:geins_v

Conversation

@fdrmrc

@fdrmrc fdrmrc commented Mar 17, 2026

Copy link
Copy Markdown
Contributor

This PR extends psb_c_dgeins allowing an explicit mode argument, named psb_c_dgeins_options. The signature is

psb_i_t psb_c_dgeins_options(psb_i_t nz, const psb_l_t *irw, const psb_d_t *val,
                       psb_c_dvector *xh, psb_c_descriptor *cdh, psb_i_t mode);

The intent of this is to allow the insertion mode to be specified per-call rather than at allocation time. If the caller tries to switch between insert and add within the same assembly round, an exception is thrown. This is the behavior of VecSetValues() in PETSc: https://petsc.org/release/manualpages/Vec/VecSetValues/

An example of this possible usage is the following, where the xh vector is updated after assembly.

// start filling as usual
psb_c_dgeins_options(nl, indices, values, xh, cdh, PSB_INSERT_VALUES);
psb_c_dgeasb(xh, cdh); //vector is assembled

// fill the existing vector with new values
psb_c_dgeins_options(nl, indices, new_values, xh, cdh, PSB_INSERT_VALUES);
psb_c_dgeasb(xh, cdh); //assemble before switching mode once again

// accumulate again
psb_c_dgeins_options(nl, indices, other_values, xh, cdh, PSB_ADD_VALUES);
psb_c_dgeasb(xh, cdh); //assemble

I am not sure this is the best way to achieve the desired result, hence its draft status. It is also implemented here for double types only.

Here is minimal working example that tests its correct usage: mwe.c

@fdrmrc fdrmrc changed the title Implement variant of geins taking insertion mode to C interface Add variant of geins taking insertion mode to C interface Mar 17, 2026
@sfilippone

Copy link
Copy Markdown
Owner

Is this ready for review?

@fdrmrc

fdrmrc commented Mar 18, 2026

Copy link
Copy Markdown
Contributor Author

Is this ready for review?

Yes, let me remove the draft status. I am not yet entirely sure about the approach, though

@fdrmrc fdrmrc marked this pull request as ready for review March 18, 2026 11:21
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.

2 participants