Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#pragma once

#include "types.h"
#include "math/vector/tools/twistVectorAxes.hpp"
#include "math/vector/TwistComponents.hpp"

namespace PMacc
{
Expand All @@ -33,7 +33,7 @@ namespace cursor
template<typename TCursor, typename Axes>
struct TwistAxesAccessor
{
typedef typename math::tools::result_of::TwistVectorAxes<
typedef typename math::result_of::TwistComponents<
Axes, typename TCursor::ValueType>::type type;

/** Returns a reference to the result of '*cursor' (with twisted axes).
Expand All @@ -43,7 +43,7 @@ struct TwistAxesAccessor
*/
HDINLINE type operator()(TCursor& cursor)
{
return math::tools::twistVectorAxes<Axes>(*cursor);
return math::twistComponents<Axes>(*cursor);
}

///\todo: implement const method here with a const TCursor& argument and 'type' as return type.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,23 @@ namespace PMacc
{
namespace math
{
namespace tools
{

namespace result_of
{

template<typename T_Axes,
typename T_Vector>
struct TwistVectorAxes
struct TwistComponents
{
typedef typename TwistVectorAxes<T_Axes,typename T_Vector::This>::type type;
};
typedef typename TwistComponents<T_Axes,typename T_Vector::This>::type type;
};

template<typename T_Axes,
typename T_Type, int T_Dim,
typename T_Accessor,
typename T_Navigator,
template <typename, int> class T_Storage>
struct TwistVectorAxes<T_Axes,math::Vector<T_Type,T_Dim,T_Accessor,T_Navigator,T_Storage> >
struct TwistComponents<T_Axes,math::Vector<T_Type,T_Dim,T_Accessor,T_Navigator,T_Storage> >
{
typedef math::Vector<T_Type, T_Dim, T_Accessor,
math::StackedNavigator<T_Navigator, math::PermutedNavigator<T_Axes> >,T_Storage >& type;
Expand All @@ -69,15 +67,14 @@ struct TwistVectorAxes<T_Axes,math::Vector<T_Type,T_Dim,T_Accessor,T_Navigator,T
*/
template<typename T_Axes, typename T_Vector>
HDINLINE
typename result_of::TwistVectorAxes<T_Axes, T_Vector>::type
twistVectorAxes(T_Vector& vector)
typename result_of::TwistComponents<T_Axes, T_Vector>::type
twistComponents(T_Vector& vector)
{
/* The reinterpret_cast is valid because the target type is the same as the
* input type except its navigator policy which does not occupy any memory though.
*/
return reinterpret_cast<typename result_of::TwistVectorAxes<T_Axes, T_Vector>::type>(vector);
return reinterpret_cast<typename result_of::TwistComponents<T_Axes, T_Vector>::type>(vector);
}

} // tools
} // math
} // PMacc
67 changes: 67 additions & 0 deletions src/libPMacc/include/math/vector/compile-time/TwistComponents.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/**
* Copyright 2015 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 "math/vector/compile-time/Vector.hpp"

namespace PMacc
{
namespace math
{
namespace CT
{

/**
* @class TwistComponents
* @brief Twists axes of a compile-time vector.
* @tparam Vec compile-time vector to be twisted
* @tparam Axes compile-time vector containing new axes
*
* Example:
*
* typedef PMacc::math::CT::Int<1,2,0> Orientation_Y;
* typedef typename PMacc::math::CT::TwistComponents<BlockDim, Orientation_Y>::type TwistedBlockDim;
*/
template<typename Vec, typename Axes, int dim=Vec::dim>
struct TwistComponents;

template<typename Vec, typename Axes>
struct TwistComponents<Vec, Axes, DIM2>
{
typedef math::CT::Vector<
typename Vec::template at<Axes::x::value>::type,
typename Vec::template at<Axes::y::value>::type> type;
};

template<typename Vec, typename Axes>
struct TwistComponents<Vec, Axes, DIM3>
{
typedef math::CT::Vector<
typename Vec::template at<Axes::x::value>::type,
typename Vec::template at<Axes::y::value>::type,
typename Vec::template at<Axes::z::value>::type> type;
};

} // namespace CT
} // namespace math
} // namespace PMacc
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
#include <cuSTL/algorithm/kernel/ForeachBlock.hpp>
#include <lambda/Expression.hpp>
#include <cuSTL/cursor/NestedCursor.hpp>
#include <math/vector/TwistComponents.hpp>
#include <math/vector/compile-time/TwistComponents.hpp>

namespace picongpu
{
Expand Down Expand Up @@ -74,16 +76,12 @@ class DirSplitting : private ConditionCheck<fieldSolver::FieldSolver>
void propagate(CursorE cursorE, CursorB cursorB, GridSize gridSize) const
{
using namespace cursor::tools;
using namespace PMacc::math::tools;
using namespace PMacc::math;

PMACC_AUTO(gridSizeTwisted,twistVectorAxes<OrientationTwist>(gridSize));
PMACC_AUTO(gridSizeTwisted, twistComponents<OrientationTwist>(gridSize));

/* twist components of the supercell */
typedef PMacc::math::CT::Int<
PMacc::math::CT::At<SuperCellSize,typename OrientationTwist::x>::type::value,
PMacc::math::CT::At<SuperCellSize,typename OrientationTwist::y>::type::value,
PMacc::math::CT::At<SuperCellSize,typename OrientationTwist::z>::type::value
> BlockDim;
typedef typename CT::TwistComponents<SuperCellSize, OrientationTwist>::type BlockDim;

algorithm::kernel::ForeachBlock<BlockDim> foreach;
foreach(zone::SphericZone<3>(PMacc::math::Size_t<3>(BlockDim::x::value, gridSizeTwisted.y(), gridSizeTwisted.z())),
Expand Down Expand Up @@ -113,7 +111,7 @@ class DirSplitting : private ConditionCheck<fieldSolver::FieldSolver>
-GuardDim().toRT()));

using namespace cursor::tools;
using namespace PMacc::math::tools;
using namespace PMacc::math;

PMacc::math::Size_t<3> gridSize = fieldE_coreBorder.size();

Expand Down
2 changes: 0 additions & 2 deletions src/picongpu/include/plugins/SliceFieldPrinter.tpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
#include "cuSTL/algorithm/host/Foreach.hpp"
#include "lambda/Expression.hpp"
#include "SliceFieldPrinter.hpp"
#include <math/vector/tools/twistVectorAxes.hpp>
#include <sstream>

namespace picongpu
Expand Down Expand Up @@ -124,7 +123,6 @@ template<typename TField>
void SliceFieldPrinter<Field>::printSlice(const TField& field, int nAxis, float slicePoint, std::string filename)
{
namespace vec = PMacc::math;
using namespace vec::tools;

PMacc::GridController<simDim>& con = PMacc::Environment<simDim>::get().GridController();
vec::Size_t<simDim> gpuDim = (vec::Size_t<simDim>)con.getGpuNodes();
Expand Down
1 change: 0 additions & 1 deletion src/picongpu/include/plugins/SliceFieldPrinterMulti.tpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
#include "cuSTL/algorithm/host/Foreach.hpp"
#include "lambda/Expression.hpp"
#include "SliceFieldPrinterMulti.hpp"
#include <math/vector/tools/twistVectorAxes.hpp>
#include <sstream>

namespace picongpu
Expand Down