Skip to content
Snippets Groups Projects
Commit 0158ace2 authored by Martin Schönherr's avatar Martin Schönherr :speech_balloon:
Browse files

fixed some issues in GridGenerator

parent 8859fad5
No related branches found
No related tags found
1 merge request!72Clean up grid generator
......@@ -75,7 +75,7 @@ public:
new std::vector<GbTriFaceMesh3D::TriFace>(*mesh.getTriangles()));
const int maxLevel =
static_cast<int>(lround(8.0 + 1.3 * std::log((double)triFaces->size()))); // TODO: remove magic numbers
static_cast<int>(std::lround(8.0 + 1.3 * std::log((double)triFaces->size()))); // TODO: remove magic numbers
rootNode =
new Node<T>(T(mesh.getX1Minimum()), T(mesh.getX2Minimum()), T(mesh.getX3Minimum()), T(mesh.getX1Maximum()),
......
......@@ -37,13 +37,6 @@
Vertex::Vertex(real x, real y, real z) : x(x), y(y), z(z){}
Vertex::Vertex() { x = 0.0f; y = 0.0f; z = 0.0f; }
Vertex::Vertex(const Vertex& v)
{
this->x = v.x;
this->y = v.y;
this->z = v.z;
}
real Vertex::getEuclideanDistanceTo(const Vertex &w) const
{
return vf::Math::sqrtReal((x - w.x)*(x - w.x) + (y - w.y)*(y - w.y) + (z - w.z)*(z - w.z));
......
......@@ -47,7 +47,6 @@ public:
Vertex(real x, real y, real z);
Vertex();
Vertex(const Vertex& v);
~Vertex() {}
real getEuclideanDistanceTo(const Vertex &w) const;
......
......@@ -37,6 +37,7 @@
#include <iostream>
#include <omp.h>
#include <sstream>
#include <cmath>
#include "global.h"
......@@ -383,7 +384,7 @@ void GridImp::fixRefinementIntoWall(uint xIndex, uint yIndex, uint zIndex, int d
//////////////////////////////////////////////////////////////////////////
real dx, dy, dz;
real dx{ 0.0 }, dy{ 0.0 }, dz{ 0.0 };
if ( dir == 1 ){ dx = this->delta; dy = 0.0; dz = 0.0; }
else if ( dir == -1 ){ dx = - this->delta; dy = 0.0; dz = 0.0; }
......@@ -996,7 +997,7 @@ real GridImp::getNegativeNeighborCoord(bool periodicity, real startCoord, real c
{
real neighborCoords[3] = {coords[0], coords[1] , coords[2] };
neighborCoords[direction] = neighborCoords[direction] - delta;
const int neighborIndex = this->transCoordToIndex(neighborCoords[0], neighborCoords[1], neighborCoords[2]);
const uint neighborIndex = this->transCoordToIndex(neighborCoords[0], neighborCoords[1], neighborCoords[2]);
if(neighborIndex != INVALID_INDEX && !field.isStopperOutOfGrid(neighborIndex) && !field.is(neighborIndex, STOPPER_OUT_OF_GRID_BOUNDARY) )
return coords[direction] - delta;
......@@ -1011,7 +1012,7 @@ real GridImp::getNegativeNeighborCoord(bool periodicity, real startCoord, real c
real GridImp::getLastFluidNode(real coords[3], int direction, real startCoord) const
{
coords[direction] = startCoord;
int index = this->transCoordToIndex(coords[0], coords[1], coords[2]);
uint index = this->transCoordToIndex(coords[0], coords[1], coords[2]);
while (index != INVALID_INDEX && !field.isFluid(index))
{
coords[direction] -= delta;
......@@ -1702,13 +1703,13 @@ BoundingBox GridImp::getBoundingBoxOnNodes(Triangle &triangle) const
real minX, maxX, minY, maxY, minZ, maxZ;
triangle.setMinMax(minX, maxX, minY, maxY, minZ, maxZ);
int minXIndex = lround(floor((minX - this->startX) / this->delta)) - 1;
int minYIndex = lround(floor((minY - this->startY) / this->delta)) - 1;
int minZIndex = lround(floor((minZ - this->startZ) / this->delta)) - 1;
int minXIndex = std::lround(floor((minX - this->startX) / this->delta)) - 1;
int minYIndex = std::lround(floor((minY - this->startY) / this->delta)) - 1;
int minZIndex = std::lround(floor((minZ - this->startZ) / this->delta)) - 1;
int maxXIndex = lround(ceil((maxX - this->startX) / this->delta)) + 1;
int maxYIndex = lround(ceil((maxY - this->startY) / this->delta)) + 1;
int maxZIndex = lround(ceil((maxZ - this->startZ) / this->delta)) + 1;
int maxXIndex = std::lround(ceil((maxX - this->startX) / this->delta)) + 1;
int maxYIndex = std::lround(ceil((maxY - this->startY) / this->delta)) + 1;
int maxZIndex = std::lround(ceil((maxZ - this->startZ) / this->delta)) + 1;
minX = this->startX + minXIndex * this->delta;
minY = this->startY + minYIndex * this->delta;
......@@ -1759,18 +1760,19 @@ real GridImp::getMaximumOnNodes(const real &maxExact, const real &decimalStart,
return maxNode;
}
uint GridImp::getXIndex(real x) const {
return lround((x - startX) / delta);
uint GridImp::getXIndex(real x) const
{
return std::lround((x - startX) / delta);
}
uint GridImp::getYIndex(real y) const
{
return lround((y - startY) / delta);
{
return std::lround((y - startY) / delta);
}
uint GridImp::getZIndex(real z) const
{
return lround((z - startZ) / delta);
{
return std::lround((z - startZ) / delta);
}
real GridImp::getDelta() const
......@@ -1956,8 +1958,6 @@ void GridImp::getNodeValues(real *xCoords, real *yCoords, real *zCoords, uint *n
const uint neighborZIndex = uint(this->neighborIndexZ[i] + 1);
const uint neighborNegativeIndex = uint(this->neighborIndexNegative[i] + 1);
const char type2 = this->field.getFieldEntry(i);
const uint type = uint(this->field.isFluid(i) ? GEOFLUID : GEOSOLID);
xCoords[nodeNumber + 1] = x;
......
......@@ -33,6 +33,7 @@
#include "GridInterface.h"
#include <iostream>
#include <cstring>
#include "grid/distributions/D3Q27.h"
#include "grid/GridImp.h"
......@@ -164,7 +165,7 @@ void GridInterface::findInterfaceFC(const uint& indexOnCoarseGrid, GridImp* coar
for (const auto dir : coarseGrid->distribution)
{
const int neighborIndex = coarseGrid->transCoordToIndex(x + dir[0] * coarseGrid->getDelta(), y + dir[1] * coarseGrid->getDelta(), z + dir[2] * coarseGrid->getDelta());
const uint neighborIndex = coarseGrid->transCoordToIndex(x + dir[0] * coarseGrid->getDelta(), y + dir[1] * coarseGrid->getDelta(), z + dir[2] * coarseGrid->getDelta());
if (neighborIndex != INVALID_INDEX)
{
const bool neighborBelongsToCoarseToFineInterpolationCell = coarseGrid->getField().isCoarseToFineNode(neighborIndex);
......@@ -195,7 +196,7 @@ void GridInterface::findOverlapStopper(const uint& indexOnCoarseGrid, GridImp* c
if (indexOnFineGridFC == -1)
return;
real x, y, z;
real x, y, z;
coarseGrid->transIndexToCoords(indexOnCoarseGrid, x, y, z);
bool neighborBelongsToFineToCoarseInterpolationCell = false;
......@@ -204,7 +205,7 @@ void GridInterface::findOverlapStopper(const uint& indexOnCoarseGrid, GridImp* c
//if (dir[0] > 0 || dir[1] > 0 || dir[2] > 0) //only Esoteric Twist stopper, not perfectly implemented
// continue; //should not be here, should be made conditional
const int neighborIndex = coarseGrid->transCoordToIndex(x + dir[0] * coarseGrid->getDelta(), y + dir[1] * coarseGrid->getDelta(), z + dir[2] * coarseGrid->getDelta());
const uint neighborIndex = coarseGrid->transCoordToIndex(x + dir[0] * coarseGrid->getDelta(), y + dir[1] * coarseGrid->getDelta(), z + dir[2] * coarseGrid->getDelta());
neighborBelongsToFineToCoarseInterpolationCell = neighborIndex != INVALID_INDEX ? coarseGrid->getField().isFineToCoarseNode(neighborIndex) : false;
if (neighborBelongsToFineToCoarseInterpolationCell)
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment