-
Notifications
You must be signed in to change notification settings - Fork 217
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create RNG Factory only if it is needed
MySimulation.hpp: - RNGFactory will only be created if it is required by either ionization or the photon creation UsesRNG.hpp: - PIConGPU trait that checks if an object requires an RNG - Default is "false" FilterByRNG.hpp: - PMacc particle trait that takes a list of species and checks all of them with the UsesRNG trait to create a new list of species. ADL_Impl: - specialized the UsesRNG trait for "ADK_Impl" to return "true" Status: compiles [x], runs[x]
- Loading branch information
Marco Garten
committed
Aug 11, 2016
1 parent
df8a24b
commit 7edd7a3
Showing
4 changed files
with
147 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/** | ||
* Copyright 2016 Marco Garten, Heiko Burau | ||
* | ||
* This file is part of libPMacc. | ||
* | ||
* libPMacc is free software: you can redistribute it and/or modify | ||
* it under the terms of either the GNU General Public License or | ||
* the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* libPMacc 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 and the GNU Lesser General Public License | ||
* for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* and the GNU Lesser General Public License along with libPMacc. | ||
* If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "pmacc_types.hpp" | ||
#include "traits/UsesRNG.hpp" | ||
#include <boost/mpl/copy_if.hpp> | ||
#include <boost/mpl/placeholders.hpp> | ||
|
||
namespace PMacc | ||
{ | ||
namespace particles | ||
{ | ||
namespace traits | ||
{ | ||
|
||
/** Return a new sequence of particle species that require random number | ||
* generation for their ionization. | ||
* | ||
* @tparam T_MPLSeq sequence of particle species | ||
* | ||
* \TODO rather pass a sequence of objects, like ionization modules | ||
*/ | ||
template<typename T_MPLSeq> | ||
struct FilterByRNG | ||
{ | ||
typedef T_MPLSeq MPLSeq; | ||
|
||
template<typename T_Species> | ||
struct UsesRNG | ||
{ | ||
typedef T_Species SpeciesType; | ||
/* SelectIonizer will be either the specified one or fallback: None */ | ||
typedef typename picongpu::traits::GetIonizer<SpeciesType>::type SelectIonizer; | ||
/* check if ionization module requires RNG: type is boost::mpl::bool_<> */ | ||
typedef typename ::picongpu::traits::UsesRNG< | ||
SelectIonizer | ||
>::type type; | ||
}; | ||
|
||
typedef typename bmpl::copy_if<MPLSeq, UsesRNG<bmpl::_> >::type type; | ||
}; | ||
|
||
}//namespace traits | ||
}//namespace particles | ||
}//namespace PMacc |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/** | ||
* Copyright 2016 Marco Garten, Rene Widera | ||
* | ||
* 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/bool.hpp> | ||
|
||
namespace picongpu | ||
{ | ||
namespace traits | ||
{ | ||
|
||
/** Checks if an object requires the RNG | ||
* | ||
* @tparam T_Object any object (class or typename) | ||
* | ||
* This struct must define | ||
* ::type (boost::mpl::bool_<>) | ||
*/ | ||
template<typename T_Object> | ||
struct UsesRNG | ||
{ | ||
/* default implementation */ | ||
typedef boost::mpl::bool_<false> type; | ||
}; | ||
|
||
template<typename T_Object> | ||
bool usesRNG(const T_Object& obj) | ||
{ | ||
return UsesRNG<T_Object>::type::value; | ||
} | ||
|
||
}// namespace traits | ||
|
||
}// namespace picongpu |