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

OpenFOAM's output ability?

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 11, 2012, 14:19
Default OpenFOAM's output ability?
  #1
Senior Member
 
lakeat's Avatar
 
Daniel WEI (老魏)
Join Date: Mar 2009
Location: Beijing, China
Posts: 689
Blog Entries: 9
Rep Power: 21
lakeat is on a distinguished road
Send a message via Skype™ to lakeat
I'd like Info be able to output "carriage return" and other color output to the terminal. I'm not sure if Info is able to do this or not.

Any ideas?
__________________
~
Daniel WEI
-------------
Boeing Research & Technology - China
Beijing, China
Email
lakeat is offline   Reply With Quote

Old   June 16, 2012, 05:29
Default
  #2
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,974
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Hi Daniel,

Let's see:
  • Foam::endl() is a function that (sometimes ?) uses this method (source):
    Code:
    00233 void Foam::OSstream::endl()
    00234 {
    00235     write('\n');
    00236     os_.flush();
    00237 }
  • As you can see, this code should also work:
    Code:
    Info << "\n";
    As it should:
    Code:
    Info << "\r";
  • As for colors, it heavily depends on the terminal+shell pair rendering the output. When using Bash, it seems that this should be the guidelines: http://www.faqs.org/docs/Linux-HOWTO...TO.html#AEN343 - it should simply be a matter of trial and error
    • Keep in mind that colors will only appear when the output is made directly on screen. Bash couldn't care less for what's in your log files
I vaguely remember about seeing this question asked before here on the forum... but after a brief search, I couldn't find it

Let us know some successful results!

Best regards,
Bruno
__________________
wyldckat is offline   Reply With Quote

Old   June 16, 2012, 12:59
Default
  #3
Senior Member
 
lakeat's Avatar
 
Daniel WEI (老魏)
Join Date: Mar 2009
Location: Beijing, China
Posts: 689
Blog Entries: 9
Rep Power: 21
lakeat is on a distinguished road
Send a message via Skype™ to lakeat
Quote:
Code:
00233 void Foam::OSstream::endl()
00234 {
00235     write('\n');
00236     os_.flush();
00237 }
I saw this piece of code before. And endl only represent "\n", and I didn't want to change this basic class of OpenFOAM, so I just use c++ basic print to get carriage return and colors.

Thank you Bruno. Btw, I am wondering are you staying on the forum all the time? You dont have job or research to do?
__________________
~
Daniel WEI
-------------
Boeing Research & Technology - China
Beijing, China
Email
lakeat is offline   Reply With Quote

Old   June 16, 2012, 13:14
Default
  #4
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,974
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Quote:
Originally Posted by lakeat View Post
I saw this piece of code before. And endl only represent "\n", and I didn't want to change this basic class of OpenFOAM, so I just use c++ basic print to get carriage return and colors.
It would be interesting to add coloring methods, but it's not exactly a critical thing

Quote:
Originally Posted by lakeat View Post
Thank you Bruno. Btw, I am wondering are you staying on the forum all the time? You dont have job or research to do?
I do have a job and I'm almost always busy... But on weekends and late night I do what I can to help people on the forum and take the chance to learn some more stuff around OpenFOAM
__________________
wyldckat is offline   Reply With Quote

Old   June 16, 2012, 13:46
Default
  #5
Senior Member
 
lakeat's Avatar
 
Daniel WEI (老魏)
Join Date: Mar 2009
Location: Beijing, China
Posts: 689
Blog Entries: 9
Rep Power: 21
lakeat is on a distinguished road
Send a message via Skype™ to lakeat
Quote:
Originally Posted by wyldckat View Post
It would be interesting to add coloring methods, but it's not exactly a critical thing
It is purely out of fun, coz I see paraview has color output during its compilation. So I am wondering if developers can enhance this "Info" ability.

I have an impression that OpenFOAM has built a lot of fundamental classes and templates (like scalar, vector, Info, etc.) which are so mature now that even from a pure C++ programming language point of view, it is really a great contribution! So I am wondering, adding colors, etc., which hurts the OpenFOAM overall structure nothing, and also they can enhance and mature the fundamental class, why not do it.

Btw, I do have a question concerning wmake, do you know why they keep using wmake instead a cross-platform cmake at the very beginning of FOAM?

Quote:
I do have a job and I'm almost always busy... But on weekends and late night I do what I can to help people on the forum and take the chance to learn some more stuff around OpenFOAM
Quote:
2,294
Are you aware of anyone having more posts than you?
__________________
~
Daniel WEI
-------------
Boeing Research & Technology - China
Beijing, China
Email
lakeat is offline   Reply With Quote

Old   June 16, 2012, 17:13
Default
  #6
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,974
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Quote:
Originally Posted by lakeat View Post
It is purely out of fun, coz I see paraview has color output during its compilation. So I am wondering if developers can enhance this "Info" ability.
They could, but...

Quote:
Originally Posted by lakeat View Post
I have an impression that OpenFOAM has built a lot of fundamental classes and templates (like scalar, vector, Info, etc.) which are so mature now that even from a pure C++ programming language point of view, it is really a great contribution! So I am wondering, adding colors, etc., which hurts the OpenFOAM overall structure nothing, and also they can enhance and mature the fundamental class, why not do it.
Well, I can think of a few issues:
  • Here's a test, try this on a terminal with a bash shell:
    Code:
    echo -e "\033[1;34mTesting\033[0m"
    You'll see something like this:
    Quote:
    Testing
  • Problem is that when you redirect the output to a log file, what you'll see on the text file will be:
    Code:
    \033[1;34mTesting\033[0m
    It ain't pretty to look at, is it?
Then there is the task of implementing markers and so on, because the first marker gives the desired color and the second one ends the color.

Anyway, when it comes to output - and since it's CFD - if you want colors, you do it when you're post-processing
In other words, it would be easier to write a macro for VIM or script for the shell or whatever for your favorite text editor, in order to interpret the output that you usually see in the log file.

A practical example of this is "colorgcc": http://schlueters.de/colorgcc.html - it interprets Gcc's output and displays it in a more colorful way And it's not the only one out there!

Quote:
Originally Posted by lakeat View Post
Btw, I do have a question concerning wmake, do you know why they keep using wmake instead a cross-platform cmake at the very beginning of FOAM?
Let's see, a bit of hypothetical history lesson:
  1. The first CMake was created back in 1999: http://en.wikipedia.org/wiki/CMake#History
  2. FOAM was started back in late 80's: http://en.wikipedia.org/wiki/OpenFOAM#History
So, scratch that idea
Nonetheless, this is why FreeFOAM was born: http://freefoam.sourceforge.net/ - it's OpenFOAM reimplemented to use CMake for building and Python scripts for enhanced shell control. But then people that are accustomed to "wmake", have a hard time using CMake... at least by what I've read on FreeFOAM's mailing list.


But the thing is that CMake isn't perfect either. One example is Google Chromium, where they simply reinvented the wheel one more time and created gyp: http://code.google.com/p/gyp/ - for more: http://code.google.com/p/gyp/wiki/GypVsCMake


But honestly, what I miss more on wmake vs cmake is the progress indicator...


Quote:
Originally Posted by lakeat View Post
Are you aware of anyone having more posts than you?
Bernhard, aka gschaider - 2,326

What can I say: why spend money and time playing World of Warcraft, when I can help people here on the forum

My current estimate is that about 70% of my posts are concerning installation of OpenFOAM, wherever it may be
__________________
wyldckat 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
Questions about data output aki_yafuji OpenFOAM Running, Solving & CFD 3 September 9, 2010 01:59
lift and drag on ship superstructures vaina74 OpenFOAM Running, Solving & CFD 3 June 8, 2010 12:30
[Other] Output Format of MetaMesh t42 OpenFOAM Meshing & Mesh Conversion 0 August 3, 2007 04:28
can "output control " output Nu in expression? prayskyer CFX 3 July 7, 2006 19:37
Help with DPM UDF for OUTPUT needed Zhengcai Ye FLUENT 0 January 5, 2004 16:58


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