1 |
/*****************************************************************
|
2 |
|
3 |
eval_dens_reel.cpp Type:Func
|
4 |
|
5 |
Evaluation de la densite reelle d un noeud
|
6 |
|
7 |
Date de creation : 5-11-1997 11 :29 :42
|
8 |
Derniere version : 5-11-1997 11 :29 :42
|
9 |
|
10 |
Vincent FRANCOIS
|
11 |
|
12 |
*****************************************************************/
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
/**************************/
|
19 |
/* include */
|
20 |
#include <stdio.h>
|
21 |
#include <string.h>
|
22 |
#include <stdlib.h>
|
23 |
#include <math.h>
|
24 |
#include "const.h"
|
25 |
#include "memoire.h"
|
26 |
#include "struct.h"
|
27 |
#include "prototype.h"
|
28 |
|
29 |
/**************************/
|
30 |
/* variables globales */
|
31 |
extern struct s_maillage *maillage;
|
32 |
extern struct environnement env;
|
33 |
|
34 |
|
35 |
/**************************/
|
36 |
/* programme principal */
|
37 |
|
38 |
void eval_dens_reel(struct s_mnoeud *mnoe)
|
39 |
{
|
40 |
int *test_noeud;
|
41 |
int nb_connec,i;
|
42 |
float vec[4];
|
43 |
struct s_mnoeud *mnoe1;
|
44 |
struct s_mtriangle *mtri;
|
45 |
struct s_mtetra *mtet;
|
46 |
|
47 |
if (mnoe->dens>0.0001) return;
|
48 |
test_noeud=(int *)calloc(maillage->nb_mnoeud,sizeof(int));
|
49 |
ERREUR_ALLOC(test_noeud);
|
50 |
test_noeud[mnoe->num]=1;
|
51 |
nb_connec=0;
|
52 |
if (mnoe->nb_mtetra!=0)
|
53 |
for (i=0;i<mnoe->nb_mtetra;i++)
|
54 |
{
|
55 |
mtet=mnoe->mtetra[i];
|
56 |
if (test_noeud[mtet->n1]==0)
|
57 |
{
|
58 |
test_noeud[mtet->n1]=1;
|
59 |
nb_connec++;
|
60 |
mnoe1=ADRESSE(mtet->n1,mnoeud,maillage->);
|
61 |
VEC(vec,mnoe1,mnoe);
|
62 |
mnoe->dens=(float)(mnoe->dens+sqrt((double)PSCA(vec,vec)));
|
63 |
}
|
64 |
if (test_noeud[mtet->n2]==0)
|
65 |
{
|
66 |
test_noeud[mtet->n2]=1;
|
67 |
nb_connec++;
|
68 |
mnoe1=ADRESSE(mtet->n2,mnoeud,maillage->);
|
69 |
VEC(vec,mnoe1,mnoe);
|
70 |
mnoe->dens=(float)(mnoe->dens+sqrt((double)PSCA(vec,vec)));
|
71 |
}
|
72 |
if (test_noeud[mtet->n3]==0)
|
73 |
{
|
74 |
test_noeud[mtet->n3]=1;
|
75 |
nb_connec++;
|
76 |
mnoe1=ADRESSE(mtet->n3,mnoeud,maillage->);
|
77 |
VEC(vec,mnoe1,mnoe);
|
78 |
mnoe->dens=(float)(mnoe->dens+sqrt((double)PSCA(vec,vec)));
|
79 |
}
|
80 |
if (test_noeud[mtet->n4]==0)
|
81 |
{
|
82 |
test_noeud[mtet->n4]=1;
|
83 |
nb_connec++;
|
84 |
mnoe1=ADRESSE(mtet->n4,mnoeud,maillage->);
|
85 |
VEC(vec,mnoe1,mnoe);
|
86 |
mnoe->dens=(float)(mnoe->dens+sqrt((double)PSCA(vec,vec)));
|
87 |
}
|
88 |
}
|
89 |
else
|
90 |
for (i=0;i<mnoe->nb_mtriangle;i++)
|
91 |
{
|
92 |
mtri=mnoe->mtriangle[i];
|
93 |
if (test_noeud[mtri->n1]==0)
|
94 |
{
|
95 |
test_noeud[mtri->n1]=1;
|
96 |
nb_connec++;
|
97 |
mnoe1=ADRESSE(mtri->n1,mnoeud,maillage->);
|
98 |
VEC(vec,mnoe1,mnoe);
|
99 |
mnoe->dens=(float)(mnoe->dens+sqrt((double)PSCA(vec,vec)));
|
100 |
}
|
101 |
if (test_noeud[mtri->n2]==0)
|
102 |
{
|
103 |
test_noeud[mtri->n2]=1;
|
104 |
nb_connec++;
|
105 |
mnoe1=ADRESSE(mtri->n2,mnoeud,maillage->);
|
106 |
VEC(vec,mnoe1,mnoe);
|
107 |
mnoe->dens=(float)(mnoe->dens+sqrt((double)PSCA(vec,vec)));
|
108 |
}
|
109 |
if (test_noeud[mtri->n3]==0)
|
110 |
{
|
111 |
test_noeud[mtri->n3]=1;
|
112 |
nb_connec++;
|
113 |
mnoe1=ADRESSE(mtri->n3,mnoeud,maillage->);
|
114 |
VEC(vec,mnoe1,mnoe);
|
115 |
mnoe->dens=(float)(mnoe->dens+sqrt((double)PSCA(vec,vec)));
|
116 |
}
|
117 |
}
|
118 |
mnoe->dens=mnoe->dens/nb_connec;
|
119 |
free(test_noeud);
|
120 |
}
|