Commit ac063d4e by Erik Strand

### Switch to periodic boundary conditions

parent 832649ce
 ... ... @@ -78,7 +78,7 @@ void GlutGrapher::display() const { //.................................................................................................. void GlutGrapher::idle() { bool const wait_to_start = true; bool const wait_to_start = false; if (wait_to_start && frame_ == 0) { std::cout << "Press enter to start a 5 second countdown" << std::endl; do {} while (std::cin.get() != '\n'); ... ...
 ... ... @@ -12,12 +12,18 @@ void mouse(int, int, int, int) { exit(0); } //-------------------------------------------------------------------------------------------------- SparseMatrix d_x_first_order(int32_t const dim) { return MatrixBuilder(dim).stripe(0, -1).stripe(1, 1); // stripe(0, -1) means add a stripe of -1s on the diagonal // stripe(1, 1) means add a stripe of 1s one above the diagonal // element(dim - 1, 0, 1) means add a single 1 at row dim - 1 and column 0 return MatrixBuilder(dim).stripe(0, -1).stripe(1, 1).element(dim - 1, 0, 1); } //-------------------------------------------------------------------------------------------------- SparseMatrix d_x2_first_order(int32_t const dim) { return MatrixBuilder(dim).stripe(-1, 1).stripe(0, -2).stripe(1, 1); return MatrixBuilder(dim) .stripe(-1, 1).element(0, dim - 1, 1) .stripe(0, -2) .stripe(1, 1).element(dim - 1, 0, 1); } //-------------------------------------------------------------------------------------------------- ... ... @@ -49,7 +55,7 @@ int main(int, char**) { Scalar const alpha = advection_coefficient * h / d; Scalar const delta = diffusion_coefficient * h / (d * d); // transport matrices (assumes dirichlet boundary conditions identically zero) // transport matrices SparseMatrix const advection_matrix = alpha * d_x_first_order(dim); SparseMatrix const diffusion_matrix = delta * d_x2_first_order(dim); SparseMatrix const reaction_matrix = h * diagonal_ones(dim) * reaction_coefficients.asDiagonal(); ... ...
 ... ... @@ -15,6 +15,12 @@ MatrixBuilder& MatrixBuilder::stripe(int32_t k, Scalar value) { return *this; } //.................................................................................................. MatrixBuilder& MatrixBuilder::element(int32_t row, int32_t col, Scalar value) { triplets_.emplace_back(row, col, value); return *this; } //.................................................................................................. MatrixBuilder::operator SparseMatrix() const { SparseMatrix result(n_, n_); ... ...
 ... ... @@ -11,8 +11,11 @@ namespace simucene { class MatrixBuilder { public: MatrixBuilder(int32_t n): n_(n) {} // k = 0 means on the diagonal, 1 means one above the diagonal, -1 one below, etc. MatrixBuilder& stripe(int32_t k, Scalar value); MatrixBuilder& element(int32_t row, int32_t col, Scalar value); operator SparseMatrix() const; private: ... ...
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!