kspaceFirstOrder3D-OMP
1.1
The 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. More... | |
virtual void | LoadInputData () |
Load simulation data from the input file. More... | |
virtual void | Compute () |
Compute the 3D kspace first order simulation. More... | |
virtual void | PrintParametersOfSimulation (FILE *file) |
Print parameters of the simulation. More... | |
virtual size_t | ShowMemoryUsageInMB () |
Get memory usage in MB. More... | |
string | GetCodeName () |
Get code name. | |
void | PrintFullNameCodeAndLicense (FILE *file) |
Print the code name and license. More... | |
void | SetProcessorAffinity () |
Set processor affinity. More... | |
double | GetTotalTime () const |
Get total simulation time. | |
double | GetPreProcessingTime () const |
Get pre-processing time. | |
double | GetDataLoadTime () const |
Get data load time. | |
double | GetSimulationTime () const |
Get simulation time (time loop). | |
double | GetPostProcessingTime () const |
Get post-processing time. | |
double | GetCumulatedTotalTime () const |
Get total simulation time cumulated over all legs. | |
double | GetCumulatedPreProcessingTime () const |
Get pre-processing time cumulated over all legs. | |
double | GetCumulatedDataLoadTime () const |
Get data load time cumulated over all legs. | |
double | GetCumulatedSimulationTime () const |
Get simulation time (time loop) cumulated over all legs. | |
double | GetCumulatedPostProcessingTime () const |
Get post-processing time cumulated over all legs. | |
Protected Member Functions | |
TKSpaceFirstOrder3DSolver (const TKSpaceFirstOrder3DSolver &src) | |
Copy constructor not allowed for public. | |
TKSpaceFirstOrder3DSolver & | operator= (const TKSpaceFirstOrder3DSolver &src) |
operator = not allowed for public. | |
void | InitializeFFTWPlans () |
Initialize FFT plans. More... | |
void | PreProcessingPhase () |
Compute pre-processing phase. More... | |
void | Compute_MainLoop () |
Compute the main time loop of the kspaceFirstOrder3D. More... | |
void | PostPorcessing () |
Post processing, and closing the output streams. More... | |
void | StoreSensorData () |
Store sensor data. More... | |
void | SaveCheckpointData () |
Save checkpoint data. More... | |
void | WriteOutputDataInfo () |
Write statistics and header into the output file. More... | |
void | Compute_uxyz () |
compute new values of for ux_sgx, uy_sgy, uz_sgz. | |
void | Compute_duxyz () |
Compute new values of for duxdx, duydy, dzdz. More... | |
void | Compute_rhoxyz_nonlinear () |
Compute new values of rhox, rhoy, rhoz for non-linear case. More... | |
void | Compute_rhoxyz_linear () |
Compute new values of rhox, rhoy, rhoz for linear case. More... | |
void | Add_u_source () |
Add u source to the particle velocity. More... | |
void | Add_p_source () |
Add in pressure source. More... | |
void | Generate_kappa () |
Generate kappa matrix for non-absorbing media. More... | |
void | Generate_kappa_absorb_nabla1_absorb_nabla2 () |
Generate kappa matrix, absorb_nabla1, absorb_nabla2 for absorbing media. More... | |
void | Generate_absorb_tau_absorb_eta_matrix () |
Generate absorb_tau, absorb_eta for heterogenous media. More... | |
void | Calculate_dt_rho0_non_uniform () |
Calculate dt ./ rho0 for non-uniform grids. More... | |
void | Calculate_p0_source () |
Calculate p0_source. More... | |
void | Compute_c2 () |
Calculate c^2. More... | |
void | Compute_ddx_kappa_fft_p (TRealMatrix &X_Matrix, TFFTWComplexMatrix &FFT_X, TFFTWComplexMatrix &FFT_Y, TFFTWComplexMatrix &FFT_Z, const TRealMatrix &kappa, const TComplexMatrix &ddx, const TComplexMatrix &ddy, const TComplexMatrix &ddz) |
Compute part of the new velocity - gradient of p. More... | |
void | Compute_new_p_nonlinear () |
Calculate new p, non-linear case. More... | |
void | Compute_new_p_linear () |
Calculate new p linear-case, absorbing. More... | |
void | Calculate_SumRho_BonA_SumDu_SSE2 (TRealMatrix &RHO_Temp, TRealMatrix &BonA_Temp, TRealMatrix &Sum_du) |
Calculate three temporary sums in the new pressure formula, non-linear absorbing case, SSE2 version. More... | |
void | Calculate_SumRho_SumRhoDu (TRealMatrix &Sum_rhoxyz, TRealMatrix &Sum_rho0_du) |
Calculate two temporary sums in the new pressure formula, linear absorbing case. More... | |
void | Compute_Absorb_nabla1_2_SSE2 (TFFTWComplexMatrix &FFT_1, TFFTWComplexMatrix &FFT_2) |
Compute absorbing term with abosrb_nabla1 and absorb_nabla2, SSE2 version. More... | |
void | Sum_Subterms_nonlinear (TRealMatrix &Absorb_tau_temp, TRealMatrix &Absorb_eta_temp, TRealMatrix &BonA_temp) |
Sum sub-terms to calculate new pressure, non-linear case. More... | |
void | Sum_Subterms_linear (TRealMatrix &Absorb_tau_temp, TRealMatrix &Absorb_eta_temp, TRealMatrix &Sum_rhoxyz) |
Sum sub-terms to calculate new pressure, linear case. More... | |
void | Sum_new_p_nonlinear_lossless () |
Sum sub-terms for new p, linear lossless case. More... | |
void | Sum_new_p_linear_lossless () |
Sum sub-terms for new p, linear lossless case. More... | |
void | Calculate_shifted_velocity () |
Calculate ux_shifted, uy_shifted and uz_shifted. More... | |
void | PrintStatisitcs () |
Print progress statistics. More... | |
void | PrintOtputHeader () |
Print the header of the progress statistics. More... | |
bool | IsTimeToCheckpoint () |
Is time to checkpoint (save actual state on disk)? More... | |
bool | IsCheckpointInterruption () const |
Was the loop interrupted to checkpoint? | |
void | CheckOutputFile () |
Check the output file has the correct format and version. More... | |
void | RestoreCumulatedElapsedFromOutputFile () |
Reads the header of the output file and sets the cumulative elapsed time from the first log. More... | |
void | CheckCheckpointFile () |
Check the checkpoint file has the correct format and version. 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. | |
Tuxyz_sgxyzMatrix & | Get_ux_sgx () |
Get the ux_sgx matrix from the container. | |
Tuxyz_sgxyzMatrix & | Get_uy_sgy () |
Get the uy_sgy matrix from the container. | |
Tuxyz_sgxyzMatrix & | Get_uz_sgz () |
Get the uz_sgz matrix from the container. | |
Tuxyz_sgxyzMatrix & | Get_ux_shifted () |
Get the ux_shifted matrix from the container. | |
Tuxyz_sgxyzMatrix & | Get_uy_shifted () |
Get the uy_shifted matrix from the container. | |
Tuxyz_sgxyzMatrix & | 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_RS3D () |
Get the Temp_1_RS3D matrix from the container. | |
TRealMatrix & | Get_Temp_2_RS3D () |
Get the Temp_2_RS3D matrix from the container. | |
TRealMatrix & | Get_Temp_3_RS3D () |
Get the Temp_3_RS3D matrix from the container. | |
TFFTWComplexMatrix & | Get_FFT_X_temp () |
Get the FFT_X_temp from the container. | |
TFFTWComplexMatrix & | Get_FFT_Y_temp () |
Get the FFT_Y_temp from the container. | |
TFFTWComplexMatrix & | Get_FFT_Z_temp () |
Get the FFT_Z_temp from the container. | |
TFFTWComplexMatrix & | Get_FFT_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. | |
size_t | ActPercent |
Percentage of the simulation done. | |
TParameters * | Parameters |
Global parameters of the simulation. | |
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 61 of file KSpaceFirstOrder3DSolver.h.
TKSpaceFirstOrder3DSolver::TKSpaceFirstOrder3DSolver | ( | ) |
Constructor of the class.
Definition at line 84 of file KSpaceFirstOrder3DSolver.cpp.
|
virtual |
Destructor of the class.
Definition at line 103 of file KSpaceFirstOrder3DSolver.cpp.
|
protected |
Add in pressure source.
Definition at line 2201 of file KSpaceFirstOrder3DSolver.cpp.
|
protected |
Add u source to the particle velocity.
Definition at line 2162 of file KSpaceFirstOrder3DSolver.cpp.
|
virtual |
The method allocates the matrix container, creates all matrices and creates all output streams (however not allocating memory).
Definition at line 113 of file KSpaceFirstOrder3DSolver.cpp.
|
protected |
Prepare dt./ rho0 for non-uniform grid.
Definition at line 774 of file KSpaceFirstOrder3DSolver.cpp.
|
protected |
Calculate p0 source when necessary.
Definition at line 845 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 2259 of file KSpaceFirstOrder3DSolver.cpp.
|
protected |
Calculate three temporary sums in the new pressure formula
non-linear absorbing case, SSE2 version.
[out] | RHO_Temp | - rhox_sgx + rhoy_sgy + rhoz_sgz |
[out] | BonA_Temp | - BonA + rho ^2 / 2 rho0 + (rhox_sgx + rhoy_sgy + rhoz_sgz) |
[out] | Sum_du | - rho0* (duxdx + duydy + duzdz) |
Definition at line 1519 of file KSpaceFirstOrder3DSolver.cpp.
|
protected |
Calculate two temporary sums in the new pressure formula, linear absorbing case.
[out] | Sum_rhoxyz | - rhox_sgx + rhoy_sgy + rhoz_sgz |
[out] | Sum_rho0_du | - rho0* (duxdx + duydy + duzdz); |
Definition at line 1652 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 2779 of file KSpaceFirstOrder3DSolver.cpp.
|
protected |
Check the output file has the correct format and version.
ios::failure | if an error happens |
Definition at line 2703 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 217 of file KSpaceFirstOrder3DSolver.cpp.
|
protected |
Compute absorbing term with abosrb_nabla1 and absorb_nabla2, SSE2 version.
Calculate absorb_nabla1 .* fft_1
Calculate absorb_nabla2 .* fft_2
[in,out] | FFT_1 | |
[in,out] | FFT_2 |
Definition at line 1715 of file KSpaceFirstOrder3DSolver.cpp.
|
protected |
Compute c^2.
Definition at line 926 of file KSpaceFirstOrder3DSolver.cpp.
|
protected |
Compute part of the new velocity term - gradient of p represented by: bsxfun(@times, ddx_k_shift_pos, kappa .* p_k)
[in] | X_Matrix | - 3D pressure matrix |
[out] | FFT_X | - matrix to store input for iFFT (p) /dx |
[out] | FFT_Y | - matrix to store input for iFFT (p) /dy |
[out] | FFT_Z | - matrix to store input for iFFT (p) /dz |
[in] | kappa | - Real matrix of kappa |
[in] | ddx | - precomputed value of ddx_k_shift_pos |
[in] | ddy | - precomputed value of ddy_k_shift_pos |
[in] | ddz | - precomputed value of ddz_k_shift_pos |
Definition at line 962 of file KSpaceFirstOrder3DSolver.cpp.
|
protected |
Compute new values for duxdx, duydy, duzdz.
Definition at line 1032 of file KSpaceFirstOrder3DSolver.cpp.
|
protected |
Compute the main time loop of KSpaceFirstOrder3D.
Definition at line 2381 of file KSpaceFirstOrder3DSolver.cpp.
|
protected |
Compute new p for linear case.
Definition at line 2062 of file KSpaceFirstOrder3DSolver.cpp.
|
protected |
Compute new p for non-linear case.
Definition at line 2025 of file KSpaceFirstOrder3DSolver.cpp.
|
protected |
Calculate new values of rhox, rhoy and rhoz for linear case.
Definition at line 1361 of file KSpaceFirstOrder3DSolver.cpp.
|
protected |
Calculate new values of rhox, rhoy and rhoz for non-linear case.
Definition at line 1197 of file KSpaceFirstOrder3DSolver.cpp.
|
virtual |
The method frees all memory allocated by the class.
Definition at line 128 of file KSpaceFirstOrder3DSolver.cpp.
|
protected |
Generate absorb_tau and absorb_eta in for heterogenous media.
Definition at line 689 of file KSpaceFirstOrder3DSolver.cpp.
|
protected |
Generate kappa matrix for lossless case.
Definition at line 558 of file KSpaceFirstOrder3DSolver.cpp.
|
protected |
Generate kappa, absorb_nabla1, absorb_nabla2 for absorbing media.
Definition at line 614 of file KSpaceFirstOrder3DSolver.cpp.
|
protected |
Initialize FFTW plans.
Definition at line 425 of file KSpaceFirstOrder3DSolver.cpp.
|
protected |
Is time to checkpoint
Definition at line 2498 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 139 of file KSpaceFirstOrder3DSolver.cpp.
|
protected |
Post processing the quantities, closing the output streams and storing the sensor mask.
Definition at line 2515 of file KSpaceFirstOrder3DSolver.cpp.
|
protected |
Compute pre-processing phase
Initialize all indices, pre-compute constants such as c^2, rho0_sg* x dt and create kappa, absorb_eta, absorb_tau, absorb_nabla1, absorb_nabla2 matrices.
Definition at line 481 of file KSpaceFirstOrder3DSolver.cpp.
void TKSpaceFirstOrder3DSolver::PrintFullNameCodeAndLicense | ( | FILE * | file | ) |
Print Full code name and the license.
[in] | file | - file to print the data (stdout) |
Definition at line 341 of file KSpaceFirstOrder3DSolver.cpp.
|
protected |
Print the header of the progress statistics.
Definition at line 2486 of file KSpaceFirstOrder3DSolver.cpp.
|
virtual |
Print parameters of the simulation.
[in,out] | file | - where to print the parameters |
Definition at line 291 of file KSpaceFirstOrder3DSolver.cpp.
|
protected |
Print progress statistics.
Definition at line 2449 of file KSpaceFirstOrder3DSolver.cpp.
|
protected |
Restore cumulated elapsed time form Output file (header stored in TParameters) Open the header, read this and store into TTimeMeasure classes.
Get execution times stored in the output file header
Definition at line 2677 of file KSpaceFirstOrder3DSolver.cpp.
|
protected |
Save checkpoint data into the checkpoint file, flush aggregated outputs into the output file.
Definition at line 2576 of file KSpaceFirstOrder3DSolver.cpp.
void TKSpaceFirstOrder3DSolver::SetProcessorAffinity | ( | ) |
Set processor affinity.
Definition at line 395 of file KSpaceFirstOrder3DSolver.cpp.
|
virtual |
Get peak memory usage.
Definition at line 309 of file KSpaceFirstOrder3DSolver.cpp.
|
protected |
Store sensor data.
Definition at line 2558 of file KSpaceFirstOrder3DSolver.cpp.
|
protected |
Sum sub-terms for new p, linear lossless case.
Definition at line 1987 of file KSpaceFirstOrder3DSolver.cpp.
|
protected |
Sum sub-terms for new p, non-linear lossless case.
Definition at line 1913 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] | Sum_rhoxyz | - rhox_sgx + rhoy_sgy + rhoz_sgz |
Definition at line 1845 of file KSpaceFirstOrder3DSolver.cpp.
|
protected |
Sum sub-terms to calculate new pressure, non-linear case.
[in] | Absorb_tau_temp | - |
[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 1775 of file KSpaceFirstOrder3DSolver.cpp.
|
protected |
Write statistics and the header into the output file.
Definition at line 2636 of file KSpaceFirstOrder3DSolver.cpp.