From f4069563f596b35d90a6a3b941011ebd7cf191b9 Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Wed, 6 Feb 2019 14:18:14 +0100 Subject: Export and plot cylinder2d measurements --- .../cylinder2d/optimized_grid/cylinder2d.cpp | 28 ++++++++++++---------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/apps/adrian/cylinder2d/optimized_grid/cylinder2d.cpp b/apps/adrian/cylinder2d/optimized_grid/cylinder2d.cpp index 34294ee..e5a934c 100644 --- a/apps/adrian/cylinder2d/optimized_grid/cylinder2d.cpp +++ b/apps/adrian/cylinder2d/optimized_grid/cylinder2d.cpp @@ -214,12 +214,8 @@ void getResults(Grid2D& grid, vtmWriter.write(iT); } -void takeMeasurements(Grid2D& grid) +void takeMeasurements(Grid2D& grid, int iT, bool print=true) { - static T maxDrag = 0.0; - - OstreamManager clout(std::cout,"measurement"); - auto& sLattice = grid.getSuperLattice(); auto& sGeometry = grid.getSuperGeometry(); auto& converter = grid.getConverter(); @@ -236,17 +232,23 @@ void takeMeasurements(Grid2D& grid) T pressureInFrontOfCylinder, pressureBehindCylinder; intpolatePressure(&pressureInFrontOfCylinder, point1); intpolatePressure(&pressureBehindCylinder, point2); - - T pressureDrop = pressureInFrontOfCylinder - pressureBehindCylinder; - clout << "pressureDrop=" << pressureDrop; + const T pressureDrop = pressureInFrontOfCylinder - pressureBehindCylinder; const int input[3] {}; T drag[dragF.getTargetDim()] {}; dragF(drag, input); - if (drag[0] > maxDrag) { - maxDrag = drag[0]; - }; - clout << "; drag=" << drag[0] << "; maxDrag: " << maxDrag << "; lift=" << drag[1] << endl; + + static Gnuplot gplot("results"); + gplot.setData(converter.getPhysTime(iT), {drag[0], drag[1], pressureDrop}, {"drag", "lift", "deltaP"}, "bottom right", {'l','l'}); + gplot.writePNG(); + + if (print) { + OstreamManager clout(std::cout, "measurement"); + clout << "pressureDrop=" << pressureDrop + << "; drag=" << drag[0] + << "; lift=" << drag[1] + << endl; + } } int main(int argc, char* argv[]) @@ -354,7 +356,7 @@ int main(int argc, char* argv[]) getResults(grid, id, iT); }); - takeMeasurements(fineGrid3); + takeMeasurements(fineGrid3, iT); } } -- cgit v1.2.3