Merging the new branch
This commit is contained in:
@@ -1,61 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
||||
* All rights reserved.
|
||||
* Use of this source code is governed by a MIT-style
|
||||
* license that can be found in the LICENSE file.
|
||||
*/
|
||||
#ifdef __linux__
|
||||
#ifdef _OPENMP
|
||||
#include <pthread.h>
|
||||
#include <sched.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define MAX_NUM_THREADS 128
|
||||
#define gettid() syscall(SYS_gettid)
|
||||
|
||||
static int getProcessorID(cpu_set_t* cpu_set)
|
||||
{
|
||||
int processorId;
|
||||
|
||||
for (processorId = 0; processorId < MAX_NUM_THREADS; processorId++) {
|
||||
if (CPU_ISSET(processorId, cpu_set)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return processorId;
|
||||
}
|
||||
|
||||
int affinity_getProcessorId()
|
||||
{
|
||||
cpu_set_t cpu_set;
|
||||
CPU_ZERO(&cpu_set);
|
||||
sched_getaffinity(gettid(), sizeof(cpu_set_t), &cpu_set);
|
||||
|
||||
return getProcessorID(&cpu_set);
|
||||
}
|
||||
|
||||
void affinity_pinThread(int processorId)
|
||||
{
|
||||
cpu_set_t cpuset;
|
||||
pthread_t thread;
|
||||
|
||||
thread = pthread_self();
|
||||
CPU_ZERO(&cpuset);
|
||||
CPU_SET(processorId, &cpuset);
|
||||
pthread_setaffinity_np(thread, sizeof(cpu_set_t), &cpuset);
|
||||
}
|
||||
|
||||
void affinity_pinProcess(int processorId)
|
||||
{
|
||||
cpu_set_t cpuset;
|
||||
|
||||
CPU_ZERO(&cpuset);
|
||||
CPU_SET(processorId, &cpuset);
|
||||
sched_setaffinity(0, sizeof(cpu_set_t), &cpuset);
|
||||
}
|
||||
#endif /*_OPENMP*/
|
||||
#endif /*__linux__*/
|
@@ -1,14 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
||||
* All rights reserved.
|
||||
* Use of this source code is governed by a MIT-style
|
||||
* license that can be found in the LICENSE file.
|
||||
*/
|
||||
#ifndef AFFINITY_H
|
||||
#define AFFINITY_H
|
||||
|
||||
extern int affinity_getProcessorId();
|
||||
extern void affinity_pinProcess(int);
|
||||
extern void affinity_pinThread(int);
|
||||
|
||||
#endif /*AFFINITY_H*/
|
@@ -1,14 +1,17 @@
|
||||
/*
|
||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
||||
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||
* All rights reserved.
|
||||
* Use of this source code is governed by a MIT-style
|
||||
* license that can be found in the LICENSE file.
|
||||
*/
|
||||
#include <errno.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
void* allocate(int alignment, size_t bytesize)
|
||||
#include "allocate.h"
|
||||
|
||||
void* allocate(size_t alignment, size_t bytesize)
|
||||
{
|
||||
int errorCode;
|
||||
void* ptr;
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
||||
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||
* All rights reserved.
|
||||
* Use of this source code is governed by a MIT-style
|
||||
* license that can be found in the LICENSE file.
|
||||
@@ -8,6 +8,6 @@
|
||||
#define __ALLOCATE_H_
|
||||
#include <stdlib.h>
|
||||
|
||||
extern void* allocate(int alignment, size_t bytesize);
|
||||
extern void* allocate(size_t alignment, size_t bytesize);
|
||||
|
||||
#endif
|
||||
|
435
BasicSolver/2D-seq/src/discretization.c
Normal file
435
BasicSolver/2D-seq/src/discretization.c
Normal file
@@ -0,0 +1,435 @@
|
||||
/*
|
||||
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||
* All rights reserved. This file is part of nusif-solver.
|
||||
* Use of this source code is governed by a MIT style
|
||||
* license that can be found in the LICENSE file.
|
||||
*/
|
||||
#include <float.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "allocate.h"
|
||||
#include "discretization.h"
|
||||
#include "parameter.h"
|
||||
#include "util.h"
|
||||
|
||||
static void print(Discretization* d, double* grid)
|
||||
{
|
||||
int imax = d->grid.imax;
|
||||
|
||||
for (int j = 0; j < d->grid.jmax + 2; j++) {
|
||||
printf("%02d: ", j);
|
||||
for (int i = 0; i < d->grid.imax + 2; i++) {
|
||||
printf("%12.8f ", grid[j * (imax + 2) + i]);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
static void printConfig(Discretization* d)
|
||||
{
|
||||
printf("Parameters for #%s#\n", d->problem);
|
||||
printf("Boundary conditions Left:%d Right:%d Bottom:%d Top:%d\n",
|
||||
d->bcLeft,
|
||||
d->bcRight,
|
||||
d->bcBottom,
|
||||
d->bcTop);
|
||||
printf("\tReynolds number: %.2f\n", d->re);
|
||||
printf("\tGx Gy: %.2f %.2f\n", d->gx, d->gy);
|
||||
printf("Geometry data:\n");
|
||||
printf("\tDomain box size (x, y): %.2f, %.2f\n", d->grid.xlength, d->grid.ylength);
|
||||
printf("\tCells (x, y): %d, %d\n", d->grid.imax, d->grid.jmax);
|
||||
printf("Timestep parameters:\n");
|
||||
printf("\tDefault stepsize: %.2f, Final time %.2f\n", d->dt, d->te);
|
||||
printf("\tdt bound: %.6f\n", d->dtBound);
|
||||
printf("\tTau factor: %.2f\n", d->tau);
|
||||
printf("Iterative d parameters:\n");
|
||||
printf("\tgamma factor: %f\n", d->gamma);
|
||||
}
|
||||
|
||||
void initDiscretization(Discretization* d, Parameter* p)
|
||||
{
|
||||
d->problem = p->name;
|
||||
d->bcLeft = p->bcLeft;
|
||||
d->bcRight = p->bcRight;
|
||||
d->bcBottom = p->bcBottom;
|
||||
d->bcTop = p->bcTop;
|
||||
d->grid.imax = p->imax;
|
||||
d->grid.jmax = p->jmax;
|
||||
d->grid.xlength = p->xlength;
|
||||
d->grid.ylength = p->ylength;
|
||||
d->grid.dx = p->xlength / p->imax;
|
||||
d->grid.dy = p->ylength / p->jmax;
|
||||
d->re = p->re;
|
||||
d->gx = p->gx;
|
||||
d->gy = p->gy;
|
||||
d->dt = p->dt;
|
||||
d->te = p->te;
|
||||
d->tau = p->tau;
|
||||
d->gamma = p->gamma;
|
||||
|
||||
int imax = d->grid.imax;
|
||||
int jmax = d->grid.jmax;
|
||||
size_t size = (imax + 2) * (jmax + 2) * sizeof(double);
|
||||
d->u = allocate(64, size);
|
||||
d->v = allocate(64, size);
|
||||
d->p = allocate(64, size);
|
||||
d->rhs = allocate(64, size);
|
||||
d->f = allocate(64, size);
|
||||
d->g = allocate(64, size);
|
||||
|
||||
for (int i = 0; i < (imax + 2) * (jmax + 2); i++) {
|
||||
d->u[i] = p->u_init;
|
||||
d->v[i] = p->v_init;
|
||||
d->p[i] = p->p_init;
|
||||
d->rhs[i] = 0.0;
|
||||
d->f[i] = 0.0;
|
||||
d->g[i] = 0.0;
|
||||
}
|
||||
|
||||
double dx = d->grid.dx;
|
||||
double dy = d->grid.dy;
|
||||
double invSqrSum = 1.0 / (dx * dx) + 1.0 / (dy * dy);
|
||||
d->dtBound = 0.5 * d->re * 1.0 / invSqrSum;
|
||||
#ifdef VERBOSE
|
||||
printConfig(d);
|
||||
#endif
|
||||
}
|
||||
|
||||
void computeRHS(Discretization* d)
|
||||
{
|
||||
int imax = d->grid.imax;
|
||||
int jmax = d->grid.jmax;
|
||||
double idx = 1.0 / d->grid.dx;
|
||||
double idy = 1.0 / d->grid.dy;
|
||||
double idt = 1.0 / d->dt;
|
||||
double* rhs = d->rhs;
|
||||
double* f = d->f;
|
||||
double* g = d->g;
|
||||
|
||||
for (int j = 1; j < jmax + 1; j++) {
|
||||
for (int i = 1; i < imax + 1; i++) {
|
||||
RHS(i, j) = idt *
|
||||
((F(i, j) - F(i - 1, j)) * idx + (G(i, j) - G(i, j - 1)) * idy);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static double maxElement(Discretization* d, double* m)
|
||||
{
|
||||
int size = (d->grid.imax + 2) * (d->grid.jmax + 2);
|
||||
double maxval = DBL_MIN;
|
||||
|
||||
for (int i = 0; i < size; i++) {
|
||||
maxval = MAX(maxval, fabs(m[i]));
|
||||
}
|
||||
|
||||
return maxval;
|
||||
}
|
||||
|
||||
void normalizePressure(Discretization* d)
|
||||
{
|
||||
int size = (d->grid.imax + 2) * (d->grid.jmax + 2);
|
||||
double* p = d->p;
|
||||
double avgP = 0.0;
|
||||
|
||||
for (int i = 0; i < size; i++) {
|
||||
avgP += p[i];
|
||||
}
|
||||
avgP /= size;
|
||||
|
||||
for (int i = 0; i < size; i++) {
|
||||
p[i] = p[i] - avgP;
|
||||
}
|
||||
}
|
||||
|
||||
void computeTimestep(Discretization* d)
|
||||
{
|
||||
double dt = d->dtBound;
|
||||
double dx = d->grid.dx;
|
||||
double dy = d->grid.dy;
|
||||
double umax = maxElement(d, d->u);
|
||||
double vmax = maxElement(d, d->v);
|
||||
|
||||
if (umax > 0) {
|
||||
dt = (dt > dx / umax) ? dx / umax : dt;
|
||||
}
|
||||
if (vmax > 0) {
|
||||
dt = (dt > dy / vmax) ? dy / vmax : dt;
|
||||
}
|
||||
|
||||
d->dt = dt * d->tau;
|
||||
}
|
||||
|
||||
void setBoundaryConditions(Discretization* d)
|
||||
{
|
||||
int imax = d->grid.imax;
|
||||
int jmax = d->grid.jmax;
|
||||
double* u = d->u;
|
||||
double* v = d->v;
|
||||
|
||||
// Left boundary
|
||||
switch (d->bcLeft) {
|
||||
case NOSLIP:
|
||||
for (int j = 1; j < jmax + 1; j++) {
|
||||
U(0, j) = 0.0;
|
||||
V(0, j) = -V(1, j);
|
||||
}
|
||||
break;
|
||||
case SLIP:
|
||||
for (int j = 1; j < jmax + 1; j++) {
|
||||
U(0, j) = 0.0;
|
||||
V(0, j) = V(1, j);
|
||||
}
|
||||
break;
|
||||
case OUTFLOW:
|
||||
for (int j = 1; j < jmax + 1; j++) {
|
||||
U(0, j) = U(1, j);
|
||||
V(0, j) = V(1, j);
|
||||
}
|
||||
break;
|
||||
case PERIODIC:
|
||||
break;
|
||||
}
|
||||
|
||||
// Right boundary
|
||||
switch (d->bcRight) {
|
||||
case NOSLIP:
|
||||
for (int j = 1; j < jmax + 1; j++) {
|
||||
U(imax, j) = 0.0;
|
||||
V(imax + 1, j) = -V(imax, j);
|
||||
}
|
||||
break;
|
||||
case SLIP:
|
||||
for (int j = 1; j < jmax + 1; j++) {
|
||||
U(imax, j) = 0.0;
|
||||
V(imax + 1, j) = V(imax, j);
|
||||
}
|
||||
break;
|
||||
case OUTFLOW:
|
||||
for (int j = 1; j < jmax + 1; j++) {
|
||||
U(imax, j) = U(imax - 1, j);
|
||||
V(imax + 1, j) = V(imax, j);
|
||||
}
|
||||
break;
|
||||
case PERIODIC:
|
||||
break;
|
||||
}
|
||||
|
||||
// Bottom boundary
|
||||
switch (d->bcBottom) {
|
||||
case NOSLIP:
|
||||
for (int i = 1; i < imax + 1; i++) {
|
||||
V(i, 0) = 0.0;
|
||||
U(i, 0) = -U(i, 1);
|
||||
}
|
||||
break;
|
||||
case SLIP:
|
||||
for (int i = 1; i < imax + 1; i++) {
|
||||
V(i, 0) = 0.0;
|
||||
U(i, 0) = U(i, 1);
|
||||
}
|
||||
break;
|
||||
case OUTFLOW:
|
||||
for (int i = 1; i < imax + 1; i++) {
|
||||
U(i, 0) = U(i, 1);
|
||||
V(i, 0) = V(i, 1);
|
||||
}
|
||||
break;
|
||||
case PERIODIC:
|
||||
break;
|
||||
}
|
||||
|
||||
// Top boundary
|
||||
switch (d->bcTop) {
|
||||
case NOSLIP:
|
||||
for (int i = 1; i < imax + 1; i++) {
|
||||
V(i, jmax) = 0.0;
|
||||
U(i, jmax + 1) = -U(i, jmax);
|
||||
}
|
||||
break;
|
||||
case SLIP:
|
||||
for (int i = 1; i < imax + 1; i++) {
|
||||
V(i, jmax) = 0.0;
|
||||
U(i, jmax + 1) = U(i, jmax);
|
||||
}
|
||||
break;
|
||||
case OUTFLOW:
|
||||
for (int i = 1; i < imax + 1; i++) {
|
||||
U(i, jmax + 1) = U(i, jmax);
|
||||
V(i, jmax) = V(i, jmax - 1);
|
||||
}
|
||||
break;
|
||||
case PERIODIC:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void setSpecialBoundaryCondition(Discretization* d)
|
||||
{
|
||||
int imax = d->grid.imax;
|
||||
int jmax = d->grid.jmax;
|
||||
double mDy = d->grid.dy;
|
||||
double* u = d->u;
|
||||
|
||||
if (strcmp(d->problem, "dcavity") == 0) {
|
||||
for (int i = 1; i < imax; i++) {
|
||||
U(i, jmax + 1) = 2.0 - U(i, jmax);
|
||||
}
|
||||
} else if (strcmp(d->problem, "canal") == 0) {
|
||||
double ylength = d->grid.ylength;
|
||||
double y;
|
||||
|
||||
for (int j = 1; j < jmax + 1; j++) {
|
||||
y = mDy * (j - 0.5);
|
||||
U(0, j) = y * (ylength - y) * 4.0 / (ylength * ylength);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void computeFG(Discretization* d)
|
||||
{
|
||||
double* u = d->u;
|
||||
double* v = d->v;
|
||||
double* f = d->f;
|
||||
double* g = d->g;
|
||||
int imax = d->grid.imax;
|
||||
int jmax = d->grid.jmax;
|
||||
double gx = d->gx;
|
||||
double gy = d->gy;
|
||||
double gamma = d->gamma;
|
||||
double dt = d->dt;
|
||||
double inverseRe = 1.0 / d->re;
|
||||
double inverseDx = 1.0 / d->grid.dx;
|
||||
double inverseDy = 1.0 / d->grid.dy;
|
||||
double du2dx, dv2dy, duvdx, duvdy;
|
||||
double du2dx2, du2dy2, dv2dx2, dv2dy2;
|
||||
|
||||
for (int j = 1; j < jmax + 1; j++) {
|
||||
for (int i = 1; i < imax + 1; i++) {
|
||||
du2dx = inverseDx * 0.25 *
|
||||
((U(i, j) + U(i + 1, j)) * (U(i, j) + U(i + 1, j)) -
|
||||
(U(i, j) + U(i - 1, j)) * (U(i, j) + U(i - 1, j))) +
|
||||
gamma * inverseDx * 0.25 *
|
||||
(fabs(U(i, j) + U(i + 1, j)) * (U(i, j) - U(i + 1, j)) +
|
||||
fabs(U(i, j) + U(i - 1, j)) * (U(i, j) - U(i - 1, j)));
|
||||
|
||||
duvdy = inverseDy * 0.25 *
|
||||
((V(i, j) + V(i + 1, j)) * (U(i, j) + U(i, j + 1)) -
|
||||
(V(i, j - 1) + V(i + 1, j - 1)) * (U(i, j) + U(i, j - 1))) +
|
||||
gamma * inverseDy * 0.25 *
|
||||
(fabs(V(i, j) + V(i + 1, j)) * (U(i, j) - U(i, j + 1)) +
|
||||
fabs(V(i, j - 1) + V(i + 1, j - 1)) *
|
||||
(U(i, j) - U(i, j - 1)));
|
||||
|
||||
du2dx2 = inverseDx * inverseDx * (U(i + 1, j) - 2.0 * U(i, j) + U(i - 1, j));
|
||||
du2dy2 = inverseDy * inverseDy * (U(i, j + 1) - 2.0 * U(i, j) + U(i, j - 1));
|
||||
F(i, j) = U(i, j) + dt * (inverseRe * (du2dx2 + du2dy2) - du2dx - duvdy + gx);
|
||||
|
||||
duvdx = inverseDx * 0.25 *
|
||||
((U(i, j) + U(i, j + 1)) * (V(i, j) + V(i + 1, j)) -
|
||||
(U(i - 1, j) + U(i - 1, j + 1)) * (V(i, j) + V(i - 1, j))) +
|
||||
gamma * inverseDx * 0.25 *
|
||||
(fabs(U(i, j) + U(i, j + 1)) * (V(i, j) - V(i + 1, j)) +
|
||||
fabs(U(i - 1, j) + U(i - 1, j + 1)) *
|
||||
(V(i, j) - V(i - 1, j)));
|
||||
|
||||
dv2dy = inverseDy * 0.25 *
|
||||
((V(i, j) + V(i, j + 1)) * (V(i, j) + V(i, j + 1)) -
|
||||
(V(i, j) + V(i, j - 1)) * (V(i, j) + V(i, j - 1))) +
|
||||
gamma * inverseDy * 0.25 *
|
||||
(fabs(V(i, j) + V(i, j + 1)) * (V(i, j) - V(i, j + 1)) +
|
||||
fabs(V(i, j) + V(i, j - 1)) * (V(i, j) - V(i, j - 1)));
|
||||
|
||||
dv2dx2 = inverseDx * inverseDx * (V(i + 1, j) - 2.0 * V(i, j) + V(i - 1, j));
|
||||
dv2dy2 = inverseDy * inverseDy * (V(i, j + 1) - 2.0 * V(i, j) + V(i, j - 1));
|
||||
G(i, j) = V(i, j) + dt * (inverseRe * (dv2dx2 + dv2dy2) - duvdx - dv2dy + gy);
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------- boundary of F --------------------------- */
|
||||
for (int j = 1; j < jmax + 1; j++) {
|
||||
F(0, j) = U(0, j);
|
||||
F(imax, j) = U(imax, j);
|
||||
}
|
||||
|
||||
/* ---------------------- boundary of G --------------------------- */
|
||||
for (int i = 1; i < imax + 1; i++) {
|
||||
G(i, 0) = V(i, 0);
|
||||
G(i, jmax) = V(i, jmax);
|
||||
}
|
||||
}
|
||||
|
||||
void adaptUV(Discretization* d)
|
||||
{
|
||||
int imax = d->grid.imax;
|
||||
int jmax = d->grid.jmax;
|
||||
double* p = d->p;
|
||||
double* u = d->u;
|
||||
double* v = d->v;
|
||||
double* f = d->f;
|
||||
double* g = d->g;
|
||||
double factorX = d->dt / d->grid.dx;
|
||||
double factorY = d->dt / d->grid.dy;
|
||||
|
||||
for (int j = 1; j < jmax + 1; j++) {
|
||||
for (int i = 1; i < imax + 1; i++) {
|
||||
U(i, j) = F(i, j) - (P(i + 1, j) - P(i, j)) * factorX;
|
||||
V(i, j) = G(i, j) - (P(i, j + 1) - P(i, j)) * factorY;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void writeResult(Discretization* d)
|
||||
{
|
||||
int imax = d->grid.imax;
|
||||
int jmax = d->grid.jmax;
|
||||
double dx = d->grid.dx;
|
||||
double dy = d->grid.dy;
|
||||
double* p = d->p;
|
||||
double* u = d->u;
|
||||
double* v = d->v;
|
||||
double x = 0.0, y = 0.0;
|
||||
|
||||
FILE* fp;
|
||||
fp = fopen("pressure.dat", "w");
|
||||
|
||||
if (fp == NULL) {
|
||||
printf("Error!\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
for (int j = 1; j < jmax + 1; j++) {
|
||||
y = (double)(j - 0.5) * dy;
|
||||
for (int i = 1; i < imax + 1; i++) {
|
||||
x = (double)(i - 0.5) * dx;
|
||||
fprintf(fp, "%.2f %.2f %f\n", x, y, P(i, j));
|
||||
}
|
||||
fprintf(fp, "\n");
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
|
||||
fp = fopen("velocity.dat", "w");
|
||||
|
||||
if (fp == NULL) {
|
||||
printf("Error!\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
for (int j = 1; j < jmax + 1; j++) {
|
||||
y = dy * (j - 0.5);
|
||||
for (int i = 1; i < imax + 1; i++) {
|
||||
x = dx * (i - 0.5);
|
||||
double velU = (U(i, j) + U(i - 1, j)) / 2.0;
|
||||
double velV = (V(i, j) + V(i, j - 1)) / 2.0;
|
||||
double len = sqrt((velU * velU) + (velV * velV));
|
||||
fprintf(fp, "%.2f %.2f %f %f %f\n", x, y, velU, velV, len);
|
||||
}
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
}
|
40
BasicSolver/2D-seq/src/discretization.h
Normal file
40
BasicSolver/2D-seq/src/discretization.h
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||
* All rights reserved. This file is part of nusif-solver.
|
||||
* Use of this source code is governed by a MIT style
|
||||
* license that can be found in the LICENSE file.
|
||||
*/
|
||||
#ifndef __DISCRETIZATION_H_
|
||||
#define __DISCRETIZATION_H_
|
||||
#include "grid.h"
|
||||
#include "parameter.h"
|
||||
|
||||
enum BC { NOSLIP = 1, SLIP, OUTFLOW, PERIODIC };
|
||||
|
||||
typedef struct {
|
||||
/* geometry and grid information */
|
||||
Grid grid;
|
||||
/* arrays */
|
||||
double *p, *rhs;
|
||||
double *f, *g;
|
||||
double *u, *v;
|
||||
/* parameters */
|
||||
double re, tau, gamma;
|
||||
double gx, gy;
|
||||
/* time stepping */
|
||||
double dt, te;
|
||||
double dtBound;
|
||||
char* problem;
|
||||
int bcLeft, bcRight, bcBottom, bcTop;
|
||||
} Discretization;
|
||||
|
||||
extern void initDiscretization(Discretization*, Parameter*);
|
||||
extern void computeRHS(Discretization*);
|
||||
extern void normalizePressure(Discretization*);
|
||||
extern void computeTimestep(Discretization*);
|
||||
extern void setBoundaryConditions(Discretization*);
|
||||
extern void setSpecialBoundaryCondition(Discretization*);
|
||||
extern void computeFG(Discretization*);
|
||||
extern void adaptUV(Discretization*);
|
||||
extern void writeResult(Discretization*);
|
||||
#endif
|
16
BasicSolver/2D-seq/src/grid.h
Normal file
16
BasicSolver/2D-seq/src/grid.h
Normal file
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||
* All rights reserved. This file is part of nusif-solver.
|
||||
* Use of this source code is governed by a MIT style
|
||||
* license that can be found in the LICENSE file.
|
||||
*/
|
||||
#ifndef __GRID_H_
|
||||
#define __GRID_H_
|
||||
|
||||
typedef struct {
|
||||
double dx, dy;
|
||||
int imax, jmax;
|
||||
double xlength, ylength;
|
||||
} Grid;
|
||||
|
||||
#endif // __GRID_H_
|
@@ -4,23 +4,23 @@
|
||||
* Author: Jan Eitzinger (je), jan.eitzinger@fau.de
|
||||
* Copyright (c) 2020 RRZE, University Erlangen-Nuremberg
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"), to
|
||||
* deal in the Software without restriction, including without limitation the
|
||||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
* sell copies of the Software, and to permit persons to whom the Software is
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
* IN THE SOFTWARE.
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* =======================================================================================
|
||||
*/
|
||||
|
@@ -1,84 +1,58 @@
|
||||
/*
|
||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
||||
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||
* All rights reserved.
|
||||
* Use of this source code is governed by a MIT-style
|
||||
* license that can be found in the LICENSE file.
|
||||
*/
|
||||
#include <float.h>
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "discretization.h"
|
||||
#include "parameter.h"
|
||||
#include "particletracing.h"
|
||||
#include "progress.h"
|
||||
#include "solver.h"
|
||||
#include "timing.h"
|
||||
#include "vtkWriter.h"
|
||||
|
||||
enum VARIANT { SOR = 1, RB, RBA };
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
int rank;
|
||||
int variant = RB;
|
||||
double timeStart, timeStop;
|
||||
Parameter p;
|
||||
Discretization d;
|
||||
Solver s;
|
||||
|
||||
initParameter(&p);
|
||||
|
||||
double S, E;
|
||||
Parameter params;
|
||||
Solver solver;
|
||||
ParticleTracer particletracer;
|
||||
initParameter(¶ms);
|
||||
|
||||
if (argc < 2) {
|
||||
if (argc != 2) {
|
||||
printf("Usage: %s <configFile>\n", argv[0]);
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
readParameter(¶ms, argv[1]);
|
||||
if (argc == 3) {
|
||||
variant = atoi(argv[2]);
|
||||
}
|
||||
|
||||
printParameter(¶ms);
|
||||
initSolver(&solver, ¶ms);
|
||||
initParticleTracer(&particletracer, ¶ms);
|
||||
printParticleTracerParameters(&particletracer);
|
||||
|
||||
readParameter(&p, argv[1]);
|
||||
printParameter(&p);
|
||||
initDiscretization(&d, &p);
|
||||
initSolver(&s, &d, &p);
|
||||
|
||||
#ifndef VERBOSE
|
||||
initProgress(solver.te);
|
||||
initProgress(d.te);
|
||||
#endif
|
||||
|
||||
double tau = solver.tau;
|
||||
double te = solver.te;
|
||||
double tau = d.tau;
|
||||
double te = d.te;
|
||||
double t = 0.0;
|
||||
int nt = 0;
|
||||
|
||||
void (*solver_generic[])() = { solve, solveRB, solveRBA };
|
||||
|
||||
// printGrid(&solver, solver.s);
|
||||
|
||||
// exit(0);
|
||||
|
||||
S = getTimeStamp();
|
||||
|
||||
timeStart = getTimeStamp();
|
||||
while (t <= te) {
|
||||
if (tau > 0.0) computeTimestep(&solver);
|
||||
setBoundaryConditions(&solver);
|
||||
setSpecialBoundaryCondition(&solver);
|
||||
setObjectBoundaryCondition(&solver);
|
||||
|
||||
computeFG(&solver);
|
||||
computeRHS(&solver);
|
||||
if (nt % 100 == 0) normalizePressure(&solver);
|
||||
solver_generic[variant - 1](&solver);
|
||||
adaptUV(&solver);
|
||||
|
||||
/* Added function for particle tracing. Will inject and advance particles as per
|
||||
* timePeriod */
|
||||
trace(&particletracer, solver.u, solver.v, solver.s, t);
|
||||
|
||||
t += solver.dt;
|
||||
if (tau > 0.0) computeTimestep(&d);
|
||||
setBoundaryConditions(&d);
|
||||
setSpecialBoundaryCondition(&d);
|
||||
computeFG(&d);
|
||||
computeRHS(&d);
|
||||
if (nt % 100 == 0) normalizePressure(&d);
|
||||
solve(&s, d.p, d.rhs);
|
||||
adaptUV(&d);
|
||||
t += d.dt;
|
||||
nt++;
|
||||
|
||||
#ifdef VERBOSE
|
||||
@@ -87,21 +61,9 @@ int main(int argc, char** argv)
|
||||
printProgress(t);
|
||||
#endif
|
||||
}
|
||||
printf("Total particles : %d\n", particletracer.totalParticles);
|
||||
|
||||
// print(&solver, solver.p);
|
||||
|
||||
E = getTimeStamp();
|
||||
timeStop = getTimeStamp();
|
||||
stopProgress();
|
||||
|
||||
freeParticles(&particletracer);
|
||||
|
||||
// printf("\nU : \n\n");
|
||||
// print(&solver, solver.u);
|
||||
// printf("\nV : \n\n");
|
||||
// print(&solver, solver.v);
|
||||
|
||||
printf("Solution took %.2fs\n", E - S);
|
||||
writeResult(&solver);
|
||||
printf("Solution took %.2fs\n", timeStop - timeStart);
|
||||
writeResult(&d);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
||||
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||
* All rights reserved. This file is part of nusif-solver.
|
||||
* Use of this source code is governed by a MIT style
|
||||
* license that can be found in the LICENSE file.
|
||||
@@ -9,22 +9,21 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "parameter.h"
|
||||
#include "util.h"
|
||||
#define MAXLINE 4096
|
||||
|
||||
void initParameter(Parameter* param)
|
||||
{
|
||||
param->xlength = 1.0;
|
||||
param->ylength = 1.0;
|
||||
param->imax = 100;
|
||||
param->jmax = 100;
|
||||
param->imax = 128;
|
||||
param->jmax = 128;
|
||||
param->itermax = 1000;
|
||||
param->eps = 0.0001;
|
||||
param->omg = 1.7;
|
||||
param->re = 100.0;
|
||||
param->gamma = 0.9;
|
||||
param->tau = 0.5;
|
||||
param->rho = 0.99;
|
||||
param->levels = 5;
|
||||
}
|
||||
|
||||
void readParameter(Parameter* param, const char* filename)
|
||||
@@ -62,6 +61,7 @@ void readParameter(Parameter* param, const char* filename)
|
||||
PARSE_INT(imax);
|
||||
PARSE_INT(jmax);
|
||||
PARSE_INT(itermax);
|
||||
PARSE_INT(levels);
|
||||
PARSE_REAL(eps);
|
||||
PARSE_REAL(omg);
|
||||
PARSE_REAL(re);
|
||||
@@ -79,25 +79,6 @@ void readParameter(Parameter* param, const char* filename)
|
||||
PARSE_REAL(u_init);
|
||||
PARSE_REAL(v_init);
|
||||
PARSE_REAL(p_init);
|
||||
PARSE_REAL(rho);
|
||||
|
||||
/* Added new particle tracing parameters */
|
||||
PARSE_INT(numberOfParticles);
|
||||
PARSE_REAL(startTime);
|
||||
PARSE_REAL(injectTimePeriod);
|
||||
PARSE_REAL(writeTimePeriod);
|
||||
PARSE_REAL(x1);
|
||||
PARSE_REAL(y1);
|
||||
PARSE_REAL(x2);
|
||||
PARSE_REAL(y2);
|
||||
|
||||
/* Added obstacle geometry parameters */
|
||||
PARSE_INT(shape);
|
||||
PARSE_REAL(xCenter);
|
||||
PARSE_REAL(yCenter);
|
||||
PARSE_REAL(xRectLength);
|
||||
PARSE_REAL(yRectLength);
|
||||
PARSE_REAL(circleRadius);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,17 +109,5 @@ void printParameter(Parameter* param)
|
||||
printf("\tepsilon (stopping tolerance) : %f\n", param->eps);
|
||||
printf("\tgamma (stopping tolerance) : %f\n", param->gamma);
|
||||
printf("\tomega (SOR relaxation): %f\n", param->omg);
|
||||
printf("\trho (SOR relaxation): %f\n", param->rho);
|
||||
|
||||
printf("Particle Tracing data:\n");
|
||||
printf("\tNumber of particles : %d being injected for every period of %.2f\n",
|
||||
param->numberOfParticles,
|
||||
param->injectTimePeriod);
|
||||
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("\tMultiGrid levels : %d\n", param->levels);
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
||||
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||
* All rights reserved. This file is part of nusif-solver.
|
||||
* Use of this source code is governed by a MIT style
|
||||
* license that can be found in the LICENSE file.
|
||||
@@ -10,7 +10,7 @@
|
||||
typedef struct {
|
||||
double xlength, ylength;
|
||||
int imax, jmax;
|
||||
int itermax;
|
||||
int itermax, levels;
|
||||
double eps, omg, rho;
|
||||
double re, tau, gamma;
|
||||
double te, dt;
|
||||
@@ -18,15 +18,6 @@ typedef struct {
|
||||
char* name;
|
||||
int bcLeft, bcRight, bcBottom, bcTop;
|
||||
double u_init, v_init, p_init;
|
||||
|
||||
int numberOfParticles;
|
||||
double startTime, injectTimePeriod, writeTimePeriod;
|
||||
|
||||
double x1, y1, x2, y2;
|
||||
|
||||
int shape;
|
||||
double xCenter, yCenter, xRectLength, yRectLength, circleRadius;
|
||||
|
||||
} Parameter;
|
||||
|
||||
void initParameter(Parameter*);
|
||||
|
@@ -1,263 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
||||
* All rights reserved. This file is part of nusif-solver.
|
||||
* Use of this source code is governed by a MIT style
|
||||
* license that can be found in the LICENSE file.
|
||||
*/
|
||||
#include <float.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "vtkWriter.h"
|
||||
|
||||
#define U(i, j) u[(j) * (imax + 2) + (i)]
|
||||
#define V(i, j) v[(j) * (imax + 2) + (i)]
|
||||
#define S(i, j) s[(j) * (imax + 2) + (i)]
|
||||
|
||||
static int ts = 0;
|
||||
void printParticles(ParticleTracer* particletracer)
|
||||
{
|
||||
for (int i = 0; i < particletracer->totalParticles; ++i) {
|
||||
printf("Particle position X : %.2f, Y : %.2f, flag : %d\n",
|
||||
particletracer->particlePool[i].x,
|
||||
particletracer->particlePool[i].y,
|
||||
particletracer->particlePool[i].flag);
|
||||
}
|
||||
}
|
||||
void injectParticles(ParticleTracer* particletracer)
|
||||
{
|
||||
for (int i = 0; i < particletracer->numberOfParticles; ++i) {
|
||||
particletracer->particlePool[particletracer->pointer]
|
||||
.x = particletracer->linSpaceLine[i].x;
|
||||
particletracer->particlePool[particletracer->pointer]
|
||||
.y = particletracer->linSpaceLine[i].y;
|
||||
particletracer->particlePool[particletracer->pointer].flag = true;
|
||||
++(particletracer->pointer);
|
||||
++(particletracer->totalParticles);
|
||||
}
|
||||
}
|
||||
|
||||
void advanceParticles(ParticleTracer* particletracer,
|
||||
double* restrict u,
|
||||
double* restrict v,
|
||||
int* restrict s,
|
||||
double time)
|
||||
{
|
||||
int imax = particletracer->imax;
|
||||
int jmax = particletracer->jmax;
|
||||
|
||||
double dx = particletracer->dx;
|
||||
double dy = particletracer->dy;
|
||||
|
||||
double xlength = particletracer->xlength;
|
||||
double ylength = particletracer->ylength;
|
||||
|
||||
for (int i = 0; i < particletracer->totalParticles; ++i) {
|
||||
if (particletracer->particlePool[i].flag == true) {
|
||||
double x = particletracer->particlePool[i].x;
|
||||
double y = particletracer->particlePool[i].y;
|
||||
|
||||
int iCoord = (int)(x / dx) + 1;
|
||||
int jCoord = (int)((y + 0.5 * dy) / dy) + 1;
|
||||
|
||||
double x1 = (double)(iCoord - 1) * dx;
|
||||
double y1 = ((double)(jCoord - 1) - 0.5) * dy;
|
||||
double x2 = (double)iCoord * dx;
|
||||
double y2 = ((double)jCoord - 0.5) * dy;
|
||||
|
||||
double u_n = (1.0 / (dx * dy)) *
|
||||
((x2 - x) * (y2 - y) * U(iCoord - 1, jCoord - 1) +
|
||||
(x - x1) * (y2 - y) * U(iCoord, jCoord - 1) +
|
||||
(x2 - x) * (y - y1) * U(iCoord - 1, jCoord) +
|
||||
(x - x1) * (y - y1) * U(iCoord, jCoord));
|
||||
|
||||
double new_x = x + particletracer->dt * u_n;
|
||||
particletracer->particlePool[i].x = new_x;
|
||||
|
||||
iCoord = (int)((x + 0.5 * dx) / dx) + 1;
|
||||
jCoord = (int)(y / dy) + 1;
|
||||
|
||||
x1 = ((double)(iCoord - 1) - 0.5) * dx;
|
||||
y1 = (double)(jCoord - 1) * dy;
|
||||
x2 = ((double)iCoord - 0.5) * dx;
|
||||
y2 = (double)jCoord * dy;
|
||||
|
||||
double v_n = (1.0 / (dx * dy)) *
|
||||
((x2 - x) * (y2 - y) * V(iCoord - 1, jCoord - 1) +
|
||||
(x - x1) * (y2 - y) * V(iCoord, jCoord - 1) +
|
||||
(x2 - x) * (y - y1) * V(iCoord - 1, jCoord) +
|
||||
(x - x1) * (y - y1) * V(iCoord, jCoord));
|
||||
|
||||
double new_y = y + particletracer->dt * v_n;
|
||||
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("\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);
|
||||
// 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))) {
|
||||
particletracer->particlePool[i].flag = false;
|
||||
}
|
||||
int i_new = new_x / dx, j_new = new_y / dy;
|
||||
if (S(i_new, j_new) != NONE) {
|
||||
particletracer->particlePool[i].flag = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void freeParticles(ParticleTracer* particletracer)
|
||||
{
|
||||
free(particletracer->particlePool);
|
||||
free(particletracer->linSpaceLine);
|
||||
}
|
||||
|
||||
void writeParticles(ParticleTracer* particletracer)
|
||||
{
|
||||
VtkOptions opts = { .particletracer = particletracer };
|
||||
|
||||
char filename[50];
|
||||
// snprintf(filename, 50, "vtk_files/particles%d.vtk", ts);
|
||||
// vtkOpen(&opts, filename, ts);
|
||||
// vtkParticle(&opts, "particle");
|
||||
// vtkClose(&opts);
|
||||
|
||||
FILE* fp;
|
||||
Particle* particlePool = particletracer->particlePool;
|
||||
|
||||
snprintf(filename, 50, "vis_files/particles_%d.dat", ts);
|
||||
fp = fopen(filename, "w");
|
||||
|
||||
if (fp == NULL) {
|
||||
printf("Error!\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
for (int i = 0; i < particletracer->totalParticles; ++i) {
|
||||
double x = particlePool[i].x;
|
||||
double y = particlePool[i].y;
|
||||
fprintf(fp, "%f %f\n", x, y);
|
||||
}
|
||||
fclose(fp);
|
||||
|
||||
++ts;
|
||||
}
|
||||
|
||||
void initParticleTracer(ParticleTracer* particletracer, Parameter* params)
|
||||
{
|
||||
particletracer->numberOfParticles = params->numberOfParticles;
|
||||
particletracer->startTime = params->startTime;
|
||||
particletracer->injectTimePeriod = params->injectTimePeriod;
|
||||
particletracer->writeTimePeriod = params->writeTimePeriod;
|
||||
|
||||
particletracer->dt = params->dt;
|
||||
particletracer->dx = params->xlength / params->imax;
|
||||
particletracer->dy = params->ylength / params->jmax;
|
||||
|
||||
particletracer->xlength = params->xlength;
|
||||
particletracer->ylength = params->ylength;
|
||||
|
||||
particletracer->x1 = params->x1;
|
||||
particletracer->y1 = params->y1;
|
||||
particletracer->x2 = params->x2;
|
||||
particletracer->y2 = params->y2;
|
||||
|
||||
particletracer->lastInjectTime = params->startTime;
|
||||
particletracer->lastUpdateTime = params->startTime;
|
||||
particletracer->lastWriteTime = params->startTime;
|
||||
|
||||
particletracer->pointer = 0;
|
||||
particletracer->totalParticles = 0;
|
||||
|
||||
particletracer->imax = params->imax;
|
||||
particletracer->jmax = params->jmax;
|
||||
|
||||
particletracer->estimatedNumParticles = ((params->te - params->startTime) + 2) *
|
||||
params->numberOfParticles;
|
||||
|
||||
particletracer->particlePool = malloc(
|
||||
sizeof(Particle) * particletracer->estimatedNumParticles);
|
||||
particletracer->linSpaceLine = malloc(
|
||||
sizeof(Particle) * particletracer->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].flag = true;
|
||||
}
|
||||
}
|
||||
|
||||
void printParticleTracerParameters(ParticleTracer* particletracer)
|
||||
{
|
||||
printf("Particle Tracing data:\n");
|
||||
printf("\tNumber of particles : %d being injected for every period of %.2f\n",
|
||||
particletracer->numberOfParticles,
|
||||
particletracer->injectTimePeriod);
|
||||
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("\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)
|
||||
{
|
||||
if (time >= particletracer->startTime) {
|
||||
// printParticles(particletracer);
|
||||
if ((time - particletracer->lastInjectTime) >= particletracer->injectTimePeriod) {
|
||||
injectParticles(particletracer);
|
||||
particletracer->lastInjectTime = time;
|
||||
}
|
||||
if ((time - particletracer->lastWriteTime) >= particletracer->writeTimePeriod) {
|
||||
writeParticles(particletracer);
|
||||
particletracer->lastWriteTime = time;
|
||||
}
|
||||
advanceParticles(particletracer, u, v, s, time);
|
||||
compress(particletracer);
|
||||
particletracer->lastUpdateTime = time;
|
||||
}
|
||||
}
|
||||
|
||||
void compress(ParticleTracer* particletracer)
|
||||
{
|
||||
Particle* memPool = particletracer->particlePool;
|
||||
Particle tempPool[particletracer->totalParticles];
|
||||
int totalParticles = 0;
|
||||
|
||||
for (int i = 0; i < particletracer->totalParticles; ++i) {
|
||||
if (memPool[i].flag == 1) {
|
||||
tempPool[totalParticles].x = memPool[i].x;
|
||||
tempPool[totalParticles].y = memPool[i].y;
|
||||
tempPool[totalParticles].flag = memPool[i].flag;
|
||||
++totalParticles;
|
||||
}
|
||||
}
|
||||
|
||||
particletracer->totalParticles = totalParticles;
|
||||
particletracer->pointer = totalParticles + 1;
|
||||
memcpy(particletracer->particlePool, tempPool, totalParticles * sizeof(Particle));
|
||||
}
|
@@ -1,48 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
||||
* All rights reserved. This file is part of nusif-solver.
|
||||
* Use of this source code is governed by a MIT style
|
||||
* license that can be found in the LICENSE file.
|
||||
*/
|
||||
#ifndef __PARTICLETRACING_H_
|
||||
#define __PARTICLETRACING_H_
|
||||
#include "allocate.h"
|
||||
#include "parameter.h"
|
||||
#include "particletracing.h"
|
||||
#include "solver.h"
|
||||
#include <stdbool.h>
|
||||
|
||||
typedef enum COORD { X = 0, Y, NCOORD } COORD;
|
||||
typedef struct {
|
||||
double x, y;
|
||||
bool flag;
|
||||
} Particle;
|
||||
|
||||
typedef struct {
|
||||
int numberOfParticles, totalParticles;
|
||||
double startTime, injectTimePeriod, writeTimePeriod, lastInjectTime, lastUpdateTime,
|
||||
lastWriteTime;
|
||||
|
||||
int estimatedNumParticles;
|
||||
|
||||
double dx, dy, dt;
|
||||
Particle* linSpaceLine;
|
||||
Particle* particlePool;
|
||||
|
||||
int pointer;
|
||||
|
||||
double imax, jmax, xlength, ylength;
|
||||
|
||||
double x1, y1, x2, y2;
|
||||
} ParticleTracer;
|
||||
|
||||
void initParticleTracer(ParticleTracer*, Parameter*);
|
||||
void injectParticles(ParticleTracer*);
|
||||
void advanceParticles(ParticleTracer*, double*, double*, int*, double);
|
||||
void freeParticles(ParticleTracer*);
|
||||
void writeParticles(ParticleTracer*);
|
||||
void printParticleTracerParameters(ParticleTracer*);
|
||||
void printParticles(ParticleTracer*);
|
||||
void trace(ParticleTracer*, double*, double*, int*, double);
|
||||
void compress(ParticleTracer*);
|
||||
#endif
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
||||
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||
* All rights reserved. This file is part of nusif-solver.
|
||||
* Use of this source code is governed by a MIT style
|
||||
* license that can be found in the LICENSE file.
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
||||
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||
* All rights reserved.
|
||||
* Use of this source code is governed by a MIT-style
|
||||
* license that can be found in the LICENSE file.
|
||||
@@ -9,6 +9,6 @@
|
||||
|
||||
extern void initProgress(double);
|
||||
extern void printProgress(double);
|
||||
extern void stopProgress();
|
||||
extern void stopProgress(void);
|
||||
|
||||
#endif
|
||||
|
186
BasicSolver/2D-seq/src/solver-mg.c
Normal file
186
BasicSolver/2D-seq/src/solver-mg.c
Normal file
@@ -0,0 +1,186 @@
|
||||
/*
|
||||
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||
* All rights reserved. This file is part of nusif-solver.
|
||||
* Use of this source code is governed by a MIT style
|
||||
* license that can be found in the LICENSE file.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "allocate.h"
|
||||
#include "solver.h"
|
||||
#include "util.h"
|
||||
|
||||
#define FINEST_LEVEL 0
|
||||
#define COARSEST_LEVEL (s->levels - 1)
|
||||
#define S(i, j) s[(j) * (imax + 2) + (i)]
|
||||
#define E(i, j) e[(j) * (imax + 2) + (i)]
|
||||
#define R(i, j) r[(j) * (imax + 2) + (i)]
|
||||
#define OLD(i, j) old[(j) * (imax + 2) + (i)]
|
||||
|
||||
static void restrictMG(Solver* s, int level, int imax, int jmax)
|
||||
{
|
||||
double* r = s->r[level + 1];
|
||||
double* old = s->r[level];
|
||||
|
||||
for (int j = 1; j < jmax + 1; j++) {
|
||||
for (int i = 1; i < imax + 1; i++) {
|
||||
R(i, j) = (OLD(2 * i - 1, 2 * j - 1) + OLD(2 * i, 2 * j - 1) * 2 +
|
||||
OLD(2 * i + 1, 2 * j - 1) + OLD(2 * i - 1, 2 * j) * 2 +
|
||||
OLD(2 * i, 2 * j) * 4 + OLD(2 * i + 1, 2 * j) * 2 +
|
||||
OLD(2 * i - 1, 2 * j + 1) + OLD(2 * i, 2 * j + 1) * 2 +
|
||||
OLD(2 * i + 1, 2 * j + 1)) /
|
||||
16.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void prolongate(Solver* s, int level, int imax, int jmax)
|
||||
{
|
||||
double* old = s->r[level + 1];
|
||||
double* e = s->r[level];
|
||||
|
||||
for (int j = 2; j < jmax + 1; j += 2) {
|
||||
for (int i = 2; i < imax + 1; i += 2) {
|
||||
E(i, j) = OLD(i / 2, j / 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void correct(Solver* s, double* p, int level, int imax, int jmax)
|
||||
{
|
||||
double* e = s->e[level];
|
||||
|
||||
for (int j = 1; j < jmax + 1; ++j) {
|
||||
for (int i = 1; i < imax + 1; ++i) {
|
||||
P(i, j) += E(i, j);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void setBoundaryCondition(double* p, int imax, int jmax)
|
||||
{
|
||||
for (int i = 1; i < imax + 1; i++) {
|
||||
P(i, 0) = P(i, 1);
|
||||
P(i, jmax + 1) = P(i, jmax);
|
||||
}
|
||||
|
||||
for (int j = 1; j < jmax + 1; j++) {
|
||||
P(0, j) = P(1, j);
|
||||
P(imax + 1, j) = P(imax, j);
|
||||
}
|
||||
}
|
||||
|
||||
static double smooth(Solver* s, double* p, double* rhs, int level, int imax, int jmax)
|
||||
{
|
||||
double dx2 = s->grid->dx * s->grid->dx;
|
||||
double dy2 = s->grid->dy * s->grid->dy;
|
||||
double idx2 = 1.0 / dx2;
|
||||
double idy2 = 1.0 / dy2;
|
||||
double factor = s->omega * 0.5 * (dx2 * dy2) / (dx2 + dy2);
|
||||
double* r = s->r[level];
|
||||
double res = 1.0;
|
||||
int pass, jsw, isw;
|
||||
|
||||
jsw = 1;
|
||||
|
||||
for (pass = 0; pass < 2; pass++) {
|
||||
isw = jsw;
|
||||
|
||||
for (int j = 1; j < jmax + 1; j++) {
|
||||
for (int i = isw; i < imax + 1; i += 2) {
|
||||
|
||||
R(i, j) = RHS(i, j) -
|
||||
((P(i + 1, j) - 2.0 * P(i, j) + P(i - 1, j)) * idx2 +
|
||||
(P(i, j + 1) - 2.0 * P(i, j) + P(i, j - 1)) * idy2);
|
||||
|
||||
P(i, j) -= (factor * R(i, j));
|
||||
res += (R(i, j) * R(i, j));
|
||||
}
|
||||
isw = 3 - isw;
|
||||
}
|
||||
jsw = 3 - jsw;
|
||||
}
|
||||
|
||||
res = res / (double)(imax * jmax);
|
||||
return res;
|
||||
}
|
||||
|
||||
static double multiGrid(Solver* s, double* p, double* rhs, int level, int imax, int jmax)
|
||||
{
|
||||
double res = 0.0;
|
||||
|
||||
// coarsest level TODO: Use direct solver?
|
||||
if (level == COARSEST_LEVEL) {
|
||||
for (int i = 0; i < 5; i++) {
|
||||
smooth(s, p, rhs, level, imax, jmax);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
// pre-smoothing TODO: Make smoothing steps configurable?
|
||||
for (int i = 0; i < 5; i++) {
|
||||
smooth(s, p, rhs, level, imax, jmax);
|
||||
if (level == FINEST_LEVEL) setBoundaryCondition(p, imax, jmax);
|
||||
}
|
||||
|
||||
// restrict
|
||||
restrictMG(s, level, imax, jmax);
|
||||
|
||||
// MGSolver on residual and error.
|
||||
// TODO: What if there is a rest?
|
||||
multiGrid(s, s->e[level + 1], s->r[level + 1], level + 1, imax / 2, jmax / 2);
|
||||
|
||||
// prolongate
|
||||
prolongate(s, level, imax, jmax);
|
||||
|
||||
// correct p on finer level using residual
|
||||
correct(s, p, level, imax, jmax);
|
||||
if (level == FINEST_LEVEL) setBoundaryCondition(p, imax, jmax);
|
||||
|
||||
// post-smoothing
|
||||
for (int i = 0; i < 5; i++) {
|
||||
res = smooth(s, p, rhs, level, imax, jmax);
|
||||
if (level == FINEST_LEVEL) setBoundaryCondition(p, imax, jmax);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
void initSolver(Solver* s, Discretization* d, Parameter* p)
|
||||
{
|
||||
s->eps = p->eps;
|
||||
s->omega = p->omg;
|
||||
s->itermax = p->itermax;
|
||||
s->levels = p->levels;
|
||||
s->grid = &d->grid;
|
||||
|
||||
int imax = s->grid->imax;
|
||||
int jmax = s->grid->jmax;
|
||||
int levels = s->levels;
|
||||
printf("Using Multigrid solver with %d levels\n", levels);
|
||||
|
||||
s->r = malloc(levels * sizeof(double*));
|
||||
s->e = malloc(levels * sizeof(double*));
|
||||
|
||||
size_t size = (imax + 2) * (jmax + 2) * sizeof(double);
|
||||
|
||||
for (int j = 0; j < levels; j++) {
|
||||
s->r[j] = allocate(64, size);
|
||||
s->e[j] = allocate(64, size);
|
||||
|
||||
for (int i = 0; i < (imax + 2) * (jmax + 2); i++) {
|
||||
s->r[j][i] = 0.0;
|
||||
s->e[j][i] = 0.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void solve(Solver* s, double* p, double* rhs)
|
||||
{
|
||||
double res = multiGrid(s, p, rhs, 0, s->grid->imax, s->grid->jmax);
|
||||
|
||||
#ifdef VERBOSE
|
||||
printf("Residuum: %.6f\n", res);
|
||||
#endif
|
||||
}
|
76
BasicSolver/2D-seq/src/solver-rb.c
Normal file
76
BasicSolver/2D-seq/src/solver-rb.c
Normal file
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||
* All rights reserved. This file is part of nusif-solver.
|
||||
* Use of this source code is governed by a MIT style
|
||||
* license that can be found in the LICENSE file.
|
||||
*/
|
||||
#include "solver.h"
|
||||
#include "util.h"
|
||||
|
||||
void initSolver(Solver* s, Discretization* d, Parameter* p)
|
||||
{
|
||||
s->grid = &d->grid;
|
||||
s->itermax = p->itermax;
|
||||
s->eps = p->eps;
|
||||
s->omega = p->omg;
|
||||
}
|
||||
|
||||
void solve(Solver* solver, double* p, double* rhs)
|
||||
{
|
||||
int imax = solver->grid->imax;
|
||||
int jmax = solver->grid->jmax;
|
||||
double eps = solver->eps;
|
||||
int itermax = solver->itermax;
|
||||
double dx2 = solver->grid->dx * solver->grid->dx;
|
||||
double dy2 = solver->grid->dy * solver->grid->dy;
|
||||
double idx2 = 1.0 / dx2;
|
||||
double idy2 = 1.0 / dy2;
|
||||
double factor = solver->omega * 0.5 * (dx2 * dy2) / (dx2 + dy2);
|
||||
double epssq = eps * eps;
|
||||
int it = 0;
|
||||
double res = 1.0;
|
||||
int pass, jsw, isw;
|
||||
|
||||
while ((res >= epssq) && (it < itermax)) {
|
||||
res = 0.0;
|
||||
jsw = 1;
|
||||
|
||||
for (pass = 0; pass < 2; pass++) {
|
||||
isw = jsw;
|
||||
|
||||
for (int j = 1; j < jmax + 1; j++) {
|
||||
for (int i = isw; i < imax + 1; i += 2) {
|
||||
|
||||
double r = RHS(i, j) -
|
||||
((P(i + 1, j) - 2.0 * P(i, j) + P(i - 1, j)) * idx2 +
|
||||
(P(i, j + 1) - 2.0 * P(i, j) + P(i, j - 1)) * idy2);
|
||||
|
||||
P(i, j) -= (factor * r);
|
||||
res += (r * r);
|
||||
}
|
||||
isw = 3 - isw;
|
||||
}
|
||||
jsw = 3 - jsw;
|
||||
}
|
||||
|
||||
for (int i = 1; i < imax + 1; i++) {
|
||||
P(i, 0) = P(i, 1);
|
||||
P(i, jmax + 1) = P(i, jmax);
|
||||
}
|
||||
|
||||
for (int j = 1; j < jmax + 1; j++) {
|
||||
P(0, j) = P(1, j);
|
||||
P(imax + 1, j) = P(imax, j);
|
||||
}
|
||||
|
||||
res = res / (double)(imax * jmax);
|
||||
#ifdef DEBUG
|
||||
printf("%d Residuum: %e\n", it, res);
|
||||
#endif
|
||||
it++;
|
||||
}
|
||||
|
||||
#ifdef VERBOSE
|
||||
printf("Solver took %d iterations to reach %f\n", it, sqrt(res));
|
||||
#endif
|
||||
}
|
68
BasicSolver/2D-seq/src/solver-sor.c
Normal file
68
BasicSolver/2D-seq/src/solver-sor.c
Normal file
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||
* All rights reserved. This file is part of nusif-solver.
|
||||
* Use of this source code is governed by a MIT style
|
||||
* license that can be found in the LICENSE file.
|
||||
*/
|
||||
#include "solver.h"
|
||||
#include "util.h"
|
||||
|
||||
void initSolver(Solver* s, Discretization* d, Parameter* p)
|
||||
{
|
||||
s->grid = &d->grid;
|
||||
s->itermax = p->itermax;
|
||||
s->eps = p->eps;
|
||||
s->omega = p->omg;
|
||||
}
|
||||
|
||||
void solve(Solver* solver, double* p, double* rhs)
|
||||
{
|
||||
int imax = solver->grid->imax;
|
||||
int jmax = solver->grid->jmax;
|
||||
double eps = solver->eps;
|
||||
int itermax = solver->itermax;
|
||||
double dx2 = solver->grid->dx * solver->grid->dx;
|
||||
double dy2 = solver->grid->dy * solver->grid->dy;
|
||||
double idx2 = 1.0 / dx2;
|
||||
double idy2 = 1.0 / dy2;
|
||||
double factor = solver->omega * 0.5 * (dx2 * dy2) / (dx2 + dy2);
|
||||
double epssq = eps * eps;
|
||||
int it = 0;
|
||||
double res = 1.0;
|
||||
|
||||
while ((res >= epssq) && (it < itermax)) {
|
||||
res = 0.0;
|
||||
|
||||
for (int j = 1; j < jmax + 1; j++) {
|
||||
for (int i = 1; i < imax + 1; i++) {
|
||||
|
||||
double r = RHS(i, j) -
|
||||
((P(i + 1, j) - 2.0 * P(i, j) + P(i - 1, j)) * idx2 +
|
||||
(P(i, j + 1) - 2.0 * P(i, j) + P(i, j - 1)) * idy2);
|
||||
|
||||
P(i, j) -= (factor * r);
|
||||
res += (r * r);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 1; i < imax + 1; i++) {
|
||||
P(i, 0) = P(i, 1);
|
||||
P(i, jmax + 1) = P(i, jmax);
|
||||
}
|
||||
|
||||
for (int j = 1; j < jmax + 1; j++) {
|
||||
P(0, j) = P(1, j);
|
||||
P(imax + 1, j) = P(imax, j);
|
||||
}
|
||||
|
||||
res = res / (double)(imax * jmax);
|
||||
#ifdef DEBUG
|
||||
printf("%d Residuum: %e\n", it, res);
|
||||
#endif
|
||||
it++;
|
||||
}
|
||||
|
||||
#ifdef VERBOSE
|
||||
printf("Solver took %d iterations to reach %f\n", it, sqrt(res));
|
||||
#endif
|
||||
}
|
@@ -1,904 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
||||
* All rights reserved. This file is part of nusif-solver.
|
||||
* Use of this source code is governed by a MIT style
|
||||
* license that can be found in the LICENSE file.
|
||||
*/
|
||||
#include <float.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "allocate.h"
|
||||
#include "parameter.h"
|
||||
#include "solver.h"
|
||||
#include "util.h"
|
||||
|
||||
#define P(i, j) p[(j) * (imax + 2) + (i)]
|
||||
#define F(i, j) f[(j) * (imax + 2) + (i)]
|
||||
#define G(i, j) g[(j) * (imax + 2) + (i)]
|
||||
#define U(i, j) u[(j) * (imax + 2) + (i)]
|
||||
#define V(i, j) v[(j) * (imax + 2) + (i)]
|
||||
#define S(i, j) s[(j) * (imax + 2) + (i)]
|
||||
#define RHS(i, j) rhs[(j) * (imax + 2) + (i)]
|
||||
|
||||
static double distance(double i, double j, double iCenter, double jCenter)
|
||||
{
|
||||
return sqrt(pow(iCenter - i, 2) + pow(jCenter - j, 2) * 1.0);
|
||||
}
|
||||
|
||||
void print(Solver* solver, double* grid)
|
||||
{
|
||||
int imax = solver->imax;
|
||||
|
||||
for (int j = 0; j < solver->jmax + 2; j++) {
|
||||
printf("%02d: ", j);
|
||||
for (int i = 0; i < solver->imax + 2; i++) {
|
||||
printf("%3.2f ", grid[j * (imax + 2) + i]);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
void printGrid(Solver* solver, int* grid)
|
||||
{
|
||||
int imax = solver->imax;
|
||||
|
||||
for (int j = 0; j < solver->jmax + 2; j++) {
|
||||
printf("%02d: ", j);
|
||||
for (int i = 0; i < solver->imax + 2; i++) {
|
||||
printf("%2d ", grid[j * (imax + 2) + i]);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
static void printConfig(Solver* solver)
|
||||
{
|
||||
printf("Parameters for #%s#\n", solver->problem);
|
||||
printf("Boundary conditions Left:%d Right:%d Bottom:%d Top:%d\n",
|
||||
solver->bcLeft,
|
||||
solver->bcRight,
|
||||
solver->bcBottom,
|
||||
solver->bcTop);
|
||||
printf("\tReynolds number: %.2f\n", solver->re);
|
||||
printf("\tGx Gy: %.2f %.2f\n", solver->gx, solver->gy);
|
||||
printf("Geometry data:\n");
|
||||
printf("\tDomain box size (x, y): %.2f, %.2f\n", solver->xlength, solver->ylength);
|
||||
printf("\tCells (x, y): %d, %d\n", solver->imax, solver->jmax);
|
||||
printf("Timestep parameters:\n");
|
||||
printf("\tDefault stepsize: %.2f, Final time %.2f\n", solver->dt, solver->te);
|
||||
printf("\tdt bound: %.6f\n", solver->dtBound);
|
||||
printf("\tTau factor: %.2f\n", solver->tau);
|
||||
printf("Iterative solver parameters:\n");
|
||||
printf("\tMax iterations: %d\n", solver->itermax);
|
||||
printf("\tepsilon (stopping tolerance) : %f\n", solver->eps);
|
||||
printf("\tgamma factor: %f\n", solver->gamma);
|
||||
printf("\tomega (SOR relaxation): %f\n", solver->omega);
|
||||
}
|
||||
|
||||
void initSolver(Solver* solver, Parameter* params)
|
||||
{
|
||||
solver->problem = params->name;
|
||||
solver->bcLeft = params->bcLeft;
|
||||
solver->bcRight = params->bcRight;
|
||||
solver->bcBottom = params->bcBottom;
|
||||
solver->bcTop = params->bcTop;
|
||||
solver->imax = params->imax;
|
||||
solver->jmax = params->jmax;
|
||||
solver->xlength = params->xlength;
|
||||
solver->ylength = params->ylength;
|
||||
solver->dx = params->xlength / params->imax;
|
||||
solver->dy = params->ylength / params->jmax;
|
||||
solver->eps = params->eps;
|
||||
solver->omega = params->omg;
|
||||
solver->itermax = params->itermax;
|
||||
solver->re = params->re;
|
||||
solver->gx = params->gx;
|
||||
solver->gy = params->gy;
|
||||
solver->dt = params->dt;
|
||||
solver->te = params->te;
|
||||
solver->tau = params->tau;
|
||||
solver->gamma = params->gamma;
|
||||
solver->rho = params->rho;
|
||||
|
||||
int imax = solver->imax;
|
||||
int jmax = solver->jmax;
|
||||
size_t size = (imax + 2) * (jmax + 2) * sizeof(double);
|
||||
solver->u = allocate(64, size);
|
||||
solver->v = allocate(64, size);
|
||||
solver->s = allocate(64, size);
|
||||
solver->p = allocate(64, size);
|
||||
solver->rhs = allocate(64, size);
|
||||
solver->f = allocate(64, size);
|
||||
solver->g = allocate(64, size);
|
||||
|
||||
for (int i = 0; i < (imax + 2) * (jmax + 2); i++) {
|
||||
solver->u[i] = params->u_init;
|
||||
solver->v[i] = params->v_init;
|
||||
solver->p[i] = params->p_init;
|
||||
solver->rhs[i] = 0.0;
|
||||
solver->f[i] = 0.0;
|
||||
solver->g[i] = 0.0;
|
||||
solver->s[i] = NONE;
|
||||
}
|
||||
|
||||
double dx = solver->dx;
|
||||
double dy = solver->dy;
|
||||
double invSqrSum = 1.0 / (dx * dx) + 1.0 / (dy * dy);
|
||||
solver->dtBound = 0.5 * solver->re * 1.0 / invSqrSum;
|
||||
|
||||
double xCenter = 0, yCenter = 0, radius = 0;
|
||||
double x1 = 0, x2 = 0, y1 = 0, y2 = 0;
|
||||
|
||||
int* s = solver->s;
|
||||
|
||||
switch (params->shape) {
|
||||
case NOSHAPE:
|
||||
break;
|
||||
case RECT:
|
||||
x1 = params->xCenter - params->xRectLength / 2;
|
||||
x2 = params->xCenter + params->xRectLength / 2;
|
||||
y1 = params->yCenter - params->yRectLength / 2;
|
||||
y2 = params->yCenter + params->yRectLength / 2;
|
||||
|
||||
for (int j = 1; j < jmax + 1; j++) {
|
||||
for (int i = 1; i < imax + 1; i++) {
|
||||
if ((x1 <= (i * dx)) && ((i * dx) <= x2) && (y1 <= (j * dy)) &&
|
||||
((j * dy) <= y2)) {
|
||||
S(i, j) = LOCAL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case CIRCLE:
|
||||
xCenter = params->xCenter;
|
||||
yCenter = params->yCenter;
|
||||
radius = params->circleRadius;
|
||||
|
||||
for (int j = 1; j < jmax + 1; j++) {
|
||||
for (int i = 1; i < imax + 1; i++) {
|
||||
if (distance((i * dx), (j * dy), xCenter, yCenter) <= radius) {
|
||||
S(i, j) = LOCAL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
for (int j = 1; j < jmax + 1; j++) {
|
||||
for (int i = 1; i < imax + 1; i++) {
|
||||
// if( S(i+1,j+1) == NONE && S(i+1,j) == NONE && S(i,j+1) == NONE &&
|
||||
// S(i-1,j-1) == LOCAL && S(i,j) == LOCAL ) S(i,j) = BOTTOMRIGHT; else if(
|
||||
// S(i-1,j+1) == NONE && S(i-1,j) == NONE && S(i,j+1) == NONE && S(i+1,j-1) ==
|
||||
// LOCAL && S(i,j) == LOCAL ) S(i,j) = BOTTOMLEFT; else if( S(i+1,j-1) == NONE
|
||||
// && S(i,j-1) == NONE && S(i+1,j) == NONE && S(i-1,j+1) == LOCAL && S(i,j) ==
|
||||
// LOCAL ) S(i,j) = TOPRIGHT; else if( S(i-1,j-1) == NONE && S(i,j-1) == NONE
|
||||
// && S(i-1,j) == NONE && S(i+1,j+1) == LOCAL && S(i,j) == LOCAL ) S(i,j) =
|
||||
// TOPLEFT; else if( S(i+1,j) == NONE && S(i-1,j) == LOCAL && S(i,j) == LOCAL
|
||||
// ) S(i,j) = RIGHT; else if( S(i,j+1) == NONE && S(i,j-1) == LOCAL && S(i,j)
|
||||
// == LOCAL ) S(i,j) = BOTTOM; else if( S(i-1,j) == NONE && S(i+1,j) == LOCAL
|
||||
// && S(i,j) == LOCAL ) S(i,j) = LEFT; else if( S(i,j-1) == NONE && S(i,j+1)
|
||||
// == LOCAL && S(i,j) == LOCAL ) S(i,j) = TOP;
|
||||
|
||||
if (S(i, j - 1) == NONE && S(i, j + 1) == LOCAL && S(i, j) == LOCAL)
|
||||
S(i, j) = BOTTOM; // TOP
|
||||
if (S(i - 1, j) == NONE && S(i + 1, j) == LOCAL && S(i, j) == LOCAL)
|
||||
S(i, j) = LEFT; // LEFT
|
||||
if (S(i + 1, j) == NONE && S(i - 1, j) == LOCAL && S(i, j) == LOCAL)
|
||||
S(i, j) = RIGHT; // RIGHT
|
||||
if (S(i, j + 1) == NONE && S(i, j - 1) == LOCAL && S(i, j) == LOCAL)
|
||||
S(i, j) = TOP; // BOTTOM
|
||||
if (S(i - 1, j - 1) == NONE && S(i, j - 1) == NONE && S(i - 1, j) == NONE &&
|
||||
S(i + 1, j + 1) == LOCAL &&
|
||||
(S(i, j) == LOCAL || S(i, j) == LEFT || S(i, j) == BOTTOM))
|
||||
S(i, j) = BOTTOMLEFT; // TOPLEFT
|
||||
if (S(i + 1, j - 1) == NONE && S(i, j - 1) == NONE && S(i + 1, j) == NONE &&
|
||||
S(i - 1, j + 1) == LOCAL &&
|
||||
(S(i, j) == LOCAL || S(i, j) == RIGHT || S(i, j) == BOTTOM))
|
||||
S(i, j) = BOTTOMRIGHT; // TOPRIGHT
|
||||
if (S(i - 1, j + 1) == NONE && S(i - 1, j) == NONE && S(i, j + 1) == NONE &&
|
||||
S(i + 1, j - 1) == LOCAL &&
|
||||
(S(i, j) == LOCAL || S(i, j) == LEFT || S(i, j) == TOP))
|
||||
S(i, j) = TOPLEFT; // BOTTOMLEFT
|
||||
if (S(i + 1, j + 1) == NONE && S(i + 1, j) == NONE && S(i, j + 1) == NONE &&
|
||||
S(i - 1, j - 1) == LOCAL &&
|
||||
(S(i, j) == LOCAL || S(i, j) == RIGHT || S(i, j) == TOP))
|
||||
S(i, j) = TOPRIGHT; // BOTTOMRIGHT
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef VERBOSE
|
||||
printConfig(solver);
|
||||
#endif
|
||||
}
|
||||
|
||||
void computeRHS(Solver* solver)
|
||||
{
|
||||
int imax = solver->imax;
|
||||
int jmax = solver->jmax;
|
||||
double idx = 1.0 / solver->dx;
|
||||
double idy = 1.0 / solver->dy;
|
||||
double idt = 1.0 / solver->dt;
|
||||
double* rhs = solver->rhs;
|
||||
double* f = solver->f;
|
||||
double* g = solver->g;
|
||||
int* s = solver->s;
|
||||
|
||||
for (int j = 1; j < jmax + 1; j++) {
|
||||
for (int i = 1; i < imax + 1; i++) {
|
||||
// if(S(i,j) == NONE)
|
||||
RHS(i, j) = idt *
|
||||
((F(i, j) - F(i - 1, j)) * idx + (G(i, j) - G(i, j - 1)) * idy);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void solve(Solver* solver)
|
||||
{
|
||||
int imax = solver->imax;
|
||||
int jmax = solver->jmax;
|
||||
double eps = solver->eps;
|
||||
int itermax = solver->itermax;
|
||||
double dx2 = solver->dx * solver->dx;
|
||||
double dy2 = solver->dy * solver->dy;
|
||||
double idx2 = 1.0 / dx2;
|
||||
double idy2 = 1.0 / dy2;
|
||||
double factor = solver->omega * 0.5 * (dx2 * dy2) / (dx2 + dy2);
|
||||
double* p = solver->p;
|
||||
double* rhs = solver->rhs;
|
||||
double epssq = eps * eps;
|
||||
int it = 0;
|
||||
double res = 1.0;
|
||||
|
||||
while ((res >= epssq) && (it < itermax)) {
|
||||
|
||||
for (int j = 1; j < jmax + 1; j++) {
|
||||
for (int i = 1; i < imax + 1; i++) {
|
||||
|
||||
double r = RHS(i, j) -
|
||||
((P(i + 1, j) - 2.0 * P(i, j) + P(i - 1, j)) * idx2 +
|
||||
(P(i, j + 1) - 2.0 * P(i, j) + P(i, j - 1)) * idy2);
|
||||
|
||||
P(i, j) -= (factor * r);
|
||||
res += (r * r);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 1; i < imax + 1; i++) {
|
||||
P(i, 0) = P(i, 1);
|
||||
P(i, jmax + 1) = P(i, jmax);
|
||||
}
|
||||
|
||||
for (int j = 1; j < jmax + 1; j++) {
|
||||
P(0, j) = P(1, j);
|
||||
P(imax + 1, j) = P(imax, j);
|
||||
}
|
||||
|
||||
res = res / (double)(imax * jmax);
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("%d Residuum: %e\n", it, res);
|
||||
#endif
|
||||
it++;
|
||||
}
|
||||
#ifdef VERBOSE
|
||||
printf("Solver took %d iterations to reach %f\n", it, sqrt(res));
|
||||
#endif
|
||||
}
|
||||
|
||||
void solveRB(Solver* solver)
|
||||
{
|
||||
int imax = solver->imax;
|
||||
int jmax = solver->jmax;
|
||||
double eps = solver->eps;
|
||||
int itermax = solver->itermax;
|
||||
double dx2 = solver->dx * solver->dx;
|
||||
double dy2 = solver->dy * solver->dy;
|
||||
double idx2 = 1.0 / dx2;
|
||||
double idy2 = 1.0 / dy2;
|
||||
double factor = solver->omega * 0.5 * (dx2 * dy2) / (dx2 + dy2);
|
||||
double* p = solver->p;
|
||||
int* s = solver->s;
|
||||
double* rhs = solver->rhs;
|
||||
double epssq = eps * eps;
|
||||
int it = 0;
|
||||
double res = 1.0;
|
||||
double val = 1.0;
|
||||
int pass, jsw, isw;
|
||||
|
||||
while ((res >= epssq) && (it < itermax)) {
|
||||
res = 0.0;
|
||||
jsw = 1;
|
||||
|
||||
for (int i = 1; i < imax + 1; i++) {
|
||||
P(i, 0) = P(i, 1);
|
||||
P(i, jmax + 1) = P(i, jmax);
|
||||
}
|
||||
|
||||
for (int j = 1; j < jmax + 1; j++) {
|
||||
P(0, j) = P(1, j);
|
||||
P(imax + 1, j) = P(imax, j);
|
||||
}
|
||||
|
||||
// setObjectPBoundaryCondition(solver);
|
||||
|
||||
for (pass = 0; pass < 2; pass++) {
|
||||
isw = jsw;
|
||||
|
||||
for (int j = 1; j < jmax + 1; j++) {
|
||||
for (int i = isw; i < imax + 1; i += 2) {
|
||||
// if(S(i,j) == NONE)
|
||||
// {
|
||||
double r = RHS(i, j) -
|
||||
((P(i + 1, j) - 2.0 * P(i, j) + P(i - 1, j)) * idx2 +
|
||||
(P(i, j + 1) - 2.0 * P(i, j) + P(i, j - 1)) * idy2);
|
||||
|
||||
P(i, j) -= (factor * r);
|
||||
|
||||
res += (r * r);
|
||||
// }
|
||||
}
|
||||
isw = 3 - isw;
|
||||
}
|
||||
jsw = 3 - jsw;
|
||||
}
|
||||
|
||||
res = res / (double)(imax * jmax);
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("%d Residuum: %e\n", it, res);
|
||||
#endif
|
||||
|
||||
it++;
|
||||
}
|
||||
#ifdef VERBOSE
|
||||
printf("Solver took %d iterations to reach %f\n", it, sqrt(res));
|
||||
#endif
|
||||
}
|
||||
|
||||
void solveRBA(Solver* solver)
|
||||
{
|
||||
int imax = solver->imax;
|
||||
int jmax = solver->jmax;
|
||||
double eps = solver->eps;
|
||||
int itermax = solver->itermax;
|
||||
double dx2 = solver->dx * solver->dx;
|
||||
double dy2 = solver->dy * solver->dy;
|
||||
double idx2 = 1.0 / dx2;
|
||||
double idy2 = 1.0 / dy2;
|
||||
double factor = 0.5 * (dx2 * dy2) / (dx2 + dy2);
|
||||
double* p = solver->p;
|
||||
double* rhs = solver->rhs;
|
||||
double epssq = eps * eps;
|
||||
double rho = solver->rho;
|
||||
int it = 0;
|
||||
double res = 1.0;
|
||||
int pass, jsw, isw;
|
||||
double omega = 1.0;
|
||||
|
||||
while ((res >= epssq) && (it < itermax)) {
|
||||
res = 0.0;
|
||||
jsw = 1;
|
||||
|
||||
for (pass = 0; pass < 2; pass++) {
|
||||
isw = jsw;
|
||||
|
||||
for (int j = 1; j < jmax + 1; j++) {
|
||||
for (int i = isw; i < imax + 1; i += 2) {
|
||||
|
||||
double r = RHS(i, j) -
|
||||
((P(i + 1, j) - 2.0 * P(i, j) + P(i - 1, j)) * idx2 +
|
||||
(P(i, j + 1) - 2.0 * P(i, j) + P(i, j - 1)) * idy2);
|
||||
|
||||
P(i, j) -= (omega * factor * r);
|
||||
res += (r * r);
|
||||
}
|
||||
isw = 3 - isw;
|
||||
}
|
||||
jsw = 3 - jsw;
|
||||
omega = (it == 0 && pass == 0 ? 1.0 / (1.0 - 0.5 * rho * rho)
|
||||
: 1.0 / (1.0 - 0.25 * rho * rho * omega));
|
||||
}
|
||||
|
||||
for (int i = 1; i < imax + 1; i++) {
|
||||
P(i, 0) = P(i, 1);
|
||||
P(i, jmax + 1) = P(i, jmax);
|
||||
}
|
||||
|
||||
for (int j = 1; j < jmax + 1; j++) {
|
||||
P(0, j) = P(1, j);
|
||||
P(imax + 1, j) = P(imax, j);
|
||||
}
|
||||
|
||||
res = res / (double)(imax * jmax);
|
||||
#ifdef DEBUG
|
||||
printf("%d Residuum: %e\n", it, res);
|
||||
#endif
|
||||
it++;
|
||||
}
|
||||
|
||||
#ifdef VERBOSE
|
||||
printf("Solver took %d iterations to reach %f\n", it, sqrt(res));
|
||||
#endif
|
||||
}
|
||||
|
||||
static double maxElement(Solver* solver, double* m)
|
||||
{
|
||||
int size = (solver->imax + 2) * (solver->jmax + 2);
|
||||
double maxval = DBL_MIN;
|
||||
|
||||
for (int i = 0; i < size; i++) {
|
||||
maxval = MAX(maxval, fabs(m[i]));
|
||||
}
|
||||
|
||||
return maxval;
|
||||
}
|
||||
|
||||
void normalizePressure(Solver* solver)
|
||||
{
|
||||
int size = (solver->imax + 2) * (solver->jmax + 2);
|
||||
double* p = solver->p;
|
||||
double avgP = 0.0;
|
||||
|
||||
for (int i = 0; i < size; i++) {
|
||||
avgP += p[i];
|
||||
}
|
||||
avgP /= size;
|
||||
|
||||
for (int i = 0; i < size; i++) {
|
||||
p[i] = p[i] - avgP;
|
||||
}
|
||||
}
|
||||
|
||||
void computeTimestep(Solver* solver)
|
||||
{
|
||||
double dt = solver->dtBound;
|
||||
double dx = solver->dx;
|
||||
double dy = solver->dy;
|
||||
double umax = maxElement(solver, solver->u);
|
||||
double vmax = maxElement(solver, solver->v);
|
||||
|
||||
if (umax > 0) {
|
||||
dt = (dt > dx / umax) ? dx / umax : dt;
|
||||
}
|
||||
if (vmax > 0) {
|
||||
dt = (dt > dy / vmax) ? dy / vmax : dt;
|
||||
}
|
||||
|
||||
solver->dt = dt * solver->tau;
|
||||
}
|
||||
|
||||
void setBoundaryConditions(Solver* solver)
|
||||
{
|
||||
int imax = solver->imax;
|
||||
int jmax = solver->jmax;
|
||||
double* u = solver->u;
|
||||
double* v = solver->v;
|
||||
|
||||
// Left boundary
|
||||
switch (solver->bcLeft) {
|
||||
case NOSLIP:
|
||||
for (int j = 1; j < jmax + 1; j++) {
|
||||
U(0, j) = 0.0;
|
||||
V(0, j) = -V(1, j);
|
||||
}
|
||||
break;
|
||||
case SLIP:
|
||||
for (int j = 1; j < jmax + 1; j++) {
|
||||
U(0, j) = 0.0;
|
||||
V(0, j) = V(1, j);
|
||||
}
|
||||
break;
|
||||
case OUTFLOW:
|
||||
for (int j = 1; j < jmax + 1; j++) {
|
||||
U(0, j) = U(1, j);
|
||||
V(0, j) = V(1, j);
|
||||
}
|
||||
break;
|
||||
case PERIODIC:
|
||||
break;
|
||||
}
|
||||
|
||||
// Right boundary
|
||||
switch (solver->bcRight) {
|
||||
case NOSLIP:
|
||||
for (int j = 1; j < jmax + 1; j++) {
|
||||
U(imax, j) = 0.0;
|
||||
V(imax + 1, j) = -V(imax, j);
|
||||
}
|
||||
break;
|
||||
case SLIP:
|
||||
for (int j = 1; j < jmax + 1; j++) {
|
||||
U(imax, j) = 0.0;
|
||||
V(imax + 1, j) = V(imax, j);
|
||||
}
|
||||
break;
|
||||
case OUTFLOW:
|
||||
for (int j = 1; j < jmax + 1; j++) {
|
||||
U(imax, j) = U(imax - 1, j);
|
||||
V(imax + 1, j) = V(imax, j);
|
||||
}
|
||||
break;
|
||||
case PERIODIC:
|
||||
break;
|
||||
}
|
||||
|
||||
// Bottom boundary
|
||||
switch (solver->bcBottom) {
|
||||
case NOSLIP:
|
||||
for (int i = 1; i < imax + 1; i++) {
|
||||
V(i, 0) = 0.0;
|
||||
U(i, 0) = -U(i, 1);
|
||||
}
|
||||
break;
|
||||
case SLIP:
|
||||
for (int i = 1; i < imax + 1; i++) {
|
||||
V(i, 0) = 0.0;
|
||||
U(i, 0) = U(i, 1);
|
||||
}
|
||||
break;
|
||||
case OUTFLOW:
|
||||
for (int i = 1; i < imax + 1; i++) {
|
||||
U(i, 0) = U(i, 1);
|
||||
V(i, 0) = V(i, 1);
|
||||
}
|
||||
break;
|
||||
case PERIODIC:
|
||||
break;
|
||||
}
|
||||
|
||||
// Top boundary
|
||||
switch (solver->bcTop) {
|
||||
case NOSLIP:
|
||||
for (int i = 1; i < imax + 1; i++) {
|
||||
V(i, jmax) = 0.0;
|
||||
U(i, jmax + 1) = -U(i, jmax);
|
||||
}
|
||||
break;
|
||||
case SLIP:
|
||||
for (int i = 1; i < imax + 1; i++) {
|
||||
V(i, jmax) = 0.0;
|
||||
U(i, jmax + 1) = U(i, jmax);
|
||||
}
|
||||
break;
|
||||
case OUTFLOW:
|
||||
for (int i = 1; i < imax + 1; i++) {
|
||||
U(i, jmax + 1) = U(i, jmax);
|
||||
V(i, jmax) = V(i, jmax - 1);
|
||||
}
|
||||
break;
|
||||
case PERIODIC:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void setSpecialBoundaryCondition(Solver* solver)
|
||||
{
|
||||
int imax = solver->imax;
|
||||
int jmax = solver->jmax;
|
||||
double mDy = solver->dy;
|
||||
double* u = solver->u;
|
||||
int* s = solver->s;
|
||||
|
||||
if (strcmp(solver->problem, "dcavity") == 0) {
|
||||
for (int i = 1; i < imax; i++) {
|
||||
U(i, jmax + 1) = 2.0 - U(i, jmax);
|
||||
}
|
||||
} else if (strcmp(solver->problem, "canal") == 0) {
|
||||
double ylength = solver->ylength;
|
||||
double y;
|
||||
|
||||
for (int j = 1; j < jmax + 1; j++) {
|
||||
y = mDy * (j - 0.5);
|
||||
U(0, j) = y * (ylength - y) * 4.0 / (ylength * ylength);
|
||||
}
|
||||
} else if (strcmp(solver->problem, "backstep") == 0) {
|
||||
for (int j = 1; j < jmax + 1; j++) {
|
||||
if (S(0, j) == NONE) U(0, j) = 1.0;
|
||||
}
|
||||
} else if (strcmp(solver->problem, "karman") == 0) {
|
||||
for (int j = 1; j < jmax + 1; j++) {
|
||||
U(0, j) = 1.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void setObjectBoundaryCondition(Solver* solver)
|
||||
{
|
||||
int imax = solver->imax;
|
||||
int jmax = solver->jmax;
|
||||
double* u = solver->u;
|
||||
double* v = solver->v;
|
||||
int* s = solver->s;
|
||||
|
||||
for (int j = 1; j < jmax + 1; j++) {
|
||||
for (int i = 1; i < imax + 1; i++) {
|
||||
switch (S(i, j)) {
|
||||
case TOP:
|
||||
U(i, j) = -U(i, j + 1);
|
||||
U(i - 1, j) = -U(i - 1, j + 1);
|
||||
V(i, j) = 0.0;
|
||||
break;
|
||||
case BOTTOM:
|
||||
U(i, j) = -U(i, j - 1);
|
||||
U(i - 1, j) = -U(i - 1, j - 1);
|
||||
V(i, j) = 0.0;
|
||||
break;
|
||||
case LEFT:
|
||||
U(i - 1, j) = 0.0;
|
||||
V(i, j) = -V(i - 1, j);
|
||||
V(i, j - 1) = -V(i - 1, j - 1);
|
||||
break;
|
||||
case RIGHT:
|
||||
U(i, j) = 0.0;
|
||||
V(i, j) = -V(i + 1, j);
|
||||
V(i, j - 1) = -V(i + 1, j - 1);
|
||||
break;
|
||||
case TOPLEFT:
|
||||
U(i, j) = -U(i, j + 1);
|
||||
U(i - 1, j) = 0.0;
|
||||
V(i, j) = 0.0;
|
||||
V(i, j - 1) = -V(i - 1, j - 1);
|
||||
break;
|
||||
case TOPRIGHT:
|
||||
U(i, j) = 0.0;
|
||||
U(i - 1, j) = -U(i - 1, j + 1);
|
||||
V(i, j) = 0.0;
|
||||
V(i, j - 1) = -V(i + 1, j - 1);
|
||||
break;
|
||||
case BOTTOMLEFT:
|
||||
U(i, j) = -U(i, j - 1);
|
||||
U(i - 1, j) = 0.0;
|
||||
V(i, j) = -V(i - 1, j);
|
||||
V(i, j - 1) = 0.0;
|
||||
break;
|
||||
case BOTTOMRIGHT:
|
||||
U(i, j) = 0.0;
|
||||
U(i - 1, j) = -U(i - 1, j - 1);
|
||||
V(i, j) = -V(i, j + 1);
|
||||
V(i, j - 1) = 0.0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void setObjectPBoundaryCondition(Solver* solver)
|
||||
{
|
||||
int imax = solver->imax;
|
||||
int jmax = solver->jmax;
|
||||
|
||||
double* p = solver->p;
|
||||
int* s = solver->s;
|
||||
|
||||
for (int j = 1; j < jmax + 1; j++) {
|
||||
for (int i = 1; i < imax + 1; i++) {
|
||||
switch (S(i, j)) {
|
||||
case TOP:
|
||||
P(i, j) = P(i, j + 1);
|
||||
break;
|
||||
case BOTTOM:
|
||||
P(i, j) = P(i, j - 1);
|
||||
break;
|
||||
case LEFT:
|
||||
P(i, j) = P(i - 1, j);
|
||||
break;
|
||||
case RIGHT:
|
||||
P(i, j) = P(i, j + 1);
|
||||
break;
|
||||
case TOPLEFT:
|
||||
P(i, j) = (P(i - 1, j) + P(i, j + 1)) / 2;
|
||||
break;
|
||||
case TOPRIGHT:
|
||||
P(i, j) = (P(i + 1, j) + P(i, j + 1)) / 2;
|
||||
break;
|
||||
case BOTTOMLEFT:
|
||||
P(i, j) = (P(i - 1, j) + P(i, j - 1)) / 2;
|
||||
break;
|
||||
case BOTTOMRIGHT:
|
||||
P(i, j) = (P(i + 1, j) + P(i, j - 1)) / 2;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void computeFG(Solver* solver)
|
||||
{
|
||||
double* u = solver->u;
|
||||
double* v = solver->v;
|
||||
double* f = solver->f;
|
||||
double* g = solver->g;
|
||||
int* s = solver->s;
|
||||
int imax = solver->imax;
|
||||
int jmax = solver->jmax;
|
||||
double gx = solver->gx;
|
||||
double gy = solver->gy;
|
||||
double gamma = solver->gamma;
|
||||
double dt = solver->dt;
|
||||
double inverseRe = 1.0 / solver->re;
|
||||
double inverseDx = 1.0 / solver->dx;
|
||||
double inverseDy = 1.0 / solver->dy;
|
||||
double du2dx, dv2dy, duvdx, duvdy;
|
||||
double du2dx2, du2dy2, dv2dx2, dv2dy2;
|
||||
|
||||
for (int j = 1; j < jmax + 1; j++) {
|
||||
for (int i = 1; i < imax + 1; i++) {
|
||||
if (S(i, j) == NONE) {
|
||||
du2dx = inverseDx * 0.25 *
|
||||
((U(i, j) + U(i + 1, j)) * (U(i, j) + U(i + 1, j)) -
|
||||
(U(i, j) + U(i - 1, j)) * (U(i, j) + U(i - 1, j))) +
|
||||
gamma * inverseDx * 0.25 *
|
||||
(fabs(U(i, j) + U(i + 1, j)) * (U(i, j) - U(i + 1, j)) +
|
||||
fabs(U(i, j) + U(i - 1, j)) * (U(i, j) - U(i - 1, j)));
|
||||
|
||||
duvdy = inverseDy * 0.25 *
|
||||
((V(i, j) + V(i + 1, j)) * (U(i, j) + U(i, j + 1)) -
|
||||
(V(i, j - 1) + V(i + 1, j - 1)) *
|
||||
(U(i, j) + U(i, j - 1))) +
|
||||
gamma * inverseDy * 0.25 *
|
||||
(fabs(V(i, j) + V(i + 1, j)) * (U(i, j) - U(i, j + 1)) +
|
||||
fabs(V(i, j - 1) + V(i + 1, j - 1)) *
|
||||
(U(i, j) - U(i, j - 1)));
|
||||
|
||||
du2dx2 = inverseDx * inverseDx *
|
||||
(U(i + 1, j) - 2.0 * U(i, j) + U(i - 1, j));
|
||||
du2dy2 = inverseDy * inverseDy *
|
||||
(U(i, j + 1) - 2.0 * U(i, j) + U(i, j - 1));
|
||||
F(i, j) = U(i, j) +
|
||||
dt * (inverseRe * (du2dx2 + du2dy2) - du2dx - duvdy + gx);
|
||||
|
||||
duvdx = inverseDx * 0.25 *
|
||||
((U(i, j) + U(i, j + 1)) * (V(i, j) + V(i + 1, j)) -
|
||||
(U(i - 1, j) + U(i - 1, j + 1)) *
|
||||
(V(i, j) + V(i - 1, j))) +
|
||||
gamma * inverseDx * 0.25 *
|
||||
(fabs(U(i, j) + U(i, j + 1)) * (V(i, j) - V(i + 1, j)) +
|
||||
fabs(U(i - 1, j) + U(i - 1, j + 1)) *
|
||||
(V(i, j) - V(i - 1, j)));
|
||||
|
||||
dv2dy = inverseDy * 0.25 *
|
||||
((V(i, j) + V(i, j + 1)) * (V(i, j) + V(i, j + 1)) -
|
||||
(V(i, j) + V(i, j - 1)) * (V(i, j) + V(i, j - 1))) +
|
||||
gamma * inverseDy * 0.25 *
|
||||
(fabs(V(i, j) + V(i, j + 1)) * (V(i, j) - V(i, j + 1)) +
|
||||
fabs(V(i, j) + V(i, j - 1)) * (V(i, j) - V(i, j - 1)));
|
||||
|
||||
dv2dx2 = inverseDx * inverseDx *
|
||||
(V(i + 1, j) - 2.0 * V(i, j) + V(i - 1, j));
|
||||
dv2dy2 = inverseDy * inverseDy *
|
||||
(V(i, j + 1) - 2.0 * V(i, j) + V(i, j - 1));
|
||||
G(i, j) = V(i, j) +
|
||||
dt * (inverseRe * (dv2dx2 + dv2dy2) - duvdx - dv2dy + gy);
|
||||
} else {
|
||||
switch (S(i, j)) {
|
||||
case TOP:
|
||||
G(i, j) = V(i, j);
|
||||
break;
|
||||
case BOTTOM:
|
||||
G(i, j - 1) = V(i, j - 1);
|
||||
break;
|
||||
case LEFT:
|
||||
F(i - 1, j) = U(i - 1, j);
|
||||
break;
|
||||
case RIGHT:
|
||||
F(i, j) = U(i, j);
|
||||
break;
|
||||
case TOPLEFT:
|
||||
F(i - 1, j) = U(i - 1, j);
|
||||
G(i, j) = V(i, j);
|
||||
break;
|
||||
case TOPRIGHT:
|
||||
F(i, j) = U(i, j);
|
||||
G(i, j) = V(i, j);
|
||||
break;
|
||||
case BOTTOMLEFT:
|
||||
F(i - 1, j) = U(i - 1, j);
|
||||
G(i, j - 1) = V(i, j - 1);
|
||||
break;
|
||||
case BOTTOMRIGHT:
|
||||
F(i, j) = U(i, j);
|
||||
G(i, j - 1) = V(i, j - 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------- boundary of F --------------------------- */
|
||||
for (int j = 1; j < jmax + 1; j++) {
|
||||
F(0, j) = U(0, j);
|
||||
F(imax, j) = U(imax, j);
|
||||
}
|
||||
|
||||
/* ---------------------- boundary of G --------------------------- */
|
||||
for (int i = 1; i < imax + 1; i++) {
|
||||
G(i, 0) = V(i, 0);
|
||||
G(i, jmax) = V(i, jmax);
|
||||
}
|
||||
}
|
||||
|
||||
void adaptUV(Solver* solver)
|
||||
{
|
||||
int imax = solver->imax;
|
||||
int jmax = solver->jmax;
|
||||
double* p = solver->p;
|
||||
double* u = solver->u;
|
||||
double* v = solver->v;
|
||||
int* s = solver->s;
|
||||
double* f = solver->f;
|
||||
double* g = solver->g;
|
||||
double factorX = solver->dt / solver->dx;
|
||||
double factorY = solver->dt / solver->dy;
|
||||
|
||||
double val = 0;
|
||||
|
||||
for (int j = 1; j < jmax + 1; j++) {
|
||||
for (int i = 1; i < imax + 1; i++) {
|
||||
U(i, j) = F(i, j) - (P(i + 1, j) - P(i, j)) * factorX;
|
||||
V(i, j) = G(i, j) - (P(i, j + 1) - P(i, j)) * factorY;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void writeResult(Solver* solver)
|
||||
{
|
||||
int imax = solver->imax;
|
||||
int jmax = solver->jmax;
|
||||
double dx = solver->dx;
|
||||
double dy = solver->dy;
|
||||
double* p = solver->p;
|
||||
double* u = solver->u;
|
||||
double* v = solver->v;
|
||||
double x = 0.0, y = 0.0;
|
||||
|
||||
FILE* fp;
|
||||
fp = fopen("pressure.dat", "w");
|
||||
|
||||
if (fp == NULL) {
|
||||
printf("Error!\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
for (int j = 1; j < jmax + 1; j++) {
|
||||
y = (double)(j - 0.5) * dy;
|
||||
for (int i = 1; i < imax + 1; i++) {
|
||||
x = (double)(i - 0.5) * dx;
|
||||
fprintf(fp, "%.2f %.2f %f\n", x, y, P(i, j));
|
||||
}
|
||||
fprintf(fp, "\n");
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
|
||||
fp = fopen("velocity.dat", "w");
|
||||
|
||||
if (fp == NULL) {
|
||||
printf("Error!\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
for (int j = 1; j < jmax + 1; j++) {
|
||||
y = dy * (j - 0.5);
|
||||
for (int i = 1; i < imax + 1; i++) {
|
||||
x = dx * (i - 0.5);
|
||||
double vel_u = (U(i, j) + U(i - 1, j)) / 2.0;
|
||||
double vel_v = (V(i, j) + V(i, j - 1)) / 2.0;
|
||||
double len = sqrt((vel_u * vel_u) + (vel_v * vel_v));
|
||||
fprintf(fp, "%.2f %.2f %f %f %f\n", x, y, vel_u, vel_v, len);
|
||||
}
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
}
|
@@ -1,66 +1,26 @@
|
||||
/*
|
||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
||||
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||
* All rights reserved. This file is part of nusif-solver.
|
||||
* Use of this source code is governed by a MIT style
|
||||
* license that can be found in the LICENSE file.
|
||||
*/
|
||||
#ifndef __SOLVER_H_
|
||||
#define __SOLVER_H_
|
||||
#include "discretization.h"
|
||||
#include "grid.h"
|
||||
#include "parameter.h"
|
||||
|
||||
enum OBJECTBOUNDARY {
|
||||
NONE = 0,
|
||||
TOP,
|
||||
BOTTOM,
|
||||
LEFT,
|
||||
RIGHT,
|
||||
TOPLEFT,
|
||||
BOTTOMLEFT,
|
||||
TOPRIGHT,
|
||||
BOTTOMRIGHT,
|
||||
LOCAL
|
||||
};
|
||||
enum BC { NOSLIP = 1, SLIP, OUTFLOW, PERIODIC };
|
||||
/// @brief
|
||||
enum SHAPE { NOSHAPE = 0, RECT, CIRCLE };
|
||||
|
||||
typedef struct {
|
||||
/* geometry and grid information */
|
||||
double dx, dy;
|
||||
int imax, jmax;
|
||||
double xlength, ylength;
|
||||
/* arrays */
|
||||
double *p, *rhs;
|
||||
double *f, *g;
|
||||
double *u, *v;
|
||||
int* s;
|
||||
Grid* grid;
|
||||
/* parameters */
|
||||
double eps, omega, rho;
|
||||
double re, tau, gamma;
|
||||
double gx, gy;
|
||||
/* time stepping */
|
||||
int itermax;
|
||||
double dt, te;
|
||||
double dtBound;
|
||||
char* problem;
|
||||
int bcLeft, bcRight, bcBottom, bcTop;
|
||||
int levels;
|
||||
double **r, **e;
|
||||
} Solver;
|
||||
|
||||
extern void initSolver(Solver*, Parameter*);
|
||||
extern void computeRHS(Solver*);
|
||||
extern void solve(Solver*);
|
||||
extern void solveRB(Solver*);
|
||||
extern void solveRBA(Solver*);
|
||||
extern void normalizePressure(Solver*);
|
||||
extern void computeTimestep(Solver*);
|
||||
extern void setBoundaryConditions(Solver*);
|
||||
extern void setSpecialBoundaryCondition(Solver*);
|
||||
extern void setObjectBoundaryCondition(Solver*);
|
||||
extern void setObjectPBoundaryCondition(Solver*);
|
||||
extern void computeFG(Solver*);
|
||||
extern void adaptUV(Solver*);
|
||||
extern void writeResult(Solver*);
|
||||
extern void print(Solver*, double*);
|
||||
extern void printGrid(Solver*, int*);
|
||||
extern void initSolver(Solver*, Discretization*, Parameter*);
|
||||
extern void solve(Solver*, double*, double*);
|
||||
|
||||
#endif
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
||||
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||
* All rights reserved.
|
||||
* Use of this source code is governed by a MIT-style
|
||||
* license that can be found in the LICENSE file.
|
||||
@@ -7,18 +7,16 @@
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
|
||||
double getTimeStamp()
|
||||
double getTimeStamp(void)
|
||||
{
|
||||
struct timespec ts;
|
||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||
return (double)ts.tv_sec + (double)ts.tv_nsec * 1.e-9;
|
||||
}
|
||||
|
||||
double getTimeResolution()
|
||||
double getTimeResolution(void)
|
||||
{
|
||||
struct timespec ts;
|
||||
clock_getres(CLOCK_MONOTONIC, &ts);
|
||||
return (double)ts.tv_sec + (double)ts.tv_nsec * 1.e-9;
|
||||
}
|
||||
|
||||
double getTimeStamp_() { return getTimeStamp(); }
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
||||
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||
* All rights reserved.
|
||||
* Use of this source code is governed by a MIT-style
|
||||
* license that can be found in the LICENSE file.
|
||||
@@ -7,8 +7,7 @@
|
||||
#ifndef __TIMING_H_
|
||||
#define __TIMING_H_
|
||||
|
||||
extern double getTimeStamp();
|
||||
extern double getTimeResolution();
|
||||
extern double getTimeStamp_();
|
||||
extern double getTimeStamp(void);
|
||||
extern double getTimeResolution(void);
|
||||
|
||||
#endif // __TIMING_H_
|
||||
|
@@ -1,16 +1,13 @@
|
||||
/*
|
||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
||||
* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||
* All rights reserved.
|
||||
* Use of this source code is governed by a MIT-style
|
||||
* license that can be found in the LICENSE file.
|
||||
*/
|
||||
#include <math.h>
|
||||
|
||||
#ifndef __UTIL_H_
|
||||
#define __UTIL_H_
|
||||
#define HLINE \
|
||||
"------------------------------------------------------------------------" \
|
||||
"----\n"
|
||||
"----------------------------------------------------------------------------\n"
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(x, y) ((x) < (y) ? (x) : (y))
|
||||
@@ -22,4 +19,11 @@
|
||||
#define ABS(a) ((a) >= 0 ? (a) : -(a))
|
||||
#endif
|
||||
|
||||
#define P(i, j) p[(j) * (imax + 2) + (i)]
|
||||
#define F(i, j) f[(j) * (imax + 2) + (i)]
|
||||
#define G(i, j) g[(j) * (imax + 2) + (i)]
|
||||
#define U(i, j) u[(j) * (imax + 2) + (i)]
|
||||
#define V(i, j) v[(j) * (imax + 2) + (i)]
|
||||
#define RHS(i, j) rhs[(j) * (imax + 2) + (i)]
|
||||
|
||||
#endif // __UTIL_H_
|
||||
|
@@ -1,125 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
||||
* All rights reserved. This file is part of nusif-solver.
|
||||
* Use of this source code is governed by a MIT style
|
||||
* license that can be found in the LICENSE file.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "vtkWriter.h"
|
||||
|
||||
static float floatSwap(float f)
|
||||
{
|
||||
union {
|
||||
float f;
|
||||
char b[4];
|
||||
} dat1, dat2;
|
||||
|
||||
dat1.f = f;
|
||||
dat2.b[0] = dat1.b[3];
|
||||
dat2.b[1] = dat1.b[2];
|
||||
dat2.b[2] = dat1.b[1];
|
||||
dat2.b[3] = dat1.b[0];
|
||||
return dat2.f;
|
||||
}
|
||||
|
||||
static void writeHeader(VtkOptions* o, int ts)
|
||||
{
|
||||
fprintf(o->fh, "# vtk DataFile Version 3.0\n");
|
||||
fprintf(o->fh, "PAMPI cfd solver particle tracing file\n");
|
||||
if (o->fmt == ASCII) {
|
||||
fprintf(o->fh, "ASCII\n");
|
||||
} else if (o->fmt == BINARY) {
|
||||
fprintf(o->fh, "BINARY\n");
|
||||
}
|
||||
|
||||
fprintf(o->fh, "DATASET UNSTRUCTURED_GRID\n");
|
||||
fprintf(o->fh, "FIELD FieldData 2\n");
|
||||
fprintf(o->fh, "TIME 1 1 double\n");
|
||||
fprintf(o->fh, "%d\n", ts);
|
||||
fprintf(o->fh, "CYCLE 1 1 int\n");
|
||||
fprintf(o->fh, "1\n");
|
||||
}
|
||||
|
||||
void vtkOpen(VtkOptions* o, char* problem, int ts)
|
||||
{
|
||||
o->fh = fopen(problem, "w");
|
||||
|
||||
if (o->fh == NULL) {
|
||||
printf("vtkWriter not initialize! Call vtkOpen first!\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
writeHeader(o, ts);
|
||||
|
||||
printf("Writing VTK output for %s\n", problem);
|
||||
}
|
||||
|
||||
void vtkParticle(VtkOptions* o, char* name)
|
||||
{
|
||||
Particle* particlePool = o->particletracer->particlePool;
|
||||
|
||||
int imax = o->particletracer->imax;
|
||||
int jmax = o->particletracer->jmax;
|
||||
|
||||
if (o->fh == NULL) {
|
||||
printf("vtkWriter not initialize! Call vtkOpen first!\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
fprintf(o->fh, "POINTS %d float\n", o->particletracer->totalParticles);
|
||||
|
||||
for (int i = 0; i < o->particletracer->totalParticles; ++i) {
|
||||
double x = particlePool[i].x;
|
||||
double y = particlePool[i].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);
|
||||
|
||||
for (int i = 0; i < o->particletracer->totalParticles; ++i) {
|
||||
fprintf(o->fh, "1 %d\n", i);
|
||||
}
|
||||
|
||||
fprintf(o->fh, "CELL_TYPES %d\n", o->particletracer->totalParticles);
|
||||
|
||||
for (int i = 0; i < o->particletracer->totalParticles; ++i) {
|
||||
fprintf(o->fh, "1\n");
|
||||
}
|
||||
|
||||
/*
|
||||
for (int k = 0; k < kmax; k++) {
|
||||
for (int j = 0; j < jmax; j++) {
|
||||
for (int i = 0; i < imax; i++) {
|
||||
if (o->fmt == ASCII) {
|
||||
fprintf(o->fh,
|
||||
"%f %f %f\n",
|
||||
G(vec.u, i, j, k),
|
||||
G(vec.v, i, j, k),
|
||||
G(vec.w, i, j, k));
|
||||
} else if (o->fmt == BINARY) {
|
||||
fwrite((float[3]) { floatSwap(G(vec.u, i, j, k)),
|
||||
floatSwap(G(vec.v, i, j, k)),
|
||||
floatSwap(G(vec.w, i, j, k)) },
|
||||
sizeof(float),
|
||||
3,
|
||||
o->fh);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (o->fmt == BINARY) fprintf(o->fh, "\n");
|
||||
|
||||
*/
|
||||
}
|
||||
|
||||
void vtkClose(VtkOptions* o)
|
||||
{
|
||||
fclose(o->fh);
|
||||
o->fh = NULL;
|
||||
}
|
@@ -1,25 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
||||
* All rights reserved. This file is part of nusif-solver.
|
||||
* Use of this source code is governed by a MIT style
|
||||
* license that can be found in the LICENSE file.
|
||||
*/
|
||||
#ifndef __VTKWRITER_H_
|
||||
#define __VTKWRITER_H_
|
||||
#include <stdio.h>
|
||||
|
||||
#include "particletracing.h"
|
||||
#include "solver.h"
|
||||
|
||||
typedef enum VtkFormat { ASCII = 0, BINARY } VtkFormat;
|
||||
|
||||
typedef struct VtkOptions {
|
||||
VtkFormat fmt;
|
||||
FILE* fh;
|
||||
ParticleTracer* particletracer;
|
||||
} VtkOptions;
|
||||
|
||||
extern void vtkOpen(VtkOptions* opts, char* filename, int ts);
|
||||
extern void vtkParticle(VtkOptions* opts, char* name);
|
||||
extern void vtkClose(VtkOptions* opts);
|
||||
#endif // __VTKWRITER_H_
|
Reference in New Issue
Block a user