WIP: Pull Request for a complete Solver package #1

Closed
AdityaUjeniya wants to merge 51 commits from (deleted):main into main
9 changed files with 341296 additions and 8167 deletions
Showing only changes of commit 7dc7ab68d1 - Show all commits

View File

@ -39,11 +39,15 @@ $(BUILD_DIR)/%.s: %.c
.PHONY: clean distclean tags info asm format
clean:
clean: vis
$(info ===> CLEAN)
@rm -rf $(BUILD_DIR)
@rm -f tags
vis:
$(info ===> REMOVING VIZUALISATION FILES)
@rm -f vtk_files/particle*.vtk
distclean: clean
$(info ===> DIST CLEAN)
@rm -f $(TARGET)

View File

@ -7,56 +7,64 @@
name backstep # name of flow setup
bcTop 1 # flags for boundary conditions
bcBottom 1 # 1 = no-slip 3 = outflow
bcLeft 3 # 2 = free-slip 4 = periodic
bcRight 3 #
bcLeft 3 # flags for boundary conditions
bcRight 3 # 1 = no-slip 3 = outflow
bcBottom 1 # 2 = free-slip 4 = periodic
bcTop 1 #
bcFront 1 #
bcBack 1 #
gx 0.0 # Body forces (e.g. gravity)
gy 0.0 #
gx 0.0 # Body forces (e.g. gravity)
gy 0.0 #
gz 0.0 #
re 36500.0 # Reynolds number
re 36000.0 # Reynolds number
u_init 1.0 # initial value for velocity in x-direction
v_init 0.0 # initial value for velocity in y-direction
p_init 1.0 # initial value for pressure
u_init 0.0 # initial value for velocity in x-direction
v_init 0.0 # initial value for velocity in y-direction
w_init 0.0 # initial value for velocity in z-direction
p_init 1.0 # initial value for pressure
# Geometry Data:
# -------------
xlength 7.0 # domain size in x-direction
ylength 1.5 # domain size in y-direction
imax 210 # number of interior cells in x-direction
jmax 45 # number of interior cells in y-direction
xlength 7.0 # domain size in x-direction
ylength 1.5 # domain size in y-direction
zlength 1.0 # domain size in z-direction
imax 70 # number of interior cells in x-direction
jmax 15 # number of interior cells in y-direction
kmax 10 # number of interior cells in z-direction
# Time Data:
# ---------
te 60.0 # final time
dt 0.02 # time stepsize
tau 0.5 # safety factor for time stepsize control (<0 constant delt)
te 60.0 # final time
dt 0.02 # time stepsize
tau 0.5 # safety factor for time stepsize control (<0 constant delt)
# Pressure Iteration Data:
# -----------------------
itermax 500 # maximal number of pressure iteration in one time step
eps 0.0001 # stopping tolerance for pressure iteration
rho 0.52
omg 1.8 # relaxation parameter for SOR iteration
gamma 0.9 # upwind differencing factor gamma
itermax 500 # maximal number of pressure iteration in one time step
eps 0.0001 # stopping tolerance for pressure iteration
omg 0.52
omg 1.7 # relaxation parameter for SOR iteration
gamma 0.9 # upwind differencing factor gamma
# Particle Tracing Data:
# -----------------------
numberOfParticles 200
startTime 0
injectTimePeriod 1.0
writeTimePeriod 0.5
startTime 100
injectTimePeriod 2.0
writeTimePeriod 0.2
x1 0.0
y1 0.5
y1 0.0
z1 1.0
x2 0.0
y2 1.5
y2 4.0
z2 1.0
# Obstacle Geometry Data:
# -----------------------
@ -68,7 +76,7 @@ yCenter 0.0
zCenter 0.0
xRectLength 2.0
yRectLength 1.0
zRectLength 1.0
zRectLength 2.0
circleRadius 1.0
#===============================================================================

File diff suppressed because it is too large Load Diff

View File

@ -18,9 +18,9 @@ gx 0.0 # Body forces (e.g. gravity)
gy 0.0 #
gz 0.0 #
re 100.0 # Reynolds number
re 5000.0 # Reynolds number
u_init 1.0 # initial value for velocity in x-direction
u_init 0.0 # initial value for velocity in x-direction
v_init 0.0 # initial value for velocity in y-direction
w_init 0.0 # initial value for velocity in z-direction
p_init 0.0 # initial value for pressure
@ -38,7 +38,7 @@ kmax 40 # number of interior cells in z-direction
# Time Data:
# ---------
te 60.0 # final time
te 200.0 # final time
dt 0.02 # time stepsize
tau 0.5 # safety factor for time stepsize control (<0 constant delt)
@ -54,10 +54,10 @@ gamma 0.9 # upwind differencing factor gamma
# Particle Tracing Data:
# -----------------------
numberOfParticles 30
startTime 10
numberOfParticles 200
startTime 0
injectTimePeriod 2.0
writeTimePeriod 2.0
writeTimePeriod 1.0
x1 1.0
y1 0.0
@ -70,7 +70,7 @@ z2 1.0
# -----------------------
# Shape 0 disable, 1 Rectangle/Square, 2 Circle
shape 2
shape 1
xCenter 10.0
yCenter 2.0
zCenter 2.0

File diff suppressed because it is too large Load Diff

View File

@ -100,8 +100,8 @@ int main(int argc, char** argv)
double te = s.te;
double t = 0.0;
printGrid(&s, s.seg);
exit(0);
// printGrid(&s, s.seg);
// exit(0);
timeStart = getTimeStamp();
@ -118,7 +118,7 @@ int main(int argc, char** argv)
solver_generic[variant - 1](&s);
adaptUV(&s);
trace(&particletracer, s.u, s.v, s.w, t);
trace(&particletracer, s.u, s.v, s.w, s.seg, t);
t += s.dt;

View File

@ -15,6 +15,7 @@
#define U(i, j, k) u[(k) * (imax + 2) * (jmax + 2) + (j) * (imax + 2) + (i)]
#define V(i, j, k) v[(k) * (imax + 2) * (jmax + 2) + (j) * (imax + 2) + (i)]
#define W(i, j, k) w[(k) * (imax + 2) * (jmax + 2) + (j) * (imax + 2) + (i)]
#define S(i, j, k) seg[(k) * (imax + 2) * (jmax + 2) + (j) * (imax + 2) + (i)]
static int ts = 0;
unsigned int seed = 32767;
@ -47,7 +48,7 @@ void injectParticles(ParticleTracer* particletracer)
}
}
void advanceParticles(ParticleTracer* particletracer, double* restrict u, double* restrict v, double* restrict w, double time)
void advanceParticles(ParticleTracer* particletracer, double* restrict u, double* restrict v, double* restrict w, int* restrict seg, double time)
{
int imax = particletracer->imax;
int jmax = particletracer->jmax;
@ -167,6 +168,11 @@ void advanceParticles(ParticleTracer* particletracer, double* restrict u, double
{
particletracer->particlePool[i].flag = false;
}
int i_new = new_x/dx, j_new = new_y/dy, k_new = new_z/dz;
if(S(i_new, j_new, k_new) != NONE)
{
particletracer->particlePool[i].flag = false;
}
}
}
}
@ -256,7 +262,7 @@ void printParticleTracerParameters(ParticleTracer* particletracer)
printf("\tdt : %.2f, dx : %.2f, dy : %.2f, dz : %.2f\n", particletracer->dt, particletracer->dx, particletracer->dy, particletracer->dz);
}
void trace(ParticleTracer* particletracer, double* u, double* v, double* w, double time)
void trace(ParticleTracer* particletracer, double* u, double* v, double* w, int* seg, double time)
{
if (time >= particletracer->startTime)
{
@ -272,7 +278,7 @@ void trace(ParticleTracer* particletracer, double* u, double* v, double* w, doub
particletracer->lastWriteTime = time;
}
advanceParticles(particletracer, u, v, w, time);
advanceParticles(particletracer, u, v, w, seg, time);
compress(particletracer);
particletracer->lastUpdateTime = time;
}

View File

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

View File

@ -1006,6 +1006,8 @@ void computeFG(Solver* s)
double* f = s->f;
double* g = s->g;
double* h = s->h;
int* seg = s->seg;
double gx = s->gx;
double gy = s->gy;
@ -1026,6 +1028,9 @@ void computeFG(Solver* s)
for (int k = 1; k < kmax + 1; k++) {
for (int j = 1; j < jmax + 1; j++) {
for (int i = 1; i < imax + 1; i++) {
if(S(i,j,k) == NONE)
{
du2dx = inverseDx * 0.25 *
((U(i, j, k) + U(i + 1, j, k)) *
(U(i, j, k) + U(i + 1, j, k)) -
@ -1151,6 +1156,117 @@ void computeFG(Solver* s)
(W(i, j, k + 1) - 2.0 * W(i, j, k) + W(i, j, k - 1));
H(i, j, k) = W(i, j, k) + dt * (inverseRe * (dw2dx2 + dw2dy2 + dw2dz2) -
duwdx - dvwdy - dw2dz + gz);
}
else{
switch (S(i, j, k)) {
case TOPFACE:
G(i, j, k) = V(i, j, k);
break;
case BOTTOMFACE:
G(i, j, k) = V(i, j, k);
break;
case LEFTFACE:
F(i, j, k) = U(i, j, k);
break;
case RIGHTFACE:
F(i, j, k) = U(i, j, k);
break;
case FRONTFACE:
H(i, j, k) = W(i, j, k);
break;
case BACKFACE:
H(i, j, k) = W(i, j, k);
break;
case FRONTLEFTLINE:
F(i, j, k) = 0.0;
H(i, j, k) = 0.0;
break;
case FRONTRIGHTLINE:
F(i, j, k) = 0.0;
H(i, j, k) = 0.0;
break;
case FRONTTOPLINE:
G(i, j, k) = 0.0;
H(i, j, k) = 0.0;
break;
case FRONTBOTTOMLINE:
G(i, j, k) = 0.0;
H(i, j, k) = 0.0;
break;
case MIDTOPLEFTLINE:
F(i, j, k) = 0.0;
G(i, j, k) = 0.0;
break;
case MIDTOPRIGHTLINE:
F(i, j, k) = U(i, j, k);
G(i, j, k) = V(i, j, k);
break;
case MIDBOTTOMLEFTLINE:
F(i, j, k) = 0.0;
G(i, j, k) = 0.0;
break;
case MIDBOTTOMRIGHTLINE:
F(i, j, k) = 0.0;
G(i, j, k) = 0.0;
break;
case BACKLEFTLINE:
F(i, j, k) = 0.0;
H(i, j, k) = 0.0;
break;
case BACKRIGHTLINE:
F(i, j, k) = 0.0;
H(i, j, k) = 0.0;
break;
case BACKTOPLINE:
G(i, j, k) = 0.0;
H(i, j, k) = 0.0;
break;
case BACKBOTTOMLINE:
G(i, j, k) = 0.0;
H(i, j, k) = 0.0;
break;
case FRONTTOPLEFTCORNER:
F(i, j, k) = 0.0;
G(i, j, k) = 0.0;
H(i, j, k) = 0.0;
break;
case FRONTTOPRIGHTCORNER:
F(i, j, k) = 0.0;
G(i, j, k) = 0.0;
H(i, j, k) = 0.0;
break;
case FRONTBOTTOMLEFTCORNER:
F(i, j, k) = 0.0;
G(i, j, k) = 0.0;
H(i, j, k) = 0.0;
break;
case FRONTBOTTOMRIGHTCORNER:
F(i, j, k) = 0.0;
G(i, j, k) = 0.0;
H(i, j, k) = 0.0;
break;
case BACKTOPLEFTCORNER:
F(i, j, k) = 0.0;
G(i, j, k) = 0.0;
H(i, j, k) = 0.0;
break;
case BACKTOPRIGHTCORNER:
F(i, j, k) = 0.0;
G(i, j, k) = 0.0;
H(i, j, k) = 0.0;
break;
case BACKBOTTOMLEFTCORNER:
F(i, j, k) = 0.0;
G(i, j, k) = 0.0;
H(i, j, k) = 0.0;
break;
case BACKBOTTOMRIGHTCORNER:
F(i, j, k) = 0.0;
G(i, j, k) = 0.0;
H(i, j, k) = 0.0;
break;
}
}
}
}
}
@ -1215,8 +1331,8 @@ void adaptUV(Solver* s)
void setObjectBoundaryCondition(Solver* s)
{
int imax = s->grid.imax;
int jmax = s->jmax;
int kmax = s->kmax;
int jmax = s->grid.jmax;
int kmax = s->grid.kmax;
double* u = s->u;
double* v = s->v;
double* w = s->w;
@ -1226,152 +1342,136 @@ void setObjectBoundaryCondition(Solver* s)
for (int i = 1; i < imax + 1; i++) {
switch (S(i, j, k)) {
case TOPFACE:
U(i, j, k) = -U(i, j + 1, k);
U(i - 1, j, k) = -U(i - 1, j + 1, k);
U(i, j, k) = -U(i, j+1, k);
V(i, j, k) = 0.0;
W(i, j, k) = 0.0;
W(i, j, k) = -W(i, j+1, k);;
break;
case BOTTOMFACE:
U(i, j, k) = -U(i, j - 1, k);
U(i - 1, j, k) = -U(i - 1, j - 1, k);
U(i, j, k) = -U(i, j-1, k);
V(i, j, k) = 0.0;
W(i, j, k) = 0.0;
W(i, j, k) = -W(i, j-1, k);
break;
case LEFTFACE:
U(i - 1, j, k) = 0.0;
V(i, j, k) = -V(i - 1, j, k);
V(i, j - 1, k) = -V(i - 1, j - 1, k);
W(i, j, k) = 0.0;
U(i, j, k) = 0.0;
V(i, j, k) = -V(i-1, j, k);
W(i, j, k) = -W(i-1, j, k);
break;
case RIGHTFACE:
U(i, j, k) = 0.0;
V(i, j, k) = -V(i + 1, j, k);
V(i, j - 1, k) = -V(i + 1, j - 1, k);
W(i, j, k) = 0.0;
V(i, j, k) = -V(i+1, j, k);
W(i, j, k) = -W(i+1, j, k);
break;
case FRONTFACE:
U(i - 1, j, k) = 0.0;
V(i, j, k) = 0.0;
V(i, j, k) = -V(i - 1, j, k);
V(i, j - 1, k) = -V(i - 1, j - 1, k);
U(i, j, k) = -U(i, j, k-1);
V(i, j, k) = -V(i, j, k-1);
W(i, j, k) = 0.0;
break;
case BACKFACE:
U(i, j, k) = -U(i, j, k+1);
V(i, j, k) = -V(i, j, k+1);
W(i, j, k) = 0.0;
break;
case FRONTLEFTLINE:
U(i, j, k) = 0.0;
V(i, j, k) = -V(i, j, k-1);
W(i, j, k) = -W(i-1, j, k);
break;
case FRONTRIGHTLINE:
U(i, j, k) = 0.0;
V(i, j, k) = -V(i, j, k-1);
W(i, j, k) = -W(i+1, j, k);
break;
case FRONTTOPLINE:
U(i, j, k) = -U(i, j, k-1);
V(i, j, k) = 0.0;
W(i, j, k) = -W(i, j+1, k);
break;
case FRONTBOTTOMLINE:
U(i, j, k) = -U(i, j, k-1);
V(i, j, k) = 0.0;
W(i, j, k) = -W(i, j-1, k);
break;
case MIDTOPLEFTLINE:
U(i, j, k) = -U(i, j+1, k);
V(i, j, k) = -V(i-1, j, k);
W(i, j, k) = 0.0;
break;
case MIDTOPRIGHTLINE:
U(i, j, k) = 0.0;
V(i, j, k) = 0.0;
V(i, j, k) = -V(i + 1, j, k);
V(i, j - 1, k) = -V(i + 1, j - 1, k);
U(i-1, j, k) = -U(i-1, j+1, k);
V(i, j-1, k) = -V(i+1, j-1, k);
W(i, j, k) = 0.0;
break;
case TOPLEFT:
U(i, j) = -U(i, j + 1);
U(i - 1, j) = 0.0;
V(i, j) = 0.0;
V(i, j - 1) = -V(i - 1, j - 1);
case MIDBOTTOMLEFTLINE:
U(i, j, k) = -U(i, j-1, k);
V(i, j, k) = -V(i-1, j, k);
W(i, j, k) = 0.0;
break;
case TOPRIGHT:
U(i, j) = 0.0;
U(i - 1, j) = -U(i - 1, j + 1);
V(i, j) = 0.0;
V(i, j - 1) = -V(i + 1, j - 1);
case MIDBOTTOMRIGHTLINE:
U(i, j, k) = -U(i, j-1, k);
V(i, j, k) = -V(i+1, j, k);
W(i, j, k) = 0.0;
break;
case BOTTOMLEFT:
U(i, j) = -U(i, j - 1);
U(i - 1, j) = 0.0;
V(i, j) = -V(i - 1, j);
V(i, j - 1) = 0.0;
case BACKLEFTLINE:
U(i, j, k) = 0.0;
V(i, j, k) = -V(i, j, k+1);
W(i, j, k) = -W(i-1, j, k);
break;
case BOTTOMRIGHT:
U(i, j) = 0.0;
U(i - 1, j) = -U(i - 1, j - 1);
V(i, j) = -V(i, j + 1);
V(i, j - 1) = 0.0;
case BACKRIGHTLINE:
U(i, j, k) = 0.0;
V(i, j, k) = -V(i, j, k+1);
W(i, j, k) = -W(i+1, j, k);
break;
case TOP:
U(i, j) = -U(i, j + 1);
U(i - 1, j) = -U(i - 1, j + 1);
V(i, j) = 0.0;
case BACKTOPLINE:
U(i, j, k) = -U(i, j, k+1);
V(i, j, k) = 0.0;
W(i, j, k) = -W(i, j+1, k);
break;
case BOTTOM:
U(i, j) = -U(i, j - 1);
U(i - 1, j) = -U(i - 1, j - 1);
V(i, j) = 0.0;
case BACKBOTTOMLINE:
U(i, j, k) = -U(i, j, k+1);
V(i, j, k) = 0.0;
W(i, j, k) = -W(i, j-1, k);
break;
case LEFT:
U(i - 1, j) = 0.0;
V(i, j) = -V(i - 1, j);
V(i, j - 1) = -V(i - 1, j - 1);
case FRONTTOPLEFTCORNER:
U(i, j, k) = -U(i, j, k-1);
V(i, j, k) = -V(i-1, j, k);
W(i, j, k) = -W(i, j+1, k);
break;
case RIGHT:
U(i, j) = 0.0;
V(i, j) = -V(i + 1, j);
V(i, j - 1) = -V(i + 1, j - 1);
case FRONTTOPRIGHTCORNER:
U(i, j, k) = -U(i, j, k-1);
V(i, j, k) = -V(i+1, j, k);
W(i, j, k) = -W(i, j+1, k);
break;
case TOPLEFT:
U(i, j) = -U(i, j + 1);
U(i - 1, j) = 0.0;
V(i, j) = 0.0;
V(i, j - 1) = -V(i - 1, j - 1);
case FRONTBOTTOMLEFTCORNER:
U(i, j, k) = -U(i, j, k-1);
V(i, j, k) = -V(i-1, j, k);
W(i, j, k) = -W(i, j-1, k);
break;
case TOPRIGHT:
U(i, j) = 0.0;
U(i - 1, j) = -U(i - 1, j + 1);
V(i, j) = 0.0;
V(i, j - 1) = -V(i + 1, j - 1);
case FRONTBOTTOMRIGHTCORNER:
U(i, j, k) = -U(i, j, k-1);
V(i, j, k) = -V(i+1, j, k);
W(i, j, k) = -W(i, j-1, k);
break;
case BOTTOMLEFT:
U(i, j) = -U(i, j - 1);
U(i - 1, j) = 0.0;
V(i, j) = -V(i - 1, j);
V(i, j - 1) = 0.0;
case BACKTOPLEFTCORNER:
U(i, j, k) = -U(i, j, k+1);
V(i, j, k) = -V(i-1, j, k);
W(i, j, k) = -W(i, j+1, k);
break;
case BOTTOMRIGHT:
U(i, j) = 0.0;
U(i - 1, j) = -U(i - 1, j - 1);
V(i, j) = -V(i, j + 1);
V(i, j - 1) = 0.0;
case BACKTOPRIGHTCORNER:
U(i, j, k) = -U(i, j, k+1);
V(i, j, k) = -V(i+1, j, k);
W(i, j, k) = -W(i, j+1, k);
break;
case TOP:
U(i, j) = -U(i, j + 1);
U(i - 1, j) = -U(i - 1, j + 1);
V(i, j) = 0.0;
case BACKBOTTOMLEFTCORNER:
U(i, j, k) = -U(i, j, k+1);
V(i, j, k) = -V(i-1, j, k);
W(i, j, k) = -W(i, j-1, k);
break;
case BOTTOM:
U(i, j) = -U(i, j - 1);
U(i - 1, j) = -U(i - 1, j - 1);
V(i, j) = 0.0;
break;
case LEFT:
U(i - 1, j) = 0.0;
V(i, j) = -V(i - 1, j);
V(i, j - 1) = -V(i - 1, j - 1);
break;
case RIGHT:
U(i, j) = 0.0;
V(i, j) = -V(i + 1, j);
V(i, j - 1) = -V(i + 1, j - 1);
break;
case TOPLEFT:
U(i, j) = -U(i, j + 1);
U(i - 1, j) = 0.0;
V(i, j) = 0.0;
V(i, j - 1) = -V(i - 1, j - 1);
break;
case TOPRIGHT:
U(i, j) = 0.0;
U(i - 1, j) = -U(i - 1, j + 1);
V(i, j) = 0.0;
V(i, j - 1) = -V(i + 1, j - 1);
break;
case BOTTOMLEFT:
U(i, j) = -U(i, j - 1);
U(i - 1, j) = 0.0;
V(i, j) = -V(i - 1, j);
V(i, j - 1) = 0.0;
break;
case BOTTOMRIGHT:
U(i, j) = 0.0;
U(i - 1, j) = -U(i - 1, j - 1);
V(i, j) = -V(i, j + 1);
V(i, j - 1) = 0.0;
case BACKBOTTOMRIGHTCORNER:
U(i, j, k) = -U(i, j, k+1);
V(i, j, k) = -V(i+1, j, k);
W(i, j, k) = -W(i, j-1, k);
break;
}
}