00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "MeshCut_Maillage.hxx"
00021 #include "MeshCut_Cube.hxx"
00022
00023 #include <iostream>
00024 #include <sstream>
00025 #include <list>
00026 #include <algorithm>
00027 #include <cmath>
00028 #include <cstring>
00029
00030 using namespace MESHCUT;
00031 using namespace std;
00032
00033 Maillage::Maillage(std::string _ID)
00034 {
00035 ID = _ID;
00036 nombreNoeudsMaillage = 0;
00037 nombreMaillesMaillage = 0;
00038
00039 GM.clear();
00040 GN.clear();
00041 for (int itm = (int) POI1; itm <= (int) HEXA20; itm++)
00042 EFFECTIFS_TYPES[(TYPE_MAILLE) itm] = 0;
00043 }
00044
00045 Maillage::~Maillage()
00046 {
00047 }
00048
00049 void Maillage::creationGMtype(TYPE_MAILLE tm, std::string nomGMtype)
00050 {
00051
00052 for (int nl = 0; nl < EFFECTIFS_TYPES[tm]; nl++)
00053 GM[nomGMtype][tm].push_back(nl);
00054 GM[nomGMtype][tm].resize(EFFECTIFS_TYPES[tm]);
00055 sort(GM[nomGMtype][tm].begin(), GM[nomGMtype][tm].end());
00056 }
00057
00058 void Maillage::afficheMailles(TYPE_MAILLE tm)
00059 {
00060 cout << "Affichage des mailles du type " << TM2string(tm) << " (effectif " << EFFECTIFS_TYPES[tm] << "): " << endl;
00061 if (EFFECTIFS_TYPES[tm])
00062 {
00063
00064 int nnoeuds = Nnoeuds(tm);
00065 for (int i = 0; i < EFFECTIFS_TYPES[tm]; i++)
00066 {
00067 cout << "\tMaille " << i << " :" << endl;
00068
00069 int * offset = CNX[tm] + nnoeuds * i;
00070 for (int j = 0; j < nnoeuds; j++)
00071 {
00072 int ngnoeud = *(offset + j);
00073
00074 cout << "\t" << ngnoeud << "\t" << *(XX + ngnoeud - 1) << " " << *(YY + ngnoeud - 1) << " " << *(ZZ + ngnoeud - 1) << endl;
00075 }
00076 }
00077 cout << endl;
00078 }
00079 }
00080
00081 void Maillage::listeMaillesType(TYPE_MAILLE tm)
00082 {
00083 cout << "La fonction \"Restitution des mailles par type\" est obsolète " << endl;
00084
00085
00086
00087
00088
00089
00090 }
00091
00092 void Maillage::listeMaillesTousTypes()
00093 {
00094 for (int itm = (int) POI1; itm <= (int) HEXA20; itm++)
00095 {
00096 TYPE_MAILLE tm = (TYPE_MAILLE) itm;
00097 listeMaillesType(tm);
00098 }
00099 }
00100
00101 void Maillage::listeMaillesParGM()
00102 {
00103 cout << "Liste des mailles par GM : " << endl;
00104 for (map<string, map<TYPE_MAILLE, vector<int> > >::iterator I = GM.begin(); I != GM.end(); I++)
00105 listeMaillesGM(I->first);
00106 }
00107
00108 void Maillage::listeMaillesGM(std::string nomGM)
00109 {
00110 cout << "Liste des mailles du groupe " << nomGM << " : " << endl;
00111 for (int itm = (int) POI1; itm <= (int) HEXA20; itm++)
00112 {
00113 TYPE_MAILLE tm = (TYPE_MAILLE) itm;
00114 if (GM[nomGM][tm].size())
00115 {
00116 cout << "\t" << TM2string(tm) << " : ";
00117 for (unsigned int j = 0; j < GM[nomGM][tm].size(); j++)
00118 cout << GM[nomGM][tm][j] << " ";
00119 cout << endl;
00120 }
00121 }
00122 }
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133 void Maillage::listeNoeuds()
00134 {
00135 cout << "Liste des noeuds du maillage : " << endl;
00136 for (int i = 0; i < nombreNoeudsMaillage; i++)
00137 cout << "\t" << *(XX + i) << " " << *(YY + i) << " " << *(ZZ + i) << endl;
00138 cout << endl;
00139 }
00140
00141 void Maillage::listeNoeudsGN(std::string nomGN)
00142 {
00143 cout << "Liste brute des noeuds du groupe " << nomGN << " (" << GN[nomGN].size() << " noeuds) : ";
00144 for (unsigned int j = 0; j < GN[nomGN].size(); j++)
00145 cout << GN[nomGN][j] << " ";
00146 cout << endl;
00147 }
00148
00149 void Maillage::listeNoeudsGNordonne(std::string nomGN)
00150 {
00151 cout << "Liste ordonnée des noeuds du groupe " << nomGN << " (" << GN[nomGN].size() << " noeuds) : ";
00152 sort(GN[nomGN].begin(), GN[nomGN].end());
00153 for (unsigned int j = 0; j < GN[nomGN].size(); j++)
00154 cout << GN[nomGN][j] << " ";
00155 cout << endl;
00156 }
00157
00158 std::vector<float> Maillage::G(int i, TYPE_MAILLE tm)
00159 {
00160 vector<float> G;
00161 float x = 0.0;
00162 float y = 0.0;
00163 float z = 0.0;
00164 int nn = NnoeudsGeom(tm);
00165 for (int j = 0; j < nn; j++)
00166 {
00167 int ng = CNX[tm][nn * i + j];
00168 x += XX[ng - 1];
00169 y += YY[ng - 1];
00170 z += ZZ[ng - 1];
00171 }
00172 G.push_back(x / nn);
00173 G.push_back(y / nn);
00174 G.push_back(z / nn);
00175 G.resize(3);
00176 return G;
00177 }
00178
00179 float Maillage::distanceNoeudMaille(int ngnoeud, int imaille, TYPE_MAILLE tm)
00180 {
00181 float x, y, z;
00182 float x0 = XX[ngnoeud - 1];
00183 float y0 = YY[ngnoeud - 1];
00184 float z0 = ZZ[ngnoeud - 1];
00185 int nn = NnoeudsGeom(tm);
00186 float d1 = 1000000000000.0;
00187 float d;
00188 for (int j = 0; j < nn; j++)
00189 {
00190 int ng = CNX[tm][nn * imaille + j];
00191 x = XX[ng - 1];
00192 y = YY[ng - 1];
00193 z = ZZ[ng - 1];
00194 d = sqrt((x - x0) * (x - x0) + (y - y0) * (y - y0) + (z - z0) * (z - z0));
00195 if (d < d1)
00196 d1 = d;
00197 }
00198 return d1;
00199 }
00200
00204 int Maillage::noeudVoisin(int ngnoeud, int imaille, TYPE_MAILLE tm)
00205 {
00206 float x, y, z;
00207 int ngv;
00208 float x0 = XX[ngnoeud - 1];
00209 float y0 = YY[ngnoeud - 1];
00210 float z0 = ZZ[ngnoeud - 1];
00211 int nn = NnoeudsGeom(tm);
00212 float d1 = 1000000000000.0;
00213 float d;
00214 for (int j = 0; j < nn; j++)
00215 {
00216 int ng = CNX[tm][nn * imaille + j];
00217 x = XX[ng - 1];
00218 y = YY[ng - 1];
00219 z = ZZ[ng - 1];
00220 d = sqrt((x - x0) * (x - x0) + (y - y0) * (y - y0) + (z - z0) * (z - z0));
00221 if (d < d1)
00222 {
00223 d1 = d;
00224 ngv = ng;
00225 }
00226 }
00227 return ngv;
00228 }
00229
00230 float Maillage::distanceNoeudNoeud(int ng1, int ng2)
00231 {
00232 float x1, x2, y1, y2, z1, z2;
00233 x1 = XX[ng1 - 1];
00234 y1 = YY[ng1 - 1];
00235 z1 = ZZ[ng1 - 1];
00236 x2 = XX[ng2 - 1];
00237 y2 = YY[ng2 - 1];
00238 z2 = ZZ[ng2 - 1];
00239 return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2) + (z1 - z2) * (z1 - z2));
00240 }
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267 void Maillage::inputMED(std::string fichierMED)
00268 {
00269
00270
00271
00272 int j;
00273
00274 med_idt fid;
00275 char maa[MED_NAME_SIZE + 1];
00276 med_int spacedim;
00277 med_int mdim;
00278 med_mesh_type type;
00279 char desc[MED_COMMENT_SIZE + 1];
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294 med_int nPasTemps;
00295
00296
00297
00298 char dtunit[MED_SNAME_SIZE + 1] = "";
00299
00300
00301
00302
00303 med_sorting_type sortingtype;
00304 med_axis_type axistype;
00305
00306
00307 FAMILLES.clear();
00308 FAM_TYPES.clear();
00309 FAMILLES_NOEUDS.clear();
00310 GROUPES_MAILLES.clear();
00311 GROUPES_NOEUDS.clear();
00312 RESIDU.clear();
00313 tailleFAMILLES.clear();
00314 tailleGROUPES.clear();
00315
00316
00317 fid = MEDfileOpen(string2char(fichierMED), MED_ACC_RDONLY);
00318 if (fid < 0)
00319 {
00320 ERREUR("Error file open\n");
00321 }
00322
00323
00324
00325 if (MEDmeshInfo(fid, 1, maa, &spacedim, &mdim, &type, desc, dtunit, &sortingtype, &nPasTemps, &axistype, axisname,
00326 unitname) < 0)
00327 ERREUR("Error while reading mesh informations ");
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342 dimensionMaillage = mdim;
00343 dimensionEspace = spacedim;
00344
00345 ID = (string) maa;
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396
00397
00398
00399
00400
00401
00402
00403
00404
00405
00406
00407
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463
00464
00465
00466
00467
00468
00469
00470
00471 med_int nFamilles;
00472 char nomGroupeChar[MED_LNAME_SIZE + 1];
00473 if ((nFamilles = MEDnFamily(fid, maa)) < 0)
00474 ERREUR("ERROR MEDnFamily");
00475
00476
00477
00478
00479
00480
00481
00482
00483
00484
00485
00486
00487
00488
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498
00499
00500
00501
00502
00503 for (int i = 0; i < nFamilles; i++)
00504 {
00505 char nomfam[MED_NAME_SIZE + 1];
00506 char *attdes, *gro;
00507 med_int numfam, *attide, *attval, natt, ngro;
00508
00509 if ((ngro = MEDnFamilyGroup(fid, maa, i + 1)) < 0)
00510 ERREUR("ERROR MEDnFamilyGroup");
00511 if ((natt = MEDnFamily23Attribute(fid, maa, i + 1)) < 0)
00512 ERREUR("ERROR MEDnFamily23Attribute");
00513
00514 attide = (med_int *) malloc(sizeof(med_int) * natt);
00515 attval = (med_int *) malloc(sizeof(med_int) * natt);
00516 attdes = (char *) malloc(MED_COMMENT_SIZE * natt + 1);
00517 gro = (char *) malloc(MED_LNAME_SIZE * ngro + 1);
00518
00519 if (MEDfamilyInfo(fid, maa, (med_int) (i + 1), nomfam, &numfam, gro) < 0)
00520 ERREUR("ERROR MEDfamilyInfo");
00521
00522 for (int ig = 1; ig <= ngro; ig++)
00523 {
00524 for (j = 0; j < MED_LNAME_SIZE; j++)
00525 nomGroupeChar[j] = gro[(ig - 1) * MED_LNAME_SIZE + j];
00526 nomGroupeChar[MED_LNAME_SIZE] = '\0';
00527
00528 tailleGROUPES[strip((string) nomGroupeChar)]++;
00529 if (numfam > 0)
00530 GROUPES_NOEUDS[strip((string) nomGroupeChar)].push_back((int) numfam);
00531 else if (numfam < 0)
00532 GROUPES_MAILLES[strip((string) nomGroupeChar)].push_back((int) numfam);
00533 }
00534
00535 free(attide);
00536 free(attval);
00537 free(attdes);
00538 free(gro);
00539 }
00540
00541
00542
00543
00544
00545
00546
00547
00548
00549
00550
00551
00552 string line, IDnoeud;
00553 float x0, x1, y0, y1, z0, z1;
00554
00555 vector<int> RESIDU_NOEUDS;
00556
00557 ostringstream OSCOORD;
00558
00559 med_int nnoe = 0;
00560 med_float *coo1;
00561
00562
00563 char *nomnoe;
00564
00565 med_int *numnoe;
00566 med_int *nufano;
00567
00568
00569
00570 med_bool coordinatechangement;
00571 med_bool geotransformation;
00572
00573
00574 nnoe = MEDmeshnEntity(fid, maa, MED_NO_DT, MED_NO_IT, MED_NODE, MED_NO_GEOTYPE, MED_COORDINATE, MED_NO_CMODE,
00575 &coordinatechangement, &geotransformation);
00576
00577 if (nnoe < 0)
00578 ERREUR("Error while reading number of nodes");
00579
00580 nombreNoeudsMaillage = nnoe;
00581
00582
00583 med_int *famNoeuds = (med_int*) malloc(sizeof(med_int) * nnoe);
00584 if (nnoe > 0)
00585 {
00586 if (MEDmeshEntityFamilyNumberRd(fid, maa, MED_NO_DT, MED_NO_IT, MED_NODE, MED_NONE, famNoeuds) < 0)
00587 ERREUR("Error while reading family node number (MEDmeshEntityFamilyNumberRd)");
00588 }
00589
00590
00591 if (nnoe > 0)
00592 {
00593
00594 coo1 = (med_float*) calloc(nnoe * mdim, sizeof(med_float));
00595
00596 numnoe = (med_int*) malloc(sizeof(med_int) * nnoe);
00597 nufano = (med_int*) malloc(sizeof(med_int) * nnoe);
00598
00599 nomnoe = (char*) malloc(MED_SNAME_SIZE * nnoe + 1);
00600 }
00601
00602
00603 if (nnoe > 0)
00604 if (MEDmeshNodeCoordinateRd(fid, maa, MED_NO_DT, MED_NO_IT, MED_FULL_INTERLACE, coo1) < 0)
00605 ERREUR("Error while reading nodes coordinates");
00606
00607
00608
00609
00610
00611
00612
00613
00614
00615
00616
00617
00618
00619
00620
00621
00622
00623
00624
00625
00626
00627
00628
00629
00630
00631
00632
00633
00634
00635
00636
00637
00638
00639
00640
00641
00642
00643
00644
00645
00646
00647
00648
00649
00650
00651
00652
00653
00654
00655
00656
00657 x0 = coo1[0];
00658 x1 = coo1[0];
00659 y0 = coo1[1];
00660 y1 = coo1[1];
00661 if (mdim == 3)
00662 {
00663 z0 = coo1[2];
00664 z1 = coo1[2];
00665 }
00666 else
00667 {
00668 z0 = 0.0;
00669 z1 = 0.0;
00670 }
00671
00672
00673 XX = (float*) malloc(sizeof(float) * nombreNoeudsMaillage);
00674 if (mdim > 1)
00675 YY = (float*) malloc(sizeof(float) * nombreNoeudsMaillage);
00676 if (mdim > 2)
00677 ZZ = (float*) malloc(sizeof(float) * nombreNoeudsMaillage);
00678
00679 for (int i = 0; i < nnoe; i++)
00680 {
00681
00682
00683
00684
00685 FAMILLES_NOEUDS[*(famNoeuds + i)].push_back(i + 1);
00686 tailleFAMILLES[*(famNoeuds + i)]++;
00687
00688
00689
00690 float * XXi = XX + i;
00691 float * YYi = YY + i;
00692 float * ZZi = ZZ + i;
00693
00694 if (mdim == 3)
00695 {
00696 *XXi = (float) coo1[3 * i];
00697 *YYi = (float) coo1[3 * i + 1];
00698 *ZZi = (float) coo1[3 * i + 2];
00699 if (*XXi < x0)
00700 x0 = *XXi;
00701 else if (*XXi > x1)
00702 x1 = *XXi;
00703 if (*YYi < y0)
00704 y0 = *YYi;
00705 else if (*YYi > y1)
00706 y1 = *YYi;
00707 if (*ZZi < z0)
00708 z0 = *ZZi;
00709 else if (*ZZi > z1)
00710 z1 = *ZZi;
00711 }
00712 else if (mdim == 2)
00713 {
00714 *XXi = (float) coo1[2 * i];
00715 *YYi = (float) coo1[2 * i + 1];
00716 if (*XXi < x0)
00717 x0 = *XXi;
00718 else if (*XXi > x1)
00719 x1 = *XXi;
00720 if (*YYi < y0)
00721 y0 = *YYi;
00722 else if (*YYi > y1)
00723 y1 = *YYi;
00724 }
00725 else if (mdim == 1)
00726 {
00727 *XXi = (float) coo1[1 * i];
00728 if (*XXi < x0)
00729 x0 = *XXi;
00730 else if (*XXi > x1)
00731 x1 = *XXi;
00732 }
00733
00734
00735
00736
00737
00738
00739
00740 }
00741
00742
00743
00744
00745 enveloppeMaillage = new Cube(x0, x1, y0, y1, z0, z1);
00746
00747
00748 if (nnoe > 0)
00749 {
00750 free(coo1);
00751 free(nomnoe);
00752 free(numnoe);
00753 free(nufano);
00754 }
00755
00756
00757
00758
00759
00760
00761
00762
00763
00764 for (int itm = (int) POI1; itm <= (int) HEXA20; itm++)
00765 {
00766 TYPE_MAILLE tm = (TYPE_MAILLE) itm;
00767 EFFECTIFS_TYPES[tm] = MEDmeshnEntity(fid, maa, MED_NO_DT, MED_NO_IT, MED_CELL, InstanceMGE(tm), MED_CONNECTIVITY,
00768 MED_NODAL, &coordinatechangement, &geotransformation);
00769 if (EFFECTIFS_TYPES[tm])
00770 acquisitionTYPE_inputMED(tm, EFFECTIFS_TYPES[tm], fid, maa, mdim);
00771 }
00772
00773
00774 map<int, vector<int> >::iterator IF;
00775 for (IF = FAMILLES.begin(); IF != FAMILLES.end(); IF++)
00776 {
00777 IF->second.resize(tailleFAMILLES[IF->first]);
00778 FAM_TYPES[IF->first].resize(tailleFAMILLES[IF->first]);
00779 }
00780
00781 for (int itm = (int) POI1; itm <= (int) HEXA20; itm++)
00782 nombreMaillesMaillage += EFFECTIFS_TYPES[(TYPE_MAILLE) itm];
00783
00784
00785
00786
00787
00788
00789
00790
00791
00792
00793
00794
00795
00796
00797 string nomGM;
00798 vector<int> vfam;
00799 map<string, vector<int> >::iterator iterGRO;
00800
00801 int cptGM = 0;
00802 for (iterGRO = GROUPES_MAILLES.begin(); iterGRO != GROUPES_MAILLES.end(); iterGRO++)
00803 {
00804 nomGM = iterGRO->first;
00805 vfam = iterGRO->second;
00806 cptGM++;
00807 map<TYPE_MAILLE, int> effectifGroupeType;
00808 for (unsigned int i = 0; i < vfam.size(); i++)
00809 {
00810 int numf = vfam[i];
00811
00812
00813 for (unsigned int imaille = 0; imaille < FAMILLES[numf].size(); imaille++)
00814 {
00815 TYPE_MAILLE tm = FAM_TYPES[numf][imaille];
00816 int nl = FAMILLES[numf][imaille];
00817 GM[nomGM][tm].push_back(nl);
00818 effectifGroupeType[tm]++;
00819 }
00820 }
00821
00822
00823 for (map<TYPE_MAILLE, vector<int> >::iterator I = GM[nomGM].begin(); I != GM[nomGM].end(); I++)
00824 {
00825 TYPE_MAILLE tm = I->first;
00826 GM[nomGM][tm].resize(effectifGroupeType[tm]);
00827 sort(GM[nomGM][tm].begin(), GM[nomGM][tm].end());
00828 }
00829 }
00830
00831 int cptGN = 0;
00832 for (iterGRO = GROUPES_NOEUDS.begin(); iterGRO != GROUPES_NOEUDS.end(); iterGRO++)
00833 {
00834 nomGM = iterGRO->first;
00835 vfam = iterGRO->second;
00836 cptGN++;
00837 int cptNoeudsGN = 0;
00838 for (unsigned int i = 0; i < vfam.size(); i++)
00839 {
00840 int numf = vfam[i];
00841
00842 for (unsigned int inoeud = 0; inoeud < FAMILLES_NOEUDS[numf].size(); inoeud++)
00843 {
00844 GN[nomGM].push_back(FAMILLES_NOEUDS[numf][inoeud]);
00845 cptNoeudsGN++;
00846 }
00847 }
00848 GN[nomGM].resize(cptNoeudsGN);
00849 sort(GN[nomGM].begin(), GN[nomGM].end());
00850 }
00851
00852 MEDfileClose(fid);
00853
00854 }
00855
00856 void Maillage::acquisitionTYPE_inputMED(TYPE_MAILLE TYPE, int nTYPE, med_idt fid, char maa[MED_NAME_SIZE + 1],
00857 med_int mdim)
00858 {
00859
00860
00861 int numeroFamille;
00862 string line, IDmaille, IDnoeud, typeMaille;
00863
00864
00865 med_int tTYPE = (med_int) Nnoeuds(TYPE);
00866 char *nomTYPE = (char*) malloc(MED_SNAME_SIZE * nTYPE + 1);
00867 med_int *numTYPE = (med_int*) malloc(sizeof(med_int) * nTYPE);
00868 med_int *famTYPE = (med_int*) malloc(sizeof(med_int) * nTYPE);
00869
00870
00871 CNX[TYPE] = (int*) malloc(sizeof(int) * tTYPE * nTYPE);
00872
00873 med_bool inomTYPE, inumTYPE, ifamTYPE;
00874 med_geometry_type typeBanaliseMED = InstanceMGE(TYPE);
00875
00876 if (MEDmeshElementRd(fid, maa, MED_NO_DT, MED_NO_IT, MED_CELL, typeBanaliseMED, MED_NODAL, MED_FULL_INTERLACE,
00877 CNX[TYPE], &inomTYPE, nomTYPE, &inumTYPE, numTYPE, &ifamTYPE, famTYPE) < 0)
00878 ERREUR("Error while reading elements");
00879
00880
00881 conversionCNX(CNX[TYPE], TYPE, nTYPE);
00882
00883
00884
00885
00886
00887
00888
00889
00890 for (int i = 0; i < nTYPE; i++)
00891 {
00892 numeroFamille = (int) *(famTYPE + i);
00893 FAMILLES[numeroFamille].push_back(i);
00894 tailleFAMILLES[numeroFamille]++;
00895 FAM_TYPES[numeroFamille].push_back(TYPE);
00896
00897
00898
00899
00900
00901
00902
00903 }
00904
00905
00906
00907
00908
00909
00910
00911
00912
00913
00914
00915
00916
00917
00918
00919
00920
00921
00922
00923
00924
00925
00926
00927
00928
00929
00930
00931
00932 }
00933
00934 void Maillage::outputMED(std::string fichierMED)
00935 {
00936
00937 int nTYPE, tTYPE;
00938 string line, s, stype, nomnoeud;
00939
00940
00941
00942
00943
00944 if (nombreNoeudsMaillage <= 0)
00945 {
00946 ERREUR("This mesh does not contain any node\n");
00947 }
00948
00949
00950
00951
00952
00953
00954 med_idt fid = MEDfileOpen(string2char(fichierMED), MED_ACC_CREAT);
00955 if (fid < 0)
00956 {
00957 ERREUR("Error MEDfileOpen\n");
00958 cout << "Error MEDfileOpen" << endl;
00959 }
00960
00961
00962 char maa[MED_NAME_SIZE + 1];
00963 strcpy(maa, string2char(ID));
00964
00965 med_int mdim;
00966 if (dimensionMaillage == 0)
00967 {
00968 mdim = 3;
00969 cout << "ATTENTION, dimension 3 attribuée par défaut!" << endl;
00970 }
00971 else
00972 mdim = dimensionMaillage;
00973 med_int spacedim = 3;
00974 if (dimensionEspace)
00975 spacedim = dimensionEspace;
00976
00977
00978 char desc[MED_COMMENT_SIZE + 1];
00979 strcpy(desc, string2char(ID));
00980 med_mesh_type type = MED_UNSTRUCTURED_MESH;
00981
00982
00983
00984
00985
00986
00987 if (MEDmeshCr(fid, maa, spacedim, mdim, type, desc, "s", MED_SORT_DTIT, MED_CARTESIAN, axisname, unitname) < 0)
00988 {
00989 ERREUR("Error MEDmeshCr");
00990 cout << "Error MEDmeshCr" << endl;
00991 }
00992
00993
00994 char nomfam[MED_NAME_SIZE + 1];
00995 med_int numfam;
00996
00997
00998 int ngro;
00999
01000
01001 strcpy(nomfam, "FAMILLE_0");
01002 numfam = 0;
01003 if (MEDfamilyCr(fid, maa, nomfam, numfam, 0, MED_NO_GROUP) < 0)
01004 ERREUR("Error MEDfamilyCr (create family 0)");
01005
01006
01007
01008
01009
01010 int nGroupesNoeuds = GN.size();
01011
01012 vector<vector<int> > ETIQUETTES_N;
01013 ETIQUETTES_N.resize(nombreNoeudsMaillage);
01014 vector<unsigned int> INDEX_N;
01015 INDEX_N.resize(GN.size());
01016 vector<string> NOMSFAM;
01017 vector<vector<int> > ETIQFAM;
01018 int cptNOMFAM = 0;
01019 map<string, int> NUMFAMETIQ;
01020
01021
01022 if (nGroupesNoeuds)
01023 {
01024
01025
01026 vector<string> NOMS_GROUPES_NOEUDS;
01027 for (map<string, vector<int> >::iterator ITGN = GN.begin(); ITGN != GN.end(); ITGN++)
01028 {
01029 string nomGN = ITGN->first;
01030 NOMS_GROUPES_NOEUDS.push_back(nomGN);
01031 }
01032 NOMS_GROUPES_NOEUDS.resize(GN.size());
01033
01034
01035 for (unsigned int ig = 0; ig < NOMS_GROUPES_NOEUDS.size(); ig++)
01036 sort(GN[NOMS_GROUPES_NOEUDS[ig]].begin(), GN[NOMS_GROUPES_NOEUDS[ig]].end());
01037
01038
01039
01040
01041 for (unsigned int ig = 0; ig < NOMS_GROUPES_NOEUDS.size(); ig++)
01042 INDEX_N[ig] = 0;
01043
01044 for (int k = 1; k <= nombreNoeudsMaillage; k++)
01045 {
01046 int tailleEtiquette = 0;
01047 string etiq = (string) "";
01048
01049 for (unsigned int ig = 0; ig < NOMS_GROUPES_NOEUDS.size(); ig++)
01050 {
01051 if (INDEX_N[ig] < GN[NOMS_GROUPES_NOEUDS[ig]].size())
01052 {
01053 string nomgroupe = NOMS_GROUPES_NOEUDS[ig];
01054 if (k == GN[nomgroupe][INDEX_N[ig]])
01055 {
01056
01057
01058
01059 ETIQUETTES_N[k - 1].push_back(ig);
01060 tailleEtiquette++;
01061 etiq += int2string(ig);
01062 INDEX_N[ig]++;
01063 }
01064 }
01065 }
01066 ETIQUETTES_N[k - 1].resize(tailleEtiquette);
01067
01068
01069
01070
01071
01072
01073
01074
01075 if (!NUMFAMETIQ[etiq] && etiq != (string) "")
01076 {
01077 NOMSFAM.push_back((string) "ETIQN_" + etiq);
01078 ETIQFAM.push_back(ETIQUETTES_N[k - 1]);
01079 NUMFAMETIQ[etiq] = cptNOMFAM + 1;
01080 cptNOMFAM++;
01081 }
01082 }
01083
01084 NOMSFAM.resize(cptNOMFAM);
01085 ETIQFAM.resize(cptNOMFAM);
01086
01087
01088 for (unsigned int ifam = 0; ifam < NOMSFAM.size(); ifam++)
01089 {
01090 strcpy(nomfam, string2char(NOMSFAM[ifam]));
01091
01092 numfam = ifam + 1;
01093 ngro = ETIQFAM[ifam].size();
01094
01095
01096 char gro[ngro * MED_LNAME_SIZE + 1];
01097 int cptGN = 0;
01098 for (unsigned int ign = 0; ign < ETIQFAM[ifam].size(); ign++)
01099 {
01100 string nomGNcourant = NOMS_GROUPES_NOEUDS[ETIQFAM[ifam][ign]];
01101
01102
01103 if (ign == 0)
01104 {
01105
01106 strcpy(gro, string2char(nomGNcourant));
01107 for (int jg = nomGNcourant.size(); jg < MED_LNAME_SIZE; jg++)
01108 gro[jg] = ' ';
01109 gro[MED_LNAME_SIZE] = '\0';
01110 }
01111 else
01112 {
01113 strcat(gro, string2char(nomGNcourant));
01114 for (int jg = nomGNcourant.size(); jg < MED_LNAME_SIZE; jg++)
01115 gro[cptGN * MED_LNAME_SIZE + jg] = ' ';
01116 gro[(cptGN + 1) * MED_LNAME_SIZE] = '\0';
01117 }
01118 cptGN++;
01119 }
01120
01121
01122 if (MEDfamilyCr(fid, maa, nomfam, numfam, 0, MED_NO_GROUP) < 0)
01123 ERREUR("Error MEDfamilyCr");
01124
01125 }
01126
01127 }
01128
01129
01130
01131
01132
01133
01134
01135 med_int nnoe = nombreNoeudsMaillage;
01136 med_float *coo;
01137
01138
01139 char nomcoo[mdim * MED_SNAME_SIZE + 1];
01140 string strX = (string) "X";
01141 while (strX.size() < MED_SNAME_SIZE)
01142 strX += (string) " ";
01143 string strY = (string) "Y";
01144 while (strY.size() < MED_SNAME_SIZE)
01145 strY += (string) " ";
01146 string strZ = (string) "Z";
01147 while (strZ.size() < MED_SNAME_SIZE)
01148 strZ += (string) " ";
01149 if (mdim == 3)
01150 strcpy(nomcoo, string2char(strX + strY + strZ));
01151 else if (mdim == 2)
01152 strcpy(nomcoo, string2char(strX + strY));
01153 else
01154 strcpy(nomcoo, string2char(strX));
01155 nomcoo[mdim * MED_SNAME_SIZE] = '\0';
01156
01157
01158 char unicoo[mdim * MED_SNAME_SIZE + 1];
01159 string strmesure = (string) "SI";
01160 while (strmesure.size() < MED_SNAME_SIZE)
01161 strmesure += (string) " ";
01162 if (mdim == 3)
01163 strcpy(unicoo, string2char(strmesure + strmesure + strmesure));
01164 else if (mdim == 2)
01165 strcpy(unicoo, string2char(strmesure + strmesure));
01166 else
01167 strcpy(unicoo, string2char(strmesure));
01168 unicoo[mdim * MED_SNAME_SIZE] = '\0';
01169
01170
01171
01172 char *nomnoe;
01173 med_int *numnoe = NULL;
01174 med_int *nufano;
01175 med_bool inonoe = MED_FALSE;
01176 med_bool inunoe = MED_FALSE;
01177
01178
01179 if (nnoe > 0)
01180 {
01181
01182 coo = (med_float*) calloc(nnoe * mdim, sizeof(med_float));
01183
01184
01185
01186 nufano = (med_int*) malloc(sizeof(med_int) * nnoe);
01187
01188
01189 nomnoe = (char*) "";
01190
01191
01192
01193
01194
01195
01196
01197
01198
01199
01200
01201
01202
01203
01204
01205
01206
01207
01208
01209
01210
01211 }
01212
01213
01214 if (dimensionMaillage == 3)
01215 {
01216 int i3 = 0;
01217 for (int i = 0; i < nnoe; i++)
01218 {
01219
01220
01221
01222
01223 coo[i3] = *(XX + i);
01224 coo[i3 + 1] = *(YY + i);
01225 coo[i3 + 2] = *(ZZ + i);
01226 i3 = i3 + 3;
01227
01228
01229 if (nGroupesNoeuds)
01230 {
01231 vector<int> v = ETIQUETTES_N[i];
01232 string sv = (string) "";
01233 for (unsigned int j = 0; j < v.size(); j++)
01234 sv += int2string(v[j]);
01235
01236 *(nufano + i) = (med_int) NUMFAMETIQ[sv];
01237 }
01238 else
01239 *(nufano + i) = (med_int) 0;
01240
01241
01242
01243 }
01244 }
01245 else
01246 {
01247 int i2 = 0;
01248 for (int i = 0; i < nnoe; i++)
01249 {
01250 coo[i2] = *(XX + i);
01251 coo[i2 + 1] = *(YY + i);
01252 i2 = i2 + 2;
01253
01254 if (nGroupesNoeuds)
01255 {
01256 vector<int> v = ETIQUETTES_N[i];
01257 string sv = (string) "";
01258 for (unsigned int j = 0; j < v.size(); j++)
01259 sv += int2string(v[j]);
01260
01261 *(nufano + i) = (med_int) NUMFAMETIQ[sv];
01262 }
01263 else
01264 *(nufano + i) = (med_int) 0;
01265
01266
01267 }
01268 }
01269
01270
01271
01272
01273
01274
01275
01276
01277
01278 if (MEDmeshNodeWr(fid, maa, MED_NO_DT, MED_NO_IT, MED_UNDEF_DT, MED_FULL_INTERLACE, nnoe, coo, inonoe, nomnoe,
01279 inunoe, numnoe, MED_TRUE, nufano) < 0)
01280 {
01281 ERREUR("Error MEDmeshNodeWr");
01282 cout << "Error MEDmeshNodeWr" << endl;
01283 }
01284
01285
01286
01287
01288
01289 int nGroupesMailles = GM.size();
01290
01291 map<TYPE_MAILLE, vector<vector<int> > > ETIQUETTES_M;
01292
01293
01294
01295 map<TYPE_MAILLE, vector<unsigned int> > INDEX_M;
01296 NOMSFAM.clear();
01297 ETIQFAM.clear();
01298 NUMFAMETIQ.clear();
01299 cptNOMFAM = 0;
01300
01301 if (nGroupesMailles)
01302 {
01303
01304
01305 vector<string> NOMS_GROUPES_MAILLES;
01306 for (map<string, map<TYPE_MAILLE, vector<int> > >::iterator ITGM = GM.begin(); ITGM != GM.end(); ITGM++)
01307 {
01308 string nomGM = ITGM->first;
01309 NOMS_GROUPES_MAILLES.push_back(nomGM);
01310 }
01311 NOMS_GROUPES_MAILLES.resize(GM.size());
01312
01313 for (unsigned int ig = 0; ig < NOMS_GROUPES_MAILLES.size(); ig++)
01314 {
01315 string nomGM = NOMS_GROUPES_MAILLES[ig];
01316 for (map<TYPE_MAILLE, vector<int> >::iterator I = GM[nomGM].begin(); I != GM[nomGM].end(); I++)
01317 {
01318 TYPE_MAILLE tm = I->first;
01319 sort(GM[nomGM][tm].begin(), GM[nomGM][tm].end());
01320 }
01321 }
01322
01323
01324
01325
01326 for (int itm = (int) POI1; itm <= (int) HEXA20; itm++)
01327 {
01328 TYPE_MAILLE tm = (TYPE_MAILLE) itm;
01329 if (EFFECTIFS_TYPES[tm])
01330 {
01331 for (unsigned int ig = 0; ig < NOMS_GROUPES_MAILLES.size(); ig++)
01332 INDEX_M[tm].push_back(0);
01333 ETIQUETTES_M[tm].resize(EFFECTIFS_TYPES[tm]);
01334 }
01335 }
01336
01337 for (int itm = (int) POI1; itm <= (int) HEXA20; itm++)
01338 {
01339 TYPE_MAILLE tm = (TYPE_MAILLE) itm;
01340 int efftm = EFFECTIFS_TYPES[tm];
01341
01342
01343 if (efftm)
01344 {
01345
01346 for (int nl = 0; nl < efftm; nl++)
01347 {
01348
01349
01350
01351 int tailleEtiquette = 0;
01352 string etiq = (string) "";
01353
01354 for (unsigned int ig = 0; ig < NOMS_GROUPES_MAILLES.size(); ig++)
01355 {
01356 string nomGM = NOMS_GROUPES_MAILLES[ig];
01357
01358
01359 if (INDEX_M[tm][ig] < GM[nomGM][tm].size())
01360 {
01361 if (nl == GM[nomGM][tm][INDEX_M[tm][ig]])
01362 {
01363
01364
01365
01366
01367 ETIQUETTES_M[tm][nl].push_back(ig);
01368 tailleEtiquette++;
01369 etiq += int2string(ig);
01370 INDEX_M[tm][ig]++;
01371
01372 }
01373 }
01374 }
01375
01376 ETIQUETTES_M[tm][nl].resize(tailleEtiquette);
01377
01378
01379
01380
01381
01382
01383
01384
01385
01386 if (!NUMFAMETIQ[etiq] && etiq != (string) "")
01387 {
01388 NOMSFAM.push_back((string) "ETIQM_" + etiq);
01389 ETIQFAM.push_back(ETIQUETTES_M[tm][nl]);
01390 NUMFAMETIQ[etiq] = -cptNOMFAM - 1;
01391 cptNOMFAM++;
01392 }
01393
01394 }
01395
01396 }
01397 }
01398
01399 NOMSFAM.resize(cptNOMFAM);
01400 ETIQFAM.resize(cptNOMFAM);
01401
01402
01403 for (unsigned int ifam = 0; ifam < NOMSFAM.size(); ifam++)
01404 {
01405 strcpy(nomfam, string2char(NOMSFAM[ifam]));
01406
01407 numfam = -ifam - 1;
01408 ngro = ETIQFAM[ifam].size();
01409
01410
01411 char gro[ngro * MED_LNAME_SIZE + 1];
01412 int cptGM = 0;
01413 for (unsigned int ign = 0; ign < ETIQFAM[ifam].size(); ign++)
01414 {
01415 string nomGMcourant = NOMS_GROUPES_MAILLES[ETIQFAM[ifam][ign]];
01416
01417
01418 if (ign == 0)
01419 {
01420
01421 strcpy(gro, string2char(nomGMcourant));
01422 for (int jg = nomGMcourant.size(); jg < MED_LNAME_SIZE; jg++)
01423 gro[jg] = ' ';
01424 gro[MED_LNAME_SIZE] = '\0';
01425 }
01426 else
01427 {
01428 strcat(gro, string2char(nomGMcourant));
01429 for (int jg = nomGMcourant.size(); jg < MED_LNAME_SIZE; jg++)
01430 gro[cptGM * MED_LNAME_SIZE + jg] = ' ';
01431 gro[(cptGM + 1) * MED_LNAME_SIZE] = '\0';
01432 }
01433 cptGM++;
01434 }
01435
01436
01437 if (MEDfamilyCr(fid, maa, nomfam, numfam, 1, gro) < 0)
01438 ERREUR("Error MEDfamilyCr");
01439 }
01440
01441 }
01442
01443
01444
01445
01446
01447
01448 med_bool inomTYPE = MED_FALSE;
01449 med_bool inumTYPE = MED_FALSE;
01450
01451 med_geometry_type MGE;
01452
01453 for (int itm = (int) POI1; itm <= (int) HEXA20; itm++)
01454 {
01455 TYPE_MAILLE tm = (TYPE_MAILLE) itm;
01456 if (EFFECTIFS_TYPES[tm])
01457 {
01458 nTYPE = EFFECTIFS_TYPES[tm];
01459 tTYPE = Nnoeuds(tm);
01460 MGE = InstanceMGE(tm);
01461 stype = TM2string(tm);
01462
01463
01464
01465
01466
01467 char *nomTYPE = (char*)"";
01468
01469
01470
01471
01472
01473
01474
01475
01476
01477
01478
01479
01480
01481
01482
01483
01484
01485
01486
01487
01488
01489 med_int *numTYPE = NULL;
01490
01491 med_int *famTYPE = (med_int*) malloc(sizeof(med_int) * nTYPE);
01492
01493
01494
01495
01496
01497
01498 if (nGroupesMailles)
01499 {
01500
01501 for (int nl = 0; nl < nTYPE; nl++)
01502 {
01503
01504 vector<int> v = ETIQUETTES_M[tm][nl];
01505 string sv = (string) "";
01506 for (unsigned int j = 0; j < v.size(); j++)
01507 sv += int2string(v[j]);
01508
01509 *(famTYPE + nl) = (med_int) NUMFAMETIQ[sv];
01510 }
01511 }
01512 else
01513 for (int nl = 0; nl < nTYPE; nl++)
01514 *(famTYPE + nl) = (med_int) 0;
01515
01516
01517 conversionCNX(CNX[tm], tm, nTYPE);
01518
01519
01520
01521
01522
01523
01524
01525
01526
01527
01528 if (MEDmeshElementWr(fid, maa, MED_NO_DT, MED_NO_IT, MED_UNDEF_DT, MED_CELL, MGE, MED_NODAL,
01529 MED_FULL_INTERLACE, nTYPE, CNX[tm], inomTYPE, nomTYPE, inumTYPE, numTYPE, MED_FALSE,
01530 famTYPE) < 0)
01531 {
01532 ERREUR("Error MEDmeshElementWr");
01533 cout << "Error MEDmeshElementWr, type " << stype << endl;
01534 }
01535 if (MEDmeshEntityFamilyNumberWr(fid, maa, MED_NO_DT, MED_NO_IT,
01536 MED_CELL, MGE, nTYPE, famTYPE) < 0)
01537 {
01538 ERREUR("Error MEDmeshEntityFamilyNumberWr");
01539 cout << "Error MEDmeshEntityFamilyNumberWr, type " << stype << endl;
01540 }
01541
01542
01543
01544 free(famTYPE);
01545
01546
01547 }
01548 }
01549
01550
01551
01552
01553
01554 if (MEDfileClose(fid) < 0)
01555 {
01556 ERREUR("Error on close MED file\n");
01557 cout << "Error on close MED file" << endl;
01558 }
01559
01560
01561 }
01562
01563
01564 int Maillage::NGLOBAL(TYPE_MAILLE typeMaille, int nlocal)
01565 {
01566
01567 int cpt = 1 + nlocal;
01568 for (int itm = (int) POI1; itm < (int) typeMaille; itm++)
01569 {
01570 TYPE_MAILLE tm = (TYPE_MAILLE) itm;
01571 cpt += EFFECTIFS_TYPES[tm];
01572 }
01573 return cpt;
01574 }
01575
01576 TYPE_MAILLE Maillage::TYPE(int nglobal)
01577 {
01578
01579 TYPE_MAILLE resultat;
01580 int cpt = 0;
01581 for (int itm = (int) POI1; itm <= (int) HEXA20; itm++)
01582 {
01583 TYPE_MAILLE tm = (TYPE_MAILLE) itm;
01584 cpt += EFFECTIFS_TYPES[tm];
01585 if (nglobal <= cpt)
01586 {
01587 resultat = tm;
01588 break;
01589 }
01590 }
01591 return resultat;
01592 }
01593
01594 int Maillage::NLOCAL(int nglobal, TYPE_MAILLE tm)
01595 {
01596
01597 int nPOI1 = EFFECTIFS_TYPES[POI1];
01598 int nSEG2 = EFFECTIFS_TYPES[SEG2];
01599 int nSEG3 = EFFECTIFS_TYPES[SEG3];
01600 int nTRIA3 = EFFECTIFS_TYPES[TRIA3];
01601 int nTRIA6 = EFFECTIFS_TYPES[TRIA6];
01602 int nQUAD4 = EFFECTIFS_TYPES[QUAD4];
01603 int nQUAD8 = EFFECTIFS_TYPES[QUAD8];
01604 int nTETRA4 = EFFECTIFS_TYPES[TETRA4];
01605 int nTETRA10 = EFFECTIFS_TYPES[TETRA10];
01606 int nPYRAM5 = EFFECTIFS_TYPES[PYRAM5];
01607 int nPYRAM13 = EFFECTIFS_TYPES[PYRAM13];
01608 int nPENTA6 = EFFECTIFS_TYPES[PENTA6];
01609 int nPENTA15 = EFFECTIFS_TYPES[PENTA15];
01610 int nHEXA8 = EFFECTIFS_TYPES[HEXA8];
01611 int nHEXA20 = EFFECTIFS_TYPES[HEXA20];
01612
01613 if (nglobal <= nPOI1)
01614 {
01615 return nglobal - 1;
01616 }
01617 else if (nglobal <= nPOI1 + nSEG2)
01618 {
01619 return nglobal - nPOI1 - 1;
01620 }
01621 else if (nglobal <= nPOI1 + nSEG2 + nSEG3)
01622 {
01623 return nglobal - nPOI1 - nSEG2 - 1;
01624 }
01625 else if (nglobal <= nPOI1 + nSEG2 + nSEG3 + nTRIA3)
01626 {
01627 return nglobal - nPOI1 - nSEG2 - nSEG3 - 1;
01628 }
01629 else if (nglobal <= nPOI1 + nSEG2 + nSEG3 + nTRIA3 + nTRIA6)
01630 {
01631 return nglobal - nPOI1 - nSEG2 - nSEG3 - nTRIA3 - 1;
01632 }
01633 else if (nglobal <= nPOI1 + nSEG2 + nSEG3 + nTRIA3 + nTRIA6 + nQUAD4)
01634 {
01635 return nglobal - nPOI1 - nSEG2 - nSEG3 - nTRIA3 - nTRIA6 - 1;
01636 }
01637 else if (nglobal <= nPOI1 + nSEG2 + nSEG3 + nTRIA3 + nTRIA6 + nQUAD4 + nQUAD8)
01638 {
01639 return nglobal - nPOI1 - nSEG2 - nSEG3 - nTRIA3 - nTRIA6 - nQUAD4 - 1;
01640 }
01641 else if (nglobal <= nPOI1 + nSEG2 + nSEG3 + nTRIA3 + nTRIA6 + nQUAD4 + nQUAD8 + nTETRA4)
01642 {
01643 return nglobal - nPOI1 - nSEG2 - nSEG3 - nTRIA3 - nTRIA6 - nQUAD4 - nQUAD8 - 1;
01644 }
01645 else if (nglobal <= nPOI1 + nSEG2 + nSEG3 + nTRIA3 + nTRIA6 + nQUAD4 + nQUAD8 + nTETRA4 + nTETRA10)
01646 {
01647 return nglobal - nPOI1 - nSEG2 - nSEG3 - nTRIA3 - nTRIA6 - nQUAD4 - nQUAD8 - nTETRA4 - 1;
01648 }
01649 else if (nglobal <= nPOI1 + nSEG2 + nSEG3 + nTRIA3 + nTRIA6 + nQUAD4 + nQUAD8 + nTETRA4 + nTETRA10 + nPYRAM5)
01650 {
01651 return nglobal - nPOI1 - nSEG2 - nSEG3 - nTRIA3 - nTRIA6 - nQUAD4 - nQUAD8 - nTETRA4 - nTETRA10 - 1;
01652 }
01653 else if (nglobal <= nPOI1 + nSEG2 + nSEG3 + nTRIA3 + nTRIA6 + nQUAD4 + nQUAD8 + nTETRA4 + nTETRA10 + nPYRAM5
01654 + nPYRAM13)
01655 {
01656 return nglobal - nPOI1 - nSEG2 - nSEG3 - nTRIA3 - nTRIA6 - nQUAD4 - nQUAD8 - nTETRA4 - nTETRA10 - nPYRAM5 - 1;
01657 }
01658 else if (nglobal <= nPOI1 + nSEG2 + nSEG3 + nTRIA3 + nTRIA6 + nQUAD4 + nQUAD8 + nTETRA4 + nTETRA10 + nPYRAM5
01659 + nPYRAM13 + nPENTA6)
01660 {
01661 return nglobal - nPOI1 - nSEG2 - nSEG3 - nTRIA3 - nTRIA6 - nQUAD4 - nQUAD8 - nTETRA4 - nTETRA10 - nPYRAM5
01662 - nPYRAM13 - 1;
01663 }
01664 else if (nglobal <= nPOI1 + nSEG2 + nSEG3 + nTRIA3 + nTRIA6 + nQUAD4 + nQUAD8 + nTETRA4 + nTETRA10 + nPYRAM5
01665 + nPYRAM13 + nPENTA6 + nPENTA15)
01666 {
01667 return nglobal - nPOI1 - nSEG2 - nSEG3 - nTRIA3 - nTRIA6 - nQUAD4 - nQUAD8 - nTETRA4 - nTETRA10 - nPYRAM5
01668 - nPYRAM13 - nPENTA6 - 1;
01669 }
01670 else if (nglobal <= nPOI1 + nSEG2 + nSEG3 + nTRIA3 + nTRIA6 + nQUAD4 + nQUAD8 + nTETRA4 + nTETRA10 + nPYRAM5
01671 + nPYRAM13 + nPENTA6 + nPENTA15 + nHEXA8)
01672 {
01673 return nglobal - nPOI1 - nSEG2 - nSEG3 - nTRIA3 - nTRIA6 - nQUAD4 - nQUAD8 - nTETRA4 - nTETRA10 - nPYRAM5
01674 - nPYRAM13 - nPENTA6 - nPENTA15 - 1;
01675 }
01676 else if (nglobal <= nPOI1 + nSEG2 + nSEG3 + nTRIA3 + nTRIA6 + nQUAD4 + nQUAD8 + nTETRA4 + nTETRA10 + nPYRAM5
01677 + nPYRAM13 + nPENTA6 + nPENTA15 + nHEXA8 + nHEXA20)
01678 {
01679 return nglobal - nPOI1 - nSEG2 - nSEG3 - nTRIA3 - nTRIA6 - nQUAD4 - nQUAD8 - nTETRA4 - nTETRA10 - nPYRAM5
01680 - nPYRAM13 - nPENTA6 - nPENTA15 - nHEXA8 - 1;
01681 }
01682 else
01683 ERREUR("method NLOCAL: unknown type");
01684 return 0;
01685 }
01686
01696 void Maillage::eliminationMailles(TYPE_MAILLE tm, vector<int> listeMaillesSuppr)
01697 {
01698 map<int, int> TABLE_NL;
01699
01700 cout << "Method eliminationMailles, listeMaillesSuppr.size()=" << listeMaillesSuppr.size() << endl;
01701
01702
01703
01704 int* CNX2;
01705 int nNoeudsType = Nnoeuds(tm);
01706 int tailleCNX2 = nNoeudsType * (EFFECTIFS_TYPES[tm] - listeMaillesSuppr.size());
01707 CNX2 = (int*) malloc(sizeof(int) * tailleCNX2);
01708
01709 int isuppr = 0;
01710 int ih2 = 0;
01711 for (int ih1 = 0; ih1 < EFFECTIFS_TYPES[tm]; ih1++)
01712 {
01713 if (listeMaillesSuppr[isuppr] != ih1)
01714 {
01715 for (int jh1 = 0; jh1 < nNoeudsType; jh1++)
01716 *(CNX2 + nNoeudsType * ih2 + jh1) = *(CNX[tm] + nNoeudsType * ih1 + jh1);
01717 ih2++;
01718 }
01719 else
01720 isuppr++;
01721 }
01722 free(CNX[tm]);
01723 CNX[tm] = CNX2;
01724
01725
01726 unsigned int offset = 0;
01727 for (int i = 0; i < EFFECTIFS_TYPES[tm]; i++)
01728 {
01729 if (offset < listeMaillesSuppr.size())
01730 {
01731 if (i < listeMaillesSuppr[offset])
01732 TABLE_NL[i] = i - offset;
01733 else if (i == listeMaillesSuppr[offset])
01734 {
01735 TABLE_NL[i] = -1;
01736 offset++;
01737 }
01738 }
01739 else
01740 TABLE_NL[i] = i - offset;
01741 }
01742
01743
01744 if (offset != listeMaillesSuppr.size())
01745 {
01746 ERREUR("Incoherent offset, method eliminationMailles");
01747 exit(0);
01748 }
01749
01750
01751 for (map<string, map<TYPE_MAILLE, vector<int> > >::iterator I = GM.begin(); I != GM.end(); I++)
01752 {
01753 string nomGM = I->first;
01754
01755 if (GM[nomGM][tm].size())
01756 {
01757
01758 vector<int> mailles = GM[nomGM][tm];
01759 vector<int> mailles2;
01760 unsigned int cptMailles = 0;
01761 for (unsigned int i = 0; i < mailles.size(); i++)
01762 {
01763 int nl2 = TABLE_NL[mailles[i]];
01764 if (nl2 != -1)
01765 {
01766 mailles2.push_back(nl2);
01767 cptMailles++;
01768 }
01769 }
01770
01771 GM[nomGM][tm].clear();
01772 mailles2.resize(cptMailles);
01773 GM[nomGM][tm] = mailles2;
01774
01775 }
01776 }
01777
01778
01779
01780 EFFECTIFS_TYPES[tm] = EFFECTIFS_TYPES[tm] - listeMaillesSuppr.size();
01781 nombreMaillesMaillage = nombreMaillesMaillage - listeMaillesSuppr.size();
01782
01783 TABLE_NL.clear();
01784 }
01785