# Three-Dimensional Inversion of the Time-Lapse Resistivity Method on the MPI Parallel Algorithm
## 2 Rationale and Theory
### MPI Parallel Inversion Algorithm  
To better reflect the subsurface information, three-dimensional inversion via the resistivity method uses multiple point power sources to improve the inversion performance. The corresponding amount of observation data is large, and the original serial inversion program is inefficient. When calculating the forward response, apparent resistivity, and potential at various measuring points for different power supply points, the Jacobian matrix corresponding to each source point during gradient calculation and the solution of the quasi-forward equations are independent of one another. Therefore, the problem can be divided into several independent subproblems, and parallel computing can enhance the inversion speed and efficiency. MPI is not a language, but rather a \"function library\" that can be applied to a variety of programming languages and contains hundreds of functions calling interfaces. Table 1 lists the parallel environment-related library functions used in the programming process. In parallel inversion, the main process communicates with sub-processes. The sub-processes communicate with each other, and transmit messages and data, including three \begin{table}
\begin{tabular}{c c} \hline
**Function Name** & **Functions** \\ \hline MPI\_INIT & Initializes all MPI programs. \\ MPI\_FINALIZE & Finalizes all MPI programs. \\ MPI\_COMM\_RANK & Returns the identification number for calling a process in a given communication domain, distinguishing different processes from other processes. \\ MPI\_COMM\_SIZE & Returns the number of included processes in a given communication domain. \\ \hline \end{tabular}
\end{table} 
Table 1: The parallel environment-related library functions used in the programming process. parts: message assembly, message passing, and message receiving. Table 2 shows the library functions related to communication. The MPI parallel algorithm significantly improves computational efficiency through the synchronous allocation of tasks across multiple processes. It includes both peer-to-peer and master-slave modes. In the peer-to-peer mode, all processes contribute to completing a portion of the assigned tasks. In the master-slave mode, processes are divided into master and slave processes. The master process is responsible for task allocation, message transmission, and data collection, whereas the slave processes execute the assigned tasks. In this study, the master-slave mode is selected. Suppose that there are 4 field sources, and that 10 data points are observed for each field source. N processes are used for calculations using MPI, with each process assigned 40/N field source calculation tasks. Finally, the MPI parallel algorithm is integrated into the inversion algorithm, forming a 3D time-lapse inversion MPI parallel algorithm suitable for combined data from multiple devices via the resistivity method. The MPI parallel inversion flow chart for the resistivity method is shown in Figure 3.  
The flow chart can be briefly summarized in the following steps:  
(1) The initial conductivity is inputted, and the necessary parameters for inversion are set. (2) The main process collects and assigns tasks to slave processes. (3) The calculation of the forward response between the master and slave processes is synchronized, and the computation of the objective function and gradient continues. \begin{table}
\begin{tabular}{c c} \hline \hline
**Function Name** & **Functions** \\ \hline MPI\_SEND & Sends the data in the buffer to the destination child process. \\ MPI\_RECV & Receives information from the specified process. \\ MPI\_BCAST & Sends a message from the main process to all child processes in the group that includes itself. \\ MPI\_ALLGATHER & Make each child process collect data from all other processes. \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Library functions related to communication. Figure 3: MPI parallel inversion flow chart of the resistivity method. (4) The main process collects the results from all the processes.