Skip to content
Snippets Groups Projects
Commit 9ec7a961 authored by Anna Wellmann's avatar Anna Wellmann
Browse files

Use parH instead of para in NeighborDebugWriter

parent eb0bcb57
No related branches found
No related tags found
1 merge request!182Fix bug and add some tests in NeighborDebugWriter
...@@ -16,30 +16,30 @@ ...@@ -16,30 +16,30 @@
namespace NeighborDebugWriter namespace NeighborDebugWriter
{ {
inline void writeNeighborLinkLines(Parameter *para, int level, int direction, const std::string &name, inline void writeNeighborLinkLines(LBMSimulationParameter *parH, int direction, const std::string &name,
WbWriter *writer) WbWriter *writer)
{ {
VF_LOG_INFO("Write node links in direction {}.", direction); VF_LOG_INFO("Write node links in direction {}.", direction);
const unsigned long long numberOfNodes = para->getParH(level)->numberOfNodes; const unsigned long long numberOfNodes = parH->numberOfNodes;
std::vector<UbTupleFloat3> nodes; std::vector<UbTupleFloat3> nodes;
nodes.reserve(numberOfNodes); nodes.reserve(numberOfNodes);
std::vector<UbTupleInt2> cells; std::vector<UbTupleInt2> cells;
cells.reserve(numberOfNodes/2); cells.reserve(numberOfNodes/2);
for (size_t position = 0; position < numberOfNodes; position++) { for (size_t position = 0; position < numberOfNodes; position++) {
if (para->getParH(level)->typeOfGridNode[position] != GEO_FLUID) if (parH->typeOfGridNode[position] != GEO_FLUID)
continue; continue;
const double x1 = para->getParH(level)->coordinateX[position]; const double x1 = parH->coordinateX[position];
const double x2 = para->getParH(level)->coordinateY[position]; const double x2 = parH->coordinateY[position];
const double x3 = para->getParH(level)->coordinateZ[position]; const double x3 = parH->coordinateZ[position];
const uint positionNeighbor = getNeighborIndex(para->getParH(level).get(), (uint)position, direction); const uint positionNeighbor = getNeighborIndex(parH, (uint)position, direction);
const double x1Neighbor = para->getParH(level)->coordinateX[positionNeighbor]; const double x1Neighbor = parH->coordinateX[positionNeighbor];
const double x2Neighbor = para->getParH(level)->coordinateY[positionNeighbor]; const double x2Neighbor = parH->coordinateY[positionNeighbor];
const double x3Neighbor = para->getParH(level)->coordinateZ[positionNeighbor]; const double x3Neighbor = parH->coordinateZ[positionNeighbor];
nodes.emplace_back(float(x1), float(x2), float(x3)); nodes.emplace_back(float(x1), float(x2), float(x3));
nodes.emplace_back(float(x1Neighbor), float(x2Neighbor), float(x3Neighbor)); nodes.emplace_back(float(x1Neighbor), float(x2Neighbor), float(x3Neighbor));
...@@ -55,7 +55,7 @@ inline void writeNeighborLinkLinesDebug(Parameter *para) ...@@ -55,7 +55,7 @@ inline void writeNeighborLinkLinesDebug(Parameter *para)
for (size_t direction = vf::lbm::dir::STARTDIR; direction <= vf::lbm::dir::ENDDIR; direction++) { for (size_t direction = vf::lbm::dir::STARTDIR; direction <= vf::lbm::dir::ENDDIR; direction++) {
const std::string fileName = para->getFName() + "_" + StringUtil::toString<int>(level) + "_Link_" + const std::string fileName = para->getFName() + "_" + StringUtil::toString<int>(level) + "_Link_" +
std::to_string(direction) + "_Debug.vtk"; std::to_string(direction) + "_Debug.vtk";
writeNeighborLinkLines(para, level, (int)direction, fileName, WbWriterVtkXmlBinary::getInstance()); writeNeighborLinkLines(para->getParH(level).get(), (int)direction, fileName, WbWriterVtkXmlBinary::getInstance());
} }
} }
} }
......
...@@ -54,7 +54,7 @@ TEST_F(NeighborDebugWriterTest, writeNeighborLinkLinesOnlyFLuidNodes) ...@@ -54,7 +54,7 @@ TEST_F(NeighborDebugWriterTest, writeNeighborLinkLinesOnlyFLuidNodes)
std::vector<UbTupleFloat3> expectedNodes = { oneCoord, threeCoord, oneCoord, threeCoord, threeCoord, threeCoord }; std::vector<UbTupleFloat3> expectedNodes = { oneCoord, threeCoord, oneCoord, threeCoord, threeCoord, threeCoord };
std::vector<UbTupleInt2> expectedLines = { UbTupleInt2(0, 1), UbTupleInt2(2, 3), UbTupleInt2(4, 5) }; std::vector<UbTupleInt2> expectedLines = { UbTupleInt2(0, 1), UbTupleInt2(2, 3), UbTupleInt2(4, 5) };
NeighborDebugWriter::writeNeighborLinkLines(para.get(), level, direction, "name", &writerSpy); NeighborDebugWriter::writeNeighborLinkLines(para->getParH(level).get(), direction, "name", &writerSpy);
EXPECT_THAT(writerSpy.nodes.size(), testing::Eq(numberOfNodes * 2)); EXPECT_THAT(writerSpy.nodes.size(), testing::Eq(numberOfNodes * 2));
EXPECT_THAT(writerSpy.lines.size(), testing::Eq(numberOfNodes)); EXPECT_THAT(writerSpy.lines.size(), testing::Eq(numberOfNodes));
...@@ -71,7 +71,7 @@ TEST_F(NeighborDebugWriterTest, writeNeighborLinkLinesOneSolidNode) ...@@ -71,7 +71,7 @@ TEST_F(NeighborDebugWriterTest, writeNeighborLinkLinesOneSolidNode)
std::vector<UbTupleFloat3> expectedNodes = { oneCoord, threeCoord, oneCoord, threeCoord}; std::vector<UbTupleFloat3> expectedNodes = { oneCoord, threeCoord, oneCoord, threeCoord};
std::vector<UbTupleInt2> expectedLines = { UbTupleInt2(0, 1), UbTupleInt2(2, 3)}; std::vector<UbTupleInt2> expectedLines = { UbTupleInt2(0, 1), UbTupleInt2(2, 3)};
NeighborDebugWriter::writeNeighborLinkLines(para.get(), level, direction, "name", &writerSpy); NeighborDebugWriter::writeNeighborLinkLines(para->getParH(level).get(), direction, "name", &writerSpy);
EXPECT_THAT(writerSpy.nodes.size(), testing::Eq((numberOfNodes-1) * 2)); EXPECT_THAT(writerSpy.nodes.size(), testing::Eq((numberOfNodes-1) * 2));
EXPECT_THAT(writerSpy.lines.size(), testing::Eq(numberOfNodes-1)); EXPECT_THAT(writerSpy.lines.size(), testing::Eq(numberOfNodes-1));
......
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