Added a test program for fem framework.
authorMilind Bhandarkar <milind@cs.uiuc.edu>
Fri, 4 Aug 2000 22:09:01 +0000 (22:09 +0000)
committerMilind Bhandarkar <milind@cs.uiuc.edu>
Fri, 4 Aug 2000 22:09:01 +0000 (22:09 +0000)
tests/fem/femtest/Makefile [new file with mode: 0644]
tests/fem/femtest/cmesh.dat [new file with mode: 0644]
tests/fem/femtest/pgm.C [new file with mode: 0644]

diff --git a/tests/fem/femtest/Makefile b/tests/fem/femtest/Makefile
new file mode 100644 (file)
index 0000000..5993627
--- /dev/null
@@ -0,0 +1,12 @@
+CHARMC=../../../../bin/charmc $(OPTS) 
+
+all: pgm
+
+pgm: pgm.o
+       $(CHARMC) -o pgm pgm.o -language fem
+
+pgm.o: pgm.C
+       $(CHARMC) -c pgm.C
+
+clean:
+       rm -f pgm *.o conv-host
diff --git a/tests/fem/femtest/cmesh.dat b/tests/fem/femtest/cmesh.dat
new file mode 100644 (file)
index 0000000..e39f1dc
--- /dev/null
@@ -0,0 +1,5 @@
+4 9 4
+0 1 3 4
+1 2 4 5
+3 4 6 7
+4 5 7 8
diff --git a/tests/fem/femtest/pgm.C b/tests/fem/femtest/pgm.C
new file mode 100644 (file)
index 0000000..ceaee79
--- /dev/null
@@ -0,0 +1,67 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <math.h>
+#include "fem.h"
+
+extern "C" void
+init_(void)
+{
+  CkPrintf("init_ called\n");
+  FILE *fp = fopen("cmesh.dat", "r");
+  if(fp==0) { CkAbort("Cannot open cmesh.dat file.\n"); }
+  int nelems, nnodes, ctype;
+  fscanf(fp, "%d%d%d\n", &nelems, &nnodes, &ctype);
+  int i,j;
+  int esize = (ctype==FEM_TRIANGULAR)?3:
+              ((ctype==FEM_HEXAHEDRAL)?8:
+             4);
+  int *conn = new int[nelems*esize];
+  for(i=0;i<nelems;i++) {
+    for(j=0;j<esize;j++) {
+      fscanf(fp,"%d",&conn[i*esize+j]);
+    }
+  }
+  fclose(fp);
+  FEM_Set_Mesh(nelems, nnodes, ctype, conn);
+}
+
+extern "C" void
+driver_(int *nnodes, int *nnums, int *nelems, int *enums, int *npere, int *conn)
+{
+  char str[1024];
+  char tmpstr[80];
+  CkPrintf("[%d] Number of Elements = %d\n", FEM_My_Partition(), *nelems);
+  CkPrintf("[%d] Number of Nodes = %d\n", FEM_My_Partition(), *nnodes);
+  int i, j;
+  sprintf(str, "[%d] List of Elements:\n", FEM_My_Partition());
+  for(i=0;i<*nelems;i++) {
+    sprintf(tmpstr, "\t%d\n", enums[i]);
+    strcat(str,tmpstr);
+  }
+  CkPrintf("%s", str);
+  sprintf(str, "[%d] List of Nodes:\n", FEM_My_Partition());
+  for(i=0;i<*nnodes;i++) {
+    sprintf(tmpstr, "\t%d\n", nnums[i]);
+    strcat(str,tmpstr);
+  }
+  CkPrintf("%s", str);
+  sprintf(str, "[%d] Connectivity:\n", FEM_My_Partition());
+  for(i=0;i<*nelems;i++) {
+    sprintf(tmpstr, "\t[%d] ", enums[i]);
+    strcat(str,tmpstr);
+    for(j=0;j<*npere;j++) {
+      sprintf(tmpstr, "%d ", nnums[conn[i*(*npere)+j]]);
+      strcat(str,tmpstr);
+    }
+    sprintf(tmpstr, "\n");
+    strcat(str,tmpstr);
+  }
+  CkPrintf("%s", str);
+  FEM_Done();
+}
+
+extern "C" void
+finalize_(void)
+{
+  CkPrintf("finalize_ called\n");
+}