Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
François Trigaux
Cgebt
Commits
b41cec3f
Commit
b41cec3f
authored
Oct 11, 2021
by
François Trigaux
🤠
Browse files
✨
Added exchange functions
parent
1805e914
Changes
3
Show whitespace changes
Inline
Side-by-side
Makefile
View file @
b41cec3f
...
...
@@ -43,6 +43,9 @@ $(OBJF90): $(OBJDIR)/%.o: $(DIRF90)/%.f90
$(OBJF)
:
$(OBJDIR)/%.o: $(DIRF)/%.f
$(CF)
$(FFLAGS)
-fallow-argument-mismatch
-c
-o
$@
$<
-J
$(OBJDIR)
install
:
ln
-f
lib/libgebt.so /usr/local/lib
ln
-f
include/gebt.h /usr/local/include
clean
:
rm
-vf
$(OBJDIR)
/
*
.o
...
...
src/interface/gebt.c
View file @
b41cec3f
...
...
@@ -44,6 +44,9 @@ void initGebt(Gebt *bm)
SET
(
&
(
bm
->
dt
),
%
lf
,
fileGebt
,
section
,
"dt"
);
}
bm
->
t
=
0
.
0
;
bm
->
lastStep
=
-
1
;
bm
->
nmemb
=
bm
->
nkp
-
1
;
// specific for beams.
bm
->
nmate
=
bm
->
nkp
;
// 1 material per point
bm
->
ncond_mb
=
bm
->
nmemb
;
// each member has one condition
...
...
@@ -184,7 +187,7 @@ void initGebt(Gebt *bm)
}
}
// This
must be initialize but has no consequence as no time-functions are used
// This
is used to compute dt in Fortran. MUST BE UPDATED IF nstep OR dt ARE CHANGED!!!
bm
->
simu_time
[
0
]
=
0
.
0
;
bm
->
simu_time
[
1
]
=
bm
->
nstep
*
bm
->
dt
;
...
...
@@ -574,12 +577,12 @@ void gebt_setTwistFromFile(Gebt *bm, char *fname)
if
(
idx
<=
0
)
{
if
(
np
>
1
)
printf
(
"Warning: in Twist Interpolation : value of xp=%f is below or equal to xp[0]=%f
\n
"
,
x
,
xp
[
0
]);
//
if (np>1) printf("Warning: in Twist Interpolation : value of xp=%f is below or equal to xp[0]=%f \n",x,xp[0]);
twist
[
k
]
=
twistp
[
idx
];
}
else
if
(
idx
>=
np
)
{
if
(
np
>
1
)
printf
(
"Warning: in Twist Interpolation : value of xp=%f is higher than xp[np-1]=%f
\n
"
,
x
,
xp
[
np
-
1
]);
//
if (np>1) printf("Warning: in Twist Interpolation : value of xp=%f is higher than xp[np-1]=%f \n",x,xp[np-1]);
twist
[
k
]
=
twistp
[
idx
-
1
];
}
else
...
...
@@ -604,8 +607,22 @@ void gebt_setTwistFromFile(Gebt *bm, char *fname)
void
gebt_getNodeVelocities
(
double
**
vel
,
Gebt
*
bm
){
int
i
,
j
;
int
step
=
bm
->
nstep
-
1
;
int
step
=
bm
->
lastStep
;
if
(
step
<
1
)
{
for
(
i
=
0
;
i
<
bm
->
nkp
;
i
++
)
{
for
(
j
=
0
;
j
<
NSTRN
;
j
++
)
{
// !!! it is vel(j,i) to ease the access from interpolation methods!
vel
[
j
][
i
]
=
0
.
0
;
}
}
}
else
{
for
(
i
=
0
;
i
<
bm
->
nkp
;
i
++
)
{
for
(
j
=
0
;
j
<
NSTRN
;
j
++
)
...
...
@@ -614,12 +631,26 @@ void gebt_getNodeVelocities(double **vel, Gebt *bm){
vel
[
j
][
i
]
=
(
bm
->
sol_pt
[
step
][
i
][
j
+
NDIM
]
-
bm
->
sol_pt
[
step
-
1
][
i
][
j
+
NDIM
])
/
bm
->
dt
;
}
}
}
}
void
gebt_getMemberVelocities
(
double
**
vel
,
Gebt
*
bm
){
int
i
,
j
;
int
step
=
bm
->
nstep
-
1
;
int
step
=
bm
->
lastStep
;
if
(
step
<
1
)
{
for
(
i
=
0
;
i
<
bm
->
nelem
;
i
++
)
{
for
(
j
=
0
;
j
<
NSTRN
;
j
++
)
{
// !!! it is vel(j,i) to ease the access from interpolation methods!
vel
[
j
][
i
]
=
bm
->
init_cond
[
i
][
j
+
NSTRN
];
}
}
}
else
{
for
(
i
=
0
;
i
<
bm
->
nelem
;
i
++
)
{
for
(
j
=
0
;
j
<
NSTRN
;
j
++
)
...
...
@@ -628,6 +659,7 @@ void gebt_getMemberVelocities(double **vel, Gebt *bm){
vel
[
j
][
i
]
=
(
bm
->
sol_mb
[
step
][
i
][
j
+
NDIM
]
-
bm
->
sol_mb
[
step
-
1
][
i
][
j
+
NDIM
])
/
bm
->
dt
;
}
}
}
}
/* disp = allocated double pointer of size (6,nkp)
...
...
@@ -635,14 +667,27 @@ void gebt_getMemberVelocities(double **vel, Gebt *bm){
*/
void
gebt_getNodeDisplacement
(
double
**
disp
,
Gebt
*
bm
){
int
i
,
j
;
int
step
=
bm
->
nstep
-
1
;
int
step
=
bm
->
lastStep
;
for
(
i
=
0
;
i
<
bm
->
nkp
;
i
++
)
if
(
step
<
0
)
{
for
(
j
=
0
;
j
<
NSTRN
;
j
++
)
for
(
i
=
0
;
i
<
bm
->
nkp
;
i
++
)
{
for
(
j
=
0
;
j
<
NSTRN
;
j
++
)
{
disp
[
j
][
i
]
=
0
.
0
;
}
}
}
else
{
for
(
i
=
0
;
i
<
bm
->
nkp
;
i
++
)
{
for
(
j
=
0
;
j
<
NSTRN
;
j
++
)
{
// !!! it is disp(j,i) to ease the access from interpolation methods!
disp
[
j
][
i
]
=
bm
->
sol_pt
[
step
][
i
][
j
+
NDIM
];
disp
[
j
][
i
]
=
bm
->
sol_pt
[
step
][
i
][
j
+
NDIM
];
}
}
}
}
...
...
@@ -652,8 +697,21 @@ void gebt_getNodeDisplacement(double **disp, Gebt *bm){
*/
void
gebt_getMemberDisplacement
(
double
**
disp
,
Gebt
*
bm
){
int
i
,
j
;
int
step
=
bm
->
nstep
-
1
;
int
step
=
bm
->
lastStep
;
if
(
step
<
0
)
{
for
(
i
=
0
;
i
<
bm
->
nelem
;
i
++
)
{
for
(
j
=
0
;
j
<
NSTRN
;
j
++
)
{
// !!! it is vel(j,i) to ease the access from interpolation methods!
disp
[
j
][
i
]
=
bm
->
init_cond
[
i
][
j
];
}
}
}
else
{
for
(
i
=
0
;
i
<
bm
->
nelem
;
i
++
)
{
for
(
j
=
0
;
j
<
NSTRN
;
j
++
)
...
...
@@ -662,6 +720,27 @@ void gebt_getMemberDisplacement(double **disp, Gebt *bm){
disp
[
j
][
i
]
=
bm
->
sol_mb
[
step
][
i
][
j
+
NDIM
];
}
}
}
}
/* Get the rotation matrix from the internal Wiener-Milenkovic parameters of GEBT.
*/
void
gebt_getRotationMatrix
(
double
out
[
3
][
3
],
double
c
[
3
])
{
double
c0
,
fac
;
c0
=
2
.
0
-
(
c
[
0
]
*
c
[
0
]
+
c
[
1
]
*
c
[
1
]
+
c
[
2
]
*
c
[
2
])
/
8
.
0
;
fac
=
1
.
0
/
(
4
.
0
-
c0
)
/
(
4
.
0
-
c0
);
out
[
0
][
0
]
=
fac
*
(
c0
*
c0
+
c
[
0
]
*
c
[
0
]
-
c
[
1
]
*
c
[
1
]
-
c
[
2
]
*
c
[
2
]);
out
[
0
][
1
]
=
fac
*
(
2
*
(
c
[
0
]
*
c
[
1
]
+
c0
*
c
[
2
]));
out
[
0
][
2
]
=
fac
*
(
2
*
(
c
[
0
]
*
c
[
2
]
-
c0
*
c
[
1
]));
out
[
1
][
0
]
=
fac
*
(
2
*
(
c
[
0
]
*
c
[
1
]
-
c0
*
c
[
2
]));
out
[
1
][
1
]
=
fac
*
(
c0
*
c0
-
c
[
0
]
*
c
[
0
]
+
c
[
1
]
*
c
[
1
]
-
c
[
2
]
*
c
[
2
]);
out
[
1
][
2
]
=
fac
*
(
2
*
(
c
[
1
]
*
c
[
2
]
+
c0
*
c
[
0
]));
out
[
2
][
0
]
=
fac
*
(
2
*
(
c
[
0
]
*
c
[
2
]
+
c0
*
c
[
1
]));
out
[
2
][
1
]
=
fac
*
(
2
*
(
c
[
1
]
*
c
[
2
]
-
c0
*
c
[
0
]));
out
[
2
][
2
]
=
fac
*
(
c0
*
c0
-
c
[
0
]
*
c
[
0
]
-
c
[
1
]
*
c
[
1
]
+
c
[
2
]
*
c
[
2
]);
}
void
gebt_writeSolToFile
(
Gebt
*
bm
,
char
*
fileName
)
...
...
@@ -670,9 +749,15 @@ void gebt_writeSolToFile(Gebt *bm,char* fileName)
char
fname
[
32
];
FILE
*
fid
;
for
(
k
=
0
;
k
<
bm
->
nstep
;
k
++
){
if
(
bm
->
lastStep
<
0
)
{
printf
(
"Unable to write the solution: No time-step have been performed with bm_analysis"
);
exit
(
EXIT_FAILURE
);
}
sprintf
(
fname
,
"%s%03d.dat"
,
fileName
,
k
);
//for (k=0;k<bm->nstep;k++){
k
=
bm
->
lastStep
;
sprintf
(
fname
,
"%s.dat"
,
fileName
);
fid
=
fopen
(
fname
,
"w"
);
if
(
fid
==
NULL
)
{
...
...
@@ -680,6 +765,7 @@ void gebt_writeSolToFile(Gebt *bm,char* fileName)
exit
(
EXIT_FAILURE
);
}
fprintf
(
fid
,
"Time = %f
\n
"
,
bm
->
t
);
for
(
i
=
0
;
i
<
bm
->
nkp
;
i
++
)
{
for
(
j
=
0
;
j
<
NDIM
+
NDOF_ND
;
j
++
)
...
...
@@ -698,7 +784,7 @@ void gebt_writeSolToFile(Gebt *bm,char* fileName)
fprintf
(
fid
,
"
\n
"
);
}
fclose
(
fid
);
}
//
}
}
...
...
@@ -770,6 +856,10 @@ void gebt_analysis(Gebt *bm)
material_tmp
[
i
]
=
rav_material
[
i
];
}
// In case dt or nstep have been changed, must recompute the simu-time because fortran uses it to compute the dt.
bm
->
simu_time
[
0
]
=
0
.
0
;
bm
->
simu_time
[
1
]
=
bm
->
nstep
*
bm
->
dt
;
// Call the fortran function
fortran_analysis
(
bm
->
nkp
,
bm
->
nelem
,
bm
->
ndof_el
,
bm
->
nmemb
,
bm
->
ncond_pt
,
bm
->
nmate
,
bm
->
nframe
,
bm
->
ndistrfun
,
bm
->
ncurv
,
&
rav_coord
,
&
rav_member
,
&
(
bm
->
pt_condition
),
&
material_tmp
,
bm
->
niter
,
bm
->
nstep
,
...
...
@@ -793,6 +883,8 @@ void gebt_analysis(Gebt *bm)
// Set initialize to zero to perform dynamic analysis without redoing the initialization step
bm
->
initialize
=
0
;
bm
->
lastStep
=
bm
->
nstep
-
1
;
bm
->
t
+=
bm
->
nstep
*
bm
->
dt
;
free
(
rav_eigen_val
);
free
(
rav_eigen_vec_mb
);
...
...
@@ -918,7 +1010,7 @@ static void gebt_interpolateMatrix(double **out, double x, double *xp, double **
if
(
idx
==
0
)
{
if
(
np
>
1
){
printf
(
"Warning: in Matrix Interpolation : value of xp=%f is below or equal to xp[0]=%f
\n
"
,
x
,
xp
[
0
]);}
//
if (np>1){ printf("Warning: in Matrix Interpolation : value of xp=%f is below or equal to xp[0]=%f \n",x,xp[0]);}
for
(
i
=
0
;
i
<
nx
;
i
++
)
{
for
(
j
=
0
;
j
<
ny
;
j
++
)
...
...
@@ -929,7 +1021,7 @@ static void gebt_interpolateMatrix(double **out, double x, double *xp, double **
}
else
if
(
idx
==
np
)
{
if
(
np
>
1
)
printf
(
"Warning: in Matrix Interpolation : value of xp=%f is higher than xp[np-1]=%f
\n
"
,
x
,
xp
[
np
-
1
]);
//
if (np>1) printf("Warning: in Matrix Interpolation : value of xp=%f is higher than xp[np-1]=%f \n",x,xp[np-1]);
for
(
i
=
0
;
i
<
nx
;
i
++
)
{
for
(
j
=
0
;
j
<
ny
;
j
++
)
...
...
src/interface/gebt.h
View file @
b41cec3f
...
...
@@ -144,8 +144,9 @@ typedef struct
// Personal add
double
L
;
// Beam Length
int
initFromFile
;
double
dt
;
double
dt
,
t
;
int
initialize
;
// flag indicating if an initialisation step is required to find the compatible state variables
int
lastStep
;
// number of the last solved step
}
Gebt
;
...
...
@@ -166,6 +167,8 @@ void gebt_getMemberVelocities(double **vel, Gebt *bm);
void
gebt_getNodeDisplacement
(
double
**
disp
,
Gebt
*
bm
);
void
gebt_getMemberDisplacement
(
double
**
disp
,
Gebt
*
bm
);
void
gebt_getRotationMatrix
(
double
out
[
3
][
3
],
double
c
[
3
]);
void
gebt_writeGebtToFile
(
Gebt
*
bm
,
char
*
fname
);
void
gebt_writeSolToFile
(
Gebt
*
bm
,
char
*
fileName
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment