ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/lib/mecanique/src/mc_gestionnaire.cpp
Revision: 300
Committed: Fri Nov 18 16:53:02 2011 UTC (13 years, 5 months ago) by francois
File size: 6625 byte(s)
Log Message:
Ajout d'une condition au limite

File Contents

# User Rev Content
1 francois 283 //------------------------------------------------------------
2     //------------------------------------------------------------
3     // MAGiC
4     // Jean Christophe Cuilli�re et Vincent FRANCOIS
5     // D�partement de G�nie M�canique - UQTR
6     //------------------------------------------------------------
7     // Le projet MAGIC est un projet de recherche du d�partement
8     // de g�nie m�canique de l'Universit� du Qu�bec �
9     // Trois Rivi�res
10     // Les librairies ne peuvent �tre utilis�es sans l'accord
11     // des auteurs (contact : francois@uqtr.ca)
12     //------------------------------------------------------------
13     //------------------------------------------------------------
14     //
15     // mt_gestionnaire.cpp
16     //
17     //------------------------------------------------------------
18     //------------------------------------------------------------
19     // COPYRIGHT 2000
20     // Version du 02/03/2006 � 11H23
21     //------------------------------------------------------------
22     //------------------------------------------------------------
23    
24    
25     #include "gestionversion.h"
26    
27     #pragma hdrstop
28    
29 francois 296 #include "mc_gestionnaire.h"
30     #include "mc_materiau.h"
31 francois 283 #include "parse.h"
32     #include "pars_argument.h"
33     #include <string.h>
34     //---------------------------------------------------------------------------
35 francois 296 MC_GESTIONNAIRE::MC_GESTIONNAIRE(char* path)
36 francois 283 {
37     chemin=path;
38     lire();
39     }
40    
41 francois 296
42     MC_GESTIONNAIRE::MC_GESTIONNAIRE()
43 francois 283 {
44 francois 296 std::pair<std::string,std::string> tmp("Dx","Déplacement en X");
45     mecaliste.insert(tmp);
46     std::pair<std::string,std::string> tmp2("Dy","Déplacement en Y");
47     mecaliste.insert(tmp2);
48     std::pair<std::string,std::string> tmp3("Dz","Déplacement en z");
49     mecaliste.insert(tmp3);
50     std::pair<std::string,std::string> tmp4("Da","Tous les déplacements");
51     mecaliste.insert(tmp4);
52     std::pair<std::string,std::string> tmp5("Fx","Force concentrée en X");
53     mecaliste.insert(tmp5);
54     std::pair<std::string,std::string> tmp6("Fy","Force concentrée en Y");
55     mecaliste.insert(tmp6);
56     std::pair<std::string,std::string> tmp7("Fz","Force concentrée en Z");
57     mecaliste.insert(tmp7);
58     std::pair<std::string,std::string> tmp8("Px","Pression en x");
59     mecaliste.insert(tmp8);
60     std::pair<std::string,std::string> tmp9("Py","Pression en y");
61     mecaliste.insert(tmp9);
62     std::pair<std::string,std::string> tmp10("Pz","Pression en z");
63     mecaliste.insert(tmp10);
64     std::pair<std::string,std::string> tmp11("Pn","Pression normale");
65     mecaliste.insert(tmp11);
66     std::pair<std::string,std::string> tmp12("Tp","Temperature de reference");
67     mecaliste.insert(tmp12);
68     std::pair<std::string,std::string> tmp13("Cc","Couleur pour algorithme de comparaison");
69     mecaliste.insert(tmp13);
70     std::pair<std::string,std::string> tmp14("Em","Modele d'Young isotrope");
71     mecaliste.insert(tmp14);
72     std::pair<std::string,std::string> tmp15("nu","Coefficient de poisson isotrope");
73     mecaliste.insert(tmp15);
74     std::pair<std::string,std::string> tmp16("Ro","Densité du matériau");
75     mecaliste.insert(tmp16);
76 francois 300 std::pair<std::string,std::string> tmp17("ep","Epaisseur d'une coque");
77     mecaliste.insert(tmp17);
78 francois 296 }
79    
80    
81    
82     int MC_GESTIONNAIRE::existe(std::string code)
83     {
84     std::map<std::string,std::string,std::less<std::string> >::iterator it=mecaliste.find(code);
85     if (it==mecaliste.end()) return 0;
86     return 1;
87     }
88    
89    
90     std::string MC_GESTIONNAIRE::get_description(std::string code)
91     {
92     std::map<std::string,std::string,std::less<std::string> >::iterator it=mecaliste.find(code);
93     if (it==mecaliste.end()) return "";
94     return (*it).second;
95     }
96    
97     int MC_GESTIONNAIRE::get_description(std::string &code,std::string &description,int init)
98     {
99     static std::map<std::string,std::string,std::less<std::string> >::iterator it;
100     static int passe=0;
101     if (passe==0) {init=1;passe=1;}
102     if (it==mecaliste.end()) init=1;
103     if (init==1) it=mecaliste.begin();
104     if (init==0) it++;
105     if (it!=mecaliste.end())
106     {
107     code=(*it).first;
108     description=(*it).second;
109     return 1;
110     }
111     return 0;
112     }
113    
114    
115     MC_GESTIONNAIRE::~MC_GESTIONNAIRE()
116     {
117 francois 283 int nb=lst_mat.get_nb();
118     while (nb!=0)
119     {
120 francois 296 MC_MATERIAU* mat=lst_mat.get(0);
121 francois 283 lst_mat.supprimer(mat);
122     delete mat;
123     nb=lst_mat.get_nb();
124     }
125     }
126    
127 francois 296 class MC_MATERIAU* MC_GESTIONNAIRE::ajouter_materiau(std::string nom,std::string descrip)
128 francois 283 {
129 francois 296 MC_MATERIAU* mat=new MC_MATERIAU((char*)nom.c_str(),(char*)descrip.c_str());
130 francois 283 lst_mat.ajouter(mat);
131     return mat;
132     }
133    
134 francois 296 int MC_GESTIONNAIRE::get_nb_materiau()
135 francois 283 {
136     return lst_mat.get_nb();
137     }
138    
139 francois 296 class MC_MATERIAU* MC_GESTIONNAIRE::get_materiau(int num)
140 francois 283 {
141     return lst_mat.get(num);
142     }
143    
144 francois 296 char* MC_GESTIONNAIRE::get_chemin()
145 francois 283 {
146     return (char*)chemin.c_str();
147     }
148    
149    
150 francois 296 void MC_GESTIONNAIRE::lire(void)
151 francois 283 {
152     FILE *in=fopen(chemin.c_str(),"rt");
153     if (in==NULL) return ;
154     PARS_ARGUMENT param[20];
155     PARSE parse;
156     char motcle[255];
157     do
158     {
159     char mess[255];
160     char* res=fgets(mess,255,in);
161     std::string ligne=mess;
162     parse.decode(ligne.c_str(),(char*)"@\n",param);
163     sscanf(param[0].argument[0].c_str(),"%s",motcle);
164     if (strcmp(motcle,"END")!=0)
165     {
166     parse.decode(ligne.c_str(),(char*)"@:@\n",param);
167     sscanf(param[0].argument[0].c_str(),"%s",motcle);
168     if (strcmp(motcle,"MATL")==0)
169     {
170     parse.decode(ligne.c_str(),(char*)"@:@:@:@\n",param);
171 francois 296 MC_MATERIAU* mate=ajouter_materiau(param[1].argument[0],param[3].argument[0].c_str());
172 francois 283 do
173     {
174     char mess[255];
175     char *res=fgets(mess,255,in);
176     std::string ligne=mess;
177     parse.decode(ligne.c_str(),(char*)"@\n",param);
178     sscanf(param[0].argument[0].c_str(),"%s",motcle);
179     if (strcmp(motcle,"ENDMATL")!=0)
180     {
181     char nom[20],uni1[50],uni2[50],uni3[50];
182     double val1,val2,val3;
183     int nb=sscanf(ligne.c_str(),"%s %lf %s %lf %s %lf %s",nom,&val1,uni1,&val2,uni2,&val3,uni3);
184     if (nb==7)
185     mate->ajouter_propriete(nom,val1,uni1,val2,uni2,val3,uni3);
186     else
187     {
188     sscanf(ligne.c_str(),"%s %lf %lf %lf",nom,&val1,&val2,&val3);
189     mate->ajouter_propriete(nom,val1,(char*)"",val2,(char*)"",val3,(char*)"");
190     }
191    
192     }
193     sscanf(param[0].argument[0].c_str(),"%s",motcle);
194     }
195     while (strcmp(motcle,"ENDMATL")!=0);
196     }
197     }
198     sscanf(param[0].argument[0].c_str(),"%s",motcle);
199     }
200     while (strcmp(motcle,"END")!=0);
201     fclose(in);
202     }
203    
204