Commit 0de2e1f6 authored by Lukas Werner's avatar Lukas Werner
Browse files

Added timing functionality, minor changes

parent 77a654fb
Pipeline #6904 failed with stage
in 33 minutes and 51 seconds
......@@ -78,6 +78,7 @@ int main( int argc, char ** argv )
real_t radius = real_c(0.4);
real_t vMax = real_c(1.0);
int simulationSteps = 10;
size_t raytraceSkippedSteps = 10;
real_t dt = real_c(0.01);
uint_t blocks_x = 2, blocks_y = 2, blocks_z = 2;
......@@ -88,6 +89,8 @@ int main( int argc, char ** argv )
spacing = confBlock.getParameter<real_t>("spacing", spacing);
radius = confBlock.getParameter<real_t>("radius", radius);
simulationSteps = confBlock.getParameter<int>("simulationSteps", simulationSteps);
raytraceSkippedSteps = confBlock.getParameter<size_t>("raytraceSkippedSteps", raytraceSkippedSteps);
blocks_x = confBlock.getParameter<uint_t>("blocks_x", blocks_x);
blocks_y = confBlock.getParameter<uint_t>("blocks_y", blocks_y);
blocks_z = confBlock.getParameter<uint_t>("blocks_z", blocks_z);
......@@ -191,7 +194,7 @@ int main( int argc, char ** argv )
WALBERLA_LOG_INFO_ON_ROOT("*** SIMULATION - START ***");
//! [GameLoop]
for (int i=0; i < simulationSteps; ++i)
for (size_t i=0; i < simulationSteps; ++i)
{
if( i % 10 == 0 )
{
......@@ -200,6 +203,10 @@ int main( int argc, char ** argv )
cr.timestep( real_c(dt) );
syncNextNeighbors<BodyTypeTuple>(*forest, storageID);
if (i%raytraceSkippedSteps == 0) {
raytracer.rayTrace<BodyTypeTuple>(i);
}
}
//! [GameLoop]
WALBERLA_LOG_INFO_ON_ROOT("*** SIMULATION - END ***");
......@@ -218,9 +225,9 @@ int main( int argc, char ** argv )
WALBERLA_LOG_INFO( "mean velocity: " << meanVelocity );
//! [PostProcessing]
WALBERLA_LOG_INFO_ON_ROOT("*** RAYTRACING - START ***");
raytracer.rayTrace<BodyTypeTuple>(0);
WALBERLA_LOG_INFO_ON_ROOT("*** RAYTRACING - END ***");
//WALBERLA_LOG_INFO_ON_ROOT("*** RAYTRACING - START ***");
//raytracer.rayTrace<BodyTypeTuple>(0);
//WALBERLA_LOG_INFO_ON_ROOT("*** RAYTRACING - END ***");
// für einzelne sphere vtks: -> SphereVtkOutput.cpp
......
......@@ -106,9 +106,9 @@ void Raytracer::setupView_() {
/*!\brief Writes the tBuffer to a file in the tBuffer output directory.
* \param tBuffer Buffer with t values as generated in rayTrace(...).
*/
void Raytracer::writeTBufferToFile(const std::map<Coordinates, real_t, CoordinatesComparator>& tBuffer) const {
void Raytracer::writeTBufferToFile(const std::map<Coordinates, real_t, CoordinatesComparator>& tBuffer, const size_t timestep) const {
mpi::MPIRank rank = mpi::MPIManager::instance()->rank();
std::string fileName = "tbuffer_" + std::to_string(rank) + ".ppm";
std::string fileName = "tbuffer_" + std::to_string(timestep) + "+" + std::to_string(rank) + ".ppm";
writeTBufferToFile(tBuffer, fileName);
}
......
......@@ -26,9 +26,14 @@
#include <core/mpi/all.h>
#include <core/config/Config.h>
#include <boost/filesystem.hpp>
#include <core/timing/TimingTree.h>
#include "Ray.h"
#include "Intersects.h"
using namespace walberla;
using namespace walberla::pe;
using namespace walberla::timing;
namespace walberla {
namespace pe {
namespace raytracing {
......@@ -123,7 +128,7 @@ public:
void rayTrace(const size_t timestep) const;
private:
void writeTBufferToFile(const std::map<Coordinates, real_t, CoordinatesComparator>& tBuffer) const;
void writeTBufferToFile(const std::map<Coordinates, real_t, CoordinatesComparator>& tBuffer, const size_t timestep) const;
void writeTBufferToFile(const std::map<Coordinates, real_t, CoordinatesComparator>& tBuffer, const std::string& fileName) const;
//@}
};
......@@ -224,17 +229,18 @@ inline void Raytracer::setTBufferOutputDirectory(const std::string& path) {
*/
template <typename BodyTypeTuple>
void Raytracer::rayTrace(const size_t timestep) const {
WcTimingPool tp;
std::map<Coordinates, real_t, CoordinatesComparator> tBuffer; // t values for each pixel
std::map<Coordinates, walberla::id_t, CoordinatesComparator> idBuffer; // ids of the intersected body for each pixel
std::vector<BodyIntersectionInfo> intersections; // contains for each pixel information about an intersection, if existent
std::map<Coordinates, BodyIntersectionInfo, CoordinatesComparator> localPixelIntersectionMap;
std::map<Coordinates, BodyIntersectionInfo, CoordinatesComparator> localPixelIntersectionMap; // contains intersection info indexed by the coordinates of the pixel which was hit
real_t t, t_closest;
walberla::id_t id_closest;
RigidBody* body_closest = NULL;
Ray ray(cameraPosition_, Vec3(1,0,0));
IntersectsFunctor func(ray, t);
tp["Raytracing"].start();
for (size_t x = 0; x < pixelsHorizontal_; x++) {
for (size_t y = 0; y < pixelsVertical_; y++) {
//WALBERLA_LOG_INFO(x << "/" << y);
......@@ -286,6 +292,9 @@ void Raytracer::rayTrace(const size_t timestep) const {
}
//std::cout << std::endl;
}
tp["Raytracing"].end();
tp["Reduction"].start();
// intersections synchronisieren
mpi::SendBuffer sendBuffer;
......@@ -340,11 +349,22 @@ void Raytracer::rayTrace(const size_t timestep) const {
visibleBodyIDs[info.second.bodySystemID] = true;
}
tp["Reduction"].end();
WALBERLA_LOG_INFO("#particles visible: " << visibleBodyIDs.size());
//WALBERLA_LOG_INFO_ON_ROOT("#gatheredIntersections: " << gatheredIntersections.size());
WALBERLA_LOG_INFO_ON_ROOT("#gatheredIntersections: " << gatheredIntersections.size());
auto tpReducedTotal = tp.getReduced(WcTimingPool::REDUCE_TOTAL);
auto tpReducedMax = tp.getReduced(WcTimingPool::REDUCE_MAX);
WALBERLA_ROOT_SECTION() {
WALBERLA_LOG_INFO("Timing total:");
tpReducedTotal->print(std::cout);
WALBERLA_LOG_INFO("Timing max.:");
tpReducedMax->print(std::cout);
}
if (getTBufferOutputEnabled()) {
writeTBufferToFile(tBuffer);
writeTBufferToFile(tBuffer, timestep);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment