12 #if defined(_WIN32) || defined(_WIN64)
13 #define strncasecmp _strnicmp
14 #define strcasecmp _stricmp
38 if (parameters.
type ==
"BCT_CONSTANT_VALUE") {
47 }
else if (parameters.
type ==
"BCT_CONSTANT_PSD") {
57 }
else if (parameters.
type ==
"BCT_CONSTANT_DERIVATIVE") {
65 }
else if (parameters.
type ==
"BCT_CONSTANT_SECOND_DERIVATIVE") {
73 }
else if (parameters.
type ==
"BCT_FILE" || parameters.
type ==
"BCT_FILE_GRID" || parameters.
type ==
"BCT_MULTIPLE_FILES") {
78 throw error_msg(
"BCT_ERROR",
"Unknown boundary condition type: %d", parameters.
type.c_str());
102 Output::echo(0,
"Loading boundary conditions from files... ");
106 if (parameters.
type ==
"BCT_FILE" || parameters.
type ==
"BCT_FILE_GRID") {
111 ifstream input(parameters.
filename.c_str());
114 throw error_msg(
"BC_FILE_OPEN_ERR",
"Boundary conditions file %s not found.", parameters.
filename.c_str());
118 while (strcasecmp(inBuf.c_str(),
"ZONE") != 0 && !input.eof() ) input >> inBuf;
119 input.ignore(9999,
'\n');
120 double loadedTime, loadedAx1, loadedAx2, loadedValue;
124 if (parameters.
type ==
"BCT_FILE_GRID") input >> loadedAx1 >> loadedAx2;
125 input >> loadedValue;
127 if (parameters.
type ==
"BCT_FILE_GRID" && (fabs(loadedAx1 - gridElement1[ix][iy]) > err || fabs(loadedAx2 - gridElement2[ix][iy]) > err)) {
129 throw error_msg(
"BC_LOAD_GRID_ERR",
"Loading %s: not enough data points in the boundary condition file.\n", parameters.
filename.c_str());
131 throw error_msg(
"BC_LOAD_GRID_ERR",
"Loading %s: grid mismatch.\nLoaded: ax1=%e, ax2=%e\nGrid: ax1=%e, ax2=%e\n(i1=%d, i2=%d)\n", parameters.
filename.c_str(), loadedAx1, loadedAx2, gridElement1[ix][iy], gridElement2[ix][iy], ix, iy);
134 arr[ix][iy] = loadedValue;
137 input.ignore(9999,
'\n');
144 }
else if (parameters.
type ==
"BCT_MULTIPLE_FILES") {
149 Output::echo(0,
"Loading a list of boundary conditions... ");
150 ifstream input(parameters.
filename.c_str());
153 throw error_msg(
"BC_FILE_OPEN_ERR",
"Boundary conditions file %s not found.", parameters.
filename.c_str());
158 while (strcasecmp(inBuf.c_str(),
"ZONE") != 0 && !input.eof() ) input >> inBuf;
159 input.ignore(9999,
'\n');
164 while (!input.eof()) {
166 input >> time_tmp >> filename_tmp;
174 if (input2 == NULL) {
175 throw error_msg(
"BC_FILE_OPEN_ERR",
"Boundary conditions file %s not found.", parameters.
filename.c_str());
181 while (strcasecmp(inBuf.c_str(),
"ZONE") != 0 && !input2.eof() ) input2 >> inBuf;
182 input2.ignore(9999,
'\n');
186 input2 >>
arr[ix][iy];
201 if (
type ==
"BCT_MULTIPLE_FILES") {
202 if (time == -1 || dt == -1)
203 throw error_msg(
"BC_ERR",
"To use BCT_MULTIPLE_FILES, time and dt need to be specified when the function is called.");
213 throw error_msg(
"BC_FILE_OPEN_ERR",
"Boundary conditions file %s not found.",
BC_filename[i].c_str());
219 while (strcasecmp(inBuf.c_str(),
"ZONE") != 0 && !input.eof() ) input >> inBuf;
220 input.ignore(9999,
'\n');