Completed 3D seq backstep

This commit is contained in:
Aditya Ujeniya 2023-10-24 10:03:24 +02:00
parent 7dc7ab68d1
commit 175ec58667
9 changed files with 341216 additions and 21082 deletions

View File

@ -65,8 +65,8 @@ y2 1.5
shape 1
xCenter 0.0
yCenter 0.0
xRectLength 2.0
yRectLength 1.0
xRectLength 1.0
yRectLength 2.0
circleRadius 1.0
#===============================================================================

View File

@ -18,9 +18,9 @@ gx 0.0 # Body forces (e.g. gravity)
gy 0.0 #
gz 0.0 #
re 36000.0 # Reynolds number
re 5000.0 # Reynolds number
u_init 0.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
w_init 0.0 # initial value for velocity in z-direction
p_init 1.0 # initial value for pressure
@ -55,7 +55,7 @@ gamma 0.9 # upwind differencing factor gamma
# -----------------------
numberOfParticles 200
startTime 100
startTime 0
injectTimePeriod 2.0
writeTimePeriod 0.2

File diff suppressed because it is too large Load Diff

View File

@ -7,18 +7,22 @@
name karman # 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 #
gz 0.0 #
re 5050.0 # Reynolds number
re 100.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
# Geometry Data:
@ -26,37 +30,41 @@ p_init 0.0 # initial value for pressure
xlength 30.0 # domain size in x-direction
ylength 8.0 # domain size in y-direction
imax 400 # number of interior cells in x-direction
jmax 200 # number of interior cells in y-direction
zlength 8.0 # domain size in z-direction
imax 100 # number of interior cells in x-direction
jmax 40 # number of interior cells in y-direction
kmax 40 # number of interior cells in z-direction
# Time Data:
# ---------
te 150.0 # final time
te 100.0 # final time
dt 0.02 # time stepsize
tau 0.5 # safety factor for time stepsize control (<0 constant delt)
# Pressure Iteration Data:
# -----------------------
itermax 200 # maximal number of pressure iteration in one time step
eps 0.001 # stopping tolerance for pressure iteration
rho 0.52
omg 1.75 # relaxation parameter for SOR iteration
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 50
injectTimePeriod 1.0
writeTimePeriod 0.5
startTime 0
injectTimePeriod 2.0
writeTimePeriod 1.0
x1 0.0
y1 3.8
x2 0.0
y2 4.1
x1 1.0
y1 0.0
z1 1.0
x2 1.0
y2 4.0
z2 1.0
# Obstacle Geometry Data:
# -----------------------
@ -65,18 +73,7 @@ y2 4.1
shape 2
xCenter 5.0
yCenter 4.0
xRectLength 2.0
yRectLength 1.0
circleRadius 1.0
# Obstacle Geometry Data:
# -----------------------
# Shape 0 disable, 1 Rectangle/Square, 2 Circle
shape 1
xCenter 10.0
yCenter 2.0
zCenter 2.0
zCenter 4.0
xRectLength 8.0
yRectLength 2.0
zRectLength 2.0

320011
BasicSolver/3D-seq/karman.vtk Normal file

File diff suppressed because it is too large Load Diff

View File

@ -28,8 +28,12 @@ void printParticles(ParticleTracer* particletracer)
particletracer->particlePool[i].flag);
}
}
void injectParticles(ParticleTracer* particletracer)
void injectParticles(ParticleTracer* particletracer, int* seg)
{
int imax = particletracer->imax;
int jmax = particletracer->jmax;
int kmax = particletracer->kmax;
for(int i = 0; i < particletracer->numberOfParticles; ++i)
{
@ -41,11 +45,17 @@ void injectParticles(ParticleTracer* particletracer)
particletracer->particlePool[particletracer->pointer].y = (double) rand() / RAND_MAX * particletracer->ylength;
particletracer->particlePool[particletracer->pointer].z = (double) rand() / RAND_MAX * particletracer->zlength;
int i = particletracer->particlePool[particletracer->pointer].x / particletracer->dx;
int j = particletracer->particlePool[particletracer->pointer].y / particletracer->dy;
int k = particletracer->particlePool[particletracer->pointer].z / particletracer->dz;
if(S(i,j,k) == NONE)
{
particletracer->particlePool[particletracer->pointer].flag = true;
++(particletracer->pointer);
++(particletracer->totalParticles);
}
}
}
void advanceParticles(ParticleTracer* particletracer, double* restrict u, double* restrict v, double* restrict w, int* restrict seg, double time)
@ -269,7 +279,7 @@ void trace(ParticleTracer* particletracer, double* u, double* v, double* w, int*
//printParticles(particletracer);
if( (time - particletracer->lastInjectTime) >= particletracer->injectTimePeriod)
{
injectParticles(particletracer);
injectParticles(particletracer, seg);
particletracer->lastInjectTime = time;
}
if( (time - particletracer->lastWriteTime) >= particletracer->writeTimePeriod)

View File

@ -37,7 +37,7 @@ typedef struct {
} ParticleTracer;
extern void initParticleTracer(ParticleTracer*, Parameter*);
extern void injectParticles(ParticleTracer*);
extern void injectParticles(ParticleTracer*, int* seg);
extern void advanceParticles(ParticleTracer*, double*, double*, double*, int*,double);
extern void freeParticles(ParticleTracer*);
extern void writeParticles(ParticleTracer*);

View File

@ -438,10 +438,13 @@ void computeRHS(Solver* s)
double* f = s->f;
double* g = s->g;
double* h = s->h;
int* seg = s->seg;
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)
{
RHS(i, j, k) = ((F(i, j, k) - F(i - 1, j, k)) * idx +
(G(i, j, k) - G(i, j - 1, k)) * idy +
(H(i, j, k) - H(i, j, k - 1)) * idz) *
@ -449,6 +452,7 @@ void computeRHS(Solver* s)
}
}
}
}
}
void solve(Solver* s)
@ -471,6 +475,7 @@ void solve(Solver* s)
double epssq = eps * eps;
int it = 0;
double res = 1.0;
int* seg = s->seg;
while ((res >= epssq) && (it < itermax)) {
res = 0.0;
@ -478,7 +483,8 @@ void solve(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)
{
double r = RHS(i, j, k) -
((P(i + 1, j, k) - 2.0 * P(i, j, k) + P(i - 1, j, k)) *
idx2 +
@ -492,6 +498,7 @@ void solve(Solver* s)
}
}
}
}
for (int j = 1; j < jmax + 1; j++) {
for (int i = 1; i < imax + 1; i++) {
@ -513,6 +520,7 @@ void solve(Solver* s)
P(imax + 1, j, k) = P(imax, j, k);
}
}
setObjectPBoundaryCondition(s);
res = res / (double)(imax * jmax * kmax);
#ifdef DEBUG
@ -547,37 +555,12 @@ void solveRB(Solver* s)
int it = 0;
double res = 1.0;
int pass, ksw, jsw, isw;
int* seg = s->seg;
while ((res >= epssq) && (it < itermax)) {
res = 0.0;
ksw = 1;
for (pass = 0; pass < 2; pass++) {
jsw = ksw;
for (int k = 1; k < kmax + 1; k++) {
isw = jsw;
for (int j = 1; j < jmax + 1; j++) {
for (int i = isw; i < imax + 1; i += 2) {
double r =
RHS(i, j, k) -
((P(i + 1, j, k) - 2.0 * P(i, j, k) + P(i - 1, j, k)) * idx2 +
(P(i, j + 1, k) - 2.0 * P(i, j, k) + P(i, j - 1, k)) *
idy2 +
(P(i, j, k + 1) - 2.0 * P(i, j, k) + P(i, j, k - 1)) *
idz2);
P(i, j, k) -= (factor * r);
res += (r * r);
}
isw = 3 - isw;
}
jsw = 3 - jsw;
}
ksw = 3 - ksw;
}
for (int j = 1; j < jmax + 1; j++) {
for (int i = 1; i < imax + 1; i++) {
P(i, j, 0) = P(i, j, 1);
@ -599,6 +582,37 @@ void solveRB(Solver* s)
}
}
setObjectPBoundaryCondition(s);
for (pass = 0; pass < 2; pass++) {
jsw = ksw;
for (int k = 1; k < kmax + 1; k++) {
isw = jsw;
for (int j = 1; j < jmax + 1; j++) {
for (int i = isw; i < imax + 1; i += 2) {
if(S(i,j,k) == NONE)
{
double r =
RHS(i, j, k) -
((P(i + 1, j, k) - 2.0 * P(i, j, k) + P(i - 1, j, k)) * idx2 +
(P(i, j + 1, k) - 2.0 * P(i, j, k) + P(i, j - 1, k)) *
idy2 +
(P(i, j, k + 1) - 2.0 * P(i, j, k) + P(i, j, k - 1)) *
idz2);
P(i, j, k) -= (factor * r);
res += (r * r);
}
}
isw = 3 - isw;
}
jsw = 3 - jsw;
}
ksw = 3 - ksw;
}
res = res / (double)(imax * jmax * kmax);
#ifdef DEBUG
printf("%d Residuum: %e\n", it, res);
@ -633,6 +647,8 @@ void solveRBA(Solver* s)
int it = 0;
double res = 1.0;
int pass, ksw, jsw, isw;
int* seg = s->seg;
while ((res >= epssq) && (it < itermax)) {
res = 0.0;
@ -645,7 +661,8 @@ void solveRBA(Solver* s)
isw = jsw;
for (int j = 1; j < jmax + 1; j++) {
for (int i = isw; i < imax + 1; i += 2) {
if(S(i,j,k) == NONE)
{
double r =
RHS(i, j, k) -
((P(i + 1, j, k) - 2.0 * P(i, j, k) + P(i - 1, j, k)) * idx2 +
@ -656,6 +673,7 @@ void solveRBA(Solver* s)
P(i, j, k) -= (omega * factor * r);
res += (r * r);
}
}
isw = 3 - isw;
}
@ -686,6 +704,7 @@ void solveRBA(Solver* s)
P(imax + 1, j, k) = P(imax, j, k);
}
}
setObjectPBoundaryCondition(s);
res = res / (double)(imax * jmax * kmax);
#ifdef DEBUG
@ -985,10 +1004,11 @@ void setSpecialBoundaryCondition(Solver* s)
}
}
} else if (strcmp(s->problem, "backstep") == 0) {
int* seg = s->seg;
for (int k = 1; k < kmax + 1; k++) {
for (int j = 1; j < jmax + 1; j++) {
U(0, j, k) = 1.0;
if(S(0,j,k) == NONE) U(0, j, k) = 1.0;
}
}
}
@ -1478,3 +1498,98 @@ void setObjectBoundaryCondition(Solver* s)
}
}
}
void setObjectPBoundaryCondition(Solver* s)
{
int imax = s->grid.imax;
int jmax = s->grid.jmax;
int kmax = s->grid.kmax;
double* p = s->p;
int* seg = s->seg;
for (int k = 1; k < kmax + 1; k++) {
for (int j = 1; j < jmax + 1; j++) {
for (int i = 1; i < imax + 1; i++) {
switch (S(i, j, k)) {
case TOPFACE:
P(i,j,k) = P(i,j+1,k);
break;
case BOTTOMFACE:
P(i,j,k) = P(i,j-1,k);
break;
case LEFTFACE:
P(i,j,k) = P(i-1,j,k);
break;
case RIGHTFACE:
P(i,j,k) = P(i+1,j,k);
break;
case FRONTFACE:
P(i,j,k) = P(i,j,k-1);
break;
case BACKFACE:
P(i,j,k) = P(i,j,k+1);
break;
case FRONTLEFTLINE:
P(i,j,k) = (P(i,j,k-1) + P(i-1,j,k)) / 2;
break;
case FRONTRIGHTLINE:
P(i,j,k) = (P(i,j,k-1) + P(i+1,j,k)) / 2;
break;
case FRONTTOPLINE:
P(i,j,k) = (P(i,j,k-1) + P(i,j+1,k)) / 2;
break;
case FRONTBOTTOMLINE:
P(i,j,k) = (P(i,j,k-1) + P(i,j-1,k)) / 2;
break;
case MIDTOPLEFTLINE:
P(i,j,k) = (P(i-1,j,k) + P(i,j+1,k)) / 2;
break;
case MIDTOPRIGHTLINE:
P(i,j,k) = (P(i+1,j,k) + P(i,j+1,k)) / 2;
break;
case MIDBOTTOMLEFTLINE:
P(i,j,k) = (P(i-1,j,k) + P(i,j-1,k)) / 2;
break;
case MIDBOTTOMRIGHTLINE:
P(i,j,k) = (P(i+1,j,k) + P(i,j-1,k)) / 2;
break;
case BACKLEFTLINE:
P(i,j,k) = (P(i,j,k+1) + P(i-1,j,k)) / 2;
break;
case BACKRIGHTLINE:
P(i,j,k) = (P(i,j,k+1) + P(i+1,j,k)) / 2;
break;
case BACKTOPLINE:
P(i,j,k) = (P(i,j,k+1) + P(i,j+1,k)) / 2;
break;
case BACKBOTTOMLINE:
P(i,j,k) = (P(i,j,k+1) + P(i,j-1,k)) / 2;
break;
case FRONTTOPLEFTCORNER:
P(i,j,k) = (P(i,j,k-1) + P(i-1,j,k) + P(i,j+1,k)) / 3;
break;
case FRONTTOPRIGHTCORNER:
P(i,j,k) = (P(i,j,k-1) + P(i+1,j,k) + P(i,j+1,k)) / 3;
break;
case FRONTBOTTOMLEFTCORNER:
P(i,j,k) = (P(i,j,k-1) + P(i-1,j,k) + P(i,j-1,k)) / 3;
break;
case FRONTBOTTOMRIGHTCORNER:
P(i,j,k) = (P(i,j,k-1) + P(i+1,j,k) + P(i,j-1,k)) / 3;
break;
case BACKTOPLEFTCORNER:
P(i,j,k) = (P(i,j,k+1) + P(i-1,j,k) + P(i,j+1,k)) / 3;
break;
case BACKTOPRIGHTCORNER:
P(i,j,k) = (P(i,j,k+1) + P(i+1,j,k) + P(i,j+1,k)) / 3;
break;
case BACKBOTTOMLEFTCORNER:
P(i,j,k) = (P(i,j,k+1) + P(i-1,j,k) + P(i,j-1,k)) / 3;
break;
case BACKBOTTOMRIGHTCORNER:
P(i,j,k) = (P(i,j,k+1) + P(i+1,j,k) + P(i,j-1,k)) / 3;
break;
}
}
}
}
}

View File

@ -80,6 +80,7 @@ extern void normalizePressure(Solver*);
extern void computeTimestep(Solver*);
extern void setBoundaryConditions(Solver*);
extern void setObjectBoundaryCondition(Solver*);
extern void setObjectPBoundaryCondition(Solver*);
extern void setSpecialBoundaryCondition(Solver*);
extern void computeFG(Solver*);
extern void adaptUV(Solver*);