| tpass sliders as pointers in initialization - slidergrid - grid of elastic sliders on a frictional surface |
| git clone git://src.adamsgaard.dk/slidergrid |
| Log |
| Files |
| Refs |
| README |
| LICENSE |
| --- |
| commit 8e7d2be14d5283bfd8230b8eef858bbbca8c2723 |
| parent 762b3f6943d2c21d2ef469462691efae7aaa92d5 |
| Author: Anders Damsgaard |
| Date: Tue, 22 Mar 2016 11:56:45 -0700
pass sliders as pointers in initialization
Diffstat:
M slidergrid/grid.c | 5 +++++
M slidergrid/main.c | 6 ++++--
M slidergrid/slider.c | 15 ++++++++-------
M slidergrid/slider.h | 2 +-
4 files changed, 18 insertions(+), 10 deletions(-)
--- |
| diff --git a/slidergrid/grid.c b/slidergrid/grid.c |
| t@@ -61,6 +61,11 @@ void find_and_bond_to_neighbors_n2(
if (dist_norm < cutoff) {
sliders[i].neighbors[n_neighbors++] = j;
+#ifdef DEBUG_FIND_AND_BOND_TO_NEIGHBORS
+ printf("sliders[%d].neighbors[%d] = %d;\n",
+ i, n_neighbors-1, j);
+#endif
+
if (n_neighbors == MAX_NEIGHBORS - 1)
fprintf(stderr, "Error: MAX_NEIGHBORS exceeded for "
"slider %d.\n", i); |
| diff --git a/slidergrid/main.c b/slidergrid/main.c |
| t@@ -70,12 +70,14 @@ int main(int argc, char** argv)
// external function which defines the simulation setup and parameters
simulation sim = setup_simulation();
- if (verbose == 1)
+ if (verbose == 1) {
sim.verbose = 1;
+ printf("Sliders N = %d\n", sim.N);
+ }
// set initial values for the sliders
for (i=0; i |
| diff --git a/slidergrid/slider.c b/slidergrid/slider.c |
| t@@ -16,18 +16,19 @@ slider create_slider()
return s;
}
-void initialize_slider_values(slider s)
+void initialize_slider_values(slider* s)
{
- s.force = zeroes_float3();
- s.torque = zeroes_float3();
+ s->force = zeroes_float3();
+ s->torque = zeroes_float3();
// define all entries in neighbor list as empty
int i;
for (i=0; ineighbors[i] = -1;
+ s->neighbor_distance[i] = zeroes_float3();
+ s->neighbor_relative_distance_displacement[i] = zeroes_float3();
+ s->neighbor_relative_distance_velocity[i] = zeroes_float3();
}
} |
| diff --git a/slidergrid/slider.h b/slidergrid/slider.h |
| t@@ -47,7 +47,7 @@ typedef struct {
void print_slider_position(slider s);
-void initialize_slider_values(slider s);
+void initialize_slider_values(slider* s);
//void check_slider_values(slider s);
void update_kinematics(slider s, Float dt, long int iteration); |