From 6996325ebbf2f2b77365a64e8b07cea44a628f8c Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Sun, 16 Oct 2005 03:15:31 +0000 Subject: [PATCH] add missing copyright headers --- Mesh/BDS.cpp | 21 ++++ Mesh/BDS.h | 19 ++++ Mesh/PartitionMesh.cpp | 222 ++++++++++++++++++++++------------------- Mesh/Read_Mesh.cpp | 9 +- 4 files changed, 162 insertions(+), 109 deletions(-) diff --git a/Mesh/BDS.cpp b/Mesh/BDS.cpp index cfb9f9f288..e533b448ac 100644 --- a/Mesh/BDS.cpp +++ b/Mesh/BDS.cpp @@ -1,3 +1,24 @@ +// $Id: BDS.cpp,v 1.36 2005-10-16 03:15:31 geuzaine Exp $ +// +// Copyright (C) 1997-2005 C. Geuzaine, J.-F. Remacle +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +// USA. +// +// Please report all bugs and problems to "gmsh@geuz.org". + #include <math.h> #include <stdio.h> #include "Numeric.h" diff --git a/Mesh/BDS.h b/Mesh/BDS.h index 8ef0384566..a9e61ea9b9 100644 --- a/Mesh/BDS.h +++ b/Mesh/BDS.h @@ -1,3 +1,22 @@ +// Copyright (C) 1997-2005 C. Geuzaine, J.-F. Remacle +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +// USA. +// +// Please report all bugs and problems to <gmsh@geuz.org>. + // This is a 2D version of the Bidirectional Data Structure (BDS) // of shephard and beall // points may know the normals to the surface they are classified on diff --git a/Mesh/PartitionMesh.cpp b/Mesh/PartitionMesh.cpp index 29a658cd3b..c676dab579 100644 --- a/Mesh/PartitionMesh.cpp +++ b/Mesh/PartitionMesh.cpp @@ -1,3 +1,24 @@ +// $Id: PartitionMesh.cpp,v 1.3 2005-10-16 03:15:31 geuzaine Exp $ +// +// Copyright (C) 1997-2005 C. Geuzaine, J.-F. Remacle +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +// USA. +// +// Please report all bugs and problems to "gmsh@geuz.org". + #include "Gmsh.h" #include "Numeric.h" #include "Mesh.h" @@ -17,10 +38,10 @@ extern "C" #include "metis.h" } #endif -extern void Mesh_To_BDS(Mesh *m); -extern void BDS_To_Mesh_2(Mesh *m); -extern void BDS_To_Mesh(Mesh *m); +extern void Mesh_To_BDS(Mesh * m); +extern void BDS_To_Mesh_2(Mesh * m); +extern void BDS_To_Mesh(Mesh * m); void DeleteMesh(Mesh * M) { @@ -33,7 +54,7 @@ void DeleteMesh(Mesh * M) c->Simplexes = Tree_Create(sizeof(SimplexBase *), compareSimplex); } List_T *Surfaces = Tree2List(M->Surfaces); - for(int i = 0; i < List_Nbr(Surfaces); i++){ + for(int i = 0; i < List_Nbr(Surfaces); i++) { Surface *s; List_Read(Surfaces, i, &s); Tree_Action(s->Simplexes, Free_SimplexBase); @@ -41,9 +62,9 @@ void DeleteMesh(Mesh * M) s->Simplexes = Tree_Create(sizeof(SimplexBase *), compareSimplex); } List_Delete(Surfaces); - + List_T *Volumes = Tree2List(M->Volumes); - for(int i = 0; i < List_Nbr(Volumes); i++){ + for(int i = 0; i < List_Nbr(Volumes); i++) { Volume *v; List_Read(Volumes, i, &v); Tree_Action(v->Simplexes, Free_SimplexBase); @@ -53,143 +74,136 @@ void DeleteMesh(Mesh * M) List_Delete(Volumes); } - -void PartitionMesh ( Mesh *M , int NP) +void PartitionMesh(Mesh * M, int NP) { - - printf("moving the mesh to BDS\n"); - Mesh_To_BDS (M); + Msg(INFO, "moving the mesh to BDS"); + Mesh_To_BDS(M); BDS_Mesh *m = M->bds; - printf("partitioning\n"); - PartitionMesh (m,NP); - printf("Moving back to the old data str\n"); - DeleteMesh (M);// BDS_To_Mesh(M); - M->bds_mesh = new BDS_Mesh (*M->bds); + Msg(INFO, "Partitioning"); + PartitionMesh(m, NP); + Msg(INFO, "Moving back to the old data str"); + DeleteMesh(M); + //BDS_To_Mesh(M); + M->bds_mesh = new BDS_Mesh(*M->bds); BDS_To_Mesh_2(M); delete M->bds; - // delete M->bds_mesh; + //delete M->bds_mesh; M->bds = 0; //M->bds_mesh = 0; SetBoundingBox(); } -void PartitionMesh ( BDS_Mesh *m , int NP) +void PartitionMesh(BDS_Mesh * m, int NP) { - #ifdef HAVE_METIS - // NN = number of nodes of the graph - int dim = (m->tets.size() == 0)?2:3; - int NN = (dim == 2)? m->triangles.size() : m->tets.size() ; + //NN = number of nodes of the graph + int dim = (m->tets.size() == 0) ? 2 : 3; + int NN = (dim == 2) ? m->triangles.size() : m->tets.size(); + + Msg(INFO, "%d nodes in the graph", NN); - printf ("%d nodes in the graph\n",NN); - int *partitionVector = new int[NN]; - int *xadj = new int[NN+2]; + int *xadj = new int[NN + 2]; int totCount = 0; - std::list<BDS_Triangle*>::iterator it2 = m->triangles.begin(); - std::list<BDS_Tet*>::iterator it3 = m->tets.begin(); +std: : list < BDS_Triangle * >: :iterator it2 = m->triangles.begin(); +std: : list < BDS_Tet * >: :iterator it3 = m->tets.begin(); xadj[0] = 0; - for(int i=0;i<NN;i++) - { - int nbAdj = 0; - if (dim == 2) - { - BDS_Triangle *t = *it2; - t->partition = i; - ++it2; - nbAdj = (t->e1->numfaces() + t->e2->numfaces() + t->e3->numfaces() - 3); - totCount += nbAdj; - } - else if (dim == 3) - { - BDS_Tet *t = *it3; - t->partition = i; - ++it3; - nbAdj =(t->f1->numtets() + t->f2->numtets() + t->f3->numtets() + t->f4->numtets() - 4); - totCount += nbAdj; - } - xadj[i+1] = xadj[i] + nbAdj; + for(int i = 0; i < NN; i++) { + int nbAdj = 0; + if(dim == 2) { + BDS_Triangle *t = *it2; + t->partition = i; + ++it2; + nbAdj = (t->e1->numfaces() + t->e2->numfaces() + t->e3->numfaces() - 3); + totCount += nbAdj; } + else if(dim == 3) { + BDS_Tet *t = *it3; + t->partition = i; + ++it3; + nbAdj = (t->f1->numtets() + t->f2->numtets() + + t->f3->numtets() + t->f4->numtets() - 4); + totCount += nbAdj; + } + xadj[i + 1] = xadj[i] + nbAdj; + } - printf ("Tot Count %d \n",totCount); + Msg(INFO, "Tot Count %d", totCount); it2 = m->triangles.begin(); it3 = m->tets.begin(); - int *adjncy = new int[totCount+1]; + int *adjncy = new int[totCount + 1]; int count = 0; - for(int i=0;i<NN;i++) - { - if (dim == 2) - { - BDS_Triangle *t = *it2; - for (int j=0;j<t->e1->numfaces();j++) - { - BDS_Triangle *f = t->e1->faces(j); - if (f != t) adjncy[count++] = f->partition; - } - for (int j=0;j<t->e2->numfaces();j++) - { - BDS_Triangle *f = t->e2->faces(j); - if (f != t) adjncy[count++] = f->partition; - } - for (int j=0;j<t->e3->numfaces();j++) - { - BDS_Triangle *f = t->e3->faces(j); - if (f != t) adjncy[count++] = f->partition; - } - ++it2; - } - else if (dim == 3) - { - BDS_Tet *t = *it3; - BDS_Tet *o = t->f1->opposite_tet (t); - if (o) adjncy[count++] = o->partition; - o = t->f2->opposite_tet (t); - if (o) adjncy[count++] = o->partition; - o = t->f3->opposite_tet (t); - if (o) adjncy[count++] = o->partition; - o = t->f4->opposite_tet (t); - if (o) adjncy[count++] = o->partition; - ++it3; - } + for(int i = 0; i < NN; i++) { + if(dim == 2) { + BDS_Triangle *t = *it2; + for(int j = 0; j < t->e1->numfaces(); j++) { + BDS_Triangle *f = t->e1->faces(j); + if(f != t) + adjncy[count++] = f->partition; + } + for(int j = 0; j < t->e2->numfaces(); j++) { + BDS_Triangle *f = t->e2->faces(j); + if(f != t) + adjncy[count++] = f->partition; + } + for(int j = 0; j < t->e3->numfaces(); j++) { + BDS_Triangle *f = t->e3->faces(j); + if(f != t) + adjncy[count++] = f->partition; + } + ++it2; + } + else if(dim == 3) { + BDS_Tet *t = *it3; + BDS_Tet *o = t->f1->opposite_tet(t); + if(o) + adjncy[count++] = o->partition; + o = t->f2->opposite_tet(t); + if(o) + adjncy[count++] = o->partition; + o = t->f3->opposite_tet(t); + if(o) + adjncy[count++] = o->partition; + o = t->f4->opposite_tet(t); + if(o) + adjncy[count++] = o->partition; + ++it3; } + } int wgtflag = 0; int numflag = 0; int options[4]; options[0] = 0; int edgecut; - METIS_PartGraphRecursive(&NN,xadj,adjncy,0,0,&wgtflag, - &numflag,&NP,options,&edgecut, - partitionVector); - delete [] xadj; - delete [] adjncy; + METIS_PartGraphRecursive(&NN, xadj, adjncy, 0, 0, &wgtflag, + &numflag, &NP, options, &edgecut, partitionVector); + delete[]xadj; + delete[]adjncy; it2 = m->triangles.begin(); it3 = m->tets.begin(); - for(int i=0;i<NN;i++) - { - if (dim == 2) - { - BDS_Triangle *t = *it2; - t->partition = partitionVector[i]; - ++it2; - } - else if (dim == 3) - { - BDS_Tet *t = *it3; - t->partition = partitionVector[i]; - ++it3; - } + for(int i = 0; i < NN; i++) { + if(dim == 2) { + BDS_Triangle *t = *it2; + t->partition = partitionVector[i]; + ++it2; + } + else if(dim == 3) { + BDS_Tet *t = *it3; + t->partition = partitionVector[i]; + ++it3; } + } - delete [] partitionVector; + delete[]partitionVector; #endif } diff --git a/Mesh/Read_Mesh.cpp b/Mesh/Read_Mesh.cpp index e2178c2803..c2041c63eb 100644 --- a/Mesh/Read_Mesh.cpp +++ b/Mesh/Read_Mesh.cpp @@ -1,4 +1,4 @@ -// $Id: Read_Mesh.cpp,v 1.94 2005-09-07 14:36:45 remacle Exp $ +// $Id: Read_Mesh.cpp,v 1.95 2005-10-16 03:15:31 geuzaine Exp $ // // Copyright (C) 1997-2005 C. Geuzaine, J.-F. Remacle // @@ -908,7 +908,6 @@ void Read_Mesh_SMS(Mesh * m, FILE * in) } // Public Read_Mesh routine -extern void Mesh_To_BDS(Mesh *m); void Read_Mesh(Mesh * M, FILE * fp, char *filename, int type) { @@ -930,7 +929,7 @@ void Read_Mesh(Mesh * M, FILE * fp, char *filename, int type) Msg(INFO, "Read mesh file '%s'", filename); Msg(STATUS2N, "Read '%s'", filename); } - if (CTX.mesh.nbPartitions != 1) - PartitionMesh ( M , CTX.mesh.nbPartitions); - // Mesh_To_BDS(M); + + if(CTX.mesh.nbPartitions != 1) + PartitionMesh(M, CTX.mesh.nbPartitions); } -- GitLab