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;
int npoints_local_wghosts
#define _THERMAL_SLIP_WALL_
int MPIBroadcast_double(double *, int, int, void *)
#define _TURBULENT_SUPERSONIC_INFLOW_
double * UnsteadyDirichletData
int BCReadTemperatureData(void *, void *, int, int, int *)
void GetStringFromInteger(int, char *, int)
int gpu_npoints_local_wghosts
Containts the structures and definitions for boundary condition implementation.
void gpuMemcpy(void *, const void *, size_t, enum gpuMemcpyKind)
MPI related function definitions.
#define _SUBSONIC_OUTFLOW_
#define _ArraySubtract1D_(x, a, b, size)
void FindInterval(double, double, double *, int, int *, int *)
#define _MAX_STRING_SIZE_
Structure containing the variables and function pointers defining a boundary.
int * UnsteadyDirichletSize
Contains function definitions for common mathematical functions.
int BCReadTurbulentInflowData(void *, void *, int, int, int *)
#define _SUPERSONIC_INFLOW_
Contains function definitions for common array operations on GPU.
#define _SUBSONIC_INFLOW_
int InitializeBoundaries(void *, int)
#define _SUBSONIC_AMBIVALENT_
int BCInitialize(void *, int)
void gpuMalloc(void **, size_t)
int MPIBroadcast_character(char *, int, int, void *)
Structure defining a simulation.
Some basic definitions and macros.
static int CalculateLocalExtent(void *, void *)
#define _THERMAL_NOSLIP_WALL_
#define _ArrayProduct1D_(x, size, p)
Structure of MPI-related variables.
Structure containing all solver-specific variables and functions.
int MPIBroadcast_integer(int *, int, int, void *)
Some common functions used here and there.