https://github.com/liby99/storage_utils
Dense and Sparse Vector Storage Library
https://github.com/liby99/storage_utils
Last synced: 10 months ago
JSON representation
Dense and Sparse Vector Storage Library
- Host: GitHub
- URL: https://github.com/liby99/storage_utils
- Owner: Liby99
- Created: 2020-02-01T17:21:50.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-02-03T20:47:46.000Z (almost 6 years ago)
- Last Synced: 2025-01-21T10:51:05.444Z (12 months ago)
- Language: C++
- Homepage:
- Size: 52.7 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Storage Utilities
A header only vector storage utilities library in C++.
## Usage
``` c++
// mass, position, velocity
using Particles = VecStorageGroup;
// theta_c, theta_s, deformation_gradient
using Deformations = DenseStorageGroup;
// hardening
using Hardenings = DenseStorageGroup;
int main() {
Particles particles;
Deformations deformations;
Hardenings hardenings;
for (int i = 0; i < 100; i++) {
auto id = particles.insert(1.0, Vector2f(1.0, 1.0), Vector2f(1.0, 1.0));
if (i < 25) { hardenings.insert(id, 1.0); }
if (i < 50) { deformations.insert(id, 0.0, 1.0, Matrix2f(1.0, 0.0, 0.0, 1.0)); }
}
for (auto [id, m, x, v, tc, ts, F] : particles.join(deformations)) {
// Do things with particle & deformations
}
for (auto [id, m, x, v, hardening] : particles.join(hardenings)) {
// Do things with particle & hardenings
}
for (auto [id, m, x, v, tc, ts, F, h] : particles.join(deformations, hardenings)) {
// Do things with particle & deformation & hardenings
}
}
```
## Compile & Run Test
This repo follows standard CMake build process:
```
$ mkdir build
$ cd build
$ cmake ..
$ make
```
After that, if you want to test, you can type:
```
$ make test
```
This will run each of the executables inside the `tests` folder.
## Include this library in your CMake Project
Since this project is a header only library, you can simply use the following code in your `CMakeLists.txt` file:
``` cmake
add_subdirectory(${PATH_TO_YOUR_STORAGE_UTILS_DIR})
target_include_directories(${YOUR_TARGET} PUBLIC ${PATH_TO_YOUR_STORAGE_UTILS_DIR}/include/)
```
And then you can use, in your `C++` code,
```
#include
```