uw-comphys / openccm

OpenCCM is a CFD-based compartment modelling software package. It is primarily intended for convection dominated reactive flows which feature a weak or one-way coupling between the reactive species and the carrier fluid, i.e. the reaction does not substantially influence the fluid flow over the course of the simulation.
https://uw-comphys.github.io/openccm/
GNU Lesser General Public License v2.1
0 stars 3 forks source link

Speed up _calculate_facet_normals and _calculate_facet_sizes #22

Closed Alex-Vasile closed 5 months ago

Alex-Vasile commented 5 months ago

Both _calculate_facet_normals and _calculate_facet_sizes used np.cross extensively. The overhead of calling the general function was very high, this is 5x faster which makes a big difference for large meshes.

Will need to investigate further how to rework the functions as they take up a very large percentage of the total mesh conversion time.

nasserma commented 5 months ago

Just to clarify, the optimization was to replace the cross product operation implemented using np.cross() with inline/algebraic formulation, removing the overhead of a function call.

Alex-Vasile commented 5 months ago

The overhead and the extra cost needed to obtained the generality afforded by np.cross.