Refactored code according to language server
This commit is contained in:
parent
120be69102
commit
1987056dce
@ -11,15 +11,15 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "parameter.h"
|
#include "parameter.h"
|
||||||
|
#include "particletracing.h"
|
||||||
#include "progress.h"
|
#include "progress.h"
|
||||||
#include "solver.h"
|
#include "solver.h"
|
||||||
#include "particletracing.h"
|
|
||||||
#include "timing.h"
|
#include "timing.h"
|
||||||
#include "vtkWriter.h"
|
#include "vtkWriter.h"
|
||||||
|
|
||||||
enum VARIANT { SOR = 1, RB, RBA };
|
enum VARIANT { SOR = 1, RB, RBA };
|
||||||
|
|
||||||
int main (int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
int rank;
|
int rank;
|
||||||
int variant = RB;
|
int variant = RB;
|
||||||
@ -36,8 +36,7 @@ int main (int argc, char** argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
readParameter(¶ms, argv[1]);
|
readParameter(¶ms, argv[1]);
|
||||||
if (argc == 3)
|
if (argc == 3) {
|
||||||
{
|
|
||||||
variant = atoi(argv[2]);
|
variant = atoi(argv[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,7 +54,7 @@ int main (int argc, char** argv)
|
|||||||
double t = 0.0;
|
double t = 0.0;
|
||||||
int nt = 0;
|
int nt = 0;
|
||||||
|
|
||||||
void (*solver_generic[])() = {solve, solveRB, solveRBA};
|
void (*solver_generic[])() = { solve, solveRB, solveRBA };
|
||||||
|
|
||||||
// printGrid(&solver, solver.s);
|
// printGrid(&solver, solver.s);
|
||||||
|
|
||||||
@ -63,8 +62,7 @@ int main (int argc, char** argv)
|
|||||||
|
|
||||||
S = getTimeStamp();
|
S = getTimeStamp();
|
||||||
|
|
||||||
while (t <= te)
|
while (t <= te) {
|
||||||
{
|
|
||||||
if (tau > 0.0) computeTimestep(&solver);
|
if (tau > 0.0) computeTimestep(&solver);
|
||||||
setBoundaryConditions(&solver);
|
setBoundaryConditions(&solver);
|
||||||
setSpecialBoundaryCondition(&solver);
|
setSpecialBoundaryCondition(&solver);
|
||||||
@ -76,14 +74,13 @@ int main (int argc, char** argv)
|
|||||||
solver_generic[variant - 1](&solver);
|
solver_generic[variant - 1](&solver);
|
||||||
adaptUV(&solver);
|
adaptUV(&solver);
|
||||||
|
|
||||||
|
/* Added function for particle tracing. Will inject and advance particles as per
|
||||||
/* Added function for particle tracing. Will inject and advance particles as per timePeriod */
|
* timePeriod */
|
||||||
trace(&particletracer, solver.u, solver.v, solver.s, t);
|
trace(&particletracer, solver.u, solver.v, solver.s, t);
|
||||||
|
|
||||||
t += solver.dt;
|
t += solver.dt;
|
||||||
nt++;
|
nt++;
|
||||||
|
|
||||||
|
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
printf("TIME %f , TIMESTEP %f\n", t, solver.dt);
|
printf("TIME %f , TIMESTEP %f\n", t, solver.dt);
|
||||||
#else
|
#else
|
||||||
@ -92,7 +89,7 @@ int main (int argc, char** argv)
|
|||||||
}
|
}
|
||||||
printf("Total particles : %d\n", particletracer.totalParticles);
|
printf("Total particles : %d\n", particletracer.totalParticles);
|
||||||
|
|
||||||
//print(&solver, solver.p);
|
// print(&solver, solver.p);
|
||||||
|
|
||||||
E = getTimeStamp();
|
E = getTimeStamp();
|
||||||
stopProgress();
|
stopProgress();
|
||||||
|
@ -98,7 +98,6 @@ void readParameter(Parameter* param, const char* filename)
|
|||||||
PARSE_REAL(xRectLength);
|
PARSE_REAL(xRectLength);
|
||||||
PARSE_REAL(yRectLength);
|
PARSE_REAL(yRectLength);
|
||||||
PARSE_REAL(circleRadius);
|
PARSE_REAL(circleRadius);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,10 +131,14 @@ void printParameter(Parameter* param)
|
|||||||
printf("\trho (SOR relaxation): %f\n", param->rho);
|
printf("\trho (SOR relaxation): %f\n", param->rho);
|
||||||
|
|
||||||
printf("Particle Tracing data:\n");
|
printf("Particle Tracing data:\n");
|
||||||
printf("\tNumber of particles : %d being injected for every period of %.2f\n", param->numberOfParticles, param->injectTimePeriod);
|
printf("\tNumber of particles : %d being injected for every period of %.2f\n",
|
||||||
|
param->numberOfParticles,
|
||||||
|
param->injectTimePeriod);
|
||||||
printf("\tstartTime : %.2f\n", param->startTime);
|
printf("\tstartTime : %.2f\n", param->startTime);
|
||||||
printf("\t(Line along which the particles are to be injected) \n\tx1 : %.2f, y1 : %.2f, x2 : %.2f, y2 : %.2f\n", param->x1, param->y1, param->x2, param->y2);
|
printf("\t(Line along which the particles are to be injected) \n\tx1 : %.2f, y1 : "
|
||||||
|
"%.2f, x2 : %.2f, y2 : %.2f\n",
|
||||||
|
param->x1,
|
||||||
|
param->y1,
|
||||||
|
param->x2,
|
||||||
|
param->y2);
|
||||||
}
|
}
|
||||||
|
@ -12,48 +12,50 @@
|
|||||||
|
|
||||||
#include "vtkWriter.h"
|
#include "vtkWriter.h"
|
||||||
|
|
||||||
#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)]
|
#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)
|
||||||
{
|
{
|
||||||
for(int i = 0; i < particletracer->totalParticles; ++i)
|
for (int i = 0; i < particletracer->totalParticles; ++i) {
|
||||||
{
|
printf("Particle position X : %.2f, Y : %.2f, flag : %d\n",
|
||||||
printf("Particle position X : %.2f, Y : %.2f, flag : %d\n", particletracer->particlePool[i].x,
|
particletracer->particlePool[i].x,
|
||||||
particletracer->particlePool[i].y,
|
particletracer->particlePool[i].y,
|
||||||
particletracer->particlePool[i].flag);
|
particletracer->particlePool[i].flag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void injectParticles(ParticleTracer* particletracer)
|
void injectParticles(ParticleTracer* particletracer)
|
||||||
{
|
{
|
||||||
for(int i = 0; i < particletracer->numberOfParticles; ++i)
|
for (int i = 0; i < particletracer->numberOfParticles; ++i) {
|
||||||
{
|
particletracer->particlePool[particletracer->pointer]
|
||||||
particletracer->particlePool[particletracer->pointer].x = particletracer->linSpaceLine[i].x;
|
.x = particletracer->linSpaceLine[i].x;
|
||||||
particletracer->particlePool[particletracer->pointer].y = particletracer->linSpaceLine[i].y;
|
particletracer->particlePool[particletracer->pointer]
|
||||||
|
.y = particletracer->linSpaceLine[i].y;
|
||||||
particletracer->particlePool[particletracer->pointer].flag = true;
|
particletracer->particlePool[particletracer->pointer].flag = true;
|
||||||
++(particletracer->pointer);
|
++(particletracer->pointer);
|
||||||
++(particletracer->totalParticles);
|
++(particletracer->totalParticles);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void advanceParticles(ParticleTracer* particletracer, double* restrict u, double* restrict v, int* restrict s, 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;
|
||||||
|
|
||||||
|
|
||||||
double dx = particletracer->dx;
|
double dx = particletracer->dx;
|
||||||
double dy = particletracer->dy;
|
double dy = particletracer->dy;
|
||||||
|
|
||||||
double xlength = particletracer->xlength;
|
double xlength = particletracer->xlength;
|
||||||
double ylength = particletracer->ylength;
|
double ylength = particletracer->ylength;
|
||||||
|
|
||||||
for(int i = 0; i < particletracer->totalParticles; ++i)
|
for (int i = 0; i < particletracer->totalParticles; ++i) {
|
||||||
{
|
if (particletracer->particlePool[i].flag == true) {
|
||||||
if(particletracer->particlePool[i].flag == true)
|
|
||||||
{
|
|
||||||
double x = particletracer->particlePool[i].x;
|
double x = particletracer->particlePool[i].x;
|
||||||
double y = particletracer->particlePool[i].y;
|
double y = particletracer->particlePool[i].y;
|
||||||
|
|
||||||
@ -66,12 +68,12 @@ void advanceParticles(ParticleTracer* particletracer, double* restrict u, double
|
|||||||
double y2 = ((double)jCoord - 0.5) * dy;
|
double y2 = ((double)jCoord - 0.5) * dy;
|
||||||
|
|
||||||
double u_n = (1.0 / (dx * dy)) *
|
double u_n = (1.0 / (dx * dy)) *
|
||||||
((x2 - x) * (y2 - y) * U(iCoord - 1, jCoord - 1) +
|
((x2 - x) * (y2 - y) * U(iCoord - 1, jCoord - 1) +
|
||||||
(x - x1) * (y2 - y) * U(iCoord, jCoord - 1) +
|
(x - x1) * (y2 - y) * U(iCoord, jCoord - 1) +
|
||||||
(x2 - x) * (y - y1) * U(iCoord - 1, jCoord) +
|
(x2 - x) * (y - y1) * U(iCoord - 1, jCoord) +
|
||||||
(x - x1) * (y - y1) * U(iCoord, jCoord));
|
(x - x1) * (y - y1) * U(iCoord, jCoord));
|
||||||
|
|
||||||
double new_x = x + particletracer->dt * u_n;
|
double new_x = x + particletracer->dt * u_n;
|
||||||
particletracer->particlePool[i].x = new_x;
|
particletracer->particlePool[i].x = new_x;
|
||||||
|
|
||||||
iCoord = (int)((x + 0.5 * dx) / dx) + 1;
|
iCoord = (int)((x + 0.5 * dx) / dx) + 1;
|
||||||
@ -83,28 +85,33 @@ void advanceParticles(ParticleTracer* particletracer, double* restrict u, double
|
|||||||
y2 = (double)jCoord * dy;
|
y2 = (double)jCoord * dy;
|
||||||
|
|
||||||
double v_n = (1.0 / (dx * dy)) *
|
double v_n = (1.0 / (dx * dy)) *
|
||||||
((x2 - x) * (y2 - y) * V(iCoord - 1, jCoord - 1) +
|
((x2 - x) * (y2 - y) * V(iCoord - 1, jCoord - 1) +
|
||||||
(x - x1) * (y2 - y) * V(iCoord, jCoord - 1) +
|
(x - x1) * (y2 - y) * V(iCoord, jCoord - 1) +
|
||||||
(x2 - x) * (y - y1) * V(iCoord - 1, jCoord) +
|
(x2 - x) * (y - y1) * V(iCoord - 1, jCoord) +
|
||||||
(x - x1) * (y - y1) * V(iCoord, jCoord));
|
(x - x1) * (y - y1) * V(iCoord, jCoord));
|
||||||
|
|
||||||
double new_y = y + particletracer->dt * v_n;
|
double new_y = y + particletracer->dt * v_n;
|
||||||
particletracer->particlePool[i].y = new_y;
|
particletracer->particlePool[i].y = new_y;
|
||||||
|
|
||||||
// printf("\tOld X : %.2f, New X : %.2f, iCoord : %d\n\tOld Y : %.2f, New Y : %.2f, jCoord : %d\n\n", x, new_x, iCoord, y, new_y, jCoord);
|
// printf("\tOld X : %.2f, New X : %.2f, iCoord : %d\n\tOld Y : %.2f, New Y :
|
||||||
// printf("\tU(iCoord - 1, jCoord - 1) : %.2f, U(iCoord, jCoord - 1) : %.2f, U(iCoord - 1, jCoord) : %.2f, U(iCoord, jCoord) : %.2f\n", U(iCoord - 1, jCoord - 1), U(iCoord, jCoord - 1), U(iCoord - 1, jCoord), U(iCoord, jCoord));
|
// %.2f, jCoord : %d\n\n", x, new_x, iCoord, y, new_y, jCoord);
|
||||||
// printf("\tV(iCoord - 1, jCoord - 1) : %.2f, V(iCoord, jCoord - 1) : %.2f, V(iCoord - 1, jCoord) : %.2f, V(iCoord, jCoord) : %.2f\n\n", V(iCoord - 1, jCoord - 1), V(iCoord, jCoord - 1), V(iCoord - 1, jCoord), V(iCoord, jCoord));
|
// printf("\tU(iCoord - 1, jCoord - 1) : %.2f, U(iCoord, jCoord - 1) : %.2f,
|
||||||
// printf("\t U N : %.2f, V N : %.2f\n\n", u_n, v_n);
|
// U(iCoord - 1, jCoord) : %.2f, U(iCoord, jCoord) : %.2f\n", U(iCoord - 1,
|
||||||
// printf("\t j-1 * (imax + 2) + i-1 = %d with element from U : %.2f", (jCoord - 1) * (200 + 2) + (iCoord - 1), u[(jCoord - 1) * (imax + 2) + (iCoord - 1)]);
|
// jCoord - 1), U(iCoord, jCoord - 1), U(iCoord - 1, jCoord), U(iCoord,
|
||||||
// printf("\nimax : %d, jmax : %d\n", imax, jmax);
|
// jCoord)); printf("\tV(iCoord - 1, jCoord - 1) : %.2f, V(iCoord, jCoord - 1)
|
||||||
|
// : %.2f, V(iCoord - 1, jCoord) : %.2f, V(iCoord, jCoord) : %.2f\n\n",
|
||||||
|
// V(iCoord - 1, jCoord - 1), V(iCoord, jCoord - 1), V(iCoord - 1, jCoord),
|
||||||
|
// V(iCoord, jCoord)); printf("\t U N : %.2f, V N : %.2f\n\n", u_n, v_n);
|
||||||
|
// printf("\t j-1 * (imax + 2) + i-1 = %d with element from U : %.2f", (jCoord
|
||||||
|
// - 1) * (200 + 2) + (iCoord - 1), u[(jCoord - 1) * (imax + 2) + (iCoord -
|
||||||
|
// 1)]); printf("\nimax : %d, jmax : %d\n", imax, jmax);
|
||||||
|
|
||||||
if (((new_x < 0.0) || (new_x > xlength) || (new_y < 0.0) || (new_y > ylength)))
|
if (((new_x < 0.0) || (new_x > xlength) || (new_y < 0.0) ||
|
||||||
{
|
(new_y > ylength))) {
|
||||||
particletracer->particlePool[i].flag = false;
|
particletracer->particlePool[i].flag = false;
|
||||||
}
|
}
|
||||||
int i_new = new_x/dx, j_new = new_y/dy;
|
int i_new = new_x / dx, j_new = new_y / dy;
|
||||||
if(S(i_new, j_new) != NONE)
|
if (S(i_new, j_new) != NONE) {
|
||||||
{
|
|
||||||
particletracer->particlePool[i].flag = false;
|
particletracer->particlePool[i].flag = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -138,8 +145,7 @@ void writeParticles(ParticleTracer* particletracer)
|
|||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < particletracer->totalParticles; ++i)
|
for (int i = 0; i < particletracer->totalParticles; ++i) {
|
||||||
{
|
|
||||||
double x = particlePool[i].x;
|
double x = particlePool[i].x;
|
||||||
double y = particlePool[i].y;
|
double y = particlePool[i].y;
|
||||||
fprintf(fp, "%f %f\n", x, y);
|
fprintf(fp, "%f %f\n", x, y);
|
||||||
@ -156,69 +162,79 @@ void initParticleTracer(ParticleTracer* particletracer, Parameter* params)
|
|||||||
particletracer->injectTimePeriod = params->injectTimePeriod;
|
particletracer->injectTimePeriod = params->injectTimePeriod;
|
||||||
particletracer->writeTimePeriod = params->writeTimePeriod;
|
particletracer->writeTimePeriod = params->writeTimePeriod;
|
||||||
|
|
||||||
particletracer->dt = params->dt;
|
particletracer->dt = params->dt;
|
||||||
particletracer->dx = params->xlength / params->imax;
|
particletracer->dx = params->xlength / params->imax;
|
||||||
particletracer->dy = params->ylength / params->jmax;
|
particletracer->dy = params->ylength / params->jmax;
|
||||||
|
|
||||||
particletracer->xlength = params->xlength;
|
particletracer->xlength = params->xlength;
|
||||||
particletracer->ylength = params->ylength;
|
particletracer->ylength = params->ylength;
|
||||||
|
|
||||||
particletracer->x1 = params->x1;
|
particletracer->x1 = params->x1;
|
||||||
particletracer->y1 = params->y1;
|
particletracer->y1 = params->y1;
|
||||||
particletracer->x2 = params->x2;
|
particletracer->x2 = params->x2;
|
||||||
particletracer->y2 = params->y2;
|
particletracer->y2 = params->y2;
|
||||||
|
|
||||||
particletracer->lastInjectTime = params->startTime;
|
particletracer->lastInjectTime = params->startTime;
|
||||||
particletracer->lastUpdateTime = params->startTime;
|
particletracer->lastUpdateTime = params->startTime;
|
||||||
particletracer->lastWriteTime = params->startTime;
|
particletracer->lastWriteTime = params->startTime;
|
||||||
|
|
||||||
particletracer->pointer = 0;
|
particletracer->pointer = 0;
|
||||||
particletracer->totalParticles = 0;
|
particletracer->totalParticles = 0;
|
||||||
|
|
||||||
particletracer->imax = params->imax;
|
particletracer->imax = params->imax;
|
||||||
particletracer->jmax = params->jmax;
|
particletracer->jmax = params->jmax;
|
||||||
|
|
||||||
particletracer->estimatedNumParticles = ((params->te - params->startTime) + 2 ) * params->numberOfParticles;
|
particletracer->estimatedNumParticles = ((params->te - params->startTime) + 2) *
|
||||||
|
params->numberOfParticles;
|
||||||
|
|
||||||
particletracer->particlePool = malloc(sizeof(Particle) * particletracer->estimatedNumParticles);
|
particletracer->particlePool = malloc(
|
||||||
particletracer->linSpaceLine = malloc(sizeof(Particle) * particletracer->numberOfParticles);
|
sizeof(Particle) * particletracer->estimatedNumParticles);
|
||||||
|
particletracer->linSpaceLine = malloc(
|
||||||
|
sizeof(Particle) * particletracer->numberOfParticles);
|
||||||
|
|
||||||
|
for (int i = 0; i < particletracer->numberOfParticles; ++i) {
|
||||||
for (int i = 0; i < particletracer->numberOfParticles; ++i)
|
double spacing = (double)i / (double)(particletracer->numberOfParticles - 1);
|
||||||
{
|
particletracer->linSpaceLine[i].x = spacing * particletracer->x1 +
|
||||||
double spacing = (double)i / (double)(particletracer->numberOfParticles - 1);
|
(1.0 - spacing) * particletracer->x2;
|
||||||
particletracer->linSpaceLine[i].x = spacing * particletracer->x1 + (1.0 - spacing) * particletracer->x2;
|
particletracer->linSpaceLine[i].y = spacing * particletracer->y1 +
|
||||||
particletracer->linSpaceLine[i].y = spacing * particletracer->y1 + (1.0 - spacing) * particletracer->y2;
|
(1.0 - spacing) * particletracer->y2;
|
||||||
particletracer->linSpaceLine[i].flag = true;
|
particletracer->linSpaceLine[i].flag = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void printParticleTracerParameters(ParticleTracer* particletracer)
|
void printParticleTracerParameters(ParticleTracer* particletracer)
|
||||||
{
|
{
|
||||||
printf("Particle Tracing data:\n");
|
printf("Particle Tracing data:\n");
|
||||||
printf("\tNumber of particles : %d being injected for every period of %.2f\n", particletracer->numberOfParticles, particletracer->injectTimePeriod);
|
printf("\tNumber of particles : %d being injected for every period of %.2f\n",
|
||||||
|
particletracer->numberOfParticles,
|
||||||
|
particletracer->injectTimePeriod);
|
||||||
printf("\tstartTime : %.2f\n", particletracer->startTime);
|
printf("\tstartTime : %.2f\n", particletracer->startTime);
|
||||||
printf("\t(Line along which the particles are to be injected) \n\tx1 : %.2f, y1 : %.2f, x2 : %.2f, y2 : %.2f\n", particletracer->x1, particletracer->y1, particletracer->x2, particletracer->y2);
|
printf("\t(Line along which the particles are to be injected) \n\tx1 : %.2f, y1 : "
|
||||||
printf("\tPointer : %d, TotalParticles : %d\n", particletracer->pointer, particletracer->totalParticles);
|
"%.2f, x2 : %.2f, y2 : %.2f\n",
|
||||||
printf("\tdt : %.2f, dx : %.2f, dy : %.2f\n", particletracer->dt, particletracer->dx, particletracer->dy);
|
particletracer->x1,
|
||||||
|
particletracer->y1,
|
||||||
|
particletracer->x2,
|
||||||
|
particletracer->y2);
|
||||||
|
printf("\tPointer : %d, TotalParticles : %d\n",
|
||||||
|
particletracer->pointer,
|
||||||
|
particletracer->totalParticles);
|
||||||
|
printf("\tdt : %.2f, dx : %.2f, dy : %.2f\n",
|
||||||
|
particletracer->dt,
|
||||||
|
particletracer->dx,
|
||||||
|
particletracer->dy);
|
||||||
}
|
}
|
||||||
|
|
||||||
void trace(ParticleTracer* particletracer, double* u, double* v, int* s, double time)
|
void trace(ParticleTracer* particletracer, double* u, double* v, int* s, double time)
|
||||||
{
|
{
|
||||||
if (time >= particletracer->startTime)
|
if (time >= particletracer->startTime) {
|
||||||
{
|
// printParticles(particletracer);
|
||||||
//printParticles(particletracer);
|
if ((time - particletracer->lastInjectTime) >= particletracer->injectTimePeriod) {
|
||||||
if( (time - particletracer->lastInjectTime) >= particletracer->injectTimePeriod)
|
|
||||||
{
|
|
||||||
injectParticles(particletracer);
|
injectParticles(particletracer);
|
||||||
particletracer->lastInjectTime = time;
|
particletracer->lastInjectTime = time;
|
||||||
}
|
}
|
||||||
if( (time - particletracer->lastWriteTime) >= particletracer->writeTimePeriod)
|
if ((time - particletracer->lastWriteTime) >= particletracer->writeTimePeriod) {
|
||||||
{
|
|
||||||
writeParticles(particletracer);
|
writeParticles(particletracer);
|
||||||
particletracer->lastWriteTime = time;
|
particletracer->lastWriteTime = time;
|
||||||
|
|
||||||
}
|
}
|
||||||
advanceParticles(particletracer, u, v, s, time);
|
advanceParticles(particletracer, u, v, s, time);
|
||||||
compress(particletracer);
|
compress(particletracer);
|
||||||
@ -232,12 +248,10 @@ void compress(ParticleTracer* particletracer)
|
|||||||
Particle tempPool[particletracer->totalParticles];
|
Particle tempPool[particletracer->totalParticles];
|
||||||
int totalParticles = 0;
|
int totalParticles = 0;
|
||||||
|
|
||||||
for(int i=0; i < particletracer->totalParticles; ++i)
|
for (int i = 0; i < particletracer->totalParticles; ++i) {
|
||||||
{
|
if (memPool[i].flag == 1) {
|
||||||
if(memPool[i].flag == 1)
|
tempPool[totalParticles].x = memPool[i].x;
|
||||||
{
|
tempPool[totalParticles].y = memPool[i].y;
|
||||||
tempPool[totalParticles].x = memPool[i].x;
|
|
||||||
tempPool[totalParticles].y = memPool[i].y;
|
|
||||||
tempPool[totalParticles].flag = memPool[i].flag;
|
tempPool[totalParticles].flag = memPool[i].flag;
|
||||||
++totalParticles;
|
++totalParticles;
|
||||||
}
|
}
|
||||||
@ -245,5 +259,5 @@ void compress(ParticleTracer* particletracer)
|
|||||||
|
|
||||||
particletracer->totalParticles = totalParticles;
|
particletracer->totalParticles = totalParticles;
|
||||||
particletracer->pointer = totalParticles + 1;
|
particletracer->pointer = totalParticles + 1;
|
||||||
memcpy(particletracer->particlePool, tempPool, totalParticles*sizeof(Particle));
|
memcpy(particletracer->particlePool, tempPool, totalParticles * sizeof(Particle));
|
||||||
}
|
}
|
@ -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;
|
double x, y;
|
||||||
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;
|
int estimatedNumParticles;
|
||||||
|
|
||||||
@ -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*, int*, 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* , int* , double );
|
void trace(ParticleTracer*, double*, double*, int*, double);
|
||||||
void compress(ParticleTracer* );
|
void compress(ParticleTracer*);
|
||||||
#endif
|
#endif
|
@ -71,27 +71,24 @@ void vtkParticle(VtkOptions* o, char* name)
|
|||||||
|
|
||||||
fprintf(o->fh, "POINTS %d float\n", o->particletracer->totalParticles);
|
fprintf(o->fh, "POINTS %d float\n", o->particletracer->totalParticles);
|
||||||
|
|
||||||
|
for (int i = 0; i < o->particletracer->totalParticles; ++i) {
|
||||||
for (int i = 0; i < o->particletracer->totalParticles; ++i)
|
|
||||||
{
|
|
||||||
double x = particlePool[i].x;
|
double x = particlePool[i].x;
|
||||||
double y = particlePool[i].y;
|
double y = particlePool[i].y;
|
||||||
fprintf(o->fh, "%.2f %.2f 0.0\n", x, y);
|
fprintf(o->fh, "%.2f %.2f 0.0\n", x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(o->fh, "CELLS %d %d\n", o->particletracer->totalParticles, 2 * o->particletracer->totalParticles);
|
fprintf(o->fh,
|
||||||
|
"CELLS %d %d\n",
|
||||||
|
o->particletracer->totalParticles,
|
||||||
|
2 * o->particletracer->totalParticles);
|
||||||
|
|
||||||
|
for (int i = 0; i < o->particletracer->totalParticles; ++i) {
|
||||||
for (int i = 0; i < o->particletracer->totalParticles; ++i)
|
|
||||||
{
|
|
||||||
fprintf(o->fh, "1 %d\n", i);
|
fprintf(o->fh, "1 %d\n", i);
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(o->fh, "CELL_TYPES %d\n", o->particletracer->totalParticles);
|
fprintf(o->fh, "CELL_TYPES %d\n", o->particletracer->totalParticles);
|
||||||
|
|
||||||
|
for (int i = 0; i < o->particletracer->totalParticles; ++i) {
|
||||||
for (int i = 0; i < o->particletracer->totalParticles; ++i)
|
|
||||||
{
|
|
||||||
fprintf(o->fh, "1\n");
|
fprintf(o->fh, "1\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ static void setupCommunication(Comm* c, Direction direction, int layer)
|
|||||||
MPI_DOUBLE,
|
MPI_DOUBLE,
|
||||||
&c->rbufferTypes[direction]);
|
&c->rbufferTypes[direction]);
|
||||||
MPI_Type_commit(&c->rbufferTypes[direction]);
|
MPI_Type_commit(&c->rbufferTypes[direction]);
|
||||||
MPI_Type_create_subarray(NDIMS,
|
MPI_Type_create_subarray(NDIMS,
|
||||||
sizes,
|
sizes,
|
||||||
subSizes,
|
subSizes,
|
||||||
starts,
|
starts,
|
||||||
@ -118,7 +118,7 @@ static void setupCommunication(Comm* c, Direction direction, int layer)
|
|||||||
MPI_DOUBLE,
|
MPI_DOUBLE,
|
||||||
&c->sbufferTypes[direction]);
|
&c->sbufferTypes[direction]);
|
||||||
MPI_Type_commit(&c->sbufferTypes[direction]);
|
MPI_Type_commit(&c->sbufferTypes[direction]);
|
||||||
MPI_Type_create_subarray(NDIMS,
|
MPI_Type_create_subarray(NDIMS,
|
||||||
sizes,
|
sizes,
|
||||||
subSizes,
|
subSizes,
|
||||||
starts,
|
starts,
|
||||||
@ -508,17 +508,18 @@ void commInit(Comm* c, int kmax, int jmax, int imax)
|
|||||||
MPI_Cart_get(c->comm, NCORDS, c->dims, periods, c->coords);
|
MPI_Cart_get(c->comm, NCORDS, c->dims, periods, c->coords);
|
||||||
|
|
||||||
c->imaxLocal = sizeOfRank(c->coords[KDIM], dims[ICORD], imax);
|
c->imaxLocal = sizeOfRank(c->coords[KDIM], dims[ICORD], imax);
|
||||||
//printf("\nRank : %d\nimaxLocal : %d -> c->coords[IDIM] : %d , dims[ICORD] : %d, imax : %d\n", c->rank, c->imaxLocal, c->coords[IDIM], dims[ICORD], imax);
|
// printf("\nRank : %d\nimaxLocal : %d -> c->coords[IDIM] : %d , dims[ICORD] : %d,
|
||||||
|
// imax : %d\n", c->rank, c->imaxLocal, c->coords[IDIM], dims[ICORD], imax);
|
||||||
c->jmaxLocal = sizeOfRank(c->coords[JDIM], dims[JCORD], jmax);
|
c->jmaxLocal = sizeOfRank(c->coords[JDIM], dims[JCORD], jmax);
|
||||||
//printf("jmaxLocal : %d -> c->coords[JDIM] : %d , dims[JCORD] : %d, imax : %d\n", c->jmaxLocal, c->coords[JDIM], dims[JCORD], jmax);
|
// printf("jmaxLocal : %d -> c->coords[JDIM] : %d , dims[JCORD] : %d, imax : %d\n",
|
||||||
|
// c->jmaxLocal, c->coords[JDIM], dims[JCORD], jmax);
|
||||||
c->kmaxLocal = sizeOfRank(c->coords[IDIM], dims[KCORD], kmax);
|
c->kmaxLocal = sizeOfRank(c->coords[IDIM], dims[KCORD], kmax);
|
||||||
//printf("kmaxLocal : %d -> c->coords[KDIM] : %d , dims[KCORD] : %d, imax : %d\n", c->kmaxLocal, c->coords[KDIM], dims[KCORD], kmax);
|
// printf("kmaxLocal : %d -> c->coords[KDIM] : %d , dims[KCORD] : %d, imax : %d\n",
|
||||||
|
// c->kmaxLocal, c->coords[KDIM], dims[KCORD], kmax);
|
||||||
|
|
||||||
// sizeOfRank(int rank, int size, int N)
|
// sizeOfRank(int rank, int size, int N)
|
||||||
// { return N / size + ((N % size > rank) ? 1 : 0); }
|
// { return N / size + ((N % size > rank) ? 1 : 0); }
|
||||||
|
|
||||||
|
|
||||||
// setup buffer types for communication
|
// setup buffer types for communication
|
||||||
setupCommunication(c, LEFT, BULK);
|
setupCommunication(c, LEFT, BULK);
|
||||||
setupCommunication(c, LEFT, HALO);
|
setupCommunication(c, LEFT, HALO);
|
||||||
|
@ -13,11 +13,11 @@
|
|||||||
|
|
||||||
#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 "test.h"
|
#include "test.h"
|
||||||
#include "timing.h"
|
#include "timing.h"
|
||||||
#include "particletracing.h"
|
|
||||||
#include "vtkWriter.h"
|
#include "vtkWriter.h"
|
||||||
|
|
||||||
enum VARIANT { SOR = 1, RB, RBA };
|
enum VARIANT { SOR = 1, RB, RBA };
|
||||||
@ -42,8 +42,7 @@ int main(int argc, char** argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
readParameter(¶ms, argv[1]);
|
readParameter(¶ms, argv[1]);
|
||||||
if (argc == 3)
|
if (argc == 3) {
|
||||||
{
|
|
||||||
variant = atoi(argv[2]);
|
variant = atoi(argv[2]);
|
||||||
}
|
}
|
||||||
if (commIsMaster(&solver.comm)) {
|
if (commIsMaster(&solver.comm)) {
|
||||||
@ -63,7 +62,7 @@ int main(int argc, char** argv)
|
|||||||
double t = 0.0;
|
double t = 0.0;
|
||||||
int nt = 0;
|
int nt = 0;
|
||||||
|
|
||||||
void (*solver_generic[])() = {solve, solveRB, solveRBA};
|
void (*solver_generic[])() = { solve, solveRB, solveRBA };
|
||||||
|
|
||||||
timeStart = getTimeStamp();
|
timeStart = getTimeStamp();
|
||||||
|
|
||||||
@ -73,7 +72,6 @@ int main(int argc, char** argv)
|
|||||||
setSpecialBoundaryCondition(&solver);
|
setSpecialBoundaryCondition(&solver);
|
||||||
setObjectBoundaryCondition(&solver);
|
setObjectBoundaryCondition(&solver);
|
||||||
|
|
||||||
|
|
||||||
computeFG(&solver);
|
computeFG(&solver);
|
||||||
computeRHS(&solver);
|
computeRHS(&solver);
|
||||||
// if (nt % 100 == 0) normalizePressure(&solver);
|
// if (nt % 100 == 0) normalizePressure(&solver);
|
||||||
@ -94,8 +92,6 @@ int main(int argc, char** argv)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
timeStop = getTimeStamp();
|
timeStop = getTimeStamp();
|
||||||
stopProgress();
|
stopProgress();
|
||||||
if (commIsMaster(&solver.comm)) {
|
if (commIsMaster(&solver.comm)) {
|
||||||
|
@ -27,7 +27,6 @@ void initParameter(Parameter* param)
|
|||||||
param->gamma = 0.9;
|
param->gamma = 0.9;
|
||||||
param->tau = 0.5;
|
param->tau = 0.5;
|
||||||
param->rho = 0.99;
|
param->rho = 0.99;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void readParameter(Parameter* param, const char* filename)
|
void readParameter(Parameter* param, const char* filename)
|
||||||
@ -111,7 +110,6 @@ void readParameter(Parameter* param, const char* filename)
|
|||||||
PARSE_REAL(yRectLength);
|
PARSE_REAL(yRectLength);
|
||||||
PARSE_REAL(zRectLength);
|
PARSE_REAL(zRectLength);
|
||||||
PARSE_REAL(circleRadius);
|
PARSE_REAL(circleRadius);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,8 @@ typedef struct {
|
|||||||
double x1, y1, z1, x2, y2, z2;
|
double x1, y1, z1, x2, y2, z2;
|
||||||
|
|
||||||
int shape;
|
int shape;
|
||||||
double xCenter, yCenter, zCenter, xRectLength, yRectLength, zRectLength, circleRadius;} Parameter;
|
double xCenter, yCenter, zCenter, xRectLength, yRectLength, zRectLength, circleRadius;
|
||||||
|
} Parameter;
|
||||||
|
|
||||||
void initParameter(Parameter*);
|
void initParameter(Parameter*);
|
||||||
void readParameter(Parameter*, const char*);
|
void readParameter(Parameter*, const char*);
|
||||||
|
@ -13,16 +13,20 @@
|
|||||||
#include "particletracing.h"
|
#include "particletracing.h"
|
||||||
#include "solver.h"
|
#include "solver.h"
|
||||||
|
|
||||||
#define U(i, j, k) u[(k) * (imaxLocal + 2) * (jmaxLocal + 2) + (j) * (imaxLocal + 2) + (i)]
|
#define U(i, j, k) \
|
||||||
#define V(i, j, k) v[(k) * (imaxLocal + 2) * (jmaxLocal + 2) + (j) * (imaxLocal + 2) + (i)]
|
u[(k) * (imaxLocal + 2) * (jmaxLocal + 2) + (j) * (imaxLocal + 2) + (i)]
|
||||||
#define W(i, j, k) w[(k) * (imaxLocal + 2) * (jmaxLocal + 2) + (j) * (imaxLocal + 2) + (i)]
|
#define V(i, j, k) \
|
||||||
#define S(i, j, k) seg[(k) * (imaxLocal + 2) * (jmaxLocal + 2) + (j) * (imaxLocal + 2) + (i)]
|
v[(k) * (imaxLocal + 2) * (jmaxLocal + 2) + (j) * (imaxLocal + 2) + (i)]
|
||||||
|
#define W(i, j, k) \
|
||||||
|
w[(k) * (imaxLocal + 2) * (jmaxLocal + 2) + (j) * (imaxLocal + 2) + (i)]
|
||||||
|
#define S(i, j, k) \
|
||||||
|
seg[(k) * (imaxLocal + 2) * (jmaxLocal + 2) + (j) * (imaxLocal + 2) + (i)]
|
||||||
|
|
||||||
static int ts = 0;
|
static int ts = 0;
|
||||||
|
|
||||||
#define XOFFSET 0
|
#define XOFFSET 0
|
||||||
#define YOFFSET 1
|
#define YOFFSET 1
|
||||||
#define ZOFFSET 2
|
#define ZOFFSET 2
|
||||||
#define XOFFSETEND 3
|
#define XOFFSETEND 3
|
||||||
#define YOFFSETEND 4
|
#define YOFFSETEND 4
|
||||||
#define ZOFFSETEND 5
|
#define ZOFFSETEND 5
|
||||||
@ -31,8 +35,7 @@ static double sum(int* sizes, int size)
|
|||||||
{
|
{
|
||||||
double sum = 0;
|
double sum = 0;
|
||||||
|
|
||||||
for (int i = 0; i < size; ++i)
|
for (int i = 0; i < size; ++i) {
|
||||||
{
|
|
||||||
sum += sizes[i];
|
sum += sizes[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,91 +46,97 @@ static double sumOffset(double* sizes, int init, int offset, int coord)
|
|||||||
{
|
{
|
||||||
double sum = 0;
|
double sum = 0;
|
||||||
|
|
||||||
for (int i = init - offset; coord > 0; i-=offset, --coord)
|
for (int i = init - offset; coord > 0; i -= offset, --coord) {
|
||||||
{
|
|
||||||
sum += sizes[i];
|
sum += sizes[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
return sum;
|
return sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void printParticles(ParticleTracer* particletracer)
|
void printParticles(ParticleTracer* particletracer)
|
||||||
{
|
{
|
||||||
for(int i = 0; i < particletracer->totalParticles; ++i)
|
for (int i = 0; i < particletracer->totalParticles; ++i) {
|
||||||
{
|
printf("Rank : %d Particle position X : %.2f, Y : %.2f, flag : %d, total pt : "
|
||||||
printf("Rank : %d Particle position X : %.2f, Y : %.2f, flag : %d, total pt : %d, pointer : %d, xOffset : %.2f, yOffset : %.2f, xOffsetEnd : %.2f, yOffsetEnd : %.2f\n",
|
"%d, pointer : %d, xOffset : %.2f, yOffset : %.2f, xOffsetEnd : %.2f, "
|
||||||
|
"yOffsetEnd : %.2f\n",
|
||||||
particletracer->rank,
|
particletracer->rank,
|
||||||
particletracer->particlePool[i].x,
|
particletracer->particlePool[i].x,
|
||||||
particletracer->particlePool[i].y,
|
particletracer->particlePool[i].y,
|
||||||
particletracer->particlePool[i].flag,
|
particletracer->particlePool[i].flag,
|
||||||
particletracer->totalParticles,
|
particletracer->totalParticles,
|
||||||
particletracer->pointer,
|
particletracer->pointer,
|
||||||
particletracer->xOffset, particletracer->yOffset,
|
particletracer->xOffset,
|
||||||
particletracer->xOffsetEnd, particletracer->yOffsetEnd);
|
particletracer->yOffset,
|
||||||
|
particletracer->xOffsetEnd,
|
||||||
|
particletracer->yOffsetEnd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void injectParticles(ParticleTracer* particletracer,int* restrict seg)
|
void injectParticles(ParticleTracer* particletracer, int* restrict seg)
|
||||||
{
|
{
|
||||||
double x, y, z;
|
double x, y, z;
|
||||||
int imaxLocal = particletracer->imaxLocal;
|
int imaxLocal = particletracer->imaxLocal;
|
||||||
int jmaxLocal = particletracer->jmaxLocal;
|
int jmaxLocal = particletracer->jmaxLocal;
|
||||||
int kmaxLocal = particletracer->kmaxLocal;
|
int kmaxLocal = particletracer->kmaxLocal;
|
||||||
for(int i = 0; i < particletracer->numberOfParticles; ++i)
|
for (int i = 0; i < particletracer->numberOfParticles; ++i) {
|
||||||
{
|
|
||||||
x = particletracer->linSpaceLine[i].x;
|
x = particletracer->linSpaceLine[i].x;
|
||||||
y = particletracer->linSpaceLine[i].y;
|
y = particletracer->linSpaceLine[i].y;
|
||||||
z = particletracer->linSpaceLine[i].z;
|
z = particletracer->linSpaceLine[i].z;
|
||||||
if(x >= particletracer->xOffset && y >= particletracer->yOffset && z >= particletracer->zOffset && x <= particletracer->xOffsetEnd && y <= particletracer->yOffsetEnd && y <= particletracer->zOffsetEnd )
|
if (x >= particletracer->xOffset && y >= particletracer->yOffset &&
|
||||||
{
|
z >= particletracer->zOffset && x <= particletracer->xOffsetEnd &&
|
||||||
|
y <= particletracer->yOffsetEnd && y <= particletracer->zOffsetEnd) {
|
||||||
// printf("\nRank : %d\n", particletracer->rank);
|
// printf("\nRank : %d\n", particletracer->rank);
|
||||||
// printf("\t%.2f >= %.2f && %.2f >= %.2f && %.2f <= %.2f && %.2f <= %.2f\n",x , particletracer->xOffset ,y , particletracer->yOffset, x , particletracer->xOffsetEnd ,y , particletracer->yOffsetEnd);
|
// printf("\t%.2f >= %.2f && %.2f >= %.2f && %.2f <= %.2f && %.2f <= %.2f\n",x
|
||||||
|
// , particletracer->xOffset ,y , particletracer->yOffset, x ,
|
||||||
|
// particletracer->xOffsetEnd ,y , particletracer->yOffsetEnd);
|
||||||
|
|
||||||
particletracer->particlePool[particletracer->pointer].x = x;
|
particletracer->particlePool[particletracer->pointer].x = x;
|
||||||
particletracer->particlePool[particletracer->pointer].y = y;
|
particletracer->particlePool[particletracer->pointer].y = y;
|
||||||
particletracer->particlePool[particletracer->pointer].z = z;
|
particletracer->particlePool[particletracer->pointer].z = z;
|
||||||
|
|
||||||
int i = particletracer->particlePool[particletracer->pointer].x / particletracer->dx;
|
int i = particletracer->particlePool[particletracer->pointer].x /
|
||||||
int j = particletracer->particlePool[particletracer->pointer].y / particletracer->dy;
|
particletracer->dx;
|
||||||
int k = particletracer->particlePool[particletracer->pointer].z / particletracer->dz;
|
int j = particletracer->particlePool[particletracer->pointer].y /
|
||||||
if(S(i,j,k) == NONE)
|
particletracer->dy;
|
||||||
{
|
int k = particletracer->particlePool[particletracer->pointer].z /
|
||||||
particletracer->particlePool[particletracer->pointer].flag = true;
|
particletracer->dz;
|
||||||
++(particletracer->pointer);
|
if (S(i, j, k) == NONE) {
|
||||||
++(particletracer->totalParticles);
|
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)
|
void advanceParticles(ParticleTracer* particletracer,
|
||||||
|
double* restrict u,
|
||||||
|
double* restrict v,
|
||||||
|
double* restrict w,
|
||||||
|
int* restrict seg,
|
||||||
|
double time)
|
||||||
{
|
{
|
||||||
int imax = particletracer->imax;
|
int imax = particletracer->imax;
|
||||||
int jmax = particletracer->jmax;
|
int jmax = particletracer->jmax;
|
||||||
int kmax = particletracer->kmax;
|
int kmax = particletracer->kmax;
|
||||||
int imaxLocal = particletracer->imaxLocal;
|
int imaxLocal = particletracer->imaxLocal;
|
||||||
int jmaxLocal = particletracer->jmaxLocal;
|
int jmaxLocal = particletracer->jmaxLocal;
|
||||||
int kmaxLocal = particletracer->kmaxLocal;
|
int kmaxLocal = particletracer->kmaxLocal;
|
||||||
|
|
||||||
|
double dx = particletracer->dx;
|
||||||
double dx = particletracer->dx;
|
double dy = particletracer->dy;
|
||||||
double dy = particletracer->dy;
|
double dz = particletracer->dz;
|
||||||
double dz = particletracer->dz;
|
|
||||||
|
|
||||||
double xlength = particletracer->xlength;
|
double xlength = particletracer->xlength;
|
||||||
double ylength = particletracer->ylength;
|
double ylength = particletracer->ylength;
|
||||||
double zlength = particletracer->zlength;
|
double zlength = particletracer->zlength;
|
||||||
|
|
||||||
|
|
||||||
Particle buff[particletracer->size][100];
|
Particle buff[particletracer->size][100];
|
||||||
|
|
||||||
for(int i = 0; i < particletracer->size; ++i)
|
for (int i = 0; i < particletracer->size; ++i) {
|
||||||
{
|
for (int j = 0; j < 100; ++j) {
|
||||||
for(int j = 0; j < 100; ++j)
|
buff[i][j].x = 0.0;
|
||||||
{
|
buff[i][j].y = 0.0;
|
||||||
buff[i][j].x = 0.0;
|
buff[i][j].z = 0.0;
|
||||||
buff[i][j].y = 0.0;
|
|
||||||
buff[i][j].z = 0.0;
|
|
||||||
buff[i][j].flag = false;
|
buff[i][j].flag = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -135,25 +144,20 @@ void advanceParticles(ParticleTracer* particletracer, double* restrict u, double
|
|||||||
|
|
||||||
memset(particleBufIndex, 0, sizeof(particleBufIndex));
|
memset(particleBufIndex, 0, sizeof(particleBufIndex));
|
||||||
|
|
||||||
|
for (int i = 0; i < particletracer->totalParticles; ++i) {
|
||||||
for(int i = 0; i < particletracer->totalParticles; ++i)
|
if (particletracer->particlePool[i].flag == true) {
|
||||||
{
|
|
||||||
if(particletracer->particlePool[i].flag == true)
|
|
||||||
{
|
|
||||||
double xTemp = particletracer->particlePool[i].x;
|
double xTemp = particletracer->particlePool[i].x;
|
||||||
double yTemp = particletracer->particlePool[i].y;
|
double yTemp = particletracer->particlePool[i].y;
|
||||||
double zTemp = particletracer->particlePool[i].z;
|
double zTemp = particletracer->particlePool[i].z;
|
||||||
|
|
||||||
|
double x = xTemp - particletracer->xOffset;
|
||||||
double x = xTemp - particletracer->xOffset;
|
double y = yTemp - particletracer->yOffset;
|
||||||
double y = yTemp - particletracer->yOffset;
|
double z = zTemp - particletracer->zOffset;
|
||||||
double z = zTemp - particletracer->zOffset;
|
|
||||||
|
|
||||||
int iCoord = (int)(x / dx) + 1;
|
int iCoord = (int)(x / dx) + 1;
|
||||||
int jCoord = (int)((y + 0.5 * dy) / dy) + 1;
|
int jCoord = (int)((y + 0.5 * dy) / dy) + 1;
|
||||||
int kCoord = (int)((z + 0.5 * dz) / dz) + 1;
|
int kCoord = (int)((z + 0.5 * dz) / dz) + 1;
|
||||||
|
|
||||||
|
|
||||||
double x1 = (double)(iCoord - 1) * dx;
|
double x1 = (double)(iCoord - 1) * dx;
|
||||||
double y1 = ((double)(jCoord - 1) - 0.5) * dy;
|
double y1 = ((double)(jCoord - 1) - 0.5) * dy;
|
||||||
double z1 = ((double)(kCoord - 1) - 0.5) * dz;
|
double z1 = ((double)(kCoord - 1) - 0.5) * dz;
|
||||||
@ -162,18 +166,16 @@ void advanceParticles(ParticleTracer* particletracer, double* restrict u, double
|
|||||||
double y2 = ((double)jCoord - 0.5) * dy;
|
double y2 = ((double)jCoord - 0.5) * dy;
|
||||||
double z2 = ((double)kCoord - 0.5) * dz;
|
double z2 = ((double)kCoord - 0.5) * dz;
|
||||||
|
|
||||||
|
double u_n =
|
||||||
double u_n = (1.0 / (dx * dy * dz)) *
|
(1.0 / (dx * dy * dz)) *
|
||||||
(
|
((x2 - x) * (y2 - y) * (z2 - z) * U(iCoord - 1, jCoord - 1, kCoord - 1) +
|
||||||
(x2 - x) * (y2 - y) * (z2 - z) * U(iCoord - 1, jCoord - 1, kCoord - 1) +
|
|
||||||
(x - x1) * (y2 - y) * (z2 - z) * U(iCoord, jCoord - 1, kCoord - 1) +
|
(x - x1) * (y2 - y) * (z2 - z) * U(iCoord, jCoord - 1, kCoord - 1) +
|
||||||
(x2 - x) * (y - y1) * (z2 - z) * U(iCoord - 1, jCoord, kCoord - 1) +
|
(x2 - x) * (y - y1) * (z2 - z) * U(iCoord - 1, jCoord, kCoord - 1) +
|
||||||
(x - x1) * (y - y1) * (z2 - z) * U(iCoord, jCoord, kCoord - 1) +
|
(x - x1) * (y - y1) * (z2 - z) * U(iCoord, jCoord, kCoord - 1) +
|
||||||
(x2 - x) * (y2 - y) * (z - z1) * U(iCoord - 1, jCoord - 1, kCoord) +
|
(x2 - x) * (y2 - y) * (z - z1) * U(iCoord - 1, jCoord - 1, kCoord) +
|
||||||
(x - x1) * (y2 - y) * (z - z1) * U(iCoord, jCoord - 1, kCoord) +
|
(x - x1) * (y2 - y) * (z - z1) * U(iCoord, jCoord - 1, kCoord) +
|
||||||
(x2 - x) * (y - y1) * (z - z1) * U(iCoord - 1, jCoord, kCoord) +
|
(x2 - x) * (y - y1) * (z - z1) * U(iCoord - 1, jCoord, kCoord) +
|
||||||
(x - x1) * (y - y1) * (z - z1) * U(iCoord, jCoord, kCoord)
|
(x - x1) * (y - y1) * (z - z1) * U(iCoord, jCoord, kCoord));
|
||||||
);
|
|
||||||
|
|
||||||
double new_x = (x + particletracer->xOffset) + particletracer->dt * u_n;
|
double new_x = (x + particletracer->xOffset) + particletracer->dt * u_n;
|
||||||
particletracer->particlePool[i].x = new_x;
|
particletracer->particlePool[i].x = new_x;
|
||||||
@ -190,17 +192,16 @@ void advanceParticles(ParticleTracer* particletracer, double* restrict u, double
|
|||||||
y2 = (double)jCoord * dy;
|
y2 = (double)jCoord * dy;
|
||||||
z2 = ((double)kCoord - 0.5) * dz;
|
z2 = ((double)kCoord - 0.5) * dz;
|
||||||
|
|
||||||
double v_n = (1.0 / (dx * dy * dz)) *
|
double v_n =
|
||||||
(
|
(1.0 / (dx * dy * dz)) *
|
||||||
(x2 - x) * (y2 - y) * (z2 - z) * V(iCoord - 1, jCoord - 1, kCoord - 1) +
|
((x2 - x) * (y2 - y) * (z2 - z) * V(iCoord - 1, jCoord - 1, kCoord - 1) +
|
||||||
(x - x1) * (y2 - y) * (z2 - z) * V(iCoord, jCoord - 1, kCoord - 1) +
|
(x - x1) * (y2 - y) * (z2 - z) * V(iCoord, jCoord - 1, kCoord - 1) +
|
||||||
(x2 - x) * (y - y1) * (z2 - z) * V(iCoord - 1, jCoord, kCoord - 1) +
|
(x2 - x) * (y - y1) * (z2 - z) * V(iCoord - 1, jCoord, kCoord - 1) +
|
||||||
(x - x1) * (y - y1) * (z2 - z) * V(iCoord, jCoord, kCoord - 1) +
|
(x - x1) * (y - y1) * (z2 - z) * V(iCoord, jCoord, kCoord - 1) +
|
||||||
(x2 - x) * (y2 - y) * (z - z1) * V(iCoord - 1, jCoord - 1, kCoord) +
|
(x2 - x) * (y2 - y) * (z - z1) * V(iCoord - 1, jCoord - 1, kCoord) +
|
||||||
(x - x1) * (y2 - y) * (z - z1) * V(iCoord, jCoord - 1, kCoord) +
|
(x - x1) * (y2 - y) * (z - z1) * V(iCoord, jCoord - 1, kCoord) +
|
||||||
(x2 - x) * (y - y1) * (z - z1) * V(iCoord - 1, jCoord, kCoord) +
|
(x2 - x) * (y - y1) * (z - z1) * V(iCoord - 1, jCoord, kCoord) +
|
||||||
(x - x1) * (y - y1) * (z - z1) * V(iCoord, jCoord, kCoord)
|
(x - x1) * (y - y1) * (z - z1) * V(iCoord, jCoord, kCoord));
|
||||||
);
|
|
||||||
|
|
||||||
double new_y = (y + particletracer->yOffset) + particletracer->dt * v_n;
|
double new_y = (y + particletracer->yOffset) + particletracer->dt * v_n;
|
||||||
particletracer->particlePool[i].y = new_y;
|
particletracer->particlePool[i].y = new_y;
|
||||||
@ -217,90 +218,108 @@ void advanceParticles(ParticleTracer* particletracer, double* restrict u, double
|
|||||||
y2 = ((double)jCoord - 0.5) * dy;
|
y2 = ((double)jCoord - 0.5) * dy;
|
||||||
z2 = (double)kCoord * dz;
|
z2 = (double)kCoord * dz;
|
||||||
|
|
||||||
double w_n = (1.0 / (dx * dy * dz)) *
|
double w_n =
|
||||||
(
|
(1.0 / (dx * dy * dz)) *
|
||||||
(x2 - x) * (y2 - y) * (z2 - z) * W(iCoord - 1, jCoord - 1, kCoord - 1) +
|
((x2 - x) * (y2 - y) * (z2 - z) * W(iCoord - 1, jCoord - 1, kCoord - 1) +
|
||||||
(x - x1) * (y2 - y) * (z2 - z) * W(iCoord, jCoord - 1, kCoord - 1) +
|
(x - x1) * (y2 - y) * (z2 - z) * W(iCoord, jCoord - 1, kCoord - 1) +
|
||||||
(x2 - x) * (y - y1) * (z2 - z) * W(iCoord - 1, jCoord, kCoord - 1) +
|
(x2 - x) * (y - y1) * (z2 - z) * W(iCoord - 1, jCoord, kCoord - 1) +
|
||||||
(x - x1) * (y - y1) * (z2 - z) * W(iCoord, jCoord, kCoord - 1) +
|
(x - x1) * (y - y1) * (z2 - z) * W(iCoord, jCoord, kCoord - 1) +
|
||||||
(x2 - x) * (y2 - y) * (z - z1) * W(iCoord - 1, jCoord - 1, kCoord) +
|
(x2 - x) * (y2 - y) * (z - z1) * W(iCoord - 1, jCoord - 1, kCoord) +
|
||||||
(x - x1) * (y2 - y) * (z - z1) * W(iCoord, jCoord - 1, kCoord) +
|
(x - x1) * (y2 - y) * (z - z1) * W(iCoord, jCoord - 1, kCoord) +
|
||||||
(x2 - x) * (y - y1) * (z - z1) * W(iCoord - 1, jCoord, kCoord) +
|
(x2 - x) * (y - y1) * (z - z1) * W(iCoord - 1, jCoord, kCoord) +
|
||||||
(x - x1) * (y - y1) * (z - z1) * W(iCoord, jCoord, kCoord)
|
(x - x1) * (y - y1) * (z - z1) * W(iCoord, jCoord, kCoord));
|
||||||
);
|
|
||||||
|
|
||||||
double new_z = (z + particletracer->zOffset) + particletracer->dt * w_n;
|
double new_z = (z + particletracer->zOffset) + particletracer->dt * w_n;
|
||||||
particletracer->particlePool[i].z = new_z;
|
particletracer->particlePool[i].z = new_z;
|
||||||
|
|
||||||
// printf("Rank : %d\n", particletracer->rank);
|
// printf("Rank : %d\n", particletracer->rank);
|
||||||
// printf("\tOld X : %.2f, translated X : %.2f, xOffset : %.2f, New X : %.2f, iCoord : %d\n\tOld Y : %.2f, translated X : %.2f, yOffset : %.2f, New Y : %.2f, jCoord : %d\n\n",xTemp, x, particletracer->xOffset, new_x, iCoord, yTemp, y, particletracer->yOffset , new_y, jCoord);
|
// printf("\tOld X : %.2f, translated X : %.2f, xOffset : %.2f, New X : %.2f,
|
||||||
// printf("\tU(iCoord - 1, jCoord - 1) : %.2f, U(iCoord, jCoord - 1) : %.2f, U(iCoord - 1, jCoord) : %.2f, U(iCoord, jCoord) : %.2f\n", U(iCoord - 1, jCoord - 1), U(iCoord, jCoord - 1), U(iCoord - 1, jCoord), U(iCoord, jCoord));
|
// iCoord : %d\n\tOld Y : %.2f, translated X : %.2f, yOffset : %.2f, New Y :
|
||||||
// printf("\tV(iCoord - 1, jCoord - 1) : %.2f, V(iCoord, jCoord - 1) : %.2f, V(iCoord - 1, jCoord) : %.2f, V(iCoord, jCoord) : %.2f\n\n", V(iCoord - 1, jCoord - 1), V(iCoord, jCoord - 1), V(iCoord - 1, jCoord), V(iCoord, jCoord));
|
// %.2f, jCoord : %d\n\n",xTemp, x, particletracer->xOffset, new_x, iCoord,
|
||||||
//printf("\t U N : %.2f, V N : %.2f\n\n", u_n, v_n);
|
// yTemp, y, particletracer->yOffset , new_y, jCoord); printf("\tU(iCoord - 1,
|
||||||
|
// jCoord - 1) : %.2f, U(iCoord, jCoord - 1) : %.2f, U(iCoord - 1, jCoord) :
|
||||||
|
// %.2f, U(iCoord, jCoord) : %.2f\n", U(iCoord - 1, jCoord - 1), U(iCoord,
|
||||||
|
// jCoord - 1), U(iCoord - 1, jCoord), U(iCoord, jCoord)); printf("\tV(iCoord
|
||||||
|
// - 1, jCoord - 1) : %.2f, V(iCoord, jCoord - 1) : %.2f, V(iCoord - 1,
|
||||||
|
// jCoord) : %.2f, V(iCoord, jCoord) : %.2f\n\n", V(iCoord - 1, jCoord - 1),
|
||||||
|
// V(iCoord, jCoord - 1), V(iCoord - 1, jCoord), V(iCoord, jCoord));
|
||||||
|
// printf("\t U N : %.2f, V N : %.2f\n\n", u_n, v_n);
|
||||||
|
|
||||||
if (((new_x < particletracer->xOffset) || (new_x >= particletracer->xOffsetEnd) ||
|
if (((new_x < particletracer->xOffset) ||
|
||||||
(new_y < particletracer->yOffset) || (new_y >= particletracer->yOffsetEnd) ||
|
(new_x >= particletracer->xOffsetEnd) ||
|
||||||
(new_z < particletracer->zOffset) || (new_z >= particletracer->zOffsetEnd)))
|
(new_y < particletracer->yOffset) ||
|
||||||
{
|
(new_y >= particletracer->yOffsetEnd) ||
|
||||||
//New logic to transfer particles to neighbouring ranks or discard the particle.
|
(new_z < particletracer->zOffset) ||
|
||||||
|
(new_z >= particletracer->zOffsetEnd))) {
|
||||||
|
// New logic to transfer particles to neighbouring ranks or discard the
|
||||||
|
// particle.
|
||||||
|
|
||||||
for(int i = 0; i < particletracer->size; ++i)
|
for (int i = 0; i < particletracer->size; ++i) {
|
||||||
{
|
if ((new_x >=
|
||||||
if((new_x >= particletracer->offset[i + particletracer->size * XOFFSET]) &&
|
particletracer->offset[i + particletracer->size * XOFFSET]) &&
|
||||||
(new_x <= particletracer->offset[i + particletracer->size * XOFFSETEND]) &&
|
(new_x <= particletracer
|
||||||
(new_y >= particletracer->offset[i + particletracer->size * YOFFSET]) &&
|
->offset[i + particletracer->size * XOFFSETEND]) &&
|
||||||
(new_y <= particletracer->offset[i + particletracer->size * YOFFSETEND]) &&
|
(new_y >=
|
||||||
(new_z >= particletracer->offset[i + particletracer->size * ZOFFSET]) &&
|
particletracer->offset[i + particletracer->size * YOFFSET]) &&
|
||||||
(new_z <= particletracer->offset[i + particletracer->size * ZOFFSETEND]) &&
|
(new_y <= particletracer
|
||||||
i != particletracer->rank)
|
->offset[i + particletracer->size * YOFFSETEND]) &&
|
||||||
{
|
(new_z >=
|
||||||
buff[i][particleBufIndex[i]].x = new_x;
|
particletracer->offset[i + particletracer->size * ZOFFSET]) &&
|
||||||
buff[i][particleBufIndex[i]].y = new_y;
|
(new_z <= particletracer
|
||||||
buff[i][particleBufIndex[i]].z = new_z;
|
->offset[i + particletracer->size * ZOFFSETEND]) &&
|
||||||
|
i != particletracer->rank) {
|
||||||
|
buff[i][particleBufIndex[i]].x = new_x;
|
||||||
|
buff[i][particleBufIndex[i]].y = new_y;
|
||||||
|
buff[i][particleBufIndex[i]].z = new_z;
|
||||||
buff[i][particleBufIndex[i]].flag = true;
|
buff[i][particleBufIndex[i]].flag = true;
|
||||||
++particleBufIndex[i];
|
++particleBufIndex[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
particletracer->particlePool[i].flag = false;
|
particletracer->particlePool[i].flag = false;
|
||||||
|
|
||||||
int i_new = new_x/dx, j_new = new_y/dy, k_new = new_z/dz;
|
int i_new = new_x / dx, j_new = new_y / dy, k_new = new_z / dz;
|
||||||
|
|
||||||
int iOffset = particletracer->xOffset / dx,
|
int iOffset = particletracer->xOffset / dx,
|
||||||
jOffset = particletracer->yOffset / dy,
|
jOffset = particletracer->yOffset / dy,
|
||||||
kOffset = particletracer->zOffset / dz;
|
kOffset = particletracer->zOffset / dz;
|
||||||
if(S(i_new - iOffset, j_new - jOffset, k_new - kOffset) != NONE)
|
if (S(i_new - iOffset, j_new - jOffset, k_new - kOffset) != NONE) {
|
||||||
{
|
particletracer->particlePool[i].flag = false;
|
||||||
particletracer->particlePool[i].flag = false;
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int i = 0; i < particletracer->size; ++i)
|
for (int i = 0; i < particletracer->size; ++i) {
|
||||||
{
|
if (i != particletracer->rank) {
|
||||||
if(i != particletracer->rank)
|
MPI_Send(buff[i],
|
||||||
{
|
100,
|
||||||
MPI_Send(buff[i], 100, particletracer->mpi_particle, i, 0, particletracer->comm);
|
particletracer->mpi_particle,
|
||||||
|
i,
|
||||||
|
0,
|
||||||
|
particletracer->comm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(int i = 0; i < particletracer->size; ++i)
|
for (int i = 0; i < particletracer->size; ++i) {
|
||||||
{
|
if (i != particletracer->rank) {
|
||||||
if(i != particletracer->rank)
|
MPI_Recv(buff[i],
|
||||||
{
|
100,
|
||||||
MPI_Recv(buff[i], 100, particletracer->mpi_particle, i, 0, particletracer->comm, MPI_STATUS_IGNORE);
|
particletracer->mpi_particle,
|
||||||
|
i,
|
||||||
|
0,
|
||||||
|
particletracer->comm,
|
||||||
|
MPI_STATUS_IGNORE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(int i = 0; i < particletracer->size; ++i)
|
for (int i = 0; i < particletracer->size; ++i) {
|
||||||
{
|
if (i != particletracer->rank) {
|
||||||
if(i != particletracer->rank)
|
for (int j = 0; j < 100; ++j) {
|
||||||
{
|
if (buff[i][j].flag == true) {
|
||||||
for(int j = 0; j < 100; ++j)
|
particletracer->particlePool[particletracer->pointer].x = buff[i][j]
|
||||||
{
|
.x;
|
||||||
if(buff[i][j].flag == true)
|
particletracer->particlePool[particletracer->pointer].y = buff[i][j]
|
||||||
{
|
.y;
|
||||||
particletracer->particlePool[particletracer->pointer].x = buff[i][j].x;
|
particletracer->particlePool[particletracer->pointer].z = buff[i][j]
|
||||||
particletracer->particlePool[particletracer->pointer].y = buff[i][j].y;
|
.z;
|
||||||
particletracer->particlePool[particletracer->pointer].z = buff[i][j].z;
|
|
||||||
particletracer->particlePool[particletracer->pointer].flag = true;
|
particletracer->particlePool[particletracer->pointer].flag = true;
|
||||||
++(particletracer->pointer);
|
++(particletracer->pointer);
|
||||||
++(particletracer->totalParticles);
|
++(particletracer->totalParticles);
|
||||||
@ -321,23 +340,34 @@ void writeParticles(ParticleTracer* particletracer)
|
|||||||
{
|
{
|
||||||
int collectedBuffIndex[particletracer->size];
|
int collectedBuffIndex[particletracer->size];
|
||||||
|
|
||||||
MPI_Gather(&particletracer->totalParticles, 1, MPI_INT, collectedBuffIndex, 1, MPI_INT, 0, particletracer->comm);
|
MPI_Gather(&particletracer->totalParticles,
|
||||||
|
1,
|
||||||
|
MPI_INT,
|
||||||
|
collectedBuffIndex,
|
||||||
|
1,
|
||||||
|
MPI_INT,
|
||||||
|
0,
|
||||||
|
particletracer->comm);
|
||||||
|
|
||||||
if(particletracer->rank != 0)
|
if (particletracer->rank != 0) {
|
||||||
{
|
|
||||||
Particle buff[particletracer->totalParticles];
|
Particle buff[particletracer->totalParticles];
|
||||||
for(int i = 0; i < particletracer->totalParticles; ++i)
|
for (int i = 0; i < particletracer->totalParticles; ++i) {
|
||||||
{
|
buff[i].x = particletracer->particlePool[i].x;
|
||||||
buff[i].x = particletracer->particlePool[i].x;
|
buff[i].y = particletracer->particlePool[i].y;
|
||||||
buff[i].y = particletracer->particlePool[i].y;
|
buff[i].z = particletracer->particlePool[i].z;
|
||||||
buff[i].z = particletracer->particlePool[i].z;
|
buff[i].flag = particletracer->particlePool[i].flag;
|
||||||
buff[i].flag = particletracer->particlePool[i].flag;
|
// printf("Rank : %d sending to rank 0 X : %.2f, Y : %.2f with totalpt :
|
||||||
//printf("Rank : %d sending to rank 0 X : %.2f, Y : %.2f with totalpt : %d\n", particletracer->rank, buff[i].x, buff[i].y, particletracer->totalParticles);
|
// %d\n", particletracer->rank, buff[i].x, buff[i].y,
|
||||||
|
// particletracer->totalParticles);
|
||||||
}
|
}
|
||||||
MPI_Send(buff, particletracer->totalParticles, particletracer->mpi_particle, 0, 1, particletracer->comm);
|
MPI_Send(buff,
|
||||||
|
particletracer->totalParticles,
|
||||||
|
particletracer->mpi_particle,
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
particletracer->comm);
|
||||||
}
|
}
|
||||||
if(particletracer->rank == 0)
|
if (particletracer->rank == 0) {
|
||||||
{
|
|
||||||
char filename[50];
|
char filename[50];
|
||||||
FILE* fp;
|
FILE* fp;
|
||||||
|
|
||||||
@ -352,7 +382,6 @@ void writeParticles(ParticleTracer* particletracer)
|
|||||||
fprintf(fp, "PAMPI cfd solver particle tracing file\n");
|
fprintf(fp, "PAMPI cfd solver particle tracing file\n");
|
||||||
fprintf(fp, "ASCII\n");
|
fprintf(fp, "ASCII\n");
|
||||||
|
|
||||||
|
|
||||||
fprintf(fp, "DATASET UNSTRUCTURED_GRID\n");
|
fprintf(fp, "DATASET UNSTRUCTURED_GRID\n");
|
||||||
fprintf(fp, "FIELD FieldData 2\n");
|
fprintf(fp, "FIELD FieldData 2\n");
|
||||||
fprintf(fp, "TIME 1 1 double\n");
|
fprintf(fp, "TIME 1 1 double\n");
|
||||||
@ -366,45 +395,43 @@ void writeParticles(ParticleTracer* particletracer)
|
|||||||
|
|
||||||
printf("Total particles : %d\n", overallTotalParticles);
|
printf("Total particles : %d\n", overallTotalParticles);
|
||||||
|
|
||||||
for (int i = 1; i < particletracer->size; ++i)
|
for (int i = 1; i < particletracer->size; ++i) {
|
||||||
{
|
|
||||||
Particle recvBuff[collectedBuffIndex[i]];
|
Particle recvBuff[collectedBuffIndex[i]];
|
||||||
MPI_Recv(&recvBuff, collectedBuffIndex[i], particletracer->mpi_particle, i, 1, particletracer->comm, MPI_STATUS_IGNORE);
|
MPI_Recv(&recvBuff,
|
||||||
|
collectedBuffIndex[i],
|
||||||
|
particletracer->mpi_particle,
|
||||||
|
i,
|
||||||
|
1,
|
||||||
|
particletracer->comm,
|
||||||
|
MPI_STATUS_IGNORE);
|
||||||
|
|
||||||
for (int j = 0; j < collectedBuffIndex[i]; ++j)
|
for (int j = 0; j < collectedBuffIndex[i]; ++j) {
|
||||||
{
|
|
||||||
double x = recvBuff[j].x;
|
double x = recvBuff[j].x;
|
||||||
double y = recvBuff[j].y;
|
double y = recvBuff[j].y;
|
||||||
double z = recvBuff[j].z;
|
double z = recvBuff[j].z;
|
||||||
fprintf(fp, "%f %f %f\n", x, y, z);
|
fprintf(fp, "%f %f %f\n", x, y, z);
|
||||||
//printf("Rank : 0 receiving from rank %d X : %.2f, Y : %.2f with totalpt : %d\n", i, x, y, particletracer->totalParticles);
|
// printf("Rank : 0 receiving from rank %d X : %.2f, Y : %.2f with totalpt
|
||||||
|
// : %d\n", i, x, y, particletracer->totalParticles);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
for (int i = 0; i < particletracer->totalParticles; ++i)
|
for (int i = 0; i < particletracer->totalParticles; ++i) {
|
||||||
{
|
|
||||||
double x = particletracer->particlePool[i].x;
|
double x = particletracer->particlePool[i].x;
|
||||||
double y = particletracer->particlePool[i].y;
|
double y = particletracer->particlePool[i].y;
|
||||||
double z = particletracer->particlePool[i].z;
|
double z = particletracer->particlePool[i].z;
|
||||||
fprintf(fp, "%f %f %f\n", x, y, z);
|
fprintf(fp, "%f %f %f\n", x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(fp, "CELLS %d %d\n", overallTotalParticles, 2 * overallTotalParticles);
|
fprintf(fp, "CELLS %d %d\n", overallTotalParticles, 2 * overallTotalParticles);
|
||||||
|
|
||||||
|
for (int i = 0; i < overallTotalParticles; ++i) {
|
||||||
|
fprintf(fp, "1 %d\n", i);
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < overallTotalParticles; ++i)
|
fprintf(fp, "CELL_TYPES %d\n", overallTotalParticles);
|
||||||
{
|
|
||||||
fprintf(fp, "1 %d\n", i);
|
|
||||||
}
|
|
||||||
|
|
||||||
fprintf(fp, "CELL_TYPES %d\n", overallTotalParticles);
|
for (int i = 0; i < overallTotalParticles; ++i) {
|
||||||
|
fprintf(fp, "1\n");
|
||||||
|
}
|
||||||
for (int i = 0; i < overallTotalParticles; ++i)
|
|
||||||
{
|
|
||||||
fprintf(fp, "1\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
}
|
}
|
||||||
@ -412,7 +439,7 @@ void writeParticles(ParticleTracer* particletracer)
|
|||||||
++ts;
|
++ts;
|
||||||
}
|
}
|
||||||
|
|
||||||
void initParticleTracer(ParticleTracer* particletracer, Parameter* params, Solver* solver)
|
void initParticleTracer(ParticleTracer* particletracer, Parameter* params, Solver* solver)
|
||||||
{
|
{
|
||||||
/* initializing local properties from params */
|
/* initializing local properties from params */
|
||||||
|
|
||||||
@ -421,118 +448,164 @@ void initParticleTracer(ParticleTracer* particletracer, Parameter* params, Solv
|
|||||||
particletracer->injectTimePeriod = params->injectTimePeriod;
|
particletracer->injectTimePeriod = params->injectTimePeriod;
|
||||||
particletracer->writeTimePeriod = params->writeTimePeriod;
|
particletracer->writeTimePeriod = params->writeTimePeriod;
|
||||||
|
|
||||||
particletracer->dt = params->dt;
|
particletracer->dt = params->dt;
|
||||||
particletracer->dx = params->xlength / params->imax;
|
particletracer->dx = params->xlength / params->imax;
|
||||||
particletracer->dy = params->ylength / params->jmax;
|
particletracer->dy = params->ylength / params->jmax;
|
||||||
particletracer->dz = params->zlength / params->kmax;
|
particletracer->dz = params->zlength / params->kmax;
|
||||||
|
|
||||||
particletracer->xlength = params->xlength;
|
particletracer->xlength = params->xlength;
|
||||||
particletracer->ylength = params->ylength;
|
particletracer->ylength = params->ylength;
|
||||||
particletracer->zlength = params->zlength;
|
particletracer->zlength = params->zlength;
|
||||||
|
|
||||||
particletracer->x1 = params->x1;
|
particletracer->x1 = params->x1;
|
||||||
particletracer->y1 = params->y1;
|
particletracer->y1 = params->y1;
|
||||||
particletracer->z1 = params->z1;
|
particletracer->z1 = params->z1;
|
||||||
particletracer->x2 = params->x2;
|
particletracer->x2 = params->x2;
|
||||||
particletracer->y2 = params->y2;
|
particletracer->y2 = params->y2;
|
||||||
particletracer->z2 = params->z2;
|
particletracer->z2 = params->z2;
|
||||||
|
|
||||||
particletracer->lastInjectTime = params->startTime;
|
particletracer->lastInjectTime = params->startTime;
|
||||||
particletracer->lastUpdateTime = params->startTime;
|
particletracer->lastUpdateTime = params->startTime;
|
||||||
particletracer->lastWriteTime = params->startTime;
|
particletracer->lastWriteTime = params->startTime;
|
||||||
|
|
||||||
particletracer->pointer = 0;
|
particletracer->pointer = 0;
|
||||||
particletracer->totalParticles = 0;
|
particletracer->totalParticles = 0;
|
||||||
|
|
||||||
particletracer->imax = params->imax;
|
particletracer->imax = params->imax;
|
||||||
particletracer->jmax = params->jmax;
|
particletracer->jmax = params->jmax;
|
||||||
particletracer->kmax = params->kmax;
|
particletracer->kmax = params->kmax;
|
||||||
|
|
||||||
particletracer->imaxLocal = solver->comm.imaxLocal;
|
particletracer->imaxLocal = solver->comm.imaxLocal;
|
||||||
particletracer->jmaxLocal = solver->comm.jmaxLocal;
|
particletracer->jmaxLocal = solver->comm.jmaxLocal;
|
||||||
particletracer->kmaxLocal = solver->comm.kmaxLocal;
|
particletracer->kmaxLocal = solver->comm.kmaxLocal;
|
||||||
|
|
||||||
particletracer->estimatedNumParticles = (particletracer->imaxLocal * particletracer->jmaxLocal * particletracer->kmaxLocal);
|
particletracer->estimatedNumParticles = (particletracer->imaxLocal *
|
||||||
|
particletracer->jmaxLocal *
|
||||||
|
particletracer->kmaxLocal);
|
||||||
|
|
||||||
particletracer->particlePool = malloc(sizeof(Particle) * particletracer->estimatedNumParticles);
|
particletracer->particlePool = malloc(
|
||||||
|
sizeof(Particle) * particletracer->estimatedNumParticles);
|
||||||
|
|
||||||
for(int i = 0; i < particletracer->estimatedNumParticles; ++i)
|
for (int i = 0; i < particletracer->estimatedNumParticles; ++i) {
|
||||||
{
|
particletracer->particlePool[i].x = 0.0;
|
||||||
particletracer->particlePool[i].x = 0.0;
|
particletracer->particlePool[i].y = 0.0;
|
||||||
particletracer->particlePool[i].y = 0.0;
|
particletracer->particlePool[i].z = 0.0;
|
||||||
particletracer->particlePool[i].z = 0.0;
|
|
||||||
particletracer->particlePool[i].flag = false;
|
particletracer->particlePool[i].flag = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
particletracer->linSpaceLine = malloc(sizeof(Particle) * particletracer->numberOfParticles);
|
particletracer->linSpaceLine = malloc(
|
||||||
|
sizeof(Particle) * particletracer->numberOfParticles);
|
||||||
|
|
||||||
/* duplicating communication from solver */
|
/* duplicating communication from solver */
|
||||||
MPI_Comm_dup(solver->comm.comm, &particletracer->comm);
|
MPI_Comm_dup(solver->comm.comm, &particletracer->comm);
|
||||||
|
|
||||||
particletracer->rank = solver->comm.rank;
|
particletracer->rank = solver->comm.rank;
|
||||||
particletracer->size = solver->comm.size;
|
particletracer->size = solver->comm.size;
|
||||||
|
|
||||||
particletracer->offset = (double *)malloc(sizeof(double) * 4 * particletracer->size);
|
|
||||||
|
|
||||||
|
particletracer->offset = (double*)malloc(sizeof(double) * 4 * particletracer->size);
|
||||||
|
|
||||||
memcpy(particletracer->dims, solver->comm.dims, sizeof(solver->comm.dims));
|
memcpy(particletracer->dims, solver->comm.dims, sizeof(solver->comm.dims));
|
||||||
|
|
||||||
memcpy(particletracer->coords, solver->comm.coords, sizeof(solver->comm.coords));
|
memcpy(particletracer->coords, solver->comm.coords, sizeof(solver->comm.coords));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
double offset[6][particletracer->size];
|
double offset[6][particletracer->size];
|
||||||
|
|
||||||
particletracer->xOffset = solver->xOffset;
|
particletracer->xOffset = solver->xOffset;
|
||||||
particletracer->yOffset = solver->yOffset;
|
particletracer->yOffset = solver->yOffset;
|
||||||
particletracer->zOffset = solver->zOffset;
|
particletracer->zOffset = solver->zOffset;
|
||||||
particletracer->xOffsetEnd = solver->xOffsetEnd;
|
particletracer->xOffsetEnd = solver->xOffsetEnd;
|
||||||
particletracer->yOffsetEnd = solver->yOffsetEnd;
|
particletracer->yOffsetEnd = solver->yOffsetEnd;
|
||||||
particletracer->zOffsetEnd = solver->zOffsetEnd;
|
particletracer->zOffsetEnd = solver->zOffsetEnd;
|
||||||
|
|
||||||
//printf("Rank : %d, xOffset : %.2f, yOffset : %.2f, zOffset : %.2f, xOffsetEnd : %.2f, yOffsetEnd : %.2f, zOffsetEnd : %.2f\n", particletracer->rank, particletracer->xOffset, particletracer->yOffset, particletracer->zOffset, particletracer->xOffsetEnd, particletracer->yOffsetEnd, particletracer->zOffsetEnd);
|
// printf("Rank : %d, xOffset : %.2f, yOffset : %.2f, zOffset : %.2f, xOffsetEnd :
|
||||||
|
// %.2f, yOffsetEnd : %.2f, zOffsetEnd : %.2f\n", particletracer->rank,
|
||||||
|
// particletracer->xOffset, particletracer->yOffset, particletracer->zOffset,
|
||||||
|
// particletracer->xOffsetEnd, particletracer->yOffsetEnd,
|
||||||
|
// particletracer->zOffsetEnd);
|
||||||
|
|
||||||
MPI_Allgather(&particletracer->xOffset, 1, MPI_DOUBLE, offset[0], 1, MPI_DOUBLE, particletracer->comm);
|
MPI_Allgather(&particletracer->xOffset,
|
||||||
MPI_Allgather(&particletracer->yOffset, 1, MPI_DOUBLE, offset[1], 1, MPI_DOUBLE, particletracer->comm);
|
1,
|
||||||
MPI_Allgather(&particletracer->zOffset, 1, MPI_DOUBLE, offset[2], 1, MPI_DOUBLE, particletracer->comm);
|
MPI_DOUBLE,
|
||||||
MPI_Allgather(&particletracer->xOffsetEnd, 1, MPI_DOUBLE, offset[3], 1, MPI_DOUBLE, particletracer->comm);
|
offset[0],
|
||||||
MPI_Allgather(&particletracer->yOffsetEnd, 1, MPI_DOUBLE, offset[4], 1, MPI_DOUBLE, particletracer->comm);
|
1,
|
||||||
MPI_Allgather(&particletracer->zOffsetEnd, 1, MPI_DOUBLE, offset[5], 1, MPI_DOUBLE, particletracer->comm);
|
MPI_DOUBLE,
|
||||||
|
particletracer->comm);
|
||||||
|
MPI_Allgather(&particletracer->yOffset,
|
||||||
|
1,
|
||||||
|
MPI_DOUBLE,
|
||||||
|
offset[1],
|
||||||
|
1,
|
||||||
|
MPI_DOUBLE,
|
||||||
|
particletracer->comm);
|
||||||
|
MPI_Allgather(&particletracer->zOffset,
|
||||||
|
1,
|
||||||
|
MPI_DOUBLE,
|
||||||
|
offset[2],
|
||||||
|
1,
|
||||||
|
MPI_DOUBLE,
|
||||||
|
particletracer->comm);
|
||||||
|
MPI_Allgather(&particletracer->xOffsetEnd,
|
||||||
|
1,
|
||||||
|
MPI_DOUBLE,
|
||||||
|
offset[3],
|
||||||
|
1,
|
||||||
|
MPI_DOUBLE,
|
||||||
|
particletracer->comm);
|
||||||
|
MPI_Allgather(&particletracer->yOffsetEnd,
|
||||||
|
1,
|
||||||
|
MPI_DOUBLE,
|
||||||
|
offset[4],
|
||||||
|
1,
|
||||||
|
MPI_DOUBLE,
|
||||||
|
particletracer->comm);
|
||||||
|
MPI_Allgather(&particletracer->zOffsetEnd,
|
||||||
|
1,
|
||||||
|
MPI_DOUBLE,
|
||||||
|
offset[5],
|
||||||
|
1,
|
||||||
|
MPI_DOUBLE,
|
||||||
|
particletracer->comm);
|
||||||
|
|
||||||
memcpy(particletracer->offset, offset, sizeof(offset));
|
memcpy(particletracer->offset, offset, sizeof(offset));
|
||||||
|
|
||||||
|
|
||||||
// if(particletracer->rank == 0)
|
// if(particletracer->rank == 0)
|
||||||
// {
|
// {
|
||||||
// for(int i = 0;i < particletracer->size; ++i)
|
// for(int i = 0;i < particletracer->size; ++i)
|
||||||
// {
|
// {
|
||||||
// printf("Rank : %d, xLocal : %.2f, yLocal : %.2f, zLocal : %.2f\n", i, xLocal[i], yLocal[i], zLocal[i]);
|
// printf("Rank : %d, xLocal : %.2f, yLocal : %.2f, zLocal : %.2f\n", i,
|
||||||
|
// xLocal[i], yLocal[i], zLocal[i]);
|
||||||
// }
|
// }
|
||||||
// for(int i = 0;i < particletracer->size; ++i)
|
// for(int i = 0;i < particletracer->size; ++i)
|
||||||
// {
|
// {
|
||||||
// printf("Rank : %d and its xOffset : %.2f, yOffset : %.2f, zOffset : %.2f,xOffsetEnd : %.2f, yOffsetEnd : %.2f, zOffsetEnd : %.2f\n",
|
// printf("Rank : %d and its xOffset : %.2f, yOffset : %.2f, zOffset :
|
||||||
// i, particletracer->offset[i + particletracer->size * XOFFSET],
|
// %.2f,xOffsetEnd : %.2f, yOffsetEnd : %.2f, zOffsetEnd : %.2f\n", i,
|
||||||
// particletracer->offset[i + particletracer->size * YOFFSET], particletracer->offset[i + particletracer->size * ZOFFSET]
|
// particletracer->offset[i + particletracer->size * XOFFSET],
|
||||||
// , particletracer->offset[i + particletracer->size * XOFFSETEND],
|
// particletracer->offset[i + particletracer->size * YOFFSET],
|
||||||
// particletracer->offset[i + particletracer->size * YOFFSETEND], particletracer->offset[i + particletracer->size * ZOFFSETEND]);
|
// particletracer->offset[i + particletracer->size * ZOFFSET] ,
|
||||||
|
// particletracer->offset[i + particletracer->size * XOFFSETEND],
|
||||||
|
// particletracer->offset[i + particletracer->size * YOFFSETEND],
|
||||||
|
// particletracer->offset[i + particletracer->size * ZOFFSETEND]);
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
for (int i = 0; i < particletracer->numberOfParticles; ++i)
|
for (int i = 0; i < particletracer->numberOfParticles; ++i) {
|
||||||
{
|
// double spacing = (double)i /
|
||||||
// double spacing = (double)i / (double)(particletracer->numberOfParticles - 1);
|
// (double)(particletracer->numberOfParticles - 1);
|
||||||
// particletracer->linSpaceLine[i].x = spacing * particletracer->x1 + (1.0 - spacing) * particletracer->x2;
|
// particletracer->linSpaceLine[i].x = spacing * particletracer->x1 + (1.0 -
|
||||||
// particletracer->linSpaceLine[i].y = spacing * particletracer->y1 + (1.0 - spacing) * particletracer->y2;
|
// spacing) * particletracer->x2; particletracer->linSpaceLine[i].y = spacing *
|
||||||
// particletracer->linSpaceLine[i].z = spacing * particletracer->z1 + (1.0 - spacing) * particletracer->z2;
|
// particletracer->y1 + (1.0 - spacing) * particletracer->y2;
|
||||||
|
// particletracer->linSpaceLine[i].z = spacing * particletracer->z1 + (1.0 -
|
||||||
|
// spacing) * particletracer->z2;
|
||||||
|
|
||||||
particletracer->linSpaceLine[i].x = particletracer->x1;
|
particletracer->linSpaceLine[i].x = particletracer->x1;
|
||||||
particletracer->linSpaceLine[i].y = (double) rand() / RAND_MAX * particletracer->ylength;
|
particletracer->linSpaceLine[i].y = (double)rand() / RAND_MAX *
|
||||||
particletracer->linSpaceLine[i].z = (double) rand() / RAND_MAX * particletracer->zlength;
|
particletracer->ylength;
|
||||||
|
particletracer->linSpaceLine[i].z = (double)rand() / RAND_MAX *
|
||||||
|
particletracer->zlength;
|
||||||
|
|
||||||
particletracer->linSpaceLine[i].flag = true;
|
particletracer->linSpaceLine[i].flag = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Create the mpi_particle datatype
|
// Create the mpi_particle datatype
|
||||||
MPI_Datatype mpi_particle;
|
MPI_Datatype mpi_particle;
|
||||||
int lengths[4] = { 1, 1, 1, 1 };
|
int lengths[4] = { 1, 1, 1, 1 };
|
||||||
@ -545,42 +618,74 @@ void initParticleTracer(ParticleTracer* particletracer, Parameter* params, Solv
|
|||||||
MPI_Get_address(&dummy_particle.y, &displacements[1]);
|
MPI_Get_address(&dummy_particle.y, &displacements[1]);
|
||||||
MPI_Get_address(&dummy_particle.z, &displacements[2]);
|
MPI_Get_address(&dummy_particle.z, &displacements[2]);
|
||||||
MPI_Get_address(&dummy_particle.flag, &displacements[3]);
|
MPI_Get_address(&dummy_particle.flag, &displacements[3]);
|
||||||
displacements[0] = MPI_Aint_diff(displacements[0], base_address);
|
displacements[0] = MPI_Aint_diff(displacements[0], base_address);
|
||||||
displacements[1] = MPI_Aint_diff(displacements[1], base_address);
|
displacements[1] = MPI_Aint_diff(displacements[1], base_address);
|
||||||
displacements[2] = MPI_Aint_diff(displacements[2], base_address);
|
displacements[2] = MPI_Aint_diff(displacements[2], base_address);
|
||||||
displacements[3] = MPI_Aint_diff(displacements[3], base_address);
|
displacements[3] = MPI_Aint_diff(displacements[3], base_address);
|
||||||
MPI_Datatype types[4] = { MPI_DOUBLE, MPI_DOUBLE, MPI_DOUBLE, MPI_C_BOOL };
|
MPI_Datatype types[4] = { MPI_DOUBLE, MPI_DOUBLE, MPI_DOUBLE, MPI_C_BOOL };
|
||||||
MPI_Type_create_struct(4, lengths, displacements, types, &particletracer->mpi_particle);
|
MPI_Type_create_struct(4,
|
||||||
|
lengths,
|
||||||
|
displacements,
|
||||||
|
types,
|
||||||
|
&particletracer->mpi_particle);
|
||||||
MPI_Type_commit(&particletracer->mpi_particle);
|
MPI_Type_commit(&particletracer->mpi_particle);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void printParticleTracerParameters(ParticleTracer* particletracer)
|
void printParticleTracerParameters(ParticleTracer* particletracer)
|
||||||
{
|
{
|
||||||
printf("Particle Tracing data:\n");
|
printf("Particle Tracing data:\n");
|
||||||
printf("Rank : %d\n", particletracer->rank);
|
printf("Rank : %d\n", particletracer->rank);
|
||||||
printf("\tNumber of particles : %d being injected for every period of %.2f\n", particletracer->numberOfParticles, particletracer->injectTimePeriod);
|
printf("\tNumber of particles : %d being injected for every period of %.2f\n",
|
||||||
|
particletracer->numberOfParticles,
|
||||||
|
particletracer->injectTimePeriod);
|
||||||
printf("\tstartTime : %.2f\n", particletracer->startTime);
|
printf("\tstartTime : %.2f\n", particletracer->startTime);
|
||||||
printf("\t(Line along which the particles are to be injected) \n\tx1 : %.2f, y1 : %.2f, z1 : %.2f, x2 : %.2f, y2 : %.2f, z2 : %.2f\n", particletracer->x1, particletracer->y1, particletracer->z1, particletracer->x2, particletracer->y2, particletracer->z2);
|
printf("\t(Line along which the particles are to be injected) \n\tx1 : %.2f, y1 : "
|
||||||
printf("\tPointer : %d, TotalParticles : %d\n", particletracer->pointer, particletracer->totalParticles);
|
"%.2f, z1 : %.2f, x2 : %.2f, y2 : %.2f, z2 : %.2f\n",
|
||||||
printf("\tdt : %.2f, dx : %.2f, dy : %.2f, dz : %.2f\n", particletracer->dt, particletracer->dx, particletracer->dy, particletracer->dz);
|
particletracer->x1,
|
||||||
printf("\tcoord[0] : %d, coord[1] : %d, coord[2] : %d\n", particletracer->coords[IDIM], particletracer->coords[JDIM], particletracer->coords[KDIM]);
|
particletracer->y1,
|
||||||
printf("\txOffset : %.2f, yOffset : %.2f, zOffset : %.2f\n", particletracer->xOffset, particletracer->yOffset, particletracer->zOffset);
|
particletracer->z1,
|
||||||
printf("\txOffsetEnd : %.2f, yOffsetEnd : %.2f, zOffsetEnd : %.2f\n", particletracer->xOffsetEnd, particletracer->yOffsetEnd, particletracer->zOffsetEnd);
|
particletracer->x2,
|
||||||
printf("\txLocal : %.2f, yLocal : %.2f, zLocal : %.2f\n", particletracer->xLocal, particletracer->yLocal, particletracer->zLocal);
|
particletracer->y2,
|
||||||
|
particletracer->z2);
|
||||||
|
printf("\tPointer : %d, TotalParticles : %d\n",
|
||||||
|
particletracer->pointer,
|
||||||
|
particletracer->totalParticles);
|
||||||
|
printf("\tdt : %.2f, dx : %.2f, dy : %.2f, dz : %.2f\n",
|
||||||
|
particletracer->dt,
|
||||||
|
particletracer->dx,
|
||||||
|
particletracer->dy,
|
||||||
|
particletracer->dz);
|
||||||
|
printf("\tcoord[0] : %d, coord[1] : %d, coord[2] : %d\n",
|
||||||
|
particletracer->coords[IDIM],
|
||||||
|
particletracer->coords[JDIM],
|
||||||
|
particletracer->coords[KDIM]);
|
||||||
|
printf("\txOffset : %.2f, yOffset : %.2f, zOffset : %.2f\n",
|
||||||
|
particletracer->xOffset,
|
||||||
|
particletracer->yOffset,
|
||||||
|
particletracer->zOffset);
|
||||||
|
printf("\txOffsetEnd : %.2f, yOffsetEnd : %.2f, zOffsetEnd : %.2f\n",
|
||||||
|
particletracer->xOffsetEnd,
|
||||||
|
particletracer->yOffsetEnd,
|
||||||
|
particletracer->zOffsetEnd);
|
||||||
|
printf("\txLocal : %.2f, yLocal : %.2f, zLocal : %.2f\n",
|
||||||
|
particletracer->xLocal,
|
||||||
|
particletracer->yLocal,
|
||||||
|
particletracer->zLocal);
|
||||||
}
|
}
|
||||||
|
|
||||||
void trace(ParticleTracer* particletracer, double* restrict u, double* restrict v, double* restrict w, int* restrict seg,double time)
|
void trace(ParticleTracer* particletracer,
|
||||||
|
double* restrict u,
|
||||||
|
double* restrict v,
|
||||||
|
double* restrict w,
|
||||||
|
int* restrict seg,
|
||||||
|
double time)
|
||||||
{
|
{
|
||||||
if (time >= particletracer->startTime)
|
if (time >= particletracer->startTime) {
|
||||||
{
|
if ((time - particletracer->lastInjectTime) >= particletracer->injectTimePeriod) {
|
||||||
if( (time - particletracer->lastInjectTime) >= particletracer->injectTimePeriod)
|
|
||||||
{
|
|
||||||
injectParticles(particletracer, seg);
|
injectParticles(particletracer, seg);
|
||||||
particletracer->lastInjectTime = time;
|
particletracer->lastInjectTime = time;
|
||||||
}
|
}
|
||||||
if( (time - particletracer->lastWriteTime) >= particletracer->writeTimePeriod)
|
if ((time - particletracer->lastWriteTime) >= particletracer->writeTimePeriod) {
|
||||||
{
|
|
||||||
writeParticles(particletracer);
|
writeParticles(particletracer);
|
||||||
particletracer->lastWriteTime = time;
|
particletracer->lastWriteTime = time;
|
||||||
}
|
}
|
||||||
@ -595,19 +700,16 @@ void compress(ParticleTracer* particletracer)
|
|||||||
Particle* memPool = particletracer->particlePool;
|
Particle* memPool = particletracer->particlePool;
|
||||||
Particle tempPool[particletracer->totalParticles];
|
Particle tempPool[particletracer->totalParticles];
|
||||||
|
|
||||||
for(int i = 0; i < particletracer->totalParticles; ++i)
|
for (int i = 0; i < particletracer->totalParticles; ++i) {
|
||||||
{
|
tempPool[i].x = 0.0;
|
||||||
tempPool[i].x = 0.0;
|
tempPool[i].y = 0.0;
|
||||||
tempPool[i].y = 0.0;
|
tempPool[i].z = 0.0;
|
||||||
tempPool[i].z = 0.0;
|
|
||||||
tempPool[i].flag = false;
|
tempPool[i].flag = false;
|
||||||
}
|
}
|
||||||
int totalParticles = 0;
|
int totalParticles = 0;
|
||||||
|
|
||||||
for(int i=0; i < particletracer->totalParticles; ++i)
|
for (int i = 0; i < particletracer->totalParticles; ++i) {
|
||||||
{
|
if (memPool[i].flag == true) {
|
||||||
if(memPool[i].flag == true)
|
|
||||||
{
|
|
||||||
tempPool[totalParticles].x = memPool[i].x;
|
tempPool[totalParticles].x = memPool[i].x;
|
||||||
tempPool[totalParticles].y = memPool[i].y;
|
tempPool[totalParticles].y = memPool[i].y;
|
||||||
tempPool[totalParticles].z = memPool[i].z;
|
tempPool[totalParticles].z = memPool[i].z;
|
||||||
|
@ -9,25 +9,25 @@
|
|||||||
#include "allocate.h"
|
#include "allocate.h"
|
||||||
#include "parameter.h"
|
#include "parameter.h"
|
||||||
#include "solver.h"
|
#include "solver.h"
|
||||||
#include <stdbool.h>
|
|
||||||
#include <mpi.h>
|
#include <mpi.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
#define NDIMS 3
|
#define NDIMS 3
|
||||||
|
|
||||||
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;
|
int estimatedNumParticles;
|
||||||
|
|
||||||
double dx, dy,dz, dt;
|
double dx, dy, dz, dt;
|
||||||
Particle* linSpaceLine;
|
Particle* linSpaceLine;
|
||||||
Particle* particlePool;
|
Particle* particlePool;
|
||||||
|
|
||||||
@ -43,19 +43,20 @@ typedef struct {
|
|||||||
int rank, size;
|
int rank, size;
|
||||||
int coords[NDIMS], dims[NDIMS];
|
int coords[NDIMS], dims[NDIMS];
|
||||||
|
|
||||||
double xLocal, yLocal, zLocal, xOffset, yOffset, zOffset, xOffsetEnd, yOffsetEnd, zOffsetEnd;
|
double xLocal, yLocal, zLocal, xOffset, yOffset, zOffset, xOffsetEnd, yOffsetEnd,
|
||||||
|
zOffsetEnd;
|
||||||
|
|
||||||
double* offset;
|
double* offset;
|
||||||
|
|
||||||
} ParticleTracer;
|
} ParticleTracer;
|
||||||
|
|
||||||
void initParticleTracer(ParticleTracer*, Parameter*, Solver* );
|
void initParticleTracer(ParticleTracer*, Parameter*, Solver*);
|
||||||
void injectParticles(ParticleTracer*, int*);
|
void injectParticles(ParticleTracer*, int*);
|
||||||
void advanceParticles(ParticleTracer*, double* , double* , double* ,int*, double);
|
void advanceParticles(ParticleTracer*, double*, 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* , int*, double );
|
void trace(ParticleTracer*, double*, double*, double*, int*, double);
|
||||||
void compress(ParticleTracer* );
|
void compress(ParticleTracer*);
|
||||||
#endif
|
#endif
|
File diff suppressed because it is too large
Load Diff
@ -59,7 +59,8 @@ typedef struct {
|
|||||||
double *f, *g, *h;
|
double *f, *g, *h;
|
||||||
double *u, *v, *w;
|
double *u, *v, *w;
|
||||||
int* seg;
|
int* seg;
|
||||||
double xLocal, yLocal, zLocal, xOffset, yOffset, zOffset, xOffsetEnd, yOffsetEnd, zOffsetEnd;
|
double xLocal, yLocal, zLocal, xOffset, yOffset, zOffset, xOffsetEnd, yOffsetEnd,
|
||||||
|
zOffsetEnd;
|
||||||
/* parameters */
|
/* parameters */
|
||||||
double eps, omega, rho;
|
double eps, omega, rho;
|
||||||
double re, tau, gamma;
|
double re, tau, gamma;
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "vtkWriter.h"
|
#include "vtkWriter.h"
|
||||||
#define G(v, i, j, k) v[(k)*imax * jmax + (j)*imax + (i)]
|
#define G(v, i, j, k) v[(k) * imax * jmax + (j) * imax + (i)]
|
||||||
|
|
||||||
static double floatSwap(double f)
|
static double floatSwap(double f)
|
||||||
{
|
{
|
||||||
|
@ -12,20 +12,20 @@
|
|||||||
|
|
||||||
#include "vtkWriter.h"
|
#include "vtkWriter.h"
|
||||||
|
|
||||||
#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 S(i, j, k) seg[(k) * (imax + 2) * (jmax + 2) + (j) * (imax + 2) + (i)]
|
||||||
|
|
||||||
static int ts = 0;
|
static int ts = 0;
|
||||||
unsigned int seed = 32767;
|
unsigned int seed = 32767;
|
||||||
void printParticles(ParticleTracer* particletracer)
|
void printParticles(ParticleTracer* particletracer)
|
||||||
{
|
{
|
||||||
for(int i = 0; i < particletracer->totalParticles; ++i)
|
for (int i = 0; i < particletracer->totalParticles; ++i) {
|
||||||
{
|
printf("Particle position X : %.2f, Y : %.2f, flag : %d\n",
|
||||||
printf("Particle position X : %.2f, Y : %.2f, flag : %d\n", particletracer->particlePool[i].x,
|
particletracer->particlePool[i].x,
|
||||||
particletracer->particlePool[i].y,
|
particletracer->particlePool[i].y,
|
||||||
particletracer->particlePool[i].flag);
|
particletracer->particlePool[i].flag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void injectParticles(ParticleTracer* particletracer, int* seg)
|
void injectParticles(ParticleTracer* particletracer, int* seg)
|
||||||
@ -34,23 +34,31 @@ void injectParticles(ParticleTracer* particletracer, int* seg)
|
|||||||
int imax = particletracer->imax;
|
int imax = particletracer->imax;
|
||||||
int jmax = particletracer->jmax;
|
int jmax = particletracer->jmax;
|
||||||
int kmax = particletracer->kmax;
|
int kmax = particletracer->kmax;
|
||||||
for(int i = 0; i < particletracer->numberOfParticles; ++i)
|
for (int i = 0; i < particletracer->numberOfParticles; ++i) {
|
||||||
{
|
|
||||||
|
|
||||||
// particletracer->particlePool[particletracer->pointer].x = particletracer->linSpaceLine[i].x;
|
// particletracer->particlePool[particletracer->pointer].x =
|
||||||
// particletracer->particlePool[particletracer->pointer].y = particletracer->linSpaceLine[i].y;
|
// particletracer->linSpaceLine[i].x;
|
||||||
// particletracer->particlePool[particletracer->pointer].z = particletracer->linSpaceLine[i].z;
|
// particletracer->particlePool[particletracer->pointer].y =
|
||||||
|
// particletracer->linSpaceLine[i].y;
|
||||||
|
// particletracer->particlePool[particletracer->pointer].z =
|
||||||
|
// particletracer->linSpaceLine[i].z;
|
||||||
|
|
||||||
particletracer->particlePool[particletracer->pointer].x = particletracer->x1;
|
particletracer->particlePool[particletracer->pointer].x = particletracer->x1;
|
||||||
particletracer->particlePool[particletracer->pointer].y = (double) rand() / RAND_MAX * particletracer->ylength;
|
particletracer->particlePool[particletracer->pointer].y = (double)rand() /
|
||||||
particletracer->particlePool[particletracer->pointer].z = (double) rand() / RAND_MAX * particletracer->zlength;
|
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 i = particletracer->particlePool[particletracer->pointer].x /
|
||||||
int j = particletracer->particlePool[particletracer->pointer].y / particletracer->dy;
|
particletracer->dx;
|
||||||
int k = particletracer->particlePool[particletracer->pointer].z / particletracer->dz;
|
int j = particletracer->particlePool[particletracer->pointer].y /
|
||||||
|
particletracer->dy;
|
||||||
|
int k = particletracer->particlePool[particletracer->pointer].z /
|
||||||
|
particletracer->dz;
|
||||||
|
|
||||||
if(S(i,j,k) == NONE)
|
if (S(i, j, k) == NONE) {
|
||||||
{
|
|
||||||
particletracer->particlePool[particletracer->pointer].flag = true;
|
particletracer->particlePool[particletracer->pointer].flag = true;
|
||||||
++(particletracer->pointer);
|
++(particletracer->pointer);
|
||||||
++(particletracer->totalParticles);
|
++(particletracer->totalParticles);
|
||||||
@ -58,28 +66,27 @@ void injectParticles(ParticleTracer* particletracer, int* seg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void advanceParticles(ParticleTracer* particletracer, double* restrict u, double* restrict v, double* restrict w, int* restrict seg, 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 imax = particletracer->imax;
|
||||||
int jmax = particletracer->jmax;
|
int jmax = particletracer->jmax;
|
||||||
int kmax = particletracer->kmax;
|
int kmax = particletracer->kmax;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
double dx = particletracer->dx;
|
double dx = particletracer->dx;
|
||||||
double dy = particletracer->dy;
|
double dy = particletracer->dy;
|
||||||
double dz = particletracer->dz;
|
double dz = particletracer->dz;
|
||||||
|
|
||||||
|
|
||||||
double xlength = particletracer->xlength;
|
double xlength = particletracer->xlength;
|
||||||
double ylength = particletracer->ylength;
|
double ylength = particletracer->ylength;
|
||||||
double zlength = particletracer->zlength;
|
double zlength = particletracer->zlength;
|
||||||
|
|
||||||
|
for (int i = 0; i < particletracer->totalParticles; ++i) {
|
||||||
for(int i = 0; i < particletracer->totalParticles; ++i)
|
if (particletracer->particlePool[i].flag == true) {
|
||||||
{
|
|
||||||
if(particletracer->particlePool[i].flag == true)
|
|
||||||
{
|
|
||||||
double x = particletracer->particlePool[i].x;
|
double x = particletracer->particlePool[i].x;
|
||||||
double y = particletracer->particlePool[i].y;
|
double y = particletracer->particlePool[i].y;
|
||||||
double z = particletracer->particlePool[i].z;
|
double z = particletracer->particlePool[i].z;
|
||||||
@ -88,7 +95,6 @@ void advanceParticles(ParticleTracer* particletracer, double* restrict u, double
|
|||||||
int jCoord = (int)((y + 0.5 * dy) / dy) + 1;
|
int jCoord = (int)((y + 0.5 * dy) / dy) + 1;
|
||||||
int kCoord = (int)((z + 0.5 * dz) / dz) + 1;
|
int kCoord = (int)((z + 0.5 * dz) / dz) + 1;
|
||||||
|
|
||||||
|
|
||||||
double x1 = (double)(iCoord - 1) * dx;
|
double x1 = (double)(iCoord - 1) * dx;
|
||||||
double y1 = ((double)(jCoord - 1) - 0.5) * dy;
|
double y1 = ((double)(jCoord - 1) - 0.5) * dy;
|
||||||
double z1 = ((double)(kCoord - 1) - 0.5) * dz;
|
double z1 = ((double)(kCoord - 1) - 0.5) * dz;
|
||||||
@ -97,20 +103,18 @@ void advanceParticles(ParticleTracer* particletracer, double* restrict u, double
|
|||||||
double y2 = ((double)jCoord - 0.5) * dy;
|
double y2 = ((double)jCoord - 0.5) * dy;
|
||||||
double z2 = ((double)kCoord - 0.5) * dz;
|
double z2 = ((double)kCoord - 0.5) * dz;
|
||||||
|
|
||||||
|
double u_n =
|
||||||
double u_n = (1.0 / (dx * dy * dz)) *
|
(1.0 / (dx * dy * dz)) *
|
||||||
(
|
((x2 - x) * (y2 - y) * (z2 - z) * U(iCoord - 1, jCoord - 1, kCoord - 1) +
|
||||||
(x2 - x) * (y2 - y) * (z2 - z) * U(iCoord - 1, jCoord - 1, kCoord - 1) +
|
|
||||||
(x - x1) * (y2 - y) * (z2 - z) * U(iCoord, jCoord - 1, kCoord - 1) +
|
(x - x1) * (y2 - y) * (z2 - z) * U(iCoord, jCoord - 1, kCoord - 1) +
|
||||||
(x2 - x) * (y - y1) * (z2 - z) * U(iCoord - 1, jCoord, kCoord - 1) +
|
(x2 - x) * (y - y1) * (z2 - z) * U(iCoord - 1, jCoord, kCoord - 1) +
|
||||||
(x - x1) * (y - y1) * (z2 - z) * U(iCoord, jCoord, kCoord - 1) +
|
(x - x1) * (y - y1) * (z2 - z) * U(iCoord, jCoord, kCoord - 1) +
|
||||||
(x2 - x) * (y2 - y) * (z - z1) * U(iCoord - 1, jCoord - 1, kCoord) +
|
(x2 - x) * (y2 - y) * (z - z1) * U(iCoord - 1, jCoord - 1, kCoord) +
|
||||||
(x - x1) * (y2 - y) * (z - z1) * U(iCoord, jCoord - 1, kCoord) +
|
(x - x1) * (y2 - y) * (z - z1) * U(iCoord, jCoord - 1, kCoord) +
|
||||||
(x2 - x) * (y - y1) * (z - z1) * U(iCoord - 1, jCoord, kCoord) +
|
(x2 - x) * (y - y1) * (z - z1) * U(iCoord - 1, jCoord, kCoord) +
|
||||||
(x - x1) * (y - y1) * (z - z1) * U(iCoord, jCoord, kCoord)
|
(x - x1) * (y - y1) * (z - z1) * U(iCoord, jCoord, kCoord));
|
||||||
);
|
|
||||||
|
|
||||||
double new_x = x + particletracer->dt * u_n;
|
double new_x = x + particletracer->dt * u_n;
|
||||||
particletracer->particlePool[i].x = new_x;
|
particletracer->particlePool[i].x = new_x;
|
||||||
|
|
||||||
iCoord = (int)((x + 0.5 * dx) / dx) + 1;
|
iCoord = (int)((x + 0.5 * dx) / dx) + 1;
|
||||||
@ -125,19 +129,18 @@ void advanceParticles(ParticleTracer* particletracer, double* restrict u, double
|
|||||||
y2 = (double)jCoord * dy;
|
y2 = (double)jCoord * dy;
|
||||||
z2 = ((double)kCoord - 0.5) * dz;
|
z2 = ((double)kCoord - 0.5) * dz;
|
||||||
|
|
||||||
double v_n = (1.0 / (dx * dy * dz)) *
|
double v_n =
|
||||||
(
|
(1.0 / (dx * dy * dz)) *
|
||||||
(x2 - x) * (y2 - y) * (z2 - z) * V(iCoord - 1, jCoord - 1, kCoord - 1) +
|
((x2 - x) * (y2 - y) * (z2 - z) * V(iCoord - 1, jCoord - 1, kCoord - 1) +
|
||||||
(x - x1) * (y2 - y) * (z2 - z) * V(iCoord, jCoord - 1, kCoord - 1) +
|
(x - x1) * (y2 - y) * (z2 - z) * V(iCoord, jCoord - 1, kCoord - 1) +
|
||||||
(x2 - x) * (y - y1) * (z2 - z) * V(iCoord - 1, jCoord, kCoord - 1) +
|
(x2 - x) * (y - y1) * (z2 - z) * V(iCoord - 1, jCoord, kCoord - 1) +
|
||||||
(x - x1) * (y - y1) * (z2 - z) * V(iCoord, jCoord, kCoord - 1) +
|
(x - x1) * (y - y1) * (z2 - z) * V(iCoord, jCoord, kCoord - 1) +
|
||||||
(x2 - x) * (y2 - y) * (z - z1) * V(iCoord - 1, jCoord - 1, kCoord) +
|
(x2 - x) * (y2 - y) * (z - z1) * V(iCoord - 1, jCoord - 1, kCoord) +
|
||||||
(x - x1) * (y2 - y) * (z - z1) * V(iCoord, jCoord - 1, kCoord) +
|
(x - x1) * (y2 - y) * (z - z1) * V(iCoord, jCoord - 1, kCoord) +
|
||||||
(x2 - x) * (y - y1) * (z - z1) * V(iCoord - 1, jCoord, kCoord) +
|
(x2 - x) * (y - y1) * (z - z1) * V(iCoord - 1, jCoord, kCoord) +
|
||||||
(x - x1) * (y - y1) * (z - z1) * V(iCoord, jCoord, kCoord)
|
(x - x1) * (y - y1) * (z - z1) * V(iCoord, jCoord, kCoord));
|
||||||
);
|
|
||||||
|
|
||||||
double new_y = y + particletracer->dt * v_n;
|
double new_y = y + particletracer->dt * v_n;
|
||||||
particletracer->particlePool[i].y = new_y;
|
particletracer->particlePool[i].y = new_y;
|
||||||
|
|
||||||
iCoord = (int)((x + 0.5 * dx) / dx) + 1;
|
iCoord = (int)((x + 0.5 * dx) / dx) + 1;
|
||||||
@ -152,36 +155,40 @@ void advanceParticles(ParticleTracer* particletracer, double* restrict u, double
|
|||||||
y2 = ((double)jCoord - 0.5) * dy;
|
y2 = ((double)jCoord - 0.5) * dy;
|
||||||
z2 = (double)kCoord * dz;
|
z2 = (double)kCoord * dz;
|
||||||
|
|
||||||
double w_n = (1.0 / (dx * dy * dz)) *
|
double w_n =
|
||||||
(
|
(1.0 / (dx * dy * dz)) *
|
||||||
(x2 - x) * (y2 - y) * (z2 - z) * W(iCoord - 1, jCoord - 1, kCoord - 1) +
|
((x2 - x) * (y2 - y) * (z2 - z) * W(iCoord - 1, jCoord - 1, kCoord - 1) +
|
||||||
(x - x1) * (y2 - y) * (z2 - z) * W(iCoord, jCoord - 1, kCoord - 1) +
|
(x - x1) * (y2 - y) * (z2 - z) * W(iCoord, jCoord - 1, kCoord - 1) +
|
||||||
(x2 - x) * (y - y1) * (z2 - z) * W(iCoord - 1, jCoord, kCoord - 1) +
|
(x2 - x) * (y - y1) * (z2 - z) * W(iCoord - 1, jCoord, kCoord - 1) +
|
||||||
(x - x1) * (y - y1) * (z2 - z) * W(iCoord, jCoord, kCoord - 1) +
|
(x - x1) * (y - y1) * (z2 - z) * W(iCoord, jCoord, kCoord - 1) +
|
||||||
(x2 - x) * (y2 - y) * (z - z1) * W(iCoord - 1, jCoord - 1, kCoord) +
|
(x2 - x) * (y2 - y) * (z - z1) * W(iCoord - 1, jCoord - 1, kCoord) +
|
||||||
(x - x1) * (y2 - y) * (z - z1) * W(iCoord, jCoord - 1, kCoord) +
|
(x - x1) * (y2 - y) * (z - z1) * W(iCoord, jCoord - 1, kCoord) +
|
||||||
(x2 - x) * (y - y1) * (z - z1) * W(iCoord - 1, jCoord, kCoord) +
|
(x2 - x) * (y - y1) * (z - z1) * W(iCoord - 1, jCoord, kCoord) +
|
||||||
(x - x1) * (y - y1) * (z - z1) * W(iCoord, jCoord, kCoord)
|
(x - x1) * (y - y1) * (z - z1) * W(iCoord, jCoord, kCoord));
|
||||||
);
|
|
||||||
|
|
||||||
double new_z = z + particletracer->dt * w_n;
|
double new_z = z + particletracer->dt * w_n;
|
||||||
particletracer->particlePool[i].z = new_z;
|
particletracer->particlePool[i].z = new_z;
|
||||||
|
|
||||||
// printf("\tOld X : %.2f, New X : %.2f, iCoord : %d\n\tOld Y : %.2f, New Y : %.2f, jCoord : %d\n\n", x, new_x, iCoord, y, new_y, jCoord);
|
// printf("\tOld X : %.2f, New X : %.2f, iCoord : %d\n\tOld Y : %.2f, New Y :
|
||||||
// printf("\tU(iCoord - 1, jCoord - 1) : %.2f, U(iCoord, jCoord - 1) : %.2f, U(iCoord - 1, jCoord) : %.2f, U(iCoord, jCoord) : %.2f\n", U(iCoord - 1, jCoord - 1), U(iCoord, jCoord - 1), U(iCoord - 1, jCoord), U(iCoord, jCoord));
|
// %.2f, jCoord : %d\n\n", x, new_x, iCoord, y, new_y, jCoord);
|
||||||
// printf("\tV(iCoord - 1, jCoord - 1) : %.2f, V(iCoord, jCoord - 1) : %.2f, V(iCoord - 1, jCoord) : %.2f, V(iCoord, jCoord) : %.2f\n\n", V(iCoord - 1, jCoord - 1), V(iCoord, jCoord - 1), V(iCoord - 1, jCoord), V(iCoord, jCoord));
|
// printf("\tU(iCoord - 1, jCoord - 1) : %.2f, U(iCoord, jCoord - 1) : %.2f,
|
||||||
// printf("\t U N : %.2f, V N : %.2f\n\n", u_n, v_n);
|
// U(iCoord - 1, jCoord) : %.2f, U(iCoord, jCoord) : %.2f\n", U(iCoord - 1,
|
||||||
// printf("\t j-1 * (imax + 2) + i-1 = %d with element from U : %.2f", (jCoord - 1) * (200 + 2) + (iCoord - 1), u[(jCoord - 1) * (imax + 2) + (iCoord - 1)]);
|
// jCoord - 1), U(iCoord, jCoord - 1), U(iCoord - 1, jCoord), U(iCoord,
|
||||||
// printf("\nimax : %d, jmax : %d\n", imax, jmax);
|
// jCoord)); printf("\tV(iCoord - 1, jCoord - 1) : %.2f, V(iCoord, jCoord - 1)
|
||||||
|
// : %.2f, V(iCoord - 1, jCoord) : %.2f, V(iCoord, jCoord) : %.2f\n\n",
|
||||||
|
// V(iCoord - 1, jCoord - 1), V(iCoord, jCoord - 1), V(iCoord - 1, jCoord),
|
||||||
|
// V(iCoord, jCoord)); printf("\t U N : %.2f, V N : %.2f\n\n", u_n, v_n);
|
||||||
|
// printf("\t j-1 * (imax + 2) + i-1 = %d with element from U : %.2f", (jCoord
|
||||||
|
// - 1) * (200 + 2) + (iCoord - 1), u[(jCoord - 1) * (imax + 2) + (iCoord -
|
||||||
|
// 1)]); printf("\nimax : %d, jmax : %d\n", imax, jmax);
|
||||||
|
|
||||||
if (((new_x < 0.0) || (new_x > xlength) || (new_y < 0.0) || (new_y > ylength) || (new_z < 0.0) || (new_z > zlength)))
|
if (((new_x < 0.0) || (new_x > xlength) || (new_y < 0.0) ||
|
||||||
{
|
(new_y > ylength) || (new_z < 0.0) || (new_z > zlength))) {
|
||||||
particletracer->particlePool[i].flag = false;
|
particletracer->particlePool[i].flag = false;
|
||||||
}
|
}
|
||||||
int i_new = new_x/dx, j_new = new_y/dy, k_new = new_z/dz;
|
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)
|
if (S(i_new, j_new, k_new) != NONE) {
|
||||||
{
|
|
||||||
particletracer->particlePool[i].flag = false;
|
particletracer->particlePool[i].flag = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -213,81 +220,101 @@ void initParticleTracer(ParticleTracer* particletracer, Parameter* params)
|
|||||||
particletracer->injectTimePeriod = params->injectTimePeriod;
|
particletracer->injectTimePeriod = params->injectTimePeriod;
|
||||||
particletracer->writeTimePeriod = params->writeTimePeriod;
|
particletracer->writeTimePeriod = params->writeTimePeriod;
|
||||||
|
|
||||||
particletracer->dt = params->dt;
|
particletracer->dt = params->dt;
|
||||||
particletracer->dx = params->xlength / params->imax;
|
particletracer->dx = params->xlength / params->imax;
|
||||||
particletracer->dy = params->ylength / params->jmax;
|
particletracer->dy = params->ylength / params->jmax;
|
||||||
particletracer->dz = params->zlength / params->kmax;
|
particletracer->dz = params->zlength / params->kmax;
|
||||||
|
|
||||||
|
particletracer->xlength = params->xlength;
|
||||||
|
particletracer->ylength = params->ylength;
|
||||||
|
particletracer->zlength = params->zlength;
|
||||||
|
|
||||||
particletracer->xlength = params->xlength;
|
particletracer->x1 = params->x1;
|
||||||
particletracer->ylength = params->ylength;
|
particletracer->y1 = params->y1;
|
||||||
particletracer->zlength = params->zlength;
|
particletracer->z1 = params->z1;
|
||||||
|
particletracer->x2 = params->x2;
|
||||||
|
particletracer->y2 = params->y2;
|
||||||
|
particletracer->z2 = params->z2;
|
||||||
|
|
||||||
|
particletracer->lastInjectTime = params->startTime;
|
||||||
|
particletracer->lastUpdateTime = params->startTime;
|
||||||
|
particletracer->lastWriteTime = params->startTime;
|
||||||
|
|
||||||
particletracer->x1 = params->x1;
|
particletracer->pointer = 0;
|
||||||
particletracer->y1 = params->y1;
|
particletracer->totalParticles = 0;
|
||||||
particletracer->z1 = params->z1;
|
|
||||||
particletracer->x2 = params->x2;
|
|
||||||
particletracer->y2 = params->y2;
|
|
||||||
particletracer->z2 = params->z2;
|
|
||||||
|
|
||||||
particletracer->lastInjectTime = params->startTime;
|
particletracer->imax = params->imax;
|
||||||
particletracer->lastUpdateTime = params->startTime;
|
particletracer->jmax = params->jmax;
|
||||||
particletracer->lastWriteTime = params->startTime;
|
particletracer->kmax = params->kmax;
|
||||||
|
|
||||||
particletracer->pointer = 0;
|
particletracer->estimatedNumParticles = ((params->te - params->startTime) + 2) *
|
||||||
particletracer->totalParticles = 0;
|
params->numberOfParticles;
|
||||||
|
|
||||||
particletracer->imax = params->imax;
|
particletracer->particlePool = malloc(
|
||||||
particletracer->jmax = params->jmax;
|
sizeof(Particle) * particletracer->estimatedNumParticles);
|
||||||
particletracer->kmax = params->kmax;
|
particletracer->linSpaceLine = malloc(
|
||||||
|
sizeof(Particle) * particletracer->numberOfParticles);
|
||||||
|
|
||||||
particletracer->estimatedNumParticles = ((params->te - params->startTime) + 2 ) * params->numberOfParticles;
|
for (int i = 0; i < particletracer->numberOfParticles; ++i) {
|
||||||
|
// double spacing = (double)i /
|
||||||
|
// (double)(particletracer->numberOfParticles - 1);
|
||||||
|
// particletracer->linSpaceLine[i].x = spacing * particletracer->x1 + (1.0 -
|
||||||
|
// spacing) * particletracer->x2; particletracer->linSpaceLine[i].y = spacing *
|
||||||
|
// particletracer->y1 + (1.0 - spacing) * particletracer->y2;
|
||||||
|
// particletracer->linSpaceLine[i].z = spacing * particletracer->z1 + (1.0 -
|
||||||
|
// spacing) * particletracer->z2;
|
||||||
|
|
||||||
particletracer->particlePool = malloc(sizeof(Particle) * particletracer->estimatedNumParticles);
|
particletracer->linSpaceLine[i].x = particletracer->x1;
|
||||||
particletracer->linSpaceLine = malloc(sizeof(Particle) * particletracer->numberOfParticles);
|
particletracer->linSpaceLine[i].y = (double)rand() / RAND_MAX *
|
||||||
|
particletracer->ylength;
|
||||||
for (int i = 0; i < particletracer->numberOfParticles; ++i)
|
particletracer->linSpaceLine[i].z = (double)rand() / RAND_MAX *
|
||||||
{
|
particletracer->zlength;
|
||||||
// double spacing = (double)i / (double)(particletracer->numberOfParticles - 1);
|
|
||||||
// particletracer->linSpaceLine[i].x = spacing * particletracer->x1 + (1.0 - spacing) * particletracer->x2;
|
|
||||||
// particletracer->linSpaceLine[i].y = spacing * particletracer->y1 + (1.0 - spacing) * particletracer->y2;
|
|
||||||
// particletracer->linSpaceLine[i].z = spacing * particletracer->z1 + (1.0 - spacing) * particletracer->z2;
|
|
||||||
|
|
||||||
particletracer->linSpaceLine[i].x = particletracer->x1;
|
|
||||||
particletracer->linSpaceLine[i].y = (double) rand() / RAND_MAX * particletracer->ylength;
|
|
||||||
particletracer->linSpaceLine[i].z = (double) rand() / RAND_MAX * particletracer->zlength;
|
|
||||||
|
|
||||||
particletracer->linSpaceLine[i].flag = true;
|
particletracer->linSpaceLine[i].flag = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void printParticleTracerParameters(ParticleTracer* particletracer)
|
void printParticleTracerParameters(ParticleTracer* particletracer)
|
||||||
{
|
{
|
||||||
printf("Particle Tracing data:\n");
|
printf("Particle Tracing data:\n");
|
||||||
printf("\tNumber of particles : %d being injected for every period of %.2f\n", particletracer->numberOfParticles, particletracer->injectTimePeriod);
|
printf("\tNumber of particles : %d being injected for every period of %.2f\n",
|
||||||
|
particletracer->numberOfParticles,
|
||||||
|
particletracer->injectTimePeriod);
|
||||||
printf("\tstartTime : %.2f\n", particletracer->startTime);
|
printf("\tstartTime : %.2f\n", particletracer->startTime);
|
||||||
printf("\t(Line along which the particles are to be injected) \n\tx1 : %.2f, y1 : %.2f, z1 : %.2f, x2 : %.2f, y2 : %.2f, z2 : %.2f\n", particletracer->x1, particletracer->y1, particletracer->z1, particletracer->x2, particletracer->y2, particletracer->z2);
|
printf("\t(Line along which the particles are to be injected) \n\tx1 : %.2f, y1 : "
|
||||||
printf("\tPointer : %d, TotalParticles : %d\n", particletracer->pointer, particletracer->totalParticles);
|
"%.2f, z1 : %.2f, x2 : %.2f, y2 : %.2f, z2 : %.2f\n",
|
||||||
printf("\tdt : %.2f, dx : %.2f, dy : %.2f, dz : %.2f\n", particletracer->dt, particletracer->dx, particletracer->dy, particletracer->dz);
|
particletracer->x1,
|
||||||
|
particletracer->y1,
|
||||||
|
particletracer->z1,
|
||||||
|
particletracer->x2,
|
||||||
|
particletracer->y2,
|
||||||
|
particletracer->z2);
|
||||||
|
printf("\tPointer : %d, TotalParticles : %d\n",
|
||||||
|
particletracer->pointer,
|
||||||
|
particletracer->totalParticles);
|
||||||
|
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, int* seg, double time)
|
void trace(ParticleTracer* particletracer,
|
||||||
|
double* u,
|
||||||
|
double* v,
|
||||||
|
double* w,
|
||||||
|
int* seg,
|
||||||
|
double time)
|
||||||
{
|
{
|
||||||
if (time >= particletracer->startTime)
|
if (time >= particletracer->startTime) {
|
||||||
{
|
// printParticles(particletracer);
|
||||||
//printParticles(particletracer);
|
if ((time - particletracer->lastInjectTime) >= particletracer->injectTimePeriod) {
|
||||||
if( (time - particletracer->lastInjectTime) >= particletracer->injectTimePeriod)
|
|
||||||
{
|
|
||||||
injectParticles(particletracer, seg);
|
injectParticles(particletracer, seg);
|
||||||
particletracer->lastInjectTime = time;
|
particletracer->lastInjectTime = time;
|
||||||
}
|
}
|
||||||
if( (time - particletracer->lastWriteTime) >= particletracer->writeTimePeriod)
|
if ((time - particletracer->lastWriteTime) >= particletracer->writeTimePeriod) {
|
||||||
{
|
|
||||||
writeParticles(particletracer);
|
writeParticles(particletracer);
|
||||||
particletracer->lastWriteTime = time;
|
particletracer->lastWriteTime = time;
|
||||||
|
|
||||||
}
|
}
|
||||||
advanceParticles(particletracer, u, v, w, seg, time);
|
advanceParticles(particletracer, u, v, w, seg, time);
|
||||||
compress(particletracer);
|
compress(particletracer);
|
||||||
@ -301,13 +328,11 @@ void compress(ParticleTracer* particletracer)
|
|||||||
Particle tempPool[particletracer->totalParticles];
|
Particle tempPool[particletracer->totalParticles];
|
||||||
int totalParticles = 0;
|
int totalParticles = 0;
|
||||||
|
|
||||||
for(int i=0; i < particletracer->totalParticles; ++i)
|
for (int i = 0; i < particletracer->totalParticles; ++i) {
|
||||||
{
|
if (memPool[i].flag == 1) {
|
||||||
if(memPool[i].flag == 1)
|
tempPool[totalParticles].x = memPool[i].x;
|
||||||
{
|
tempPool[totalParticles].y = memPool[i].y;
|
||||||
tempPool[totalParticles].x = memPool[i].x;
|
tempPool[totalParticles].z = memPool[i].z;
|
||||||
tempPool[totalParticles].y = memPool[i].y;
|
|
||||||
tempPool[totalParticles].z = memPool[i].z;
|
|
||||||
tempPool[totalParticles].flag = memPool[i].flag;
|
tempPool[totalParticles].flag = memPool[i].flag;
|
||||||
++totalParticles;
|
++totalParticles;
|
||||||
}
|
}
|
||||||
@ -316,5 +341,5 @@ void compress(ParticleTracer* particletracer)
|
|||||||
particletracer->totalParticles = totalParticles;
|
particletracer->totalParticles = totalParticles;
|
||||||
particletracer->pointer = totalParticles + 1;
|
particletracer->pointer = totalParticles + 1;
|
||||||
|
|
||||||
memcpy(particletracer->particlePool, tempPool, totalParticles*sizeof(Particle));
|
memcpy(particletracer->particlePool, tempPool, totalParticles * sizeof(Particle));
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ typedef struct {
|
|||||||
|
|
||||||
extern void initParticleTracer(ParticleTracer*, Parameter*);
|
extern void initParticleTracer(ParticleTracer*, Parameter*);
|
||||||
extern void injectParticles(ParticleTracer*, int* seg);
|
extern void injectParticles(ParticleTracer*, int* seg);
|
||||||
extern void advanceParticles(ParticleTracer*, double*, double*, double*, int*,double);
|
extern void advanceParticles(ParticleTracer*, double*, double*, double*, int*, double);
|
||||||
extern void freeParticles(ParticleTracer*);
|
extern void freeParticles(ParticleTracer*);
|
||||||
extern void writeParticles(ParticleTracer*);
|
extern void writeParticles(ParticleTracer*);
|
||||||
extern void printParticleTracerParameters(ParticleTracer*);
|
extern void printParticleTracerParameters(ParticleTracer*);
|
||||||
|
@ -438,17 +438,16 @@ void computeRHS(Solver* s)
|
|||||||
double* f = s->f;
|
double* f = s->f;
|
||||||
double* g = s->g;
|
double* g = s->g;
|
||||||
double* h = s->h;
|
double* h = s->h;
|
||||||
int* seg = s->seg;
|
int* seg = s->seg;
|
||||||
|
|
||||||
for (int k = 1; k < kmax + 1; k++) {
|
for (int k = 1; k < kmax + 1; k++) {
|
||||||
for (int j = 1; j < jmax + 1; j++) {
|
for (int j = 1; j < jmax + 1; j++) {
|
||||||
for (int i = 1; i < imax + 1; i++) {
|
for (int i = 1; i < imax + 1; i++) {
|
||||||
if(S(i,j,k) == NONE)
|
if (S(i, j, k) == NONE) {
|
||||||
{
|
RHS(i, j, k) = ((F(i, j, k) - F(i - 1, j, k)) * idx +
|
||||||
RHS(i, j, k) = ((F(i, j, k) - F(i - 1, j, k)) * idx +
|
(G(i, j, k) - G(i, j - 1, k)) * idy +
|
||||||
(G(i, j, k) - G(i, j - 1, k)) * idy +
|
(H(i, j, k) - H(i, j, k - 1)) * idz) *
|
||||||
(H(i, j, k) - H(i, j, k - 1)) * idz) *
|
idt;
|
||||||
idt;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -475,7 +474,7 @@ void solve(Solver* s)
|
|||||||
double epssq = eps * eps;
|
double epssq = eps * eps;
|
||||||
int it = 0;
|
int it = 0;
|
||||||
double res = 1.0;
|
double res = 1.0;
|
||||||
int* seg = s->seg;
|
int* seg = s->seg;
|
||||||
|
|
||||||
while ((res >= epssq) && (it < itermax)) {
|
while ((res >= epssq) && (it < itermax)) {
|
||||||
res = 0.0;
|
res = 0.0;
|
||||||
@ -483,19 +482,18 @@ void solve(Solver* s)
|
|||||||
for (int k = 1; k < kmax + 1; k++) {
|
for (int k = 1; k < kmax + 1; k++) {
|
||||||
for (int j = 1; j < jmax + 1; j++) {
|
for (int j = 1; j < jmax + 1; j++) {
|
||||||
for (int i = 1; i < imax + 1; i++) {
|
for (int i = 1; i < imax + 1; i++) {
|
||||||
if(S(i,j,k) == NONE)
|
if (S(i, j, k) == NONE) {
|
||||||
{
|
double r =
|
||||||
double r = RHS(i, j, k) -
|
RHS(i, j, k) -
|
||||||
((P(i + 1, j, k) - 2.0 * P(i, j, k) + P(i - 1, j, k)) *
|
((P(i + 1, j, k) - 2.0 * P(i, j, k) + P(i - 1, j, k)) * idx2 +
|
||||||
idx2 +
|
(P(i, j + 1, k) - 2.0 * P(i, j, k) + P(i, j - 1, k)) *
|
||||||
(P(i, j + 1, k) - 2.0 * P(i, j, k) + P(i, j - 1, k)) *
|
idy2 +
|
||||||
idy2 +
|
(P(i, j, k + 1) - 2.0 * P(i, j, k) + P(i, j, k - 1)) *
|
||||||
(P(i, j, k + 1) - 2.0 * P(i, j, k) + P(i, j, k - 1)) *
|
idz2);
|
||||||
idz2);
|
|
||||||
|
|
||||||
P(i, j, k) -= (factor * r);
|
P(i, j, k) -= (factor * r);
|
||||||
res += (r * r);
|
res += (r * r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -561,7 +559,7 @@ void solveRB(Solver* s)
|
|||||||
res = 0.0;
|
res = 0.0;
|
||||||
ksw = 1;
|
ksw = 1;
|
||||||
|
|
||||||
for (int j = 1; j < jmax + 1; j++) {
|
for (int j = 1; j < jmax + 1; j++) {
|
||||||
for (int i = 1; i < imax + 1; i++) {
|
for (int i = 1; i < imax + 1; i++) {
|
||||||
P(i, j, 0) = P(i, j, 1);
|
P(i, j, 0) = P(i, j, 1);
|
||||||
P(i, j, kmax + 1) = P(i, j, kmax);
|
P(i, j, kmax + 1) = P(i, j, kmax);
|
||||||
@ -591,19 +589,19 @@ void solveRB(Solver* s)
|
|||||||
isw = jsw;
|
isw = jsw;
|
||||||
for (int j = 1; j < jmax + 1; j++) {
|
for (int j = 1; j < jmax + 1; j++) {
|
||||||
for (int i = isw; i < imax + 1; i += 2) {
|
for (int i = isw; i < imax + 1; i += 2) {
|
||||||
if(S(i,j,k) == NONE)
|
if (S(i, j, k) == NONE) {
|
||||||
{
|
double r =
|
||||||
double r =
|
RHS(i, j, k) -
|
||||||
RHS(i, j, k) -
|
((P(i + 1, j, k) - 2.0 * P(i, j, k) + P(i - 1, j, k)) *
|
||||||
((P(i + 1, j, k) - 2.0 * P(i, j, k) + P(i - 1, j, k)) * idx2 +
|
idx2 +
|
||||||
(P(i, j + 1, k) - 2.0 * P(i, j, k) + P(i, j - 1, k)) *
|
(P(i, j + 1, k) - 2.0 * P(i, j, k) + P(i, j - 1, k)) *
|
||||||
idy2 +
|
idy2 +
|
||||||
(P(i, j, k + 1) - 2.0 * P(i, j, k) + P(i, j, k - 1)) *
|
(P(i, j, k + 1) - 2.0 * P(i, j, k) + P(i, j, k - 1)) *
|
||||||
idz2);
|
idz2);
|
||||||
|
|
||||||
P(i, j, k) -= (factor * r);
|
P(i, j, k) -= (factor * r);
|
||||||
res += (r * r);
|
res += (r * r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
isw = 3 - isw;
|
isw = 3 - isw;
|
||||||
}
|
}
|
||||||
@ -612,7 +610,6 @@ void solveRB(Solver* s)
|
|||||||
ksw = 3 - ksw;
|
ksw = 3 - ksw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
res = res / (double)(imax * jmax * kmax);
|
res = res / (double)(imax * jmax * kmax);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printf("%d Residuum: %e\n", it, res);
|
printf("%d Residuum: %e\n", it, res);
|
||||||
@ -649,7 +646,6 @@ void solveRBA(Solver* s)
|
|||||||
int pass, ksw, jsw, isw;
|
int pass, ksw, jsw, isw;
|
||||||
int* seg = s->seg;
|
int* seg = s->seg;
|
||||||
|
|
||||||
|
|
||||||
while ((res >= epssq) && (it < itermax)) {
|
while ((res >= epssq) && (it < itermax)) {
|
||||||
res = 0.0;
|
res = 0.0;
|
||||||
ksw = 1;
|
ksw = 1;
|
||||||
@ -661,19 +657,19 @@ void solveRBA(Solver* s)
|
|||||||
isw = jsw;
|
isw = jsw;
|
||||||
for (int j = 1; j < jmax + 1; j++) {
|
for (int j = 1; j < jmax + 1; j++) {
|
||||||
for (int i = isw; i < imax + 1; i += 2) {
|
for (int i = isw; i < imax + 1; i += 2) {
|
||||||
if(S(i,j,k) == NONE)
|
if (S(i, j, k) == NONE) {
|
||||||
{
|
double r =
|
||||||
double r =
|
RHS(i, j, k) -
|
||||||
RHS(i, j, k) -
|
((P(i + 1, j, k) - 2.0 * P(i, j, k) + P(i - 1, j, k)) *
|
||||||
((P(i + 1, j, k) - 2.0 * P(i, j, k) + P(i - 1, j, k)) * idx2 +
|
idx2 +
|
||||||
(P(i, j + 1, k) - 2.0 * P(i, j, k) + P(i, j - 1, k)) *
|
(P(i, j + 1, k) - 2.0 * P(i, j, k) + P(i, j - 1, k)) *
|
||||||
idy2 +
|
idy2 +
|
||||||
(P(i, j, k + 1) - 2.0 * P(i, j, k) + P(i, j, k - 1)) *
|
(P(i, j, k + 1) - 2.0 * P(i, j, k) + P(i, j, k - 1)) *
|
||||||
idz2);
|
idz2);
|
||||||
|
|
||||||
P(i, j, k) -= (omega * factor * r);
|
P(i, j, k) -= (omega * factor * r);
|
||||||
res += (r * r);
|
res += (r * r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
isw = 3 - isw;
|
isw = 3 - isw;
|
||||||
}
|
}
|
||||||
@ -1005,10 +1001,10 @@ void setSpecialBoundaryCondition(Solver* s)
|
|||||||
}
|
}
|
||||||
} else if (strcmp(s->problem, "backstep") == 0) {
|
} else if (strcmp(s->problem, "backstep") == 0) {
|
||||||
|
|
||||||
int* seg = s->seg;
|
int* seg = s->seg;
|
||||||
for (int k = 1; k < kmax + 1; k++) {
|
for (int k = 1; k < kmax + 1; k++) {
|
||||||
for (int j = 1; j < jmax + 1; j++) {
|
for (int j = 1; j < jmax + 1; j++) {
|
||||||
if(S(0,j,k) == NONE) U(0, j, k) = 1.0;
|
if (S(0, j, k) == NONE) U(0, j, k) = 1.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1028,7 +1024,6 @@ void computeFG(Solver* s)
|
|||||||
double* h = s->h;
|
double* h = s->h;
|
||||||
int* seg = s->seg;
|
int* seg = s->seg;
|
||||||
|
|
||||||
|
|
||||||
double gx = s->gx;
|
double gx = s->gx;
|
||||||
double gy = s->gy;
|
double gy = s->gy;
|
||||||
double gz = s->gz;
|
double gz = s->gz;
|
||||||
@ -1049,243 +1044,244 @@ void computeFG(Solver* s)
|
|||||||
for (int j = 1; j < jmax + 1; j++) {
|
for (int j = 1; j < jmax + 1; j++) {
|
||||||
for (int i = 1; i < imax + 1; i++) {
|
for (int i = 1; i < imax + 1; i++) {
|
||||||
|
|
||||||
if(S(i,j,k) == NONE)
|
if (S(i, j, k) == NONE) {
|
||||||
{
|
du2dx = inverseDx * 0.25 *
|
||||||
du2dx = inverseDx * 0.25 *
|
((U(i, j, k) + U(i + 1, j, k)) *
|
||||||
((U(i, j, k) + U(i + 1, j, k)) *
|
(U(i, j, k) + U(i + 1, j, k)) -
|
||||||
(U(i, j, k) + U(i + 1, j, k)) -
|
(U(i, j, k) + U(i - 1, j, k)) *
|
||||||
(U(i, j, k) + U(i - 1, j, k)) *
|
(U(i, j, k) + U(i - 1, j, k))) +
|
||||||
(U(i, j, k) + U(i - 1, j, k))) +
|
gamma * inverseDx * 0.25 *
|
||||||
gamma * inverseDx * 0.25 *
|
(fabs(U(i, j, k) + U(i + 1, j, k)) *
|
||||||
(fabs(U(i, j, k) + U(i + 1, j, k)) *
|
(U(i, j, k) - U(i + 1, j, k)) +
|
||||||
(U(i, j, k) - U(i + 1, j, k)) +
|
fabs(U(i, j, k) + U(i - 1, j, k)) *
|
||||||
fabs(U(i, j, k) + U(i - 1, j, k)) *
|
(U(i, j, k) - U(i - 1, j, k)));
|
||||||
(U(i, j, k) - U(i - 1, j, k)));
|
|
||||||
|
|
||||||
duvdy = inverseDy * 0.25 *
|
duvdy = inverseDy * 0.25 *
|
||||||
((V(i, j, k) + V(i + 1, j, k)) *
|
((V(i, j, k) + V(i + 1, j, k)) *
|
||||||
(U(i, j, k) + U(i, j + 1, k)) -
|
(U(i, j, k) + U(i, j + 1, k)) -
|
||||||
(V(i, j - 1, k) + V(i + 1, j - 1, k)) *
|
(V(i, j - 1, k) + V(i + 1, j - 1, k)) *
|
||||||
(U(i, j, k) + U(i, j - 1, k))) +
|
(U(i, j, k) + U(i, j - 1, k))) +
|
||||||
gamma * inverseDy * 0.25 *
|
gamma * inverseDy * 0.25 *
|
||||||
(fabs(V(i, j, k) + V(i + 1, j, k)) *
|
(fabs(V(i, j, k) + V(i + 1, j, k)) *
|
||||||
(U(i, j, k) - U(i, j + 1, k)) +
|
(U(i, j, k) - U(i, j + 1, k)) +
|
||||||
fabs(V(i, j - 1, k) + V(i + 1, j - 1, k)) *
|
fabs(V(i, j - 1, k) + V(i + 1, j - 1, k)) *
|
||||||
(U(i, j, k) - U(i, j - 1, k)));
|
(U(i, j, k) - U(i, j - 1, k)));
|
||||||
|
|
||||||
duwdz = inverseDz * 0.25 *
|
duwdz = inverseDz * 0.25 *
|
||||||
((W(i, j, k) + W(i + 1, j, k)) *
|
((W(i, j, k) + W(i + 1, j, k)) *
|
||||||
(U(i, j, k) + U(i, j, k + 1)) -
|
(U(i, j, k) + U(i, j, k + 1)) -
|
||||||
(W(i, j, k - 1) + W(i + 1, j, k - 1)) *
|
(W(i, j, k - 1) + W(i + 1, j, k - 1)) *
|
||||||
(U(i, j, k) + U(i, j, k - 1))) +
|
(U(i, j, k) + U(i, j, k - 1))) +
|
||||||
gamma * inverseDz * 0.25 *
|
gamma * inverseDz * 0.25 *
|
||||||
(fabs(W(i, j, k) + W(i + 1, j, k)) *
|
(fabs(W(i, j, k) + W(i + 1, j, k)) *
|
||||||
(U(i, j, k) - U(i, j, k + 1)) +
|
(U(i, j, k) - U(i, j, k + 1)) +
|
||||||
fabs(W(i, j, k - 1) + W(i + 1, j, k - 1)) *
|
fabs(W(i, j, k - 1) + W(i + 1, j, k - 1)) *
|
||||||
(U(i, j, k) - U(i, j, k - 1)));
|
(U(i, j, k) - U(i, j, k - 1)));
|
||||||
|
|
||||||
du2dx2 = inverseDx * inverseDx *
|
du2dx2 = inverseDx * inverseDx *
|
||||||
(U(i + 1, j, k) - 2.0 * U(i, j, k) + U(i - 1, j, k));
|
(U(i + 1, j, k) - 2.0 * U(i, j, k) + U(i - 1, j, k));
|
||||||
du2dy2 = inverseDy * inverseDy *
|
du2dy2 = inverseDy * inverseDy *
|
||||||
(U(i, j + 1, k) - 2.0 * U(i, j, k) + U(i, j - 1, k));
|
(U(i, j + 1, k) - 2.0 * U(i, j, k) + U(i, j - 1, k));
|
||||||
du2dz2 = inverseDz * inverseDz *
|
du2dz2 = inverseDz * inverseDz *
|
||||||
(U(i, j, k + 1) - 2.0 * U(i, j, k) + U(i, j, k - 1));
|
(U(i, j, k + 1) - 2.0 * U(i, j, k) + U(i, j, k - 1));
|
||||||
F(i, j, k) = U(i, j, k) + dt * (inverseRe * (du2dx2 + du2dy2 + du2dz2) -
|
F(i, j, k) = U(i, j, k) +
|
||||||
du2dx - duvdy - duwdz + gx);
|
dt * (inverseRe * (du2dx2 + du2dy2 + du2dz2) - du2dx -
|
||||||
|
duvdy - duwdz + gx);
|
||||||
|
|
||||||
duvdx = inverseDx * 0.25 *
|
duvdx = inverseDx * 0.25 *
|
||||||
((U(i, j, k) + U(i, j + 1, k)) *
|
((U(i, j, k) + U(i, j + 1, k)) *
|
||||||
(V(i, j, k) + V(i + 1, j, k)) -
|
(V(i, j, k) + V(i + 1, j, k)) -
|
||||||
(U(i - 1, j, k) + U(i - 1, j + 1, k)) *
|
(U(i - 1, j, k) + U(i - 1, j + 1, k)) *
|
||||||
(V(i, j, k) + V(i - 1, j, k))) +
|
(V(i, j, k) + V(i - 1, j, k))) +
|
||||||
gamma * inverseDx * 0.25 *
|
gamma * inverseDx * 0.25 *
|
||||||
(fabs(U(i, j, k) + U(i, j + 1, k)) *
|
(fabs(U(i, j, k) + U(i, j + 1, k)) *
|
||||||
(V(i, j, k) - V(i + 1, j, k)) +
|
(V(i, j, k) - V(i + 1, j, k)) +
|
||||||
fabs(U(i - 1, j, k) + U(i - 1, j + 1, k)) *
|
fabs(U(i - 1, j, k) + U(i - 1, j + 1, k)) *
|
||||||
(V(i, j, k) - V(i - 1, j, k)));
|
(V(i, j, k) - V(i - 1, j, k)));
|
||||||
|
|
||||||
dv2dy = inverseDy * 0.25 *
|
dv2dy = inverseDy * 0.25 *
|
||||||
((V(i, j, k) + V(i, j + 1, k)) *
|
((V(i, j, k) + V(i, j + 1, k)) *
|
||||||
(V(i, j, k) + V(i, j + 1, k)) -
|
(V(i, j, k) + V(i, j + 1, k)) -
|
||||||
(V(i, j, k) + V(i, j - 1, k)) *
|
(V(i, j, k) + V(i, j - 1, k)) *
|
||||||
(V(i, j, k) + V(i, j - 1, k))) +
|
(V(i, j, k) + V(i, j - 1, k))) +
|
||||||
gamma * inverseDy * 0.25 *
|
gamma * inverseDy * 0.25 *
|
||||||
(fabs(V(i, j, k) + V(i, j + 1, k)) *
|
(fabs(V(i, j, k) + V(i, j + 1, k)) *
|
||||||
(V(i, j, k) - V(i, j + 1, k)) +
|
(V(i, j, k) - V(i, j + 1, k)) +
|
||||||
fabs(V(i, j, k) + V(i, j - 1, k)) *
|
fabs(V(i, j, k) + V(i, j - 1, k)) *
|
||||||
(V(i, j, k) - V(i, j - 1, k)));
|
(V(i, j, k) - V(i, j - 1, k)));
|
||||||
|
|
||||||
dvwdz = inverseDz * 0.25 *
|
dvwdz = inverseDz * 0.25 *
|
||||||
((W(i, j, k) + W(i, j + 1, k)) *
|
((W(i, j, k) + W(i, j + 1, k)) *
|
||||||
(V(i, j, k) + V(i, j, k + 1)) -
|
(V(i, j, k) + V(i, j, k + 1)) -
|
||||||
(W(i, j, k - 1) + W(i, j + 1, k - 1)) *
|
(W(i, j, k - 1) + W(i, j + 1, k - 1)) *
|
||||||
(V(i, j, k) + V(i, j, k + 1))) +
|
(V(i, j, k) + V(i, j, k + 1))) +
|
||||||
gamma * inverseDz * 0.25 *
|
gamma * inverseDz * 0.25 *
|
||||||
(fabs(W(i, j, k) + W(i, j + 1, k)) *
|
(fabs(W(i, j, k) + W(i, j + 1, k)) *
|
||||||
(V(i, j, k) - V(i, j, k + 1)) +
|
(V(i, j, k) - V(i, j, k + 1)) +
|
||||||
fabs(W(i, j, k - 1) + W(i, j + 1, k - 1)) *
|
fabs(W(i, j, k - 1) + W(i, j + 1, k - 1)) *
|
||||||
(V(i, j, k) - V(i, j, k + 1)));
|
(V(i, j, k) - V(i, j, k + 1)));
|
||||||
|
|
||||||
dv2dx2 = inverseDx * inverseDx *
|
dv2dx2 = inverseDx * inverseDx *
|
||||||
(V(i + 1, j, k) - 2.0 * V(i, j, k) + V(i - 1, j, k));
|
(V(i + 1, j, k) - 2.0 * V(i, j, k) + V(i - 1, j, k));
|
||||||
dv2dy2 = inverseDy * inverseDy *
|
dv2dy2 = inverseDy * inverseDy *
|
||||||
(V(i, j + 1, k) - 2.0 * V(i, j, k) + V(i, j - 1, k));
|
(V(i, j + 1, k) - 2.0 * V(i, j, k) + V(i, j - 1, k));
|
||||||
dv2dz2 = inverseDz * inverseDz *
|
dv2dz2 = inverseDz * inverseDz *
|
||||||
(V(i, j, k + 1) - 2.0 * V(i, j, k) + V(i, j, k - 1));
|
(V(i, j, k + 1) - 2.0 * V(i, j, k) + V(i, j, k - 1));
|
||||||
G(i, j, k) = V(i, j, k) + dt * (inverseRe * (dv2dx2 + dv2dy2 + dv2dz2) -
|
G(i, j, k) = V(i, j, k) +
|
||||||
duvdx - dv2dy - dvwdz + gy);
|
dt * (inverseRe * (dv2dx2 + dv2dy2 + dv2dz2) - duvdx -
|
||||||
|
dv2dy - dvwdz + gy);
|
||||||
|
|
||||||
duwdx = inverseDx * 0.25 *
|
duwdx = inverseDx * 0.25 *
|
||||||
((U(i, j, k) + U(i, j, k + 1)) *
|
((U(i, j, k) + U(i, j, k + 1)) *
|
||||||
(W(i, j, k) + W(i + 1, j, k)) -
|
(W(i, j, k) + W(i + 1, j, k)) -
|
||||||
(U(i - 1, j, k) + U(i - 1, j, k + 1)) *
|
(U(i - 1, j, k) + U(i - 1, j, k + 1)) *
|
||||||
(W(i, j, k) + W(i - 1, j, k))) +
|
(W(i, j, k) + W(i - 1, j, k))) +
|
||||||
gamma * inverseDx * 0.25 *
|
gamma * inverseDx * 0.25 *
|
||||||
(fabs(U(i, j, k) + U(i, j, k + 1)) *
|
(fabs(U(i, j, k) + U(i, j, k + 1)) *
|
||||||
(W(i, j, k) - W(i + 1, j, k)) +
|
(W(i, j, k) - W(i + 1, j, k)) +
|
||||||
fabs(U(i - 1, j, k) + U(i - 1, j, k + 1)) *
|
fabs(U(i - 1, j, k) + U(i - 1, j, k + 1)) *
|
||||||
(W(i, j, k) - W(i - 1, j, k)));
|
(W(i, j, k) - W(i - 1, j, k)));
|
||||||
|
|
||||||
dvwdy = inverseDy * 0.25 *
|
dvwdy = inverseDy * 0.25 *
|
||||||
((V(i, j, k) + V(i, j, k + 1)) *
|
((V(i, j, k) + V(i, j, k + 1)) *
|
||||||
(W(i, j, k) + W(i, j + 1, k)) -
|
(W(i, j, k) + W(i, j + 1, k)) -
|
||||||
(V(i, j - 1, k + 1) + V(i, j - 1, k)) *
|
(V(i, j - 1, k + 1) + V(i, j - 1, k)) *
|
||||||
(W(i, j, k) + W(i, j - 1, k))) +
|
(W(i, j, k) + W(i, j - 1, k))) +
|
||||||
gamma * inverseDy * 0.25 *
|
gamma * inverseDy * 0.25 *
|
||||||
(fabs(V(i, j, k) + V(i, j, k + 1)) *
|
(fabs(V(i, j, k) + V(i, j, k + 1)) *
|
||||||
(W(i, j, k) - W(i, j + 1, k)) +
|
(W(i, j, k) - W(i, j + 1, k)) +
|
||||||
fabs(V(i, j - 1, k + 1) + V(i, j - 1, k)) *
|
fabs(V(i, j - 1, k + 1) + V(i, j - 1, k)) *
|
||||||
(W(i, j, k) - W(i, j - 1, k)));
|
(W(i, j, k) - W(i, j - 1, k)));
|
||||||
|
|
||||||
dw2dz = inverseDz * 0.25 *
|
dw2dz = inverseDz * 0.25 *
|
||||||
((W(i, j, k) + W(i, j, k + 1)) *
|
((W(i, j, k) + W(i, j, k + 1)) *
|
||||||
(W(i, j, k) + W(i, j, k + 1)) -
|
(W(i, j, k) + W(i, j, k + 1)) -
|
||||||
(W(i, j, k) + W(i, j, k - 1)) *
|
(W(i, j, k) + W(i, j, k - 1)) *
|
||||||
(W(i, j, k) + W(i, j, k - 1))) +
|
(W(i, j, k) + W(i, j, k - 1))) +
|
||||||
gamma * inverseDz * 0.25 *
|
gamma * inverseDz * 0.25 *
|
||||||
(fabs(W(i, j, k) + W(i, j, k + 1)) *
|
(fabs(W(i, j, k) + W(i, j, k + 1)) *
|
||||||
(W(i, j, k) - W(i, j, k + 1)) +
|
(W(i, j, k) - W(i, j, k + 1)) +
|
||||||
fabs(W(i, j, k) + W(i, j, k - 1)) *
|
fabs(W(i, j, k) + W(i, j, k - 1)) *
|
||||||
(W(i, j, k) - W(i, j, k - 1)));
|
(W(i, j, k) - W(i, j, k - 1)));
|
||||||
|
|
||||||
dw2dx2 = inverseDx * inverseDx *
|
dw2dx2 = inverseDx * inverseDx *
|
||||||
(W(i + 1, j, k) - 2.0 * W(i, j, k) + W(i - 1, j, k));
|
(W(i + 1, j, k) - 2.0 * W(i, j, k) + W(i - 1, j, k));
|
||||||
dw2dy2 = inverseDy * inverseDy *
|
dw2dy2 = inverseDy * inverseDy *
|
||||||
(W(i, j + 1, k) - 2.0 * W(i, j, k) + W(i, j - 1, k));
|
(W(i, j + 1, k) - 2.0 * W(i, j, k) + W(i, j - 1, k));
|
||||||
dw2dz2 = inverseDz * inverseDz *
|
dw2dz2 = inverseDz * inverseDz *
|
||||||
(W(i, j, k + 1) - 2.0 * W(i, j, k) + W(i, j, k - 1));
|
(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) -
|
H(i, j, k) = W(i, j, k) +
|
||||||
duwdx - dvwdy - dw2dz + gz);
|
dt * (inverseRe * (dw2dx2 + dw2dy2 + dw2dz2) - duwdx -
|
||||||
}
|
dvwdy - dw2dz + gz);
|
||||||
else{
|
} else {
|
||||||
switch (S(i, j, k)) {
|
switch (S(i, j, k)) {
|
||||||
case TOPFACE:
|
case TOPFACE:
|
||||||
G(i, j, k) = V(i, j, k);
|
G(i, j, k) = V(i, j, k);
|
||||||
break;
|
break;
|
||||||
case BOTTOMFACE:
|
case BOTTOMFACE:
|
||||||
G(i, j, k) = V(i, j, k);
|
G(i, j, k) = V(i, j, k);
|
||||||
break;
|
break;
|
||||||
case LEFTFACE:
|
case LEFTFACE:
|
||||||
F(i, j, k) = U(i, j, k);
|
F(i, j, k) = U(i, j, k);
|
||||||
break;
|
break;
|
||||||
case RIGHTFACE:
|
case RIGHTFACE:
|
||||||
F(i, j, k) = U(i, j, k);
|
F(i, j, k) = U(i, j, k);
|
||||||
break;
|
break;
|
||||||
case FRONTFACE:
|
case FRONTFACE:
|
||||||
H(i, j, k) = W(i, j, k);
|
H(i, j, k) = W(i, j, k);
|
||||||
break;
|
break;
|
||||||
case BACKFACE:
|
case BACKFACE:
|
||||||
H(i, j, k) = W(i, j, k);
|
H(i, j, k) = W(i, j, k);
|
||||||
break;
|
break;
|
||||||
case FRONTLEFTLINE:
|
case FRONTLEFTLINE:
|
||||||
F(i, j, k) = 0.0;
|
F(i, j, k) = 0.0;
|
||||||
H(i, j, k) = 0.0;
|
H(i, j, k) = 0.0;
|
||||||
break;
|
break;
|
||||||
case FRONTRIGHTLINE:
|
case FRONTRIGHTLINE:
|
||||||
F(i, j, k) = 0.0;
|
F(i, j, k) = 0.0;
|
||||||
H(i, j, k) = 0.0;
|
H(i, j, k) = 0.0;
|
||||||
break;
|
break;
|
||||||
case FRONTTOPLINE:
|
case FRONTTOPLINE:
|
||||||
G(i, j, k) = 0.0;
|
G(i, j, k) = 0.0;
|
||||||
H(i, j, k) = 0.0;
|
H(i, j, k) = 0.0;
|
||||||
break;
|
break;
|
||||||
case FRONTBOTTOMLINE:
|
case FRONTBOTTOMLINE:
|
||||||
G(i, j, k) = 0.0;
|
G(i, j, k) = 0.0;
|
||||||
H(i, j, k) = 0.0;
|
H(i, j, k) = 0.0;
|
||||||
break;
|
break;
|
||||||
case MIDTOPLEFTLINE:
|
case MIDTOPLEFTLINE:
|
||||||
F(i, j, k) = 0.0;
|
F(i, j, k) = 0.0;
|
||||||
G(i, j, k) = 0.0;
|
G(i, j, k) = 0.0;
|
||||||
break;
|
break;
|
||||||
case MIDTOPRIGHTLINE:
|
case MIDTOPRIGHTLINE:
|
||||||
F(i, j, k) = U(i, j, k);
|
F(i, j, k) = U(i, j, k);
|
||||||
G(i, j, k) = V(i, j, k);
|
G(i, j, k) = V(i, j, k);
|
||||||
break;
|
break;
|
||||||
case MIDBOTTOMLEFTLINE:
|
case MIDBOTTOMLEFTLINE:
|
||||||
F(i, j, k) = 0.0;
|
F(i, j, k) = 0.0;
|
||||||
G(i, j, k) = 0.0;
|
G(i, j, k) = 0.0;
|
||||||
break;
|
break;
|
||||||
case MIDBOTTOMRIGHTLINE:
|
case MIDBOTTOMRIGHTLINE:
|
||||||
F(i, j, k) = 0.0;
|
F(i, j, k) = 0.0;
|
||||||
G(i, j, k) = 0.0;
|
G(i, j, k) = 0.0;
|
||||||
break;
|
break;
|
||||||
case BACKLEFTLINE:
|
case BACKLEFTLINE:
|
||||||
F(i, j, k) = 0.0;
|
F(i, j, k) = 0.0;
|
||||||
H(i, j, k) = 0.0;
|
H(i, j, k) = 0.0;
|
||||||
break;
|
break;
|
||||||
case BACKRIGHTLINE:
|
case BACKRIGHTLINE:
|
||||||
F(i, j, k) = 0.0;
|
F(i, j, k) = 0.0;
|
||||||
H(i, j, k) = 0.0;
|
H(i, j, k) = 0.0;
|
||||||
break;
|
break;
|
||||||
case BACKTOPLINE:
|
case BACKTOPLINE:
|
||||||
G(i, j, k) = 0.0;
|
G(i, j, k) = 0.0;
|
||||||
H(i, j, k) = 0.0;
|
H(i, j, k) = 0.0;
|
||||||
break;
|
break;
|
||||||
case BACKBOTTOMLINE:
|
case BACKBOTTOMLINE:
|
||||||
G(i, j, k) = 0.0;
|
G(i, j, k) = 0.0;
|
||||||
H(i, j, k) = 0.0;
|
H(i, j, k) = 0.0;
|
||||||
break;
|
break;
|
||||||
case FRONTTOPLEFTCORNER:
|
case FRONTTOPLEFTCORNER:
|
||||||
F(i, j, k) = 0.0;
|
F(i, j, k) = 0.0;
|
||||||
G(i, j, k) = 0.0;
|
G(i, j, k) = 0.0;
|
||||||
H(i, j, k) = 0.0;
|
H(i, j, k) = 0.0;
|
||||||
break;
|
break;
|
||||||
case FRONTTOPRIGHTCORNER:
|
case FRONTTOPRIGHTCORNER:
|
||||||
F(i, j, k) = 0.0;
|
F(i, j, k) = 0.0;
|
||||||
G(i, j, k) = 0.0;
|
G(i, j, k) = 0.0;
|
||||||
H(i, j, k) = 0.0;
|
H(i, j, k) = 0.0;
|
||||||
break;
|
break;
|
||||||
case FRONTBOTTOMLEFTCORNER:
|
case FRONTBOTTOMLEFTCORNER:
|
||||||
F(i, j, k) = 0.0;
|
F(i, j, k) = 0.0;
|
||||||
G(i, j, k) = 0.0;
|
G(i, j, k) = 0.0;
|
||||||
H(i, j, k) = 0.0;
|
H(i, j, k) = 0.0;
|
||||||
break;
|
break;
|
||||||
case FRONTBOTTOMRIGHTCORNER:
|
case FRONTBOTTOMRIGHTCORNER:
|
||||||
F(i, j, k) = 0.0;
|
F(i, j, k) = 0.0;
|
||||||
G(i, j, k) = 0.0;
|
G(i, j, k) = 0.0;
|
||||||
H(i, j, k) = 0.0;
|
H(i, j, k) = 0.0;
|
||||||
break;
|
break;
|
||||||
case BACKTOPLEFTCORNER:
|
case BACKTOPLEFTCORNER:
|
||||||
F(i, j, k) = 0.0;
|
F(i, j, k) = 0.0;
|
||||||
G(i, j, k) = 0.0;
|
G(i, j, k) = 0.0;
|
||||||
H(i, j, k) = 0.0;
|
H(i, j, k) = 0.0;
|
||||||
break;
|
break;
|
||||||
case BACKTOPRIGHTCORNER:
|
case BACKTOPRIGHTCORNER:
|
||||||
F(i, j, k) = 0.0;
|
F(i, j, k) = 0.0;
|
||||||
G(i, j, k) = 0.0;
|
G(i, j, k) = 0.0;
|
||||||
H(i, j, k) = 0.0;
|
H(i, j, k) = 0.0;
|
||||||
break;
|
break;
|
||||||
case BACKBOTTOMLEFTCORNER:
|
case BACKBOTTOMLEFTCORNER:
|
||||||
F(i, j, k) = 0.0;
|
F(i, j, k) = 0.0;
|
||||||
G(i, j, k) = 0.0;
|
G(i, j, k) = 0.0;
|
||||||
H(i, j, k) = 0.0;
|
H(i, j, k) = 0.0;
|
||||||
break;
|
break;
|
||||||
case BACKBOTTOMRIGHTCORNER:
|
case BACKBOTTOMRIGHTCORNER:
|
||||||
F(i, j, k) = 0.0;
|
F(i, j, k) = 0.0;
|
||||||
G(i, j, k) = 0.0;
|
G(i, j, k) = 0.0;
|
||||||
H(i, j, k) = 0.0;
|
H(i, j, k) = 0.0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1362,136 +1358,137 @@ void setObjectBoundaryCondition(Solver* s)
|
|||||||
for (int i = 1; i < imax + 1; i++) {
|
for (int i = 1; i < imax + 1; i++) {
|
||||||
switch (S(i, j, k)) {
|
switch (S(i, j, k)) {
|
||||||
case TOPFACE:
|
case TOPFACE:
|
||||||
U(i, j, k) = -U(i, j+1, k);
|
U(i, j, k) = -U(i, j + 1, k);
|
||||||
V(i, j, k) = 0.0;
|
V(i, j, k) = 0.0;
|
||||||
W(i, j, k) = -W(i, j+1, k);;
|
W(i, j, k) = -W(i, j + 1, k);
|
||||||
|
;
|
||||||
break;
|
break;
|
||||||
case BOTTOMFACE:
|
case BOTTOMFACE:
|
||||||
U(i, j, k) = -U(i, j-1, k);
|
U(i, j, k) = -U(i, j - 1, k);
|
||||||
V(i, j, k) = 0.0;
|
V(i, j, k) = 0.0;
|
||||||
W(i, j, k) = -W(i, j-1, k);
|
W(i, j, k) = -W(i, j - 1, k);
|
||||||
break;
|
break;
|
||||||
case LEFTFACE:
|
case LEFTFACE:
|
||||||
U(i, j, k) = 0.0;
|
U(i, j, k) = 0.0;
|
||||||
V(i, j, k) = -V(i-1, j, k);
|
V(i, j, k) = -V(i - 1, j, k);
|
||||||
W(i, j, k) = -W(i-1, j, k);
|
W(i, j, k) = -W(i - 1, j, k);
|
||||||
break;
|
break;
|
||||||
case RIGHTFACE:
|
case RIGHTFACE:
|
||||||
U(i, j, k) = 0.0;
|
U(i, j, k) = 0.0;
|
||||||
V(i, j, k) = -V(i+1, j, k);
|
V(i, j, k) = -V(i + 1, j, k);
|
||||||
W(i, j, k) = -W(i+1, j, k);
|
W(i, j, k) = -W(i + 1, j, k);
|
||||||
break;
|
break;
|
||||||
case FRONTFACE:
|
case FRONTFACE:
|
||||||
U(i, j, k) = -U(i, j, k-1);
|
U(i, j, k) = -U(i, j, k - 1);
|
||||||
V(i, j, k) = -V(i, j, k-1);
|
V(i, j, k) = -V(i, j, k - 1);
|
||||||
W(i, j, k) = 0.0;
|
W(i, j, k) = 0.0;
|
||||||
break;
|
break;
|
||||||
case BACKFACE:
|
case BACKFACE:
|
||||||
U(i, j, k) = -U(i, j, k+1);
|
U(i, j, k) = -U(i, j, k + 1);
|
||||||
V(i, j, k) = -V(i, j, k+1);
|
V(i, j, k) = -V(i, j, k + 1);
|
||||||
W(i, j, k) = 0.0;
|
W(i, j, k) = 0.0;
|
||||||
break;
|
break;
|
||||||
case FRONTLEFTLINE:
|
case FRONTLEFTLINE:
|
||||||
U(i, j, k) = 0.0;
|
U(i, j, k) = 0.0;
|
||||||
V(i, j, k) = -V(i, j, k-1);
|
V(i, j, k) = -V(i, j, k - 1);
|
||||||
W(i, j, k) = -W(i-1, j, k);
|
W(i, j, k) = -W(i - 1, j, k);
|
||||||
break;
|
break;
|
||||||
case FRONTRIGHTLINE:
|
case FRONTRIGHTLINE:
|
||||||
U(i, j, k) = 0.0;
|
U(i, j, k) = 0.0;
|
||||||
V(i, j, k) = -V(i, j, k-1);
|
V(i, j, k) = -V(i, j, k - 1);
|
||||||
W(i, j, k) = -W(i+1, j, k);
|
W(i, j, k) = -W(i + 1, j, k);
|
||||||
break;
|
break;
|
||||||
case FRONTTOPLINE:
|
case FRONTTOPLINE:
|
||||||
U(i, j, k) = -U(i, j, k-1);
|
U(i, j, k) = -U(i, j, k - 1);
|
||||||
V(i, j, k) = 0.0;
|
V(i, j, k) = 0.0;
|
||||||
W(i, j, k) = -W(i, j+1, k);
|
W(i, j, k) = -W(i, j + 1, k);
|
||||||
break;
|
break;
|
||||||
case FRONTBOTTOMLINE:
|
case FRONTBOTTOMLINE:
|
||||||
U(i, j, k) = -U(i, j, k-1);
|
U(i, j, k) = -U(i, j, k - 1);
|
||||||
V(i, j, k) = 0.0;
|
V(i, j, k) = 0.0;
|
||||||
W(i, j, k) = -W(i, j-1, k);
|
W(i, j, k) = -W(i, j - 1, k);
|
||||||
break;
|
break;
|
||||||
case MIDTOPLEFTLINE:
|
case MIDTOPLEFTLINE:
|
||||||
U(i, j, k) = -U(i, j+1, k);
|
U(i, j, k) = -U(i, j + 1, k);
|
||||||
V(i, j, k) = -V(i-1, j, k);
|
V(i, j, k) = -V(i - 1, j, k);
|
||||||
W(i, j, k) = 0.0;
|
W(i, j, k) = 0.0;
|
||||||
break;
|
break;
|
||||||
case MIDTOPRIGHTLINE:
|
case MIDTOPRIGHTLINE:
|
||||||
U(i, j, k) = 0.0;
|
U(i, j, k) = 0.0;
|
||||||
V(i, j, k) = 0.0;
|
V(i, j, k) = 0.0;
|
||||||
U(i-1, j, k) = -U(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);
|
V(i, j - 1, k) = -V(i + 1, j - 1, k);
|
||||||
W(i, j, k) = 0.0;
|
W(i, j, k) = 0.0;
|
||||||
break;
|
break;
|
||||||
case MIDBOTTOMLEFTLINE:
|
case MIDBOTTOMLEFTLINE:
|
||||||
U(i, j, k) = -U(i, j-1, k);
|
U(i, j, k) = -U(i, j - 1, k);
|
||||||
V(i, j, k) = -V(i-1, j, k);
|
V(i, j, k) = -V(i - 1, j, k);
|
||||||
W(i, j, k) = 0.0;
|
W(i, j, k) = 0.0;
|
||||||
break;
|
break;
|
||||||
case MIDBOTTOMRIGHTLINE:
|
case MIDBOTTOMRIGHTLINE:
|
||||||
U(i, j, k) = -U(i, j-1, k);
|
U(i, j, k) = -U(i, j - 1, k);
|
||||||
V(i, j, k) = -V(i+1, j, k);
|
V(i, j, k) = -V(i + 1, j, k);
|
||||||
W(i, j, k) = 0.0;
|
W(i, j, k) = 0.0;
|
||||||
break;
|
break;
|
||||||
case BACKLEFTLINE:
|
case BACKLEFTLINE:
|
||||||
U(i, j, k) = 0.0;
|
U(i, j, k) = 0.0;
|
||||||
V(i, j, k) = -V(i, j, k+1);
|
V(i, j, k) = -V(i, j, k + 1);
|
||||||
W(i, j, k) = -W(i-1, j, k);
|
W(i, j, k) = -W(i - 1, j, k);
|
||||||
break;
|
break;
|
||||||
case BACKRIGHTLINE:
|
case BACKRIGHTLINE:
|
||||||
U(i, j, k) = 0.0;
|
U(i, j, k) = 0.0;
|
||||||
V(i, j, k) = -V(i, j, k+1);
|
V(i, j, k) = -V(i, j, k + 1);
|
||||||
W(i, j, k) = -W(i+1, j, k);
|
W(i, j, k) = -W(i + 1, j, k);
|
||||||
break;
|
break;
|
||||||
case BACKTOPLINE:
|
case BACKTOPLINE:
|
||||||
U(i, j, k) = -U(i, j, k+1);
|
U(i, j, k) = -U(i, j, k + 1);
|
||||||
V(i, j, k) = 0.0;
|
V(i, j, k) = 0.0;
|
||||||
W(i, j, k) = -W(i, j+1, k);
|
W(i, j, k) = -W(i, j + 1, k);
|
||||||
break;
|
break;
|
||||||
case BACKBOTTOMLINE:
|
case BACKBOTTOMLINE:
|
||||||
U(i, j, k) = -U(i, j, k+1);
|
U(i, j, k) = -U(i, j, k + 1);
|
||||||
V(i, j, k) = 0.0;
|
V(i, j, k) = 0.0;
|
||||||
W(i, j, k) = -W(i, j-1, k);
|
W(i, j, k) = -W(i, j - 1, k);
|
||||||
break;
|
break;
|
||||||
case FRONTTOPLEFTCORNER:
|
case FRONTTOPLEFTCORNER:
|
||||||
U(i, j, k) = -U(i, j, k-1);
|
U(i, j, k) = -U(i, j, k - 1);
|
||||||
V(i, j, k) = -V(i-1, j, k);
|
V(i, j, k) = -V(i - 1, j, k);
|
||||||
W(i, j, k) = -W(i, j+1, k);
|
W(i, j, k) = -W(i, j + 1, k);
|
||||||
break;
|
break;
|
||||||
case FRONTTOPRIGHTCORNER:
|
case FRONTTOPRIGHTCORNER:
|
||||||
U(i, j, k) = -U(i, j, k-1);
|
U(i, j, k) = -U(i, j, k - 1);
|
||||||
V(i, j, k) = -V(i+1, j, k);
|
V(i, j, k) = -V(i + 1, j, k);
|
||||||
W(i, j, k) = -W(i, j+1, k);
|
W(i, j, k) = -W(i, j + 1, k);
|
||||||
break;
|
break;
|
||||||
case FRONTBOTTOMLEFTCORNER:
|
case FRONTBOTTOMLEFTCORNER:
|
||||||
U(i, j, k) = -U(i, j, k-1);
|
U(i, j, k) = -U(i, j, k - 1);
|
||||||
V(i, j, k) = -V(i-1, j, k);
|
V(i, j, k) = -V(i - 1, j, k);
|
||||||
W(i, j, k) = -W(i, j-1, k);
|
W(i, j, k) = -W(i, j - 1, k);
|
||||||
break;
|
break;
|
||||||
case FRONTBOTTOMRIGHTCORNER:
|
case FRONTBOTTOMRIGHTCORNER:
|
||||||
U(i, j, k) = -U(i, j, k-1);
|
U(i, j, k) = -U(i, j, k - 1);
|
||||||
V(i, j, k) = -V(i+1, j, k);
|
V(i, j, k) = -V(i + 1, j, k);
|
||||||
W(i, j, k) = -W(i, j-1, k);
|
W(i, j, k) = -W(i, j - 1, k);
|
||||||
break;
|
break;
|
||||||
case BACKTOPLEFTCORNER:
|
case BACKTOPLEFTCORNER:
|
||||||
U(i, j, k) = -U(i, j, k+1);
|
U(i, j, k) = -U(i, j, k + 1);
|
||||||
V(i, j, k) = -V(i-1, j, k);
|
V(i, j, k) = -V(i - 1, j, k);
|
||||||
W(i, j, k) = -W(i, j+1, k);
|
W(i, j, k) = -W(i, j + 1, k);
|
||||||
break;
|
break;
|
||||||
case BACKTOPRIGHTCORNER:
|
case BACKTOPRIGHTCORNER:
|
||||||
U(i, j, k) = -U(i, j, k+1);
|
U(i, j, k) = -U(i, j, k + 1);
|
||||||
V(i, j, k) = -V(i+1, j, k);
|
V(i, j, k) = -V(i + 1, j, k);
|
||||||
W(i, j, k) = -W(i, j+1, k);
|
W(i, j, k) = -W(i, j + 1, k);
|
||||||
break;
|
break;
|
||||||
case BACKBOTTOMLEFTCORNER:
|
case BACKBOTTOMLEFTCORNER:
|
||||||
U(i, j, k) = -U(i, j, k+1);
|
U(i, j, k) = -U(i, j, k + 1);
|
||||||
V(i, j, k) = -V(i-1, j, k);
|
V(i, j, k) = -V(i - 1, j, k);
|
||||||
W(i, j, k) = -W(i, j-1, k);
|
W(i, j, k) = -W(i, j - 1, k);
|
||||||
break;
|
break;
|
||||||
case BACKBOTTOMRIGHTCORNER:
|
case BACKBOTTOMRIGHTCORNER:
|
||||||
U(i, j, k) = -U(i, j, k+1);
|
U(i, j, k) = -U(i, j, k + 1);
|
||||||
V(i, j, k) = -V(i+1, j, k);
|
V(i, j, k) = -V(i + 1, j, k);
|
||||||
W(i, j, k) = -W(i, j-1, k);
|
W(i, j, k) = -W(i, j - 1, k);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1511,82 +1508,82 @@ void setObjectPBoundaryCondition(Solver* s)
|
|||||||
for (int i = 1; i < imax + 1; i++) {
|
for (int i = 1; i < imax + 1; i++) {
|
||||||
switch (S(i, j, k)) {
|
switch (S(i, j, k)) {
|
||||||
case TOPFACE:
|
case TOPFACE:
|
||||||
P(i,j,k) = P(i,j+1,k);
|
P(i, j, k) = P(i, j + 1, k);
|
||||||
break;
|
break;
|
||||||
case BOTTOMFACE:
|
case BOTTOMFACE:
|
||||||
P(i,j,k) = P(i,j-1,k);
|
P(i, j, k) = P(i, j - 1, k);
|
||||||
break;
|
break;
|
||||||
case LEFTFACE:
|
case LEFTFACE:
|
||||||
P(i,j,k) = P(i-1,j,k);
|
P(i, j, k) = P(i - 1, j, k);
|
||||||
break;
|
break;
|
||||||
case RIGHTFACE:
|
case RIGHTFACE:
|
||||||
P(i,j,k) = P(i+1,j,k);
|
P(i, j, k) = P(i + 1, j, k);
|
||||||
break;
|
break;
|
||||||
case FRONTFACE:
|
case FRONTFACE:
|
||||||
P(i,j,k) = P(i,j,k-1);
|
P(i, j, k) = P(i, j, k - 1);
|
||||||
break;
|
break;
|
||||||
case BACKFACE:
|
case BACKFACE:
|
||||||
P(i,j,k) = P(i,j,k+1);
|
P(i, j, k) = P(i, j, k + 1);
|
||||||
break;
|
break;
|
||||||
case FRONTLEFTLINE:
|
case FRONTLEFTLINE:
|
||||||
P(i,j,k) = (P(i,j,k-1) + P(i-1,j,k)) / 2;
|
P(i, j, k) = (P(i, j, k - 1) + P(i - 1, j, k)) / 2;
|
||||||
break;
|
break;
|
||||||
case FRONTRIGHTLINE:
|
case FRONTRIGHTLINE:
|
||||||
P(i,j,k) = (P(i,j,k-1) + P(i+1,j,k)) / 2;
|
P(i, j, k) = (P(i, j, k - 1) + P(i + 1, j, k)) / 2;
|
||||||
break;
|
break;
|
||||||
case FRONTTOPLINE:
|
case FRONTTOPLINE:
|
||||||
P(i,j,k) = (P(i,j,k-1) + P(i,j+1,k)) / 2;
|
P(i, j, k) = (P(i, j, k - 1) + P(i, j + 1, k)) / 2;
|
||||||
break;
|
break;
|
||||||
case FRONTBOTTOMLINE:
|
case FRONTBOTTOMLINE:
|
||||||
P(i,j,k) = (P(i,j,k-1) + P(i,j-1,k)) / 2;
|
P(i, j, k) = (P(i, j, k - 1) + P(i, j - 1, k)) / 2;
|
||||||
break;
|
break;
|
||||||
case MIDTOPLEFTLINE:
|
case MIDTOPLEFTLINE:
|
||||||
P(i,j,k) = (P(i-1,j,k) + P(i,j+1,k)) / 2;
|
P(i, j, k) = (P(i - 1, j, k) + P(i, j + 1, k)) / 2;
|
||||||
break;
|
break;
|
||||||
case MIDTOPRIGHTLINE:
|
case MIDTOPRIGHTLINE:
|
||||||
P(i,j,k) = (P(i+1,j,k) + P(i,j+1,k)) / 2;
|
P(i, j, k) = (P(i + 1, j, k) + P(i, j + 1, k)) / 2;
|
||||||
break;
|
break;
|
||||||
case MIDBOTTOMLEFTLINE:
|
case MIDBOTTOMLEFTLINE:
|
||||||
P(i,j,k) = (P(i-1,j,k) + P(i,j-1,k)) / 2;
|
P(i, j, k) = (P(i - 1, j, k) + P(i, j - 1, k)) / 2;
|
||||||
break;
|
break;
|
||||||
case MIDBOTTOMRIGHTLINE:
|
case MIDBOTTOMRIGHTLINE:
|
||||||
P(i,j,k) = (P(i+1,j,k) + P(i,j-1,k)) / 2;
|
P(i, j, k) = (P(i + 1, j, k) + P(i, j - 1, k)) / 2;
|
||||||
break;
|
break;
|
||||||
case BACKLEFTLINE:
|
case BACKLEFTLINE:
|
||||||
P(i,j,k) = (P(i,j,k+1) + P(i-1,j,k)) / 2;
|
P(i, j, k) = (P(i, j, k + 1) + P(i - 1, j, k)) / 2;
|
||||||
break;
|
break;
|
||||||
case BACKRIGHTLINE:
|
case BACKRIGHTLINE:
|
||||||
P(i,j,k) = (P(i,j,k+1) + P(i+1,j,k)) / 2;
|
P(i, j, k) = (P(i, j, k + 1) + P(i + 1, j, k)) / 2;
|
||||||
break;
|
break;
|
||||||
case BACKTOPLINE:
|
case BACKTOPLINE:
|
||||||
P(i,j,k) = (P(i,j,k+1) + P(i,j+1,k)) / 2;
|
P(i, j, k) = (P(i, j, k + 1) + P(i, j + 1, k)) / 2;
|
||||||
break;
|
break;
|
||||||
case BACKBOTTOMLINE:
|
case BACKBOTTOMLINE:
|
||||||
P(i,j,k) = (P(i,j,k+1) + P(i,j-1,k)) / 2;
|
P(i, j, k) = (P(i, j, k + 1) + P(i, j - 1, k)) / 2;
|
||||||
break;
|
break;
|
||||||
case FRONTTOPLEFTCORNER:
|
case FRONTTOPLEFTCORNER:
|
||||||
P(i,j,k) = (P(i,j,k-1) + P(i-1,j,k) + P(i,j+1,k)) / 3;
|
P(i, j, k) = (P(i, j, k - 1) + P(i - 1, j, k) + P(i, j + 1, k)) / 3;
|
||||||
break;
|
break;
|
||||||
case FRONTTOPRIGHTCORNER:
|
case FRONTTOPRIGHTCORNER:
|
||||||
P(i,j,k) = (P(i,j,k-1) + P(i+1,j,k) + P(i,j+1,k)) / 3;
|
P(i, j, k) = (P(i, j, k - 1) + P(i + 1, j, k) + P(i, j + 1, k)) / 3;
|
||||||
break;
|
break;
|
||||||
case FRONTBOTTOMLEFTCORNER:
|
case FRONTBOTTOMLEFTCORNER:
|
||||||
P(i,j,k) = (P(i,j,k-1) + P(i-1,j,k) + P(i,j-1,k)) / 3;
|
P(i, j, k) = (P(i, j, k - 1) + P(i - 1, j, k) + P(i, j - 1, k)) / 3;
|
||||||
break;
|
break;
|
||||||
case FRONTBOTTOMRIGHTCORNER:
|
case FRONTBOTTOMRIGHTCORNER:
|
||||||
P(i,j,k) = (P(i,j,k-1) + P(i+1,j,k) + P(i,j-1,k)) / 3;
|
P(i, j, k) = (P(i, j, k - 1) + P(i + 1, j, k) + P(i, j - 1, k)) / 3;
|
||||||
break;
|
break;
|
||||||
case BACKTOPLEFTCORNER:
|
case BACKTOPLEFTCORNER:
|
||||||
P(i,j,k) = (P(i,j,k+1) + P(i-1,j,k) + P(i,j+1,k)) / 3;
|
P(i, j, k) = (P(i, j, k + 1) + P(i - 1, j, k) + P(i, j + 1, k)) / 3;
|
||||||
break;
|
break;
|
||||||
case BACKTOPRIGHTCORNER:
|
case BACKTOPRIGHTCORNER:
|
||||||
P(i,j,k) = (P(i,j,k+1) + P(i+1,j,k) + P(i,j+1,k)) / 3;
|
P(i, j, k) = (P(i, j, k + 1) + P(i + 1, j, k) + P(i, j + 1, k)) / 3;
|
||||||
break;
|
break;
|
||||||
case BACKBOTTOMLEFTCORNER:
|
case BACKBOTTOMLEFTCORNER:
|
||||||
P(i,j,k) = (P(i,j,k+1) + P(i-1,j,k) + P(i,j-1,k)) / 3;
|
P(i, j, k) = (P(i, j, k + 1) + P(i - 1, j, k) + P(i, j - 1, k)) / 3;
|
||||||
break;
|
break;
|
||||||
case BACKBOTTOMRIGHTCORNER:
|
case BACKBOTTOMRIGHTCORNER:
|
||||||
P(i,j,k) = (P(i,j,k+1) + P(i+1,j,k) + P(i,j-1,k)) / 3;
|
P(i, j, k) = (P(i, j, k + 1) + P(i + 1, j, k) + P(i, j - 1, k)) / 3;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "vtkWriter.h"
|
#include "vtkWriter.h"
|
||||||
#define G(v, i, j, k) v[(k)*imax * jmax + (j)*imax + (i)]
|
#define G(v, i, j, k) v[(k) * imax * jmax + (j) * imax + (i)]
|
||||||
|
|
||||||
static float floatSwap(float f)
|
static float floatSwap(float f)
|
||||||
{
|
{
|
||||||
@ -174,28 +174,25 @@ void vtkParticle(VtkOptions* o, char* name)
|
|||||||
|
|
||||||
fprintf(o->fh, "POINTS %d float\n", o->particletracer->totalParticles);
|
fprintf(o->fh, "POINTS %d float\n", o->particletracer->totalParticles);
|
||||||
|
|
||||||
|
for (int i = 0; i < o->particletracer->totalParticles; ++i) {
|
||||||
for (int i = 0; i < o->particletracer->totalParticles; ++i)
|
double x = particlePool[i].x;
|
||||||
{
|
double y = particlePool[i].y;
|
||||||
double x = particlePool[i].x;
|
double z = particlePool[i].z;
|
||||||
double y = particlePool[i].y;
|
fprintf(o->fh, "%.2f %.2f %.2f\n", x, y, z);
|
||||||
double z = particlePool[i].z;
|
|
||||||
fprintf(o->fh, "%.2f %.2f %.2f\n", x, y, z);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(o->fh, "CELLS %d %d\n", o->particletracer->totalParticles, 2 * o->particletracer->totalParticles);
|
fprintf(o->fh,
|
||||||
|
"CELLS %d %d\n",
|
||||||
|
o->particletracer->totalParticles,
|
||||||
|
2 * o->particletracer->totalParticles);
|
||||||
|
|
||||||
|
for (int i = 0; i < o->particletracer->totalParticles; ++i) {
|
||||||
for (int i = 0; i < o->particletracer->totalParticles; ++i)
|
|
||||||
{
|
|
||||||
fprintf(o->fh, "1 %d\n", i);
|
fprintf(o->fh, "1 %d\n", i);
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(o->fh, "CELL_TYPES %d\n", o->particletracer->totalParticles);
|
fprintf(o->fh, "CELL_TYPES %d\n", o->particletracer->totalParticles);
|
||||||
|
|
||||||
|
for (int i = 0; i < o->particletracer->totalParticles; ++i) {
|
||||||
for (int i = 0; i < o->particletracer->totalParticles; ++i)
|
|
||||||
{
|
|
||||||
fprintf(o->fh, "1\n");
|
fprintf(o->fh, "1\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user