41 if ( newptr != NULL ) {
44 memFree_null( tmpptr );
72 if( newperm != NULL ) {
78 for (i = 0; i < n; i++, perm++) {
82 if( newinvp != NULL ) {
88 for (i = 0; i < n; i++, invp++) {
132 invp_nonisol = invptab;
133 invp_isolate = invptab + (n - isolate_n);
136 if ( ((invp_isolate - invptab) < n) &&
137 (i == (*isolate_list - baseval)) )
148 assert( (invp_nonisol - invptab) == (n - isolate_n) );
149 assert( (invp_isolate - invptab) == n );
152 invp_nonisol = invptab;
153 for( i = 0; i < n; i++, invp_nonisol++ )
155 permtab[ *invp_nonisol ] = i;
158 #if defined(PASTIX_DEBUG_GRAPH)
159 for(i = 0; i < n; i++)
161 assert(permtab[i] < n );
162 assert(permtab[i] > -1);
189 pastix_graph_t *newgraph,
208 if ( newgraph->glob2loc ) {
209 free( newgraph->glob2loc );
210 newgraph->glob2loc = NULL;
215 if ( oldgraph->dofs ) {
219 for ( i=0; i<n; i++, oldcol++, olddof++, oldl2g++ )
222 k = oldgraph->loc2glob ? *oldl2g : i;
227 oldrow += (oldcol[1] - oldcol[0]);
232 for( k=oldcol[0]; k<oldcol[1]; k++, oldrow++ )
234 j = *oldrow - baseval;
239 *newrow = jp + baseval;
246 newcol[1] = newcol[0] + nbrows;
250 if ( oldgraph->loc2glob ) {
256 if ( oldgraph->dofs ) {
257 newdof[1] = newdof[0] + (olddof[1] - olddof[0]);
265 new_n = newcol - newgraph->colptr;
266 new_nnz = *newcol - baseval;
268 assert( new_n <= new_gn );
269 assert( new_nnz <= oldgraph->nnz );
272 newgraph->nnz = new_nnz;
278 newgraph->colptr = realloc( newgraph->colptr, (newgraph->n+1) *
sizeof(
pastix_int_t) );
279 newgraph->rowptr = realloc( newgraph->rowptr, newgraph->nnz *
sizeof(
pastix_int_t) );
280 if ( newgraph->loc2glob ) {
281 newgraph->loc2glob = realloc( newgraph->loc2glob, newgraph->n *
sizeof(
pastix_int_t) );
283 if ( newgraph->dofs ) {
284 newgraph->dofs = realloc( newgraph->dofs, (newgraph->gN+1) *
sizeof(
pastix_int_t) );
335 pastix_graph_t *outgraph,
347 if ( (isolate_n > gN) || (isolate_n < 0) ) {
348 pastix_print_warning(
"Number of columns to isolate greater than the columns in the graph matrix\n" );
353 assert( baseval == 0 );
356 if ( isolate_n == gN )
366 if ( isolate_n == 0 ) {
367 pastix_print_warning(
"graphIsolate: the graph is beeing duplicated to isolate no unknowns, are you sure you wanted to do that ?\n" );
372 intSort1asc1( isolate_list, isolate_n );
378 tmpperm, tmpinvp, baseval );
445 baseval = graph->baseval;
446 colptr = graph->colptr;
447 rowptr = graph->rowptr - baseval;
449 for( ip=fnode; ip<lnode; ip++ )
454 out_connected[ip-fnode] = 1;
462 while( d < distance ) {
466 for (jj = colptr[i]; jj < colptr[i+1]; jj++)
468 j = rowptr[jj] - baseval;
472 if ( ( jp >= fnode ) && ( jp < lnode ) ) {
473 if (out_connected[jp-fnode] == 0){
474 out_connected[jp-fnode] = 1;
477 out_colptr[ip-fnode+1]++;
542 pastix_graph_t *out_graph,
555 if ( out_graph == NULL ) {
556 pastix_print_warning(
"graphIsolateSupernode: Incorrect pointer for the output graph\n" );
561 out_graph->n = out_n;
564 out_graph->dof = graph->dof;
565 if( out_graph->dof < 0 ) {
566 MALLOC_INTERN( out_graph->dofs, graph->gN,
pastix_int_t );
567 memcpy( out_graph->dofs, graph->dofs, graph->gN *
sizeof(
pastix_int_t) );
571 pastix_print_warning(
"graphIsolateSupernode: Empty supernode\n" );
576 assert( baseval == 0 );
587 MALLOC_INTERN( out_graph->colptr, out_n + 1,
pastix_int_t );
588 memset( out_graph->colptr, 0, (out_n + 1) *
sizeof(
pastix_int_t) );
589 out_colptr = out_graph->colptr;
592 MALLOC_INTERN( out_graph->rowptr, graph->nnz,
pastix_int_t );
593 out_rowptr = out_graph->rowptr;
599 out_graph->baseval = baseval;
600 out_colptr[0] = baseval;
606 out_colptr, out_rowptr,
607 fnode, lnode, distance );
610 for (i = 0; i < out_n; i++){
611 out_colptr[i+1] += out_colptr[i];
614 out_graph->nnz = out_colptr[out_n] - out_colptr[0];
617 if ( out_graph->nnz == 0 ){
618 fprintf( stderr,
"Diagonal matrix cannot be correcly managed here!\n" );
BEGIN_C_DECLS typedef int pastix_int_t
static void graph_isolate_compress(const pastix_graph_t *oldgraph, pastix_graph_t *newgraph, pastix_int_t new_gn, const pastix_int_t *permtab)
Compress the local copy of the graph with only the kept unknowns.
static void graph_isolate_permutations(pastix_int_t n, pastix_int_t isolate_n, const pastix_int_t *isolate_list, pastix_int_t *permtab, pastix_int_t *invptab, pastix_int_t baseval)
Init and fill the inverse permutation array.
static void graph_isolate_everything(pastix_int_t n, pastix_int_t **newperm, pastix_int_t **newinvp)
If isolate_n == n, everything needs to be isolated. That means that we just need an id permuation.
static void graph_isolate_assign_ptr(pastix_int_t **newptr, pastix_int_t *tmpptr)
Assign the new pointer to the temporary one.
static void graph_iRange_fill_outptr(const pastix_graph_t *graph, const pastix_order_t *order, ExtendVectorINT *vec, pastix_int_t *out_colptr, pastix_int_t *out_rowptr, pastix_int_t fnode, pastix_int_t lnode, pastix_int_t distance)
Fill the isolated colptr and rowptr.
pastix_int_t extendint_Size(const ExtendVectorINT *)
Return the number of element stored in the vector.
void extendint_Clear(ExtendVectorINT *)
Cleanup the vector.
pastix_int_t extendint_Read(const ExtendVectorINT *, pastix_int_t)
Return the element of index eltnum.
pastix_int_t * extendint_Init(ExtendVectorINT *, pastix_int_t)
Initialize the extendVector structure with the initial size given.
void extendint_Add(ExtendVectorINT *, pastix_int_t)
Add an element elt to the end of the vector.
void extendint_Exit(ExtendVectorINT *)
Free the extendVector structure.
The extend integer array structure.
@ PASTIX_ERR_BADPARAMETER
int graphUpdateComputedFields(pastix_graph_t *graph)
Update dofs, nnz, nnzexp, gnnz, n, nexp, gN of a given graph.
int graphIsolate(const pastix_graph_t *ingraph, pastix_graph_t *outgraph, pastix_int_t isolate_n, pastix_int_t *isolate_list, pastix_int_t **new_perm, pastix_int_t **new_invp)
Isolate a subset of vertices from a given graph.
int graphCopy(pastix_graph_t *graphdst, const pastix_graph_t *graphsrc)
This routine copy a given ordering in a new one.
int graphIsolateRange(const pastix_graph_t *graphIn, const pastix_order_t *order, pastix_graph_t *graphOut, pastix_int_t fnode, pastix_int_t lnode, pastix_int_t distance)
Isolate the subgraph associated to a range of unknowns in the permuted graph.
void graphInitEmpty(pastix_graph_t *graph, PASTIX_Comm comm)
Initialize an empty graph.
void graphBase(pastix_graph_t *graph, pastix_int_t baseval)
Rebase the graph to the given value.