twrite all kinematic values to text file - 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 18aacc6e97a8d8b41b307dbd97051738a3218759 (DIR) parent b315e491a0bfd7a53ef281f41933220f8de8e0c2 (HTM) Author: Anders Damsgaard <anders.damsgaard@geo.au.dk> Date: Wed, 30 Mar 2016 13:37:43 -0700 write all kinematic values to text file Diffstat: M slidergrid/simulation.c | 29 +++++++++++++++++++++++++---- M slidergrid/simulation.h | 4 ++-- M slidergrid/slider.c | 21 +++++++++++++++------ 3 files changed, 42 insertions(+), 12 deletions(-) --- (DIR) diff --git a/slidergrid/simulation.c b/slidergrid/simulation.c t@@ -102,7 +102,7 @@ Float find_time_step(const slider* sliders, const int N, const Float safety) return safety/sqrt(largest_stiffness/smallest_mass); } -int save_slider_positions_to_file( +int save_slider_data_to_file( const slider* sliders, const int N, const char* filename) t@@ -115,8 +115,29 @@ int save_slider_positions_to_file( int i; for (i=0; i<N; i++) - fprintf(f, "%f\t%f\t%f\n", - sliders[i].pos.x, sliders[i].pos.y, sliders[i].pos.z); + fprintf(f, + "%f\t%f\t%f\t" // pos + "%f\t%f\t%f\t" // vel + "%f\t%f\t%f\t" // acc + "%f\t%f\t%f\t" // force + "%f\t%f\t%f\t" // angpos + "%f\t%f\t%f\t" // angvel + "%f\t%f\t%f\t" // angacc + "%f\t%f\t%f\t" // torque + "%f\t" // mass + "%f" // moment of inertia + "\n", + sliders[i].pos.x, sliders[i].pos.y, sliders[i].pos.z, + sliders[i].vel.x, sliders[i].vel.y, sliders[i].vel.z, + sliders[i].acc.x, sliders[i].acc.y, sliders[i].acc.z, + sliders[i].force.x, sliders[i].force.y, sliders[i].force.z, + sliders[i].angpos.x, sliders[i].angpos.y, sliders[i].angpos.z, + sliders[i].angvel.x, sliders[i].angvel.y, sliders[i].angvel.z, + sliders[i].angacc.x, sliders[i].angacc.y, sliders[i].angacc.z, + sliders[i].torque.x, sliders[i].torque.y, sliders[i].torque.z, + sliders[i].mass, + sliders[i].moment_of_inertia + ); fclose(f); return 0; t@@ -307,7 +328,7 @@ int write_simulation_output(simulation* sim, char* output_folder) // slider parameters sprintf(filename, "%s/%s.sliders.%06d.txt", output_folder, sim->id, sim->file_number); - if (save_slider_positions_to_file(sim->sliders, sim->N, filename)) { + if (save_slider_data_to_file(sim->sliders, sim->N, filename)) { fprintf(stderr, "\nFatal error: Could not save to output file " "'%s'.\n", filename); return 1; (DIR) diff --git a/slidergrid/simulation.h b/slidergrid/simulation.h t@@ -26,8 +26,8 @@ Float find_time_step(const slider* sliders, const int N, const Float safety); // check if simulation parameters have reasonable values int check_simulation_values(const simulation* sim); -// save slider positions to a file on the disk -int save_slider_positions_to_file( +// save slider information to a file on the disk +int save_slider_data_to_file( const slider* sliders, const int N, const char* filename); (DIR) diff --git a/slidergrid/slider.c b/slidergrid/slider.c t@@ -127,6 +127,9 @@ void update_kinematics(slider* s, Float dt, long int iteration) s->angvel = add_float3(s->angvel, dangvel_dt); } + +// determine time step increment bond-parallel deformation (tension or +// compression) void bond_parallel_deformation(slider* s1, const slider s2, const int idx_neighbor, const int iteration) { t@@ -151,8 +154,8 @@ void bond_parallel_deformation(slider* s1, const slider s2, // determine projected future displacement const Float3 dist_future = subtract_float3(s1->pos_future, s2.pos_future); - // increment in inter-slider distance, divide by two to get displacement - // over 1 time step + // increment in inter-slider distance with central differences, divide by + // two to get displacement over 1 time step const Float3 ddist = divide_float3_scalar( subtract_float3(dist_future, dist0), 2.0); t@@ -173,8 +176,11 @@ void bond_parallel_deformation(slider* s1, const slider s2, multiply_float3_scalar(n, vel_n); } + +// determine time step increment bond-oblique deformation (shear, bending, +// and/or twist) void bond_normal_deformation(slider* s1, const slider s2, - const int idx_neighbor, const int iteration) + const int idx_neighbor, const int iteration, const Float dt) { // vector pointing from neighbor (s2) position to this slider position (s1) const Float3 dist = subtract_float3(s1->pos, s2.pos); t@@ -217,14 +223,17 @@ void bond_normal_deformation(slider* s1, const slider s2, multiply_float3(n, tangential_displacement0_uncor))); // project future tangential displacement - + const Float3 dtangential_displacement = multiply_float3_scalar(vel_t, dt); + const Float3 tangential_displacement_future = + add_float3(tangential_displacement0, dtangential_displacement); // determine dtangential_displacement by central differences - // use dtangential_displacement for elastic response + // use dtangential_displacement for elastic response on shear motion + + // use vel_t for viscous response on shear motion - // use vel_t for viscous response }