|
[Sponsors] |
September 24, 2015, 09:32 |
Accelerating code?
|
#1 |
New Member
Join Date: Jul 2015
Posts: 9
Rep Power: 10 |
Hello,
I want to accelerate my code. I have to determine the x-component of a cell center. I know the Cell ID, so I execute this command for every cell I need Code:
mesh.C()[Cellid].x() Maybe it is more efficient to determine the required x-coordinates in one command and store them so that I can access the values? I have several for loop, which loop over all cells. Is there a possibility for exampe to only access the cells where alpha is nonzero? Do I have to generate a list for that or is there a easy way? Thank you very much. |
|
September 25, 2015, 09:46 |
|
#2 |
Senior Member
Join Date: Oct 2013
Posts: 397
Rep Power: 18 |
First of all, you need to profile your code to figure out which parts of it are slow. In my experience optimizing things like this may give a small boost, but not very much. I would try to avoid reallocating lists all the time and to store the things which can be precalculated. Also try to avoid nested loops if possible.
|
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
The FOAM Documentation Project - SHUT-DOWN | holger_marschall | OpenFOAM | 242 | March 7, 2013 12:30 |
How to make code run in parallel? | cwang5 | OpenFOAM Programming & Development | 1 | May 30, 2011 04:47 |
Open Source Vs Commercial Software | MechE | OpenFOAM | 28 | May 16, 2011 11:02 |
Small 3-D code | Zdravko Stojanovic | Main CFD Forum | 2 | July 19, 2010 10:11 |
public CFD Code development | Heinz Wilkening | Main CFD Forum | 38 | March 5, 1999 11:44 |