-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdye-injection.h
44 lines (36 loc) · 1.35 KB
/
dye-injection.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/**
# dye Injection for Flow Visualization
This module introduces a circular tracer (dye) into the flow at a specified time
and location. The dye then advects with the flow, allowing visualization of flow
patterns. This is useful for visualizing complex flow structures in simulations
like lid-driven cavity flow.
## Parameters
- `tInjection`: time at which to inject the dye
- `xInjection`, `yInjection`: position where the dye is injected
- `dyeRadius`: radius of the circular dye
*/
#include "tracer.h"
// dye tracer parameters (can be overridden by the user)
double tInjection = 0.1; // Default injection time
double xInjection = 0.0; // Default X-position for injection
double yInjection = 0.0; // Default Y-position for injection
double dyeRadius = 0.05; // Default radius of the circular dye
// Define the scalar field for the dye
scalar T[];
scalar * tracers = {T};
// Initialize the dye tracer to zero everywhere
event init (t = 0) {
foreach()
T[] = 0.0;
}
// Inject the dye at the specified time
event inject_dye (t = tInjection) {
fprintf(stderr, "Injecting dye at t = %g, position = (%g, %g), radius = %g\n",
t, xInjection, yInjection, dyeRadius);
// Set dye concentration to 1.0 within the circular region
foreach() {
double dist = sqrt(sq(x - xInjection) + sq(y - yInjection));
if (dist <= dyeRadius)
T[] = 1.0;
}
}