1 |
francois |
239 |
#include "gestionversion.h" |
2 |
|
|
#include "mgopt.h" |
3 |
|
|
#include "mg_file.h" |
4 |
|
|
#include "fct_generateur_frontiere.h" |
5 |
|
|
#include "fct_generateur_constante.h" |
6 |
|
|
#include "fct_generateur_fichier.h" |
7 |
|
|
#include "mailleur_bloc.h" |
8 |
francois |
243 |
#include "mg_export.h" |
9 |
francois |
239 |
#include <string.h> |
10 |
|
|
|
11 |
|
|
|
12 |
|
|
|
13 |
|
|
|
14 |
|
|
|
15 |
|
|
|
16 |
|
|
|
17 |
|
|
|
18 |
|
|
|
19 |
|
|
|
20 |
|
|
|
21 |
|
|
|
22 |
|
|
|
23 |
|
|
MGOPT::MGOPT():gestd(NULL),gestnd(NULL),carte(NULL) |
24 |
|
|
{ |
25 |
francois |
243 |
params.ajouter("maille",0.,"0. le maillage est effectue ou numero de maillage a utiliser" ); |
26 |
|
|
params.ajouter("dg",7.,"Ecart nodal constant de la carte de taille"); |
27 |
|
|
params.ajouter("typecarte",1.,"0. calcul d'une nouvelle carte de taille 1. utilisation d'une carte existante"); |
28 |
|
|
params.ajouter("fechantillonnage",20.,"Nombre de cellules de la carte de taille dans une direction"); |
29 |
|
|
params.ajouter("festimation",1.,"nombre d'échantillons dans une direction"); |
30 |
|
|
params.ajouter("fichiercarte","bielle.ctt","Fichier carte de taille a utiliser quand typecarte vaut 1."); |
31 |
|
|
params.ajouter("degre",1.,"1. maillage lineaire 2. maillage quadratique"); |
32 |
francois |
239 |
} |
33 |
|
|
|
34 |
|
|
MGOPT::MGOPT(MGOPT &mdd) |
35 |
|
|
{ |
36 |
|
|
params=mdd.params; |
37 |
|
|
} |
38 |
|
|
|
39 |
|
|
|
40 |
|
|
MGOPT::~MGOPT() |
41 |
|
|
{ |
42 |
|
|
if (gestd!=NULL) delete gestd; |
43 |
|
|
if (gestd!=NULL) delete gestnd; |
44 |
|
|
if (carte!=NULL) delete carte; |
45 |
|
|
} |
46 |
|
|
|
47 |
|
|
void MGOPT::active_affichage(void (*fonc)(char*)) |
48 |
|
|
{ |
49 |
|
|
affiche=fonc; |
50 |
|
|
affichageactif=1; |
51 |
|
|
} |
52 |
|
|
void MGOPT::lire_params(char *fichier) |
53 |
|
|
{ |
54 |
|
|
params.vide(); |
55 |
|
|
params.lire(fichier); |
56 |
|
|
} |
57 |
|
|
|
58 |
|
|
void MGOPT::optimise(char *fichier) |
59 |
|
|
{ |
60 |
francois |
272 |
affiche((char*)""); |
61 |
|
|
affiche((char*)"*************************"); |
62 |
|
|
affiche((char*)"Optimisation de topologie"); |
63 |
|
|
affiche((char*)"*************************"); |
64 |
|
|
affiche((char*)""); |
65 |
|
|
affiche((char*)""); |
66 |
|
|
affiche((char*)""); |
67 |
|
|
affiche((char*)"Écriture d'un fichier de parametres par défaut"); |
68 |
francois |
239 |
params.enregistrer(fichier); |
69 |
|
|
} |
70 |
|
|
|
71 |
|
|
void MGOPT::optimise(char *nomgestd,char *nomgestnd,char *nomsortie,char *nomparam) |
72 |
|
|
{ |
73 |
francois |
272 |
affiche((char*)""); |
74 |
|
|
affiche((char*)"*************************"); |
75 |
|
|
affiche((char*)"Optimisation de topologie"); |
76 |
|
|
affiche((char*)"*************************"); |
77 |
|
|
affiche((char*)""); |
78 |
|
|
affiche((char*)""); |
79 |
|
|
affiche((char*)""); |
80 |
francois |
271 |
time_t heuredeb = time(NULL); |
81 |
|
|
tdebut = *localtime(&heuredeb); |
82 |
francois |
239 |
if (nomparam!=NULL) lire_params(nomparam); |
83 |
|
|
char *p=strchr(nomgestd,'.'); |
84 |
|
|
strncpy(nometude,nomgestd,p-nomgestd); |
85 |
|
|
nometude[p-nomgestd]=0; |
86 |
francois |
243 |
p=strchr(nomsortie,'.'); |
87 |
|
|
strncpy(nometudesortie,nomsortie,p-nomsortie); |
88 |
|
|
nometudesortie[p-nomsortie]=0; |
89 |
francois |
272 |
affiche((char*)"Preparation du modèle"); |
90 |
francois |
239 |
gestd=new MG_FILE(nomgestd); |
91 |
|
|
gestnd=new MG_FILE(nomgestnd); |
92 |
|
|
unsigned long maille=(unsigned long)params.get_valeur("maille"); |
93 |
|
|
FEM_MAILLAGE* fem; |
94 |
|
|
if (maille==0) fem=prepare_model(gestd,gestnd); |
95 |
|
|
else fem=gestd->get_fem_maillageid(maille); |
96 |
francois |
272 |
affiche((char*)"Debut optimisation"); |
97 |
francois |
239 |
optimisation(fem); |
98 |
francois |
272 |
affiche((char*)"Enregistrement resultat"); |
99 |
francois |
239 |
gestd->enregistrer(nomsortie); |
100 |
francois |
272 |
affiche((char*)"Enregistrement resultat sous GMSH"); |
101 |
francois |
243 |
MG_EXPORT exp; |
102 |
|
|
char nomfichier[500]; |
103 |
|
|
sprintf(nomfichier,"%s_mg",nometudesortie); |
104 |
|
|
exp.gmsh(fem->get_mg_maillage(),nomfichier); |
105 |
|
|
sprintf(nomfichier,"%s_fem",nometudesortie); |
106 |
|
|
exp.gmsh(fem,nomfichier); |
107 |
francois |
239 |
} |
108 |
|
|
|
109 |
|
|
FEM_MAILLAGE* MGOPT::prepare_model(MG_GESTIONNAIRE *gestd,MG_GESTIONNAIRE *gestnd) |
110 |
|
|
{ |
111 |
francois |
272 |
affiche((char*)"Carte de taille"); |
112 |
francois |
239 |
int typecarte=(int)params.get_valeur("typecarte"); |
113 |
|
|
if (typecarte==0) |
114 |
|
|
{ |
115 |
francois |
272 |
affiche((char*)" Calcul"); |
116 |
francois |
239 |
double eng=params.get_valeur("dg"); |
117 |
|
|
int fechan=(int)params.get_valeur("fechantillonnage"); |
118 |
|
|
int festim=(int)params.get_valeur("festimation"); |
119 |
|
|
carte=new FCT_GENERATEUR_CONSTANTE(*gestd,eng); |
120 |
|
|
FCT_GENERATEUR_CONSTANTE *carte2=(FCT_GENERATEUR_CONSTANTE*)carte; |
121 |
|
|
carte2->construit(fechan,festim); |
122 |
|
|
char nomfichiersortie[300]; |
123 |
|
|
sprintf(nomfichiersortie,"%s.ctt",nometude); |
124 |
|
|
carte2->enregistrer(nomfichiersortie); |
125 |
|
|
} |
126 |
|
|
else |
127 |
|
|
{ |
128 |
francois |
272 |
affiche((char*)" Lecture"); |
129 |
francois |
239 |
carte=new FCT_GENERATEUR_3D<4>; |
130 |
|
|
std::string fichiercarte=params.get_nom("fichiercarte"); |
131 |
|
|
carte->lire((char *)fichiercarte.c_str()); |
132 |
|
|
} |
133 |
francois |
272 |
affiche((char*)"Maillage par le mailleur bloc"); |
134 |
francois |
239 |
FCT_TAILLE* metrique=carte; |
135 |
|
|
MAILLEUR_BLOC m(gestd,gestnd,0,0,metrique); |
136 |
|
|
m.active_affichage(affiche); |
137 |
|
|
m.maille(); |
138 |
francois |
272 |
affiche((char*)"Creation du maillage FEM"); |
139 |
francois |
239 |
MG_MAILLAGE* mai=gestd->get_mg_maillage(gestd->get_nb_mg_maillage()-1); |
140 |
|
|
int degre=params.get_valeur("degre"); |
141 |
|
|
FEM_MAILLAGE* fem=new FEM_MAILLAGE(mai->get_mg_geometrie(),mai,degre); |
142 |
|
|
gestd->ajouter_fem_maillage(fem); |
143 |
|
|
fem->construire(0); |
144 |
|
|
return fem; |
145 |
|
|
} |