{"id":27624358,"url":"https://github.com/vietnoirien/sand_cmulation","last_synced_at":"2025-04-23T11:34:44.009Z","repository":{"id":288896951,"uuid":"968568315","full_name":"Vietnoirien/Sand_Cmulation","owner":"Vietnoirien","description":"A high-performance particle simulation system with advanced spatial partitioning in C++.","archived":false,"fork":false,"pushed_at":"2025-04-20T09:34:03.000Z","size":876,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-20T10:22:25.519Z","etag":null,"topics":["2d-arrays","cpp17","openmp","simulation-engine"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Vietnoirien.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-04-18T10:13:16.000Z","updated_at":"2025-04-20T09:34:07.000Z","dependencies_parsed_at":"2025-04-20T10:38:29.873Z","dependency_job_id":null,"html_url":"https://github.com/Vietnoirien/Sand_Cmulation","commit_stats":null,"previous_names":["vietnoirien/sand_cmulation"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Vietnoirien%2FSand_Cmulation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Vietnoirien%2FSand_Cmulation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Vietnoirien%2FSand_Cmulation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Vietnoirien%2FSand_Cmulation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Vietnoirien","download_url":"https://codeload.github.com/Vietnoirien/Sand_Cmulation/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250426293,"owners_count":21428711,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["2d-arrays","cpp17","openmp","simulation-engine"],"created_at":"2025-04-23T11:34:42.440Z","updated_at":"2025-04-23T11:34:43.996Z","avatar_url":"https://github.com/Vietnoirien.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Sand_Cmulation\n\nA high-performance particle simulation system with advanced spatial partitioning in C++.\n\n## Overview\n\nSand_Cmulation is a CS50X final project that implements a particle-based sand simulation with efficient spatial queries and grid operations. The system uses a combination of grid-based storage and spatial hashing to achieve high-performance particle operations.\n\n## Features\n\n- High-performance spatial partitioning with O(1) lookups\n- Thread-safe operations with OpenMP parallelization\n- Advanced spatial queries (radius, box, k-nearest neighbors)\n- Memory-efficient particle storage\n- Real-time memory usage monitoring\n- Optimized batch operations\n\n## Current Status\n\nThe project is currently in development. The grid system is visually functional, demonstrating the basic particle simulation capabilities.\n\n## Grid System\n\nThe core of the simulation is the `GridSpatialConnector` which provides a unified interface between the grid storage and spatial hash systems:\n\n### Key Components\n\n- **Grid**: Stores particles in a 2D array\n- **SpatialHash**: Provides O(1) spatial lookups\n- **QuerySystem**: Handles advanced spatial queries\n- **GridOperations**: Manages grid-level operations\n\n### Performance Metrics\n\nThe following metrics were measured on an i9 9900KF processor with DDR4 @ 3200MHz:\n\n- Insertion: ~613k particles/second\n- Queries: ~49k queries/second\n- Batch sync: ~2.4M updates/second\n- Movement: ~79k moves/second\n\n## Usage Examples\n\n```cpp\n// Initialize systems\nGrid grid(1000, 1000);\nSpatialHash spatialHash;\nGridSpatialConnector connector(grid, spatialHash);\n\n// Basic particle operations\nParticle sand;\nconnector.addParticle(x, y, sand);\nconnector.moveParticle(oldX, oldY, newX, newY);\n\n// Get neighboring cells\nauto neighbors = connector.getNeighbors(x, y);\n\n// Advanced spatial queries\nVector2D pos(x, y);\nfloat radius = 5.0f;\nauto nearbyParticles = connector.queryRadius(pos, radius);\n\n// Box query\nVector2D min(x1, y1), max(x2, y2);\nauto particlesInBox = connector.queryBox(min, max);\n\n// K-nearest neighbors\nauto nearestParticles = connector.queryKNearest(pos, 10);\n```\n\n## API Categories\n\n### Particle Operations\n- `addParticle()`: Add new particle\n- `removeParticle()`: Remove particle\n- `moveParticle()`: Move particle with boundary checking\n- `getNeighbors()`: Get valid neighboring cells\n\n### Basic Spatial Queries\n- `queryArea()`: Simple area query\n- `isValidPosition()`: Position validation\n- `isEmpty()`: Cell emptiness check\n\n### Advanced Spatial Queries\n- `queryRadius()`: Radius-based search\n- `queryRadiusFiltered()`: Filtered radius search\n- `queryBox()`: Box-bounded search\n- `queryKNearest()`: K-nearest neighbors\n- `queryDenseRegions()`: Density-based search\n\n### Grid Properties\n- `getWidth()`: Grid width\n- `getHeight()`: Grid height\n- `getParticle()`: Particle access\n\n### System Operations\n- `update()`: System sync\n- `clear()`: System reset\n- `batchSyncDirtyStates()`: Force sync\n\n### Performance Monitoring\n- `getMetrics()`: Performance metrics\n- `resetMetrics()`: Reset counters\n\n### Memory Management\n- `getCurrentMemoryUsage()`: Get current memory usage\n- `getPeakMemoryUsage()`: Get peak memory usage\n- `getMemoryAllocationMap()`: Get detailed memory allocation map\n\n## Current Interface\n\nThe current user interface is minimal and designed primarily to visually verify that the grid system is working correctly. As this is a CS50X final project, the focus has been on implementing the core simulation functionality rather than a polished UI.\n\n## Future Improvements\n\n- Implement a more user-friendly interface\n- Add more particle types and interactions\n- Optimize memory usage for larger simulations\n- Add persistence for saving/loading simulation states\n\n## Building the Project\n\n```bash\nmake\n```\n\n## Running the Simulation\n\n```bash\n./sand_simulation\n```\n\n## Requirements\n\n- C++17 compatible compiler\n- OpenMP for parallel processing\n- SDL2 library\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvietnoirien%2Fsand_cmulation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvietnoirien%2Fsand_cmulation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvietnoirien%2Fsand_cmulation/lists"}