25 int *inflow_size = NULL;
26 double *inflow_data = NULL;
27 double *buffer = NULL;
29 int dim = boundary->
dim;
30 int face= boundary->
face;
35 printf(
"Reading turbulent inflow boundary data from %s.\n",filename);
42 for (d=0; d<ndims; d++) nproc *= mpi->
iproc[d]; nproc /= mpi->
iproc[dim];
44 in = fopen(filename,
"rb");
46 fprintf(stderr,
"Error in BCReadTurbulentInflowData(): cannot open unsteady boundary data file %s.\n",filename);
50 while ((!feof(in)) && (count < nproc)) {
51 int rank[ndims], size[ndims];
52 ferr = fread(rank,
sizeof(
int),ndims,in);
54 fprintf(stderr,
"Error in BCReadTurbulentInflowData(): Error (1) in file reading, count %d.\n",count);
57 if (rank[dim] != (face > 0 ? 0 : mpi->
iproc[dim]-1) ) {
58 fprintf(stderr,
"Error in BCReadTurbulentInflowData(): Error (2) in file reading, count %d.\n",count);
61 ferr = fread(size,
sizeof(
int),ndims,in);
63 fprintf(stderr,
"Error in BCReadTurbulentInflowData(): Error (3) in file reading, count %d.\n",count);
67 for (d=0; d<ndims; d++)
if ((d != dim) && (size[d] != DomainSize[d])) flag = 0;
69 fprintf(stderr,
"Error in BCReadTurbulentInflowData(): Error (4) (dimension mismatch) in file reading, count %d.\n",count);
73 int data_size = nvars;
74 for (d=0; d<ndims; d++) data_size *= size[d];
75 buffer = (
double*) calloc (data_size,
sizeof(
double));
76 ferr = fread(buffer,
sizeof(
double),data_size,in);
77 if (ferr != data_size) {
78 fprintf(stderr,
"Error in BCReadTurbulentInflowData(): Error (6) in file reading, count %d.\n",count);
87 inflow_size = (
int*) calloc (ndims,
sizeof(
int));
89 inflow_data = (
double*) calloc (data_size,
sizeof(
double));
90 ArrayCopynD(ndims,buffer,inflow_data,size,0,0,index,nvars);
94 MPI_Request req[2] = {MPI_REQUEST_NULL,MPI_REQUEST_NULL};
95 MPI_Isend(size,ndims,MPI_INT,rank1D,2152,mpi->
world,&req[0]);
96 MPI_Isend(buffer,data_size,MPI_DOUBLE,rank1D,2153,mpi->
world,&req[1]);
97 MPI_Status status_arr[3];
98 MPI_Waitall(2,&req[0],status_arr);
100 fprintf(stderr,
"Error in BCReadTurbulentInflowData(): This is a serial run. Invalid (non-zero) rank read.\n");
109 fprintf(stderr,
"Error in BCReadTurbulentInflowData(): missing data in unsteady boundary data file %s.\n",filename);
110 fprintf(stderr,
"Error in BCReadTurbulentInflowData(): should contain data for %d processors, ", nproc);
111 fprintf(stderr,
"Error in BCReadTurbulentInflowData(): but contains data for %d processors!\n", count);
119 if (mpi->
ip[dim] == (face > 0 ? 0 : mpi->
iproc[dim]-1) ) {
120 MPI_Request req = MPI_REQUEST_NULL;
121 inflow_size = (
int*) calloc (ndims,
sizeof(
int));
122 MPI_Irecv(inflow_size,ndims,MPI_INT,0,2152,mpi->
world,&req);
123 MPI_Wait(&req,MPI_STATUS_IGNORE);
124 int data_size = nvars;
125 for (d=0; d<ndims; d++) data_size *= inflow_size[d];
126 inflow_data = (
double*) calloc (data_size,
sizeof(
double));
127 MPI_Irecv(inflow_data,data_size,MPI_DOUBLE,0,2153,mpi->
world,&req);
128 MPI_Wait(&req,MPI_STATUS_IGNORE);
131 fprintf(stderr,
"Error in BCReadTurbulentInflowData(): Serial code should not be here!.\n");
153 int *temperature_field_size = NULL;
154 double *time_level_data = NULL;
155 double *temperature_field_data = NULL;
156 double *time_buffer = NULL;
157 double *data_buffer = NULL;
159 int dim = boundary->
dim;
160 int face= boundary->
face;
165 printf(
"Reading boundary temperature data from %s.\n",filename);
172 for (d=0; d<ndims; d++) nproc *= mpi->
iproc[d]; nproc /= mpi->
iproc[dim];
174 in = fopen(filename,
"rb");
176 fprintf(stderr,
"Error in BCReadTemperatureData(): cannot open boundary temperature data file %s.\n",filename);
181 while ((!feof(in)) && (count < nproc)) {
183 int rank[ndims], size[ndims];
184 ferr = fread(rank,
sizeof(
int),ndims,in);
186 fprintf(stderr,
"Error in BCReadTemperatureData(): Error (1) in file reading, count %d.\n",count);
189 if (rank[dim] != (face > 0 ? 0 : mpi->
iproc[dim]-1) ) {
190 fprintf(stderr,
"Error in BCReadTemperatureData(): Error (2) in file reading, count %d.\n",count);
193 ferr = fread(size,
sizeof(
int),ndims,in);
195 fprintf(stderr,
"Error in BCReadTemperatureData(): Error (3) in file reading, count %d.\n",count);
199 int n_data = size[dim];
200 time_buffer = (
double*) calloc (n_data,
sizeof(
double));
201 ferr = fread(time_buffer,
sizeof(
double),n_data,in);
202 if (ferr != n_data) {
203 fprintf(stderr,
"Error in BCReadTemperatureData(): Error (5) in file reading, count %d.\n",count);
208 for (d=0; d<ndims; d++) data_size *= size[d];
209 data_buffer = (
double*) calloc (data_size,
sizeof(
double));
210 ferr = fread(data_buffer,
sizeof(
double),data_size,in);
211 if (ferr != data_size) {
212 fprintf(stderr,
"Error in BCReadTemperatureData(): Error (6) in file reading, count %d.\n",count);
222 temperature_field_size = (
int*) calloc (ndims,
sizeof(
int));
225 time_level_data = (
double*) calloc (size[dim],
sizeof(
double));
228 temperature_field_data = (
double*) calloc (data_size,
sizeof(
double));
229 ArrayCopynD(ndims,data_buffer,temperature_field_data,size,0,0,index,1);
234 MPI_Request req[3] = {MPI_REQUEST_NULL,MPI_REQUEST_NULL,MPI_REQUEST_NULL};
235 MPI_Isend(size,ndims,MPI_INT,rank1D,2152,mpi->
world,&req[0]);
236 MPI_Isend(time_buffer,size[dim],MPI_DOUBLE,rank1D,2154,mpi->
world,&req[2]);
237 MPI_Isend(data_buffer,data_size,MPI_DOUBLE,rank1D,2153,mpi->
world,&req[1]);
238 MPI_Status status_arr[3];
239 MPI_Waitall(3,&req[0],status_arr);
241 fprintf(stderr,
"Error in BCReadTemperatureData(): This is a serial run. Invalid (non-zero) rank read.\n");
252 fprintf(stderr,
"Error in BCReadTemperatureData(): missing data in unsteady boundary data file %s.\n",filename);
253 fprintf(stderr,
"Error in BCReadTemperatureData(): should contain data for %d processors, ", nproc);
254 fprintf(stderr,
"Error in BCReadTemperatureData(): but contains data for %d processors!\n", count);
263 if (mpi->
ip[dim] == (face > 0 ? 0 : mpi->
iproc[dim]-1) ) {
265 MPI_Request req = MPI_REQUEST_NULL;
267 temperature_field_size = (
int*) calloc (ndims,
sizeof(
int));
268 MPI_Irecv(temperature_field_size,ndims,MPI_INT,0,2152,mpi->
world,&req);
269 MPI_Wait(&req,MPI_STATUS_IGNORE);
272 for (d=0; d<ndims; d++)
if ((d != dim) && (temperature_field_size[d] != DomainSize[d])) flag = 0;
274 fprintf(stderr,
"Error in BCReadTemperatureData(): Error (4) (dimension mismatch) in file reading, rank %d.\n",mpi->
rank);
278 time_level_data = (
double*) calloc (temperature_field_size[dim],
sizeof(
double));
279 MPI_Irecv(time_level_data, temperature_field_size[dim], MPI_DOUBLE,0,2154,mpi->
world,&req);
280 MPI_Wait(&req,MPI_STATUS_IGNORE);
283 for (d=0; d<ndims; d++) data_size *= temperature_field_size[d];
284 temperature_field_data = (
double*) calloc (data_size,
sizeof(
double));
285 MPI_Irecv(temperature_field_data,data_size,MPI_DOUBLE,0,2153,mpi->
world,&req);
286 MPI_Wait(&req,MPI_STATUS_IGNORE);
290 fprintf(stderr,
"Error in BCReadTemperatureData(): Serial code should not be here!.\n");
int MPIRank1D(int, int *, int *)
double * UnsteadyTemperatureData
double * UnsteadyDirichletData
int BCReadTemperatureData(void *, void *, int, int, int *)
INLINE int ArrayCopynD(int, const double *, double *, int *, int, int, int *, int)
Containts the structures and definitions for boundary condition implementation.
MPI related function definitions.
char UnsteadyDirichletFilename[_MAX_STRING_SIZE_]
int * UnsteadyTemperatureSize
char UnsteadyTemperatureFilename[_MAX_STRING_SIZE_]
Structure containing the variables and function pointers defining a boundary.
double * UnsteadyTimeLevels
int * UnsteadyDirichletSize
int BCReadTurbulentInflowData(void *, void *, int, int, int *)
#define _ArrayCopy1D_(x, y, size)
Some basic definitions and macros.
Contains macros and function definitions for common array operations.
Structure of MPI-related variables.