15 static int ReadArraywInterpSerial(
int,
int,
int*,
int*,
int*,
int,
void*,
void*,
double*,
double*,
char*,
int*);
58 if (retval)
return retval;
64 for (d = 0; d < ndims; d++) {
67 offset += (dim_local [d] + 2*ghosts);
71 for (d = 0; d < ndims; d++) {
72 double *X = &x[offset];
73 int *dim = dim_local, i;
74 if (mpi->
ip[d] == 0) {
76 for (i = 0; i < ghosts; i++) {
77 int delta = ghosts - i;
78 X[i] = X[ghosts] + ((double) delta) * (X[ghosts]-X[ghosts+1]);
81 if (mpi->
ip[d] == mpi->
iproc[d]-1) {
83 for (i = dim[d]+ghosts; i < dim[d]+2*ghosts; i++) {
84 int delta = i - (dim[d]+ghosts-1);
85 X[i] = X[dim[d]+ghosts-1]
86 + ((double) delta) * (X[dim[d]+ghosts-1]-X[dim[d]+ghosts-2]);
89 offset += (dim[d] + 2*ghosts);
175 int i, d, ferr, index[ndims];
176 double *ug_src = NULL, *xg_src = NULL;
177 double *ug = NULL, *xg = NULL;
187 strcpy(filename,fname_root);
188 strcat(filename,
".inp");
189 FILE *in; in = fopen(filename,
"r");
190 if (!in) *read_flag = 0;
194 printf(
"Reading array from ASCII file %s (Serial mode).\n",filename);
197 size = 1;
for (d=0; d<ndims; d++) size *= dim_global_src[d]; size *= nvars;
198 ug_src = (
double*) calloc(size,
sizeof(
double));
199 size = 0;
for (d=0; d<ndims; d++) size += dim_global_src[d];
200 xg_src = (
double*) calloc(size,
sizeof(
double));
204 for (d = 0; d < ndims; d++) {
205 for (i = 0; i < dim_global_src[d]; i++) {
206 ferr = fscanf(in,
"%lf",&xg_src[i+offset]);
208 printf(
"Error in ReadArraySerial(): unable to read data. ferr=%d\n", ferr);
212 offset += dim_global_src[d];
216 for (i = 0; i < nvars; i++) {
220 ferr = fscanf(in,
"%lf",&ug_src[p*nvars+i]);
222 printf(
"Error in ReadArraySerial(): unable to read data. ferr=%d\n", ferr);
234 strcpy(filename,fname_root);
235 strcat(filename,
".inp");
236 FILE *in; in = fopen(filename,
"rb");
237 if (!in) *read_flag = 0;
240 printf(
"Reading array from binary file %s (Serial mode).\n",filename);
244 size = 1;
for (d=0; d<ndims; d++) size *= dim_global_src[d]; size *= nvars;
245 ug_src = (
double*) calloc(size,
sizeof(
double));
246 size = 0;
for (d=0; d<ndims; d++) size += dim_global_src[d];
247 xg_src = (
double*) calloc(size,
sizeof(
double));
251 for (d = 0; d < ndims; d++) size += dim_global_src[d];
252 bytes = fread(xg_src,
sizeof(
double), size, in);
253 if ((
int)bytes != size) {
254 fprintf(stderr,
"Error in ReadArray(): Unable to read grid. Expected %d, Read %d.\n",
260 for (d = 0; d < ndims; d++) size *= dim_global_src[d]; size *= nvars;
261 bytes = fread(ug_src,
sizeof(
double), size, in);
262 if ((
int)bytes != size) {
263 fprintf(stderr,
"Error in ReadArray(): Unable to read solution. Expected %d, Read %d.\n",
274 for (d=0; d<ndims; d++) size *= (dim_global_src[d]+2*ghosts);
275 ug_src_wg = (
double*) calloc (size,
sizeof(
double));
303 fprintf(stderr,
"Error in ReadArraywInterpSerial()\n");
304 fprintf(stderr,
" InterpolateGlobalnDVar() returned with error!\n");
309 fprintf(stderr,
"Error in ReadArraywInterpSerial()\n");
310 fprintf(stderr,
" Not yet implemented for x\n");
313 if (xg_src) free(xg_src);
316 fprintf(stderr,
"Error in ReadArraywInterp() - ug is NULL!\n");
319 if ((xg == NULL) && (x != NULL)) {
320 fprintf(stderr,
"Error in ReadArraywInterp() - xg is NULL!\n");
#define _ArraySetValue_(x, size, value)
static int ReadArraywInterpSerial(int, int, int *, int *, int *, int, void *, void *, double *, double *, char *, int *)
int MPIPartitionArraynDwGhosts(int, void *, double *, double *, int *, int *, int, int)
#define _ArrayIncrementIndex_(N, imax, i, done)
int MPIExchangeBoundaries1D(void *, double *, int, int, int, int)
INLINE int ArrayCopynD(int, const double *, double *, int *, int, int, int *, int)
MPI related function definitions.
void fillGhostCells(const int *const, const int, double *const, const int, const int, const int *const)
#define _ArrayIndex1D_(N, imax, i, ghost, index)
#define _MAX_STRING_SIZE_
int InterpolateGlobalnDVar(const int *const, double **const, const int *const, double *const, const int, const int, const int, const int *const)
Contains function definitions for common mathematical functions.
char ip_file_type[_MAX_STRING_SIZE_]
int ReadArraywInterp(int, int, int *, int *, int *, int, void *, void *, double *, double *, char *, int *)
Contains structure definition for hypar.
Some basic definitions and macros.
Contains macros and function definitions for common array operations.
Structure of MPI-related variables.
Structure containing all solver-specific variables and functions.
int MPIBroadcast_integer(int *, int, int, void *)