tdetermine bond total tension/compression and tension/compression rate - slidergrid - grid of elastic sliders on a frictional surface
 (HTM) git clone git://src.adamsgaard.dk/slidergrid
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 4d51c127fcf39c33d6a85637b5cb51b321fe320a
 (DIR) parent 1cbb23226d339f3e3ef3d13fef3ab0141148fcbe
 (HTM) Author: Anders Damsgaard <anders.damsgaard@geo.au.dk>
       Date:   Wed, 16 Mar 2016 10:56:21 -0700
       
       determine bond total tension/compression and tension/compression rate
       
       Diffstat:
         M slider.c                            |      31 +++++++++++++++++++++++++++++--
         M slider.h                            |       5 +++--
         M vector_math.c                       |       5 +++++
         M vector_math.h                       |       1 +
       
       4 files changed, 38 insertions(+), 4 deletions(-)
       ---
 (DIR) diff --git a/slider.c b/slider.c
       t@@ -62,12 +62,17 @@ void update_kinematics(slider s, Float dt, long int iteration)
        }
        
        // Find the relative displacement and velocity between two sliders
       -void slider_displacement(slider s1, const slider s2, const Float dt)
       +void slider_displacement(slider s1, const slider s2, const Float dt, const int i)
        {
        
       +    // vector pointing from neighbor (s2) position to this slider position (s1)
            const Float3 dist = subtract_float3(s1.pos, s2.pos);
       +
       +    // length of inter-slider vector
            const Float dist_norm = norm_float3(dist);
        
       +    // unit vector pointing from neighbor (s2) to slider s1
       +    const Float3 n = divide_float3_scalar(dist, dist_norm);
        
            // relative contact interface velocity w/o rolling
            const Float3 vel_linear = subtract_float3(s1.vel, s2.vel);
       t@@ -80,12 +85,34 @@ void slider_displacement(slider s1, const slider s2, const Float dt)
                        multiply_scalar_float3(dist_norm/2.,
                            cross_float3(dist, s2.angvel))));
        
       +    // Normal component of the relative contact interface velocity
       +    const Float vel_n = multiply_scalar_float3(-1.0, dot_float3(vel_linear, n));
       +
       +    // Tangential component of the relative contact interface velocity
       +    // Hinrichsen and Wolf 2004, eq. 13.9
       +    const Float3 = subtract_float3(vel, multiply_float3(n, dot_float3(n, vel)));
       +
       +    // read previous inter-slider distance vector
       +    const Float3 dist0 = s1.neighbor_distance[i];
       +
       +    // increment in inter-slider distance
       +    const Float3 ddist = subtract_float3(dist, dist0);
       +
       +    // save current inter-slider distance
       +    s1.neighbor_distance[i] = dist;
       +
       +    // total relative displacement in inter-slider distance
       +    s1.neighbor_relative_distance_displacement[i] =
       +        add_float3(s1.neighbor_relative_distance_displacement[i], ddist);
        
       +    // total relative displacement in inter-slider distance
       +    s1.neighbor_relative_distance_velocity[i] = vel_n;
        
        }
        
        
       -// Resolve bond mechanics between a slider and one of its neighbors
       +// Resolve bond mechanics between a slider and one of its neighbors based on the 
       +// incremental linear-elastic model by Potyondy and Cundall 2004
        
        
        // Resolve interaction between a slider and all of its neighbors
 (DIR) diff --git a/slider.h b/slider.h
       t@@ -41,8 +41,9 @@ typedef struct {
            int neighbors[MAX_NEIGHBORS];
        
            // relative spatial movement between this slider and its neighbors
       -    Float3 neighbor_relative_displacement[MAX_NEIGHBORS];
       -    Float3 neighbor_relative_contact_velocity[MAX_NEIGHBORS];
       +    Float3 neighbor_distance[MAX_NEIGHBORS];
       +    Float3 neighbor_relative_distance_displacement[MAX_NEIGHBORS];
       +    Float neighbor_relative_distance_velocity[MAX_NEIGHBORS];
        
        } slider;
        
 (DIR) diff --git a/vector_math.c b/vector_math.c
       t@@ -51,6 +51,11 @@ inline Float3 cross_float3(Float3 v1, Float3 v2)
                    v1.x*v2.y - v1.y*v2.x);
        }
        
       +inline Float dot_float3(Float3 v1, Float3 v2)
       +{
       +    return v1.x*v2.x + v1.y*v2.y + v1.z*v2.z;
       +}
       +
        // vector-scalar operations
        inline Float3 add_float3_scalar(Float3 v, Float s)
        {
 (DIR) diff --git a/vector_math.h b/vector_math.h
       t@@ -13,6 +13,7 @@ Float3 subtract_float3(Float3 v1, Float3 v2);
        Float3 multiply_float3(Float3 v1, Float3 v2);
        Float3 divide_float3(Float3 v1, Float3 v2);
        Float3 cross_float3(Float3 v1, Float3 v2);
       +Float dot_float3(Float3 v1, Float3 v2)
        
        // vector-scalar operations
        Float3 multiply_float3_scalar(Float3 v, Float s);