Skip to content

Commit b162322

Browse files
add ParticleFactory to Environment
- make PArticleFactory getInstance private - use Environment<> to get instance of ParticleFactory - sove all dependencies - fix all example compile time errors
1 parent 4ff8b7f commit b162322

18 files changed

Lines changed: 50 additions & 73 deletions

File tree

examples/SingleParticleCurrent/include/OneParticleSimulation.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#define ONEPARTICLESIMULATION_HPP
2525

2626
#include "simulation_defines.hpp"
27+
#include "Environment.hpp"
2728

2829
#include "simulationControl/MySimulation.hpp"
2930

@@ -75,7 +76,7 @@ class OneParticleSimulation : public MySimulation
7576

7677
MySimulation::init();
7778

78-
if (GridController<DIM3>::getInstance().getGlobalRank() == 0)
79+
if (Environment<simDim>::getInstance().getGridController().getGlobalRank() == 0)
7980
{
8081
std::cout << "max weighting " << NUM_EL_PER_PARTICLE << std::endl;
8182
std::cout << "courant=min(deltaCellSize)/dt/c > 1.77 ? " << std::min(CELL_WIDTH, std::min(CELL_DEPTH, CELL_HEIGHT)) / SPEED_OF_LIGHT / DELTA_T << std::endl;
@@ -91,7 +92,7 @@ class OneParticleSimulation : public MySimulation
9192
//diabled because we have a transaction bug
9293
//StreamController::getInstance().addStreams(6);
9394

94-
PMACC_AUTO(simBox, SubGrid<simDim>::getInstance().getSimulationBox());
95+
PMACC_AUTO(simBox, Environment<simDim>::getInstance().getSubGrid().getSimulationBox());
9596

9697
const DataSpace<simDim> halfSimSize(simBox.getGlobalSize() / 2);
9798

@@ -141,7 +142,7 @@ class OneParticleSimulation : public MySimulation
141142

142143
virtual void movingWindowCheck(uint32_t currentStep)
143144
{
144-
PMACC_AUTO(simBox, SubGrid<simDim>::getInstance().getSimulationBox());
145+
PMACC_AUTO(simBox, Environment<simDim>::getInstance().getSubGrid().getSimulationBox());
145146
GridLayout<DIM3> gridLayout(simBox.getLocalSize(), MappingDesc::SuperCellSize::getDataSpace());
146147
if (MovingWindow::getInstance().getVirtualWindow(currentStep).doSlide)
147148
{

examples/SingleParticleCurrent/include/particles/ParticlesInitOneParticle.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class ParticlesInitOneParticle
9090
static void addOneParticle(ParticlesClass& parClass, MappingDesc cellDescription, DataSpace<DIM3> globalCell)
9191
{
9292

93-
PMACC_AUTO(simBox, SubGrid<simDim>::getInstance().getSimulationBox());
93+
PMACC_AUTO(simBox, Environment<simDim>::getInstance().getSubGrid().getSimulationBox());
9494
const DataSpace<DIM3> globalTopLeft = simBox.getGlobalOffset();
9595
const DataSpace<DIM3> localSimulationArea = simBox.getLocalSize();
9696

examples/SingleParticleRadiationWithLaser/include/OneParticleSimulation.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#define ONEPARTICLESIMULATION_HPP
2525

2626
#include "simulation_defines.hpp"
27+
#include "Environment.hpp"
2728

2829
#include "simulationControl/MySimulation.hpp"
2930

@@ -75,7 +76,7 @@ class OneParticleSimulation : public MySimulation
7576

7677
MySimulation::init();
7778

78-
if (GridController<DIM3>::getInstance().getGlobalRank() == 0)
79+
if (Environment<simDim>::getInstance().getGridController().getGlobalRank() == 0)
7980
{
8081
std::cout << "max weighting " << NUM_EL_PER_PARTICLE << std::endl;
8182
std::cout << "courant=min(deltaCellSize)/dt/c > 1.77 ? " << std::min(CELL_WIDTH, std::min(CELL_DEPTH, CELL_HEIGHT)) / SPEED_OF_LIGHT / DELTA_T << std::endl;
@@ -91,7 +92,7 @@ class OneParticleSimulation : public MySimulation
9192

9293
//add one particle in simulation
9394
//
94-
PMACC_AUTO(simBox, SubGrid<simDim>::getInstance().getSimulationBox());
95+
PMACC_AUTO(simBox, Environment<simDim>::getInstance().getSubGrid().getSimulationBox());
9596

9697
const DataSpace<simDim> halfSimSize(simBox.getGlobalSize() / 2);
9798

@@ -175,7 +176,7 @@ class OneParticleSimulation : public MySimulation
175176
virtual void movingWindowCheck(uint32_t currentStep)
176177
{
177178

178-
PMACC_AUTO(simBox, SubGrid<simDim>::getInstance().getSimulationBox());
179+
PMACC_AUTO(simBox, Environment<simDim>::getInstance().getSubGrid().getSimulationBox());
179180
GridLayout<DIM3> gridLayout(simBox.getLocalSize(), MappingDesc::SuperCellSize::getDataSpace());
180181
if (MovingWindow::getInstance().getVirtualWindow(currentStep).doSlide)
181182
{

examples/SingleParticleRadiationWithLaser/include/particles/ParticlesInitOneParticle.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ class ParticlesInitOneParticle
9494
static void addOneParticle(ParticlesClass& parClass, MappingDesc cellDescription, DataSpace<DIM3> globalCell)
9595
{
9696

97-
PMACC_AUTO(simBox, SubGrid<simDim>::getInstance().getSimulationBox());
97+
PMACC_AUTO(simBox, Environment<simDim>::getInstance().getSubGrid().getSimulationBox());
9898
const DataSpace<DIM3> globalTopLeft = simBox.getGlobalOffset();
9999
const DataSpace<DIM3> localSimulationArea = simBox.getLocalSize();
100100
DataSpace<DIM3> localParCell = globalCell - globalTopLeft;

examples/SingleParticleTest/include/OneParticleSimulation.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#define ONEPARTICLESIMULATION_HPP
2525

2626
#include "simulation_defines.hpp"
27-
27+
#include "Environment.hpp"
2828
#include "simulationControl/MySimulation.hpp"
2929

3030
#include "simulationControl/SimulationHelper.hpp"
@@ -75,7 +75,7 @@ class OneParticleSimulation : public MySimulation
7575

7676
MySimulation::init();
7777

78-
if (GridController<DIM3>::getInstance().getGlobalRank() == 0)
78+
if (Environment<simDim>::getInstance().getGridController().getGlobalRank() == 0)
7979
{
8080
std::cout << "max weighting " << NUM_EL_PER_PARTICLE << std::endl;
8181
std::cout << "courant=min(deltaCellSize)/dt/c > 1.77 ? " << std::min(CELL_WIDTH, std::min(CELL_DEPTH, CELL_HEIGHT)) / SPEED_OF_LIGHT / DELTA_T << std::endl;
@@ -93,7 +93,7 @@ class OneParticleSimulation : public MySimulation
9393

9494
//add one particle in simulation
9595
//
96-
PMACC_AUTO(simBox, SubGrid<simDim>::getInstance().getSimulationBox());
96+
PMACC_AUTO(simBox, Environment<simDim>::getInstance().getSubGrid().getSimulationBox());
9797

9898
const DataSpace<simDim> halfSimSize(simBox.getGlobalSize() / 2);
9999

@@ -154,7 +154,7 @@ class OneParticleSimulation : public MySimulation
154154

155155
virtual void movingWindowCheck(uint32_t currentStep)
156156
{
157-
PMACC_AUTO(simBox, SubGrid<simDim>::getInstance().getSimulationBox());
157+
PMACC_AUTO(simBox, Environment<simDim>::getInstance().getSubGrid().getSimulationBox());
158158
GridLayout<DIM3> gridLayout(simBox.getLocalSize(), MappingDesc::SuperCellSize::getDataSpace());
159159
if (MovingWindow::getInstance().getVirtualWindow(currentStep).doSlide)
160160
{

examples/SingleParticleTest/include/particles/ParticlesInitOneParticle.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ namespace picongpu
9090
static void addOneParticle(ParticlesClass& parClass, MappingDesc cellDescription, DataSpace<DIM3> globalCell)
9191
{
9292

93-
PMACC_AUTO(simBox, SubGrid<simDim>::getInstance().getSimulationBox());
93+
PMACC_AUTO(simBox, Environment<simDim>::getInstance().getSubGrid().getSimulationBox());
9494
const DataSpace<DIM3> globalTopLeft = simBox.getGlobalOffset();
9595
const DataSpace<DIM3> localSimulationArea = simBox.getLocalSize();
9696
DataSpace<DIM3> localParCell = globalCell - globalTopLeft;

examples/ThermalTest/include/ThermalTestSimulation.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#define TERMALTESTSIMULATION_HPP
2323

2424
#include "simulation_defines.hpp"
25+
#include "Environment.hpp"
2526

2627
#include "simulationControl/MySimulation.hpp"
2728

@@ -114,7 +115,7 @@ class ThermalTestSimulation : public MySimulation
114115
{
115116
using namespace ::PMacc::math;
116117

117-
PMacc::GridController<SIMDIM>& con = PMacc::GridController<SIMDIM>::getInstance();
118+
PMACC_AUTO(&con,Environment<simDim>::getInstance().getGridController());
118119
Size_t<SIMDIM> gpuDim = (Size_t<SIMDIM>)con.getGpuNodes();
119120
Int<3> gpuPos = (Int<3>)con.getPosition();
120121
zone::SphericZone<SIMDIM> gpuGatheringZone(Size_t<SIMDIM > (1, 1, gpuDim.z()));

src/libPMacc/include/Environment.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#pragma once
2323

2424
#include "eventSystem/EventSystem.hpp"
25+
#include "particles/tasks/ParticleFactory.hpp"
2526

2627
#include "mappings/simulation/GridController.hpp"
2728
#include "mappings/simulation/SubGrid.hpp"
@@ -76,6 +77,11 @@ namespace PMacc
7677
return Factory::getInstance();
7778
}
7879

80+
ParticleFactory& getParticleFactory()
81+
{
82+
return ParticleFactory::getInstance();
83+
}
84+
7985
DataConnector& getDataConnector()
8086
{
8187
return DataConnector::getInstance();
@@ -146,3 +152,4 @@ namespace PMacc
146152

147153
}
148154

155+
#include "particles/tasks/ParticleFactory.tpp"

src/libPMacc/include/cuSTL/algorithm/mpi/Reduce.tpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ template<int dim>
3838
Reduce<dim>::Reduce(const zone::SphericZone<dim>& _zone, bool setThisAsRoot) : comm(MPI_COMM_NULL)
3939
{
4040
using namespace math;
41-
42-
PMacc::GridController<dim>& con = PMacc::GridController<dim>::getInstance();
41+
42+
PMACC_AUTO(&con,Environment<dim>::getInstance().getGridController());
4343

4444
typedef std::pair<Int<dim>, bool> PosFlag;
4545
PosFlag posFlag;

src/libPMacc/include/eventSystem/EventSystem.hpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@
1919
* If not, see <http://www.gnu.org/licenses/>.
2020
*/
2121

22-
#ifndef EVENTSYSTEM_HPP
23-
#define EVENTSYSTEM_HPP
22+
#pragma once
2423

2524
#include "eventSystem/events/EventTask.hpp"
2625
#include "eventSystem/events/EventNotify.hpp"
2726
#include "eventSystem/tasks/StreamTask.hpp"
27+
#include "eventSystem/tasks/MPITask.hpp"
2828
#include "eventSystem/transactions/TransactionManager.hpp"
2929
#include "eventSystem/transactions/Transaction.hpp"
3030
#include "eventSystem/Manager.hpp"
@@ -38,8 +38,3 @@
3838
#include "eventSystem/events/EventTask.tpp"
3939
#include "eventSystem/events/EventNotify.tpp"
4040
#include "eventSystem/tasks/Factory.tpp"
41-
42-
43-
44-
#endif /* EVENTSYSTEM_HPP */
45-

0 commit comments

Comments
 (0)