00001
00010 #ifndef __PARFUM_H
00011 #define __PARFUM_H
00012 #include "charm++.h"
00013 #include "pup_c.h"
00014 #include "idxlc.h"
00015 #include "collidec.h"
00016 #include "charm-api.h"
00017 #include "ckvector3d.h"
00018 #include "tcharm.h"
00019 #include "ParFUM_Types.h"
00020
00021
00022
00024 class FEM_Entity;
00025 class FEM_Mesh;
00026 class FEM_Elem;
00027 class FEM_Node;
00028 class femMeshModify;
00029 class FEM_Adapt_Algs;
00030 class FEM_Adapt;
00031 class FEM_AdaptL;
00032 class IDXL_Chunk;
00033 class l2g_t;
00034 class FEM_ElemAdj_Layer;
00035 class chunkListMsg;
00036
00037
00038 void _registerParFUM(void);
00039
00040 #ifdef __cplusplus
00041 extern "C" {
00042 #endif
00043
00045 #define FEM_BYTE IDXL_BYTE
00046 #define FEM_INT IDXL_INT
00047 #define FEM_REAL IDXL_REAL
00048 #define FEM_FLOAT FEM_REAL
00049 #define FEM_DOUBLE IDXL_DOUBLE
00050 #define FEM_INDEX_0 IDXL_INDEX_0
00051 #define FEM_INDEX_1 IDXL_INDEX_1
00052 #define FEM_VAR_INDEX (IDXL_FIRST_DATATYPE+6)
00053
00055 #define FEM_SUM IDXL_SUM
00056 #define FEM_PROD IDXL_PROD
00057 #define FEM_MAX IDXL_MAX
00058 #define FEM_MIN IDXL_MIN
00059
00061 #define FEM_TRIANGULAR 3
00062 #define FEM_TETRAHEDRAL 4
00063 #define FEM_HEXAHEDRAL 8
00064 #define FEM_QUADRILATERAL 4
00065
00067 #define FEM_INIT_READ 2
00068 #define FEM_INIT_WRITE 4
00069
00070 #define FEM_MESH_OUTPUT 0
00071 #define FEM_MESH_UPDATE 1
00072 #define FEM_MESH_FINALIZE 2
00073 typedef void (*FEM_Update_mesh_fn)(int userTag);
00074 typedef void (*FEM_Update_mesh_fortran_fn)(int *userTag);
00075
00076 typedef void (*FEM_PupFn)(pup_er, void*);
00077
00078 typedef void (*FEM_Mesh_alloc_fn)(void *param,int *size,int *maxSize);
00079
00081 typedef int FEM_Comm_t;
00082
00084 void FEM_Init(FEM_Comm_t defaultCommunicator);
00085 void FEM_Done(void);
00086
00088 int FEM_My_partition(void);
00089 int FEM_Num_partitions(void);
00090 double FEM_Timer(void);
00091 void FEM_Print(const char *str);
00092 void FEM_Print_partition(void);
00093
00095 #define FEM_MESH_FIRST 1650000000
00096
00097 int FEM_Mesh_allocate(void);
00098 int FEM_Mesh_copy(int fem_mesh);
00099 void FEM_Mesh_deallocate(int fem_mesh);
00101 int FEM_Mesh_read(const char *prefix,int partNo,int nParts);
00102 void FEM_Mesh_write(int fem_mesh,const char *prefix,int partNo,int nParts);
00103
00104 int FEM_Mesh_assemble(int nParts,const int *srcMeshes);
00105 void FEM_Mesh_partition(int fem_mesh,int nParts,int *destMeshes);
00106
00107 int FEM_Mesh_recv(int fromRank,int tag,FEM_Comm_t comm_context);
00108 void FEM_Mesh_send(int fem_mesh,int toRank,int tag,FEM_Comm_t comm_context);
00109
00110 int FEM_Mesh_reduce(int fem_mesh,int toRank,FEM_Comm_t comm_context);
00111 int FEM_Mesh_broadcast(int fem_mesh,int fromRank,FEM_Comm_t comm_context);
00112
00113 void FEM_Mesh_copy_globalno(int src_mesh,int dest_mesh);
00114 void FEM_Mesh_print(int fem_mesh);
00115
00116
00117 #define FEM_ENTITY_FIRST 1610000000
00118 #define FEM_NODE (FEM_ENTITY_FIRST+0)
00119 #define FEM_ELEM (FEM_ENTITY_FIRST+1000)
00120 #define FEM_ELEMENT FEM_ELEM
00121 #define FEM_SPARSE (FEM_ENTITY_FIRST+2000)
00122 #define FEM_EDGE FEM_SPARSE
00123 #define FEM_FACE FEM_SPARSE
00124 #define FEM_GHOST 10000
00125 #define FEM_ENTITY_LAST (FEM_ENTITY_FIRST+3000+FEM_GHOST)
00126
00127
00128 #define FEM_DATA 0
00129 #define FEM_ATTRIB_TAG_MAX 1000000000
00130 #define FEM_ATTRIB_FIRST 1620000000
00131 #define FEM_CONN (FEM_ATTRIB_FIRST+1)
00132 #define FEM_CONNECTIVITY FEM_CONN
00133
00134
00135 #define FEM_SPARSE_ELEM (FEM_ATTRIB_FIRST+2)
00136 #define FEM_COOR (FEM_ATTRIB_FIRST+3)
00137 #define FEM_COORD FEM_COOR
00138 #define FEM_COORDINATES FEM_COOR
00139 #define FEM_GLOBALNO (FEM_ATTRIB_FIRST+4)
00140 #define FEM_PARTITION (FEM_ATTRIB_FIRST+5)
00141 #define FEM_SYMMETRIES (FEM_ATTRIB_FIRST+6)
00142 #define FEM_NODE_PRIMARY (FEM_ATTRIB_FIRST+7)
00143 #define FEM_CHUNK (FEM_ATTRIB_FIRST+8)
00144 #define FEM_BOUNDARY (FEM_ATTRIB_FIRST+9)
00145 #define FEM_NODE_ELEM_ADJACENCY (FEM_ATTRIB_FIRST+10)
00146 #define FEM_NODE_NODE_ADJACENCY (FEM_ATTRIB_FIRST+11)
00147 #define FEM_ELEM_ELEM_ADJACENCY (FEM_ATTRIB_FIRST+12)
00148 #define FEM_ELEM_ELEM_ADJ_TYPES (FEM_ATTRIB_FIRST+13)
00149 #define FEM_IS_VALID_ATTR (FEM_ATTRIB_FIRST+14)
00150
00151 #define FEM_MESH_SIZING (FEM_ATTRIB_FIRST+15)
00152
00153 #define FEM_ADAPT_FACE_ADJ (FEM_ATTRIB_FIRST+16)
00154 #define FEM_ADAPT_EDGE_ADJ (FEM_ATTRIB_FIRST+17)
00155 #define FEM_ADAPT_LOCK (FEM_ATTRIB_FIRST+18)
00156 #define FEM_ADAPT_LOCK_PRIO (FEM_ATTRIB_FIRST+19)
00157
00158 #define FEM_ATTRIB_LAST (FEM_ATTRIB_FIRST+20)
00159
00160
00161 void FEM_Mesh_set_conn(int fem_mesh,int entity,
00162 const int *conn, int firstItem, int length, int width);
00163 void FEM_Mesh_get_conn(int fem_mesh,int entity,
00164 int *conn, int firstItem, int length, int width);
00165
00166 void FEM_Mesh_set_data(int fem_mesh,int entity,int attr,
00167 const void *data, int firstItem, int length, int datatype,int width);
00168 void FEM_Mesh_get_data(int fem_mesh,int entity,int attr,
00169 void *data, int firstItem, int length, int datatype,int width);
00170 void FEM_Mesh_conn(int fem_mesh,int entity,
00171 int *conn, int firstItem, int length, int width);
00172
00173 int FEM_Mesh_get_length(int fem_mesh,int entity);
00174
00175
00176 void FEM_Mesh_data(int fem_mesh,int entity,int attr,
00177 void *data, int firstItem, int length, int datatype,int width);
00178 void FEM_Mesh_data_layout(int fem_mesh,int entity,int attr,
00179 void *data, int firstItem, int length, IDXL_Layout_t layout);
00180 void FEM_Mesh_data_offset(int fem_mesh,int entity,int attr,
00181 void *data, int firstItem, int length,
00182 int type,int width, int offsetBytes,int distanceBytes,int skewBytes);
00183
00184 void FEM_Register_array(int fem_mesh,int entity,int attr,
00185 void *data, int datatype,int width);
00186
00187 void FEM_Register_array_layout(int fem_mesh,int entity,int attr,
00188 void *data, IDXL_Layout_t layout);
00189
00190
00191 void FEM_Register_entity(int fem_mesh,int entity,void *data,int len,int max,FEM_Mesh_alloc_fn fn);
00192
00193 void FEM_Mesh_set_length(int fem_mesh,int entity,int newLength);
00194 int FEM_Mesh_get_width(int fem_mesh,int entity,int attr);
00195 void FEM_Mesh_set_width(int fem_mesh,int entity,int attr,int newWidth);
00196 int FEM_Mesh_get_datatype(int fem_mesh,int entity,int attr);
00197 int FEM_Mesh_get_entities(int fem_mesh, int *entities);
00198 int FEM_Mesh_get_attributes(int fem_mesh,int entity,int *attributes);
00199
00200 const char *FEM_Get_entity_name(int entity,char *storage);
00201 const char *FEM_Get_attr_name(int attr,char *storage);
00202 const char *FEM_Get_datatype_name(int datatype,char *storage);
00203
00204 int FEM_Mesh_is_get(int fem_mesh);
00205 int FEM_Mesh_is_set(int fem_mesh);
00206 void FEM_Mesh_become_get(int fem_mesh);
00207 void FEM_Mesh_become_set(int fem_mesh);
00208
00209 typedef void (*FEM_Userdata_fn)(pup_er p,void *data);
00210 void FEM_Mesh_pup(int fem_mesh,int dataTag,FEM_Userdata_fn fn,void *data);
00211
00212
00213 void FEM_Add_ghost_layer(int nodesPerTuple,int doAddNodes);
00214 void FEM_Add_ghost_elem(int elType,int tuplesPerElem,const int *elem2tuple);
00215
00216 void FEM_Add_ghost_stencil(int nElts,int addNodes,
00217 const int *ends,const int *adj);
00218 void FEM_Add_ghost_stencil_type(int elType,int nElts,int addNodes,
00219 const int *ends,const int *adj2);
00220
00221 void FEM_Add_elem2face_tuples(int fem_mesh, int elem_type, int nodesPerTuple, int tuplesPerElem,const int *elem2tuple);
00222
00223 void FEM_Add_linear_periodicity(int nFaces,int nPer,
00224 const int *facesA,const int *facesB,
00225 int nNodes,const double *nodeLocs);
00226 void FEM_Sym_coordinates(int who,double *d_locs);
00227
00228 void FEM_Set_sym_nodes(const int *canon,const int *sym);
00229 void FEM_Get_sym(int who,int *destSym);
00234 void FEM_Make_node_globalno(int fem_mesh,FEM_Comm_t comm_context);
00235
00236
00237 IDXL_Layout_t FEM_Create_simple_field(int base_type,int vec_len);
00238 IDXL_Layout_t FEM_Create_field(int base_type, int vec_len, int init_offset,
00239 int distance);
00240
00241 IDXL_t FEM_Comm_shared(int fem_mesh,int entity);
00242 IDXL_t FEM_Comm_ghost(int fem_mesh,int entity);
00243
00244 void FEM_Get_roccom_pconn_size(int fem_mesh,int *total_len,int *ghost_len);
00245 void FEM_Get_roccom_pconn(int fem_mesh,const int *paneFmChunk,int *pconn);
00246 void FEM_Set_roccom_pconn(int fem_mesh,const int *paneFmChunk,const int *src,int total_len,int ghost_len);
00247
00248
00249 int FEM_Register(void *userData,FEM_PupFn _pup_ud);
00250 void FEM_Migrate(void);
00251 void *FEM_Get_userdata(int n);
00252
00253 void FEM_Barrier(void);
00254
00255
00256 void init(void);
00257 void driver(void);
00258
00259
00260 void FEM_Mesh_create_node_elem_adjacency(int fem_mesh);
00261 void FEM_Mesh_create_node_node_adjacency(int fem_mesh);
00262 void FEM_Mesh_create_elem_elem_adjacency(int fem_mesh);
00263
00264 void FEM_Print_n2n(int mesh, int nodeid);
00265 void FEM_Print_n2e(int mesh, int nodeid);
00266 void FEM_Print_e2e(int mesh, int eid);
00267 void FEM_Print_e2n(int mesh, int eid);
00268
00269
00270 void FEM_Mesh_allocate_valid_attr(int fem_mesh, int entity_type);
00271 void FEM_set_entity_valid(int mesh, int entityType, int entityIdx);
00272 void FEM_set_entity_invalid(int mesh, int entityType, int entityIdx);
00273 int FEM_is_valid(int mesh, int entityType, int entityIdx);
00274 int FEM_count_valid(int mesh, int entityType);
00275
00276
00277 int FEM_is_node_shared(int mesh, int idx);
00278 int FEM_find_node_owner(int mesh, int idx);
00279
00280
00281 void FEM_Mesh_detect_features(int fem_mesh);
00282
00283
00284
00285 void FEM_set_entity_coord2(int mesh, int entityType, int entityIdx, double x, double y);
00286 void FEM_set_entity_coord3(int mesh, int entityType, int entityIdx, double x, double y, double z);
00287
00288
00289 void FEM_Mesh_Become_Setting(int mesh);
00290 void FEM_Mesh_Become_Getting(int mesh);
00291
00292
00293 int FEM_Mesh_default_read(void);
00294 int FEM_Mesh_default_write(void);
00295 void FEM_Mesh_set_default_read(int fem_mesh);
00296 void FEM_Mesh_set_default_write(int fem_mesh);
00297
00298 void FEM_Exchange_ghost_lists(int who,int nIdx,const int *localIdx);
00299 int FEM_Get_ghost_list_length(void);
00300 void FEM_Get_ghost_list(int *dest);
00301
00302 void FEM_Update_field(int fid, void *nodes);
00303 void FEM_Update_ghost_field(int fid, int elTypeOrMinusOne, void *nodes);
00304 void FEM_Reduce_field(int fid, const void *nodes, void *outbuf, int op);
00305 void FEM_Reduce(int fid, const void *inbuf, void *outbuf, int op);
00306
00307 void FEM_Read_field(int fid, void *nodes, const char *fname);
00308
00309 void FEM_Set_node(int nNodes,int doublePerNode);
00310 void FEM_Set_node_data(const double *data);
00311 void FEM_Set_elem(int elType,int nElem,int doublePerElem,int nodePerElem);
00312 void FEM_Set_elem_data(int elType,const double *data);
00313 void FEM_Set_elem_conn(int elType,const int *conn);
00314 void FEM_Set_sparse(int uniqueIdentifier,int nRecords,
00315 const int *nodes,int nodesPerRec,
00316 const void *data,int dataPerRec,int dataType);
00317 void FEM_Set_sparse_elem(int uniqueIdentifier,const int *rec2elem);
00318
00319 void FEM_Get_node(int *nNodes,int *doublePerNode);
00320 void FEM_Get_node_data(double *data);
00321 void FEM_Get_elem(int elType,int *nElem,int *doublePerElem,int *nodePerElem);
00322 void FEM_Get_elem_data(int elType,double *data);
00323 void FEM_Get_elem_conn(int elType,int *conn);
00324 int FEM_Get_sparse_length(int uniqueIdentifier);
00325 void FEM_Get_sparse(int uniqueIdentifier,int *nodes,void *data);
00326
00327 void FEM_Set_mesh(int nelem, int nnodes, int nodePerElem, int* conn);
00328
00329 int FEM_Get_node_ghost(void);
00330 int FEM_Get_elem_ghost(int elemType);
00331
00332 void FEM_Update_mesh(FEM_Update_mesh_fn callFn,int userValue,int doWhat);
00333
00334 void FEM_Set_partition(int *elem2chunk);
00335
00336
00337
00338 int FEM_add_node(int mesh, int* adjacent_nodes=0, int num_adjacent_nodes=0, int *chunks=0, int numChunks=0, int forceShared=0);
00339 int FEM_add_element(int mesh, int* conn, int conn_size, int elem_type=0, int chunkNo=-1);
00340 void FEM_remove_node(int mesh,int node);
00341 int FEM_remove_element(int mesh, int element, int elem_type=0, int permanent=-1);
00342 int FEM_Modify_Lock(int mesh, int* affectedNodes, int numAffectedNodes, int* affectedElts=0, int numAffectedElts=0, int elemtype=0);
00343 int FEM_Modify_Unlock(int mesh);
00344 int FEM_Modify_LockN(int mesh, int nodeId, int readLock);
00345 int FEM_Modify_UnlockN(int mesh, int nodeId, int readLock);
00346 void FEM_REF_INIT(int mesh);
00347
00348
00349
00350
00351
00352 void FEM_Print_Mesh_Summary(int mesh);
00353
00354
00355 void FEM_Serial_split(int nchunks);
00356 void FEM_Serial_begin(int chunkNo);
00357
00358 void FEM_Serial_read(int chunkNo,int nChunks);
00359 void FEM_Serial_assemble(void);
00360
00361 int FEM_Get_comm_partners(void);
00362 int FEM_Get_comm_partner(int partnerNo);
00363 int FEM_Get_comm_count(int partnerNo);
00364 void FEM_Get_comm_nodes(int partnerNo,int *nodeNos);
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00395 struct ParFUM_collider {
00396 collide_t collide_grid;
00397 double box_padding;
00398 int dimension;
00399
00400 unsigned int *boxToElementMapping;
00401 unsigned int numCollidableElements;
00402 };
00403
00404
00405
00419 ParFUM_collider ParFUM_Collide_Init(int dimension);
00420
00421
00431 int ParFUM_Collide(ParFUM_collider *c, double box_padding = 0.0);
00432
00448 void ParFUM_Collide_GetCollisions(ParFUM_collider *c, void* results);
00449
00450 void ParFUM_Collide_Destroy(ParFUM_collider *c);
00451
00452
00453
00454
00455
00456
00458
00459 void FEM_ADAPT_Init(int meshID);
00460 FLINKAGE void FTN_NAME(FEM_ADAPT_INIT,fem_adapt_init)(int *meshID);
00461
00462
00463 void FEM_ADAPT_Refine(int meshID, int qm, int method, double factor, double *sizes);
00464 FLINKAGE void FTN_NAME(FEM_ADAPT_REFINE,fem_adapt_refine)(int* meshID,
00465 int *qm, int *method, double *factor, double *sizes);
00466
00467
00468 void FEM_ADAPT_Coarsen(int meshID, int qm, int method, double factor,
00469 double *sizes);
00470 FLINKAGE void FTN_NAME(FEM_ADAPT_COARSEN,fem_adapt_coarsen)(int* meshID,
00471 int *qm, int *method, double *factor, double *sizes);
00472
00473 void FEM_ADAPT_AdaptMesh(int meshID, int qm, int method, double factor, double *sizes);
00474 FLINKAGE void FTN_NAME(FEM_ADAPT_ADAPTMESH,fem_adapt_adaptmesh)(int* meshID,
00475 int *qm, int *method, double *factor, double *sizes);
00476
00477 void FEM_ADAPT_SetElementSizeField(int meshID, int elem, double size);
00478 FLINKAGE void FTN_NAME(FEM_ADAPT_SETELEMENTSIZEFIELD,fem_adapt_setelementsizefield)(int *meshID, int *elem, double *size);
00479
00480
00481 void FEM_ADAPT_SetElementsSizeField(int meshID, double *sizes);
00482 FLINKAGE void FTN_NAME(FEM_ADAPT_SETELEMENTSSIZEFIELD,fem_adapt_setelementssizefield)(int *meshID, double *sizes);
00483
00484
00485 void FEM_ADAPT_SetReferenceMesh(int meshID);
00486 FLINKAGE void FTN_NAME(FEM_ADAPT_SETREFERENCEMESH, fem_adapt_setreferencemesh)(int* meshID);
00487
00488
00489 void FEM_ADAPT_GradateMesh(int meshID, double smoothness);
00490 FLINKAGE void FTN_NAME(FEM_ADAPT_GRADATEMESH, fem_adapt_gradatemesh)(int* meshID, double* smoothness);
00491
00492
00493 void FEM_ADAPT_TestMesh(int meshID);
00494 FLINKAGE void FTN_NAME(FEM_ADAPT_TESTMESH, fem_adapt_testmesh)(int* meshID);
00495
00496
00497 int FEM_ADAPT_SimpleRefineMesh(int meshID, double targetA, double xmin=0.0, double ymin=0.0, double xmax=1.0, double ymax=1.0);
00498 FLINKAGE void FTN_NAME(FEM_ADAPT_SIMPLEREFINEMESH, fem_adapt_simplerefinemesh)(int* meshID, double* targetA, double* xmin, double* ymin, double* xmax, double* ymax);
00499
00500
00501 int FEM_ADAPT_SimpleCoarsenMesh(int meshID, double targetA, double xmin=0.0, double ymin=0.0, double xmax=1.0, double ymax=1.0);
00502 FLINKAGE void FTN_NAME(FEM_ADAPT_SIMPLECOARSENMESH, fem_adapt_simplecoarsenmesh)(int* meshID, double* targetA, double* xmin, double* ymin, double* xmax, double* ymax);
00503
00504
00505
00506
00508 void ParFUM_SA_Init(int meshId);
00509 FLINKAGE void FTN_NAME(PARFUM_SA_INIT,parfum_sa_init)(int *meshId);
00510
00511 #ifdef __cplusplus
00512 }
00513 #endif
00514
00515 #endif
00516