/* Assemble the global coefficient matrix for a non-uniform mesh. The first * argument is a function pointer to the function which creates the element * matrix, and the second is the mesh to be used. */ matrix* AssembleJ(matrix* (*makej)(double, double), matrix* mesh, double Pe) { matrix *J, *j; int n, i; /* Determine the number of elements from the mesh */ n = mtxlen2(mesh); /* Create a blank global matrix */ J = CreateMatrix(n+1, n+1); for(i=0; i<n; i++) { /* Generate the element matrix for the specified element width */ j = makej(Pe, val(mesh, i, 0)); /* Add the values of the element matrix to the global matrix */ addval(J, val(j, 0, 0), i, i); addval(J, val(j, 0, 1), i, i+1); addval(J, val(j, 1, 0), i+1, i); addval(J, val(j, 1, 1), i+1, i+1); /* Clean up */ DestroyMatrix(j); } return J; }
matrix* AssembleF(matrix* (*makef)(double, double), matrix* mesh, double Pe) { matrix *F, *f; int n, i; n = mtxlen2(mesh); F = CreateMatrix(n+1, 1); for(i=0; i<n; i++) { f = makef(Pe, val(mesh, i, 0)); addval(F, val(f, 0, 0), i, 0); addval(F, val(f, 1, 0), i+1, 0); DestroyMatrix(f); } return F; }
void read_config_file (const char *cf) { char *bp; char *p; char buf[BUFSIZE]; FILE *config = NULL; if (cf) { /* User explicitly specified a config file */ if ((config = fopen (cf, "r")) == NULL) { perror (cf); gripe (CONFIG_OPEN_ERROR, cf); return; } } else { /* Try some things - unfortunately we cannot lookup the config file to use in the config file :-). */ int i; for(i=0; i < SIZE(default_config_files); i++) { cf = default_config_files[i]; if ((config = fopen (cf, "r")) != NULL) break; } if (config == NULL) { gripe (CONFIG_OPEN_ERROR, CONFIG_FILE); return; } } if (debug) fprintf(stderr, "Reading config file %s\n", cf); configuration_file = cf; while ((bp = fgets (buf, BUFSIZE, config)) != NULL) { while (whitespace(*bp)) bp++; for (p = bp; *p && *p != '#' && *p != '\n'; p++) ; if (!*p) { gripe (LINE_TOO_LONG); gripe (BAD_CONFIG_FILE, cf); return; } while (p > bp && whitespace(p[-1])) p--; *p = 0; if (*bp == 0) continue; if (!strncmp ("MANPATH_MAP", bp, 11)) adddir (bp+11, 0); else if (!strncmp ("MANPATH", bp, 7)) addglobdir (bp+7, 1); else if(!strncmp ("MANDATORY_MANPATH", bp, 17))/* backwards compatible */ adddir (bp+17, 1); else if (!strncmp ("FHS", bp, 3)) fhs = 1; else if (!strncmp ("FSSTND", bp, 6)) fsstnd = 1; else if (!strncmp ("NOAUTOPATH", bp, 10)) noautopath = 1; else if (!strncmp ("NOCACHE", bp, 7)) nocache = 1; else if (*bp == '.') addext (bp); else addval (bp); } }