summaryrefslogtreecommitdiff
path: root/src/break_data.c
blob: 5c922f3a1af890bd397d118b477b4db128b5e556 (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

#include "fracture.h"

data_t *alloc_break_data(unsigned int num_edges) {
	data_t *data = malloc(1 * sizeof(data_t)); assert(data != NULL);

	data->num_broken = 0;

	data->break_list = (unsigned int *)malloc(num_edges * sizeof(unsigned int));
	assert(data->break_list != NULL);

	data->extern_field = (double *)malloc(num_edges * sizeof(double));
	assert(data->extern_field != NULL);

	data->conductivity = (double *)malloc(num_edges * sizeof(double));
	assert(data->conductivity != NULL);

	return data;
}

void free_break_data(data_t *data) {
	free(data->break_list);
	free(data->extern_field);
	free(data->conductivity);
	free(data);
}

void update_break_data(data_t *data, unsigned int last_broke, 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++;
}