summaryrefslogtreecommitdiff
path: root/src/physics.h
blob: 38a6100e3fda184dca2525db18ce987d1caf8378 (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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#ifndef _PHYSICS_H
#define _PHYSICS_H

#include "common.h"
#include "itc.h"

typedef struct {
	size_t width, height, depth;
	size_t zstr, ystr, xstr, size; // strides in no. of points (not bytes)
	size_t zstr1, ystr1, xstr1, size1; // same as above but for associated
	                                   // scalar fields
	float spacing; // in meters
} phy_field_info;

typedef struct {
	float *E;
	float *H;
} phy_field_em;

enum {
	PHY_CMD_QUIT,
	PHY_CMD_PAUSE,
	PHY_CMD_RESUME,
	PHY_CMD_STEP,
	PHY_CMD_RESET
};

typedef struct {
	phy_field_info field_info;
	phy_field_em fields[3];
	float *field_eps, *field_mu; //permittivity and permeability
	float time, time_delta;

	// UI stuff
	bool running;
	itc_chan ctl;
	SDL_mutex *rotate_lock;
	int64_t frame_index; // to avoid re-drawing the same fields
	int64_t step_real_time;
} phy_sim;

void phy_sim_destroy(phy_sim *sim);
int phy_sim_create(phy_sim *sim);
void phy_sim_compute_const_fields(phy_sim *sim);
void phy_sim_step(phy_sim *sim);

int phy_thread(phy_sim *sim);

#endif // _PHYSICS_H