CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Running, Solving & CFD

Accelerating code?

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 24, 2015, 09:32
Default Accelerating code?
  #1
New Member
 
Join Date: Jul 2015
Posts: 9
Rep Power: 10
fst-student is on a distinguished road
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()
Is this command slow ? Can it be accelerated?
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.
fst-student is offline   Reply With Quote

Old   September 25, 2015, 09:46
Default
  #2
Senior Member
 
Join Date: Oct 2013
Posts: 397
Rep Power: 18
chriss85 will become famous soon enough
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.
chriss85 is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


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


All times are GMT -4. The time now is 08:27.