12 #if defined(_WIN32) || defined(_WIN64)
13 #define strncasecmp _strnicmp
14 #define strcasecmp _stricmp
39 if (parameters.
type ==
"BCT_CONSTANT_VALUE") {
48 }
else if (parameters.
type ==
"BCT_CONSTANT_PSD") {
58 }
else if (parameters.
type ==
"BCT_CONSTANT_DERIVATIVE") {
66 }
else if (parameters.
type ==
"BCT_CONSTANT_SECOND_DERIVATIVE") {
74 }
else if (parameters.
type ==
"BCT_FILE" || parameters.
type ==
"BCT_FILE_GRID" || parameters.
type ==
"BCT_MULTIPLE_FILES") {
79 throw error_msg(
"BCT_ERROR",
"Unknown boundary condition type: %d", parameters.
type.c_str());
103 Output::echo(0,
"Loading boundary conditions from files... ");
107 if (parameters.
type ==
"BCT_FILE" || parameters.
type ==
"BCT_FILE_GRID") {
112 ifstream input(parameters.
filename.c_str());
115 throw error_msg(
"BC_FILE_OPEN_ERR",
"Boundary conditions file %s not found.", parameters.
filename.c_str());
119 while (strcasecmp(inBuf.c_str(),
"ZONE") != 0 && !input.eof() ) input >> inBuf;
120 input.ignore(9999,
'\n');
121 double loadedTime, loadedAx1, loadedAx2, loadedValue;
125 if (parameters.
type ==
"BCT_FILE_GRID") input >> loadedAx1 >> loadedAx2;
126 input >> loadedValue;
128 if (parameters.
type ==
"BCT_FILE_GRID" && (fabs(loadedAx1 - gridElement1[ix][iy]) > err || fabs(loadedAx2 - gridElement2[ix][iy]) > err)) {
130 throw error_msg(
"BC_LOAD_GRID_ERR",
"Loading %s: not enough data points in the boundary condition file.\n", parameters.
filename.c_str());
132 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);
135 arr[ix][iy] = loadedValue;
138 input.ignore(9999,
'\n');
145 }
else if (parameters.
type ==
"BCT_MULTIPLE_FILES") {
150 Output::echo(0,
"Loading a list of boundary conditions... ");
151 ifstream input(parameters.
filename.c_str());
154 throw error_msg(
"BC_FILE_OPEN_ERR",
"Boundary conditions file %s not found.", parameters.
filename.c_str());
159 while (strcasecmp(inBuf.c_str(),
"ZONE") != 0 && !input.eof() ) input >> inBuf;
160 input.ignore(9999,
'\n');
165 while (!input.eof()) {
167 input >> time_tmp >> filename_tmp;
175 if (input2 == NULL) {
176 throw error_msg(
"BC_FILE_OPEN_ERR",
"Boundary conditions file %s not found.", parameters.
filename.c_str());
182 while (strcasecmp(inBuf.c_str(),
"ZONE") != 0 && !input2.eof() ) input2 >> inBuf;
183 input2.ignore(9999,
'\n');
187 input2 >>
arr[ix][iy];
205 if (
type ==
"BCT_MULTIPLE_FILES") {
206 if (time == -1 || dt == -1)
207 throw error_msg(
"BC_ERR",
"To use BCT_MULTIPLE_FILES, time and dt need to be specified when the function is called.");
217 throw error_msg(
"BC_FILE_OPEN_ERR",
"Boundary conditions file %s not found.",
BC_filename[i].c_str());
223 while (strcasecmp(inBuf.c_str(),
"ZONE") != 0 && !input.eof() ) input >> inBuf;
224 input.ignore(9999,
'\n');
bool initialized
Flag, equal true if initialized.
double max(double v1, double v2)
Return maximum.
vector< string > BC_filename
If we change boundary conditions with time, this is the filename for the new boundary condition value...
void AllocateMemory(int size_x, int size_y)
string calculationType
Type: constant function/constant derivative.
string filename
File name to load boundary conditions from.
Matrix2D< double > arr
2D matrix of boundary conditions
void echo(int msglvl, const char *format,...)
Basic function! Write the message to the file.
Boundary conditions parameters structure.
string type
Initial type: how to set up boundary conditions. (Like read from a file, etc)
vector< double > BC_change_time
If we change boundary conditions with time, this is the time when we need to change it...
void MakeBoundaryCondition(Parameters_structure::BoundaryCondition parameters, Matrix2D< double > psd2DSlice, Matrix2D< double > gridElement1, Matrix2D< double > gridElement2)
string type
Type. Check StrToVal(string input, BoundaryConditionTypes &place) for known values.
double value
Value (if it is constant value on the boundary).
Parameters_structure parameters
Parameters structure, with all parameters from the parameters.ini file. The default parameters define...
Error message - stack of single_errors.
string name
name of the Matrix
void writeToFile(string filename)
static const double zero_f
Minimum value for PSD.
void Update(int iteration, Matrix2D< double > PSD_2D_Slice, double time=-1, double dt=-1)
void LoadBoundaryCondition(Parameters_structure::BoundaryCondition parameters, Matrix2D< double > gridElement1, Matrix2D< double > gridElement2)