Example to show how to use the SPM library with a variadic 0-based multi-dof sparse matrix allocated through the library but initialized by the user.
- Copyright
- 2020-2024 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, Univ. Bordeaux. All rights reserved.
- Version
- 1.2.4
- Author
- Mathieu Faverge
-
Tony Delarue
- Date
- 2024-06-26
/
d += (( i + j + k ) % 3) + 1;
if ( i < mdim1 ) {
spm->rowptr[nnz] = (i+1) + dim1 * j + dim1 * dim2 * k;
spm->colptr[nnz] = i + dim1 * j + dim1 * dim2 * k;
nnz++;
}
if ( j < mdim2 ) {
spm->rowptr[nnz] = i + dim1 * (j+1) + dim1 * dim2 * k;
spm->colptr[nnz] = i + dim1 * j + dim1 * dim2 * k;
nnz++;
}
if ( k < mdim3 ) {
spm->rowptr[nnz] = i + dim1 * j + dim1 * dim2 * (k+1);
spm->colptr[nnz] = i + dim1 * j + dim1 * dim2 * k;
nnz++;
}
}
}
}
spm->dofs[n] = d;
assert( nnz == ((2*(dim1)-1) * dim2 * dim3 + (dim2-1)*dim1*dim3 + dim2*dim1*(dim3-1)) );
}
k = l / ( dim1 * dim2 );
j = (l % ( dim1 * dim2 )) / dim1;
i = l % dim1;
col = spm->colptr[l];
row = spm->rowptr[l];
dofcol = spm->dofs[ col+1 ] - spm->dofs[ col ];
dofrow = spm->dofs[ row+1 ] - spm->dofs[ row ];
if ( col == row ) {
value = 6.;
for ( n=0; n<dofcol; n++ ) {
for ( m=0; m<dofrow; m++ ) {
values[v] = value;
v++;
}
}
}
assert( v == spm->nnzexp );
}
spm->nnz += (dim1 - 1) * dim2 * dim3;
spm->nnz += dim1 * (dim2 - 1) * dim3;
spm->nnz += dim1 * dim2 * (dim3 - 1);
spm->replicated = 1;
spm->gN = spm->n;
spm->dof = -1;
void spmAlloc(spmatrix_t *spm)
Allocate the arrays of an spm structure.
Definition in file example_mdof1.c.