Compare commits

...

2 Commits

Author SHA1 Message Date
tTh 11d1cfd7de en avant comme avant ! 2023-02-11 17:05:58 +01:00
tTh 6c9f562c13 this part need a lot of more work ! 2023-02-11 17:00:58 +01:00
17 changed files with 118 additions and 50 deletions

9
C_Binding/Makefile Normal file
View File

@ -0,0 +1,9 @@
all: single_function.o single_subroutine.o
single_function.o: single_function.c Makefile
gcc -Wall -g -c $<
single_subroutine.o: single_subroutine.c Makefile
gcc -Wall -g -c $<

6
C_Binding/README.md Normal file
View File

@ -0,0 +1,6 @@
`Sat Feb 11 15:46:25 UTC 2023`
Il serait temps de s'y mettre.

View File

@ -0,0 +1,10 @@
#include <stdio.h>
long tth_getpid(int option)
{
fprintf(stderr, ">>> %s ( %d )\n", __func__, option);
return 42L;
}

View File

@ -0,0 +1,9 @@
#include <stdio.h>
void tth_dumpmem(int option, void *ptr)
{
fprintf(stderr, ">>> %s ( %d %p )\n", __func__, option, ptr);
/* It's a subroutine so NO return */
}

View File

@ -1,6 +1,7 @@
essai essai
animation animation
realdump2png
WS/*.pgm WS/*.pgm
WS/*.png WS/*.png

View File

@ -5,7 +5,7 @@
GFOPT = -Wall -Wextra -g -time -I../Modules GFOPT = -Wall -Wextra -g -time -I../Modules
MODOBJ = ../Modules/spitpgm.o ../Modules/pixrgb.o MODOBJ = ../Modules/spitpgm.o ../Modules/pixrgb.o
all: essai animation all: essai animation realdump2png
# ----------- modules # ----------- modules
@ -20,4 +20,7 @@ essai: essai.f90 Makefile realfield.o
animation: animation.f90 Makefile realfield.o animation: animation.f90 Makefile realfield.o
gfortran $(GFOPT) $< realfield.o $(MODOBJ) -o $@ gfortran $(GFOPT) $< realfield.o $(MODOBJ) -o $@
#- realdump2png: realdump2png.f90 Makefile realfield.o
gfortran $(GFOPT) $< realfield.o $(MODOBJ) -o $@
#- remember bro: yolo forever :)

View File

@ -1,2 +0,0 @@
# placeholder

View File

@ -1,2 +0,0 @@
# placeholder

View File

@ -1,2 +0,0 @@
# placeholder

View File

@ -13,18 +13,16 @@ program animation
implicit none implicit none
! some configuration constants ! some configuration constants
integer, parameter :: S_WIDTH = 1024 integer, parameter :: S_WIDTH = 2048
integer, parameter :: S_HEIGHT = 1024 integer, parameter :: S_HEIGHT = 2048
integer, parameter :: NB_BODY = 51 integer, parameter :: NB_BODY = 250
!!! WARNING : global variable !!! !!! WARNING : global variable !!!
type(massbody) :: planets(NB_BODY) type(massbody) :: planets(NB_BODY)
call init_random() call init_random()
call create_some_planets(planets, 1664e3, S_WIDTH , S_HEIGHT) call create_some_planets(planets, 1664e3, S_WIDTH , S_HEIGHT)
call print_barycentre_bodies(planets) call print_barycentre_bodies(planets, 'begin')
! STOP 'BEFORE CRASH'
call la_grande_boucle(0, 2000, planets) call la_grande_boucle(0, 2000, planets)
@ -33,7 +31,7 @@ program animation
!----------------------------------------------------------------------- !-----------------------------------------------------------------------
contains contains
!- !-
! fabrication d'une de la sequence complete ! fabrication de la sequence complete
!- !-
subroutine la_grande_boucle(start, nbre, moons) subroutine la_grande_boucle(start, nbre, moons)
integer, intent(in) :: start, nbre integer, intent(in) :: start, nbre
@ -47,19 +45,21 @@ subroutine la_grande_boucle(start, nbre, moons)
! else use ?????ing ! else use ?????ing
call deplace_les_planetes(moons, .TRUE.) call deplace_les_planetes(moons, .TRUE.)
! computing the field (used as a HF in Povray
write (filename, "(a, i5.5, a)") 'WS/nanim/', pass, '.pgm' write (filename, "(a, i5.5, a)") 'WS/nanim/', pass, '.pgm'
write(0, '(3I5, " * ", a20)') start, nbre, pass, filename write(0, '(3I5, " * ", a20)') start, nbre, pass, filename
call build_and_write_a_field(S_WIDTH, S_HEIGHT, moons, filename) call build_and_write_a_field(S_WIDTH, S_HEIGHT, moons, filename)
write (filename, "(a, i5.5, a)") 'WS/data/', pass, '.txt' ! save the current bodies positions (can be used in gnuplot)
call save_bodies_to_txt_file (planets, filename) ! write (filename, "(a, i5.5, a)") 'WS/data/', pass, '.txt'
! call save_bodies_to_txt_file (planets, filename)
write (filename, "(a, i5.5, a)") 'WS/colmap/', pass, '.pnm' write (filename, "(a, i5.5, a)") 'WS/colmap/', pass, '.pnm'
call make_color_map(planets, filename, S_WIDTH, S_HEIGHT) call make_color_map(planets, filename, S_WIDTH, S_HEIGHT)
enddo enddo
call print_barycentre_bodies(moons) call print_barycentre_bodies(moons, 'end')
end subroutine end subroutine
@ -107,14 +107,14 @@ subroutine make_color_map(moons, fname, width, height)
endif endif
end do ! loop on all the moons, ipl index end do ! loop on all the moons, ipl index
cmap(ix, iy)%r = mod(near*13, 255) cmap(ix, iy)%r = mod(near*3, 255)
cmap(ix, iy)%g = mod(near*14, 255) cmap(ix, iy)%g = mod(near*4, 255)
cmap(ix, iy)%b = mod(near*15, 255) cmap(ix, iy)%b = mod(near*5, 255)
enddo enddo
enddo enddo
call rgbpix_spit_as_pnm(cmap, fname) call rgbpix_spit_as_pnm_8(cmap, fname)
deallocate(cmap) deallocate(cmap)
@ -131,9 +131,9 @@ subroutine deplace_les_planetes(moons, clipit)
logical, intent(in) :: clipit logical, intent(in) :: clipit
integer :: foo integer :: foo
real :: depx, depy real :: depx, depy, coef
integer, parameter :: EE = 51 integer, parameter :: EE = 100
integer :: SW = S_WIDTH - EE integer :: SW = S_WIDTH - EE
integer :: SH = S_HEIGHT - EE integer :: SH = S_HEIGHT - EE
@ -162,7 +162,12 @@ subroutine deplace_les_planetes(moons, clipit)
if (moons(foo)%posy .LT. EE) moons(foo)%posy = SH if (moons(foo)%posy .LT. EE) moons(foo)%posy = SH
endif endif
moons(foo)%heading = moons(foo)%heading + (0.78*(rand()-0.50)) if (rand() .LT. 0.15) then
coef = 1.63
else
coef = 0.78
endif
moons(foo)%heading = moons(foo)%heading + (coef*(rand()-0.42))
if (moons(foo)%heading .GT. 6.283185307) moons(foo)%heading = 0.0 if (moons(foo)%heading .GT. 6.283185307) moons(foo)%heading = 0.0
if (moons(foo)%heading .LT. 0.000000001) moons(foo)%heading = 0.0 if (moons(foo)%heading .LT. 0.000000001) moons(foo)%heading = 0.0

View File

@ -23,7 +23,7 @@ echo "file type :" $filetype
case $filetype in case $filetype in
PNG) extension=".png" ;; PNG) extension=".png" ;;
Netpbm) extension=".pgm" ;; Netpbm) extension=".pgm" ;;
*) extension=".binary" ;; *) extension=".pnm" ;;
esac esac
echo "extension :" $extension echo "extension :" $extension

View File

@ -12,7 +12,7 @@ program essai
call init_random() call init_random()
call essai_near_planet(1024, 1024) call essai_near_planet(2048, 2048)
STOP 'BECAUSE YOLO' STOP 'BECAUSE YOLO'
@ -74,7 +74,7 @@ subroutine essai_near_planet(nbplanets, szfield)
enddo enddo
call rgbpix_spit_as_pnm(cmap, "rgb.pnm") call rgbpix_spit_as_pnm_8(cmap, "rgb.pnm")
end subroutine end subroutine
!----------------------------------------------------------------------- !-----------------------------------------------------------------------

View File

@ -2,7 +2,7 @@
set -e set -e
POVOPT=" -q9 +a -W1024 -H768 +WT2 -d -v " POVOPT=" -q9 +a -W1280 -H1024 +WT2 -d -v "
SOURCE="vision.pov" SOURCE="vision.pov"
TMPF="/dev/shm/gravfield.png" TMPF="/dev/shm/gravfield.png"
@ -29,10 +29,12 @@ convert ${TMPF} \
-fill Orange \ -fill Orange \
-annotate +15+22 "$timestamp" \ -annotate +15+22 "$timestamp" \
-annotate +15+48 "$texte" \ -annotate +15+48 "$texte" \
-pointsize 16 \ -pointsize 14 \
-gravity south-west \ -gravity south-west \
-annotate +15+9 "tTh & Konrad" \ -annotate +15+9 "tTh & Konrad" \
${outfile} ${outfile}
sleep 3
} }
# --------------------------------------- # ---------------------------------------
@ -51,5 +53,6 @@ ffmpeg -nostdin \
-metadata artist='---{ tTh and Konrad }---' \ -metadata artist='---{ tTh and Konrad }---' \
-metadata title="Experiment on Gravity Field" \ -metadata title="Experiment on Gravity Field" \
-c:v libx264 -pix_fmt yuv420p \ -c:v libx264 -pix_fmt yuv420p \
bar.mp4 -preset veryslow \
gravity-field.mp4

View File

@ -0,0 +1,23 @@
!-----------------------------------------------------------------------
!-
! convertir un dum de champ de reel en .PNG
! nouveau 17 decembre 2022
!-
!-----------------------------------------------------------------------
program realdump2png
use realfield
implicit none
stop "BECAUSE I'M TIRED *NOW*"
contains
!-----------------------------------------------------------------------
subroutine load_a_dump_file(fname, location)
character(len=*), intent(in) :: fname
real, dimension(:,:), intent(inout) :: location
end subroutine
!-----------------------------------------------------------------------
end program
!-----------------------------------------------------------------------

View File

@ -29,7 +29,7 @@ subroutine compute_barycentre_bodies(astres, bcx, bcy)
integer :: foo integer :: foo
real :: cx, cy real :: cx, cy
! May be we have to use DOUBLE RPECSION here ? ! May be we have to use DOUBLE PRECSION here ?
cx = 0.0 cx = 0.0
cy = 0.0 cy = 0.0
do foo=1, ubound(astres, 1) do foo=1, ubound(astres, 1)
@ -40,12 +40,13 @@ subroutine compute_barycentre_bodies(astres, bcx, bcy)
bcy = cy / real(ubound(astres, 1)) bcy = cy / real(ubound(astres, 1))
end subroutine end subroutine
!----------------------------------------------------------------------- !-----------------------------------------------------------------------
subroutine print_barycentre_bodies(astres) subroutine print_barycentre_bodies(astres, title)
type(massbody), intent(in) :: astres(:) type(massbody), intent(in) :: astres(:)
real :: cx, cy character(len=*), intent(in) :: title
real :: cx, cy
call compute_barycentre_bodies(astres, cx, cy) call compute_barycentre_bodies(astres, cx, cy)
print *, "barycentre : ", cx, cy print *, "barycentre {", title, "} ", cx, cy
end subroutine end subroutine
!----------------------------------------------------------------------- !-----------------------------------------------------------------------
@ -81,8 +82,8 @@ subroutine create_some_planets(planets, coef, sx, sy)
!- !-
planets(foo)%posx = rand() * real(sx-1) planets(foo)%posx = rand() * real(sx-1)
planets(foo)%posy = rand() * real(sy-1) planets(foo)%posy = rand() * real(sy-1)
planets(foo)%mass = 7e6 + coef*foo planets(foo)%mass = 7.12e6 + coef*foo
planets(foo)%heading = 2 * 3.14159 * rand() planets(foo)%heading = 2 * 3.141592654 * rand()
if (rand() .LT. 0.15) planets(foo)%speed = 3.14159 if (rand() .LT. 0.15) planets(foo)%speed = 3.14159
planets(foo)%serial = foo*2 + 120 planets(foo)%serial = foo*2 + 120
endif endif

View File

@ -4,9 +4,13 @@ set -e # stop on error
make animation make animation
date > animation.log LOG="log.animation"
time ./animation | tee animation.log date >> $LOG
./encode.sh WS/nanim/ quux.mp4 time ./animation | tee -a $LOG
./encode.sh WS/colmap/ zzz.mp4
./encode.sh WS/nanim/ gravity-field.mp4
./encode.sh WS/colmap/ gravity-colmap.mp4
ls -rtl *.mp4 >> $LOG

View File

@ -45,7 +45,7 @@ texture {
} }
} }
object { GravityField scale <4, 0.60, 4> } object { GravityField scale <4.10, 0.60, 4.10> }
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
@ -58,13 +58,13 @@ merge {
XXX */ XXX */
light_source { < -2, 9.3, -7> color Gray90 } light_source { < -2, 9.3, -7> color Gray90 }
light_source { < -6, 9.3, -8> color Orange*0.75 } light_source { < -6, 9.3, -8> color Orange*0.65 }
light_source { < -15, 2.3, 17> color Green*0.25 } light_source { < -15, 2.3, 17> color Gray70 }
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
camera { camera {
location <-8, 4-(1.5*NormClock), 1 + (5*NormClock)> location <-8, 4-(1.7*NormClock), -4 + (11.66*NormClock)>
look_at <0, 0, 0> look_at <0, 0, 0>
right x*image_width/image_height right x*image_width/image_height
angle 33 angle 33