First partially-implemented functional release
[2dsolver.git] / src / main.c
1 /*
2 * main.c: entry point for 2dsolve
3 * Creation date: Fri Apr 13 23:15:04 2012
4 */
5
6 #include <stdio.h>
7 #include <stdlib.h>
8 #include <string.h>
9 #include <errno.h>
10 #include <getopt.h>
11
12 #include <2dsolve.h>
13
14 int
15 main (int argc, char *argv[], char *envp[])
16 {
17 display_t *disp;
18 struct problem2d *problem;
19
20 if (argc != 2)
21 {
22 fprintf (stderr, "Usage: %s <file.mat>\n", argv[0]);
23 exit (EXIT_FAILURE);
24 }
25
26 if ((problem = problem_get_sample_from_matlab (argv[1])) == NULL)
27 {
28 fprintf (stderr, "Cannot load problem from MATLAB\n");
29 exit (EXIT_FAILURE);
30 }
31
32 if (build_matrix_and_vector (problem) == -1)
33 {
34 fprintf (stderr, "Cannot load stiffness matrix\n");
35 exit (EXIT_FAILURE);
36 }
37
38 problem_force_dirichlet (problem, 0.0);
39
40 problem_lock (problem);
41
42 if (problem_solve (problem) == -1)
43 {
44 fprintf (stderr, "Solver failed\n");
45 exit (EXIT_FAILURE);
46 }
47
48 // export_matrix_and_vector (problem, stdout);
49
50 if ((disp = display_new (SCREEN_WIDTH, SCREEN_HEIGHT)) == NULL)
51 exit (EXIT_FAILURE);
52
53 display_solution (disp, problem, 200.0);
54
55 display_refresh (disp);
56
57 display_end (disp);
58
59 return 0;
60 }
61