ipc-sim / IPC

Incremental Potential Contact (IPC) is for robust and accurate time stepping of nonlinear elastodynamics. IPC guarantees intersection- and inversion-free trajectories regardless of materials, time-step sizes, velocities, or deformation severity.
https://ipc-sim.github.io/
MIT License
574 stars 73 forks source link

Ability to script motion of vertices with different DBCs at different times? #20

Closed kmindspark closed 3 years ago

kmindspark commented 3 years ago

This is more of a feature request, but is there currently no way to apply some DBCs for some time intervals and others for other time intervals?

zfergus commented 3 years ago

This functionality is not available in the config files, but you can create an animation script in C++. The file to look at and extend is src/AnimScripter.cpp.

If you look at the stretch and squash script: https://github.com/ipc-sim/IPC/blob/7697cbbb81cca99a842e514e35753e836d13a342/src/AnimScripter.cpp#L1618 hopefully you can get an idea of how it works. Basically, you initialize the action in AnimScripter<dim>::initAnimScript and dynamically change it in AnimScripter<dim>::stepAnimScript.

There are a couple of animation scripts in there. AST_NULL is the general case used for config txt files. To specify a script to run add the line script <scriptname> to your config file, where all scriptnames can be found here: https://github.com/ipc-sim/IPC/blob/7697cbbb81cca99a842e514e35753e836d13a342/src/AnimScripter.cpp#L33

zfergus commented 3 years ago

One other option that is exposed in the config files is the usage of DBCTimeRange and NBCTimeRange to specify the time range for which the BCs are active. For example, DBCTimeRange 1 10 will start applying DBC after 1 second and stop after 10 seconds of simulation.

kmindspark commented 3 years ago

Yeah I saw those, but I needed to script the motion of some particular vertices at different points in time. Thanks for the first suggestion, I will take a closer look at that.

kmindspark commented 3 years ago

I ended up modifying the source code to take in 2 additional numbers (start & end time) per DBC command so I could easily script motions. Resolved!

zfergus commented 3 years ago

Cool. Pull request welcome, if you want. I know this was something others had asked for.

zfergus commented 3 years ago

I just pushed a change that allows for start and end times to each DBC and NBC. More information can be found here: https://github.com/ipc-sim/IPC/wiki#timed-boundary-conditions

kmindspark commented 3 years ago

Thanks for the heads up. Sorry I didn't have time to make a pull request.