refactor: core adjustment to Boundary class
perf: const qualification of local variables
This commit is contained in:
parent
f0d5220a48
commit
edaad7cc04
@ -81,8 +81,8 @@ public:
|
|||||||
double getValue();
|
double getValue();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BC_TYPE type;
|
BC_TYPE type{BC_TYPE_CLOSED};
|
||||||
double value;
|
double value{-1};
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -1,20 +1,13 @@
|
|||||||
#include "TugUtils.hpp"
|
#include "TugUtils.hpp"
|
||||||
|
|
||||||
#include <iostream>
|
#include <cstddef>
|
||||||
#include <omp.h>
|
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <tug/Boundary.hpp>
|
#include <tug/Boundary.hpp>
|
||||||
|
|
||||||
BoundaryElement::BoundaryElement() {
|
BoundaryElement::BoundaryElement() {}
|
||||||
|
|
||||||
this->type = BC_TYPE_CLOSED;
|
BoundaryElement::BoundaryElement(double _value)
|
||||||
this->value = -1; // without meaning in closed case
|
: value(_value), type(BC_TYPE_CONSTANT) {}
|
||||||
}
|
|
||||||
|
|
||||||
BoundaryElement::BoundaryElement(double value) {
|
|
||||||
this->type = BC_TYPE_CONSTANT;
|
|
||||||
this->value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
void BoundaryElement::setType(BC_TYPE type) { this->type = type; }
|
void BoundaryElement::setType(BC_TYPE type) { this->type = type; }
|
||||||
|
|
||||||
@ -64,12 +57,9 @@ void Boundary::setBoundarySideClosed(BC_SIDE side) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int n;
|
const bool is_vertical = side == BC_SIDE_LEFT || side == BC_SIDE_RIGHT;
|
||||||
if (side == BC_SIDE_LEFT || side == BC_SIDE_RIGHT) {
|
const int n = is_vertical ? grid.getRow() : grid.getCol();
|
||||||
n = grid.getRow();
|
|
||||||
} else {
|
|
||||||
n = grid.getCol();
|
|
||||||
}
|
|
||||||
this->boundaries[side] = std::vector<BoundaryElement>(n, BoundaryElement());
|
this->boundaries[side] = std::vector<BoundaryElement>(n, BoundaryElement());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,13 +72,11 @@ void Boundary::setBoundarySideConstant(BC_SIDE side, double value) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int n;
|
const bool is_vertical = side == BC_SIDE_LEFT || side == BC_SIDE_RIGHT;
|
||||||
if (side == BC_SIDE_LEFT || side == BC_SIDE_RIGHT) {
|
const int n = is_vertical ? grid.getRow() : grid.getCol();
|
||||||
n = grid.getRow();
|
|
||||||
} else {
|
this->boundaries[side] =
|
||||||
n = grid.getCol();
|
std::vector<BoundaryElement>(n, BoundaryElement(value));
|
||||||
}
|
|
||||||
this->boundaries[side] = std::vector<BoundaryElement>(n, BoundaryElement(value));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Boundary::setBoundaryElementClosed(BC_SIDE side, int index) {
|
void Boundary::setBoundaryElementClosed(BC_SIDE side, int index) {
|
||||||
@ -121,7 +109,7 @@ const std::vector<BoundaryElement> Boundary::getBoundarySide(BC_SIDE side) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Eigen::VectorXd Boundary::getBoundarySideValues(BC_SIDE side) {
|
Eigen::VectorXd Boundary::getBoundarySideValues(BC_SIDE side) {
|
||||||
int length = boundaries[side].size();
|
const std::size_t length = boundaries[side].size();
|
||||||
Eigen::VectorXd values(length);
|
Eigen::VectorXd values(length);
|
||||||
|
|
||||||
for (int i = 0; i < length; i++) {
|
for (int i = 0; i < length; i++) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user