On 12/5/06, Charles R Harris <charlesr.harris@gmail.com> wrote:
On 12/3/06, fsenkel@verizon.net <fsenkel@verizon.net> wrote:
Hello,
I'm taking a CFD class, one of the codes I wrote runs very slow. When I look at hotshot is says the function below is the problem. Since this is an explicit step, the for loops are only traversed once, so I think it's caused by memory usage, but I'm not sure if it's the local variables or the loop? I can vectorize the inner loop, would declaring the data structures in the calling routine and passing them in be a better idea than using local storage?
I'm new at python and numpy, I need to look at how to get profiling information for the lines within a function.
Thank you,
Frank
PS I tried to post this via google groups, but it didn't seem to go through, sorry if it ends up as multiple postings
<snip>
Explicit indexing tends to be very slow. I note what looks to be a lot of differencing in the code, so I suspect what you have here is a PDE. Your best bet in the short term is to vectorize as many of these operations as possible, but because the expression is so complicated it is a bit of a chore to see just how. It your CFD class allows it, there are probably tools in scipy that are adapted to this sort of problem, and in particular to CFD. Sandia also puts out PyTrilinos, http://software.sandia.gov/trilinos/packages/pytrilinos/, which provides interfaces to distributed and parallel PDE solvers. It's big iron software for serious problems, so might be a bit of overkill for your applications.
If it is a PDE, you might also want to look into sparse matrices. Other folks here can tell you more about that. Chuck