SglParticle<FloatPos> getPositionsParticles(uint32_t currentStep) { typedef typename MappingDesc::SuperCellSize SuperCellSize; SglParticle<FloatPos> positionParticleTmp; gParticle->getDeviceBuffer().setValue(positionParticleTmp); dim3 block(SuperCellSize::getDataSpace()); __picKernelArea(kernelPositionsParticles, *cellDescription, AREA) (block) (particles->getDeviceParticlesBox(), gParticle->getDeviceBuffer().getBasePointer()); gParticle->deviceToHost(); DataSpace<simDim> localSize(cellDescription->getGridLayout().getDataSpaceWithoutGuarding()); VirtualWindow window(MovingWindow::getInstance().getVirtualWindow(currentStep)); DataSpace<simDim> gpuPhyCellOffset(SubGrid<simDim>::getInstance().getSimulationBox().getGlobalOffset()); gpuPhyCellOffset.y() += (localSize.y() * window.slides); gParticle->getHostBuffer().getDataBox()[0].globalCellOffset += gpuPhyCellOffset; return gParticle->getHostBuffer().getDataBox()[0]; }
void countMakroParticles(uint32_t currentStep) { openH5File(); /*############ count particles #######################################*/ typedef MappingDesc::SuperCellSize SuperCellSize; AreaMapping<AREA, MappingDesc> mapper(*cellDescription); __cudaKernel(CountMakroParticle) (mapper.getGridDim(), SuperCellSize::toRT().toDim3()) (particles->getDeviceParticlesBox(), localResult->getDeviceBuffer().getDataBox(), mapper); localResult->deviceToHost(); /*############ dump data #############################################*/ PMACC_AUTO(simBox, Environment<simDim>::get().SubGrid().getSimulationBox()); DataSpace<simDim> localSize(simBox.getLocalSize() / SuperCellSize::toRT()); DataSpace<simDim> globalOffset(simBox.getGlobalOffset() / SuperCellSize::toRT()); DataSpace<simDim> globalSize(simBox.getGlobalSize() / SuperCellSize::toRT()); Dimensions splashGlobalDomainOffset(0, 0, 0); Dimensions splashGlobalOffset(0, 0, 0); Dimensions splashGlobalDomainSize(1, 1, 1); Dimensions splashGlobalSize(1, 1, 1); Dimensions localBufferSize(1, 1, 1); for (uint32_t d = 0; d < simDim; ++d) { splashGlobalOffset[d] = globalOffset[d]; splashGlobalSize[d] = globalSize[d]; splashGlobalDomainSize[d] = globalSize[d]; localBufferSize[d] = localSize[d]; } size_t* ptr = localResult->getHostBuffer().getPointer(); dataCollector->writeDomain(currentStep, /* id == time step */ splashGlobalSize, /* total size of dataset over all processes */ splashGlobalOffset, /* write offset for this process */ ColTypeUInt64(), /* data type */ simDim, /* NDims of the field data (scalar, vector, ...) */ splash::Selection(localBufferSize), "makroParticlePerSupercell", /* data set name */ splash::Domain( splashGlobalDomainOffset, /* offset of the global domain */ splashGlobalDomainSize /* size of the global domain */ ), DomainCollector::GridType, ptr); closeH5File(); }
void createImage(uint32_t currentStep, VirtualWindow window) { DataConnector &dc = DataConnector::getInstance(); ParticlesType* particles = &(dc.getData<ParticlesType > (particleTag, true)); typedef MappingDesc::SuperCellSize SuperCellSize; DataSpace<simDim> blockSize(MappingDesc::SuperCellSize::getDataSpace()); DataSpace<DIM2> blockSize2D(blockSize[transpose.x()], blockSize[transpose.y()]); uint32_t globalOffset = 0; #if(SIMDIM==DIM3) globalOffset = SubGrid<simDim>::getInstance().getSimulationBox().getGlobalOffset()[sliceDim]; #endif //create density image of particles __picKernelArea((kernelParticleDensity), *cellDescription, CORE + BORDER) (SuperCellSize::getDataSpace(), blockSize2D.productOfComponents() * sizeof (float_X)) (particles->getDeviceParticlesBox(), img->getDeviceBuffer().getDataBox(), transpose, sliceOffset, globalOffset, sliceDim ); img->deviceToHost(); header.update(*cellDescription, window, transpose, currentStep); __getTransactionEvent().waitForFinished(); //wait for copy picture PMACC_AUTO(hostBox, img->getHostBuffer().getDataBox()); PMACC_AUTO(resultBox, gather(hostBox, header)); // units const float_64 cellVolume = CELL_VOLUME; float_64 unitVolume = 1.; for(uint32_t i=0;i<simDim;i++) unitVolume*=UNIT_LENGTH; // that's a hack, but works for all species //const float_64 charge = precisionCast<float_64>( // ParticlesType::FrameType().getCharge(NUM_EL_PER_PARTICLE)) / // precisionCast<float_64>(NUM_EL_PER_PARTICLE) * UNIT_CHARGE; // Note: multiply NUM_EL_PER_PARTICLE again // because of normalization during atomicAdd above // to avoid float overflow for weightings const float_64 unit = precisionCast<float_64>(NUM_EL_PER_PARTICLE) / (cellVolume * unitVolume); if (isMaster) output(resultBox.shift(header.window.offset), unit, header.window.size, header); }
void createImage(uint32_t currentStep, VirtualWindow window) { DataConnector &dc = DataConnector::getInstance(); // Data does not need to be synchronized as visualization is // done at the device. FieldB *fieldB = &(dc.getData<FieldB > (FieldB::getName(), true)); FieldE* fieldE = &(dc.getData<FieldE > (FieldE::getName(), true)); FieldJ* fieldJ = &(dc.getData<FieldJ > (FieldJ::getName(), true)); ParticlesType* particles = &(dc.getData<ParticlesType > (particleTag, true)); PMACC_AUTO(simBox, SubGrid<simDim>::getInstance().getSimulationBox()); uint32_t globalOffset = 0; #if(SIMDIM==DIM3) globalOffset = SubGrid<simDim>::getInstance().getSimulationBox().getGlobalOffset()[sliceDim]; #endif typedef MappingDesc::SuperCellSize SuperCellSize; assert(cellDescription != NULL); //create image fields __picKernelArea((kernelPaintFields), *cellDescription, CORE + BORDER) (SuperCellSize::getDataSpace()) (fieldE->getDeviceDataBox(), fieldB->getDeviceDataBox(), fieldJ->getDeviceDataBox(), img->getDeviceBuffer().getDataBox(), transpose, sliceOffset, globalOffset, sliceDim ); // find maximum for img.x()/y and z and return it as float3_X int elements = img->getGridLayout().getDataSpace().productOfComponents(); //Add one dimension access to 2d DataBox typedef DataBoxDim1Access<typename GridBuffer<float3_X, DIM2 >::DataBoxType> D1Box; D1Box d1access(img->getDeviceBuffer().getDataBox(), img->getGridLayout().getDataSpace()); #if (EM_FIELD_SCALE_CHANNEL1 == -1 || EM_FIELD_SCALE_CHANNEL2 == -1 || EM_FIELD_SCALE_CHANNEL3 == -1) //reduce with functor max float3_X max = reduce(nvidia::functors::Max(), d1access, elements); //reduce with functor min //float3_X min = reduce(nvidia::functors::Min(), // d1access, // elements); #if (EM_FIELD_SCALE_CHANNEL1 != -1 ) max.x() = float_X(1.0); #endif #if (EM_FIELD_SCALE_CHANNEL2 != -1 ) max.y() = float_X(1.0); #endif #if (EM_FIELD_SCALE_CHANNEL3 != -1 ) max.z() = float_X(1.0); #endif //We don't know the superCellSize at compile time // (because of the runtime dimension selection in any analyser), // thus we must use a one dimension kernel and no mapper __cudaKernel(vis_kernels::divideAnyCell)(ceil((double) elements / 256), 256)(d1access, elements, max); #endif // convert channels to RGB __cudaKernel(vis_kernels::channelsToRGB)(ceil((double) elements / 256), 256)(d1access, elements); // add density color channel DataSpace<simDim> blockSize(MappingDesc::SuperCellSize::getDataSpace()); DataSpace<DIM2> blockSize2D(blockSize[transpose.x()], blockSize[transpose.y()]); //create image particles __picKernelArea((kernelPaintParticles3D), *cellDescription, CORE + BORDER) (SuperCellSize::getDataSpace(), blockSize2D.productOfComponents() * sizeof (int)) (particles->getDeviceParticlesBox(), img->getDeviceBuffer().getDataBox(), transpose, sliceOffset, globalOffset, sliceDim ); // send the RGB image back to host img->deviceToHost(); header.update(*cellDescription, window, transpose, currentStep); __getTransactionEvent().waitForFinished(); //wait for copy picture DataSpace<DIM2> size = img->getGridLayout().getDataSpace(); PMACC_AUTO(hostBox, img->getHostBuffer().getDataBox()); if (picongpu::white_box_per_GPU) { hostBox[0 ][0 ] = float3_X(1.0, 1.0, 1.0); hostBox[size.y() - 1 ][0 ] = float3_X(1.0, 1.0, 1.0); hostBox[0 ][size.x() - 1] = float3_X(1.0, 1.0, 1.0); hostBox[size.y() - 1 ][size.x() - 1] = float3_X(1.0, 1.0, 1.0); } PMACC_AUTO(resultBox, gather(hostBox, header)); if (isMaster) { output(resultBox.shift(header.window.offset), header.window.size, header); } }