Last active
December 18, 2015 15:49
-
-
Save gidili/5807141 to your computer and use it in GitHub Desktop.
Snippets to log PCI-SPH states - storing in a gist not to mess up the code in this branch:
https://github.com/openworm/Smoothed-Particle-Hydrodynamics/tree/testing_geppetto_config
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// read buffer functions inline declarations in owOpenCLSolver.h | |
void read_position_b( float * positionBuffer ) { copy_buffer_from_device( positionBuffer, position, PARTICLE_COUNT * sizeof( float ) * 4 ); }; | |
void read_sortedPosition_b( float * sortedPositionBuffer ) { copy_buffer_from_device( sortedPositionBuffer, sortedPosition, PARTICLE_COUNT * sizeof( float ) * 4 * 2 ); }; | |
void read_neighborMap_b( float * neighborMapBuffer ) { copy_buffer_from_device( neighborMapBuffer, neighborMap, PARTICLE_COUNT * sizeof( float ) * 2 ); }; | |
void read_velocity_b( float * velocityBuffer ) { copy_buffer_from_device( velocityBuffer, velocity, PARTICLE_COUNT * sizeof( float ) * 4 ); }; | |
void read_acceleration_b( float * accelerationBuffer ) { copy_buffer_from_device( accelerationBuffer, acceleration, PARTICLE_COUNT * sizeof( float ) * 4 * 2); }; | |
void read_sortedVelocity_b( float * sortedVelocityBuffer ) { copy_buffer_from_device( sortedVelocityBuffer, sortedVelocity, PARTICLE_COUNT * sizeof( float ) * 4 ); }; | |
void read_elastic_b( float * elasticBuffer ) { copy_buffer_from_device( elasticBuffer, velocity, PARTICLE_COUNT * sizeof( float ) * 4 ); }; | |
void read_density_b( float * densityBuffer ) { copy_buffer_from_device( densityBuffer, rho, PARTICLE_COUNT * sizeof( float ) * 1 ); }; // This need only for visualization current density of particle (graphic effect) | |
void read_pressure_b( float * pressureBuffer ) { copy_buffer_from_device( pressureBuffer, pressure, PARTICLE_COUNT * sizeof( float ) * 4 ); }; | |
void read_particleIndex_b( unsigned int * particeleIndexBuffer ) { copy_buffer_from_device( particeleIndexBuffer, particleIndex, PARTICLE_COUNT * sizeof( unsigned int ) * 2 ); }; // This need only for visualization current density of particle (graphic effect) | |
void read_particleIndexBack_b( unsigned int * particeleIndexBackBuffer ) { copy_buffer_from_device( particeleIndexBackBuffer, particleIndexBack, PARTICLE_COUNT * sizeof( unsigned int ) * 1 ); }; | |
void read_gridCellIndex_b( unsigned int * gridCellIndexBuffer ); | |
void read_gridCellIndexFixedUp_b( unsigned int * gridCellIndexFixedUpBuffer ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// method to log all buffers in owPhysicsFluidSimulator.cpp | |
void owPhysicsFluidSimulator::logThemBuffers(std::string id, std::string sequence, bool initialConditionsOnly) | |
{ | |
#ifdef LOGGING_ENABLED | |
// print positions | |
ocl_solver->read_position_b(positionBuffer); | |
std::ostringstream posFile; | |
posFile << sequence << "position_log_" << id << ".txt"; | |
this->helper->log_bufferf(positionBuffer, 4, PARTICLE_COUNT, posFile.str().c_str()); | |
// print velocities | |
ocl_solver->read_velocity_b(velocityBuffer); | |
std::ostringstream velFile; | |
velFile << sequence << "velocity_log_" << id << ".txt"; | |
this->helper->log_bufferf(velocityBuffer, 4, PARTICLE_COUNT, velFile.str().c_str()); | |
// print elastic connections | |
float * elastic_connections_to_log = this->getElasticConnections(); | |
std::ostringstream connFile; | |
connFile << sequence << "elastic_log_" << id << ".txt"; | |
this->helper->log_bufferf(elastic_connections_to_log, 4, numOfElasticP * NEIGHBOR_COUNT, connFile.str().c_str()); | |
if(!initialConditionsOnly) | |
{ | |
// print grid cell index | |
ocl_solver->read_gridCellIndex_b(gridCellIndexBuffer); | |
std::ostringstream gridIndexFile; | |
gridIndexFile << sequence << "gridcellindex_log_" << id << ".txt"; | |
this->helper->log_bufferi(gridCellIndexBuffer, 1, ( gridCellCount + 1 ), gridIndexFile.str().c_str()); | |
// print grid cell index fixed up | |
ocl_solver->read_gridCellIndexFixedUp_b(gridCellIndexFixedUpBuffer); | |
std::ostringstream gridIndexFixedUpFile; | |
gridIndexFixedUpFile << sequence << "gridcellindexfixedup_log_" << id << ".txt"; | |
this->helper->log_bufferi(gridCellIndexFixedUpBuffer, 1, ( gridCellCount + 1 ), gridIndexFixedUpFile.str().c_str()); | |
// print neighbour count | |
ocl_solver->read_neighborMap_b(neighborMapBuffer); | |
std::ostringstream nmFile; | |
nmFile << sequence << "neighbormap_log_" << id << ".txt"; | |
this->helper->log_bufferf(neighborMapBuffer, 2, NEIGHBOR_COUNT * PARTICLE_COUNT, nmFile.str().c_str()); | |
// print sorted positions | |
ocl_solver->read_sortedPosition_b(sortedPositionBuffer); | |
std::ostringstream sortedposFile; | |
sortedposFile << sequence << "sortedposition_log_" << id << ".txt"; | |
this->helper->log_bufferf(sortedPositionBuffer, 4*2, PARTICLE_COUNT, sortedposFile.str().c_str()); | |
// print accelerations | |
/*ocl_solver->read_acceleration_b(accelerationBuffer); | |
std::ostringstream accelFile; | |
accelFile << sequence << "acceleration_log_" << id << ".txt"; | |
this->helper->log_bufferf(accelerationBuffer, 4 * 2, PARTICLE_COUNT, accelFile.str().c_str());*/ | |
// print sorted velocities | |
ocl_solver->read_sortedVelocity_b(sortedVelocityBuffer); | |
std::ostringstream sortvelFile; | |
sortvelFile << sequence << "sortedvelocity_log_" << id << ".txt"; | |
this->helper->log_bufferf(sortedVelocityBuffer, 4, PARTICLE_COUNT, sortvelFile.str().c_str()); | |
// print densities | |
ocl_solver->read_density_b( densityBuffer ); | |
std::ostringstream densFile; | |
densFile << sequence << "density_log_" << id << ".txt"; | |
this->helper->log_bufferf(densityBuffer, 2, PARTICLE_COUNT, densFile.str().c_str()); | |
// print pressure | |
ocl_solver->read_pressure_b( pressureBuffer ); | |
std::ostringstream pressFile; | |
pressFile << sequence << "pressure_log_" << id << ".txt"; | |
this->helper->log_bufferf(pressureBuffer, 4, PARTICLE_COUNT, pressFile.str().c_str()); | |
// print particle index | |
ocl_solver->read_particleIndex_b( particleIndexBuffer ); | |
std::ostringstream indexFile; | |
indexFile << sequence << "index_log_" << id << ".txt"; | |
this->helper->log_bufferi(particleIndexBuffer, 2, PARTICLE_COUNT, indexFile.str().c_str()); | |
// print particle index back | |
ocl_solver->read_particleIndexBack_b( particleIndexBackBuffer ); | |
std::ostringstream indexBackFile; | |
indexBackFile << sequence << "indexback_log_" << id << ".txt"; | |
this->helper->log_bufferi(particleIndexBackBuffer, 1, PARTICLE_COUNT, indexBackFile.str().c_str()); | |
} | |
#endif | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// float arrays declarations for logging in owPhysicsFluidSimulator.h | |
float * positionBuffer; | |
float * sortedPositionBuffer; | |
float * neighborMapBuffer; | |
float * velocityBuffer; | |
float * sortedVelocityBuffer; | |
float * elasticConnections; | |
float * densityBuffer; | |
float * pressureBuffer; | |
unsigned int * particleIndexBuffer; | |
unsigned int * particleIndexBackBuffer; | |
unsigned int * gridCellIndexBuffer; | |
unsigned int * gridCellIndexFixedUpBuffer; | |
float * accelerationBuffer; | |
void logThemBuffers(std::string id, std::string sequence, bool initialConditionsOnly); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment