Skip to content

Commit

Permalink
✔️ Add and Pass Unit Tests: Rotated STL Openings
Browse files Browse the repository at this point in the history
  • Loading branch information
micheltakken committed Aug 15, 2024
1 parent f9e5852 commit ce118d1
Show file tree
Hide file tree
Showing 5 changed files with 411 additions and 853 deletions.
23 changes: 20 additions & 3 deletions src/simulation/simulators/olbContinuous.hh
Original file line number Diff line number Diff line change
Expand Up @@ -278,12 +278,24 @@ void lbmSimulator<T>::initNsLattice (const T omega) {
template<typename T>
void lbmSimulator<T>::readGeometryStl (const T dx, const bool print) {

std::vector<T> correction ({0.0, 0.0});
T correction[2]= {0.0, 0.0};

stlReader = std::make_shared<olb::STLreader<T>>(this->stlFile, dx);
auto min = stlReader->getMesh().getMin();
auto max = stlReader->getMesh().getMax();

if (max[0] - min[0] > this->cfdModule->getSize()[0] + 1e-9 ||
max[1] - min[1] > this->cfdModule->getSize()[1] + 1e-9)
{
std::string sizeMessage;
sizeMessage = "\nModule size:\t[" + std::to_string(this->cfdModule->getSize()[0]) +
", " + std::to_string(this->cfdModule->getSize()[1]) + "]" +
"\nSTL size:\t[" + std::to_string(max[0] - min[0]) +
", " + std::to_string(max[1] - min[1]) + "]";

throw std::runtime_error("The module size is too small for the STL geometry." + sizeMessage);
}

for (unsigned char d : {0, 1}) {
if (fmod(min[d], dx) < 1e-12) {
if (fmod(max[d] + 0.5*dx, dx) < 1e-12) {
Expand Down Expand Up @@ -328,11 +340,16 @@ template<typename T>
void lbmSimulator<T>::readOpenings (const T dx) {

int extendMargin = 4;
auto min = stlReader->getMesh().getMin();

T stlShift[2];
stlShift[0] = this->cfdModule->getPosition()[0] - min[0];
stlShift[1] = this->cfdModule->getPosition()[1] - min[1];

for (auto& [key, Opening] : this->moduleOpenings ) {
// The unit vector pointing to the extend (opposite origin) of the opening
T x_origin = Opening.node->getPosition()[0] - 0.5*extendMargin*dx;
T y_origin = Opening.node->getPosition()[1] - 0.5*Opening.width;
T x_origin = Opening.node->getPosition()[0] -stlShift[0] -0.5*extendMargin*dx;
T y_origin = Opening.node->getPosition()[1] -stlShift[1] -0.5*Opening.width;

// The unit vector pointing to the extend
T x_extend = extendMargin*dx;
Expand Down
3 changes: 2 additions & 1 deletion tests/hybrid/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
set(SOURCE_LIST
Hybrid.test.cpp
Hybrid.test.cpp
Opening.test.cpp
)

target_sources(${TARGET_NAME} PRIVATE ${SOURCE_LIST})
Expand Down
Loading

0 comments on commit ce118d1

Please sign in to comment.