Beispiel #1
0
 void writeToConsole(std::ostream& ocons) const
 {
     ocons << "SimHeader.size " << size.x() << " " << size.y() << std::endl;
     ocons << "SimHeader.nodes " << nodes.x() << " " << nodes.y() << std::endl;
     ocons << "SimHeader.step " << step << std::endl;
     ocons << "SimHeader.scale " << scale[0] << " " << scale[1] << std::endl;
     ocons << "SimHeader.cellSize " << cellSizeArr[0] << " " << cellSizeArr[1] << std::endl;
 }
Beispiel #2
0
 void writeToConsole(std::ostream& ocons) const
 {
     ocons << "NodeHeader.maxSize " << maxSize.x() << " " << maxSize.y() << std::endl;
     ocons << "NodeHeader.size " << size.x() << " " << size.y() << std::endl;
     ocons << "NodeHeader.localOffset " << localOffset.x() << " " << localOffset.y() << std::endl;
     ocons << "NodeHeader.offset " << offset.x() << " " << offset.y() << std::endl;
     ocons << "NodeHeader.offsetToWindow " << offsetToWindow.x() << " " << offsetToWindow.y() << std::endl;
 }
Beispiel #3
0
 void insertData(DstBox& dst, const SrcBox& src, Size2D offsetToSimNull, Size2D srcSize)
 {
     for (int y = 0; y < srcSize.y(); ++y)
     {
         for (int x = 0; x < srcSize.x(); ++x)
         {
             dst[y + offsetToSimNull.y()][x + offsetToSimNull.x()] = src[y][x];
         }
     }
 }
Beispiel #4
0
        void operator()(
                        const Box data,
                        const ValueType unit,
                        const Size2D size,
                        const MessageHeader & header)
        {

            if (createFolder)
            {
                mkdir((folder).c_str(), 0755);
                createFolder = false;
            }

            std::stringstream step;
            step << std::setw(6) << std::setfill('0') << header.sim.step;
            //std::string filename(name + "_" + step.str() + ".bin");
            std::string filename(name + "_" + step.str() + ".dat");

            double x_cell = header.sim.cellSizeArr[0];
            double y_cell = header.sim.cellSizeArr[1];

            double x_simOff = header.sim.simOffsetToNull[0];
            double y_simOff = header.sim.simOffsetToNull[1];

            DataSpace<DIM2> gOffset = header.window.offset;

            std::ofstream file(filename.c_str(), std::ofstream::out ); //| std::ofstream::binary);
            
            typedef std::numeric_limits< ValueType > dbl;
            file.precision(dbl::digits10);
            file << std::scientific;

            ValueType sizex = (int) size.x();
            //file.write((char*) (&sizex), sizeof (ValueType));
            file << sizex << " ";
            
            //first line with y header information
            for (int x = 0; x < size.x(); ++x)
            {
                ValueType cellPos = (ValueType) ((x + x_simOff + gOffset.x()) * x_cell * UNIT_LENGTH);
                //file.write((char*) &(cellPos), sizeof (ValueType));
                file << cellPos << " ";
            }
            file << std::endl;
            
            //the first column is for x header information
            for (int y = 0; y < size.y(); ++y)
            {
                for (int x = 0; x <= size.x(); ++x)
                {
                    if (x == 0)
                    {
                        ValueType cellPos = (ValueType) ((y + y_simOff + gOffset.y()) * y_cell * UNIT_LENGTH);
                        //file.write((char*) &(cellPos), sizeof (ValueType));
                        file << cellPos;
                    }
                    else
                    {
                        const ValueType value = precisionCast<ValueType>(data[y][x])
                                              * unit;

                        /** \info take care, that gnuplots binary matrix does
                         *        not support float64 (IEEE float32 only)
                         *  \see http://stackoverflow.com/questions/8751154/looking-at-binary-output-from-fortran-on-gnuplot
                         *       http://gnuplot.sourceforge.net/docs_4.2/node101.html
                         */
                        //file.write((char*) &(value), sizeof (ValueType));
                        file << " " << value;
                    }
                }
                file << std::endl;
            }

            file.close();
        }
Beispiel #5
0
    void update(CellDesc & cellDesc,
                picongpu::Window vWindow,
                Size2D transpose,
                uint32_t currentStep,
                float* cellSizeArr = NULL,
                const PMacc::DataSpace<CellDesc::Dim> gpus = PMacc::DataSpace<CellDesc::Dim > ())
    {
        using namespace PMacc;
        using namespace picongpu;

        enum
        {
            Dim = CellDesc::Dim
        };

        const DataSpace<Dim> localSize(cellDesc.getGridLayout().getDataSpaceWithoutGuarding());
        const DataSpace<DIM2> localSize2D(localSize[transpose.x()], localSize[transpose.y()]);

        /*update only if nuber of gpus are set, else use old value*/
        if (gpus.productOfComponents() != 0)
            sim.nodes = DataSpace<DIM2 > (gpus[transpose.x()], gpus[transpose.y()]);

        PMACC_AUTO(simBox, Environment<simDim>::get().SubGrid().getSimulationBox());

        const DataSpace<Dim> globalSize(simBox.getGlobalSize());
        sim.size.x() = globalSize[transpose.x()];
        sim.size.y() = globalSize[transpose.y()];

        node.maxSize = DataSpace<DIM2 > (localSize[transpose.x()], localSize[transpose.y()]);

        const DataSpace<Dim> windowSize = vWindow.globalDimensions.size;
        window.size = DataSpace<DIM2 > (windowSize[transpose.x()], windowSize[transpose.y()]);

        if (cellSizeArr != NULL)
        {
            float scale[2];
            scale[0] = cellSizeArr[transpose.x()];
            scale[1] = cellSizeArr[transpose.y()];
            sim.cellSizeArr[0] = cellSizeArr[transpose.x()];
            sim.cellSizeArr[1] = cellSizeArr[transpose.y()];

            const float scale0to1 = scale[0] / scale[1];

            if (scale0to1 > 1.0f)
            {
                sim.setScale(scale0to1, 1.f);
            }
            else if (scale0to1 < 1.0f)
            {
                sim.setScale(1.f, 1.0f / scale0to1);
            }
            else
            {
                sim.setScale(1.f, 1.f);
            }
        }

        const DataSpace<Dim> offsetToSimNull(simBox.getGlobalOffset());
        const DataSpace<Dim> windowOffsetToSimNull(vWindow.globalDimensions.offset);
        const DataSpace<Dim> localOffset(vWindow.localDimensions.offset);

        const DataSpace<DIM2> localOffset2D(localOffset[transpose.x()], localOffset[transpose.y()]);
        node.localOffset = localOffset2D;

        DataSpace<Dim> offsetToWindow(offsetToSimNull - windowOffsetToSimNull);

        const DataSpace<DIM2> offsetToWindow2D(offsetToWindow[transpose.x()], offsetToWindow[transpose.y()]);
        node.offsetToWindow = offsetToWindow2D;

        const DataSpace<DIM2> offsetToSimNull2D(offsetToSimNull[transpose.x()], offsetToSimNull[transpose.y()]);
        node.offset = offsetToSimNull2D;

        const DataSpace<DIM2> windowOffsetToSimNull2D(windowOffsetToSimNull[transpose.x()], windowOffsetToSimNull[transpose.y()]);
        window.offset = windowOffsetToSimNull2D;

        const DataSpace<Dim> currentLocalSize(vWindow.localDimensions.size);
        const DataSpace<DIM2> currentLocalSize2D(currentLocalSize[transpose.x()], currentLocalSize[transpose.y()]);
        node.size = currentLocalSize2D;

        sim.step = currentStep;

        /*add sliding windo informations to header*/
        const uint32_t numSlides = MovingWindow::getInstance().getSlideCounter(currentStep);
        sim.simOffsetToNull = DataSpace<DIM2 > ();
        if (transpose.x() == 1)
            sim.simOffsetToNull.x() = node.maxSize.x() * numSlides;
        else if (transpose.y() == 1)
            sim.simOffsetToNull.y() = node.maxSize.y() * numSlides;

    }