mirror of
https://git.gfz-potsdam.de/naaice/tug.git
synced 2025-12-13 17:38:23 +01:00
Update getter/setters for grid specification
This commit is contained in:
parent
38b4bd0fb2
commit
9bce8be092
@ -22,23 +22,40 @@ BTCSDiffusion::BTCSDiffusion(unsigned int dim) : grid_dim(dim) {
|
||||
deltas.resize(dim, 1);
|
||||
}
|
||||
|
||||
std::vector<int> BTCSDiffusion::getNumberOfGridCells() {
|
||||
return this->grid_cells;
|
||||
}
|
||||
std::vector<int> BTCSDiffusion::getSpatialDiscretization() {
|
||||
return this->domain_size;
|
||||
}
|
||||
void BTCSDiffusion::setNumberOfGridCells(std::vector<int> &n_grid) {
|
||||
grid_cells = n_grid;
|
||||
assert(grid_cells.size() == grid_dim);
|
||||
void BTCSDiffusion::setXDimensions(unsigned int domain_size,
|
||||
unsigned int n_grid_cells) {
|
||||
assert(this->grid_dim > 0);
|
||||
this->domain_size[0] = domain_size;
|
||||
this->grid_cells[0] = n_grid_cells;
|
||||
|
||||
updateInternals();
|
||||
}
|
||||
void BTCSDiffusion::setSpatialDiscretization(std::vector<int> &s_grid) {
|
||||
domain_size = s_grid;
|
||||
assert(domain_size.size() == grid_dim);
|
||||
|
||||
void BTCSDiffusion::setYDimensions(unsigned int domain_size,
|
||||
unsigned int n_grid_cells) {
|
||||
assert(this->grid_dim > 1);
|
||||
this->domain_size[1] = domain_size;
|
||||
this->grid_cells[1] = n_grid_cells;
|
||||
|
||||
updateInternals();
|
||||
}
|
||||
|
||||
void BTCSDiffusion::setZDimensions(unsigned int domain_size,
|
||||
unsigned int n_grid_cells) {
|
||||
assert(this->grid_dim > 2);
|
||||
this->domain_size[2] = domain_size;
|
||||
this->grid_cells[2] = n_grid_cells;
|
||||
|
||||
updateInternals();
|
||||
}
|
||||
|
||||
unsigned int BTCSDiffusion::getXGridCellsN() { return this->grid_cells[0]; }
|
||||
unsigned int BTCSDiffusion::getYGridCellsN() { return this->grid_cells[1]; }
|
||||
unsigned int BTCSDiffusion::getZGridCellsN() { return this->grid_cells[2]; }
|
||||
unsigned int BTCSDiffusion::getXDomainSize() { return this->domain_size[0]; }
|
||||
unsigned int BTCSDiffusion::getYDomainSize() { return this->domain_size[1]; }
|
||||
unsigned int BTCSDiffusion::getZDomainSize() { return this->domain_size[2]; }
|
||||
|
||||
void BTCSDiffusion::updateInternals() {
|
||||
for (int i = 0; i < grid_dim; i++) {
|
||||
deltas[i] = (double)domain_size[i] / grid_cells[i];
|
||||
@ -50,7 +67,7 @@ void BTCSDiffusion::updateInternals() {
|
||||
cells *= (grid_cells[i] + 2);
|
||||
}
|
||||
|
||||
bc.resize(cells, {BTCSDiffusion::BC_CLOSED,0});
|
||||
bc.resize(cells, {BTCSDiffusion::BC_CLOSED, 0});
|
||||
}
|
||||
// BTCSDiffusion::BTCSDiffusion(int x) : n_x(x) {
|
||||
// this->grid_dim = 1;
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
|
||||
#include <Eigen/Sparse>
|
||||
#include <tuple>
|
||||
#include <type_traits>
|
||||
#include <vector>
|
||||
|
||||
/*!
|
||||
@ -70,11 +71,16 @@ public:
|
||||
*/
|
||||
BTCSDiffusion(unsigned int dim);
|
||||
|
||||
std::vector<int> getNumberOfGridCells();
|
||||
std::vector<int> getSpatialDiscretization();
|
||||
void setNumberOfGridCells(std::vector<int> &n_grid);
|
||||
void setSpatialDiscretization(std::vector<int> &s_grid);
|
||||
void setXDimensions(unsigned int domain_size, unsigned int n_grid_cells);
|
||||
void setYDimensions(unsigned int domain_size, unsigned int n_grid_cells);
|
||||
void setZDimensions(unsigned int domain_size, unsigned int n_grid_cells);
|
||||
|
||||
unsigned int getXGridCellsN();
|
||||
unsigned int getYGridCellsN();
|
||||
unsigned int getZGridCellsN();
|
||||
unsigned int getXDomainSize();
|
||||
unsigned int getYDomainSize();
|
||||
unsigned int getZDomainSize();
|
||||
// /*!
|
||||
// * Currently not implemented: Create 2D-diffusion module.
|
||||
// *
|
||||
@ -127,7 +133,8 @@ private:
|
||||
void simulate2D(std::vector<double> &c);
|
||||
void simulate3D(std::vector<double> &c);
|
||||
|
||||
inline double getBCFromFlux(boundary_condition bc, double nearest_value, double neighbor_alpha);
|
||||
inline double getBCFromFlux(boundary_condition bc, double nearest_value,
|
||||
double neighbor_alpha);
|
||||
|
||||
void updateInternals();
|
||||
|
||||
@ -140,8 +147,8 @@ private:
|
||||
double time_step;
|
||||
|
||||
int grid_dim;
|
||||
std::vector<int> grid_cells;
|
||||
std::vector<int> domain_size;
|
||||
std::vector<unsigned int> grid_cells;
|
||||
std::vector<unsigned int> domain_size;
|
||||
std::vector<double> deltas;
|
||||
};
|
||||
|
||||
|
||||
@ -18,11 +18,7 @@ int main(int argc, char *argv[]) {
|
||||
// create instance of diffusion module
|
||||
BTCSDiffusion diffu(dim);
|
||||
|
||||
std::vector<int> vec_n = diffu.getNumberOfGridCells();
|
||||
|
||||
vec_n[0] = n;
|
||||
|
||||
diffu.setNumberOfGridCells(vec_n);
|
||||
diffu.setXDimensions(1, n);
|
||||
|
||||
// set the boundary condition for the left ghost cell to dirichlet
|
||||
diffu.setBoundaryCondition(0, 5. * std::pow(10, -6),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user