You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This work introduces HydroCompute, a computational library for hydrology and environmental sciences that runs on the client side. It employes 4 different engines, 3 main computations and 1 for peer-to-peer connection. The library has been developed using ES6 standards and the most recent available APIs for WebAssembly, WebGPU, WebRTC, and the Web Workers specifications.
19
+
This work introduces hydroCompute, a computational library for hydrology and environmental sciences that runs on the client side. It employs distributed computing environments including **JavaScript** (Native & HydroLang), **Python** (Pyodide), **R** (WebR), and **WebGPU**, along with **WebRTC** for peer-to-peer connectivity. The library has been developed using ES6 standards and the most recent available APIs for WebAssembly, WebGPU, WebRTC, and the Web Workers specifications.
20
+
21
+
## Database Integration
22
+
HydroCompute now integrates **HydroComputeDB**, a robust wrapper around IndexedDB, to manage data persistence across sessions and workers. This ensures that large datasets and simulation results are stored efficiently in the browser without blocking the main thread. The database manages several stores:
23
+
*`settings`: Stores configuration and code snippets for dynamic execution.
24
+
*`workflowStates`: Manages the state of complex, multi-step workflows.
25
+
*`results`: Stores the output of computations, linked by execution IDs.
26
+
*`wasmModules`: Caches compiled WebAssembly modules for faster loading.
19
27
20
28
## How to Use
21
29
Please download the library and run `index.html`. If a new html file should be created, the library must be onloaded onto the file as a script
@@ -30,21 +38,18 @@ Please download the library and run `index.html`. If a new html file should be c
30
38
The library is loaded into an HTML web app by declaring either it as a window object when loading, or as a single instance run as follows:
31
39
32
40
```javascript
33
-
constcompute=newhydrocompute('engineName');
41
+
constcompute=newhydroCompute('engineName');
34
42
```
35
43
36
-
When instantiated if no specific engines are passed into the constructor, the library will default to run using the functions within the JavaScript engine. The available engines along with existing code and how to develop more functions for usage in the library can be found in the following links:
37
-
38
-
*[WebAssembly](https://github.com/uihilab/HydroCompute/tree/master/src/wasm): Available C and AssemblyScript bindings.
39
-
*[JavaScript](https://github.com/uihilab/HydroCompute/tree/master/src/javascript): Available as native JavaScript object.
40
-
*[WebGPU](https://github.com/uihilab/HydroCompute/tree/master/src/webgpu): GLSL code onloaded as strings in a JavaScript object.
44
+
When instantiated if no specific engines are passed into the constructor, the library will default to run using the functions within the JavaScript engine.
41
45
42
-
### Running a simulation
46
+
### Running a Simulation
43
47
44
48
By default, the hydrocompute library runs need 3 specific instructions settings: data, steps, and functions. The data submitted to the library is saved using the following instruction:
engine: ['python', 'webr', 'javascript'], // Define engine per step if supported (or set individually)
174
+
// Note: Actual mixed-engine runs rely on the 'type' param per step or switching engines between runs.
175
+
// A common pattern is to run them sequentially and link via Data IDs.
176
+
});
177
+
```
178
+
</details>
179
+
75
180
The console of the browser will show the number of executions done by the engine once the results are finished. To retrieve the results, prompt the following command.
This "Big Example" demonstrates the power of HydroCompute by chaining multiple engines into a single, cohesive hydrological workflow.
5
+
6
+
## The Workflow
7
+
1.**Input**: Raw rainfall time series and digital elevation model (DEM).
8
+
2.**Step 1 (JavaScript)**: Calculate precipitation statistics (Mean/Max) to characterize the storm event.
9
+
3.**Step 2 (Python)**: Smooth the resulting hydrograph to remove sensor noise and identify peak flow timing.
10
+
4.**Step 3 (R)**: Perform Flood Frequency Analysis to determine the return period of this specific event (e.g., "Is this a 50-year flood?").
11
+
5.**Step 4 (WASM)**: Map the flow accumulation paths to visualize where the water goes.
12
+
13
+
## Implementation
14
+
This example uses a `main.js` that orchestrates calls to different engines sequentially, passing data between steps (simulated or real). It serves as a dashboard for a complete hydrological analysis.
0 commit comments