-
Notifications
You must be signed in to change notification settings - Fork 227
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
472 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
export OPENGL=0# Set this to 1 to enable OpenGL | ||
export SERVER=1# Set this to 1 to enable the visualization web server | ||
include ../../src/Makefile.defs | ||
|
||
# CCPROBLEM is defined in Makefile.defs to allow for | ||
# a compact cross platform Makefile | ||
.PHONY: all librebound | ||
all: problem.c librebound | ||
@echo "Compiling $< ..." | ||
$(CCPROBLEM) | ||
@echo "" | ||
@echo "Compilation successful. To run REBOUND, execute the file '$(EXEREBOUND)'." | ||
@echo "" | ||
|
||
librebound: | ||
@echo "Compiling shared library $(LIBREBOUND) ..." | ||
$(MAKE) -C ../../src/ | ||
@-$(RM) $(LIBREBOUND) | ||
@$(LINKORCOPYLIBREBOUND) | ||
@echo "" | ||
|
||
clean: | ||
@echo "Cleaning up shared library $(LIBREBOUND) ..." | ||
$(MAKE) -C ../../src/ clean | ||
@echo "Cleaning up local directory ..." | ||
@-$(RM) $(LIBREBOUND) | ||
@-$(RM) $(EXEREBOUND) | ||
|
||
rebound_webgl.html: problem.c | ||
@echo "Compiling problem.c with emscripten (WebGL enabled)..." | ||
emcc -O3 -I../../src/ ../../src/*.c problem.c -DSERVERHIDEWARNING -DOPENGL=1 -sSTACK_SIZE=655360 -s USE_GLFW=3 -s FULL_ES3=1 -sASYNCIFY -sALLOW_MEMORY_GROWTH -sSINGLE_FILE -sEXPORTED_RUNTIME_METHODS="callMain" --shell-file ../../web_client/shell_rebound_webgl.html -o rebound_webgl.html | ||
|
||
rebound_console.html: problem.c | ||
@echo "Compiling problem.c with emscripten (WebGL disabled)..." | ||
emcc -O3 -I../../src/ ../../src/*.c problem.c -DSERVERHIDEWARNING -sSTACK_SIZE=655360 -sASYNCIFY -sALLOW_MEMORY_GROWTH -sSINGLE_FILE -sEXPORTED_RUNTIME_METHODS="callMain" --shell-file ../../web_client/shell_rebound_console.html -o rebound_console.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/** | ||
* Screenshots | ||
* | ||
* This example shows how to take a screenshot of a REBOUND | ||
* simulation at the beginning of the simulation and once | ||
* every 400 timesteps during the integration. You need to | ||
* compile REBOUND with SERVER=1 and connect a webbrowser | ||
* to the simulation. Only then can you take screenshots. | ||
* You might also be interested in the examples: | ||
* 1) animation_saturns_rings and | ||
* 2) animation_solar_system. | ||
* They show how one can programatically change the | ||
* visualization. You can combine this with taking | ||
* screenshots if you want to record animations of REBOUND | ||
* simulations. | ||
* | ||
*/ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <math.h> | ||
#include "rebound.h" | ||
|
||
void heartbeat(struct reb_simulation* const r){ | ||
if (r->steps_done%400==0){ // Every 400 timesteps | ||
int id = r->steps_done/400; | ||
char filename[1024]; | ||
sprintf(filename, "screenshot_%05d.png", id); | ||
if (reb_simulation_output_screenshot(r, filename)){ | ||
printf("Screenshot saved: %s\n", filename); | ||
} | ||
} | ||
} | ||
|
||
int main(int argc, char* argv[]) { | ||
struct reb_simulation* r = reb_simulation_create(); | ||
r->integrator = REB_INTEGRATOR_WHFAST; | ||
r->heartbeat = heartbeat; | ||
|
||
// Initial conditions | ||
reb_simulation_add_fmt(r, "m", 1.); // star | ||
reb_simulation_add_fmt(r, "m a", 1e-3, 1.); // planet 1 | ||
reb_simulation_add_fmt(r, "m a", 1e-3, 2.); // planet 2 | ||
reb_simulation_move_to_com(r); | ||
|
||
// Start the web server. Make sure you point your | ||
// webbrowser to http://localhost:1234 | ||
reb_simulation_start_server(r, 1234); | ||
|
||
// Manually take a screenshot of the initial conditions. | ||
// The program will pause here until you connect a | ||
// webbrowser and a screenshot can be taken. | ||
reb_simulation_output_screenshot(r, "screenshot_initial.png"); | ||
printf("Screenshot saved: screenshot_initial.png\n"); | ||
|
||
// Start integration. | ||
reb_simulation_integrate(r, 10); | ||
|
||
// Manually take a screenshot of the final simulation | ||
reb_simulation_output_screenshot(r, "screenshot_final.png"); | ||
printf("Screenshot saved: screenshot_final.png\n"); | ||
|
||
// Cleanup | ||
reb_simulation_free(r); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.