Skip to content
Snippets Groups Projects
Commit 54f2c601 authored by Lukas Werner's avatar Lukas Werner
Browse files

Updated 02_ConfinedGasExtended

parent 05ee4dd6
Branches
Tags
No related merge requests found
...@@ -5,15 +5,27 @@ ConfinedGasExtended ...@@ -5,15 +5,27 @@ ConfinedGasExtended
simulationDomain < 20, 20, 20 >; simulationDomain < 20, 20, 20 >;
blocks < 2, 2, 2 >; blocks < 2, 2, 2 >;
isPeriodic < 0, 0, 0 >; isPeriodic < 0, 0, 0 >;
raytracerSkippedSteps 10;
setupRun false; setupRun false;
simulationSteps 100;
visSpacing 10;
}
Raytracing
{
image_x 640;
image_y 480;
fov_vertical 49.13;
image_output_directory .;
cameraPosition < -25, 10, 10 >;
lookAt < -5, 10, 10 >;
upVector < 0, 0, 1 >;
antiAliasFactor 2;
blockAABBIntersectionPadding 0.8;
reductionMethod MPI_REDUCE;
Lighting {
pointLightOrigin < -10, 10, 15 >;
ambientColor < 0.3, 0.3, 0.3 >;
diffuseColor < 1, 1, 1 >;
specularColor < 1, 1, 1 >;
}
} }
Raytracing {
image_x 640;
image_y 480;
fov_vertical 49.13;
tbuffer_output_directory /Users/ng/Desktop/walberla;
cameraPosition < -25, 10, 10 >;
lookAt < -5, 10, 10 >;
upVector < 0, 0, 1 >;
}
\ No newline at end of file
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include <pe/basic.h> #include <pe/basic.h>
#include <pe/statistics/BodyStatistics.h> #include <pe/statistics/BodyStatistics.h>
#include <pe/vtk/SphereVtkOutput.h> #include <pe/vtk/SphereVtkOutput.h>
#include <pe/raytracing/Raytracer.h>
#include <core/Abort.h> #include <core/Abort.h>
#include <core/Environment.h> #include <core/Environment.h>
...@@ -31,7 +32,6 @@ ...@@ -31,7 +32,6 @@
#include <core/waLBerlaBuildInfo.h> #include <core/waLBerlaBuildInfo.h>
#include <postprocessing/sqlite/SQLite.h> #include <postprocessing/sqlite/SQLite.h>
#include <vtk/VTKOutput.h> #include <vtk/VTKOutput.h>
#include <pe/raytracing/Raytracer.h>
using namespace walberla; using namespace walberla;
using namespace walberla::pe; using namespace walberla::pe;
...@@ -105,10 +105,6 @@ int main( int argc, char ** argv ) ...@@ -105,10 +105,6 @@ int main( int argc, char ** argv )
WALBERLA_LOG_INFO_ON_ROOT("visSpacing: " << visSpacing); WALBERLA_LOG_INFO_ON_ROOT("visSpacing: " << visSpacing);
const std::string path = mainConf.getParameter<std::string>("path", "vtk_out" ); const std::string path = mainConf.getParameter<std::string>("path", "vtk_out" );
WALBERLA_LOG_INFO_ON_ROOT("path: " << path); WALBERLA_LOG_INFO_ON_ROOT("path: " << path);
const int raytracerSkippedSteps = mainConf.getParameter<int>("raytracerSkippedSteps", 10 );
WALBERLA_LOG_INFO_ON_ROOT("raytracerSkippedSteps: " << raytracerSkippedSteps);
integerProperties["raytracerSkippedSteps"] = raytracerSkippedSteps;
WALBERLA_LOG_INFO_ON_ROOT("syncShadowOwners: " << syncShadowOwners); WALBERLA_LOG_INFO_ON_ROOT("syncShadowOwners: " << syncShadowOwners);
integerProperties["syncShadowOwners"] = syncShadowOwners; integerProperties["syncShadowOwners"] = syncShadowOwners;
...@@ -145,24 +141,6 @@ int main( int argc, char ** argv ) ...@@ -145,24 +141,6 @@ int main( int argc, char ** argv )
auto ccdID = forest->addBlockData(ccd::createHashGridsDataHandling( globalBodyStorage, storageID ), "CCD"); auto ccdID = forest->addBlockData(ccd::createHashGridsDataHandling( globalBodyStorage, storageID ), "CCD");
auto fcdID = forest->addBlockData(fcd::createGenericFCDDataHandling<BodyTuple, fcd::AnalyticCollideFunctor>(), "FCD"); auto fcdID = forest->addBlockData(fcd::createGenericFCDDataHandling<BodyTuple, fcd::AnalyticCollideFunctor>(), "FCD");
WALBERLA_LOG_INFO_ON_ROOT("*** RAYTRACER ***");
//if (cfg == NULL) {
// WALBERLA_ABORT("raytracer needs a working config");
//}
//Raytracer raytracer(forest, storageID, globalBodyStorage, ccdID,
// cfg->getBlock("Raytracing"));
Lighting lighting(Vec3(-12, 12, 12),
Color(1, 1, 1),
Color(1, 1, 1),
Color(real_t(0.4), real_t(0.4), real_t(0.4)));
Raytracer raytracer(forest, storageID, globalBodyStorage, ccdID,
640, 480,
real_t(49.13), 2,
Vec3(-25, 10, 10), Vec3(-5, 10, 10), Vec3(0, 0, 1),
lighting,
Color(real_t(0.1), real_t(0.1), real_t(0.1)),
radius);
WALBERLA_LOG_INFO_ON_ROOT("*** INTEGRATOR ***"); WALBERLA_LOG_INFO_ON_ROOT("*** INTEGRATOR ***");
cr::HCSITS cr(globalBodyStorage, forest, storageID, ccdID, fcdID); cr::HCSITS cr(globalBodyStorage, forest, storageID, ccdID, fcdID);
cr.setMaxIterations( 10 ); cr.setMaxIterations( 10 );
...@@ -190,6 +168,19 @@ int main( int argc, char ** argv ) ...@@ -190,6 +168,19 @@ int main( int argc, char ** argv )
syncCallWithoutTT = boost::bind( pe::syncShadowOwners<BodyTuple>, boost::ref(*forest), storageID, static_cast<WcTimingTree*>(NULL), real_c(0.0), false ); syncCallWithoutTT = boost::bind( pe::syncShadowOwners<BodyTuple>, boost::ref(*forest), storageID, static_cast<WcTimingTree*>(NULL), real_c(0.0), false );
} }
//! [Bind Sync Call] //! [Bind Sync Call]
WALBERLA_LOG_INFO_ON_ROOT("*** RAYTRACER ***");
//! [Raytracer Init]
std::function<ShadingParameters(const BodyID body)> customShadingFunction = [](const BodyID body) {
if (body->getTypeID() == Sphere::getStaticTypeID()) {
return processRankDependentShadingParams(body).makeGlossy();
}
return defaultBodyTypeDependentShadingParams(body);
};
Raytracer raytracer(forest, storageID, globalBodyStorage, ccdID,
cfg->getBlock("Raytracing"),
customShadingFunction);
//! [Raytracer Init]
WALBERLA_LOG_INFO_ON_ROOT("*** VTK ***"); WALBERLA_LOG_INFO_ON_ROOT("*** VTK ***");
//! [VTK Domain Output] //! [VTK Domain Output]
...@@ -266,12 +257,9 @@ int main( int argc, char ** argv ) ...@@ -266,12 +257,9 @@ int main( int argc, char ** argv )
vtkDomainOutput->write( ); vtkDomainOutput->write( );
vtkSphereOutput->write( ); vtkSphereOutput->write( );
//! [VTK Output] //! [VTK Output]
} //! [Image Output]
if ( i % raytracerSkippedSteps == 0) {
tp["Raytracing"].start();
raytracer.generateImage<BodyTuple>(size_t(i), &tt); raytracer.generateImage<BodyTuple>(size_t(i), &tt);
tp["Raytracing"].end(); //! [Image Output]
} }
} }
tp["Total"].end(); tp["Total"].end();
......
...@@ -91,6 +91,34 @@ depending on the type of information you want to store. ...@@ -91,6 +91,34 @@ depending on the type of information you want to store.
You can then dump the information to disc. timing::TimingPool and timing::TimingTree already have predefined save You can then dump the information to disc. timing::TimingPool and timing::TimingTree already have predefined save
functions so you do not have to extract all the information yourself and save it in the property array. functions so you do not have to extract all the information yourself and save it in the property array.
\snippet 02_ConfinedGasExtended.cpp SQL Save \snippet 02_ConfinedGasExtended.cpp SQL Save
\section tutorial_pe_02_raytracing Image Output
Using a raytracer snapshots of the simulation can be generated each timestep and output as PNG files.
Setting up the Raytracer can be done by reading a config object, as it is done in the tutorial:
\snippet 02_ConfinedGasExtended.cpp Raytracer Init
Alternatively it can also be entirely setup in code:
\code
Lighting lighting(Vec3(-12, 12, 12),
Color(1, 1, 1),
Color(1, 1, 1),
Color(real_t(0.4), real_t(0.4), real_t(0.4)));
Raytracer raytracer(forest, storageID, globalBodyStorage, ccdID,
640, 480,
real_t(49.13), 2,
Vec3(-25, 10, 10), Vec3(-5, 10, 10), Vec3(0, 0, 1),
lighting,
Color(real_t(0.1), real_t(0.1), real_t(0.1)),
radius,
customShadingFunction);
\endcode
To apply custom coloring to bodies, you can supply a user defined function which returns a ShadingParameters struct for
a given BodyID. For an overview over predefined shading functions, visit the file ShadingFunctions.h.
After the configuration is done, images can be generated each timestep by calling Raytracer::generateImage<BodyTuple>()
which will be output to the specified directory.
\snippet 02_ConfinedGasExtended.cpp Image Output
For further information see the documentation for the classes Raytracer and Lighting, the ShadingParameters class and
ShadingFunctions.h file may also be useful.
*/ */
} }
......
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