summaryrefslogtreecommitdiff
path: root/lib/data.c
blob: e39c450b32f2f20046e643d06ce5ab33b3288203 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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++;
}