11 #if defined(HAVE_CUDA) 44 for (ns = 0; ns < nsims; ns++) {
59 strcat(filename,
"_");
60 strcat(filename, index);
62 strcat(filename,
".inp");
63 strcat(filename_backup,
".inp");
66 in = fopen(filename,
"r");
68 in = fopen(filename_backup,
"r");
70 fprintf(stderr,
"Error: boundary condition file %s or %s not found.\n",
71 filename, filename_backup );
74 if (nsims > 1) printf(
"Domain %d: ", ns);
75 printf(
"Reading boundary conditions from %s.\n", filename_backup);
78 if (nsims > 1) printf(
"Domain %d: ", ns);
79 printf(
"Reading boundary conditions from %s.\n", filename);
83 ferr = fscanf(in,
"%d",&solver->
nBoundaryZones);
if (ferr != 1)
return(1);
96 boundary[nb].
xmin = (
double*) calloc (solver->
ndims,
sizeof(
double));
97 boundary[nb].
xmax = (
double*) calloc (solver->
ndims,
sizeof(
double));
99 ferr = fscanf(in,
"%s",boundary[nb].bctype);
if (ferr != 1)
return(1);
100 ferr = fscanf(in,
"%d",&boundary[nb].dim );
if (ferr != 1)
return(1);
101 ferr = fscanf(in,
"%d",&boundary[nb].face );
if (ferr != 1)
return(1);
102 for (d=0; d < solver->
ndims; d++) {
103 ferr = fscanf(in,
"%lf %lf", &boundary[nb].xmin[d], &boundary[nb].xmax[d]);
104 if (ferr != 2)
return(1);
113 for (v = 0; v < solver->
nvars; v++) ferr = fscanf(in,
"%lf",&boundary[nb].DirichletValue[v]);
116 if (!strcmp(boundary[nb].bctype,
_SPONGE_)) {
120 for (v = 0; v < solver->
nvars; v++) ferr = fscanf(in,
"%lf",&boundary[nb].SpongeValue[v]);
128 for (v = 0; v < solver->
ndims; v++) ferr = fscanf(in,
"%lf",&boundary[nb].FlowVelocity[v]);
136 for (v = 0; v < solver->
ndims; v++) ferr = fscanf(in,
"%lf",&boundary[nb].FlowVelocity[v]);
143 ferr = fscanf(in,
"%lf",&boundary[nb].FlowDensity);
144 for (v = 0; v < solver->
ndims; v++) ferr = fscanf(in,
"%lf",&boundary[nb].FlowVelocity[v]);
149 ferr = fscanf(in,
"%lf",&boundary[nb].FlowPressure);
156 ferr = fscanf(in,
"%lf",&boundary[nb].FlowDensity);
157 for (v = 0; v < solver->
ndims; v++) ferr = fscanf(in,
"%lf",&boundary[nb].FlowVelocity[v]);
158 ferr = fscanf(in,
"%lf",&boundary[nb].FlowPressure);
165 ferr = fscanf(in,
"%lf",&boundary[nb].FlowDensity);
166 for (v = 0; v < solver->
ndims; v++) ferr = fscanf(in,
"%lf",&boundary[nb].FlowVelocity[v]);
167 ferr = fscanf(in,
"%lf",&boundary[nb].FlowPressure);
174 ferr = fscanf(in,
"%lf",&boundary[nb].FlowDensity);
175 for (v = 0; v < solver->
ndims; v++) ferr = fscanf(in,
"%lf",&boundary[nb].FlowVelocity[v]);
176 ferr = fscanf(in,
"%lf",&boundary[nb].FlowPressure);
177 ferr = fscanf(in,
"%s" , boundary[nb].UnsteadyDirichletFilename);
185 for (v = 0; v < solver->
ndims; v++) ferr = fscanf(in,
"%lf",&boundary[nb].FlowVelocity[v]);
187 ferr = fscanf(in,
"%s" , boundary[nb].UnsteadyTemperatureFilename);
191 if (!strcmp(boundary[nb].bctype,
_PERIODIC_)) {
199 if ((!strcmp(boundary[nb].bctype,
_PERIODIC_)) && (mpi->
iproc[boundary[nb].
dim] > 1)) {
204 if (boundary[nb].dim >= solver->
ndims) {
205 fprintf(stderr,
"Error in reading boundary condition %d: dim %d is invalid (ndims = %d).\n",
206 nb,boundary[nb].dim,solver->
ndims);
209 printf(
" Boundary %30s: Along dimension %2d and face %+1d\n",
210 boundary[nb].bctype,boundary[nb].dim,boundary[nb].face);
214 printf(
"%d boundary condition(s) read.\n",solver->
nBoundaryZones);
222 boundary[nb].
xmin = (
double*) calloc (solver->
ndims,
sizeof(
double));
223 boundary[nb].
xmax = (
double*) calloc (solver->
ndims,
sizeof(
double));
252 if (!strcmp(boundary[nb].bctype,
_SPONGE_)) {
317 #if defined(HAVE_CUDA) 329 gpuMalloc((
void**)&boundary[nb].gpu_is, solver->
ndims*
sizeof(
int));
330 gpuMalloc((
void**)&boundary[nb].gpu_ie, solver->
ndims*
sizeof(
int));
331 gpuMalloc((
void**)&boundary[nb].gpu_bounds, solver->
ndims*
sizeof(
int));
337 gpuMalloc((
void**)&boundary[nb].gpu_FlowVelocity, solver->
ndims*
sizeof(
double));
338 gpuMemcpy( boundary[nb].gpu_FlowVelocity,
339 boundary[nb].FlowVelocity,
340 solver->
ndims*
sizeof(
double),
349 #if defined(HAVE_CUDA) 377 boundary[n].
is = (
int*) calloc (solver->
ndims,
sizeof(
int));
378 boundary[n].
ie = (
int*) calloc (solver->
ndims,
sizeof(
int));
380 int d,dim = boundary[n].
dim;
382 if (!strcmp(boundary[n].bctype,
_SPONGE_)) {
386 for (d=0; d<solver->
ndims; d++) {
389 &solver->
x[offset+solver->
ghosts],
391 boundary[n].
is[d] = is;
392 boundary[n].
ie[d] = ie;
398 if (boundary[n].face == 1) {
400 if (mpi->
ip[dim] == 0) {
403 for (d=0; d<solver->
ndims; d++) {
405 boundary[n].
is[d] = -solver->
ghosts;
406 boundary[n].
ie[d] = 0;
410 &solver->
x[offset+solver->
ghosts],
412 boundary[n].
is[d] = is;
413 boundary[n].
ie[d] = ie;
420 }
else if (boundary[n].face == -1) {
422 if (mpi->
ip[dim] == mpi->
iproc[dim]-1) {
425 for (d=0; d<solver->
ndims; d++) {
432 &solver->
x[offset+solver->
ghosts],
434 boundary[n].
is[d] = is;
435 boundary[n].
ie[d] = ie;
Some common functions used here and there.
#define _SUPERSONIC_INFLOW_
static int CalculateLocalExtent(void *, void *)
int BCInitialize(void *, int)
int * UnsteadyDirichletSize
Containts the structures and definitions for boundary condition implementation.
MPI related function definitions.
Contains function definitions for common array operations on GPU.
Contains function definitions for common mathematical functions.
Structure defining a simulation.
int InitializeBoundaries(void *s, int nsims)
void FindInterval(double, double, double *, int, int *, int *)
#define _SUBSONIC_AMBIVALENT_
int MPIBroadcast_integer(int *, int, int, void *)
Some basic definitions and macros.
#define _THERMAL_SLIP_WALL_
#define _THERMAL_NOSLIP_WALL_
Structure containing the variables and function pointers defining a boundary.
#define _ArraySubtract1D_(x, a, b, size)
double * UnsteadyDirichletData
int MPIBroadcast_character(char *, int, int, void *)
int MPIBroadcast_double(double *, int, int, void *)
Structure containing all solver-specific variables and functions.
void gpuMalloc(void **, size_t)
#define _MAX_STRING_SIZE_
int gpu_npoints_local_wghosts
int BCReadTurbulentInflowData(void *, void *, int, int, int *)
void GetStringFromInteger(int, char *, int)
#define _SUBSONIC_INFLOW_
void gpuMemcpy(void *, const void *, size_t, enum gpuMemcpyKind)
#define _SUBSONIC_OUTFLOW_
Structure of MPI-related variables.
int npoints_local_wghosts
#define _ArrayProduct1D_(x, size, p)
int BCReadTemperatureData(void *, void *, int, int, int *)
#define _TURBULENT_SUPERSONIC_INFLOW_