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

Quick construct of symmetric/SPD IJ matrix #1225

Open
iaae opened this issue Feb 3, 2025 · 0 comments
Open

Quick construct of symmetric/SPD IJ matrix #1225

iaae opened this issue Feb 3, 2025 · 0 comments

Comments

@iaae
Copy link

iaae commented Feb 3, 2025

To benchmark Hypre Linear IJ matrix interface further, I made an equivalent symmetric assembly of IJ matrix using the function below:

static HYPRE_IJMatrix* p_matrix;
static HYPER_Int TotalEq;

HYPRESOL_API void hyperij_set_symmetry( )
{
int nrow = 1, nj = 1;
HYPRE_Int* cols = new HYPRE_Int[totalEq];
HYPRE_Int* cols_per_row = new HYPRE_Int[totalEq];
HYPRE_Int* id_rows = new HYPRE_Int[totalEq];
HYPRE_Complex* val = new HYPRE_Complex[totalEq];
HYPRE_Int irow, ncol;

for (int i = 0; i < totalEq; i++) id_rows[i] = i;

HYPRE_IJMatrixGetRowCounts(*p_matrix, totalEq, id_rows, cols_per_row);

for (int i = 1; i < totalEq; i++) {//copy the lower tri component to the upper tri
ncol = cols_per_row[i];
HYPRE_IJMatrixGetValues(*p_matrix, -nrow, &ncol, &id_rows[i], cols, val);
for (int j = 0; j < ncol; j++) {
irow = cols[j];
if (i!=irow)
HYPRE_IJMatrixSetValues(*p_matrix, nrow, &nj, &irow, &i, &val[j]);
}
}

delete[] id_rows;
delete[] cols_per_row;
delete[] cols;
delete[] val;
}

So, after the IJ matrix assembly with only the lower tri components, I make the call

HYPRE_IJMatrixAssemble(*p_matrix);
hyperij_set_symmetry();

It is not working during solving. I did test the whole entry testing and it worked well, even under multi-threaded processes. I tested this hyperij_set_symmetry() on the full entry matrix and it validated the functionality.

Is there re-initialization needed after IJMatrixAssembly()?

thanks!

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

No branches or pull requests

1 participant