CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (http://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   OpenFOAM's output ability? (http://www.cfd-online.com/Forums/openfoam-programming-development/103123-openfoams-output-ability.html)

lakeat June 11, 2012 14:19

OpenFOAM's output ability?
 
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?

wyldckat June 16, 2012 05:29

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

lakeat June 16, 2012 12:59

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? :)

wyldckat June 16, 2012 13:14

Quote:

Originally Posted by lakeat (Post 366805)
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 (Post 366805)
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 :)

lakeat June 16, 2012 13:46

Quote:

Originally Posted by wyldckat (Post 366806)
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? :)

wyldckat June 16, 2012 17:13

Quote:

Originally Posted by lakeat (Post 366812)
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 (Post 366812)
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 :D
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 (Post 366812)
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 (Post 366812)
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 :cool:

My current estimate is that about 70% of my posts are concerning installation of OpenFOAM, wherever it may be :rolleyes:


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