All Projects → Elias-Gu → Mpm2d

Elias-Gu / Mpm2d

Licence: mit
2D Material Point Method

Projects that are alternatives of or similar to Mpm2d

Attack range
A tool that allows you to create vulnerable instrumented local or cloud environments to simulate attacks against and collect the data into Splunk
Stars: ✭ 693 (+2672%)
Mutual labels:  simulation
Spritekit Leaf Simulation
A simulation of leaves blowing in the wind created with SpriteKit.
Stars: ✭ 6 (-76%)
Mutual labels:  simulation
Dig Into Apollo
Apollo notes (Apollo学习笔记) - Apollo learning notes for beginners.
Stars: ✭ 903 (+3512%)
Mutual labels:  simulation
Su2
SU2: An Open-Source Suite for Multiphysics Simulation and Design
Stars: ✭ 731 (+2824%)
Mutual labels:  simulation
Openmm
OpenMM is a toolkit for molecular simulation using high performance GPU code.
Stars: ✭ 791 (+3064%)
Mutual labels:  simulation
Splatter Paper
Data and analysis for the Splatter paper
Stars: ✭ 17 (-32%)
Mutual labels:  simulation
Awesome Open Geoscience
Curated from repositories that make our lives as geoscientists, hackers and data wranglers easier or just more awesome
Stars: ✭ 668 (+2572%)
Mutual labels:  simulation
Fastscape
A fast, versatile and user-friendly landscape evolution model
Stars: ✭ 22 (-12%)
Mutual labels:  simulation
Citybound
A work-in-progress, open-source, multi-player city simulation game.
Stars: ✭ 6,646 (+26484%)
Mutual labels:  simulation
Simex
Start-to-end photon experiment simulation platform
Stars: ✭ 18 (-28%)
Mutual labels:  simulation
Reactphysics3d
Open source C++ physics engine library in 3D
Stars: ✭ 730 (+2820%)
Mutual labels:  simulation
Shadow
Shadow is a unique discrete-event network simulator that runs real applications like Tor, and distributed systems of thousands of nodes on a single machine. Shadow combines the accuracy of emulation with the efficiency and control of simulation, achieving the best of both approaches.
Stars: ✭ 769 (+2976%)
Mutual labels:  simulation
Uav coverage
Simulation for planar area coverage by a swarm of UAVs
Stars: ✭ 17 (-32%)
Mutual labels:  simulation
Mmcamscanner
Simulation of CamScanner app With Custom Camera and Crop Rect Validation
Stars: ✭ 728 (+2812%)
Mutual labels:  simulation
Ditras
DITRAS (DIary-based TRAjectory Simulator), a mathematical model to simulate human mobility
Stars: ✭ 19 (-24%)
Mutual labels:  simulation
Abstreet
Transportation planning and traffic simulation software for creating cities friendlier to walking, biking, and public transit
Stars: ✭ 6,355 (+25320%)
Mutual labels:  simulation
Causal Inference For Data Scientists
Notebooks of Python and R code which illustrates basic causal inference using simulated data
Stars: ✭ 17 (-32%)
Mutual labels:  simulation
Vkb
Bot for vk.com competitions
Stars: ✭ 24 (-4%)
Mutual labels:  simulation
Pyncov 19
Pyncov-19: Learn and predict the spread of COVID-19
Stars: ✭ 20 (-20%)
Mutual labels:  simulation
Reads For Assembly
Simulate metagenomic short reads from one or more populations.
Stars: ✭ 17 (-32%)
Mutual labels:  simulation

MPM2D

2D implementation of the Material Point Method.

water snow elastic

Sections

Overview

C++ implementation of the Material Point Method.

The Material Point Method is a numerical technique used to simulate the behavior of continuum materials.

The continuum body is described by a number a Lagrangian elements : the material points. Kinematic equations are solved on the material points
The material points are surrounded by a background Eulerian grid where the dynamic equations are solved.

It can be summarize in 4 main steps:

  1. Transfer data from particles de grid nodes
  2. Update node state (apply forces)
  3. Transfer data from grid nodes to particles
  4. Update particles state

Papers implemented

The following papers are implemented here:

Dependencies

The following libraries are includes in the ext/ directory:

This project additionally requires the following libraries:

  • OpenGL and GLFW - Visuals.
  • Eigen - Eigen can be used to replace Algebra, but it is not as fast. The source code is in ext/Eigen/MPM2D/src/ (not updated).

The followings are optional dependencies :

Code structure

The code, located in src/, is structured as following:

  • main.cpp: OpenGL context. Run simulation.
  • solver.h and solver.cpp: MPM algorithm functions (transfers and updates). Rendering and WriteToFile.
  • node.h and node.cpp: Class for grid nodes.
  • border.h and border.cpp: Class for 2D linear borders. Collision and Friction.
  • particle.h and particle.cpp: Class and subclasses for particles and materials. Constitutive model and deformation functions.
  • constants.h: Option control and global constants.

Implementation

Characteristics:

Here are the main features of this implementation:

  • Sand, Water, Snow and purely elastic simulations already implemented
  • 2D.
  • Affine-Particle-in-Cell (APIC) transfer type.
  • B-Spline Quadratic or Cubic interpolation functions (Quadratic is faster, but not as precise).
  • Node forces are updated with an explicit method.
  • The domain has to be a convex geometry (for collision detection).

Add material type:

It is easy to add a new type of material. In particle.h and particle.cpp, create a new subclasse of Particle. Beside constructors, the subclass must contain the following functions:

  • In particle.h:
static std::vector<NewMaterial> InitializeParticles() {
        // Define initial particle mass, volume, position, velocity and acceleration
        std::vector<NewMaterial> outParticles;
        // ...
	return outParticles;
}
static std::vector<NewMaterial> AddParticles() {
        // Define mass, volume, position, velocity and acceleration of particles to add during the simulation
	std::vector<NewMaterial> outParticles;
        // ...
	return outParticles;
}
  • In particle.cpp:
void NewMaterial::ConstitutiveModel() {
    // Update Ap (pre-update deformation gradient)
}
void NewMaterial::UpdateDeformation(const Matrix2f& T) {
    // Update deformation gradient. 
    // T is the sum of the close node velocity gradients.
    // Elasticity, Plasticity functions (return-mapping, hardening) ...
}
void NewMaterial::DrawParticle() {
    // OpenGL output of particle points
}

Change domain geometry:

The shape of the domain can be changed, but is has to follow this rules:

  • It has to be convex.
  • It has to be included in [CUB ; X_GRID - CUB] x [CUB ; Y_GRID - CUB], where CUB is the range of the interpolation function (2 for Cubic, 1.5 for Quadratic).
  • Borders have to be straight lines.

To modify the domain, in border.h, use the InitializeBorders static function:

static std::vector<Border> InitializeBorders() {
        std::vector<Border> outBorders;
        std::vector<Vector2f> Corners;

        // New border line
	Corners.push_back(Vector2f(X1, Y1));    // First point
	Corners.push_back(Vector2f(X2, Y2));    // Second point
        // type can be [1](sticky), [2](Separating) or [3](Sliding)
        // normal has to be oriented inside the domain and normalized
	outBorders.push_back(Border(type, normal, Corners));
	Corners.clear();

        // Add other border

	return outBorders;
}



Options

Here is a list of different options available. They can be modify in the constants.h file.

  • Grid:
// Size of the domain
const static int X_GRID = 128;
const static int Y_GRID = 64;
  • Particle:
// Select Particle subclass (material type). [Water], [DrySand], [Snow], [Elastic]
#define Material NewMaterial
  • Transfer particles <-> grid:
// Interpolation type: [1] Cubic - [2] Quadratic
#define INTERPOLATION 1	
// Time-step (typically about 1e-4)
const static float DT = 0.0001f;
  • Output (outputs will be generated in the out/ directory):
// Generate a .mp4 of the OpenGL window
#define RECORD_VIDEO true
// Generate a .ply file with node coordinates
#define WRITE_TO_FILE false	
// Draw nodes (active nodes have a different color)
#define DRAW_NODES false        // not recommended (slow)



Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].