![]() |
kspaceFirstOrder3D-CUDA
1.1
The CUDA/C++ implementation of the k-wave toolbox for the time-domain simulation of acoustic wave fields in 3D
|
Class responsible for running the k-space first order 3D method. More...
#include <KSpaceFirstOrder3DSolver.h>
Public Member Functions | |
TKSpaceFirstOrder3DSolver () | |
Constructor. More... | |
virtual | ~TKSpaceFirstOrder3DSolver () |
Destructor. More... | |
virtual void | AllocateMemory () |
Memory allocation. More... | |
virtual void | FreeMemory () |
Memory deallocation. | |
virtual void | LoadInputData () |
Load simulation data from the input file. More... | |
virtual void | Compute () |
Compute the k-space simulation. More... | |
size_t | GetHostMemoryUsageInMB () |
Get memory usage in MB on the CPU side. More... | |
size_t | GetDeviceMemoryUsageInMB () |
Get memory usage in MB on the GPU side. More... | |
const std::string | GetCodeName () const |
Get code name - release code version. More... | |
void | PrintFullNameCodeAndLicense () const |
Print the code name and license. More... | |
double | GetTotalTime () const |
Get total simulation time. More... | |
double | GetPreProcessingTime () const |
Get pre-processing time. More... | |
double | GetDataLoadTime () const |
Get data load time. More... | |
double | GetSimulationTime () const |
Get simulation time (time loop). More... | |
double | GetPostProcessingTime () const |
Get post-processing time. More... | |
double | GetCumulatedTotalTime () const |
Get total simulation time cumulated over all legs. More... | |
double | GetCumulatedPreProcessingTime () const |
Get pre-processing time cumulated over all legs. More... | |
double | GetCumulatedDataLoadTime () const |
Get data load time cumulated over all legs. More... | |
double | GetCumulatedSimulationTime () const |
Get simulation time (time loop) cumulated over all legs. More... | |
double | GetCumulatedPostProcessingTime () const |
Get post-processing time cumulated over all legs. More... | |
Protected Member Functions | |
TKSpaceFirstOrder3DSolver (const TKSpaceFirstOrder3DSolver &src) | |
Copy constructor not allowed for public. | |
TKSpaceFirstOrder3DSolver & | operator= (const TKSpaceFirstOrder3DSolver &src) |
operator = not allowed for public. | |
void | InitializeFFTPlans () |
Initialize FFT plans. More... | |
void | PreProcessingPhase () |
Compute pre-processing phase. | |
void | ComputeMainLoop () |
Compute the main time loop of the kspaceFirstOrder3D. More... | |
void | PostProcessing () |
Post processing, and closing the output streams. | |
void | StoreSensorData () |
Store sensor data. More... | |
void | WriteOutputDataInfo () |
Write statistics and header into the output file. More... | |
void | SaveCheckpointData () |
Save checkpoint data. More... | |
void | ComputeVelocity () |
Compute new values of acoustic velocity. More... | |
void | ComputeGradientVelocity () |
Compute new values of acoustic velocity gradients. More... | |
void | ComputeDensityNonliner () |
Compute new values of acoustic density for non-linear case. More... | |
void | ComputeDensityLinear () |
Compute new values of acoustic density for linear case. More... | |
void | ComputePressureNonlinear () |
Compute acoustic pressure for nonlinear case. More... | |
void | ComputePressureLinear () |
Compute acoustic pressure for linear case. | |
void | AddVelocitySource () |
Add in velocity source. More... | |
void | AddPressureSource () |
Add in pressure source. | |
void | Calculate_p0_source () |
Calculate p0_ ource. More... | |
void | GenerateKappa () |
Generate kappa matrix for non-absorbing media. More... | |
void | GenerateKappaAndNablas () |
Generate kappa matrix, absorb_nabla1, absorb_nabla2 for absorbing media. | |
void | GenerateTauAndEta () |
Generate absorb_tau, absorb_eta for heterogenous media. More... | |
void | GenerateInitialDenisty () |
Calculate dt ./ rho0 for non-uniform grids. More... | |
void | Compute_c2 () |
Calculate square of velocity. More... | |
void | ComputePressurePartsNonLinear (TRealMatrix &rho_part, TRealMatrix &BonA_part, TRealMatrix &du_part) |
Calculate three temporary sums in the new pressure formula, non-linear absorbing case. More... | |
void | ComputePressurePartsLinear (TRealMatrix &rhoxyz_sum, TRealMatrix &rho0_du_sum) |
Calculate two temporary sums in the new pressure formula, linear absorbing case. More... | |
void | SumPressureTermsNonlinear (TRealMatrix &absorb_tau_temp, TRealMatrix &absorb_eta_temp, TRealMatrix &BonA_temp) |
Sum sub-terms to calculate new pressure, non-linear case. More... | |
void | SumPressureTermsLinear (TRealMatrix &absorb_tau_temp, TRealMatrix &absorb_eta_temp, TRealMatrix &rhoxyz_sum) |
Sum sub-terms to calculate new pressure, linear case. More... | |
void | SumPressureNonlinearLossless () |
Sum sub-terms for new p, linear lossless case. More... | |
void | SumPressureLinearLossless () |
Sum sub-terms for new p, linear lossless case. More... | |
void | CalculateShiftedVelocity () |
Calculate ux_shifted, uy_shifted and uz_shifted. More... | |
void | PrintStatistics () |
Print progress statistics. More... | |
bool | IsTimeToCheckpoint () |
Is time to checkpoint (save actual state on disk). More... | |
bool | IsCheckpointInterruption () const |
Was the loop interrupted to checkpoint? More... | |
void | CheckOutputFile () |
Check the output file has the correct format and version. More... | |
void | CheckCheckpointFile () |
Check the checkpoint file has the correct format and version. More... | |
void | LoadElapsedTimeFromOutputFile (THDF5_File &o1utputFile) |
Reads the header of the output file and sets the cumulative elapsed time from the first log. More... | |
TRealMatrix & | Get_kappa () |
Get the kappa matrix from the container. | |
TRealMatrix & | Get_c2 () |
Get the c^2 matrix from the container. | |
TRealMatrix & | Get_p () |
Get the p matrix from the container. | |
TRealMatrix & | Get_ux_sgx () |
Get the ux_sgx matrix from the container. | |
TRealMatrix & | Get_uy_sgy () |
Get the uy_sgy matrix from the container. | |
TRealMatrix & | Get_uz_sgz () |
Get the uz_sgz matrix from the container. | |
TRealMatrix & | Get_ux_shifted () |
Get the ux_shifted matrix from the container. | |
TRealMatrix & | Get_uy_shifted () |
Get the uy_shifted matrix from the container. | |
TRealMatrix & | Get_uz_shifted () |
Get the uz_shifted matrix from the container. | |
TRealMatrix & | Get_duxdx () |
Get the duxdx matrix from the container. | |
TRealMatrix & | Get_duydy () |
Get the duydy matrix from the container. | |
TRealMatrix & | Get_duzdz () |
Get the duzdz matrix from the container. | |
TRealMatrix & | Get_dt_rho0_sgx () |
Get the dt.*rho0_sgx matrix from the container. | |
TRealMatrix & | Get_dt_rho0_sgy () |
Get the dt.*rho0_sgy matrix from the container. | |
TRealMatrix & | Get_dt_rho0_sgz () |
Get the dt.*rho0_sgz matrix from the container. | |
TRealMatrix & | Get_rhox () |
Get the rhox matrix from the container. | |
TRealMatrix & | Get_rhoy () |
Get the rhoy matrix from the container. | |
TRealMatrix & | Get_rhoz () |
Get the rhoz matrix from the container. | |
TRealMatrix & | Get_rho0 () |
Get the rho0 matrix from the container. | |
TComplexMatrix & | Get_ddx_k_shift_pos () |
Get the ddx_k_shift_pos matrix from the container. | |
TComplexMatrix & | Get_ddy_k_shift_pos () |
Get the ddy_k_shift_pos matrix from the container. | |
TComplexMatrix & | Get_ddz_k_shift_pos () |
Get the ddz_k_shift_pos matrix from the container. | |
TComplexMatrix & | Get_ddx_k_shift_neg () |
Get the ddx_k_shift_neg matrix from the container. | |
TComplexMatrix & | Get_ddy_k_shift_neg () |
Get the ddy_k_shift_neg matrix from the container. | |
TComplexMatrix & | Get_ddz_k_shift_neg () |
Get the ddz_k_shift_neg matrix from the container. | |
TComplexMatrix & | Get_x_shift_neg_r () |
Get the x_shift_neg_r matrix from the container. | |
TComplexMatrix & | Get_y_shift_neg_r () |
Get the y_shift_neg_r from the container. | |
TComplexMatrix & | Get_z_shift_neg_r () |
Get the y_shift_neg_r from the container. | |
TRealMatrix & | Get_pml_x_sgx () |
Get the pml_x_sgx matrix from the container. | |
TRealMatrix & | Get_pml_y_sgy () |
Get the pml_y_sgy matrix from the container. | |
TRealMatrix & | Get_pml_z_sgz () |
Get the pml_z_sgz matrix from the container. | |
TRealMatrix & | Get_pml_x () |
Get the pml_x matrix from the container. | |
TRealMatrix & | Get_pml_y () |
Get the pml_y matrix from the container. | |
TRealMatrix & | Get_pml_z () |
Get the pml_z matrix from the container. | |
TRealMatrix & | Get_dxudxn () |
Get the dxudxn matrix from the container. | |
TRealMatrix & | Get_dyudyn () |
Get the dyudyn matrix from the container. | |
TRealMatrix & | Get_dzudzn () |
Get the dzudzn matrix from the container. | |
TRealMatrix & | Get_dxudxn_sgx () |
Get the dxudxn_sgx matrix from the container. | |
TRealMatrix & | Get_dyudyn_sgy () |
Get the dyudyn_sgy matrix from the container. | |
TRealMatrix & | Get_dzudzn_sgz () |
Get the dzudzn_sgz matrix from the container. | |
TRealMatrix & | Get_BonA () |
Get the BonA matrix from the container. | |
TRealMatrix & | Get_absorb_tau () |
Get the absorb_tau matrix from the container. | |
TRealMatrix & | Get_absorb_eta () |
Get the absorb_eta matrix from the container. | |
TRealMatrix & | Get_absorb_nabla1 () |
Get the absorb_nabla1 matrix from the container. | |
TRealMatrix & | Get_absorb_nabla2 () |
Get the absorb_nabla2 matrix from the container. | |
TIndexMatrix & | Get_sensor_mask_index () |
Get the sensor_mask_index matrix from the container. | |
TIndexMatrix & | Get_sensor_mask_corners () |
Get the sensor_mask_corners matrix from the container. | |
TIndexMatrix & | Get_u_source_index () |
Get the u_source_index matrix from the container. | |
TIndexMatrix & | Get_p_source_index () |
Get the p_source_index matrix from the container. | |
TIndexMatrix & | Get_delay_mask () |
Get the delay_mask matrix from the container. | |
TRealMatrix & | Get_transducer_source_input () |
Get the transducer_source_input matrix from the container. | |
TRealMatrix & | Get_p_source_input () |
Get the p_source_input matrix from the container. | |
TRealMatrix & | Get_p0_source_input () |
Get the p0_source_input from the container. | |
TRealMatrix & | Get_ux_source_input () |
Get the ux_source_input matrix from the container. | |
TRealMatrix & | Get_uy_source_input () |
Get the uy_source_input matrix from the container. | |
TRealMatrix & | Get_uz_source_input () |
Get the uz_source_input matrix from the container. | |
TRealMatrix & | Get_temp_1_real_3D () |
Get the Temp_1_RS3D matrix from the container. | |
TRealMatrix & | Get_temp_2_real_3D () |
Get the Temp_2_RS3D matrix from the container. | |
TRealMatrix & | Get_temp_3_real_3D () |
Get the Temp_3_RS3D matrix from the container. | |
TCUFFTComplexMatrix & | Get_cufft_x_temp () |
Get the CUFFT_X_temp from the container. | |
TCUFFTComplexMatrix & | Get_cufft_y_temp () |
Get the FFT_Y_temp from the container. | |
TCUFFTComplexMatrix & | Get_cufft_z_temp () |
Get the FFT_Z_temp from the container. | |
TCUFFTComplexMatrix & | Get_cufft_shift_temp () |
Get the FFT_shift_temp the container. | |
Private Attributes | |
TMatrixContainer | matrixContainer |
Matrix container with all the matrix classes. | |
TOutputStreamContainer | outputStreamContainer |
Output stream container. | |
TParameters & | parameters |
Global parameters of the simulation. | |
size_t | actPercent |
Percentage of the simulation done. | |
bool | isTimestepRightAfterRestore |
This variable is true when calculating first time step after restore from checkpoint (to allow asynchronous IO) | |
TTimeMeasure | totalTime |
Total time of the simulation. | |
TTimeMeasure | preProcessingTime |
Pre-processing time of the simulation. | |
TTimeMeasure | dataLoadTime |
Data load time of the simulation. | |
TTimeMeasure | simulationTime |
Simulation time of the simulation. | |
TTimeMeasure | postProcessingTime |
Post-processing time of the simulation. | |
TTimeMeasure | iterationTime |
Iteration time of the simulation. | |
Class responsible for running the k-space first order 3D method. This class maintain the whole k-wave (implements the time loop).
Definition at line 57 of file KSpaceFirstOrder3DSolver.h.
TKSpaceFirstOrder3DSolver::TKSpaceFirstOrder3DSolver | ( | ) |
Constructor of the class.
Definition at line 77 of file KSpaceFirstOrder3DSolver.cpp.
|
virtual |
Destructor of the class.
Definition at line 93 of file KSpaceFirstOrder3DSolver.cpp.
|
protected |
Add velocity source to the particle velocity.
Definition at line 1297 of file KSpaceFirstOrder3DSolver.cpp.
|
virtual |
The method allocates the matrix container and create all matrices and creates all output streams.
Definition at line 110 of file KSpaceFirstOrder3DSolver.cpp.
|
protected |
Calculate p0 source when necessary.
Definition at line 1347 of file KSpaceFirstOrder3DSolver.cpp.
|
protected |
Calculated shifted velocities.
ux_shifted = real(ifft(bsxfun(@times, x_shift_neg, fft(ux_sgx, [], 1)), [], 1));
uy_shifted = real(ifft(bsxfun(@times, y_shift_neg, fft(uy_sgy, [], 2)), [], 2));
uz_shifted = real(ifft(bsxfun(@times, z_shift_neg, fft(uz_sgz, [], 3)), [], 3));
Definition at line 1902 of file KSpaceFirstOrder3DSolver.cpp.
|
protected |
Check the file type and the version of the checkpoint file.
ios::failure | if an error happens |
Definition at line 2046 of file KSpaceFirstOrder3DSolver.cpp.
|
protected |
Check the output file has the correct format and version.
ios::failure | if an error happens |
Definition at line 1991 of file KSpaceFirstOrder3DSolver.cpp.
|
virtual |
This method computes k-space First Order 3D simulation. It launches calculation on a given dataset going through FFT initialization, pre-processing, main loop and post-processing phases.
Definition at line 240 of file KSpaceFirstOrder3DSolver.cpp.
|
protected |
Compute c^2 on the CPU side.
Definition at line 1701 of file KSpaceFirstOrder3DSolver.cpp.
|
protected |
Calculate new values of rhox, rhoy and rhoz for linear case.
Definition at line 1188 of file KSpaceFirstOrder3DSolver.cpp.
|
protected |
Calculate new values of rhox, rhoy and rhoz for non-linear case.
Definition at line 1152 of file KSpaceFirstOrder3DSolver.cpp.
|
protected |
Compute new values for duxdx, duydy, duzdz, gradient of velocity.
Definition at line 1117 of file KSpaceFirstOrder3DSolver.cpp.
|
protected |
Compute the main time loop of KSpaceFirstOrder3D.
Definition at line 771 of file KSpaceFirstOrder3DSolver.cpp.
|
protected |
Compute acoustic pressure for non-linear case.
Definition at line 1224 of file KSpaceFirstOrder3DSolver.cpp.
|
protected |
Calculate two temporary sums in the new pressure formula, linear absorbing case.
[out] | rhoxyz_sum | -rhox_sgx + rhoy_sgy + rhoz_sgz |
[out] | rho0_du_sum | - rho0* (duxdx + duydy + duzdz); |
Definition at line 1763 of file KSpaceFirstOrder3DSolver.cpp.
|
protected |
Compute three temporary sums in the new pressure formula, non-linear absorbing case.
[out] | rho_part | - rhox_sgx + rhoy_sgy + rhoz_sgz |
[out] | BonA_part | - BonA + rho ^2 / 2 rho0 + (rhox_sgx + rhoy_sgy + rhoz_sgz) |
[out] | du_part | - rho0* (duxdx + duydy + duzdz) |
Definition at line 1729 of file KSpaceFirstOrder3DSolver.cpp.
|
protected |
Compute new values of ux_sgx, uy_sgy, uz_sgz (acoustic velocity).
Definition at line 1049 of file KSpaceFirstOrder3DSolver.cpp.
|
protected |
Prepare dt./ rho0 for non-uniform grid.
Definition at line 1629 of file KSpaceFirstOrder3DSolver.cpp.
|
protected |
Generate kappa matrix for non-absorbing mode.
Definition at line 1414 of file KSpaceFirstOrder3DSolver.cpp.
|
protected |
Generate absorb_tau and absorb_eta in for heterogenous media.
Definition at line 1541 of file KSpaceFirstOrder3DSolver.cpp.
const string TKSpaceFirstOrder3DSolver::GetCodeName | ( | ) | const |
Get release code version.
Definition at line 435 of file KSpaceFirstOrder3DSolver.cpp.
double TKSpaceFirstOrder3DSolver::GetCumulatedDataLoadTime | ( | ) | const |
Get data load time cumulated over all legs.
Definition at line 628 of file KSpaceFirstOrder3DSolver.cpp.
double TKSpaceFirstOrder3DSolver::GetCumulatedPostProcessingTime | ( | ) | const |
Get post-processing time cumulated over all legs.
Definition at line 650 of file KSpaceFirstOrder3DSolver.cpp.
double TKSpaceFirstOrder3DSolver::GetCumulatedPreProcessingTime | ( | ) | const |
Get pre-processing time cumulated over all legs.
Definition at line 617 of file KSpaceFirstOrder3DSolver.cpp.
double TKSpaceFirstOrder3DSolver::GetCumulatedSimulationTime | ( | ) | const |
Get simulation time (time loop) cumulated over all legs.
Definition at line 639 of file KSpaceFirstOrder3DSolver.cpp.
double TKSpaceFirstOrder3DSolver::GetCumulatedTotalTime | ( | ) | const |
Get total simulation time cumulated over all legs.
Definition at line 606 of file KSpaceFirstOrder3DSolver.cpp.
double TKSpaceFirstOrder3DSolver::GetDataLoadTime | ( | ) | const |
Get data load time.
Definition at line 573 of file KSpaceFirstOrder3DSolver.cpp.
size_t TKSpaceFirstOrder3DSolver::GetDeviceMemoryUsageInMB | ( | ) |
Get peak GPU memory usage.
Definition at line 421 of file KSpaceFirstOrder3DSolver.cpp.
size_t TKSpaceFirstOrder3DSolver::GetHostMemoryUsageInMB | ( | ) |
Get peak CPU memory usage.
Definition at line 389 of file KSpaceFirstOrder3DSolver.cpp.
double TKSpaceFirstOrder3DSolver::GetPostProcessingTime | ( | ) | const |
Get post-processing time.
Definition at line 596 of file KSpaceFirstOrder3DSolver.cpp.
double TKSpaceFirstOrder3DSolver::GetPreProcessingTime | ( | ) | const |
Get pre-processing time.
Definition at line 562 of file KSpaceFirstOrder3DSolver.cpp.
double TKSpaceFirstOrder3DSolver::GetSimulationTime | ( | ) | const |
Get simulation time (time loop).
Definition at line 585 of file KSpaceFirstOrder3DSolver.cpp.
double TKSpaceFirstOrder3DSolver::GetTotalTime | ( | ) | const |
Get total simulation time.
Definition at line 551 of file KSpaceFirstOrder3DSolver.cpp.
|
protected |
Initialize FFT plans.
Definition at line 665 of file KSpaceFirstOrder3DSolver.cpp.
|
protected |
Was the loop interrupted to checkpoint?
Definition at line 1980 of file KSpaceFirstOrder3DSolver.cpp.
|
protected |
Is time to checkpoint?
Definition at line 1964 of file KSpaceFirstOrder3DSolver.cpp.
|
protected |
Restore cumulated elapsed time from the output file. Open the header, read this and store into TMPI_Time classes
[in] | outputFile | - Output file |
Definition at line 2102 of file KSpaceFirstOrder3DSolver.cpp.
|
virtual |
Load data from the input file provided by the parameter class and creates the output time series streams.
Definition at line 140 of file KSpaceFirstOrder3DSolver.cpp.
void TKSpaceFirstOrder3DSolver::PrintFullNameCodeAndLicense | ( | ) | const |
Print full code name and the license
Definition at line 444 of file KSpaceFirstOrder3DSolver.cpp.
|
protected |
Print progress statistics.
Definition at line 1926 of file KSpaceFirstOrder3DSolver.cpp.
|
protected |
Save checkpoint data into the checkpoint file, flush aggregated outputs into the output file.
Definition at line 985 of file KSpaceFirstOrder3DSolver.cpp.
|
protected |
Store sensor data. This routine exploits asynchronous behavior. It first performs IO from the i-1th step while waiting for ith step to come to the point of sampling.
Definition at line 915 of file KSpaceFirstOrder3DSolver.cpp.
|
protected |
Sum sub-terms for new p, linear lossless case.
Definition at line 1878 of file KSpaceFirstOrder3DSolver.cpp.
|
protected |
Sum sub-terms for new p, non-linear lossless case.
Definition at line 1851 of file KSpaceFirstOrder3DSolver.cpp.
|
protected |
Sum sub-terms to calculate new pressure, linear case.
[in] | absorb_tau_temp | - sub-term with absorb_tau |
[in] | absorb_eta_temp | - sub-term with absorb_eta |
[in] | rhoxyz_sum | - rhox_sgx + rhoy_sgy + rhoz_sgz |
Definition at line 1824 of file KSpaceFirstOrder3DSolver.cpp.
|
protected |
Sum sub-terms to calculate new pressure, non-linear case.
[in] | absorb_tau_temp | - tau component |
[in] | absorb_eta_temp | - BonA + rho ^2 / 2 rho0 + (rhox_sgx + rhoy_sgy + rhoz_sgz) |
[in] | BonA_temp | - rho0* (duxdx + duydy + duzdz) |
Definition at line 1790 of file KSpaceFirstOrder3DSolver.cpp.
|
protected |
Write statistics and the header into the output file.
Definition at line 947 of file KSpaceFirstOrder3DSolver.cpp.