Refactor variable names

This commit is contained in:
Max Luebke 2022-01-20 11:01:20 +01:00
parent e675381683
commit 5606b559c7
3 changed files with 8 additions and 8 deletions

View File

@ -17,7 +17,7 @@ BTCSDiffusion::BTCSDiffusion(unsigned int dim) : grid_dim(dim) {
assert(dim <= 3); assert(dim <= 3);
grid_cells.resize(dim, 1); grid_cells.resize(dim, 1);
spatial_discretization.resize(dim, 1); domain_size.resize(dim, 1);
deltas.resize(dim, 1); deltas.resize(dim, 1);
} }
@ -25,7 +25,7 @@ std::vector<int> BTCSDiffusion::getNumberOfGridCells() {
return this->grid_cells; return this->grid_cells;
} }
std::vector<int> BTCSDiffusion::getSpatialDiscretization() { std::vector<int> BTCSDiffusion::getSpatialDiscretization() {
return this->spatial_discretization; return this->domain_size;
} }
void BTCSDiffusion::setNumberOfGridCells(std::vector<int> &n_grid) { void BTCSDiffusion::setNumberOfGridCells(std::vector<int> &n_grid) {
grid_cells = n_grid; grid_cells = n_grid;
@ -33,14 +33,14 @@ void BTCSDiffusion::setNumberOfGridCells(std::vector<int> &n_grid) {
updateInternals(); updateInternals();
} }
void BTCSDiffusion::setSpatialDiscretization(std::vector<int> &s_grid) { void BTCSDiffusion::setSpatialDiscretization(std::vector<int> &s_grid) {
spatial_discretization = s_grid; domain_size = s_grid;
assert(spatial_discretization.size() == grid_dim); assert(domain_size.size() == grid_dim);
updateInternals(); updateInternals();
} }
void BTCSDiffusion::updateInternals() { void BTCSDiffusion::updateInternals() {
for (int i = 0; i < grid_dim; i++) { for (int i = 0; i < grid_dim; i++) {
deltas[i] = (double)spatial_discretization[i] / grid_cells[i]; deltas[i] = (double)domain_size[i] / grid_cells[i];
} }
switch (grid_dim) { switch (grid_dim) {

View File

@ -141,7 +141,7 @@ private:
int grid_dim; int grid_dim;
std::vector<int> grid_cells; std::vector<int> grid_cells;
std::vector<int> spatial_discretization; std::vector<int> domain_size;
std::vector<double> deltas; std::vector<double> deltas;
}; };

View File

@ -13,7 +13,7 @@ int main(int argc, char *argv[]) {
// create input + diffusion coefficients for each grid cell // create input + diffusion coefficients for each grid cell
std::vector<double> alpha(n, 1 * pow(10, -1)); std::vector<double> alpha(n, 1 * pow(10, -1));
std::vector<double> input(n, 1 * std::pow(10, -6)); std::vector<double> field(n, 1 * std::pow(10, -6));
// create instance of diffusion module // create instance of diffusion module
BTCSDiffusion diffu(dim); BTCSDiffusion diffu(dim);
@ -34,7 +34,7 @@ int main(int argc, char *argv[]) {
// loop 100 times // loop 100 times
// output is currently generated by the method itself // output is currently generated by the method itself
for (int i = 0; i < 100; i++) { for (int i = 0; i < 100; i++) {
diffu.simulate(input, alpha); diffu.simulate(field, alpha);
} }
return 0; return 0;