diff options
Export and plot cylinder2d measurements
-rw-r--r-- | apps/adrian/cylinder2d/optimized_grid/cylinder2d.cpp | 28 |
1 files 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<T,DESCRIPTOR>& grid, vtmWriter.write(iT); } -void takeMeasurements(Grid2D<T,DESCRIPTOR>& grid) +void takeMeasurements(Grid2D<T,DESCRIPTOR>& 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<T,DESCRIPTOR>& 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<T> 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); } } |