CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   How to locate this bug? (https://www.cfd-online.com/Forums/openfoam-programming-development/145864-how-locate-bug.html)

wang219910611 December 13, 2014 22:49

How to locate this bug?
 
Hi everyone,

While I am trying to test my own solver on a new case, following error appears:
Code:

Reading/calculating face flux field phi

Reading transportProperties

--> FOAM FATAL ERROR:
LHS and RHS of - have different dimensions
    dimensions : [0 0 0 0 0 0 0] - [1 -1 -1 0 0 0 0]

    From function operator-(const dimensionSet&, const dimensionSet&)
    in file dimensionSet/dimensionSet.C at line 499.

FOAM aborting

with the help of the info statement, I believe the error should be somewhere in the following code, which is in the creatField.H file :

Code:

Info<< "Reading transportProperties\n" << endl;

    incompressibleTwoPhaseMixture twoPhaseProperties(U, phi/*, "Ybar"*/);
    const dimensionedScalar& rho1 = twoPhaseProperties.rho1();

    Info<< "Done Reading transportProperties\n" << endl;

The strange part is that I can't find any "-" in the above code or in the incompressibleTwoPhaseMixture file ( they are the original ones ). Any clues where can I locate this error?

Many thanks. : )

wyldckat December 14, 2014 03:51

Greetings wang219910611,

My advice is to make sure that you're debugging the correct lines. Change that piece of code to this:
Code:

    Info<< "Reading transportProperties\n" << endl;

Info<< "Got here 00" << endl;

    incompressibleTwoPhaseMixture twoPhaseProperties(U, phi/*, "Ybar"*/);

Info<< "Got here 01" << endl;

    const dimensionedScalar& rho1 = twoPhaseProperties.rho1();

Info<< "Got here 02" << endl;

    Info<< "Done Reading transportProperties\n" << endl;

Why am I suggesting this? Because there might be more than one piece of code that gives the output "Reading transportProperties", and in addition, it will give a clearer notion of where exactly the problem is located.


The other suggestion is to look at the dictionary files that are loaded by this piece of code. My guess is that there isn't only one file and that a bug might be present in any of those dictionary files.


Beyond this: http://openfoamwiki.net/index.php/HowTo_debugging

Best regards,
Bruno

xianqiejiao December 18, 2014 03:34

2 Attachment(s)
Hi Bruno, sorry for the late reply. I turned back to learn more about gdb and c++ these days, trying to fix the bug.

I think I have managed to locate the bugs to my visThermo. This is a new thermo type I tried to set up by copying the way of psiThermo. Here is what I got from gdb:
Code:

Program received signal SIGSEGV, Segmentation fault.
0x00000000005219d8 in Foam::HashTable<Foam::autoPtr<Foam::visThermo> (*)(Foam::fvMesh const&, Foam::word const&), Foam::word, Foam::string::hash>::find (
    this=0x0, key=...)
    at /home/bo/OpenFOAM/OpenFOAM-2.3.0/src/OpenFOAM/lnInclude/HashTable.C:143
143        if (nElmts_)
(gdb) frame 0
#0  0x00000000005219d8 in Foam::HashTable<Foam::autoPtr<Foam::visThermo> (*)(Foam::fvMesh const&, Foam::word const&), Foam::word, Foam::string::hash>::find (
    this=0x0, key=...)
    at /home/bo/OpenFOAM/OpenFOAM-2.3.0/src/OpenFOAM/lnInclude/HashTable.C:143
143        if (nElmts_)
(gdb) frane 1
Undefined command: "frane".  Try "help".
(gdb) frame 1
#1  0x0000000000520ef0 in Foam::basicThermo::lookupThermo<Foam::visThermo, Foam::HashTable<Foam::autoPtr<Foam::visThermo> (*)(Foam::fvMesh const&, Foam::word const&), Foam::word, Foam::string::hash> > (thermoDict=..., tablePtr=0x0)
    at /home/bo/OpenFOAM/OpenFOAM-2.3.0/src/thermophysicalModels/basic/lnInclude/basicThermoTemplates.C:68
68            typename Table::iterator cstrIter = tablePtr->find(thermoTypeName);

I have attached the visThermo file in the attachment. I think I have copied most of the line from psiThermo except the last few ones, which are member function. In my visThermo, I have got Ybar ( phase density), rho, mu1 for phase 1, mu2 for phase 2 and mu. Should I set the member functions in visThermo like the following ?
Code:

  virtual const volScalarField& Ybar() const;
            virtual const scalarField& Ybar(const label patchi) const;
            virtual tmp<volScalarField> rho() const
            virtual tmp<scalarField> rho(const label patchi) const;
            virtual volScalarField& rho();
            virtual const scalarField& mu1 const;
            virtual const scalarField& mu2 const;
            virtual const volScalarField& mu() const;
            virtual const scalarField& mu(const label patchi) const;
            virtual const volScalarField& Ybar() const;
            virtual const scalarField& Ybar(const label patchi) const;



All times are GMT -4. The time now is 12:41.