Commit a7367ef7 authored by ESTERIE Pierre's avatar ESTERIE Pierre

Some more work on basic components

parent 50e3ee34
......@@ -2,6 +2,7 @@
// Experimental example
//---------------------
#include <algorithm>
#include <iostream>
#include <random>
#include <tuple>
......@@ -25,13 +26,6 @@
#include <xtensor/xtensor.hpp>
#include <scalfmm/container/particle.hpp>
#include <scalfmm/container/particle_container.hpp>
#include <scalfmm/container/point.hpp>
#include <scalfmm/functional/utils.hpp>
#include <scalfmm/interpolation/uniform.hpp>
#include <scalfmm/tools/colorized.hpp>
#include <scalfmm/tree/box.hpp>
#include <scalfmm/tree/tree.hpp>
namespace args {
struct nb_particle : inria::tcli::required_tag {
......@@ -117,7 +111,8 @@ CPP_template(class Iter, class Sent, class Fun)(
// Quick type displayer
template <typename T> class TD;
int main(int argc, char **argv) {
int main(int argc, char **argv)
{
args::cli.parse(argc, argv);
params parameters(args::cli);
......
#ifndef SCALFMM_SPACE_CURVE_HPP_
#define SCALFMM_SPACE_CURVE_HPP_
#include "Utils/FPoint.hpp"
/** Provides the corner traversal order of an N dimension hypercube
*
* The positions returned are array of booleans. Each boolean tells where
* to place the element in the binary grid.
*
* For instance, in 2D:
*
*
* __0__ __1__
* | | |
* 0| | X | pos(X) = [true, false]
* |_____|_____|
* | | |
* 1| | Y | pos(Y) = [true, true ]
* |_____|_____|
*
*
* \tparam Dim The hypercube dimension.
*/
template<std::size_t _Dim>
class FZCurve {
public:
/// Space dimension count
constexpr static const std::size_t Dim = _Dim;
/// Position type used
using position_t = FPoint<bool, Dim>;
/// Position count in the grid
constexpr static std::size_t pos_count = Fpow(2,Dim);
private:
/// Array of positions type
using position_array_t = std::array<position_t, pos_count>;
/// Array to cache the positions corresponding to indexes
static const position_array_t _positions;
/** Creates an array of positions to initialize #_positions */
static position_array_t create_array() noexcept {
position_array_t positions;
for(std::size_t i = 0; i < pos_count; ++i) {
for(std::size_t j = Dim-1, k = i; k != 0; --j, k >>=1) {
positions[i][j] = k % 2;
}
}
return positions;
}
public:
/** The position corresponding to an index
*
* \param idx The index of the point in the space filling curve
* \return The position corresponding to the space filling curve index
*/
static position_t position(std::size_t idx) noexcept {
return _positions[idx];
}
/** Index in the space filling curve of a boolean position
*
* \param p The position
* \return The space filling curve index corresponding to the position
*/
static std::size_t index(const position_t& p) noexcept {
std::size_t idx = 0;
for(auto i : p) {
idx <<= 1;
idx += i;
}
return idx;
}
/** Index in the space filling curve of a real position relative to the center of the hypercube
*
* \param p The position
* \param center The center of the hypercube
* \return The space filling curve index corresponding to the position
*/
template<typename FReal>
static std::size_t index(const FPoint<FReal, Dim>& p, const FPoint<FReal, Dim>& center) noexcept {
std::size_t idx = 0;
for(std::size_t i = 0; i < Dim; ++i) {
idx <<= 1;
idx += p[i] > center[i];
}
return idx;
}
};
// Initialization of static variable
template<std::size_t _Dim>
const typename FZCurve<_Dim>::position_array_t FZCurve<_Dim>::_positions(FZCurve<_Dim>::create_array());
#endif
......@@ -27,17 +27,10 @@
*
* ```
* using FReal = double;
<<<<<<< HEAD
* static constexpr std::size_t dimension = 3;
*
* particle<FReal, dimension, int, float, float, float, float>;
* particle<FReal, dimension, int, scalfmm::pack<4, float> >;
=======
* static constexpr std::size_t Dim = 3;
*
* particle<FReal, Dim, int, float, float, float, float>;
* particle<FReal, Dim, int, scalfmm::pack<4, float> >;
>>>>>>> Some components on there way, not working yet, just backup.
* ```
*
* The base of these two classes is
......@@ -60,11 +53,7 @@
*
*
* \tparam FReal Floating point type
<<<<<<< HEAD
* \tparam dimension Space dimension count
=======
* \tparam Dim Space dimension count
>>>>>>> Some components on there way, not working yet, just backup.
* \tparam Types Attributes type list
*
*/
......@@ -77,7 +66,6 @@ namespace scalfmm::container
public:
/// Storage class : std::tuple<FReal,...(dimension times), Types...>
using tuple_data_t = scalfmm::meta::pack_expand_tuple<scalfmm::meta::pack<Dim, ValueType>, Types...>;
/// Expand Types list
using types_tuple_t = scalfmm::meta::pack_expand_tuple<Types...>;
......@@ -107,7 +95,6 @@ namespace scalfmm::container
using value_type = ValueType;
/// Position type, required by the FVariadicParticleContainer
using position_type = point<value_type, dimension>;
/// Default constructor
particle() = default;
/// Default copy constructor
......
......@@ -334,7 +334,6 @@ namespace scalfmm::container
return is;
}
};
} // end of namespace scalfmm::container
#endif
......
// See LICENCE file at project root
//
#ifndef SCALFMM_TREE_MORTON_CURVE_HPP
#define SCALFMM_TREE_MORTON_CURVE_HPP
#include <scalfmm/container/point.hpp>
#include <scalfmm/meta/const_functions.hpp>
/** Provides the corner traversal order of an N dimension hypercube
*
* The positions returned are array of booleans. Each boolean tells where
* to place the element in the binary grid.
*
* For instance, in 2D:
*
*
* __0__ __1__
* | | |
* 0| | X | pos(X) = [true, false]
* |_____|_____|
* | | |
* 1| | Y | pos(Y) = [true, true ]
* |_____|_____|
*
*
* \tparam dimension The hypercube dimension.
*/
namespace scalfmm::component
{
template<std::size_t Dim>
class z_curve
{
public:
/// Space dimension count
static const std::size_t dimension = Dim;
/// Template alias
template<typename T>
using position_alias = container::point<T,dimension>;
/// Position type used
using position_type = container::point<bool, dimension>;
/// Position count in the grid
static const std::size_t pos_count = pow(2,dimension);
private:
/// Array of positions type
using position_array_t = std::array<position_type, pos_count>;
/// Array to cache the positions corresponding to indexes
static const position_array_t _positions;
/** Creates an array of positions to initialize #_positions */
static position_array_t create_array() noexcept {
position_array_t positions;
for(std::size_t i = 0; i < pos_count; ++i) {
for(std::size_t j = dimension-1, k = i; k != 0; --j, k >>=1) {
positions[i][j] = k % 2;
}
}
return positions;
}
public:
/** The position corresponding to an index
*
* \param idx The index of the point in the space filling curve
* \return The position corresponding to the space filling curve index
*/
static position_type position(std::size_t idx) noexcept
{
return _positions[idx];
}
/** Index in the space filling curve of a boolean position
*
* \param p The position
* \return The space filling curve index corresponding to the position
*/
static std::size_t index(const position_type& p) noexcept
{
std::size_t idx = 0;
for(auto i : p) {
idx <<= 1;
idx += i;
}
return idx;
}
/** Index in the space filling curve of a real position relative to the center of the hypercube
*
* \param p The position
* \param center The center of the hypercube
* \return The space filling curve index corresponding to the position
*/
template<typename T>
static std::size_t index(const position_alias<T>& p, const position_alias<T>& center) noexcept
{
std::size_t idx = 0;
for(std::size_t i = 0; i < dimension; ++i) {
idx <<= 1;
idx += p[i] > center[i];
}
return idx;
}
};
// Initialization of static variable
template<std::size_t dimension>
const typename z_curve<dimension>::position_array_t z_curve<dimension>::_positions(z_curve<dimension>::create_array());
}
#endif
......@@ -42,7 +42,6 @@ namespace scalfmm::index
coords[i] <<= Dim-1;
}
}
return idx;
}
......@@ -63,8 +62,6 @@ namespace scalfmm::component
};
template< typename Node = node<> >
class tree
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment