|
Basilisk CFD
Adaptive Cartesian mesh PDE framework
|
Go to the source code of this file.
Data Structures | |
| struct | DisplayClient |
| struct | kh_strhash_s |
| struct | DisplayControl |
Macros | |
| #define | DISPLAY_JS "http://basilisk.ida.upmc.fr/three.js/editor/index.html" |
| #define | DISPLAY_HOST "localhost" |
| #define | DISPLAY_RANGE "7100:7200" |
| #define | debug(...) do { if (Display.debug) fprintf (qerr, __VA_ARGS__), fflush(qerr); } while(0) |
| #define | JSON_BUILD(...) |
| #define | display_control(val, ...) |
Typedefs | |
| typedef struct kh_strhash_s | kh_strhash_t |
Variables | ||
| struct { | ||
| kh_strhash_t * objects | ||
| int sock | ||
| int port | ||
| char * error | ||
| Array * controls | ||
| bool debug | ||
| } | Display = { .sock = -1 } | |
| int | display_usage = 20 | |
| int | display_play = 0 < 0 ? -1 : 0 | |
| #define DISPLAY_JS "http://basilisk.ida.upmc.fr/three.js/editor/index.html" |
This file implements the server-side of the interactive display of a running Basilisk code. The client-side is typically done by the javascript implementation.
This works using two main components:
The wsServer WebSocket library Vertex buffers
The initial state of the display can be controlled using the DISPLAY macro, following these rules:
-DDISPLAY=1, -DDISPLAY: play controls, start running immediately. -DDISPLAY=-1: play controls, initially paused. -DDISPLAY=0: no play controls, start running immediately. #include "display.h": play controls, initially paused.
This can also be changed by setting display_play = 0; in main().
Multiple servers can run simultaneously on the same machine but must use different ports. When connecting, the server looks for a free port in the default range (typically 7100 to 7200, see the DISPLAY_RANGE macro below). The corresponding connection information (including the URL of the javascript interface) is written in the display.html file, which can be used to open the connection on the client side (i.e. the web browser).
The values of integer or double variables can be controlled interactively using the display_control() macro, for example:
where the first argument is the name of the variable and the numbers indicate the (optional) range (min and max values). The (optional) name and tooltip are used to generate the Basilisk View interface. The only compulsory argument is the variable name.
Default drawing function calls, which will be sent to an empty javascript client, can be setup using something like:
where the single quotes will be expanded to doubles quotes when interpreted. Do not forget the trailing semi-column.
Note that these function calls will be appended to existing ones. To overwrite existing calls, use:
| #define JSON_BUILD | ( | ... | ) |
Definition at line 493 of file display.h.
References bview_interface, i, json, JSON_BUILD, realloc(), and x.
Referenced by display_onopen().
Definition at line 140 of file display.h.
References debug, Display, fflush(), fp, free(), line, process_line(), read_file_into_buffer(), strdup(), vertex_buffer_setup(), VertexBuffer, and x.
Referenced by display_update().
| void display_control_internal | ( | void * | ptr, |
| double | min, | ||
| double | max, | ||
| char * | name = NULL, |
||
| char * | tooltip = NULL, |
||
| char * | ptr_name, | ||
| int | size | ||
| ) |
Definition at line 435 of file display.h.
References array_append(), controls, d, Display, display_control_json(), display_control_lookup(), free(), max, min, DisplayControl::name, size, sizeof(), strdup(), and x.
Definition at line 396 of file display.h.
References assert, d, Display, i, JSON_BUILD, and x.
Referenced by display_control_internal(), display_control_update(), and display_onopen().
|
static |
Definition at line 426 of file display.h.
References d, Display, i, and x.
Referenced by display_control_internal(), and display_control_update().
Definition at line 465 of file display.h.
References assert, clamp(), controls, d, debug, display_control_json(), display_control_lookup(), free(), s, strdup(), val(), and x.
Referenced by display_onmessage().
Definition at line 106 of file display.h.
References debug, Display, k, kh_begin, kh_end, kh_exist, kh_key, kh_value, and x.
Referenced by display_add(), display_onclose(), and display_remove().
| init_solver void display_init | ( | ) |
Definition at line 746 of file display.h.
References array_new(), Display, display_control, display_destroy(), display_play, DISPLAY_RANGE, display_url(), display_usage, fp, free(), free_solver_func_add(), kh_init, port, s, strdup(), and x.
Definition at line 512 of file display.h.
References array_remove(), debug, Display, display_display(), k, kh_begin, kh_end, and kh_exist.
Referenced by display_onopen(), display_poll(), and display_update().
Definition at line 522 of file display.h.
References display_add(), display_control_update(), display_remove(), type, and x.
Referenced by display_poll().
Definition at line 542 of file display.h.
References bview_interface_json(), controls, debug, display_control_json(), display_defaults, display_onclose(), free(), and x.
Referenced by display_poll().
Definition at line 645 of file display.h.
References array_free(), assert, calloc(), Display, display_onclose(), display_onmessage(), display_onopen(), and x.
Referenced by event_refresh_display(), and main().
Definition at line 377 of file display.h.
References array_remove(), debug, Display, display_display(), k, kh_end, kh_get, and x.
Referenced by display_onmessage().
Definition at line 248 of file display.h.
References c, debug, Display, free(), i, int, npe, type, VertexBuffer, ws_send_array(), and x.
Referenced by display_update().
Definition at line 569 of file display.h.
References debug, Display, display_command(), display_onclose(), display_send(), free(), i, k, kh_begin, kh_del, kh_end, kh_exist, kh_key, kh_value, vertex_buffer_free(), and x.
Referenced by event_refresh_display(), and main().
Definition at line 697 of file display.h.
References Display, DISPLAY_JS, fp, h, LINENO, and x.
Referenced by display_init(), and main().
Event: refresh_display (i++, last)
Definition at line 798 of file display.h.
References display_play, display_poll(), display_update(), display_usage, i, timer_elapsed(), timer_start(), and x.
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
| Array* controls |
Definition at line 102 of file display.h.
Referenced by display_control_internal(), display_control_update(), and display_onopen().
| struct { ... } Display |
Referenced by array_remove(), display_add(), display_command(), display_control_internal(), display_control_json(), display_control_lookup(), display_destroy(), display_display(), display_init(), display_onclose(), display_poll(), display_remove(), display_send(), display_update(), display_url(), and main().
| int display_play = 0 < 0 ? -1 : 0 |
Definition at line 715 of file display.h.
Referenced by display_init(), and event_refresh_display().
| int display_usage = 20 |
Definition at line 711 of file display.h.
Referenced by display_init(), and event_refresh_display().
| char* error |
Definition at line 101 of file display.h.
Referenced by createShaderFromString(), input_fatal_error(), and merge().
| kh_strhash_t* objects |
| int port |
Definition at line 100 of file display.h.
Referenced by display_init().