1
|
/************************************************************************
|
2
|
* UNIVERSITE DE BRETAGNE SUD (UBS) --- I.U.P/I.U.T. DE LORIENT *
|
3
|
************************************************************************
|
4
|
* LABORATOIRE DE GENIE MECANIQUE ET MATERIAUX (LG2M) *
|
5
|
* Centre de Recherche Rue de Saint Maudé - 56325 Lorient cedex *
|
6
|
* tel. 02.97.87.45.70 fax. 02.97.87.45.72 http://www-lg2m.univ-ubs.fr *
|
7
|
************************************************************************
|
8
|
* DATE: 08/03/2005 *
|
9
|
* $ *
|
10
|
* AUTEUR: G RIO/H LAURENT (mailto:gerard.rio@univ-ubs.fr) *
|
11
|
* Tel 0297874571 fax : 02.97.87.45.72 *
|
12
|
* $ *
|
13
|
************************************************************************
|
14
|
* BUT: échange de structures de données: fortran Umat -> C++ *
|
15
|
* fonction C a implanter du coté d'abaqus (ou autre prog) *
|
16
|
* accés directe aux informations. *
|
17
|
* *
|
18
|
* $ *
|
19
|
* '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' *
|
20
|
* *
|
21
|
* VERIFICATION: *
|
22
|
* *
|
23
|
* ! date ! auteur ! but ! *
|
24
|
* ------------------------------------------------------------ *
|
25
|
* ! ! ! ! *
|
26
|
* $ *
|
27
|
* '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' *
|
28
|
* MODIFICATIONS: *
|
29
|
* ! date ! auteur ! but ! *
|
30
|
* 5 avril 2016 : G Rio : prise en compte des éléments axi *
|
31
|
* ------------------------------------------------------------ *
|
32
|
* $ *
|
33
|
************************************************************************/
|
34
|
|
35
|
#include <sys/types.h>
|
36
|
#include <sys/stat.h>
|
37
|
#include <stdio.h>
|
38
|
#include <fcntl.h> /* Pour O_WRONLY, etc */
|
39
|
#include <unistd.h> /* pour les ordres read write close*/
|
40
|
|
41
|
/* définition d'une union qui lie les réels, les entiers et les caractères */
|
42
|
union Tab_car_double_int
|
43
|
{ char tampon[928];
|
44
|
double x[116];
|
45
|
int n[232];
|
46
|
} ;
|
47
|
Tab_car_double_int t_car_x_n;
|
48
|
|
49
|
/* --- def des variables globales (a commenter certaines si elles sont declarees autre part) */
|
50
|
/* nom du tube nommé pour l'envoi des donnees */
|
51
|
char* envoi="Umat_envoi_Hz";
|
52
|
/* nom du tube nomme pour la reception des donnees */
|
53
|
char* reception="Umat_reception_Hz";
|
54
|
/* -- declarations des variables de passages avec un nom assez long pour qu'il n'y ait pas */
|
55
|
/* -- de confusion avec les noms du programme appelant */
|
56
|
/* --- en sortie uniquement */
|
57
|
double* u_herezh_DDSDDT = &t_car_x_n.x[0]; /* 6 */
|
58
|
double* u_herezh_DRPLDE = &t_car_x_n.x[6]; /* 6 */
|
59
|
double* u_herezh_DDSDDE = &t_car_x_n.x[12]; /* 36 */
|
60
|
/* --- en entrée - sortie */
|
61
|
double* u_herezh_RPL = &t_car_x_n.x[48]; /* 1 */
|
62
|
double* u_herezh_STRESS = &t_car_x_n.x[49]; /* 6 */
|
63
|
double* u_herezh_SSE = &t_car_x_n.x[55]; /* 1 */
|
64
|
double* u_herezh_SPD = &t_car_x_n.x[56]; /* 1 */
|
65
|
double* u_herezh_SCD = &t_car_x_n.x[57]; /* 1 */
|
66
|
double* u_herezh_DRPLDT = &t_car_x_n.x[58]; /* 1 */
|
67
|
double* u_herezh_PNEWDT = &t_car_x_n.x[59]; /* 1 */
|
68
|
/* --- en entrée seulement */
|
69
|
double* u_herezh_STRAN = &t_car_x_n.x[60]; /* 6 */
|
70
|
double* u_herezh_DSTRAN = &t_car_x_n.x[66]; /* 6 */
|
71
|
double* u_herezh_TIME = &t_car_x_n.x[72]; /* 2 */
|
72
|
double* u_herezh_DTIME = &t_car_x_n.x[74]; /* 1 */
|
73
|
double* u_herezh_TemP = &t_car_x_n.x[75]; /* 1 */
|
74
|
double* u_herezh_DTEMP = &t_car_x_n.x[76]; /* 1 */
|
75
|
double* u_herezh_COORDS = &t_car_x_n.x[77]; /* 3 */
|
76
|
double* u_herezh_DROT = &t_car_x_n.x[80]; /* 9 */
|
77
|
double* u_herezh_CELENT = &t_car_x_n.x[89]; /* 1 */
|
78
|
double* u_herezh_DFGRD0 = &t_car_x_n.x[90]; /* 9 */
|
79
|
double* u_herezh_DFGRD1 = &t_car_x_n.x[99]; /* 9 */
|
80
|
|
81
|
int* u_herezh_NDI = &t_car_x_n.n[216]; /* 1 */
|
82
|
int* u_herezh_NSHR = &t_car_x_n.n[217]; /* 1 */
|
83
|
int* u_herezh_NTENS = &t_car_x_n.n[218]; /* 1 */
|
84
|
int* u_herezh_NSTATV = &t_car_x_n.n[219]; /* 1 */
|
85
|
int* u_herezh_NOEL = &t_car_x_n.n[220]; /* 1 */
|
86
|
int* u_herezh_NPT = &t_car_x_n.n[221]; /* 1 */
|
87
|
int* u_herezh_LAYER = &t_car_x_n.n[222]; /* 1 */
|
88
|
int* u_herezh_KSPT = &t_car_x_n.n[223]; /* 1 */
|
89
|
int* u_herezh_KSTEP = &t_car_x_n.n[224]; /* 1 */
|
90
|
int* u_herezh_KINC = &t_car_x_n.n[225]; /* 1 */
|
91
|
|
92
|
char* u_herezh_CMNAME = &t_car_x_n.tampon[904]; /* 24 */
|
93
|
|
94
|
|
95
|
/* --------------------- rappel des parametres de passage de la routine fortran ------------- */
|
96
|
|
97
|
/* SUBROUTINE UMAT(STRESS,STATEV,DDSDDE,SSE,SPD,SCD,
|
98
|
1 RPL,DDSDDT,DRPLDE,DRPLDT,STRAN,DSTRAN,
|
99
|
2 TIME,DTIME,TEMP,DTEMP,PREDEF,DPRED,MATERL,NDI,NSHR,NTENS,
|
100
|
3 NSTATV,PROPS,NPROPS,COORDS,DROT,PNEWDT,CELENT,
|
101
|
4 DFGRD0,DFGRD1,NOEL,NPT,KSLAY,KSPT,KSTEP,KINC)
|
102
|
C
|
103
|
INCLUDE 'ABA_PARAM.INC'
|
104
|
C
|
105
|
CHARACTER*80 MATERL
|
106
|
DIMENSION STRESS(NTENS),STATEV(NSTATV),
|
107
|
1 DDSDDE(NTENS,NTENS),DDSDDT(NTENS),DRPLDE(NTENS),
|
108
|
2 STRAN(NTENS),DSTRAN(NTENS),TIME(2),PREDEF(1),DPRED(1),
|
109
|
3 PROPS(NPROPS),COORDS(3),DROT(3,3),
|
110
|
4 DFGRD0(3,3),DFGRD1(3,3)
|
111
|
C
|
112
|
DIMENSION EELAS(6),EPLAS(6),FLOW(6)
|
113
|
PARAMETER (ONE=1.0D0,TWO=2.0D0,THREE=3.0D0,SIX=6.0D0)
|
114
|
DATA NEWTON,TOLER/10,1.D-6/
|
115
|
*/
|
116
|
|
117
|
/* --------------------- fin rappel des parametres de passage de la routine fortran ------------- */
|
118
|
|
119
|
/* procedure de lecture de recuperation sur le pipe des infos calculees */
|
120
|
void LectureDonneesUmat(double* STRESS,double* DDSDDE
|
121
|
,double* SSE,double* SPD,double* SCD
|
122
|
,const int* NDI,const int* NSHR,const int* NTENS
|
123
|
,double* PNEWDT
|
124
|
,double* RPL,double* DDSDDT,double* DRPLDE,double* DRPLDT)
|
125
|
|
126
|
{
|
127
|
|
128
|
/* Creation d'un processus de reception des donnees */
|
129
|
int tub;
|
130
|
/* ouverture du tube nomme en lecture */
|
131
|
tub = open(envoi,O_RDONLY);
|
132
|
/* lecture dans le tampon */
|
133
|
read (tub,t_car_x_n.tampon,480);
|
134
|
close (tub); /* fermeture du tampon */
|
135
|
/* transformation de l'information
|
136
|
a priori *NDI + *NSHR = *NTENS, mais abaqus garde les 3 valeurs donc on se refere uniquement sur les 2
|
137
|
premieres donnees -> d'ou un test */
|
138
|
if ((*NDI == 3) && (*NSHR == 3))
|
139
|
{/* cas classique 3D */
|
140
|
int ij;
|
141
|
for (ij=0;ij<6;ij++)
|
142
|
{STRESS[ij] = u_herezh_STRESS[ij];
|
143
|
DDSDDT[ij] = u_herezh_DDSDDT[ij];
|
144
|
DRPLDE[ij] = u_herezh_DRPLDE[ij];
|
145
|
int kl;
|
146
|
for (kl=0;kl<6;kl++)
|
147
|
{int r=ij*6+kl;
|
148
|
DDSDDE[r] = u_herezh_DDSDDE[r];
|
149
|
};
|
150
|
};
|
151
|
}
|
152
|
else if ((*NDI == 3) && (*NSHR == 1))
|
153
|
{/* cas d'elements axisymetrique 3D */
|
154
|
int ij;
|
155
|
for (ij=0;ij<4;ij++)
|
156
|
{STRESS[ij] = u_herezh_STRESS[ij];
|
157
|
DDSDDT[ij] = u_herezh_DDSDDT[ij];
|
158
|
DRPLDE[ij] = u_herezh_DRPLDE[ij];
|
159
|
int kl;
|
160
|
for (kl=0;kl<4;kl++)
|
161
|
{int r=ij*4+kl;
|
162
|
DDSDDE[r] = u_herezh_DDSDDE[r];
|
163
|
};
|
164
|
};
|
165
|
};
|
166
|
*SSE = *u_herezh_SSE; *SPD = *u_herezh_SPD; *SCD = *u_herezh_SCD;
|
167
|
*PNEWDT = *u_herezh_PNEWDT;
|
168
|
*RPL = *u_herezh_RPL;
|
169
|
*DRPLDT = *u_herezh_DRPLDT;
|
170
|
};
|
171
|
|
172
|
union Tab_car_et_double
|
173
|
{ char tampon[21];
|
174
|
double truc[2];
|
175
|
} ;
|
176
|
|
177
|
/* procedure d'ecriture sur le pipe des infos passees par le programme principal */
|
178
|
void EcritureDonneesUmat(double* STRESS
|
179
|
,double* SSE,double* SPD,double* SCD
|
180
|
,const double* STRAN,const double* DSTRAN
|
181
|
,const double* TIME,const double* DTIME,const double* TemP,const double* DTEMP
|
182
|
,const char* CMNAME
|
183
|
,const int* NDI,const int* NSHR,const int* NTENS
|
184
|
,const int* NSTATV
|
185
|
,const double* COORDS,const double* DROT
|
186
|
,double* PNEWDT,const double* CELENT
|
187
|
,const double* DFGRD0,const double* DFGRD1
|
188
|
,const int* NOEL,const int* NPT,const int* LAYER
|
189
|
,const int* KSPT,const int* KSTEP,const int* KINC)
|
190
|
{
|
191
|
|
192
|
/* a priori *NDI + *NSHR = *NTENS, mais abaqus garde les 3 valeurs donc on se refere uniquement sur les 2
|
193
|
premieres donnees -> d'ou un test (que l'on pourrait sans doute eviter ) */
|
194
|
if ((*NDI == 3) && (*NSHR == 3))
|
195
|
{ /* cas classique 3D */
|
196
|
int ij;
|
197
|
for (ij=0;ij<6;ij++)
|
198
|
{u_herezh_STRESS[ij] = STRESS[ij];
|
199
|
u_herezh_STRAN[ij] = STRAN[ij];
|
200
|
u_herezh_DSTRAN[ij] = DSTRAN[ij];
|
201
|
};
|
202
|
}
|
203
|
else if ((*NDI == 3) && (*NSHR == 1))
|
204
|
{ /* cas d'éléments axisymétrique 3D */
|
205
|
int ij;
|
206
|
for (ij=0;ij<4;ij++)
|
207
|
{u_herezh_STRESS[ij] = STRESS[ij];
|
208
|
u_herezh_STRAN[ij] = STRAN[ij];
|
209
|
u_herezh_DSTRAN[ij] = DSTRAN[ij];
|
210
|
};
|
211
|
};
|
212
|
|
213
|
*u_herezh_SSE = *SSE; *u_herezh_SPD = *SPD; *u_herezh_SCD = *SCD;
|
214
|
*u_herezh_PNEWDT= *PNEWDT;
|
215
|
u_herezh_TIME[0]= TIME[0]; u_herezh_TIME[1]= TIME[1]; *u_herezh_DTIME = *DTIME;
|
216
|
*u_herezh_TemP = *TemP; *u_herezh_DTEMP = *DTEMP;
|
217
|
*u_herezh_NDI = *NDI; *u_herezh_NSHR = *NSHR; *u_herezh_NTENS = *NTENS; *u_herezh_NSTATV = *NSTATV;
|
218
|
int i;
|
219
|
for (i=0;i<3;i++)
|
220
|
{u_herezh_COORDS[i]= COORDS[i];
|
221
|
int j;
|
222
|
for (j=0;j<3;j++)
|
223
|
{int r=i*3+j;
|
224
|
u_herezh_DROT[r]= DROT[r]; u_herezh_DFGRD0[r]=DFGRD0[r]; u_herezh_DFGRD1[r]=DFGRD1[r];
|
225
|
}
|
226
|
};
|
227
|
*u_herezh_CELENT = *CELENT;
|
228
|
*u_herezh_NOEL = *NOEL; *u_herezh_NPT = *NPT; *u_herezh_LAYER = *LAYER; *u_herezh_KSPT = *KSPT;
|
229
|
*u_herezh_KSTEP = *KSTEP; *u_herezh_KINC = *KINC;
|
230
|
for (i=0;i<20;i++) u_herezh_CMNAME[i] = CMNAME[i];
|
231
|
|
232
|
/*cout << "\n *********** grandeurs expedier du sous prog c abaqus ************ ";
|
233
|
cout << "\n sigma_t "; for (int i=0;i<6;i++) cout << " ("<<i<<")=" << u_herezh_STRESS[i];
|
234
|
cout << "\n def "; for (int i=0;i<6;i++) cout << " ("<<i<<")=" << u_herezh_STRAN[i];
|
235
|
cout << "\n deltatdef "; for (int i=0;i<6;i++) cout << " ("<<i<<")=" << u_herezh_DSTRAN[i];
|
236
|
cout << "\n rotation "; for (int i=0;i<9;i++) cout << " ("<<i<<")=" << u_herezh_DROT[i];
|
237
|
cout << "\n gradiant_t "; for (int i=1;i<9;i++) cout << " ("<<i<<")=" << u_herezh_DFGRD0[i];
|
238
|
cout << "\n gradiant_tdt "; for (int i=1;i<9;i++) cout << " ("<<i<<")=" << u_herezh_DFGRD1[i];
|
239
|
cout << endl; */
|
240
|
/* Creation d'un processus de pour l'ecriture des donnees */
|
241
|
/* ouverture du tube nomme en ecriture */
|
242
|
printf("\n on ouvre le tube pour l'ecriture: sp essai");
|
243
|
int tub = open(reception,O_WRONLY);
|
244
|
/* ecriture dans le tampon */
|
245
|
/* en fait l'objectif est d'ecrire que les variables d'entrees ou */
|
246
|
/* d'entree sortie */
|
247
|
char* tampon_envoi = &(t_car_x_n.tampon[384]);
|
248
|
write (tub,tampon_envoi,544); /*sizeof(tampon)); */
|
249
|
close (tub); /* fermeture du tampon */
|
250
|
printf("\n fermeture du tampon: sp essai");
|
251
|
return;
|
252
|
};
|
253
|
|