Karman Vortex trials

This commit is contained in:
Aditya Ujeniya 2023-10-03 13:10:41 +02:00
parent 2fe1b67fe9
commit d02b0f9e3d
11 changed files with 20034 additions and 20024 deletions

View File

@ -32,7 +32,7 @@ jmax 45 # number of interior cells in y-direction
# Time Data: # Time Data:
# --------- # ---------
te 30.0 # final time te 60.0 # final time
dt 0.02 # time stepsize dt 0.02 # time stepsize
tau 0.5 # safety factor for time stepsize control (<0 constant delt) tau 0.5 # safety factor for time stepsize control (<0 constant delt)
@ -49,7 +49,7 @@ gamma 0.9 # upwind differencing factor gamma
# ----------------------- # -----------------------
numberOfParticles 60 numberOfParticles 60
startTime 0 startTime 100.0
injectTimePeriod 0.5 injectTimePeriod 0.5
writeTimePeriod 0.2 writeTimePeriod 0.2

View File

@ -15,11 +15,11 @@ bcRight 3 #
gx 0.0 # Body forces (e.g. gravity) gx 0.0 # Body forces (e.g. gravity)
gy 0.0 # gy 0.0 #
re 10000.0 # Reynolds number re 5050.0 # Reynolds number
u_init 1.0 # initial value for velocity in x-direction u_init 1.0 # initial value for velocity in x-direction
v_init 0.0 # initial value for velocity in y-direction v_init 0.0 # initial value for velocity in y-direction
p_init 0.0 # initial value for pressure p_init 1.0 # initial value for pressure
# Geometry Data: # Geometry Data:
# ------------- # -------------
@ -32,7 +32,7 @@ jmax 50 # number of interior cells in y-direction
# Time Data: # Time Data:
# --------- # ---------
te 100.0 # final time te 150.0 # final time
dt 0.02 # time stepsize dt 0.02 # time stepsize
tau 0.5 # safety factor for time stepsize control (<0 constant delt) tau 0.5 # safety factor for time stepsize control (<0 constant delt)
@ -48,13 +48,13 @@ gamma 0.9 # upwind differencing factor gamma
# Particle Tracing Data: # Particle Tracing Data:
# ----------------------- # -----------------------
numberOfParticles 60 numberOfParticles 200
startTime 0 startTime 50
injectTimePeriod 0.5 injectTimePeriod 1.0
writeTimePeriod 0.5 writeTimePeriod 0.5
x1 0.0 x1 0.0
y1 1.9 y1 1.8
x2 0.0 x2 0.0
y2 2.1 y2 2.1
@ -63,7 +63,7 @@ y2 2.1
# Shape 0 disable, 1 Rectangle/Square, 2 Circle # Shape 0 disable, 1 Rectangle/Square, 2 Circle
shape 2 shape 2
xCenter 4.0 xCenter 5.0
yCenter 2.0 yCenter 2.0
xRectLength 2.0 xRectLength 2.0
yRectLength 1.0 yRectLength 1.0

File diff suppressed because it is too large Load Diff

View File

@ -78,7 +78,7 @@ int main (int argc, char** argv)
/* Added function for particle tracing. Will inject and advance particles as per timePeriod */ /* Added function for particle tracing. Will inject and advance particles as per timePeriod */
trace(&particletracer, solver.u, solver.v, t); trace(&particletracer, solver.u, solver.v, solver.s, t);
t += solver.dt; t += solver.dt;
nt++; nt++;

View File

@ -14,6 +14,7 @@
#define U(i, j) u[(j) * (imax + 2) + (i)] #define U(i, j) u[(j) * (imax + 2) + (i)]
#define V(i, j) v[(j) * (imax + 2) + (i)] #define V(i, j) v[(j) * (imax + 2) + (i)]
#define S(i, j) s[(j) * (imax + 2) + (i)]
static int ts = 0; static int ts = 0;
void printParticles(ParticleTracer* particletracer) void printParticles(ParticleTracer* particletracer)
@ -37,7 +38,7 @@ void injectParticles(ParticleTracer* particletracer)
} }
} }
void advanceParticles(ParticleTracer* particletracer, double* restrict u, double* restrict v, double time) void advanceParticles(ParticleTracer* particletracer, double* restrict u, double* restrict v, int* restrict s, double time)
{ {
int imax = particletracer->imax; int imax = particletracer->imax;
int jmax = particletracer->jmax; int jmax = particletracer->jmax;
@ -101,6 +102,11 @@ void advanceParticles(ParticleTracer* particletracer, double* restrict u, double
{ {
particletracer->particlePool[i].flag = false; particletracer->particlePool[i].flag = false;
} }
int i_new = new_x/dx, j_new = new_y/dy;
if(S(i_new, j_new) == LOCAL)
{
particletracer->particlePool[i].flag = false;
}
} }
} }
} }
@ -116,10 +122,10 @@ void writeParticles(ParticleTracer* particletracer)
VtkOptions opts = { .particletracer = particletracer }; VtkOptions opts = { .particletracer = particletracer };
char filename[50]; char filename[50];
snprintf(filename, 50, "vtk_files/particles%d.vtk", ts); // snprintf(filename, 50, "vtk_files/particles%d.vtk", ts);
vtkOpen(&opts, filename, ts); // vtkOpen(&opts, filename, ts);
vtkParticle(&opts, "particle"); // vtkParticle(&opts, "particle");
vtkClose(&opts); // vtkClose(&opts);
FILE* fp; FILE* fp;
Particle* particlePool = particletracer->particlePool; Particle* particlePool = particletracer->particlePool;
@ -176,6 +182,7 @@ void initParticleTracer(ParticleTracer* particletracer, Parameter* params)
particletracer->particlePool = malloc(sizeof(Particle) * particletracer->estimatedNumParticles); particletracer->particlePool = malloc(sizeof(Particle) * particletracer->estimatedNumParticles);
particletracer->linSpaceLine = malloc(sizeof(Particle) * particletracer->numberOfParticles); particletracer->linSpaceLine = malloc(sizeof(Particle) * particletracer->numberOfParticles);
for (int i = 0; i < particletracer->numberOfParticles; ++i) for (int i = 0; i < particletracer->numberOfParticles; ++i)
{ {
@ -197,7 +204,7 @@ void printParticleTracerParameters(ParticleTracer* particletracer)
printf("\tdt : %.2f, dx : %.2f, dy : %.2f\n", particletracer->dt, particletracer->dx, particletracer->dy); printf("\tdt : %.2f, dx : %.2f, dy : %.2f\n", particletracer->dt, particletracer->dx, particletracer->dy);
} }
void trace(ParticleTracer* particletracer, double* u, double* v, double time) void trace(ParticleTracer* particletracer, double* u, double* v, int* s, double time)
{ {
if (time >= particletracer->startTime) if (time >= particletracer->startTime)
{ {
@ -213,7 +220,7 @@ void trace(ParticleTracer* particletracer, double* u, double* v, double time)
particletracer->lastWriteTime = time; particletracer->lastWriteTime = time;
} }
advanceParticles(particletracer, u, v, time); advanceParticles(particletracer, u, v, s, time);
compress(particletracer); compress(particletracer);
particletracer->lastUpdateTime = time; particletracer->lastUpdateTime = time;
} }

View File

@ -38,11 +38,11 @@ typedef struct {
void initParticleTracer(ParticleTracer*, Parameter*); void initParticleTracer(ParticleTracer*, Parameter*);
void injectParticles(ParticleTracer*); void injectParticles(ParticleTracer*);
void advanceParticles(ParticleTracer*, double* , double*, double); void advanceParticles(ParticleTracer*, double* , double*, int*, double);
void freeParticles(ParticleTracer*); void freeParticles(ParticleTracer*);
void writeParticles(ParticleTracer*); void writeParticles(ParticleTracer*);
void printParticleTracerParameters(ParticleTracer*); void printParticleTracerParameters(ParticleTracer*);
void printParticles(ParticleTracer*); void printParticles(ParticleTracer*);
void trace(ParticleTracer*, double* , double* , double ); void trace(ParticleTracer*, double* , double* , int* , double );
void compress(ParticleTracer* ); void compress(ParticleTracer* );
#endif #endif

View File

@ -1,5 +1,7 @@
set terminal png size 3600,768 enhanced font ,28 set terminal png size 3600,768 enhanced font ,28
set output 'velocity.png' set output 'velocity.png'
set xrange[0:30]
set yrange[0:4]
set size ratio -1 set size ratio -1
set datafile separator whitespace set datafile separator whitespace

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 289 KiB

After

Width:  |  Height:  |  Size: 206 KiB

View File

@ -1,12 +1,13 @@
unset border; unset tics; unset key; unset border; unset tics; unset key;
set term gif animate delay 20 set term gif animate delay 10
set output "trace.gif" set output "trace.gif"
set xrange [0:30] set xrange [0:30]
set yrange [0:4] set yrange [0:4]
set object 1 circle front at 4.0,2.0 size 1.0 fillcolor rgb "black" lw 2 set size ratio -1
set object 1 circle front at 5.0,2.0 size 1.0 fillcolor rgb "black" lw 2
do for [ts=0:300] { do for [ts=0:500] {
plot "particles_".ts.".dat" with points pointtype 7 plot "particles_".ts.".dat" with points pointtype 7 pointsize 0.3
} }
unset output unset output

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 MiB

After

Width:  |  Height:  |  Size: 709 KiB