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

[OpenFOAM.org] Need basic help with compiling OF 5.x for debugging

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree1Likes
  • 1 Post By fertinaz

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 9, 2018, 16:14
Angry Need basic help with compiling OF 5.x for debugging
  #1
Senior Member
 
Deep
Join Date: Oct 2017
Posts: 180
Rep Power: 7
deepbandivadekar is on a distinguished road
Hi,

I am trying to get to the core of this error caused at the beginning of sonicFoam

Code:
[3] 
[3] 
[3] --> FOAM FATAL ERROR: 
[3] Negative initial temperature T0: -315.342
[3] 
[3]     From function Foam::scalar Foam::species::thermo<Thermo, Type>::T(Foam::scalar, Foam::scalar, Foam::scalar, Foam::scalar (Foam::species::thermo<Thermo, Type>::*)(Foam::scalar, Foam::scalar) const, Foam::scalar (Foam::species::thermo<Thermo, Type>::*)(Foam::scalar, Foam::scalar) const, Foam::scalar (Foam::species::thermo<Thermo, Type>::*)(Foam::scalar) const) const [with Thermo = Foam::hConstThermo<Foam::perfectGas<Foam::specie> >; Type = Foam::sensibleInternalEnergy; Foam::scalar = double; Foam::species::thermo<Thermo, Type> = Foam::species::thermo<Foam::hConstThermo<Foam::perfectGas<Foam::specie> >, Foam::sensibleInternalEnergy>]
[3]     in file /home/ubuntu/OpenFOAM/OpenFOAM-5.x/src/thermophysicalModels/specie/lnInclude/thermoI.H at line 54.
[3] 
FOAM parallel run aborting
[3] 
[3] #0  Foam::error::printStack(Foam::Ostream&) at ??:?
[3] #1  Foam::error::abort() at ??:?
[3] #2  Foam::species::thermo<Foam::hConstThermo<Foam::perfectGas<Foam::specie> >, Foam::sensibleInternalEnergy>::TEs(double, double, double) const at ??:?
[3] #3  Foam::hePsiThermo<Foam::psiThermo, Foam::pureMixture<Foam::constTransport<Foam::species::thermo<Foam::hConstThermo<Foam::perfectGas<Foam::specie> >, Foam::sensibleInternalEnergy> > > >::calculate() at ??:?
[3] #4  Foam::hePsiThermo<Foam::psiThermo, Foam::pureMixture<Foam::constTransport<Foam::species::thermo<Foam::hConstThermo<Foam::perfectGas<Foam::specie> >, Foam::sensibleInternalEnergy> > > >::correct() at ??:?
[3] #5  ? at ??:?
[3] #6  __libc_start_main in "/lib/x86_64-linux-gnu/libc.so.6"
[3] #7  ? at ??:?
I did go through many threads on the forum and the wiki for the same https://openfoamwiki.net/index.php/HowTo_debugging However, I am stuck with something very basic. I can't get the debugging mode active. Forgive me, but am new to Linux as well and use only as much as needed, so I would appreciate if you please explain in a simpler language for me.

When I change the bashrc option to Debug for fulldebugging and lookup the path to any solver as this chalmers pdf suggests (http://www.tfd.chalmers.se/~hani/kur.../debugging.pdf) by which sonicFoam, it doesn't show me anything and goes to new line (no blank line output either). This suggests probably debug mode isn't activated but if I check with echo $WM_COMPILATION_OPTION it does show me Debug.

So what is going on? Can anyone please help?
deepbandivadekar is offline   Reply With Quote

Old   March 10, 2018, 09:39
Default
  #2
Member
 
Fatih Ertinaz
Join Date: Feb 2011
Location: Istanbul
Posts: 64
Rep Power: 13
fertinaz is on a distinguished road
As its name says, $WM_COMPILATION_OPTION is a flag for compilation. Changing it to Debug is not enough. You need to compile the whole OF to create the Debug version binaries.

You don't have to make a new compilation though. There is another option: Overriding debug switches. Take a look at the ..../OF-5.x/etc/controlDict file. There you will find a block DebugSwitches which can be overridden in your case system/controlDict. Nilsson explains it very nicely. I find this method very handy as well.

The option "3 Top-Level debugging" in the link you gave simply says:
  • Copy the source directories of the binaries you use, e.g sonicFoam solver directory
  • Change the source names and Make/files
  • Add the debug option to Make/option
  • Compile -- I would do that with a new name for instance sonicFoam_debug and save it to $FOAM_USER_APPBIN instead of over-writing the existing solver
fertinaz is offline   Reply With Quote

Old   March 10, 2018, 11:20
Default
  #3
Senior Member
 
Deep
Join Date: Oct 2017
Posts: 180
Rep Power: 7
deepbandivadekar is on a distinguished road
Thanks for quick reply. Yes, I have been through that but didn't quiet understand that. If I may trouble you a bit more, I've added specifically what I'm not following below, could you please elaborate a little more?

Quote:
Originally Posted by fertinaz View Post
As its name says, $WM_COMPILATION_OPTION is a flag for compilation. Changing it to Debug is not enough. You need to compile the whole OF to create the Debug version binaries.
I don't mind creating that for now but I'll skip it if there exists a simpler way (Top-Level?). Nonetheless, what exactly do I do to compile (e.g. do I run ./Allrun from the installation directory.. I didn't try as I didn't want to mess with the existing installation lest am doing something stupid)?

Quote:
Originally Posted by fertinaz View Post
You don't have to make a new compilation though. There is another option: Overriding debug switches. Take a look at the ..../OF-5.x/etc/controlDict file. There you will find a block DebugSwitches which can be overridden in your case system/controlDict.
There's a whole big list of parameters. I have no idea what those mean.
1. How is that related to the following instructions?
2. When you say, it can be overridden...how? Can you please show me an example?

Quote:
Originally Posted by fertinaz View Post
Nilsson explains it very nicely. I find this method very handy as well.

The option "3 Top-Level debugging" in the link you gave simply says:
  • Copy the source directories of the binaries you use, e.g sonicFoam solver directory
1. It mentions functions, so isn't it possible that some of those are located outside of the solver directory? Finding each function's location (through grep) is what am guessing is the correct way to choose all the relevant folders?
2. Copy these folders to where?? I have my installation in /opt/openfoam5 folder. Does it mean I should copy those to my current working directory?


Quote:
Originally Posted by fertinaz View Post
  • Change the source names and Make/files
  • Add the debug option to Make/option


1. Change the source name to what !? Absolutely no idea what this statement means.
2. What is Make/files ? A location? I can't find it anywhere in my openfoam installation directory.


Quote:
Originally Posted by fertinaz View Post
  • Compile -- I would do that with a new name for instance sonicFoam_debug and save it to $FOAM_USER_APPBIN instead of over-writing the existing solver
Can you please elaborate this? I am not sure I follow completely. I do get that the debug compilation should be independent of the existing compilation.

I'm sorry, my questions might seem very basic but I'd really appreciate help.
deepbandivadekar is offline   Reply With Quote

Old   March 12, 2018, 15:16
Default
  #4
Member
 
Fatih Ertinaz
Join Date: Feb 2011
Location: Istanbul
Posts: 64
Rep Power: 13
fertinaz is on a distinguished road
Hi there!

1- You should change the compiler option, and probably the project name as well to (OF-5x_debug for instance) then yes you will run ./Allwmake which is going to create new binaries into a new location according to the names you provide in etc/bashrc

2- Yes, I agree that list is very long but you can find the interesting ones for your need. I don't any know source that explains each of them, so you might have to go through the code to extract them.

3- You can copy them anywhere using any name you want. Natural way of doing that is to create, e.g a work directory located in your user directory in OpenFOAM folder. For instance; if you're using version 5.x then OpenFOAM/username-5.x/work/sonicFoam_debug can contain the modified sonicFoam. You can read Nilsson's documents that explain implementation of a new solver and new BC to understand how that works, especially Make/files and Make/options.

By the way, this is what you do if you do NOT compile the debug version of OpenFOAM. If you compile a whole new debug version then for sure you don't need to compile a particular solver.

4- By defining a debugSwitch block in your case/system/controlDict you can override default switches. So it will look like:
Code:
debugSwitches 
{ 
    someDebugSwitch debugLevel; 
}
As far as I know, debugLevel can be 1, 2 or 3. 0 refers to no debug and a larger number means a lower level of debug thus more Info statements printed on your screen. However I don't know if there is a maximum value for it. Someone who uses those debug switches can correct me if I'm wrong. Or maybe you can try using 1 and 3, and compare level of debugging and let us know. But anyway you can find information on Nilsson's "Debugging OF" document.

5- You are right, just compiling the solver might not be enough. Then of course it becomes pointless and might require too much effort. That's why I would either use debug switching or using a debugger like gdb.

Good luck!

// Fatih
deepbandivadekar likes this.
fertinaz is offline   Reply With Quote

Old   March 26, 2018, 11:04
Default
  #5
Senior Member
 
Deep
Join Date: Oct 2017
Posts: 180
Rep Power: 7
deepbandivadekar is on a distinguished road
Thanks. This helped. Am still not where I want to be but getting there.
Just needed some hints.

Have a nice day.
deepbandivadekar is offline   Reply With Quote

Old   April 15, 2018, 19:10
Default
  #6
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,968
Blog Entries: 45
Rep Power: 126
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
Quick question @Deep: Have you solved your problem here? If not, please let us know. Preferably, please let us also know how to reproduce the error message you are getting, so that it's easier to figure out which debug mode/level is needed.

In the meantime, you can also try running:
Code:
export FOAM_ABORT=1
before running the solver, which should trigger it to give you a bit more details about why it crashed and/or where, both in normal and debug modes.
__________________
wyldckat is offline   Reply With Quote

Old   April 16, 2018, 07:04
Default
  #7
Senior Member
 
Deep
Join Date: Oct 2017
Posts: 180
Rep Power: 7
deepbandivadekar is on a distinguished road
Quote:
Originally Posted by wyldckat View Post
In the meantime, you can also try running:
Code:
export FOAM_ABORT=1
before running the solver, which should trigger it to give you a bit more details about why it crashed and/or where, both in normal and debug modes.
Wow okay. I couldn't possibly have found this on my own. I'll try for the next run.


Quote:
Originally Posted by wyldckat View Post
Quick question @Deep: Have you solved your problem here? If not, please let us know. Preferably, please let us also know how to reproduce the error message you are getting, so that it's easier to figure out which debug mode/level is needed.
No I haven't. I am not sure which debugSwitch to use and it was taking too long to figure out so I tried some other deviations with the case itself. Lot of things have changed since then so the case isn't exactly the same any more else I could share the case with you.

However, I suspect it had to do with keeping the porous inlet patch defined as "patch" rather than "wall" (which I have just figured out and that's exactly how it should have been and I didn't know how to effect it). If I encounter similar negative temperature error, I'll definitely come back to this thread and update.

Thanks for looking this up for me!
deepbandivadekar is offline   Reply With Quote

Reply

Tags
debug, debug mode, debugging, openfoam 5.x, sonicfoam

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
[OpenFOAM.org] Error when compiling OF 5.x in RedHat 6.5 agustinvo OpenFOAM Installation 2 May 31, 2018 09:47
[OpenFOAM.org] Error compiling OF 5.x marluc OpenFOAM Installation 4 November 2, 2017 10:39
Is there a relation between version of fluent and visual basic in compiling? 4asino Fluent UDF and Scheme Programming 1 October 31, 2015 07:03
Basic question regarding compiling a UDF A.Jalal Fluent UDF and Scheme Programming 2 August 6, 2015 14:57
Help with KIVA4 source code compiling geothokar Main CFD Forum 0 September 3, 2010 06:40


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