src-local/dye-injection.h
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 dyexInjection
,yInjection
: position where the dye is injecteddyeRadius
: 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* tracers = {T};
scalar
// Initialize the dye tracer to zero everywhere
(t = 0) {
event init ()
foreach[] = 0.0;
T}
// Inject the dye at the specified time
(t = tInjection) {
event inject_dye (stderr, "Injecting dye at t = %g, position = (%g, %g), radius = %g\n",
fprintf, xInjection, yInjection, dyeRadius);
t
// Set dye concentration to 1.0 within the circular region
() {
foreachdouble dist = sqrt(sq(x - xInjection) + sq(y - yInjection));
if (dist <= dyeRadius)
[] = 1.0;
T}
}