kspaceFirstOrder3D-CUDA  1.1
The CUDA/C++ implementation of the k-wave toolbox for the time-domain simulation of acoustic wave fields in 3D
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Parameters.cpp
Go to the documentation of this file.
1 /**
2  * @file Parameters.cpp
3  *
4  * @author Jiri Jaros \n
5  * Faculty of Information Technology \n
6  * Brno University of Technology \n
7  * jarosjir@fit.vutbr.cz
8  *
9  * @brief The implementation file containing parameters of the simulation.
10  *
11  * @version kspaceFirstOrder3D 3.4
12  *
13  * @date 09 August 2012, 13:39 (created) \n
14  * 10 August 2016, 12:57 (revised)
15  *
16  * @section License
17  * This file is part of the C++ extension of the k-Wave Toolbox
18  * (http://www.k-wave.org).\n Copyright (C) 2016 Jiri Jaros and Bradley Treeby.
19  *
20  * This file is part of the k-Wave. k-Wave is free software: you can redistribute it and/or modify
21  * it under the terms of the GNU Lesser General Public License as published by the Free Software
22  * Foundation, either version 3 of the License, or (at your option) any later version.
23  *
24  * k-Wave is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
25  * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
26  * General Public License for more details.
27  *
28  * You should have received a copy of the GNU Lesser General Public License along with k-Wave.
29  * If not, see http://www.gnu.org/licenses/.
30  */
31 
32 #ifdef _OPENMP
33  #include <omp.h>
34 #endif
35 
36 #include <iostream>
37 #include <string>
38 #include <exception>
39 #include <stdexcept>
40 
41 #include <Parameters/Parameters.h>
43 #include <Utils/MatrixNames.h>
44 #include <Logger/Logger.h>
45 
46 
47 using std::ios;
48 using std::string;
49 
50 //------------------------------------------------------------------------------------------------//
51 //------------------------------------------ Constants -------------------------------------------//
52 //------------------------------------------------------------------------------------------------//
53 
54 
55 //------------------------------------------------------------------------------------------------//
56 //------------------------------------------ VARIABLES -------------------------------------------//
57 //------------------------------------------------------------------------------------------------//
58 
60 
62 
63 //------------------------------------------------------------------------------------------------//
64 //--------------------------------------- Public methods -----------------------------------------//
65 //------------------------------------------------------------------------------------------------//
66 
67 /**
68  * Get instance of singleton class.
69  */
71 {
73  {
77  }
78  else
79  {
81  }
82 }// end of GetInstance()
83 //--------------------------------------------------------------------------------------------------
84 
85 /**
86  * Destructor.
87  */
89 {
90  parametersInstanceFlag = false;
92  {
94  }
95  parametersSingleInstance = nullptr;
96 };
97 //--------------------------------------------------------------------------------------------------
98 
99 /**
100  * Parse command line and read scalar values from the input file to initialise the class and
101  * the simulation.
102  *
103  * @param [in] argc - Number of commandline parameters
104  * @param [in] argv - Commandline parameters
105  */
106 void TParameters::Init(int argc, char** argv)
107 {
109 
110  if (GetGitHash() != "")
111  {
114  }
116  {
117  return;
118  }
119 
122 
124  {
126  }
127 
130  {
131  throw std::invalid_argument(TLogger::FormatMessage(ERR_FMT_ILLEGAL_START_TIME_VALUE,
132  1l,
133  nt));
134  }
135 
137 }// end of ParseCommandLine
138 //--------------------------------------------------------------------------------------------------
139 
140 
141 /**
142  * Select a GPU device for execution.
143  */
145 {
149 
150  int deviceIdx = commandLineParameters.GetCUDADeviceIdx();
151  cudaParameters.SelectDevice(deviceIdx); // throws an exception when wrong
152 
156 
159  cudaParameters.GetDeviceName().c_str());
160 }// end of SelectDevice
161 //--------------------------------------------------------------------------------------------------
162 
163 
164 /**
165  * Print parameters of the simulation, based in the actual level of verbosity.
166  */
168 {
172 
174 
175 
176  const string domainsSizes = TLogger::FormatMessage(OUT_FMT_DOMAIN_SIZE_FORMAT,
179  GetFullDimensionSizes().nz);
180  // Print simulation size
181  TLogger::Log(TLogger::BASIC, OUT_FMT_DOMAIN_SIZE, domainsSizes.c_str());
182 
184 
185  // Print all command line parameters
187 
188  if (Get_sensor_mask_type() == INDEX)
189  {
191  }
192  if (Get_sensor_mask_type() == CORNERS)
193  {
195  }
196 }// end of PrintParametersOfTask
197 //--------------------------------------------------------------------------------------------------
198 
199 
200 /**
201  * Read scalar values from the input HDF5 file.
202  *
203  * @param [in] inputFile - Handle to an opened input file.
204  *
205  * @throw ios:failure if the file cannot be open or is of a wrong type or version.
206  */
208 {
209  TDimensionSizes scalarSizes(1,1,1);
210 
211  if (!inputFile.IsOpen())
212  {
213  // Open file -- exceptions handled in main
215  }
216 
218 
219  // check file type
220  if (fileHeader.GetFileType() != THDF5_FileHeader::INPUT)
221  {
223  GetInputFileName().c_str()));
224  }
225 
226  // check version
228  {
230  GetInputFileName().c_str(),
232  }
233 
235  {
237  GetInputFileName().c_str(),
239  }
240 
241  const hid_t rootGroup = inputFile.GetRootGroup();
242 
243  inputFile.ReadScalarValue(rootGroup, Nt_NAME, nt);
244 
245  inputFile.ReadScalarValue(rootGroup, dt_NAME, dt);
246  inputFile.ReadScalarValue(rootGroup, dx_NAME, dx);
247  inputFile.ReadScalarValue(rootGroup, dy_NAME, dy);
248  inputFile.ReadScalarValue(rootGroup, dz_NAME, dz);
249 
250  inputFile.ReadScalarValue(rootGroup, c_ref_NAME, c_ref);
251  inputFile.ReadScalarValue(rootGroup, pml_x_size_NAME, pml_x_size);
252  inputFile.ReadScalarValue(rootGroup, pml_y_size_NAME, pml_y_size);
253  inputFile.ReadScalarValue(rootGroup, pml_z_size_NAME, pml_z_size);
254 
255  inputFile.ReadScalarValue(rootGroup, pml_x_alpha_NAME, pml_x_alpha);
256  inputFile.ReadScalarValue(rootGroup, pml_y_alpha_NAME, pml_y_alpha);
257  inputFile.ReadScalarValue(rootGroup, pml_z_alpha_NAME, pml_z_alpha);
258 
259  size_t x, y, z;
260  inputFile.ReadScalarValue(rootGroup, Nx_NAME, x);
261  inputFile.ReadScalarValue(rootGroup, Ny_NAME, y);
262  inputFile.ReadScalarValue(rootGroup, Nz_NAME, z);
263 
264 
268 
269  reducedDimensionSizes.nx = ((x/2) + 1);
272 
273  // if the file is of version 1.0, there must be a sensor mask index (backward compatibility)
274  if (fileHeader.GetFileVersion() == THDF5_FileHeader::VERSION_10)
275  {
277 
278  //if -u_non_staggered_raw enabled, throw an error - not supported
280  {
282  }
283  }// version 1.0
284 
285  // This is the current version 1.1
286  if (fileHeader.GetFileVersion() == THDF5_FileHeader::VERSION_11)
287  {
288  // read sensor mask type as a size_t value to enum
289  size_t sensorMaskTypeNumericValue = 0;
290  inputFile.ReadScalarValue(rootGroup, sensor_mask_type_NAME, sensorMaskTypeNumericValue);
291 
292  // convert the long value on
293  switch (sensorMaskTypeNumericValue)
294  {
295  case 0:
296  {
297  sensor_mask_type = INDEX;
298  break;
299  }
300  case 1:
301  {
302  sensor_mask_type = CORNERS;
303  break;
304  }
305  default:
306  {
307  throw ios::failure(ERR_FMT_BAD_SENSOR_MASK_TYPE);
308  break;
309  }
310  }//case
311 
312  // read the input mask size
313  switch (sensor_mask_type)
314  {
315  case INDEX:
316  {
318  break;
319  }
320  case CORNERS:
321  {
322  // mask dimensions are [6, N, 1] - I want to know N
324  break;
325  }
326  }// switch
327  }// version 1.1
328 
329  // flags
330  inputFile.ReadScalarValue(rootGroup, ux_source_flag_NAME, ux_source_flag);
331  inputFile.ReadScalarValue(rootGroup, uy_source_flag_NAME, uy_source_flag);
332  inputFile.ReadScalarValue(rootGroup, uz_source_flag_NAME, uz_source_flag);
334 
335  inputFile.ReadScalarValue(rootGroup, p_source_flag_NAME, p_source_flag);
336  inputFile.ReadScalarValue(rootGroup, p0_source_flag_NAME,p0_source_flag);
337 
339  inputFile.ReadScalarValue(rootGroup, absorbing_flag_NAME, absorbing_flag);
340  inputFile.ReadScalarValue(rootGroup, nonlinear_flag_NAME, nonlinear_flag);
341 
342  // Vector sizes.
343  if (transducer_source_flag == 0)
344  {
346  }
347  else
348  {
350  }
351 
352  if ((transducer_source_flag > 0) || (ux_source_flag > 0) || (uy_source_flag > 0) || (uz_source_flag > 0))
353  {
355  }
356 
357  // uxyz_source_flags.
358  if ((ux_source_flag > 0) || (uy_source_flag > 0) || (uz_source_flag > 0))
359  {
360  inputFile.ReadScalarValue(rootGroup, u_source_many_NAME, u_source_many);
361  inputFile.ReadScalarValue(rootGroup, u_source_mode_NAME, u_source_mode);
362  }
363  else
364  {
365  u_source_many = 0;
366  u_source_mode = 0;
367  }
368 
369  // p_source_flag
370  if (p_source_flag != 0)
371  {
372  inputFile.ReadScalarValue(rootGroup, p_source_many_NAME, p_source_many);
373  inputFile.ReadScalarValue(rootGroup, p_source_mode_NAME, p_source_mode);
374 
376  }
377  else
378  {
379  p_source_mode = 0;
380  p_source_many = 0;
382  }
383 
384  // absorb flag.
385  if (absorbing_flag != 0)
386  {
387  inputFile.ReadScalarValue(rootGroup, alpha_power_NAME, alpha_power);
388  if (alpha_power == 1.0f)
389  {
390  throw std::invalid_argument(ERR_FMT_ILLEGAL_ALPHA_POWER_VALUE);
391  }
392 
393  alpha_coeff_scalar_flag = inputFile.GetDatasetDimensionSizes(rootGroup, alpha_coeff_NAME) == scalarSizes;
394 
396  {
397  inputFile.ReadScalarValue(rootGroup, alpha_coeff_NAME, alpha_coeff_scalar);
398  }
399  }
400 
401  c0_scalar_flag = inputFile.GetDatasetDimensionSizes(rootGroup, c0_NAME) == scalarSizes;
402  if (c0_scalar_flag)
403  {
404  inputFile.ReadScalarValue(rootGroup, c0_NAME, c0_scalar);
405  }
406 
407  if (nonlinear_flag)
408  {
409  BonA_scalar_flag = inputFile.GetDatasetDimensionSizes(rootGroup, BonA_NAME) == scalarSizes;
410  if (BonA_scalar_flag)
411  {
412  inputFile.ReadScalarValue(rootGroup, BonA_NAME, BonA_scalar);
413  }
414  }
415 
416  rho0_scalar_flag = inputFile.GetDatasetDimensionSizes(rootGroup, rho0_NAME) == scalarSizes;
417  if (rho0_scalar_flag)
418  {
419  inputFile.ReadScalarValue(rootGroup, rho0_NAME, rho0_scalar);
420  inputFile.ReadScalarValue(rootGroup, rho0_sgx_NAME, rho0_sgx_scalar);
421  inputFile.ReadScalarValue(rootGroup, rho0_sgy_NAME, rho0_sgy_scalar);
422  inputFile.ReadScalarValue(rootGroup, rho0_sgz_NAME, rho0_sgz_scalar);
423  }
424 }// end of ReadScalarsFromInputFile
425 //--------------------------------------------------------------------------------------------------
426 
427 /**
428  * Save scalars into the output HDF5 file.
429  *
430  * @param [in] outputFile - Handle to an opened output file where to store
431  */
433 {
434  const hid_t HDF5RootGroup = outputFile.GetRootGroup();
435 
436  // Write dimension sizes
437  outputFile.WriteScalarValue(HDF5RootGroup, Nx_NAME, fullDimensionSizes.nx);
438  outputFile.WriteScalarValue(HDF5RootGroup, Ny_NAME, fullDimensionSizes.ny);
439  outputFile.WriteScalarValue(HDF5RootGroup, Nz_NAME, fullDimensionSizes.nz);
440 
441  outputFile.WriteScalarValue(HDF5RootGroup, Nt_NAME, nt);
442 
443  outputFile.WriteScalarValue(HDF5RootGroup, dt_NAME, dt);
444  outputFile.WriteScalarValue(HDF5RootGroup, dx_NAME, dx);
445  outputFile.WriteScalarValue(HDF5RootGroup, dy_NAME, dy);
446  outputFile.WriteScalarValue(HDF5RootGroup, dz_NAME, dz);
447 
448  outputFile.WriteScalarValue(HDF5RootGroup, c_ref_NAME, c_ref);
449 
450  outputFile.WriteScalarValue(HDF5RootGroup, pml_x_size_NAME, pml_x_size);
451  outputFile.WriteScalarValue(HDF5RootGroup, pml_y_size_NAME, pml_y_size);
452  outputFile.WriteScalarValue(HDF5RootGroup, pml_z_size_NAME, pml_z_size);
453 
454  outputFile.WriteScalarValue(HDF5RootGroup, pml_x_alpha_NAME, pml_x_alpha);
455  outputFile.WriteScalarValue(HDF5RootGroup, pml_y_alpha_NAME, pml_y_alpha);
456  outputFile.WriteScalarValue(HDF5RootGroup, pml_z_alpha_NAME, pml_z_alpha);
457 
458  outputFile.WriteScalarValue(HDF5RootGroup, ux_source_flag_NAME, ux_source_flag);
459  outputFile.WriteScalarValue(HDF5RootGroup, uy_source_flag_NAME, uy_source_flag);
460  outputFile.WriteScalarValue(HDF5RootGroup, uz_source_flag_NAME, uz_source_flag);
462 
463  outputFile.WriteScalarValue(HDF5RootGroup, p_source_flag_NAME, p_source_flag);
464  outputFile.WriteScalarValue(HDF5RootGroup, p0_source_flag_NAME, p0_source_flag);
465 
467  outputFile.WriteScalarValue(HDF5RootGroup, absorbing_flag_NAME, absorbing_flag);
468  outputFile.WriteScalarValue(HDF5RootGroup, nonlinear_flag_NAME, nonlinear_flag);
469 
470  // uxyz_source_flags.
471  if ((ux_source_flag > 0) || (uy_source_flag > 0) || (uz_source_flag > 0))
472  {
473  outputFile.WriteScalarValue(HDF5RootGroup, u_source_many_NAME, u_source_many);
474  outputFile.WriteScalarValue(HDF5RootGroup, u_source_mode_NAME, u_source_mode);
475  }
476 
477  // p_source_flag.
478  if (p_source_flag != 0)
479  {
480  outputFile.WriteScalarValue(HDF5RootGroup, p_source_many_NAME, p_source_many);
481  outputFile.WriteScalarValue(HDF5RootGroup, p_source_mode_NAME, p_source_mode);
482 
483  }
484 
485  // absorb flag
486  if (absorbing_flag != 0)
487  {
488  outputFile.WriteScalarValue(HDF5RootGroup, alpha_power_NAME, alpha_power);
489  }
490 
491  // if copy sensor mask, then copy the mask type
492  if (IsCopySensorMask())
493  {
494  size_t SensorMaskTypeNumericValue = 0;
495 
496  switch (sensor_mask_type)
497  {
498  case INDEX: SensorMaskTypeNumericValue = 0;
499  break;
500  case CORNERS: SensorMaskTypeNumericValue = 1;
501  break;
502  }// switch
503 
504  outputFile.WriteScalarValue(HDF5RootGroup, sensor_mask_type_NAME, SensorMaskTypeNumericValue);
505  }
506 }// end of SaveScalarsToFile
507 //--------------------------------------------------------------------------------------------------
508 
509 /**
510  * Get GitHash of the code
511  * @return githash
512  */
514 {
515 #if (defined (__KWAVE_GIT_HASH__))
516  return string(__KWAVE_GIT_HASH__);
517 #else
518  return "";
519 #endif
520 }// end of GetGitHash
521 //--------------------------------------------------------------------------------------------------
522 
523 
524 
525 //------------------------------------------------------------------------------------------------//
526 //-------------------------------------- Protected methods ---------------------------------------//
527 //------------------------------------------------------------------------------------------------//
528 
529 
530 /**
531  * Constructor.
532  */
534  cudaParameters(),
537  nt(0), t_index(0), dt(0.0f),
538  dx(0.0f), dy(0.0f), dz(0.0f),
539  c_ref(0.0f), alpha_power(0.0f),
547  pml_x_size(0), pml_y_size(0), pml_z_size(0),
549  c0_scalar_flag(false), c0_scalar(0.0f),
550  absorb_eta_scalar(0.0f), absorb_tau_scalar (0.0f),
551  BonA_scalar_flag(false), BonA_scalar (0.0f),
552  rho0_scalar_flag(false), rho0_scalar(0.0f),
554 {
555 
556 }// end of TParameters()
557 //--------------------------------------------------------------------------------------------------
558 
559 
TMatrixName c_ref_NAME
c_ref variable name
Definition: MatrixNames.h:61
TMatrixName alpha_power_NAME
alpha_power variable name
Definition: MatrixNames.h:66
size_t nx
number of elements in the x direction
TErrorMessage ERR_FMT_ILLEGAL_START_TIME_VALUE
Command line parameters error message.
size_t transducer_source_flag
transducer_source_flag value.
Definition: Parameters.h:344
TCUDAParameters cudaParameters
Class with CUDA Parameters (runtime setup)
Definition: Parameters.h:280
TOutputMessage OUT_FMT_DEVICE_NAME
Output message.
static bool parametersInstanceFlag
singleton flag
Definition: Parameters.h:409
size_t transducer_source_input_size
transducer_source_input_size value.
Definition: Parameters.h:330
float c_ref
c_ref value.
Definition: Parameters.h:309
bool BonA_scalar_flag
BonA_scalar_flag value.
Definition: Parameters.h:393
TOutputMessage OUT_FMT_SENSOR_MASK_INDEX
Output message.
size_t p_source_flag
p_source_flag value.
Definition: Parameters.h:340
size_t GetNumberOfThreads() const
Get number of threads.
Definition: Parameters.h:220
TMatrixName p_source_index_NAME
p_source_index variable name
Definition: MatrixNames.h:145
TMatrixName p_source_flag_NAME
p_source_flag variable name
Definition: MatrixNames.h:133
void ReadScalarsFromInputFile(THDF5_File &inputFile)
Read scalar values from the input HDF5 file.
Definition: Parameters.cpp:207
void Open(const std::string &fileName, unsigned int flags=H5F_ACC_RDONLY)
Open a file.
Definition: HDF5_File.cpp:127
TMatrixName dt_NAME
dt variable name
Definition: MatrixNames.h:52
size_t u_source_mode
u_source_mode value.
Definition: Parameters.h:349
size_t ux_source_flag
ux_source_flag value.
Definition: Parameters.h:333
const std::string & GetInputFileName() const
Get input file name.
bool alpha_coeff_scalar_flag
alpha_coeff_scalar_flag value.
Definition: Parameters.h:378
The header file for the class for setting CUDA kernel parameters.
float pml_x_alpha
pml_x_alpha value.
Definition: Parameters.h:371
TMatrixName sensor_mask_index_NAME
sensor_mask_index variable name
Definition: MatrixNames.h:166
TOutputMessage OUT_FMT_SIMULATION_DETAIL_TITLE
Output message.
TMatrixName transducer_source_input_NAME
transducer_source_input variable name
Definition: MatrixNames.h:173
TMatrixName u_source_mode_NAME
u_source_mode variable name
Definition: MatrixNames.h:138
TOutputMessage OUT_FMT_SIMULATION_LENGTH
Output message.
TMatrixName rho0_sgz_NAME
rho0_sgz variable name
Definition: MatrixNames.h:257
TMatrixName BonA_NAME
BonA variable name.
Definition: MatrixNames.h:184
TDimensionSizes reducedDimensionSizes
Reduced 3D dimension sizes.
Definition: Parameters.h:316
void PrintComandlineParamers()
Print setup.
TMatrixName pml_z_size_NAME
pml_z_size variable name
Definition: MatrixNames.h:96
TMatrixName dy_NAME
dy variable name
Definition: MatrixNames.h:56
TMatrixName transducer_source_flag_NAME
transducer_source_flag variable name
Definition: MatrixNames.h:164
static TParameters & GetInstance()
Get instance of the singleton class.
Definition: Parameters.cpp:70
float absorb_eta_scalar
absorb_eta_scalar value.
Definition: Parameters.h:388
bool c0_scalar_flag
c0_scalar_flag value.
Definition: Parameters.h:383
size_t nonlinear_flag
nonlinear_flag value.
Definition: Parameters.h:361
size_t p_source_mode
p_source_mode value.
Definition: Parameters.h:352
TOutputMessage OUT_FMT_DOMAIN_SIZE
Output message.
static std::string GetCurrentHDF5_MinorVersion()
Get string version of current Minor version.
Definition: HDF5_File.h:831
TErrorMessage ERR_FMT_U_NON_STAGGERED_NOT_SUPPORTED_FILE_VERSION
Command line parameters error message.
std::string GetInputFileName() const
Get input file name.
Definition: Parameters.h:211
TMatrixName nonlinear_flag_NAME
nonlinear_flag variable name
Definition: MatrixNames.h:161
size_t u_source_index_size
u_source_index_size value.
Definition: Parameters.h:326
float dz
dz value.
Definition: Parameters.h:306
TMatrixName pml_y_alpha_NAME
pml_y_alpha variable name
Definition: MatrixNames.h:116
TMatrixName Ny_NAME
Ny variable name.
Definition: MatrixNames.h:73
void WriteScalarValue(const hid_t parentGroup, TMatrixName &datasetName, const float value)
Write the scalar value under a specified group, float value.
Definition: HDF5_File.cpp:748
float pml_z_alpha
pml_z_alpha value.
Definition: Parameters.h:375
TMatrixName u_source_index_NAME
u_source_index variable name
Definition: MatrixNames.h:148
TMatrixName absorbing_flag_NAME
absorbing_flag variable name
Definition: MatrixNames.h:159
TMatrixName p_source_mode_NAME
p_source_mode variable name
Definition: MatrixNames.h:140
float BonA_scalar
BonA_scalar value.
Definition: Parameters.h:395
float alpha_power
alpha_power value.
Definition: Parameters.h:311
static TParameters * parametersSingleInstance
singleton instance
Definition: Parameters.h:411
TOutputMessage OUT_FMT_GIT_HASH_LEFT
Output message.
The header file containing the parameters of the simulation.
bool IsOpen() const
Is the file opened?
Definition: HDF5_File.h:545
TMatrixName pml_y_size_NAME
pml_y_size variable name
Definition: MatrixNames.h:94
size_t nonuniform_grid_flag
nonuniform_grid_flag value.
Definition: Parameters.h:357
TMatrixName ux_source_flag_NAME
ux_source_flag variable name
Definition: MatrixNames.h:121
float dt
dt value.
Definition: Parameters.h:300
Full level of verbosity.
Definition: Logger.h:67
TDimensionSizes GetDatasetDimensionSizes(const hid_t parentGroup, TMatrixName &datasetName)
Get dimension sizes of the dataset under a specified group.
Definition: HDF5_File.cpp:949
size_t uz_source_flag
uz_source_flag value.
Definition: Parameters.h:337
TMatrixName sensor_mask_corners_NAME
sensor_mask_corners variable name
Definition: MatrixNames.h:170
static std::string GetCurrentHDF5_MajorVersion()
Get string version of current Major version.
Definition: HDF5_File.h:821
THDF5_File inputFile
Handle to the input HDF5 file.
Definition: Parameters.h:285
TMatrixName p0_source_flag_NAME
p0_source_flag variable name
Definition: MatrixNames.h:135
float pml_y_alpha
pml_y_alpha value.
Definition: Parameters.h:373
std::string GetDeviceName() const
Get the name of the device used.
TErrorMessage ERR_FMT_ILLEGAL_ALPHA_POWER_VALUE
Command line parameters error message.
void SelectDevice(const int DeviceIdx=DEFAULT_DEVICE_IDX)
Select cuda device for execution.
size_t absorbing_flag
absorbing_flag value.
Definition: Parameters.h:359
int GetCUDADeviceIdx() const
Get GPU device ID specified by the user (not necessary the one the code runs on). ...
virtual ~TParameters()
Destructor.
Definition: Parameters.cpp:88
TMatrixName dx_NAME
dx variable name
Definition: MatrixNames.h:54
TDimensionSizes GetFullDimensionSizes() const
Full dimension sizes of the simulation (real classes).
Definition: Parameters.h:95
THDF5_File outputFile
Handle to the output HDF5 file.
Definition: Parameters.h:287
TParameters()
Constructor.
Definition: Parameters.cpp:533
The header file containing a class responsible for printing out info and error messages (stdout...
bool IsBenchmarkFlag() const
Is –benchmark flag set?
TMatrixName pml_z_alpha_NAME
pml_z_alpha variable name
Definition: MatrixNames.h:118
static void Flush(const TLogLevel queryLevel)
Flush output messages.
Definition: Logger.cpp:109
size_t sensor_mask_ind_size
sensor_mask_ind_size value.
Definition: Parameters.h:321
float c0_scalar
c0_scalar value.
Definition: Parameters.h:385
size_t sensor_mask_corners_size
sensor_mask_corners_size - how many cuboids are in the mask.
Definition: Parameters.h:323
void ReadScalarValue(const hid_t parentGroup, TMatrixName &datasetName, float &value)
Read the scalar value under a specified group, float value.
Definition: HDF5_File.cpp:855
void SelectDevice()
Select cuda device for execution.
Definition: Parameters.cpp:144
bool IsStore_u_non_staggered_raw() const
Is –u_non_staggered_raw set?
Definition: Parameters.h:252
TMatrixName c0_NAME
c0 variable name
Definition: MatrixNames.h:63
TMatrixName rho0_sgx_NAME
rho0_sgx variable name
Definition: MatrixNames.h:253
void ReadHeaderFromInputFile(THDF5_File &inputFile)
Read header from the input file.
Definition: HDF5_File.cpp:1241
float dx
dx value.
Definition: Parameters.h:302
Class storing all parameters of the simulation.
Definition: Parameters.h:49
size_t nt
Nt value.
Definition: Parameters.h:295
void PrintSimulatoinSetup()
Print the simulation setup (all parameters)
Definition: Parameters.cpp:167
float rho0_sgz_scalar
rho0_sgz_scalar value.
Definition: Parameters.h:406
TErrorMessage ERR_FMT_BAD_INPUT_FILE_FORMAT
Command line parameters error message.
size_t uy_source_flag
uy_source_flag value.
Definition: Parameters.h:335
hid_t GetRootGroup() const
Get handle to the root group.
Definition: HDF5_File.h:573
The header file storing names of all variables/matrices/output streams used in the simulation...
size_t GetBenchmarkTimeStepsCount() const
Get benchmark time step count.
TOutputMessage OUT_FMT_SELECTED_DEVICE
Output message.
TMatrixName dz_NAME
dz variable name
Definition: MatrixNames.h:58
size_t ny
number of elements in the y direction
TMatrixName uy_source_flag_NAME
uy_source_flag variable name
Definition: MatrixNames.h:123
TMatrixName uz_source_flag_NAME
uz_source_flag variable name
Definition: MatrixNames.h:125
TMatrixName Nz_NAME
Nz variable name.
Definition: MatrixNames.h:75
size_t t_index
actual time index (time step of the simulation).
Definition: Parameters.h:297
int GetDeviceIdx() const
Get Idx of the device being used.
TOutputMessage OUT_FMT_NUMBER_OF_THREADS
Output message.
Basic (default) level of verbosity.
Definition: Logger.h:63
TMatrixName u_source_many_NAME
u_source_many variable name
Definition: MatrixNames.h:128
size_t pml_x_size
pml_x_size value.
Definition: Parameters.h:364
TMatrixName pml_x_alpha_NAME
pml_x_alpha variable name
Definition: MatrixNames.h:114
TMatrixName Nx_NAME
Nx variable name.
Definition: MatrixNames.h:71
TMatrixName pml_x_size_NAME
pml_x_size variable name
Definition: MatrixNames.h:92
float dy
dy value.
Definition: Parameters.h:304
TMatrixName alpha_coeff_NAME
alpha_coeff variable name
Definition: MatrixNames.h:68
void SaveScalarsToFile(THDF5_File &outputFile)
Save scalar values into the output HDF5 file.
Definition: Parameters.cpp:432
bool CheckMajorFileVersion()
Check major file version.
Definition: HDF5_File.h:862
THDF5_FileHeader fileHeader
Handle to file header.
Definition: Parameters.h:292
TOutputMessage OUT_FMT_DEVICE_ID
Output message.
TErrorMessage ERR_FMT_BAD_MINOR_FILE_VERSION
Command line parameters error message.
bool CheckMinorFileVersion()
Check minor file version.
Definition: HDF5_File.h:872
TOutputMessage OUT_FMT_READING_CONFIGURATION
Output message.
THDF5_FileHeader::TFileType GetFileType()
Get File type.
Definition: HDF5_File.cpp:1472
size_t p0_source_flag
p0_source_flag value.
Definition: Parameters.h:342
void Init(int argc, char **argv)
Parse command line and read scalar values to init the class.
Definition: Parameters.cpp:106
TFileVersion GetFileVersion()
Set major file version in a string.
Definition: HDF5_File.cpp:1447
size_t pml_z_size
pml_z_size value.
Definition: Parameters.h:368
float rho0_scalar
rho0_scalar value.
Definition: Parameters.h:400
float rho0_sgx_scalar
rho0_sgx_scalar value.
Definition: Parameters.h:402
TSensorMaskType sensor_mask_type
sensor mask type (0 = index, 1 = corners).
Definition: Parameters.h:319
static std::string FormatMessage(const std::string &format, Args...args)
C++-11 replacement for sprintf that works with std::string instead of char *.
Definition: Logger.h:126
size_t p_source_index_size
p_source_index_size value.
Definition: Parameters.h:328
bool rho0_scalar_flag
rho0_scalar_flag value.
Definition: Parameters.h:398
THDF5_File checkpointFile
Handle to the checkpoint HDF5 file.
Definition: Parameters.h:289
float absorb_tau_scalar
absorb_tau_scalar value.
Definition: Parameters.h:390
TErrorMessage ERR_FMT_BAD_MAJOR_File_Version
Command line parameters error message.
TMatrixName nonuniform_grid_flag_NAME
nonuniform_grid_flag variable name
Definition: MatrixNames.h:157
TMatrixName p_source_many_NAME
p_source_many variable name
Definition: MatrixNames.h:130
Advanced level of verbosity.
Definition: Logger.h:65
TCommandLineParameters commandLineParameters
Class with command line parameters.
Definition: Parameters.h:282
TDimensionSizes fullDimensionSizes
Full 3D dimension sizes.
Definition: Parameters.h:314
size_t p_source_many
p_source_many value.
Definition: Parameters.h:354
size_t nz
number of elements in the z direction
static void Log(const TLogLevel queryLevel, const std::string &format, Args...args)
Log desired activity for a given log level, version with string format.
Definition: Logger.h:85
TOutputMessage OUT_FMT_SEPARATOR
Output message - separator.
TOutputMessage OUT_FMT_DOMAIN_SIZE_FORMAT
Output message.
TErrorMessage ERR_FMT_BAD_SENSOR_MASK_TYPE
Command line parameters error message.
size_t GetDatasetElementCount(const hid_t parentGroup, TMatrixName &datasetName)
Get dataset element count under a specified group.
Definition: HDF5_File.cpp:1006
size_t u_source_many
u_source_many value.
Definition: Parameters.h:347
TOutputMessage OUT_FMT_SENSOR_MASK_CUBOID
Output message.
bool IsVersion() const
Is –version flag set?
float rho0_sgy_scalar
rho0_sgy_scalar value.
Definition: Parameters.h:404
size_t pml_y_size
pml_y_size value.
Definition: Parameters.h:366
TMatrixName rho0_sgy_NAME
rho0_sgy variable name
Definition: MatrixNames.h:255
size_t GetStartTimeIndex() const
Get start time index when sensor data collection begins.
size_t Get_nt() const
Get Nt value.
Definition: Parameters.h:100
std::string GetGitHash() const
Get Git hash of the code.
Definition: Parameters.cpp:513
float alpha_coeff_scalar
alpha_coeff_scalar value.
Definition: Parameters.h:380
TSensorMaskType Get_sensor_mask_type() const
Get sensor mask type (linear or corners).
Definition: Parameters.h:166
bool IsCopySensorMask() const
is –copy_mask set
Definition: Parameters.h:267
TMatrixName rho0_NAME
rho0 variable name
Definition: MatrixNames.h:251
void ParseCommandLine(int argc, char **argv)
Parse command line.
Class wrapping the HDF5 routines.
Definition: HDF5_File.h:500
TMatrixName Nt_NAME
Nt variable name.
Definition: MatrixNames.h:48
Structure with 4D dimension sizes (3 in space and 1 in time).
TOutputMessage OUT_FMT_DONE
Output message - Done with two spaces.
TMatrixName sensor_mask_type_NAME
sensor_mask_type variable name
Definition: MatrixNames.h:168