tsimulation.c: add VTK export for grains - granular - granular dynamics simulation
git clone git://src.adamsgaard.dk/granular
Log
Files
Refs
README
LICENSE
---
commit 22b76f0ca163f3753c5f6b973c6320e50edd4491
parent 99c38f2f6c2fd472b1056e8cf72e55a56358f573
Author: Anders Damsgaard 
Date:   Fri, 19 Mar 2021 18:32:00 +0100

simulation.c: add VTK export for grains

Diffstat:
  M simulation.c                        |      51 ++++++++++++++++++++++++++++++-
  M simulation.h                        |       5 +----

2 files changed, 51 insertions(+), 5 deletions(-)
---
diff --git a/simulation.c b/simulation.c
t@@ -13,7 +13,56 @@ print_grains(FILE *stream, const struct grain *grains, size_t n)
 {
         size_t i;
 
-        /* fprintf(stream, "N = %zu\n", n); */
         for (i = 0; i < n; i++)
                 grain_print(stream, &grains[i]);
 }
+
+void
+print_grains_vtk(FILE *stream, const struct grain *grains, size_t n)
+{
+        size_t i;
+
+        fprintf(stream,
+                        "\n"
+                    "\n"
+                        "\t\n"
+                        "\t\t\n", n);
+        fprintf(stream,
+                        "\t\t\t\n"
+                        "\t\t\t\t\n");
+        for (i = 0; i < n; i++)
+                fprintf(stream, "%.17g %.17g %.17g ",
+                        grains[i].pos[0], grains[i].pos[1], grains[i].pos[2]);
+        fprintf(stream, "\n");
+        fprintf(stream,
+                        "\t\t\t\t\n"
+                        "\t\t\t\n");
+
+        fprintf(stream,
+                        "\t\t\t\n"
+                        "\t\t\t\t\n"
+                        "\t\t\t\t\n"
+                        "\t\t\t\t\n"
+                        "\t\t\t\n");
+
+        fprintf(stream,
+                        "\t\t\t\n"
+                        "\t\t\t\t\n");
+        for (i = 0; i < n; i++)
+                fprintf(stream, "%.17g ", grains[i].radius * 2.0);
+        fprintf(stream,
+                        "\n"
+                        "\t\t\t\t\n"
+                        "\t\t\t\n");
+
+        fprintf(stream,
+                        "\t\t\n"
+                        "\t\n"
+                        "\n");
+}
diff --git a/simulation.h b/simulation.h
t@@ -37,12 +37,9 @@ struct simulation {
         struct grain *grains;
 };
 
-void init_sim(struct simulation *sim);
 void free_sim(struct simulation *sim);
 
 void print_grains(FILE *stream, const struct grain *grains, size_t n);
-
-void write_output_file(struct simulation *sim, const int normalize);
-void print_output(FILE *stream, struct simulation *sim);
+void print_grains_vtk(FILE *stream, const struct grain *grains, size_t n);
 
 #endif