1 // ORIG-DATE:     Dec 2007
2 // -*- Mode : c++ -*-
3 //
4 // SUMMARY  :  Model  mesh 1d
5 // USAGE    : LGPL
6 // ORG      : LJLL Universite Pierre et Marie Curi, Paris,  FRANCE
7 // AUTHOR   : Frederic Hecht
8 // E-MAIL   : frederic.hecht@ann.jussieu.fr
9 //
10 
11 /*
12 
13  This file is part of Freefem++
14 
15  Freefem++ is free software; you can redistribute it and/or modify
16  it under the terms of the GNU Lesser General Public License as published by
17  the Free Software Foundation; either version 2.1 of the License, or
18  (at your option) any later version.
19 
20  Freefem++  is distributed in the hope that it will be useful,
21  but WITHOUT ANY WARRANTY; without even the implied warranty of
22  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23  GNU Lesser General Public License for more details.
24 
25  You should have received a copy of the GNU Lesser General Public License
26  along with Freefem++; if not, write to the Free Software
27  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
28 
29  Thank to the ARN ()  FF2A3 grant
30  ref:ANR-07-CIS7-002-01
31  */
32 #include <fstream>
33 #include <iostream>
34 #include "ufunction.hpp"
35 #include "error.hpp"
36 #include "RNM.hpp"
37 #include "libmesh5.h"
38 
39 #include "Mesh1dn.hpp"
40 
41    //long verbosity=1;
42 
43 namespace Fem2D {
44 
45   const R1 R1::KHat[2]={R1(0),R1(1)};
46   const R2 R2::KHat[3]={R2(0,0),R2(1,0),R2(0,1)};
47   const  R3 R3::KHat[4]={R3(0,0,0),R3(1,0,0),R3(0,1,0),R3(0,0,1)};
48 
49  // static const int  nvfaceTet[4][3]  = {{3,2,1}, {0,2,3},{ 3,1,0},{ 0,1,2}}  ;
50  // static const int  nvedgeTet[6][2] = { {0,1},{0,2},{0,3},{1,2},{1,3},{2,3} };
51 
52 //  static const int  nvfaceTria[1][3]  = { {0,1,2} };
53 //  static const int  nvedgeTria[3][2] = { {1,2},{2,0},{0,1}};
54 
55 //  static const int   nvfaceSeg[1][3]  = {{-1,-1,-1}};
56   static const int  nvedgeSeg[1][2] = { {0,1} };
57   static const int  nvadjSeg[2][1] = { {0},{1} };
58 
59   template<> const int (* const GenericElement<DataPoint1>::nvface)[3] = 0 ;
60   template<> const int (* const GenericElement<DataPoint1>::nvedge)[2] = 0 ;
61   template<> const int (* const GenericElement<DataPoint1>::nvadj)[1] = 0 ;
62 
63   template<> const int (* const GenericElement<DataSeg1>::nvface)[3] = 0 ;
64   template<> const int (* const GenericElement<DataSeg1>::nvedge)[2] = nvedgeSeg; //nvedgeTria ;
65   template<> const int (* const GenericElement<DataSeg1>::nvadj)[1] = nvadjSeg ;
66 
67   template<> const int  GenericElement<DataSeg1>::nitemdim[4] = {2,1,0,0 }  ;
68 
69   template<> int   GenericMesh<Seg1,BoundaryPoint1,Vertex1>::kfind=0;
70   template<> int   GenericMesh<Seg1,BoundaryPoint1,Vertex1>::kthrough=0;
71 
72   static const int onWhatIsVertex[2][3] = {  {1,0,0}, // sommet  0
73 					     {0,1,0}}; // sommet 1
74 
75 
76   template<>
77   const int (* const GenericElement<DataSeg1>::onWhatBorder)[3] = onWhatIsVertex ;
78 
79 
Mesh1(const char * filename)80   Mesh1::Mesh1(const char * filename)
81   { // read the mesh
82 
83     int nt,nv,nbe;
84     int ok=0;//load(filename);
85     if(ok)
86       {
87 	ifstream f(filename);
88 	if(!f) {cerr << "Mesh1::Mesh1 Erreur opening " << filename<<endl;exit(1);}
89 	if(verbosity)
90 	  cout << " Read On file \"" <<filename<<"\""<<  endl;
91 	f >> nv >> nt >> nbe ;
92 	this->set(nv,nt,nbe);
93 	if(verbosity)
94 	  cout << "  -- Nb of Vertex " << nv << " " << " Nb of Seg " << nt
95 	       << " , Nb of border Vertex " << nbe <<  endl;
96 	assert(f.good() && nt && nv) ;
97 	for (int i=0;i<nv;i++)
98 	  {
99 	    f >> this->vertices[i];
100 	    assert(f.good());
101 	  }
102 	mes=0;
103 	for (int i=0;i<nt;i++)
104 	  {
105 	    this->t(i).Read1(f,this->vertices,nv);
106 	    mes += t(i).mesure();
107 	  }
108 	mesb=0.;
109 	for (int i=0;i<nbe;i++)
110 	  {
111 	    this->be(i).Read1(f,this->vertices,nv);
112 	    mesb += be(i).mesure();
113 	  }
114       }
115     BuildBound();
116     BuildAdj();
117     Buildbnormalv();
118     BuildjElementConteningVertex();
119 
120     if(verbosity)
121       cout << "   - mesh mesure = " << mes << " border mesure: " << mesb << endl;
122   }
123 }
124 
125 
126