Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move checkpoint fields and species to new file #387

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 33 additions & 12 deletions src/picongpu/include/plugins/hdf5/HDF5Writer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,11 @@ class HDF5Writer : public ISimulationPlugin
ThreadParams *params = &mThreadParams;

/* load all fields */
ForEach<FileRestartFields, LoadFields<void> > forEachLoadFields;
ForEach<FileCheckpointFields, LoadFields<void> > forEachLoadFields;
forEachLoadFields(ref(params));

/* load all particles */
ForEach<FileRestartParticles, LoadParticles<void> > forEachLoadSpecies;
ForEach<FileCheckpointParticles, LoadParticles<void> > forEachLoadSpecies;
forEachLoadSpecies(ref(params), gridPosition);

/* close datacollector */
Expand Down Expand Up @@ -344,7 +344,6 @@ class HDF5Writer : public ISimulationPlugin

static void *writeHDF5(void *p_args)
{
// synchronize, because following operations will be blocking anyway
ThreadParams *threadParams = (ThreadParams*) (p_args);

writeMetaAttributes(threadParams);
Expand All @@ -357,16 +356,30 @@ class HDF5Writer : public ISimulationPlugin
DataSpace<simDim> particleOffset(threadParams->gridPosition);
particleOffset.y() -= threadParams->window.globalSimulationOffset.y();

/*print all fields*/
/* write all fields */
log<picLog::INPUT_OUTPUT > ("HDF5: (begin) writing fields.");
ForEach<FileOutputFields, WriteFields<void> > forEachWriteFields;
forEachWriteFields(ref(threadParams), domInfo);
if (threadParams->isCheckpoint)
{
ForEach<FileCheckpointFields, WriteFields<void> > forEachWriteFields;
forEachWriteFields(ref(threadParams), domInfo);
} else
{
ForEach<FileOutputFields, WriteFields<void> > forEachWriteFields;
forEachWriteFields(ref(threadParams), domInfo);
}
log<picLog::INPUT_OUTPUT > ("HDF5: ( end ) writing fields.");

/*print all particle species*/
/* write all particle species */
log<picLog::INPUT_OUTPUT > ("HDF5: (begin) writing particle species.");
ForEach<FileOutputParticles, WriteSpecies<void> > writeSpecies;
writeSpecies(ref(threadParams), std::string(), domInfo, particleOffset);
if (threadParams->isCheckpoint)
{
ForEach<FileCheckpointParticles, WriteSpecies<void> > writeSpecies;
writeSpecies(ref(threadParams), std::string(), domInfo, particleOffset);
} else
{
ForEach<FileOutputParticles, WriteSpecies<void> > writeSpecies;
writeSpecies(ref(threadParams), std::string(), domInfo, particleOffset);
}
log<picLog::INPUT_OUTPUT > ("HDF5: ( end ) writing particle species.");


Expand All @@ -378,10 +391,18 @@ class HDF5Writer : public ISimulationPlugin
particleOffset = threadParams->gridPosition;
particleOffset.y() = -threadParams->window.localSize.y();

/* for restart we only need bottom ghosts for particles */
log<picLog::INPUT_OUTPUT > ("HDF5: (begin) writing particle species bottom.");
/* for checkpoints we only need bottom ghosts for particles */
/* print all particle species */
writeSpecies(ref(threadParams), std::string("_ghosts"), domInfoGhosts, particleOffset);
log<picLog::INPUT_OUTPUT > ("HDF5: (begin) writing particle species bottom.");
if (threadParams->isCheckpoint)
{
ForEach<FileCheckpointParticles, WriteSpecies<void> > writeSpecies;
writeSpecies(ref(threadParams), std::string("_ghosts"), domInfoGhosts, particleOffset);
} else
{
ForEach<FileOutputParticles, WriteSpecies<void> > writeSpecies;
writeSpecies(ref(threadParams), std::string("_ghosts"), domInfoGhosts, particleOffset);
}
log<picLog::INPUT_OUTPUT > ("HDF5: ( end ) writing particle species bottom.");
}
return NULL;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@
#include "simulation_defines/unitless/pusherConfig.unitless"
#include "simulation_defines/unitless/radiationConfig.unitless"
#include "simulation_defines/unitless/fileOutput.unitless"
#include "simulation_defines/unitless/checkpoints.unitless"
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/**
* Copyright 2013-2014 Axel Huebl, Rene Widera, Felix Schmitt
*
* This file is part of PIConGPU.
*
* PIConGPU is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PIConGPU is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PIConGPU.
* If not, see <http://www.gnu.org/licenses/>.
*/

#pragma once

#include <boost/mpl/vector.hpp>
#include <boost/mpl/pair.hpp>

#include "compileTime/conversion/MakeSeq.hpp"

/** some forward declarations we need */
#include "fields/Fields.def"
#include "particles/Species.hpp"

namespace picongpu
{
/** Note: we need at least FieldE and FieldB for restart
* capabilities!
*/
typedef typename MakeSeq<FieldE, FieldB>::type NativeFileCheckpointFields;

/* List of particle species for checkpoint/restart */
typedef VectorAllSpecies FileCheckpointParticles;

/** List of fields for checkpoint/restart */
typedef typename MakeSeq<
NativeFileCheckpointFields
>::type FileCheckpointFields;
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,13 @@

namespace picongpu
{
/** Note: you will need at least FieldE and FieldB for restart
* capabilities!
/**
* Possible fields: FieldE, FieldB, FieldJ
*/
typedef typename MakeSeq<FieldE, FieldB>::type NativeFileOutputFields;

typedef VectorAllSpecies FileOutputParticles;

typedef VectorAllSpecies FileRestartParticles;

/** TimeAvg Fields
* \todo Reduce/Avg on host-side RAM with a plugin
*/
Expand Down Expand Up @@ -90,9 +87,4 @@ namespace picongpu
PluginsFileOutputFieldsElectrons,
PluginsFileOutputFieldsIons
>::type FileOutputFields;

/** This list is use to restarts fields from a file. */
typedef typename MakeSeq<
NativeFileOutputFields
>::type FileRestartFields;
}