00001 #ifndef __PARFUM_IMPORT_H
00002 #define __PARFUM_IMPORT_H
00003 #include "ParFUM.h"
00004 #include "ParFUM_internals.h"
00005 #include <vector>
00006
00007 #define msbInt(var,key){\
00008 int *ptr = (int *)&key; \
00009 var = *(ptr+endian);\
00010 }
00011
00012 extern int getFloatFormat(void);
00013
00014
00021 inline int coordCompare(const double *key1, const double *key2, int dim) {
00022 #if TERRY_BIT_COMPARE
00023
00024 static const int endian = getFloatFormat();
00025 int maxUlps=100;
00026 for(int ii=0; ii<dim; ii++) {
00027 int a, b;
00028 msbInt(a,key1[ii]);
00029 msbInt(b,key2[ii]);
00030 if (a < 0) a = 0x80000000 - a;
00031 if (b < 0) b = 0x80000000 - b;
00032 int diff = a-b;
00033 if (abs(diff) > maxUlps) {
00034 if (diff < 0) {
00035
00036 return 1;
00037 } else {
00038 return -1;
00039 }
00040 }
00041 }
00042 return 0;
00043 #else
00044 CkAssert(dim==3);
00045 const double threshold = 0.0001;
00046 for(int i=0; i<dim; i++) {
00047 const double a = key1[i];
00048 const double b = key2[i];
00049 const double diff = a-b;
00050 if (diff < -1.0*threshold){
00051 return 1;
00052 }
00053 else if (diff > threshold){
00054 return -1;
00055 }
00056 }
00057 return 0;
00058 #endif
00059 }
00060
00061 inline int coordEqual(const double *key1, const double *key2, int dim) {
00062 return coordCompare(key1, key2, dim)==0;
00063 }
00064
00065 inline int coordLessThan(const double *key1, const double *key2, int dim) {
00066 return coordCompare(key1, key2, dim)==1;
00067 }
00068
00069 void ParFUM_desharing(int meshid);
00070 void ParFUM_deghosting(int meshid);
00071 void ParFUM_generateGlobalNodeNumbers(int fem_mesh, MPI_Comm comm);
00072 void ParFUM_recreateSharedNodes(int meshid, int dim, int nParts);
00073
00074 void ParFUM_createComm(int meshid, int dim, MPI_Comm comm);
00075
00076 void ParFUM_import_nodes(int meshid, int numNodes, double *nodeCoords, int dim);
00077 void ParFUM_import_elems(int meshid, int numElems, int nodesPer, int *conn, int type);
00078 void ParFUM_findMatchingCoords(int dim, int extent_a, double* a,
00079 int extent_b, double *b,
00080 std::vector<int>& matches_a,
00081 std::vector<int>& matches_b
00082 );
00083
00084 void sortNodes(double *nodes, double *sorted_nodes, int *sorted_ids, int numNodes, int dim);
00085
00086 #endif
00087
00088