42 std::cout << message << std::endl;
49 params.
ajouter(
"carte_taille_structure_adapt",20.,
OT_PARAMETRES::DOUBLE,
"Utilisation d'un support de carte de taille structure 0-non nombre=nombre de subdivision en une direction");
80 jac[0]=(xyz2[0]-xyz1[0]);
81 jac[1]=(xyz2[1]-xyz1[1]);
82 jac[2]=(xyz2[2]-xyz1[2]);
83 jac[3]=(xyz3[0]-xyz1[0]);
84 jac[4]=(xyz3[1]-xyz1[1]);
85 jac[5]=(xyz3[2]-xyz1[2]);
86 jac[6]=(xyz4[0]-xyz1[0]);
87 jac[7]=(xyz4[1]-xyz1[1]);
88 jac[8]=(xyz4[2]-xyz1[2]);
89 double detj=jac[0]*jac[4]*jac[8]+jac[3]*jac[7]*jac[2]+jac[6]*jac[1]*jac[5]-jac[2]*jac[4]*jac[6]-jac[5]*jac[7]*jac[0]-jac[8]*jac[1]*jac[3];
91 j[0*3+0] = (jac[1*3+1]*jac[2*3+2]-jac[1*3+2]*jac[2*3+1])/(detj);
92 j[0*3+1] = -(jac[0*3+1]*jac[2*3+2]-jac[0*3+2]*jac[2*3+1])/(detj);
93 j[0*3+2] =-(-jac[0*3+1]*jac[1*3+2]+jac[0*3+2]*jac[1*3+1])/(detj);
94 j[1*3+0] = -(jac[1*3+0]*jac[2*3+2]-jac[1*3+2]*jac[2*3+0])/(detj);
95 j[1*3+1] = (jac[0*3+0]*jac[2*3+2]-jac[0*3+2]*jac[2*3+0])/(detj);
96 j[1*3+2] = -(jac[0*3+0]*jac[1*3+2]-jac[0*3+2]*jac[1*3+0])/(detj);
97 j[2*3+0] =-(-jac[1*3+0]*jac[2*3+1]+jac[1*3+1]*jac[2*3+0])/(detj);
98 j[2*3+1] = -(jac[0*3+0]*jac[2*3+1]-jac[0*3+1]*jac[2*3+0])/(detj);
99 j[2*3+2] = (jac[0*3+0]*jac[1*3+1]-jac[0*3+1]*jac[1*3+0])/(detj);
107 double gd_x = j[0*3+0]*(d1-d0)+j[0*3+1]*(d2-d0)+j[0*3+2]*(d3-d0);
108 double gd_y = j[1*3+0]*(d1-d0)+j[1*3+1]*(d2-d0)+j[1*3+2]*(d3-d0);
109 double gd_z = j[2*3+0]*(d1-d0)+j[2*3+1]*(d2-d0)+j[2*3+2]*(d3-d0);
112 return(gd.get_longueur());
121 double grdmax = 0.001;
122 double grdmax_grd = 0.001;
134 affiche((
char*)
"Extrapolation de la densité aux noeuds ");
136 LISTE_FEM_NOEUD::iterator it;
138 no->change_solution(0.);
141 LISTE_FEM_ELEMENT3::iterator itt;
150 liste_noeuds_design.
ajouter(n1);
151 liste_noeuds_design.
ajouter(n2);
152 liste_noeuds_design.
ajouter(n3);
153 liste_noeuds_design.
ajouter(n4);
154 liste_tetras_design.
ajouter(tet);
162 liste_noeuds_nondesign.
ajouter(n1);
163 liste_noeuds_nondesign.
ajouter(n2);
164 liste_noeuds_nondesign.
ajouter(n3);
165 liste_noeuds_nondesign.
ajouter(n4);
166 liste_tetras_nondesign.
ajouter(tet);
172 if (no1==no2) lstasup.
ajouter(no2);
173 for (
int i=0;i<lstasup.
get_nb();i++)
181 for (
int i=0;i<no->get_lien_element3()->get_nb();i++)
192 no->change_solution(nume/deno);
198 if ((tet->get_nb_fem_noeud()==4)&&(tet->get_mg_element_maillage()->get_origine()!=
MAGIC::ORIGINE::IMPOSE))
203 affiche((
char*)
"Extrapolation du gradient aux noeuds ");
205 no->change_solution(0.);
212 for (
int i=0;i<no->get_lien_element3()->get_nb();i++)
229 double volume=(fabs(vec3*pvec))/6.;
234 if(vect/vol > 0.001) no->change_solution(vect/vol);
235 if(vect/vol > grdmax) grdmax = vect/vol;
236 if(vect/vol >= 1.e-308) lstnode.
ajouter(no);
240 sprintf(message,
"gradient maximal = %lf",grdmax);
247 tet->change_solution(0.);
250 if ((tet->get_nb_fem_noeud()==4)&&(tet->get_mg_element_maillage()->get_origine()!=
MAGIC::ORIGINE::IMPOSE))
258 for (
int i=0;i<no->get_lien_element3()->get_nb();i++)
275 double volume=(fabs(vec3*pvec))/6.;
280 if(vect/vol > grdmax_grd) grdmax_grd = vect/vol;
282 sprintf(message,
"gradient maximal du gradient = %lf",grdmax_grd);
292 for (
int i=0;i<no->get_lien_element3()->get_nb();i++)
309 double volume=(fabs(vec3*pvec))/6.;
314 if(vect/vol > seuil*grdmax_grd)
319 for (
int i=0;i<no->get_lien_element3()->get_nb();i++)
337 som=som+nod->get_solution();
338 no->change_solution(som/nb);
346 if(no->get_solution() > grdmax) grdmax = no->get_solution();
347 sprintf(message,
"Nombre de noeuds lisses # %d",stnode2.
get_nb());
358 sol3->
ecrire(no->get_solution(),i,0);
369 affiche((
char*)
"************************************");
370 affiche((
char*)
"Optimisation adaptative de topologie");
371 affiche((
char*)
"************************************");
376 time_t heuredeb = time(NULL);
377 tdebut = *localtime(&heuredeb);
379 char *p=strchr(nomgestd,
'.');
380 strncpy(
nometude,nomgestd,p-nomgestd);
382 p=strchr(nomsortie,
'.');
389 affiche((
char*)
"Itération 1 de SIMP");
390 affiche((
char*)
"Preparation du modèle");
416 char nomsortieiter[5000];
417 sprintf(nomsortieiter,
"%s_iter%d_gradient.sol",
nometudesortie,nbiter);
421 LISTE_FEM_NOEUD::iterator it;
423 double taille_min=1e308;
426 double *xyz=no->get_coord();
428 if (1./
sqrt(tenseur_i[0]) <= taille_min) taille_min = 1./
sqrt(tenseur_i[0]);
432 sprintf(message,
"Enregistrement resultat iteration %d",nbiter);
438 sprintf(message,
"Calcul de la carte de taille");
448 sprintf(message,
"Calcul de la carte de taille sur un support structure de %d,%d,%d divisions",nbdiv,nbdiv,nbdiv);
474 sprintf(message,
"Itération %d de la SIMP",nbiter);
478 affiche((
char*)
"Preparation du modèle");
488 affiche((
char*)
"Enregistrement resultat");
495 double taille_min2 = 1.e308;
496 double taille_max = 0.;
499 double *xyz=no->get_coord();
501 if (1./
sqrt(tenseur_j[0]) <= taille_min2) taille_min2 = 1./
sqrt(tenseur_j[0]);
502 if (1./
sqrt(tenseur_j[0]) > taille_max) taille_max = 1./
sqrt(tenseur_j[0]);
504 sprintf(message,
"taille_min (ancienne carte) = %lf ; taille_min2 (nouvelle carte) = %lf",taille_min,taille_min2);
510 std::vector<std::string> tab;
512 for (
int i=0;i<tab.size();i++)
513 printf(
"%s\n",(
char*)tab[i].c_str());
516 while ((fin == 0) && (nbiter < nbitermax));
517 if (nbiter==nbitermax) {sprintf(message2,
" Arrêt de la procedure d'optimisation adaptative apres %d cycles de raffinement",nbiter-1);
affiche(message2);}
518 else {sprintf(message2,
" Convergence de la procedure d'optimisation adaptative après %d cycles de raffinement",nbiter-1);
affiche(message2);}
523 affiche((
char*)
"Enregistrement resultat simplifie");
524 char nomfichier[5000];
529 affiche((
char*)
"Enregistrement finaux resultat sous GMSH");
531 char nomfichier[5000];
535 exp.
gmsh(fem,nomfichier);