Manish Agrawal


Week 6 And 7

14 Jul 2019 »

GSoC 2019 :: gprMax Weekly Documentation

Week 6 and 7

Passed the first evalution :D

PMLs

Perfectly Matched Layers is a crucial part for building a electromagnetic simulation software. PMLs is a method of truncating computational regions in numerical methods for simulating open boundary problems. PMLs are designed so that incident waves upon the PML region from a non-PML region do not reflect back.

gprMax allows for alteration in formulation of PMLs. Currently it supports Higher Order RIPML and Multipole RIPML. Discussing the working of the variants would be out of topic here but these links can be helpful.

For testing with modeling PMLs with OpenCl, only the 2D domain space was considered. Thus if order1 PMLs are to be considered, only four PML equation come into play which are order1_xminus, order1_xplus, order1_yminus and order1_yplus. The CUDA codes for corresponding update equations were taken as reference to write the OpenCl kernel codes. Some vector initialization function related to PMLs were added to pml.py. Also, dictionaries of function name and its corresponding object for kernel function were created for field updates. The global_work_size and local_work_size parameters required for calling the kernel functions are calculated depending upon the domain of PMLs itself. The total cells that are under the PML region are the cells which will require updates resulting to that many number of work-items. Thus, global_work_size will be set to (number_of_pml_cells,1,1) and local_work_size is None. As explained earlier too, the None value can be handled by PyOpenCl and distribute the work-items evenly.

After successful testing and integration of 2D PMLs, 3D PMLs were integrated. For this all 12 functions of updates for each dimension, order and polarity were added. Files 'pml_updates_electric_HORIPML.cl' and 'pml_updates_magnetic_HORIPML.cl' are the kernel files for PML update equations for HORIPML formulation.

After basic method of kernel built was successfully tested, elementwise kernel building component was written and tested. For elementwise kernel building process, separate functions were written is separate Template objects. Also, a dictionary of arguments as strings were made which can be called according to function name. Finally, the ElementwiseKernel objects for every function is stored in a dictionary as per their function names. Template from string are useful tool for substituting values. Finally, after many minor errors and exchange of graphs between mentors, the whole PMLs were integrated with OpenCl module. They have been tested and working correctly as tested with test modules.

Voltage Source and Magnetic Dipoles

Considering Hertzian Dipoles as a basic and starting point for source integration, finally all the sources were intergrated with opencl module. Both the basic kernel built as well as elementwise kernel built. Tested with test module, they are working correctly.

For convenience, by default opencl module is meant to build the kernels by basic method. If you want to envoke the ElementwiseKernel building method add --elwise to your command line argument.

As a result of the work that has been carried out PR (#215)[https://github.com/gprMax/gprMax/pull/215] and (#216)[https://github.com/gprMax/gprMax/pull/216] are accepted.