From 9ca7ff4191710c58316fa458279c1daa48c17cab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Thu, 19 Aug 2010 22:30:54 +0000 Subject: [PATCH] Add files missing in -c5083. Pointy hat: bska --- partition.c | 44 ++++++++++++++++++++++++++++++++++++++ test_mex_schur_comp_symm.m | 2 +- 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/partition.c b/partition.c index ae9d80db..032ce116 100644 --- a/partition.c +++ b/partition.c @@ -1,6 +1,7 @@ #include #include #include +#include #include "dfs.h" #include "partition.h" @@ -285,6 +286,7 @@ partition_create_c2c(int nc, int nneigh, const int *neigh, if (*pc2c != NULL) { for (i = 0; i < nneigh; i++) { if ((neigh[2*i + 0] >= 0) && (neigh[2*i + 1] >= 0)) { + /* Symmetric Laplace matrix (undirected graph) */ (*pc2c)[neigh[2*i + 0]]++; (*pc2c)[neigh[2*i + 1]]++; } @@ -300,6 +302,7 @@ partition_create_c2c(int nc, int nneigh, const int *neigh, if (*c2c != NULL) { for (i = 0; i < nneigh; i++) { if ((neigh[2*i + 0] >= 0) && (neigh[2*i + 1] >= 0)) { + /* Symmetric Laplace matrix (undirected graph) */ (*c2c)[-- (*pc2c)[neigh[2*i + 0]]] = neigh[2*i + 1]; (*c2c)[-- (*pc2c)[neigh[2*i + 1]]] = neigh[2*i + 0]; } @@ -399,6 +402,47 @@ create_block_conns(int b , int *ia , int *ja ) /* ---------------------------------------------------------------------- */ { + int nc, c, i, j; + + nc = pb2c[b + 1] - pb2c[b]; + + /* Clear start pointers */ + memset(ia, 0, (nc + 1) * sizeof *ia); + + for (i = pb2c[b]; i < pb2c[b + 1]; i++) { + c = b2c[i]; assert (loc[c] == i - pb2c[b]); + + /* Connect cell to self */ + ia[loc[c]] ++ ; + + /* Handle neighbours (if any) */ + for (j = pc2c[c]; j < pc2c[c + 1]; j++) { + if (p[c2c[j]] == b) { + /* Connection internal to block 'b'. Add */ + ia[loc[c]] ++; + } + } + } + + assert (ia[nc] == 0); + for (i = 1; i <= nc; i++) { ia[i] += ia[i - 1]; } + + for (i = pb2c[b]; i < pb2c[b + 1]; i++) { + c = b2c[i]; + + /* Connect cell to self */ + ja[-- ia[loc[c]]] = loc[c]; + + /* Handle neighbours (if any) */ + for (j = pc2c[c]; j < pc2c[c + 1]; j++) { + if (p[c2c[j]] == b) { + ja[-- ia[loc[c]]] = loc[c2c[j]]; + } + } + } + assert (ia[0] == 0); + + reverse_bins(nc, ia, ja); } diff --git a/test_mex_schur_comp_symm.m b/test_mex_schur_comp_symm.m index fcb068ca..cc63a6c2 100644 --- a/test_mex_schur_comp_symm.m +++ b/test_mex_schur_comp_symm.m @@ -1,5 +1,5 @@ run ../../startup -G = computeGeometry(cartGrid([200, 1], [1, 1])); +G = computeGeometry(cartGrid([200000, 1], [1, 1])); rock.perm = ones(G.cells.num, 1); [BI, connPos, conns] = mex_ip_simple(G, rock);