jackhamel16 / Acoustics

Acoustic integral equation solver
1 stars 0 forks source link

Refactor integrateTriangle and solve so that quadrature points on each triangle are computed elsewhere #43

Closed jackhamel16 closed 3 years ago

jackhamel16 commented 3 years ago

The quadrature points on each triangle are computed with every call to integrateTriangle. Many calls to integrateTriangle are integrating over the same triangle at the same points so I am repeating this calculation redundantly. By moving it to buildPulseMesh and storing the quadrature points as members of PulseMesh types I should be able to save computation time.

It also might be smart to add in the parameters package during this refactor.

jackhamel16 commented 3 years ago

Also the arrays storing the quadrature points should be structured as Array{Array{Float64, 2}}. This is an array of pointers to 2D arrays. The 2D arrays should be of the format row = coordinate, col = point. This results in the fastest indexing scheme.

jackhamel16 commented 3 years ago

Left off:

scalarGreensIntegration needs access to the area quadrature points so that it can calculate the quadrature points on the sub triangles in singular integration. This might be a case where the parameters package couldve been useful if used correctly. Maybe I should be passing my pulse_mesh object to pretty much every function (maybe the exceptions can be the quadrature functions)... Doesn't doing this cause these functions to lose generality though? If they require a PulseMesh object, then they can only be used in the context of a code using the PulseMesh. Maybe that is okay though because multiple dispatch can be used to launch versions of the functions for other Mesh objects in the future.

jackhamel16 commented 3 years ago

Make scalarGreensIntegration take a PulseMesh object and unpack it, then pass what is needed to the sub functions. The sub functions can remain as they are until it is necessary to refactor those

jackhamel16 commented 3 years ago

Damn. Changes resulted in a very pleasant speed up. For 300 iterations of solve on the circular plate I am seeing

389.262349 seconds (3.76 G allocations: 366.727 GiB, 12.12% gc time)

From a second run:

224.478091 seconds (3.76 G allocations: 366.838 GiB, 9.61% gc time)

These results are almost unbelievable...

edit: All tests pass so its good to merge