Skip to content

Commit

Permalink
Truly unsymmetric matrix in examples/mpi/subdomain_deflation.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
ddemidov committed Jun 22, 2014
1 parent 8d787c1 commit 91ccac5
Showing 1 changed file with 37 additions and 30 deletions.
67 changes: 37 additions & 30 deletions examples/mpi/subdomain_deflation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

#include "domain_partition.hpp"

#define CONVECTION

struct linear_deflation {
long n;
double h;
Expand Down Expand Up @@ -91,41 +93,46 @@ int main(int argc, char *argv[]) {

ptr.push_back(0);

const double h2i = (n - 1) * (n - 1);
const double hinv = (n - 1);
const double h2i = (n - 1) * (n - 1);
for(long j = 0, idx = 0; j < n; ++j) {
for(long i = 0; i < n; ++i, ++idx) {
if (renum[idx] < chunk_start || renum[idx] >= chunk_end) continue;

if (i == 0 || j == 0 || i + 1 == n || j + 1 == n) {
col.push_back(renum[idx]);
val.push_back(1);
rhs.push_back(0);
} else {
if (j > 0) {
col.push_back(renum[idx - n]);
val.push_back(-h2i);
}

if (i > 0) {
col.push_back(renum[idx - 1]);
val.push_back(-h2i);
}

col.push_back(renum[idx]);
val.push_back(4 * h2i);

if (i + 1 < n) {
col.push_back(renum[idx + 1]);
val.push_back(-h2i);
}

if (j + 1 < n) {
col.push_back(renum[idx + n]);
val.push_back(-h2i);
}

rhs.push_back(1);
if (j > 0) {
col.push_back(renum[idx - n]);
val.push_back(-h2i);
}

if (i > 0) {
col.push_back(renum[idx - 1]);
val.push_back(-h2i
#ifdef CONVECTION
- hinv
#endif
);
}

col.push_back(renum[idx]);
val.push_back(
#ifdef CONVECTION
i > 0 ? (4 * h2i + hinv) : (4 * h2i)
#else
4 * h2i
#endif
);

if (i + 1 < n) {
col.push_back(renum[idx + 1]);
val.push_back(-h2i);
}

if (j + 1 < n) {
col.push_back(renum[idx + n]);
val.push_back(-h2i);
}

rhs.push_back(1);
ptr.push_back( col.size() );
}
}
Expand Down

0 comments on commit 91ccac5

Please sign in to comment.