CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > CFX

Advanced post-processing (to Excel)

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 30, 2008, 16:28
Default Advanced post-processing (to Excel)
  #1
Felix
Guest
 
Posts: n/a
Hello,

I'm looking to do some very efficient automatic post-processing but I don't even know if it's feasible so any advice is welcome. What I would like to do is to export data directly from CFX-Post to MS Excel by launching a .cse file and without having to write intermediate files.

The thing is I often have to export data from CFX-Post to Excel for post-processing and presentation of CFD results. So far, I used to export results to a .dat file and then copy-paste the raw data in an Excel sheet. However, the number of files I have to deal with is quite important and the whole copy-paste/convert thing is time-consuming (and also very boring).

I know that it is possible to write an Excel Macro to read many files but I would then have to specify the File.dat names in my spreadsheet and I would like to avoid that as much as possible (and also get rid of the .dat step).

I don't know if this is even possible but I've seen very interesting interaction between Excel and softwares like Pro/Engineer and Catia and it would be amazing to do similar things with CFX.

Thanks for your help and time,

Felix

  Reply With Quote

Old   May 1, 2008, 05:45
Default Re: Advanced post-processing (to Excel)
  #2
SpaceDude
Guest
 
Posts: n/a
You might consider using a high-level interpreted programming language like python (instead of Excel Macro's), it is ideally suited for these kinds of batch processing tasks. See below:

http://www.python.org/

Though you will need to spend some time learning the language it is well worth it in the long run.
  Reply With Quote

Old   May 1, 2008, 09:32
Default Re: Advanced post-processing (to Excel)
  #3
Andrew
Guest
 
Posts: n/a
You do not need to explicitly state the names of every "DAT" file before importing into Excel.

Hit Alt+F11 to open the VB editor. In the editor go to tools->references. Add the Microsoft Scripting Runtime reference. This makes the "FileSystemObject" available.

Put all your dat files in the same folder and run this macro. Be sure to replace "c:\location_of_dat_files" with the correct folder.

Sub ImportStuff()

Dim fso As New Scripting.FileSystemObject

Dim f As Scripting.File

Dim w As Worksheet

For Each f In fso.GetFolder("c:\location_of_dat_files").Files

If LCase(f.Name) Like "*.dat" Then

Set w = ActiveWorkbook.Worksheets.Add

w.Name = f.Name

With w.QueryTables.Add("TEXT;" & f.ShortPath, Range("A1"))

.SaveData = True

.TextFileParseType = xlDelimited

.TextFileCommaDelimiter = True

.Refresh False

End With

End If

Next

Set w = Nothing

Set fso = Nothing

End Sub
  Reply With Quote

Old   May 2, 2008, 10:49
Default Re: Advanced post-processing (to Excel)
  #4
Felix
Guest
 
Posts: n/a
Thank you very much for your macro Andrew. It does a great part of the long, boring job and it does it fast ! I should be able to adapt it so it fits perfectly in the actual sheet I have. I don't have a lot of experience with Excel macros but I'm sure I can specify where to paste the data instead of creating new sheets.

SpaceDude, Python looks like a great software but it would mean that many people here would have to learn it so I'll stick with simple macros as long as possible.

Thanks again,

Felix
  Reply With Quote

Old   May 2, 2008, 14:30
Default Re: Advanced post-processing (to Excel)
  #5
Andrew
Guest
 
Posts: n/a
To change where it outputs the data, look at the code:

Set w = ActiveWorkbook.Worksheets.Add

w.Name = f.Name

With w.QueryTables.Add("TEXT;" & f.ShortPath, Range("A1"))

Instead of creating a new workbook, you can set w to an existing worksheet:

Set w = ActiveWorkbook.WorkSheets("NAME_OF_WORKSHEET")

You can remove the w.Name line, that just renames the sheet. Then when adding the querytable change the Range("A1") to the appropriate location by putting the origin cell's location within the quotes.
  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
Ansys Post processing ano999 ANSYS 1 May 27, 2011 17:24
NO model vs post processing in coal combustion,CFX sakalido CFX 1 April 15, 2011 15:07
post processing for KIVA dirga Main CFD Forum 5 April 23, 2009 11:58
Tecplot for CFX post processing pantangi goud CFX 2 August 24, 2005 17:42
Post Processing in FEM Abhijit Tilak Main CFD Forum 0 April 26, 2004 12:59


All times are GMT -4. The time now is 18:16.