b031c23c5a33b4fb9f349c78118ce4673407a838
[2dsolver.git] / src / 2dsolve.h
1 /*
2 * 2dsolve.h: headers, prototypes and declarations for 2dsolve
3 * Creation date: Fri Apr 13 23:15:04 2012
4 */
5
6 #ifndef _MAIN_APP_INCLUDE_H
7 #define _MAIN_APP_INCLUDE_H
8
9 #include <util.h> /* From util: Common utility library */
10 #include <wbmp.h> /* From sim-static: Built-in simulation library over SDL */
11 #include <draw.h> /* From sim-static: Built-in simulation library over SDL */
12 #include <matfile.h> /* From matlab: Utility functions for manipulating MATLAB data files */
13 #include <jit.h> /* For evaluating expressions */
14 #include <config.h> /* Goodies */
15
16 #ifdef HAVE_INLINE
17 # define INLINE static inline
18 #else
19 # define INLINE static
20 #endif
21
22 #include <gsl/gsl_vector.h>
23 #include <gsl/gsl_matrix.h>
24 #include <gsl/gsl_linalg.h>
25
26
27 #define SCREEN_WIDTH 640
28 #define SCREEN_HEIGHT 480
29
30 struct point
31 {
32 int index;
33 float x;
34 float y;
35 };
36
37 struct edge_desc
38 {
39 struct point *p1;
40 struct point *p2;
41 };
42
43 #define TRIANGLE_NODES 3
44
45 struct triangle
46 {
47 struct point *nodes[TRIANGLE_NODES];
48 };
49
50 struct geometry_info
51 {
52 PTR_LIST (struct point, point);
53 PTR_LIST (struct edge_desc, edge);
54 PTR_LIST (struct triangle, triangle);
55 };
56
57 #define A_11 0
58 #define A_12 1
59 #define A_21 2
60 #define A_22 3
61
62 struct problem2d
63 {
64 struct geometry_info *geometry;
65 struct jit_expr *a[4];
66 struct jit_expr *a0, *f, *g;
67
68 float x, y;
69 };
70
71 #include <triangle.h>
72
73 struct edge_desc *edge_desc_new (struct point *, struct point *);
74 struct point *point_new (float, float);
75 struct triangle *triangle_new (struct point *, struct point *, struct point *);
76 int build_matrix_and_vector (struct problem2d *, gsl_matrix **, gsl_vector **);
77 struct geometry_info *geometry_load_from_matlab (const char *, const char *, const char *, const char *);
78 void geometry_destroy (struct geometry_info *);
79
80 #endif /* _MAIN_APP_INCLUDE_H */