From 7b36225bd651b48a9218cb624ec056924a9170c9 Mon Sep 17 00:00:00 2001 From: Max Luebke Date: Tue, 19 Apr 2022 10:49:18 +0200 Subject: [PATCH] Update app to new API --- app/main_1D.cpp | 6 +++--- app/main_2D.cpp | 10 +++++----- app/main_2D_mdl.cpp | 22 +++++++++++----------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/app/main_1D.cpp b/app/main_1D.cpp index b2423f2..e908039 100644 --- a/app/main_1D.cpp +++ b/app/main_1D.cpp @@ -20,7 +20,7 @@ int main(int argc, char *argv[]) { // create input + diffusion coefficients for each grid cell std::vector alpha(n, 1 * pow(10, -1)); std::vector field(n, 1 * std::pow(10, -6)); - std::vector bc(n, {0,0}); + std::vector bc(n + 2, {0, 0}); // create instance of diffusion module BTCSDiffusion diffu(dim); @@ -28,7 +28,7 @@ int main(int argc, char *argv[]) { diffu.setXDimensions(1, n); // set the boundary condition for the left ghost cell to dirichlet - bc[0] = {Diffusion::BC_CONSTANT, 5*std::pow(10,-6)}; + bc[1] = {Diffusion::BC_CONSTANT, 5 * std::pow(10, -6)}; // diffu.setBoundaryCondition(1, 0, BTCSDiffusion::BC_CONSTANT, // 5. * std::pow(10, -6)); @@ -44,7 +44,7 @@ int main(int argc, char *argv[]) { cout << "Iteration: " << i << "\n\n"; - for (auto & cell : field) { + for (auto &cell : field) { cout << cell << "\n"; } diff --git a/app/main_2D.cpp b/app/main_2D.cpp index 6a35bba..502ad0e 100644 --- a/app/main_2D.cpp +++ b/app/main_2D.cpp @@ -1,7 +1,7 @@ +#include // for copy, max +#include #include #include -#include // for copy, max -#include #include #include // for std #include // for vector @@ -20,7 +20,7 @@ int main(int argc, char *argv[]) { // create input + diffusion coefficients for each grid cell std::vector alpha(n * m, 1 * pow(10, -1)); std::vector field(n * m, 1 * std::pow(10, -6)); - std::vector bc(n*m, {0,0}); + std::vector bc((n + 2) * (m + 2), {0, 0}); // create instance of diffusion module BTCSDiffusion diffu(dim); @@ -28,8 +28,8 @@ int main(int argc, char *argv[]) { diffu.setXDimensions(1, n); diffu.setYDimensions(1, m); - //set inlet to higher concentration without setting bc - field[12] = 5*std::pow(10,-3); + // set inlet to higher concentration without setting bc + field[12] = 5 * std::pow(10, -3); // set timestep for simulation to 1 second diffu.setTimestep(1.); diff --git a/app/main_2D_mdl.cpp b/app/main_2D_mdl.cpp index c040cfe..f4eab0c 100644 --- a/app/main_2D_mdl.cpp +++ b/app/main_2D_mdl.cpp @@ -1,7 +1,7 @@ +#include // for copy, max +#include #include #include -#include // for copy, max -#include #include #include // for std #include // for vector @@ -20,7 +20,7 @@ int main(int argc, char *argv[]) { // create input + diffusion coefficients for each grid cell std::vector alpha(n * m, 1 * pow(10, -1)); std::vector field(n * m, 0.); - std::vector bc(n*m, {0,0}); + std::vector bc((n + 2) * (m + 2), {0, 0}); field[125500] = 1; @@ -31,13 +31,13 @@ int main(int argc, char *argv[]) { diffu.setYDimensions(1., m); // set the boundary condition for the left ghost cell to dirichlet - //diffu.setBoundaryCondition(250, 250, BTCSDiffusion::BC_CONSTANT, 1); + // diffu.setBoundaryCondition(250, 250, BTCSDiffusion::BC_CONSTANT, 1); // for (int d=0; d<5;d++){ // diffu.setBoundaryCondition(d, 0, BC_CONSTANT, .1); // } // diffu.setBoundaryCondition(1, 1, BTCSDiffusion::BC_CONSTANT, .1); // diffu.setBoundaryCondition(1, 1, BTCSDiffusion::BC_CONSTANT, .1); - + // set timestep for simulation to 1 second diffu.setTimestep(1.); @@ -45,9 +45,9 @@ int main(int argc, char *argv[]) { // First we output the initial state cout << 0; - - for (int i=0; i < m*n; i++) { - cout << "," << field[i]; + + for (int i = 0; i < m * n; i++) { + cout << "," << field[i]; } cout << endl; @@ -58,9 +58,9 @@ int main(int argc, char *argv[]) { cerr << "time elapsed: " << time << " seconds" << endl; cout << t; - - for (int i=0; i < m*n; i++) { - cout << "," << field[i]; + + for (int i = 0; i < m * n; i++) { + cout << "," << field[i]; } cout << endl; }