Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

2D Material Point Method

License

NotificationsYou must be signed in to change notification settings

Elias-Gu/MPM2D

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 

Repository files navigation

2D implementation of the Material Point Method.

watersnowelastic

Sections

Overview

C++ implementation of the Material Point Method.

TheMaterial 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 theext/ directory:

This project additionally requires the following libraries:

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

The followings are optional dependencies :

Code structure

The code, located insrc/, is structured as following:

  • main.cpp: OpenGL context. Run simulation.
  • solver.h andsolver.cpp: MPM algorithm functions (transfers and updates). Rendering and WriteToFile.
  • node.h andnode.cpp: Class for grid nodes.
  • border.h andborder.cpp: Class for 2D linear borders. Collision and Friction.
  • particle.h andparticle.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. Inparticle.h andparticle.cpp, create a new subclasse ofParticle. Beside constructors, the subclass must contain the following functions:

  • Inparticle.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 simulationstd::vector<NewMaterial> outParticles;// ...return outParticles;}
  • Inparticle.cpp:
voidNewMaterial::ConstitutiveModel() {// Update Ap (pre-update deformation gradient)}
voidNewMaterial::UpdateDeformation(const Matrix2f& T) {// Update deformation gradient.// T is the sum of the close node velocity gradients.// Elasticity, Plasticity functions (return-mapping, hardening) ...}
voidNewMaterial::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 beconvex.
  • It has to be included in [CUB ;X_GRID - CUB] x [CUB ;Y_GRID - CUB], whereCUB is the range of the interpolation function (2 for Cubic, 1.5 for Quadratic).
  • Borders have to be straight lines.

To modify the domain, inborder.h, use theInitializeBorders static function:

static std::vector<Border>InitializeBorders() {        std::vector<Border> outBorders;        std::vector<Vector2f> Corners;// New border lineCorners.push_back(Vector2f(X1, Y1));// First pointCorners.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 normalizedoutBorders.push_back(Border(type,normal, Corners));Corners.clear();// Add other borderreturn outBorders;}



Options

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

  • Grid:
// Size of the domainconststaticint X_GRID =128;conststaticint Y_GRID =64;
  • Particle:
// Select Particle subclass (material type). [Water], [DrySand], [Snow], [Elastic]#defineMaterial NewMaterial
  • Transfer particles <-> grid:
// Interpolation type: [1] Cubic - [2] Quadratic#defineINTERPOLATION1// Time-step (typically about 1e-4)conststaticfloat DT =0.0001f;
  • Output (outputs will be generated in theout/ directory):
// Generate a .mp4 of the OpenGL window#defineRECORD_VIDEOtrue// Generate a .ply file with node coordinates#defineWRITE_TO_FILEfalse// Draw nodes (active nodes have a different color)#defineDRAW_NODESfalse// not recommended (slow)



Releases

No releases published

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp