forked from brown-cs-224/FEM-Stencil
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME
48 lines (38 loc) · 4.5 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
Simulation README
The program requires one command line argument to run: an input .mesh file. If none is provided, it will default to the sphere mesh. To toggle other features on/off, please change the macros defined at top of the simulation.cpp file and view.cpp file. Parameters for elements are in element.cpp, but I don't recommend changing those (density, phi, psi, lambda, mu) due to volatility. At the top of view.cpp, there is the option to run the simulation using RK4 time integration (this is on by default-- simply switch macro to "false" to use midpoint method). At the top of simulation.cpp, there are 4 options to toggle: using gravity, including a rigid sphere obstacle in the scene, using drag/air resistance, and recalculating the surface area for drag at every time step (explained more in Drag below). The default includes gravity and the sphere, but not drag (or area recalculation). The air density value can be changed to see a more dramatic effect of drag, and gravity can be changed as well (though neither is necessary). All simulations use a time step of 0.015.
Features implemented:
Surface mesh extraction (in simulation.cpp)
Gravitational force (in simulation.cpp): Gravitational force on each node is calculated as that node's mass * acceleration due to gravity (defined in macro).
Internal elastic forces (strain/stress) (in Element.cpp)
Internal viscous damping forces (in Element.cpp)
Collisions (with ground plane and sphere) (in simulation.cpp): implemented with sphere. The sphere is by default defined to have radius 1 and center at the origin. I rendered the sphere mesh at this position to visualize the obstacle.
Midpoint method time integration (in simulation.cpp)
Extra features:
RK4 time integration (in simulation.cpp): Comparing regular midpoint integration (Sphere_midpoint.mp4) with RK4 integration (Sphere_rk4.mp4) on the sphere colliding with the sphere/plane shows less "stickiness" when using RK4.
Drag (in simulation.cpp): implemented air resistance, which acts on the object as a whole. Generally somewhat difficult to see the difference if using real values of air density because air is not that dense and only slows down the object by a tiny bit, but increasing AIR_DENSITY (at the top of simulation.cpp) to simulate moving through denser volumes than air will show the object moving slower and stopping movement sooner. Drag is calculated in updateForces(), and acts on the whole object opposite to the direction of the object's velocity (I used the average velocity of all nodes in the object for this). It also uses the surface area of the object in the direction of motion, for which I use the sum of the area of the surface face triangles whose normals have a positive dot product with the average velocity vector. I actually experimented with 2 different ways of doing this: the first being only calculating the surface area once at the beginning of the simulation, using the area of the surface face triangles who had a negative y-component and reusing that value for each drag calculation, and the second being recalculating the surface area as described at each time step, where faces' areas are counted if their normals have a positive dot product with the average velocity vector. I am unsure which actually produced more physically accurate results, so I leave the option to the user to toggle between the 2 options using the RECALC_AREA macro at the top of simulation.cpp. This macro is false by default, and changing it to true will use the 2nd method described, where the surface area is recalculated at each time step.
Videos (inside videos folder in root directory): Features demonstrated
All videos:
surface mesh extraction
internal elastic forces
Internal viscous damping forces
Single-tet_single_point.mp4:
Midpoint method
For this video, I displaced one vertex from its rest position. (Code at bottom of Simulation::init().)
**For the following videos, I shifted the shapes up by 1 unit so they would have more time to accelerate from gravity. (Code at bottom of Simulation::init(), ON by default but can be easily commented out (lines 118-120).)
Ellipsoid_gravity:
Gravitational force
Collisions
Midpoint method
Sphere_midpoint: (Used for comparisons with Sphere_rk4.mp4, visibly more "sticky" than using RK4 integration in initial bounces off the rigid sphere)
Gravitational force
Collisions
Midpoint method
Sphere_rk4:
Gravitational force
Collisions
RK4 integration
Sphere_rk4_drag: (AIR_DENSITY = 1.5, C_d=0.47, RECALC_AREA=true)
Gravitational force
Collisions
RK4 integration
Drag/Air resistance