tgrain.c: resolve issues around grain fixing and rotation lock - granular - granular dynamics simulation
 (HTM) git clone git://src.adamsgaard.dk/granular
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 01f75f59b3a0ddbaacdf66d98100c45300652fbd
 (DIR) parent c5d3ea04206942befe8197ee0fee4e8f49fc7ccb
 (HTM) Author: Anders Damsgaard <anders@adamsgaard.dk>
       Date:   Fri, 23 Apr 2021 06:20:49 +0200
       
       grain.c: resolve issues around grain fixing and rotation lock
       
       Diffstat:
         M grain.c                             |      10 ++++++----
       
       1 file changed, 6 insertions(+), 4 deletions(-)
       ---
 (DIR) diff --git a/grain.c b/grain.c
       t@@ -318,16 +318,18 @@ grain_temporal_integration_two_term_taylor(struct grain *g, double dt)
                double moment_of_inertia = grain_moment_of_inertia(g);
        
                for (d = 0; d < 3; d++) {
       -                if (!g->acc_lock[d])
       -                        g->acc[d] = (g->force[d] + g->forceext[d]) / mass;
       +                g->acc[d] = (g->force[d] + g->forceext[d]) / mass;
        
                        if (g->rotating)
                                g->angacc[d] = g->torque[d] / moment_of_inertia;
                }
        
                if (g->fixed)
       -                for (d = 0; d < 3; d++)
       -                        g->acc[d] = 0.0;
       +                for (d = 0; d < 3; d++) {
       +                        g->angacc[d] = 0.0;
       +                        if (!g->acc_lock[d])
       +                                g->acc[d] = 0.0;
       +                }
        
                for (d = 0; d < 3; d++) {
                        dx = g->vel[d] * dt + 0.5 * g->acc[d] * dt * dt;