-
Notifications
You must be signed in to change notification settings - Fork 0
/
mesh_interface.h
480 lines (447 loc) · 15 KB
/
mesh_interface.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
#ifndef _MESH_INTERFACE_H_
#define _MESH_INTERFACE_H_
#include <stdlib.h>
#ifdef SIM
#include "SimPartitionedMesh.h"
#include "MeshSim.h"
#include "MeshSimInternal.h"
#include "Eigen.h"
typedef class MVertex * pVertex;
typedef class MEdge * pEdge;
typedef class MFace * pFace;
typedef class MRegion * pRegion;
#include <vector>
#endif
#ifdef FMDB
// using SCOREC tools
//#include "mTSTT.h"
#include "ParUtil.h"
#include "AOMD.h"
#include "AOMD_cint.h"
#include "MeshSimAdapt.h"
#include "MeshSimInternal.h"
#include <math.h>
// enum sthreadType {sthreadNone = 0, sthreadDefault = 1};
#ifdef __cplusplus
// for remote copies
//#include "AOMD_cc.h"
#include <vector>
#endif
#ifdef __cplusplus
extern "C" {
#endif
extern int numParts;
extern int numTotParts;
struct EntCopy {
pEntity rCopy;
int rank;
};
typedef struct EntCopy EntCopy;
typedef struct EntCopy *pEntCopy;
typedef pMesh pParMesh;
typedef pMeshDataId pRegionWtId;
typedef struct pmEnt *pMatch;
typedef pParMesh pUnstructuredMesh;
typedef int pProgress;
//typedef struct entOrig *pEntOrig;
#ifdef __cplusplus
typedef pMeshIterator PBEntProcIter;
typedef pMeshIterator pBdryProcIter;
// typedef class AOMD::mFullIterator *pBdryProcIter;
// typedef class AOMD::mFullIterator *PBEntProcIter;
typedef class PList *pEntCopies;
typedef class PList *pEntOrig;
typedef class SMeshChanges * pMeshChanges;
typedef class BasePartitioner *pPartitioner;
typedef class PartitionOpts *pPartitionOpts;
typedef class AttachDataCommu *pAttachDataCommu;
#else
// typedef struct BdryProcIter *pBEntProcIter;
// typedef struct BdryProcIter *pBdryProcIter;
typedef pMeshIterator pBdryProcIter;
typedef pMeshIterator PBEntProcIter;
typedef struct PList *pEntCopies;
typedef struct PList *pEntOrig;
typedef struct SMeshChanges * pMeshChanges;
typedef struct BasePartitioner *pPartitioner;
typedef struct PartitionOpts *pPartitionOpts;
typedef struct AttachDataCommu *pAttachDataCommu;
#endif
inline int SimMeshing_start(void){
if(P_pid()==0)
printf("\nSimMeshing_start(): Not yet implemented\n");
return 0;
// exit(-1);
}
inline int SimMeshing_stop(void){
if(P_pid()==0)
printf("\nSimMeshing_stop(): Not yet implemented\n");
return 0;
// exit(-1);
}
inline int SimModel_start(void){
if(P_pid()==0)
printf("SimModel start(): Not yet implemented\n");
return 0;
}
inline int SimModel_stop(void){return 0;}
inline int Sim_readLicenseFile(const char *filename){return 1;}
inline void Sim_logOff(void){};
inline void SimPartitionedMesh_start(int *pargc, char ***pargv) {
AOMD::ParUtil::Instance()->init(*pargc,*pargv);
}
inline void SimPartitionedMesh_stop() {
AOMD::ParUtil::Instance()->Finalize();
}
inline const char* SimMeshing_buildID(void){
printf("\nSimMeshing_buildID(): Not yet implemented\n");
return("undergoing");
}
inline const char *SimPartitionedMesh_buildID(){
if(P_pid()==0)
printf("\nSimPartitionedMesh_buildID(): Not yet implemented\n");
return("undergoing");
}
inline const char* SimMeshTools_buildID(){
if(P_pid()==0)
printf("\nSimMeshTools_buildID(): Not yet implemented\n");
return("undergoing");
}
inline const char* SimAdvMeshing_buildID(){
if(P_pid()==0)
printf("\nSimAdvMeshing_buildID(): Not yet implemented\n");
return("undergoing");
}
inline int MS_registerKey(const char *key){
if(P_pid()==0)
printf("\nMS_registerKey(): Not yet implemented\n");
return 0;
// exit(-1);
}
inline void EN_deleteDataDbl(pEntity ent, pMeshDataId id) {EN_deleteData(ent,id);}
inline int Match_gid(pMatch pmatch) {
if(P_pid()==0)
printf("\nMatch_gid() : NOT yet implemented\n");
exit(-1);
}
inline pEntity Match_ent(pMatch pmatch){
if(P_pid()==0)
printf("\nMatch_ent(): Not yet implemented\n");
return (pEntity)0;
}
inline pMatch PList_matchItem(pPList pl, int i){
if(P_pid()==0)
printf("\nPList_matchItem(): Not yet implemented\n");
return (pMatch)0;
}
/* lets start from here */
inline int M_write(pMesh mesh, const char *filename, int version)
{
M_writeSMS(mesh,filename,2);
return 1;
}
inline void M_release(pUnstructuredMesh pm){M_delete(pm);}
inline int PM_verify(pParMesh pm, int choice, int thropt, pProgress progess){
// if(M_verify(pm))
if(P_pid()==0)
printf("\nM_verify is not implemented\n");
return 1;
// else
//return 0;
}
#ifdef FMDB
inline pMesh PM_mesh(pParMesh pm, int p){return pm;}
#endif
inline pGModel PM_model(pParMesh pm){return M_model(pm);}
inline int PM_numParts(pParMesh pm) {return numParts;}
inline int PM_totalNumParts(pParMesh pm) {return numTotParts;}
inline int PMU_rank() {return P_pid();}
inline int PMU_size() {return P_size();}
inline int PMU_gid(int proc, int p) {return P_pid()*numParts+p;}
inline int PMU_proc(int gid) {return gid/numParts;}
inline int PMU_totalPartFromGid(int tnparts, int gid) {return 0;}
inline pBdryProcIter PM_bdryProcIter(pParMesh pm, int etype) {
switch(etype) {
case 0 :
return(pBdryProcIter)M_vertexIter(pm);
break;
case 1 :
return (pBdryProcIter)M_edgeIter(pm);
break;
case 2 :
return (pBdryProcIter)M_faceIter(pm);
break;
default:
if(P_pid()==0)
printf("\nPM_bdryProcIter() : etype=%d NOT supported\n",etype);
exit(-1);
}
}
inline pEntity BdryProcIter_next(pBdryProcIter iter) {
pEntity ent = 0;
// use RIter_next to get the next ent
// even if the iter is for vertex etc. we use RIter_next()
// see AOMD.cc for more details
while(1) {
ent = RIter_next(iter);
if(ent) {
if(EN_duplicate(ent))
break;
}
else
return 0;
}
return ent;
}
// even if the iter is for vertex etc. we use RIter_reset()
// see AOMD.cc for more details
inline void BdryProcIter_reset(pBdryProcIter iter) {RIter_reset(iter);}
// even if the iter is for vertex etc. we use RIter_delete()
// see AOMD.cc for more details
inline void BdryProcIter_delete(pBdryProcIter iter) {RIter_delete(iter);}
inline int EN_ownerProc(pEntity ent){return EN_owner(ent);}
inline int EN_isOwnerProc(pEntity ent){
int proc1, proc2;
proc1 = P_pid();
proc2 = EN_owner(ent);
if(proc1==proc2)
return 1;
else
return 0;
}
inline int EN_isOwnerPart(pEntity ent, int p){
if(!EN_duplicate(ent))return 1;
if(EN_owner(ent)==P_pid()*numParts+p) return 1;
return 0;
}
inline int EN_isOnPartBdry(pEntity ent) { return EN_duplicate(ent);}
inline int PM_numBdryEnt(pParMesh pm, int p, int etype, int proc) {
int count = 0;
pBdryProcIter pbIter = PM_bdryProcIter(pm,etype);
pEntity ent;
while(ent = BdryProcIter_next(pbIter)) {
if(!EN_isOwnerPart(ent, p))
continue;
if(EN_getCopy(ent,proc))
count++;
}
BdryProcIter_delete(pbIter);
return count;
}
#ifdef __cplusplus
inline pEntCopies EN_copies(pEntity ent){
pEntCopies ec = PList_new();
std::vector<std::pair<pEntity,int> > remoteCopies;
std::vector<std::pair<pEntity,int> >::iterator vecIter;
EN_getCopies(ent,remoteCopies);
for(vecIter=remoteCopies.begin(); vecIter!=remoteCopies.end(); ++vecIter) {
pEntCopy entCopy = new EntCopy;
entCopy->rCopy = vecIter->first;
entCopy->rank = vecIter->second;
PList_append(ec,entCopy);
}
return ec;
}
inline int EntCopies_size(pEntCopies ec){return PList_size(ec);}
inline pEntity EntCopies_ent(pEntCopies ec, int n){return ((pEntCopy)PList_item(ec,n))->rCopy;}
inline int EntCopies_gid(pEntCopies ec, int n){return ((pEntCopy)PList_item(ec,n))->rank;}
inline void EntCopies_delete(pEntCopies ec) {
void *iter = 0;
pEntCopy entCopy;
while(entCopy = (pEntCopy)PList_next(ec,&iter)) {
delete entCopy;
}
PList_delete(ec);
}
inline pEntOrig EN_original(pEntity ent){
void *iter =0;
pEntOrig eo = PList_new();
pEntCopy entOrig = new EntCopy;
entOrig->rank = EN_owner(ent);
pEntCopies ec = EN_copies(ent);
pEntCopy entCopy;
while(entCopy = (pEntCopy)PList_next(ec,&iter)){
if(entCopy->rank == entOrig->rank){
entOrig->rCopy = entCopy->rCopy;
break;
}
else
continue;
}
EntCopies_delete(ec);
PList_append(eo,entOrig);
return eo;
}
inline void EntOrig_delete(pEntOrig eo){
void *iter = 0;
pEntCopy entOrig;
while(entOrig = (pEntCopy)PList_next(eo,&iter)) {
delete entOrig;
}
PList_delete(eo);
}
inline pEntity EntOrig_ent(pEntOrig eo){
return ((pEntCopy)PList_item(eo,0))->rCopy;
}
#endif
/* lets first implement above ones */
typedef enum MeshModType {
MeshModType_TRef=0, MeshModType_VMov, MeshModType_ESplit, MeshModType_EColapse,
MeshModType_ESwap, MeshModType_ESplitClps, MeshModType_FSwap, MeshModType_RColapse,
MeshModType_CavRetri, MeshModType_General
} MeshModType;
inline void MSA_setPartWts(pMSAdapt simAdapter, const double *partwts){
if(P_pid()==0)
printf("\nMSA_setPartWts(): Not yet implemented\n");
}
/* inline pPList MCO_getCreatedEntities(pMeshChanges mco){ */
/* printf("\nMCO_getCreatedEntities(): Not yet implemented\n"); */
/* return (pPList)0; */
/* } */
/* inline pPList MCO_getDeletedEntities(pMeshChanges mco){ */
/* printf("\nMCO_getDeletedEntities(): Not yet implemented\n"); */
/* return (pPList)0; */
/* } */
inline pPartitionOpts PartitionOpts_new(){
if(P_pid()==0)
printf("\nPartitionOpts_new(): Not yet implemented\n");
return (pPartitionOpts)0;
}
inline void PartitionOpts_delete(pPartitionOpts popts){
if(P_pid()==0)
printf("\nPartitionOpts(): Not yet implemented\n");
}
inline void PartitionOpts_setTotalNumParts(pPartitionOpts popts, int dtnump){
if(P_pid()==0)
printf("\nPartionOpts_setTotNparts(): Not yet implemented\n");
}
inline void PartitionOpts_setProcWt(pPartitionOpts popts, const double *wt){
if(P_pid()==0)
printf("\nPartionOpts_setProcWt(): Not yet implemented\n");
}
inline void PartitionOpts_setPartWtEqual(pPartitionOpts popts){
if(P_pid()==0)
printf("\nPartionOpts_setPartWtEqual(): Not yet implemented\n");
}
inline void PartitionOpts_setEntityWeightId(pPartitionOpts popts, int i, pRegionWtId id){
if(P_pid()==0)
printf("\nPartionOpts_setsetEntityWeightId(): Not yet implemented\n");
}
inline void PartitionOpts_setNumEntityWeightIds(pPartitionOpts popts, int nrwtid){
if(P_pid()==0)
printf("\nPartionOpts_setNumEntityWeightIds(): Not yet implemented\n");
}
inline void PM_partition(pParMesh pm, pPartitionOpts popts, int thropt, pProgress prog){
if(P_pid()==0)
printf("\nPM_partition(): Not yet implemented\n");
}
inline pRegionWtId EntityWeightId_new(const char *tag){
if(P_pid()==0)
printf("\nEntityWeightId_new(): Not yet implemented\n");
return (pRegionWtId)0;
}
inline void EN_setWeight(pRegion r, pRegionWtId id, int wgt){
if(P_pid()==0)
printf("\nEN_setWeight(): Not yet implemented\n");
}
inline void EntityWeightId_delete(pRegionWtId id){
if(P_pid()==0)
printf("\nEntityWeightId_delete(): Not yet implemented\n");
}
inline void PM_setMigrId(pParMesh pm, pMeshDataId id){
if(P_pid()==0)
printf("\nPM_setMigrId(): Not yet implemented\n");
}
inline void PM_removeMigrId(pParMesh pm, pMeshDataId id){
if(P_pid()==0)
printf("\nPM_removeMigrId(): Not yet implemented\n");
}
inline pAttachDataCommu AttachDataCommu_new(int mult, int var,
int maxper){
if(P_pid()==0)
printf("\nAttachDataCommu_new(): Not yet implemented\n");
return (pAttachDataCommu)0;
}
inline void AttachDataCommu_delete(pAttachDataCommu adc){
if(P_pid()==0)
printf("\nAttachDataCommu_delete(): Not yet implemented\n");
}
inline int pm_sendAnInt(pAttachableData ad, pAttachDataId id, int cb, void **a, void *b){
if(P_pid()==0)
printf("\npm_sendAnInt(): Not yet implemented\n");
return 0;
}
inline int pm_recvAnInt(pAttachableData ad, pAttachDataId id, int cb, void **a, void *b){
if(P_pid()==0)
printf("\npm_recvAnInt(): Not yet implemented\n");
return 0;
}
inline int pm_sendDblArray(pAttachableData ad, pAttachDataId id, int cb, void **a, void *b){
if(P_pid()==0)
printf("\npm_sendDblArray(): Not yet implemented\n");
return 0;
}
inline int pm_recvDblArray(pAttachableData ad, pAttachDataId id, int cb, void **a, void *b){
if(P_pid()==0)
printf("\npm_recvDblArray(): Not yet implemented\n");
return 0;
}
inline pVertex F_oppositeVertex(pFace face, pEdge edge){
return F_edOpVt(face,edge);
}
inline pPList EN_matches(pEntity ent, pGEntity filter){
if(P_pid()==0)
printf("\nEN_matches() : Not yet implemented\n");
return (pPList)0;
}
inline double E_length(pEdge edge){
return sqrt(E_lengthSq(edge));
}
inline void GM_release(pGModel model){
GM_delete(model);
}
inline void MD_setMeshCallback(pMeshDataId id, int event, CBfunc f, void *cbdata){
if(P_pid()==0)
printf("MD_setMeshCallback() not implemented yet\n");
}
inline void MD_removeMeshCallback(pMeshDataId id, int event){
if(P_pid()==0)
printf("MD_removeMeshCallback() not implemented yet\n");
}
#ifdef __cplusplus
}
#endif
#endif
//end of SCOREC tools
#ifdef SIM
#ifdef __cplusplus
extern "C" {
#endif
inline int F_conToFace(pFace face1, pFace face2) {
pPList fverts, fedges;
pEdge edge;
pVertex vtx;
void *temp;
temp = 0;
fverts = F_vertices(face1,1);
while (vtx = (pVertex)PList_next(fverts,&temp))
if (F_inClosure(face2,vtx)) {
PList_delete(fverts);
return 1;
}
PList_delete(fverts);
temp = 0;
fedges = F_edges(face1,0,0);
while (edge = (pEdge)PList_next(fedges,&temp))
if (F_inClosure(face2,edge)) {
PList_delete(fedges);
return 1;
}
PList_delete(fedges);
return 0;
}
#ifdef __cplusplus
}
#endif
#endif //endif SIM
#endif