Changeset 3267


Ignore:
Timestamp:
03/12/10 07:27:15 (15 years ago)
Author:
Mathieu Morlighem
Message:

minor

Location:
issm/trunk/src/c/Bamgx
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk/src/c/Bamgx/Bamgx.cpp

    r3263 r3267  
    113113                if (verbosity>0) printf("Anisotropic mesh adaptation\n");
    114114                if (verbosity>1) printf("   Processing initial mesh and geometry...\n");
    115                 Triangles BTh(bamgmesh_in,bamgopts);
     115                Triangles BTh(bamggeom_in,bamgmesh_in,bamgopts);
    116116                hmin = Max(hmin,BTh.MinimalHmin());
    117117                hmax = Min(hmax,BTh.MaximalHmax());
  • issm/trunk/src/c/Bamgx/objects/BamgObjects.h

    r3263 r3267  
    22#define _BAMGOBEJECTS_H_
    33
    4 /*Bamg objects (Must be compiled in this order!!*/
     4/*Bamg objects (Must be compiled in this order!!)*/
    55#include "./Metric.h"
    66#include "./DoubleAndInt.h"
     
    2222#include "./Triangles.h"
    2323#include "./Geometry.h"
     24#include "./QuadTree.h"
     25#include "./SetOfE4.h"
    2426
    2527#endif
  • issm/trunk/src/c/Bamgx/objects/QuadTree.cpp

    r3263 r3267  
    220220                register long n0;
    221221                register QuadTreeBox* b;
    222                 IntQuad  h=MaxISize,h0;
    223                 IntQuad  hb=MaxISize;
     222                long     h=MaxISize,h0;
     223                long     hb=MaxISize;
    224224                Icoor1   i0=0,j0=0;
    225225                //iplus= i projected in [0,MaxISize-1] (example: if i<0, i=0)
     
    356356                int l; // level
    357357                QuadTreeBox * b;
    358                 IntQuad  h=MaxISize,h0;
    359                 IntQuad hb =  MaxISize;
     358                long     h =MaxISize,h0;
     359                long     hb=MaxISize;
    360360                Icoor1  i0=0,j0=0;
    361361                Icoor1  iplus( i<MaxISize?(i<0?0:i):MaxISize-1);
  • issm/trunk/src/c/Bamgx/objects/QuadTree.h

    r3246 r3267  
    1010namespace bamg {
    1111
    12         typedef long IntQuad;
    13 
    14         const int MaxDeep = 30;
    15         const IntQuad MaxISize = ( 1L << MaxDeep);
     12        const int  MaxDeep = 30;
     13        const long MaxISize = ( 1L << MaxDeep);
    1614
    1715        class Triangles;
  • issm/trunk/src/c/Bamgx/objects/Triangles.cpp

    r3263 r3267  
    33#include <cmath>
    44#include <ctime>
     5#include <assert.h>
    56
    67#include "BamgObjects.h"
    78#include "../shared/shared.h"
    8 #include "QuadTree.h"
    9 #include "SetOfE4.h"
    109
    1110#undef __FUNCT__
     
    1817
    1918        /*Constructors/Destructors*/
    20         /*FUNCTION Triangles::Triangles(BamgMesh* bamgmesh, BamgOpts* bamgopts){{{1*/
    21         Triangles::Triangles(BamgMesh* bamgmesh, BamgOpts* bamgopts):Gh(*(new Geometry())),BTh(*this){
     19        /*FUNCTION Triangles::Triangles(BamgGeom* bamggeom,BamgMesh* bamgmesh, BamgOpts* bamgopts){{{1*/
     20        Triangles::Triangles(BamgGeom* bamggeom,BamgMesh* bamgmesh, BamgOpts* bamgopts):Gh(*(new Geometry())),BTh(*this){
     21
     22                /*Initialize fields*/
    2223                PreInit(0);
     24
     25                /*Read background mesh*/
    2326                ReadMesh(bamgmesh,bamgopts);
     27
     28                /*Read Geometry*/
     29                if(bamggeom->NumEdges==0) {
     30                        /*Recreate geometry if needed*/
     31                        printf("WARNING: mesh present but no geometry found. Reconstructing...\n");
     32                        BuildGeometryFromMesh(bamgopts);
     33                        Gh.AfterRead();
     34                }
     35                else{
     36                        Gh.ReadGeometry(bamggeom,bamgopts);
     37                        Gh.AfterRead();
     38                }
     39
     40                /*Set integer coordinates*/
    2441                SetIntCoor();
    25                 GenerateMeshProperties();
     42
     43                /*Fill holes and generate mesh properties*/
     44                ReconstructExistingMesh();
    2645        }
    2746        /*}}}1*/
     
    3251                ReadMesh(index,x,y,nods,nels);
    3352                SetIntCoor();
    34                 GenerateMeshProperties();
     53                ReconstructExistingMesh();
    3554        }
    3655        /*}}}1*/
     
    127146                  Gh.AfterRead();
    128147                  SetIntCoor();
    129                   GenerateMeshProperties();
     148                  ReconstructExistingMesh();
    130149
    131150                  if (!NbSubDomains){
     
    523542                }
    524543
    525                 /*Recreate geometry if needed*/
    526                 if(1!=0) {
    527                         printf("WARNING: mesh present but no geometry found. Reconstructing...\n");
    528                         /*Recreate geometry: */
    529                         BuildGeometryFromMesh(bamgopts);
    530                         Gh.AfterRead();
    531                 }
    532544        }
    533545        /*}}}1*/
     
    26042616        }
    26052617        /*}}}1*/
    2606         /*FUNCTION Triangles::GenerateMeshProperties{{{1*/
    2607         void Triangles::GenerateMeshProperties() {
     2618        /*FUNCTION Triangles::ReconstructExistingMesh{{{1*/
     2619        void Triangles::ReconstructExistingMesh() {
    26082620                /*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/FillHoleInMesh)*/
     2621
     2622                /*This routine reconstruct an existing mesh to make it CONVEX:
     2623                 * -all the holes are filled
     2624                 * -concave boundaries are filled
     2625                 * A convex mesh is required for a lot of operations. This is why every mesh
     2626                 * goes through this process.
     2627                 * This routine also generates mesh properties such as adjencies,...
     2628                 */
    26092629
    26102630                int verbosity=0;
     
    26142634                // find extrema coordinates of vertices pmin,pmax
    26152635                long i;
    2616                 if(verbosity>2) printf("      Filling holes in mesh of %i vertices\n",nbv);
     2636                if(verbosity>2) printf("      Completing Triangles structure for a mesh of %i vertices\n",nbv);
    26172637
    26182638                //initialize ordre
    2619                 if (!ordre){
    2620                         throw ErrorException(__FUNCT__,exprintf("!ordre"));
    2621                 }
     2639                assert(ordre);
    26222640                for (i=0;i<nbv;i++) ordre[i]=0;
    26232641
     
    26512669                                }
    26522670                                else if(st[k]>=0) {
    2653                                         if (triangles[i].TriangleAdj(j) || triangles[st[k] / 3].TriangleAdj((int) (st[k]%3))){
    2654                                                 throw ErrorException(__FUNCT__,exprintf("(triangles[i].TriangleAdj(j) || triangles[st[k] / 3].TriangleAdj((int) (st[k]%3)))"));
    2655                                         }
     2671                                        assert(!triangles[i].TriangleAdj(j));
     2672                                        assert(!triangles[st[k]/3].TriangleAdj((int) (st[k]%3)));
    26562673
    26572674                                        triangles[i].SetAdj2(j,triangles + st[k] / 3,(int) (st[k]%3));
     
    26812698                for (i=0;i<edge4->nb();i++){
    26822699                        if (st[i] >=0){ // edge alone
    2683                                 if (i < nbe) {
     2700                                if (i<nbe){
    26842701                                        long i0=edge4->i(i);
    26852702                                        ordre[i0] = vertices+i0;
     
    26892706                                else {
    26902707                                        k=k+1;
    2691                                         if (k <20) {
    2692                                                 throw ErrorException(__FUNCT__,exprintf("Lost boundary edges %i : %i %i",i,edge4->i(i),edge4->j(i)));
     2708                                        if (k<10) {
     2709                                                //print only 10 edges
     2710                                                printf("Lost boundary edges %i : %i %i\n",i,edge4->i(i),edge4->j(i));
    26932711                                        }
    2694                                 }
    2695                         }
    2696                 }
    2697                 if(k != 0) {
    2698                         throw ErrorException(__FUNCT__,exprintf("%i boundary edges  are not defined as edges",k));
     2712                                        else if (k==10){
     2713                                                printf("Other lost boundary edges not shown...\n");
     2714                                        }
     2715                                }
     2716                        }
     2717                }
     2718                if(k) {
     2719                        throw ErrorException(__FUNCT__,exprintf("%i boundary edges (from the geometry) are not defined as mesh edges",k));
    26992720                }
    27002721
     
    27052726                        vertices[i].vint=0;
    27062727                        if (ordre[i]){
    2707                                 ordre[nbvb++] = ordre[i];
    2708                         }
    2709                 }
    2710 
    2711                 Triangle* savetriangles= triangles;
     2728                                ordre[nbvb++]=ordre[i];
     2729                        }
     2730                }
     2731
     2732                Triangle* savetriangles=triangles;
    27122733                long savenbt=nbt;
    27132734                long savenbtx=nbtx;
    2714                 SubDomain * savesubdomains = subdomains;
    2715                 subdomains = 0;
     2735                SubDomain* savesubdomains=subdomains;
     2736                subdomains=0;
    27162737
    27172738                long  Nbtriafillhole = 2*nbvb;
     
    27232744
    27242745                for (i=2 ; det( ordre[0]->i, ordre[1]->i, ordre[i]->i ) == 0;)
    2725                  if  ( ++i >= nbvb) {
    2726                          throw ErrorException(__FUNCT__,exprintf("GenerateMeshProperties: All the vertices are aligned"));
     2746                 if  (++i>=nbvb) {
     2747                         throw ErrorException(__FUNCT__,exprintf("ReconstructExistingMesh: All the vertices are aligned"));
    27272748                 }
    2728                 Exchange( ordre[2], ordre[i]);
     2749                Exchange(ordre[2], ordre[i]);
    27292750
    27302751                Vertex *  v0=ordre[0], *v1=ordre[1];
    27312752
    2732 
    2733                 triangles[0](0) = 0; // sommet pour infini
     2753                triangles[0](0) = NULL; // Infinite vertex
    27342754                triangles[0](1) = v0;
    27352755                triangles[0](2) = v1;
    27362756
    2737                 triangles[1](0) = 0;// sommet pour infini
     2757                triangles[1](0) = NULL;// Infinite vertex
    27382758                triangles[1](2) = v0;
    27392759                triangles[1](1) = v1;
     
    27452765                triangles[0].SetAdj2(e2, &triangles[1] ,e1);
    27462766
    2747                 triangles[0].det = -1;  // faux triangles
    2748                 triangles[1].det = -1;  // faux triangles
     2767                triangles[0].det = -1;  // boundary triangles
     2768                triangles[1].det = -1;  // boundary triangles
    27492769
    27502770                triangles[0].SetTriangleContainingTheVertex();
     
    28812901                SetVertexFieldOn();
    28822902
    2883                 for (i=0;i<nbe;i++)
    2884                  if(edges[i].onGeometry)
    2885                   for(int j=0;j<2;j++)
    2886                         if (!edges[i].adj[j])
    2887                          if(!edges[i][j].onGeometry->IsRequiredVertex()) {
    2888                                  throw ErrorException(__FUNCT__,exprintf("adj and vertex required esge(?)"));
    2889                          }
     2903                /*Check requirements consistency*/
     2904                for (i=0;i<nbe;i++){
     2905                        /*If the current mesh edge is on Geometry*/
     2906                        if(edges[i].onGeometry){
     2907                                for(int j=0;j<2;j++){
     2908                                        if (!edges[i].adj[j]){
     2909                                                if(!edges[i][j].onGeometry->IsRequiredVertex()) {
     2910                                                        printf("Error: adj and vertex requires edges [%i %i]=%i on = %i\n",i,j,Number(edges[i][j]),Gh.Number(edges[i].onGeometry));
     2911                                                        if (edges[i][j].onGeometry->OnGeomVertex())
     2912                                                         printf(" Vertex %i\n",Gh.Number(edges[i][j].onGeometry->gv));
     2913                                                        else if (edges[i][j].onGeometry->OnGeomEdge())
     2914                                                         printf(" Edges %i \n",Gh.Number(edges[i][j].onGeometry->ge));
     2915                                                        else
     2916                                                         printf(" = %p\n",edges[i][j].onGeometry);
     2917                                                        throw ErrorException(__FUNCT__,exprintf("See above (might be cryptic...)"));
     2918                                                }
     2919                                        }
     2920                                }
     2921                        }
     2922                }
    28902923        }
    28912924        /*}}}1*/
     
    52715304                //  ReMakeTriangleContainingTheVertex();
    52725305
    5273                 GenerateMeshProperties();
     5306                ReconstructExistingMesh();
    52745307
    52755308                if (verbosity>2){
  • issm/trunk/src/c/Bamgx/objects/Triangles.h

    r3263 r3267  
    6868
    6969                        //Constructors/Destructors
    70                         Triangles(BamgMesh* bamgmesh,BamgOpts* bamgopts);
     70                        Triangles(BamgGeom* bamggeom,BamgMesh* bamgmesh,BamgOpts* bamgopts);
    7171                        Triangles(double* index,double* x,double* y,int nods,int nels);
    7272                        Triangles(Triangles &,Geometry * pGh=0,Triangles* pBTh=0,long nbvxx=0 ); //copy operator
     
    145145                        int  UnCrack();
    146146                        void BuildGeometryFromMesh(BamgOpts* bamgopts=NULL);
    147                         void GenerateMeshProperties() ;
     147                        void ReconstructExistingMesh();
    148148                        int  CrackMesh();
    149149
  • issm/trunk/src/c/Bamgx/objects/VertexOnGeom.h

    r3263 r3267  
    2424                        double abscisse; 
    2525                        union{
    26                                 GeometricalVertex * gv; // if abscisse <0;
    27                                 GeometricalEdge * ge; // if abscisse in [0..1]
     26                                GeometricalVertex* gv; // if abscisse <0;
     27                                GeometricalEdge*   ge; // if abscisse in [0..1]
    2828                        };
    2929
     
    4646
    4747                        //Inline methods
    48                         //inline void Set(const Triangles &,long,Triangles &);
    4948                        void Set(const VertexOnGeom&,const Triangles &,Triangles &); 
    5049
Note: See TracChangeset for help on using the changeset viewer.