aboria / Aboria

Enables computations over a set of particles in N-dimensional space

Home Page:https://aboria.github.io/Aboria

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TravisCI Coverage Join the chat at https://gitter.im/Aboria/Lobby

Aboria is a C++ library that enables computations over a set of particles or points in N-dimensional space, with the aim of providing a useful library for implementing particle-based numerical algorithms, for example Molecular Dynamics, Smoothed Particle Hydrodynamics or Radial Basis Functions.

A standards-compliant particle container

The library gives you a STL compatible container class to store a particle set containing a position and unique id for each particle, as well as any number of user-defined variables with arbitrary types.

ABORIA_VARIABLE(scalar, double, "an example scalar variable")
const int DIM = 2;
using Particles_t = Particles<std::tuple<scalar>,DIM>;
using position = Particles_t::position;
Particles_t particles(100);

std::normal_distribution<double> normal(0.5, 0.2);
std::default_random_engine gen;
for (auto i: particles) {
  get<position>(i) = vdouble2(normal(gen), normal(gen));
  get<scalar>(i) = normal(gen);
}

Spatial data structures and queries

Aboria gives you the ability to embed each particle set within a hypercube domain with arbitrary periodicity. The underlying data structure can be a cell list, kd-tree or hyper oct-tree.

      

These data structures provide flexible neighbourhood queries that return iterators, and can use any integer p-norm distance measure for p > 0.

for (auto i = euclidean_search(particles.get_query(),
                               vdouble2::Constant(0), radius);
         i != false; ++i) {
  std::cout << "Found a particle with dx = " << i.dx()
            << " and id = " << get<id>(*i) << "\n";
}

An API for forming linear kernel operators

Aboria gives you an API for forming linear kernel operators from C++ lambda functions, This can be used, for example, to implement Radial Basis Function kernels. These can be wrapped as Eigen matrices in order to solve linear systems.

auto K = create_sparse_operator(
    particles, particles, radius,
    [epsilon](const vdouble2 &dx, auto i, auto j) {
      return (get<scalar>(i) * get<scalar>(j)) / (dx.norm() + epsilon);
    });

// matrix-vector multiply (matrix-free)
const int N = particles.size();
Eigen::VectorXd b = Eigen::VectorXd::LinSpaced(N, 0, 1.0);
Eigen::VectorXd c = K * b;

// matrix-vector multiply (assemble to a matrix first)
Eigen::MatrixXd K_eigen(N, N);
K.assemble(K_eigen);
c = K_eigen * b;

License and Contact

Aboria is distributed under a BSD 3-Clause License, see LICENCE for more details. For documentation see the Aboria website. If you are interested in contributing to Aboria, having trouble getting it working or just have a question, send me an email at martin.robinson@cs.ox.ac.uk or create a GitHub issue or pull request.

About

Enables computations over a set of particles in N-dimensional space

https://aboria.github.io/Aboria

License:Other


Languages

Language:C++ 74.0%Language:Python 19.9%Language:XSLT 2.8%Language:CMake 1.2%Language:C 0.8%Language:Shell 0.5%Language:Ruby 0.4%Language:Perl 0.4%Language:Makefile 0.0%Language:Smarty 0.0%Language:MATLAB 0.0%Language:Batchfile 0.0%