tpass pointer to structure instead of structure - slidergrid - grid of elastic … | |
git clone git://src.adamsgaard.dk/slidergrid | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit d45ab4c31a7de996f1785ca5d8fb7bc17c06c9dc | |
parent 695b94d0b8c81fbbcfca476c06eda313facaf72c | |
Author: Anders Damsgaard <[email protected]> | |
Date: Thu, 17 Mar 2016 16:49:15 -0700 | |
pass pointer to structure instead of structure | |
Diffstat: | |
M slidergrid/main.c | 4 ++-- | |
M slidergrid/simulation.c | 16 ++++++++-------- | |
M slidergrid/simulation.h | 3 ++- | |
3 files changed, 12 insertions(+), 11 deletions(-) | |
--- | |
diff --git a/slidergrid/main.c b/slidergrid/main.c | |
t@@ -113,7 +113,7 @@ int main(int argc, char** argv) | |
} | |
// save initial conditions to output files | |
- if (write_simulation_output(sim, output_folder)) { | |
+ if (write_simulation_output(&sim, output_folder)) { | |
fprintf(stderr, "\nFatal error: Could not write one or more " | |
"output files.\n"); | |
return EXIT_FAILURE; | |
t@@ -142,7 +142,7 @@ int main(int argc, char** argv) | |
} | |
if (time_since_file >= sim.file_interval) { | |
- if (write_simulation_output(sim, output_folder)) { | |
+ if (write_simulation_output(&sim, output_folder)) { | |
fprintf(stderr, "\nFatal error: Could not write one or more " | |
"output files.\n"); | |
return EXIT_FAILURE; | |
diff --git a/slidergrid/simulation.c b/slidergrid/simulation.c | |
t@@ -298,14 +298,14 @@ int save_sliders_to_vtk_file( | |
return 0; | |
} | |
-int write_simulation_output(simulation sim, char* output_folder) | |
+int write_simulation_output(simulation* sim, char* output_folder) | |
{ | |
char filename[1000]; | |
// 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)) { | |
+ output_folder, sim->id, sim->file_number); | |
+ if (save_slider_positions_to_file(sim->sliders, sim->N, filename)) { | |
fprintf(stderr, "\nFatal error: Could not save to output file " | |
"'%s'.\n", filename); | |
return 1; | |
t@@ -313,8 +313,8 @@ int write_simulation_output(simulation sim, char* output_f… | |
// other parameters | |
sprintf(filename, "%s/%s.general.%06d.txt", | |
- output_folder, sim.id, sim.file_number); | |
- if (save_general_state_to_file(sim, filename)) { | |
+ output_folder, sim->id, sim->file_number); | |
+ if (save_general_state_to_file(*sim, filename)) { | |
fprintf(stderr, "\nFatal error: Could not save to output file " | |
"'%s'.\n", filename); | |
return 1; | |
t@@ -322,13 +322,13 @@ int write_simulation_output(simulation sim, char* output… | |
// sliders to VTK file | |
sprintf(filename, "%s/%s.sliders.%06d.vtu", | |
- output_folder, sim.id, sim.file_number); | |
- if (save_sliders_to_vtk_file(sim.sliders, sim.N, filename)) { | |
+ output_folder, sim->id, sim->file_number); | |
+ if (save_sliders_to_vtk_file(sim->sliders, sim->N, filename)) { | |
fprintf(stderr, "\nFatal error: Could not save to output file " | |
"'%s'.\n", filename); | |
return 1; | |
} | |
- sim.file_number++; | |
+ sim->file_number++; | |
return 0; | |
} | |
diff --git a/slidergrid/simulation.h b/slidergrid/simulation.h | |
t@@ -39,7 +39,8 @@ int save_sliders_to_vtk_file( | |
const int N, | |
const char* filename); | |
-int write_simulation_output(simulation sim, char* output_folder); | |
+//int write_simulation_output(simulation sim, char* output_folder); | |
+int write_simulation_output(simulation* sim, char* output_folder); | |
// user-defined function which sets up the simulation | |
simulation setup_simulation(); |