Introduction
Introduction Statistics Contact Development Disclaimer Help
tfile io in progress - ns2dfd - 2D finite difference Navier Stokes solver for f…
git clone git://src.adamsgaard.dk/ns2dfd
Log
Files
Refs
LICENSE
---
commit d7c14c02d398035d751b2d5e7dee8896b9c53437
parent ff4818b93a5d588736b06699059914c255ee1596
Author: Anders Damsgaard <[email protected]>
Date: Sun, 2 Mar 2014 09:44:54 +0100
file io in progress
Diffstat:
A src/file_io.h | 13 +++++++++++++
A src/utility.c | 36 +++++++++++++++++++++++++++++…
A src/utility.h | 8 ++++++++
3 files changed, 57 insertions(+), 0 deletions(-)
---
diff --git a/src/file_io.h b/src/file_io.h
t@@ -0,0 +1,13 @@
+#ifndef FILE_IO_H_
+#define FILE_IO_H_
+
+int read_file(char *path,
+ double *t, double *t_end, double *tau, int *itermax,
+ double *epsilon, double *omega, double *gamma,
+ double *gx, double *gy, double *re,
+ int *w_left, int *w_right, int *w_top, int *w_bottom,
+ double *dx, double *dy,
+ int *nx, int *ny,
+ double **p, double **u, double **v);
+
+#endif
diff --git a/src/utility.c b/src/utility.c
t@@ -0,0 +1,36 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+/* Linear index from two-dimensional index */
+unsigned int idx(int x, int y, int nx)
+{
+ return x + y*nx;
+}
+
+/* Allocate memory for 2d arrays */
+int allocate_memory(double *p, double *u, double *v, int nx, int ny)
+{
+ p = malloc(sizeof(double)*(nx+1)*(ny+1));
+ if (p == NULL) {
+ fprintf(stderr, "allocate_memory: Could not allocate memory for p\n");
+ return 1;
+ }
+ u = malloc(sizeof(double)*(nx+2)*(ny+2));
+ if (u == NULL) {
+ fprintf(stderr, "allocate_memory: Could not allocate memory for u\n");
+ return 1;
+ }
+ v = malloc(sizeof(double)*(nx+2)*(ny+2));
+ if (v == NULL) {
+ fprintf(stderr, "allocate_memory: Could not allocate memory for v\n");
+ return 1;
+ }
+ return 0;
+}
+
+void free_memory(double *p, double *u, double *v)
+{
+ free(p);
+ free(u);
+ free(v);
+}
diff --git a/src/utility.h b/src/utility.h
t@@ -0,0 +1,8 @@
+#ifndef UTILITY_H_
+#define UTILITY_H_
+
+unsigned int idx(int x, int y, int nx);
+int allocate_memory(double *p, double *u, double *v, int nx, int ny);
+void free_memory(double *p, double *u, double *v);
+
+#endif
You are viewing proxied material from mx1.adamsgaard.dk. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.