summaryrefslogtreecommitdiff
path: root/lib/data.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/data.c')
-rw-r--r--lib/data.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/lib/data.c b/lib/data.c
new file mode 100644
index 0000000..2047c44
--- /dev/null
+++ b/lib/data.c
@@ -0,0 +1,35 @@
+
+#include "fracture.h"
+
+data_t *data_create(uint_t ne) {
+ data_t *data = malloc(1 * sizeof(data_t));
+ assert(data != NULL);
+
+ data->num_broken = 0;
+
+ data->break_list = (uint_t *)malloc(ne * sizeof(uint_t));
+ assert(data->break_list != NULL);
+
+ data->extern_field = (long double *)malloc(ne * sizeof(long double));
+ assert(data->extern_field != NULL);
+
+ data->conductivity = (double *)malloc(ne * sizeof(double));
+ assert(data->conductivity != NULL);
+
+ return data;
+}
+
+void data_free(data_t *data) {
+ free(data->break_list);
+ free(data->extern_field);
+ free(data->conductivity);
+ free(data);
+}
+
+void data_update(data_t *data, uint_t last_broke, long double strength, double conductivity) {
+ data->break_list[data->num_broken] = last_broke;
+ data->extern_field[data->num_broken] = strength;
+ data->conductivity[data->num_broken] = conductivity;
+ data->num_broken++;
+}
+