Incomplete 3D enhanced solver + slides

This commit is contained in:
Aditya Ujeniya 2023-10-12 17:46:33 +02:00
parent 86f7677f34
commit 4c374c82c7
34 changed files with 22943 additions and 19447 deletions

View File

@ -15,7 +15,7 @@ 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 36500.0 # Reynolds number re 7500.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

View File

@ -17,7 +17,7 @@ gy 0.0 #
re 10.0 # Reynolds number re 10.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 v_init 0.0 # initial value for velocity in y-direction
p_init 0.0 # initial value for pressure p_init 0.0 # initial value for pressure
@ -48,9 +48,9 @@ gamma 0.9 # upwind differencing factor gamma
# Particle Tracing Data: # Particle Tracing Data:
# ----------------------- # -----------------------
numberOfParticles 30 numberOfParticles 200
startTime 0 startTime 0
injectTimePeriod 2.0 injectTimePeriod 0.5
writeTimePeriod 0.2 writeTimePeriod 0.2
x1 0.1 x1 0.1

File diff suppressed because it is too large Load Diff

View File

@ -8,7 +8,18 @@
#define __SOLVER_H_ #define __SOLVER_H_
#include "parameter.h" #include "parameter.h"
enum OBJECTBOUNDARY { NONE = 0, TOP, BOTTOM, LEFT, RIGHT, TOPLEFT, BOTTOMLEFT, TOPRIGHT, BOTTOMRIGHT, LOCAL }; enum OBJECTBOUNDARY {
NONE = 0,
TOP,
BOTTOM,
LEFT,
RIGHT,
TOPLEFT,
BOTTOMLEFT,
TOPRIGHT,
BOTTOMRIGHT,
LOCAL
};
enum BC { NOSLIP = 1, SLIP, OUTFLOW, PERIODIC }; enum BC { NOSLIP = 1, SLIP, OUTFLOW, PERIODIC };
/// @brief /// @brief
enum SHAPE { NOSHAPE = 0, RECT, CIRCLE }; enum SHAPE { NOSHAPE = 0, RECT, CIRCLE };

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 188 KiB

After

Width:  |  Height:  |  Size: 208 KiB

View File

@ -1,8 +1,8 @@
unset border; unset tics; unset key; unset border; unset tics; unset key;
set term gif animate delay 50 set term gif animate delay 30
set output "trace.gif" set output "trace.gif"
set xrange [0:7] set xrange [0:1]
set yrange [0:1.5] set yrange [0:1]
do for [ts=0:120] { do for [ts=0:120] {
plot "particles_".ts.".dat" with points pointtype 7 plot "particles_".ts.".dat" with points pointtype 7

Binary file not shown.

Before

Width:  |  Height:  |  Size: 453 KiB

After

Width:  |  Height:  |  Size: 478 KiB

View File

@ -0,0 +1,74 @@
#==============================================================================
# Laminar Canal Flow
#==============================================================================
# Problem specific Data:
# ---------------------
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 #
gx 0.0 # Body forces (e.g. gravity)
gy 0.0 #
re 36500.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
# 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
# Time Data:
# ---------
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
# Particle Tracing Data:
# -----------------------
numberOfParticles 200
startTime 0
injectTimePeriod 1.0
writeTimePeriod 0.5
x1 0.0
y1 0.5
x2 0.0
y2 1.5
# Obstacle Geometry Data:
# -----------------------
# Shape 0 disable, 1 Rectangle/Square, 2 Circle
shape 1
xCenter 0.0
yCenter 0.0
zCenter 0.0
xRectLength 2.0
yRectLength 1.0
zRectLength 1.0
circleRadius 1.0
#===============================================================================

View File

@ -31,14 +31,14 @@ p_init 0.0 # initial value for pressure
xlength 30.0 # domain size in x-direction xlength 30.0 # domain size in x-direction
ylength 4.0 # domain size in y-direction ylength 4.0 # domain size in y-direction
zlength 4.0 # domain size in z-direction zlength 4.0 # domain size in z-direction
imax 40 # number of interior cells in x-direction imax 100 # number of interior cells in x-direction
jmax 10 # number of interior cells in y-direction jmax 40 # number of interior cells in y-direction
kmax 10 # number of interior cells in z-direction kmax 40 # number of interior cells in z-direction
# Time Data: # Time Data:
# --------- # ---------
te 100.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)
@ -65,4 +65,17 @@ z1 1.0
x2 1.0 x2 1.0
y2 4.0 y2 4.0
z2 1.0 z2 1.0
# Obstacle Geometry Data:
# -----------------------
# Shape 0 disable, 1 Rectangle/Square, 2 Circle
shape 2
xCenter 10.0
yCenter 2.0
zCenter 2.0
xRectLength 8.0
yRectLength 2.0
zRectLength 2.0
circleRadius 1.0
#=============================================================================== #===============================================================================

View File

@ -65,4 +65,17 @@ z1 1.0
x2 1.0 x2 1.0
y2 4.0 y2 4.0
z2 1.0 z2 1.0
# Obstacle Geometry Data:
# -----------------------
# Shape 0 disable, 1 Rectangle/Square, 2 Circle
shape 1
xCenter 10.0
yCenter 2.0
zCenter 2.0
xRectLength 8.0
yRectLength 2.0
zRectLength 2.0
circleRadius 1.0
#=============================================================================== #===============================================================================

View File

@ -0,0 +1,85 @@
#==============================================================================
# Laminar Canal Flow
#==============================================================================
# Problem specific Data:
# ---------------------
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 #
gx 0.0 # Body forces (e.g. gravity)
gy 0.0 #
re 5050.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 0.0 # initial value for pressure
# Geometry Data:
# -------------
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
# Time Data:
# ---------
te 150.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
gamma 0.9 # upwind differencing factor gamma
# Particle Tracing Data:
# -----------------------
numberOfParticles 200
startTime 50
injectTimePeriod 1.0
writeTimePeriod 0.5
x1 0.0
y1 3.8
x2 0.0
y2 4.1
# Obstacle Geometry Data:
# -----------------------
# Shape 0 disable, 1 Rectangle/Square, 2 Circle
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
xRectLength 8.0
yRectLength 2.0
zRectLength 2.0
circleRadius 1.0
#===============================================================================

File diff suppressed because it is too large Load Diff

View File

@ -12,18 +12,16 @@
#include "allocate.h" #include "allocate.h"
#include "parameter.h" #include "parameter.h"
#include "particletracing.h"
#include "progress.h" #include "progress.h"
#include "solver.h" #include "solver.h"
#include "timing.h" #include "timing.h"
#include "vtkWriter.h" #include "vtkWriter.h"
#include "particletracing.h"
#define G(v, i, j, k) v[(k) * (imax + 2) * (jmax + 2) + (j) * (imax + 2) + (i)] #define G(v, i, j, k) v[(k) * (imax + 2) * (jmax + 2) + (j) * (imax + 2) + (i)]
enum VARIANT { SOR = 1, RB, RBA }; enum VARIANT { SOR = 1, RB, RBA };
static void createBulkArrays(Solver* s, double* pg, double* ug, double* vg, double* wg) static void createBulkArrays(Solver* s, double* pg, double* ug, double* vg, double* wg)
{ {
int imax = s->grid.imax; int imax = s->grid.imax;
@ -87,8 +85,7 @@ int main(int argc, char** argv)
} }
readParameter(&params, argv[1]); readParameter(&params, argv[1]);
if (argc == 3) if (argc == 3) {
{
variant = atoi(argv[2]); variant = atoi(argv[2]);
} }
printParameter(&params); printParameter(&params);
@ -103,6 +100,9 @@ int main(int argc, char** argv)
double te = s.te; double te = s.te;
double t = 0.0; double t = 0.0;
printGrid(&s, s.seg);
exit(0);
timeStart = getTimeStamp(); timeStart = getTimeStamp();
void (*solver_generic[])() = { solve, solveRB, solveRBA }; void (*solver_generic[])() = { solve, solveRB, solveRBA };
@ -111,6 +111,8 @@ int main(int argc, char** argv)
if (tau > 0.0) computeTimestep(&s); if (tau > 0.0) computeTimestep(&s);
setBoundaryConditions(&s); setBoundaryConditions(&s);
setSpecialBoundaryCondition(&s); setSpecialBoundaryCondition(&s);
setObjectBoundaryCondition(&s);
computeFG(&s); computeFG(&s);
computeRHS(&s); computeRHS(&s);
solver_generic[variant - 1](&s); solver_generic[variant - 1](&s);

View File

@ -101,6 +101,15 @@ void readParameter(Parameter* param, const char* filename)
PARSE_REAL(y2); PARSE_REAL(y2);
PARSE_REAL(z2); PARSE_REAL(z2);
/* Added obstacle geometry parameters */
PARSE_INT(shape);
PARSE_REAL(xCenter);
PARSE_REAL(yCenter);
PARSE_REAL(zCenter);
PARSE_REAL(xRectLength);
PARSE_REAL(yRectLength);
PARSE_REAL(zRectLength);
PARSE_REAL(circleRadius);
} }
} }

View File

@ -23,9 +23,12 @@ typedef struct {
double startTime, injectTimePeriod, writeTimePeriod; double startTime, injectTimePeriod, writeTimePeriod;
double x1, y1, z1, x2, y2, z2; double x1, y1, z1, x2, y2, z2;
int shape;
double xCenter, yCenter, zCenter, xRectLength, yRectLength, zRectLength, circleRadius;
} Parameter; } Parameter;
void initParameter(Parameter*); extern void initParameter(Parameter*);
void readParameter(Parameter*, const char*); extern void readParameter(Parameter*, const char*);
void printParameter(Parameter*); extern void printParameter(Parameter*);
#endif #endif

View File

@ -8,20 +8,20 @@
#define __PARTICLETRACING_H_ #define __PARTICLETRACING_H_
#include "allocate.h" #include "allocate.h"
#include "parameter.h" #include "parameter.h"
#include "solver.h"
#include "particletracing.h" #include "particletracing.h"
#include "solver.h"
#include <stdbool.h> #include <stdbool.h>
typedef enum COORD { X = 0, Y, NCOORD } COORD; typedef enum COORD { X = 0, Y, NCOORD } COORD;
typedef struct typedef struct {
{
double x, y, z; double x, y, z;
bool flag; bool flag;
} Particle; } Particle;
typedef struct { typedef struct {
int numberOfParticles, totalParticles; int numberOfParticles, totalParticles;
double startTime, injectTimePeriod, writeTimePeriod, lastInjectTime, lastUpdateTime, lastWriteTime; double startTime, injectTimePeriod, writeTimePeriod, lastInjectTime, lastUpdateTime,
lastWriteTime;
int estimatedNumParticles, activeParticles; int estimatedNumParticles, activeParticles;
@ -36,13 +36,13 @@ typedef struct {
double x1, y1, x2, y2, z1, z2; double x1, y1, x2, y2, z1, z2;
} ParticleTracer; } ParticleTracer;
void initParticleTracer(ParticleTracer*, Parameter*); extern void initParticleTracer(ParticleTracer*, Parameter*);
void injectParticles(ParticleTracer*); extern void injectParticles(ParticleTracer*);
void advanceParticles(ParticleTracer*, double* , double*, double*, double); extern void advanceParticles(ParticleTracer*, double*, double*, double*, double);
void freeParticles(ParticleTracer*); extern void freeParticles(ParticleTracer*);
void writeParticles(ParticleTracer*); extern void writeParticles(ParticleTracer*);
void printParticleTracerParameters(ParticleTracer*); extern void printParticleTracerParameters(ParticleTracer*);
void printParticles(ParticleTracer*); extern void printParticles(ParticleTracer*);
void compress(ParticleTracer*); extern void compress(ParticleTracer*);
void trace(ParticleTracer*, double* , double* , double* , double); extern void trace(ParticleTracer*, double*, double*, double*, double);
#endif #endif

View File

@ -22,8 +22,122 @@
#define U(i, j, k) u[(k) * (imax + 2) * (jmax + 2) + (j) * (imax + 2) + (i)] #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 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 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)]
#define RHS(i, j, k) rhs[(k) * (imax + 2) * (jmax + 2) + (j) * (imax + 2) + (i)] #define RHS(i, j, k) rhs[(k) * (imax + 2) * (jmax + 2) + (j) * (imax + 2) + (i)]
static double distance(
double i, double j, double k, double iCenter, double jCenter, double kCenter)
{
return sqrt(pow(iCenter - i, 2) + pow(jCenter - j, 2) + pow(kCenter - k, 2) * 1.0);
}
void printGrid(Solver* solver, int* grid)
{
int imax = solver->grid.imax;
int jmax = solver->grid.jmax;
for (int k = 0; k < solver->grid.kmax + 2; k++) {
printf("K : %02d:\n", k);
for (int j = 0; j < solver->grid.jmax + 2; j++) {
printf("J : %02d: ", j);
for (int i = 0; i < solver->grid.imax + 2; i++) {
switch (grid[(k) * (imax + 2) * (jmax + 2) + (j) * (imax + 2) + (i)]) {
case FRONTFACE:
printf("FF ");
break;
case BACKFACE:
printf("BF ");
break;
case LEFTFACE:
printf("LF ");
break;
case RIGHTFACE:
printf("RF ");
break;
case TOPFACE:
printf("TF ");
break;
case BOTTOMFACE:
printf("BMF ");
break;
case FRONTTOPLEFTCORNER:
printf("FTLC ");
break;
case FRONTTOPRIGHTCORNER:
printf("FTRC ");
break;
case FRONTBOTTOMLEFTCORNER:
printf("FBLC ");
break;
case FRONTBOTTOMRIGHTCORNER:
printf("FBRC ");
break;
case BACKTOPLEFTCORNER:
printf("BTLC ");
break;
case BACKTOPRIGHTCORNER:
printf("BTRC ");
break;
case BACKBOTTOMLEFTCORNER:
printf("BBLC ");
break;
case BACKBOTTOMRIGHTCORNER:
printf("BBRC ");
break;
case FRONTTOPLINE:
printf("FTL ");
break;
case FRONTBOTTOMLINE:
printf("FBL ");
break;
case FRONTLEFTLINE:
printf("FLL ");
break;
case FRONTRIGHTLINE:
printf("FRL ");
break;
case MIDTOPLEFTLINE:
printf("MTLL ");
break;
case MIDTOPRIGHTLINE:
printf("MTRL ");
break;
case MIDBOTTOMLEFTLINE:
printf("MBTL ");
break;
case MIDBOTTOMRIGHTLINE:
printf("MBRL ");
break;
case BACKTOPLINE:
printf("BTL ");
break;
case BACKBOTTOMLINE:
printf("BBL ");
break;
case BACKLEFTLINE:
printf("BLL ");
break;
case BACKRIGHTLINE:
printf("BRL ");
break;
case LOCAL:
printf("L ");
break;
case NONE:
printf("N ");
break;
}
}
printf("\n");
}
printf("\n\n");
}
fflush(stdout);
}
static void printConfig(Solver* s) static void printConfig(Solver* s)
{ {
printf("Parameters for #%s#\n", s->problem); printf("Parameters for #%s#\n", s->problem);
@ -85,7 +199,6 @@ void initSolver(Solver* s, Parameter* params)
s->gamma = params->gamma; s->gamma = params->gamma;
s->rho = params->rho; s->rho = params->rho;
int imax = s->grid.imax; int imax = s->grid.imax;
int jmax = s->grid.jmax; int jmax = s->grid.jmax;
int kmax = s->grid.kmax; int kmax = s->grid.kmax;
@ -98,6 +211,7 @@ void initSolver(Solver* s, Parameter* params)
s->f = allocate(64, bytesize); s->f = allocate(64, bytesize);
s->g = allocate(64, bytesize); s->g = allocate(64, bytesize);
s->h = allocate(64, bytesize); s->h = allocate(64, bytesize);
s->seg = allocate(64, bytesize);
for (int i = 0; i < (imax + 2) * (jmax + 2) * (kmax + 2); i++) { for (int i = 0; i < (imax + 2) * (jmax + 2) * (kmax + 2); i++) {
s->u[i] = params->u_init; s->u[i] = params->u_init;
@ -108,6 +222,7 @@ void initSolver(Solver* s, Parameter* params)
s->f[i] = 0.0; s->f[i] = 0.0;
s->g[i] = 0.0; s->g[i] = 0.0;
s->h[i] = 0.0; s->h[i] = 0.0;
s->seg[i] = NONE;
} }
double dx = s->grid.dx; double dx = s->grid.dx;
@ -117,6 +232,194 @@ void initSolver(Solver* s, Parameter* params)
double invSqrSum = 1.0 / (dx * dx) + 1.0 / (dy * dy) + 1.0 / (dz * dz); double invSqrSum = 1.0 / (dx * dx) + 1.0 / (dy * dy) + 1.0 / (dz * dz);
s->dtBound = 0.5 * s->re * 1.0 / invSqrSum; s->dtBound = 0.5 * s->re * 1.0 / invSqrSum;
double xCenter = 0, yCenter = 0, zCenter = 0, radius = 0;
double x1 = 0, x2 = 0, y1 = 0, y2 = 0, z1 = 0, z2 = 0;
int* seg = s->seg;
switch (params->shape) {
case NOSHAPE:
break;
case RECT:
x1 = params->xCenter - params->xRectLength / 2;
x2 = params->xCenter + params->xRectLength / 2;
y1 = params->yCenter - params->yRectLength / 2;
y2 = params->yCenter + params->yRectLength / 2;
z1 = params->zCenter - params->zRectLength / 2;
z2 = params->zCenter + params->zRectLength / 2;
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 ((x1 <= (i * dx)) && ((i * dx) <= x2) && (y1 <= (j * dy)) &&
((j * dy) <= y2) && ((z1 <= (k * dz)) && ((k * dz) <= z2))) {
S(i, j, k) = LOCAL;
}
}
}
}
break;
case CIRCLE:
xCenter = params->xCenter;
yCenter = params->yCenter;
zCenter = params->zCenter;
radius = params->circleRadius;
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 (distance((i * dx),
(j * dy),
(k * dz),
xCenter,
yCenter,
zCenter) <= radius) {
S(i, j, k) = LOCAL;
}
}
}
}
break;
default:
break;
}
for (int k = 1; k < kmax + 1; k++) {
for (int j = 1; j < jmax + 1; j++) {
for (int i = 1; i < imax + 1; i++) {
/* Assigning enum values to Corners */
if (S(i - 1, j + 1, k - 1) == NONE && S(i - 1, j, k) == NONE &&
S(i, j + 1, k) == NONE && S(i, j, k - 1) == NONE &&
S(i + 1, j - 1, k + 1) == LOCAL && S(i, j, k) == LOCAL) {
S(i, j, k) = FRONTTOPLEFTCORNER; //
}
if (S(i + 1, j + 1, k - 1) == NONE && S(i + 1, j, k) == NONE &&
S(i, j + 1, k) == NONE && S(i, j, k - 1) == NONE &&
S(i - 1, j - 1, k + 1) == LOCAL && S(i, j, k) == LOCAL) {
S(i, j, k) = FRONTTOPRIGHTCORNER; //
}
if (S(i - 1, j - 1, k - 1) == NONE && S(i - 1, j, k) == NONE &&
S(i, j - 1, k) == NONE && S(i, j, k - 1) == NONE &&
S(i + 1, j + 1, k + 1) == LOCAL && S(i, j, k) == LOCAL) {
S(i, j, k) = FRONTBOTTOMLEFTCORNER; //
}
if (S(i + 1, j - 1, k - 1) == NONE && S(i + 1, j, k) == NONE &&
S(i, j - 1, k) == NONE && S(i, j, k - 1) == NONE &&
S(i - 1, j + 1, k + 1) == LOCAL && S(i, j, k) == LOCAL) {
S(i, j, k) = FRONTBOTTOMRIGHTCORNER; //
}
if (S(i - 1, j + 1, k + 1) == NONE && S(i - 1, j, k) == NONE &&
S(i, j + 1, k) == NONE && S(i, j, k + 1) == NONE &&
S(i + 1, j - 1, k - 1) == LOCAL && S(i, j, k) == LOCAL) {
S(i, j, k) = BACKTOPLEFTCORNER; //
}
if (S(i + 1, j + 1, k + 1) == NONE && S(i + 1, j, k) == NONE &&
S(i, j + 1, k) == NONE && S(i, j, k + 1) == NONE &&
S(i - 1, j - 1, k - 1) == LOCAL && S(i, j, k) == LOCAL) {
S(i, j, k) = BACKTOPRIGHTCORNER;
}
if (S(i - 1, j - 1, k + 1) == NONE && S(i - 1, j, k) == NONE &&
S(i, j - 1, k) == NONE && S(i, j, k + 1) == NONE &&
S(i + 1, j + 1, k - 1) == LOCAL && S(i, j, k) == LOCAL) {
S(i, j, k) = BACKBOTTOMLEFTCORNER;
}
if (S(i + 1, j - 1, k + 1) == NONE && S(i + 1, j, k) == NONE &&
S(i, j - 1, k) == NONE && S(i, j, k + 1) == NONE &&
S(i - 1, j + 1, k - 1) == LOCAL && S(i, j, k) == LOCAL) {
S(i, j, k) = BACKBOTTOMRIGHTCORNER;
}
/* Assigning enum values to Lines */
if (S(i - 1, j, k - 1) == NONE && S(i, j, k - 1) == NONE &&
S(i - 1, j, k) == NONE && S(i + 1, j, k + 1) == LOCAL &&
S(i, j, k) == LOCAL) {
S(i, j, k) = FRONTLEFTLINE;
}
if (S(i + 1, j, k - 1) == NONE && S(i + 1, j, k) == NONE &&
S(i, j, k - 1) == NONE && S(i - 1, j, k + 1) == LOCAL &&
S(i, j, k) == LOCAL) {
S(i, j, k) = FRONTRIGHTLINE;
}
if (S(i, j + 1, k - 1) == NONE && S(i, j + 1, k) == NONE &&
S(i, j, k - 1) == NONE && S(i, j - 1, k + 1) == LOCAL &&
S(i, j, k) == LOCAL) {
S(i, j, k) = FRONTTOPLINE;
}
if (S(i, j - 1, k - 1) == NONE && S(i, j, k - 1) == NONE &&
S(i, j - 1, k) == NONE && S(i, j + 1, k + 1) == LOCAL &&
S(i, j, k) == LOCAL) {
S(i, j, k) = FRONTBOTTOMLINE;
}
if (S(i - 1, j + 1, k) == NONE && S(i, j + 1, k) == NONE &&
S(i - 1, j, k) == NONE && S(i + 1, j - 1, k) == LOCAL &&
S(i, j, k) == LOCAL) {
S(i, j, k) = MIDTOPLEFTLINE;
}
if (S(i + 1, j + 1, k) == NONE && S(i + 1, j, k) == NONE &&
S(i, j + 1, k) == NONE && S(i - 1, j - 1, k) == LOCAL &&
S(i, j, k) == LOCAL) {
S(i, j, k) = MIDTOPRIGHTLINE;
}
if (S(i - 1, j - 1, k) == NONE && S(i - 1, j, k) == NONE &&
S(i, j - 1, k) == NONE && S(i + 1, j + 1, k) == LOCAL &&
S(i, j, k) == LOCAL) {
S(i, j, k) = MIDBOTTOMLEFTLINE;
}
if (S(i + 1, j - 1, k) == NONE && S(i + 1, j, k) == NONE &&
S(i, j - 1, k) == NONE && S(i - 1, j + 1, k) == LOCAL &&
S(i, j, k) == LOCAL) {
S(i, j, k) = MIDBOTTOMRIGHTLINE;
}
if (S(i - 1, j, k + 1) == NONE && S(i - 1, j, k) == NONE &&
S(i, j, k + 1) == NONE && S(i + 1, j, k - 1) == LOCAL &&
S(i, j, k) == LOCAL) {
S(i, j, k) = BACKLEFTLINE;
}
if (S(i + 1, j, k + 1) == NONE && S(i + 1, j, k) == NONE &&
S(i, j, k + 1) == NONE && S(i - 1, j, k - 1) == LOCAL &&
S(i, j, k) == LOCAL) {
S(i, j, k) = BACKRIGHTLINE;
}
if (S(i, j + 1, k + 1) == NONE && S(i, j + 1, k) == NONE &&
S(i, j, k + 1) == NONE && S(i, j - 1, k - 1) == LOCAL &&
S(i, j, k) == LOCAL) {
S(i, j, k) = BACKTOPLINE;
}
if (S(i, j - 1, k + 1) == NONE && S(i, j - 1, k) == NONE &&
S(i, j, k + 1) == NONE && S(i, j + 1, k - 1) == LOCAL &&
S(i, j, k) == LOCAL) {
S(i, j, k) = BACKBOTTOMLINE;
}
/* Assigning enum values to Faces */
if (S(i, j, k - 1) == NONE && S(i, j, k + 1) == LOCAL &&
S(i, j, k) == LOCAL) {
S(i, j, k) = FRONTFACE; //
}
if (S(i, j, k + 1) == NONE && S(i, j, k - 1) == LOCAL &&
S(i, j, k) == LOCAL) {
S(i, j, k) = BACKFACE; //
}
if (S(i, j - 1, k) == NONE && S(i, j + 1, k) == LOCAL &&
S(i, j, k) == LOCAL) {
S(i, j, k) = BOTTOMFACE; //
}
if (S(i, j + 1, k) == NONE && S(i, j - 1, k) == LOCAL &&
S(i, j, k) == LOCAL) {
S(i, j, k) = TOPFACE; //
}
if (S(i - 1, j, k) == NONE && S(i + 1, j, k) == LOCAL &&
S(i, j, k) == LOCAL) {
S(i, j, k) = LEFTFACE; //
}
if (S(i + 1, j, k) == NONE && S(i - 1, j, k) == LOCAL &&
S(i, j, k) == LOCAL) {
S(i, j, k) = RIGHTFACE; //
}
}
}
}
#ifdef VERBOSE #ifdef VERBOSE
printConfig(s); printConfig(s);
#endif /* VERBOSE */ #endif /* VERBOSE */
@ -321,8 +624,7 @@ void solveRBA(Solver* s)
double idx2 = 1.0 / dx2; double idx2 = 1.0 / dx2;
double idy2 = 1.0 / dy2; double idy2 = 1.0 / dy2;
double idz2 = 1.0 / dz2; double idz2 = 1.0 / dz2;
double factor = 0.5 * (dx2 * dy2 * dz2) / double factor = 0.5 * (dx2 * dy2 * dz2) / (dy2 * dz2 + dx2 * dz2 + dx2 * dy2);
(dy2 * dz2 + dx2 * dz2 + dx2 * dy2);
double* p = s->p; double* p = s->p;
double* rhs = s->rhs; double* rhs = s->rhs;
double epssq = eps * eps; double epssq = eps * eps;
@ -676,6 +978,19 @@ void setSpecialBoundaryCondition(Solver* s)
U(0, j, k) = y * (ylength - y) * 4.0 / (ylength * ylength); U(0, j, k) = y * (ylength - y) * 4.0 / (ylength * ylength);
} }
} }
} else if (strcmp(s->problem, "karman") == 0) {
for (int k = 1; k < kmax + 1; k++) {
for (int j = 1; j < jmax + 1; j++) {
U(0, j, k) = 1.0;
}
}
} else if (strcmp(s->problem, "backstep") == 0) {
for (int k = 1; k < kmax + 1; k++) {
for (int j = 1; j < jmax + 1; j++) {
U(0, j, k) = 1.0;
}
}
} }
} }
@ -896,3 +1211,170 @@ void adaptUV(Solver* s)
} }
} }
} }
void setObjectBoundaryCondition(Solver* s)
{
int imax = s->grid.imax;
int jmax = s->jmax;
int kmax = s->kmax;
double* u = s->u;
double* v = s->v;
double* w = s->w;
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:
U(i, j, k) = -U(i, j + 1, k);
U(i - 1, j, k) = -U(i - 1, j + 1, k);
V(i, j, k) = 0.0;
W(i, j, k) = 0.0;
break;
case BOTTOMFACE:
U(i, j, k) = -U(i, j - 1, k);
U(i - 1, j, k) = -U(i - 1, j - 1, k);
V(i, j, k) = 0.0;
W(i, j, k) = 0.0;
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;
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;
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);
break;
case BACKFACE:
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);
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;
break;
case TOP:
U(i, j) = -U(i, j + 1);
U(i - 1, j) = -U(i - 1, j + 1);
V(i, j) = 0.0;
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;
break;
case TOP:
U(i, j) = -U(i, j + 1);
U(i - 1, j) = -U(i - 1, j + 1);
V(i, j) = 0.0;
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;
break;
}
}
}
}
}

View File

@ -10,7 +10,46 @@
#include "grid.h" #include "grid.h"
#include "parameter.h" #include "parameter.h"
enum OBJECTBOUNDARY {
NONE = 0,
/* Front Corners */
FRONTTOPLEFTCORNER,
FRONTTOPRIGHTCORNER,
FRONTBOTTOMLEFTCORNER,
FRONTBOTTOMRIGHTCORNER,
/* Back Corners */
BACKTOPLEFTCORNER,
BACKTOPRIGHTCORNER,
BACKBOTTOMLEFTCORNER,
BACKBOTTOMRIGHTCORNER,
/* Faces */
FRONTFACE,
BACKFACE,
LEFTFACE,
RIGHTFACE,
TOPFACE,
BOTTOMFACE,
/* Front Lines remaining after Corners and Faces */
FRONTLEFTLINE,
FRONTRIGHTLINE,
FRONTTOPLINE,
FRONTBOTTOMLINE,
/* Bottom Lines remaining after Corners and Faces */
BACKLEFTLINE,
BACKRIGHTLINE,
BACKTOPLINE,
BACKBOTTOMLINE,
/* Mid Lines remaining after Corners and Faces */
MIDTOPLEFTLINE,
MIDTOPRIGHTLINE,
MIDBOTTOMLEFTLINE,
MIDBOTTOMRIGHTLINE,
/* Local where its an object but not a boundary */
LOCAL
};
enum BC { NOSLIP = 1, SLIP, OUTFLOW, PERIODIC }; enum BC { NOSLIP = 1, SLIP, OUTFLOW, PERIODIC };
/// @brief
enum SHAPE { NOSHAPE = 0, RECT, CIRCLE };
typedef struct { typedef struct {
/* geometry and grid information */ /* geometry and grid information */
@ -19,6 +58,7 @@ typedef struct {
double *p, *rhs; double *p, *rhs;
double *f, *g, *h; double *f, *g, *h;
double *u, *v, *w; double *u, *v, *w;
int* seg;
/* parameters */ /* parameters */
double eps, omega, rho; double eps, omega, rho;
double re, tau, gamma; double re, tau, gamma;
@ -39,8 +79,11 @@ extern void solveRBA(Solver*);
extern void normalizePressure(Solver*); extern void normalizePressure(Solver*);
extern void computeTimestep(Solver*); extern void computeTimestep(Solver*);
extern void setBoundaryConditions(Solver*); extern void setBoundaryConditions(Solver*);
extern void setObjectBoundaryCondition(Solver*);
extern void setSpecialBoundaryCondition(Solver*); extern void setSpecialBoundaryCondition(Solver*);
extern void computeFG(Solver*); extern void computeFG(Solver*);
extern void adaptUV(Solver*); extern void adaptUV(Solver*);
extern void writeResult(Solver*); extern void writeResult(Solver*);
extern void printGrid(Solver*, int*);
#endif #endif

View File

@ -8,8 +8,8 @@ name poisson
xlength 1.0 # domain size in x-direction xlength 1.0 # domain size in x-direction
ylength 1.0 # domain size in y-direction ylength 1.0 # domain size in y-direction
imax 200 # number of interior cells in x-direction imax 1000 # number of interior cells in x-direction
jmax 200 # number of interior cells in y-direction jmax 10000 # number of interior cells in y-direction
# Pressure Iteration Data: # Pressure Iteration Data:
# ----------------------- # -----------------------

View File

@ -0,0 +1,73 @@
Rank, SOR, RB
1, 1138.31, 447.94
2, 569.26, 225.46
3, 379.59, 150.36
4, 284.87, 112.45
5, 227.82, 89.36
6, 190.25, 75.91
7, 163.19, 64.62
8, 142.55, 56.34
9, 126.80, 49.90
10, 114.09, 45.32
11, 103.80, 40.71
12, 95.28, 37.55
13, 87.99, 35.60
14, 81.72, 33.19
15, 76.30, 30.71
16, 71.51, 29.01
17, 67.35, 26.94
18, 63.69, 25.98
19, 60.47, 24.49
20, 57.49, 23.21
21, 54.81, 22.22
22, 52.26, 21.01
23, 50.01, 20.81
24, 47.93, 19.83
25, 46.04, 18.94
26, 44.30, 18.01
27, 42.68, 17.71
28, 41.16, 16.93
29, 39.72, 16.33
30, 38.51, 16.10
31, 37.31, 15.27
32, 36.15, 14.86
33, 35.11, 14.31
34, 34.08, 13.76
35, 33.13, 13.50
36, 32.22, 13.41
37, 31.37, 12.86
38, 30.55, 12.65
39, 29.83, 12.04
40, 29.02, 11.88
41, 28.34, 11.45
42, 27.75, 11.33
43, 27.13, 10.96
44, 26.52, 10.69
45, 26.02, 10.43
46, 25.37, 10.24
47, 24.86, 10.07
48, 24.42, 9.76
49, 23.93, 9.85
50, 23.38, 9.44
51, 23.11, 9.33
52, 22.58, 9.01
53, 22.18, 8.95
54, 21.82, 8.78
55, 21.39, 8.56
56, 21.04, 8.45
57, 20.71, 8.30
58, 20.38, 8.10
59, 20.03, 7.99
60, 19.78, 7.77
61, 19.44, 7.64
62, 19.15, 7.55
63, 18.83, 7.46
64, 18.66, 7.29
65, 18.25, 7.19
66, 18.07, 7.09
67, 17.83, 7.02
68, 17.60, 6.90
69, 17.48, 6.84
70, 17.22, 6.78
71, 19.10, 6.74
72, 17.46, 6.83
1 Rank SOR RB
2 1 1138.31 447.94
3 2 569.26 225.46
4 3 379.59 150.36
5 4 284.87 112.45
6 5 227.82 89.36
7 6 190.25 75.91
8 7 163.19 64.62
9 8 142.55 56.34
10 9 126.80 49.90
11 10 114.09 45.32
12 11 103.80 40.71
13 12 95.28 37.55
14 13 87.99 35.60
15 14 81.72 33.19
16 15 76.30 30.71
17 16 71.51 29.01
18 17 67.35 26.94
19 18 63.69 25.98
20 19 60.47 24.49
21 20 57.49 23.21
22 21 54.81 22.22
23 22 52.26 21.01
24 23 50.01 20.81
25 24 47.93 19.83
26 25 46.04 18.94
27 26 44.30 18.01
28 27 42.68 17.71
29 28 41.16 16.93
30 29 39.72 16.33
31 30 38.51 16.10
32 31 37.31 15.27
33 32 36.15 14.86
34 33 35.11 14.31
35 34 34.08 13.76
36 35 33.13 13.50
37 36 32.22 13.41
38 37 31.37 12.86
39 38 30.55 12.65
40 39 29.83 12.04
41 40 29.02 11.88
42 41 28.34 11.45
43 42 27.75 11.33
44 43 27.13 10.96
45 44 26.52 10.69
46 45 26.02 10.43
47 46 25.37 10.24
48 47 24.86 10.07
49 48 24.42 9.76
50 49 23.93 9.85
51 50 23.38 9.44
52 51 23.11 9.33
53 52 22.58 9.01
54 53 22.18 8.95
55 54 21.82 8.78
56 55 21.39 8.56
57 56 21.04 8.45
58 57 20.71 8.30
59 58 20.38 8.10
60 59 20.03 7.99
61 60 19.78 7.77
62 61 19.44 7.64
63 62 19.15 7.55
64 63 18.83 7.46
65 64 18.66 7.29
66 65 18.25 7.19
67 66 18.07 7.09
68 67 17.83 7.02
69 68 17.60 6.90
70 69 17.48 6.84
71 70 17.22 6.78
72 71 19.10 6.74
73 72 17.46 6.83

39
PoissonSolver/2D-mpi/sample.sh Executable file
View File

@ -0,0 +1,39 @@
#!/bin/bash -l
#SBATCH --job-name=Sim
#SBATCH --output=Sim_Fritz.o%j
#SBATCH --partition=singlenode
#SBATCH --nodes=1
#SBATCH --ntasks-per-node=21
#SBATCH --ntasks=21
#SBATCH --time=20:00:00
#SBATCH --constraint=hwperf
#SBATCH --export=NONE
#SBATCH --cpu-freq=2400000-2400000:performance
unset SLURM_EXPORT_ENV
echo "Starting: $(date)"
export
module load python intel/2022.1.0 intelmpi/2021.7.0 itac #likwid/5.2.2
module list
cd $SLURM_SUBMIT_DIR
rm result.csv
touch result.csv
echo "Rank, SOR, RB" >> result.csv
for i in $(seq 1 1 72)
do
time="$i, "
time+="$(srun --cpu-freq=2200000-2200000:performance -n $i ./exe-ICC poisson.par 1 | grep 'Solution took' | cut -c 15-)"
time+=", "
time+="$(srun --cpu-freq=2200000-2200000:performance -n $i ./exe-ICC poisson.par 2 | grep 'Solution took' | cut -c 15-)"
time=${time//s}
echo $time >> result.csv
done

View File

@ -4,15 +4,16 @@
* Use of this source code is governed by a MIT-style * Use of this source code is governed by a MIT-style
* license that can be found in the LICENSE file. * license that can be found in the LICENSE file.
*/ */
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <limits.h>
#include <float.h> #include <float.h>
#include <limits.h>
#include <mpi.h> #include <mpi.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "parameter.h" #include "parameter.h"
#include "solver.h" #include "solver.h"
#include "timing.h"
enum VARIANT { SOR = 1, RB, RBA }; enum VARIANT { SOR = 1, RB, RBA };
@ -24,6 +25,8 @@ int main (int argc, char** argv)
Parameter params; Parameter params;
Solver solver; Solver solver;
double S, E;
MPI_Init(&argc, &argv); MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Comm_rank(MPI_COMM_WORLD, &rank);
initParameter(&params); initParameter(&params);
@ -34,18 +37,18 @@ int main (int argc, char** argv)
} }
readParameter(&params, argv[1]); readParameter(&params, argv[1]);
if (argc == 3) if (argc == 3) {
{
variant = atoi(argv[2]); variant = atoi(argv[2]);
} }
if (rank == 0) { if (rank == 0) {
printParameter(&params); printParameter(&params);
} }
initSolver(&solver, &params, 2); initSolver(&solver, &params, 2);
S = getTimeStamp();
switch (variant) { switch (variant) {
case SOR: case SOR:
printf("Plain SOR\n"); printf("Plain SOR\n");
@ -62,6 +65,12 @@ int main (int argc, char** argv)
} }
// getResult(&solver); // getResult(&solver);
E = getTimeStamp();
if (rank == 0) {
printf("Solution took %.2fs\n", E - S);
}
MPI_Finalize(); MPI_Finalize();
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }

View File

@ -4,14 +4,14 @@
* Use of this source code is governed by a MIT style * Use of this source code is governed by a MIT style
* license that can be found in the LICENSE file. * license that can be found in the LICENSE file.
*/ */
#include <stdlib.h>
#include <stdio.h>
#include <math.h> #include <math.h>
#include <mpi.h> #include <mpi.h>
#include <stdio.h>
#include <stdlib.h>
#include "solver.h"
#include "parameter.h"
#include "allocate.h" #include "allocate.h"
#include "parameter.h"
#include "solver.h"
#define PI 3.14159265358979323846 #define PI 3.14159265358979323846
#define P(i, j) p[(j) * (imax + 2) + (i)] #define P(i, j) p[(j) * (imax + 2) + (i)]
@ -27,7 +27,8 @@ static void print(Solver* solver)
double* p = solver->p; double* p = solver->p;
int imax = solver->imax; int imax = solver->imax;
printf("### RANK %d #######################################################\n", solver->rank); printf("### RANK %d #######################################################\n",
solver->rank);
for (int j = 0; j < solver->jmaxLocal + 2; j++) { for (int j = 0; j < solver->jmaxLocal + 2; j++) {
printf("%02d: ", j); printf("%02d: ", j);
for (int i = 0; i < solver->imax + 2; i++) { for (int i = 0; i < solver->imax + 2; i++) {
@ -40,7 +41,10 @@ static void print(Solver* solver)
static void exchange(Solver* solver) static void exchange(Solver* solver)
{ {
MPI_Request requests[4] = { MPI_REQUEST_NULL, MPI_REQUEST_NULL, MPI_REQUEST_NULL, MPI_REQUEST_NULL }; MPI_Request requests[4] = { MPI_REQUEST_NULL,
MPI_REQUEST_NULL,
MPI_REQUEST_NULL,
MPI_REQUEST_NULL };
/* exchange ghost cells with top neighbor */ /* exchange ghost cells with top neighbor */
if (solver->rank + 1 < solver->size) { if (solver->rank + 1 < solver->size) {
@ -87,8 +91,15 @@ void getResult(Solver *solver)
int cnt = solver->jmaxLocal * (solver->imax + 2); int cnt = solver->jmaxLocal * (solver->imax + 2);
double* sendbuffer = solver->p + (solver->imax + 2); double* sendbuffer = solver->p + (solver->imax + 2);
MPI_Gatherv(sendbuffer, cnt, MPI_DOUBLE, Pall, MPI_Gatherv(sendbuffer,
rcvCounts, displs, MPI_DOUBLE, 0, MPI_COMM_WORLD); cnt,
MPI_DOUBLE,
Pall,
rcvCounts,
displs,
MPI_DOUBLE,
0,
MPI_COMM_WORLD);
if (solver->rank == 0) { if (solver->rank == 0) {
writeResult(solver, Pall, "p.dat"); writeResult(solver, Pall, "p.dat");
@ -102,7 +113,10 @@ void initSolver(Solver *solver, Parameter *params, int problem)
solver->imax = params->imax; solver->imax = params->imax;
solver->jmax = params->jmax; solver->jmax = params->jmax;
solver->jmaxLocal = sizeOfRank(solver->rank, solver->size, solver->jmax); solver->jmaxLocal = sizeOfRank(solver->rank, solver->size, solver->jmax);
printf("RANK %d: imaxLocal : %d, jmaxLocal : %d\n", solver->rank, solver->imax, solver->jmaxLocal); printf("RANK %d: imaxLocal : %d, jmaxLocal : %d\n",
solver->rank,
solver->imax,
solver->jmaxLocal);
solver->dx = params->xlength / params->imax; solver->dx = params->xlength / params->imax;
solver->dy = params->ylength / params->jmax; solver->dy = params->ylength / params->jmax;
@ -355,7 +369,6 @@ int solveRBA(Solver* solver)
double rho = solver->rho; double rho = solver->rho;
double epssq = eps * eps; double epssq = eps * eps;
res = eps + 1.0; res = eps + 1.0;
while ((res >= epssq) && (it < itermax)) { while ((res >= epssq) && (it < itermax)) {

View File

@ -33,7 +33,7 @@ $(BUILD_DIR)/%.o: %.c $(MAKE_DIR)/include_$(TAG).mk
$(BUILD_DIR)/%.s: %.c $(BUILD_DIR)/%.s: %.c
$(info ===> GENERATE ASM $@) $(info ===> GENERATE ASM $@)
$(CC) -S $(CPPFLAGS) $(CFLAGS) $< -o $@ $(CC) -S -fverbose-asm $(CPPFLAGS) $(CFLAGS) $< -o $@
.PHONY: clean distclean tags info asm .PHONY: clean distclean tags info asm

View File

@ -7,8 +7,8 @@ OPENMP = -qopenmp
endif endif
VERSION = --version VERSION = --version
CFLAGS = -O3 -xHost -qopt-zmm-usage=high -std=c99 $(OPENMP) CFLAGS = -O3 -xHost -fp-model=precise -qopt-zmm-usage=high -std=c99 $(OPENMP)
LFLAGS = $(OPENMP) LFLAGS = $(OPENMP) -llikwid
DEFINES = -D_GNU_SOURCE DEFINES = -D_GNU_SOURCE -DLIKWID_PERFMON
INCLUDES = INCLUDES = -I/apps/likwid/5.2.2/include
LIBS = LIBS = -L/apps/likwid/5.2.2/lib

File diff suppressed because one or more lines are too long

View File

@ -8,8 +8,8 @@ name poisson
xlength 1.0 # domain size in x-direction xlength 1.0 # domain size in x-direction
ylength 1.0 # domain size in y-direction ylength 1.0 # domain size in y-direction
imax 300 # number of interior cells in x-direction imax 1000 # number of interior cells in x-direction
jmax 300 # number of interior cells in y-direction jmax 1000 # number of interior cells in y-direction
# Pressure Iteration Data: # Pressure Iteration Data:
# ----------------------- # -----------------------

View File

@ -41,8 +41,6 @@ int main(int argc, char** argv)
readParameter(&params, argv[1]); readParameter(&params, argv[1]);
// printParameter(&params); // printParameter(&params);
initSolver(&solver, &params, 2); initSolver(&solver, &params, 2);
if (argc == 3) { if (argc == 3) {
variant = atoi(argv[2]); variant = atoi(argv[2]);
@ -62,8 +60,8 @@ int main(int argc, char** argv)
LIKWID_PROFILE("RBA", solveRBA); LIKWID_PROFILE("RBA", solveRBA);
break; break;
} }
//printf("Solution took %.2fs\n", endTime - startTime); printf("Solution took %.2fs\n", endTime - startTime);
writeResult(&solver); // writeResult(&solver);
LIKWID_MARKER_CLOSE; LIKWID_MARKER_CLOSE;
return EXIT_SUCCESS; return EXIT_SUCCESS;

BIN
log/All in One.pptx Normal file

Binary file not shown.

BIN
log/Enhanced Solver.pptx Normal file

Binary file not shown.

BIN
log/Particel Tracing.pptx Normal file

Binary file not shown.

Binary file not shown.