|
[Sponsors] |
Using GDB to go through OpenFOAM source codes |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
December 13, 2018, 09:17 |
Using GDB to go through OpenFOAM source codes
|
#1 |
Member
Jingchang.Shi
Join Date: Aug 2012
Location: Hang Zhou, China
Posts: 78
Rep Power: 14 |
Hi!
I'm a newbie using OpenFOAM-6. I'm trying to read the source codes by GDB. However, I cannot understand why gdb cannot step into the constructor of some classes like fvMesh. Also GDB reports something like Code:
(gdb) p mesh $1 = <incomplete type> Then I use gdb to run rhoSimpleFoam by Code:
gdb <ThePathToDebugMode>/rhoSimpleFoam Code:
#include "fvCFD.H" #include "fluidThermo.H" #include "turbulentFluidThermoModel.H" #include "simpleControl.H" #include "pressureControl.H" #include "fvOptions.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // int main(int argc, char *argv[]) { #include "postProcess.H" #include "setRootCaseLists.H" #include "createTime.H" #include "createMesh.H" #include "createControl.H" #include "createFields.H" #include "createFieldRefs.H" #include "initContinuityErrs.H" turbulence->validate(); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Info<< "\nStarting time loop\n" << endl; while (simple.loop(runTime)) { Info<< "Time = " << runTime.timeName() << nl << endl; // Pressure-velocity SIMPLE corrector #include "UEqn.H" #include "EEqn.H" if (simple.consistent()) { #include "pcEqn.H" } else { #include "pEqn.H" } turbulence->correct(); runTime.write(); Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << " ClockTime = " << runTime.elapsedClockTime() << " s" << nl << endl; } Info<< "End\n" << endl; return 0; } Code:
#include "createMesh.H" Code:
Foam::Info << "Create mesh for time = " << runTime.timeName() << Foam::nl << Foam::endl; Foam::fvMesh mesh ( Foam::IOobject ( Foam::fvMesh::defaultRegion, runTime.timeName(), runTime, Foam::IOobject::MUST_READ ) ); Code:
Foam::fvMesh mesh Code:
runTime.timeName() Code:
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::fvMesh::fvMesh(const IOobject& io) : polyMesh(io), surfaceInterpolation(*this), fvSchemes(static_cast<const objectRegistry&>(*this)), fvSolution(static_cast<const objectRegistry&>(*this)), data(static_cast<const objectRegistry&>(*this)), boundary_(*this, boundaryMesh()), lduPtr_(nullptr), curTimeIndex_(time().timeIndex()), VPtr_(nullptr), V0Ptr_(nullptr), V00Ptr_(nullptr), SfPtr_(nullptr), magSfPtr_(nullptr), CPtr_(nullptr), CfPtr_(nullptr), phiPtr_(nullptr) { if (debug) { InfoInFunction << "Constructing fvMesh from IOobject" << endl; } // Check the existence of the cell volumes and read if present // and set the storage of V00 if (fileHandler().isFile(time().timePath()/"V0")) { V0Ptr_ = new DimensionedField<scalar, volMesh> ( IOobject ( "V0", time().timeName(), *this, IOobject::MUST_READ, IOobject::NO_WRITE, false ), *this ); V00(); } // Check the existence of the mesh fluxes, read if present and set the // mesh to be moving if (fileHandler().isFile(time().timePath()/"meshPhi")) { phiPtr_ = new surfaceScalarField ( IOobject ( "meshPhi", time().timeName(), *this, IOobject::MUST_READ, IOobject::NO_WRITE, false ), *this ); // The mesh is now considered moving so the old-time cell volumes // will be required for the time derivatives so if they haven't been // read initialise to the current cell volumes if (!V0Ptr_) { V0Ptr_ = new DimensionedField<scalar, volMesh> ( IOobject ( "V0", time().timeName(), *this, IOobject::NO_READ, IOobject::NO_WRITE, false ), V() ); } moving(true); } } Code:
(gdb) p runTime $1 = <incomplete type> (gdb) p runTime.timeName() Couldn't find method Foam::Time::timeName Code:
info sources Code:
info sources So it seems like GDB knows really a little about OpenFOAM. GDB cannot step into a function body in some OpenFOAM classes. GDB cannot find some methods in OpenFOAM either. Anyone could help me understand what's going on? Thanks! Jingchang |
|
December 24, 2018, 19:46 |
|
#2 |
Senior Member
Wouter van der Meer
Join Date: May 2009
Location: Elahuizen, Netherlands
Posts: 203
Rep Power: 18 |
did you google: debug openfoam ?
There are a lot of suggestions Hope this helps Wouter |
|
Tags |
debug, gdb |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[foam-extend.org] problem when installing foam-extend-1.6 | Thomas pan | OpenFOAM Installation | 7 | September 9, 2015 22:53 |
[swak4Foam] swak4foam building problem | GGerber | OpenFOAM Community Contributions | 54 | April 24, 2015 17:02 |
[swak4Foam] Swak4FOAM 0.2.3 / OF2.2.x installation error | FerdiFuchs | OpenFOAM Community Contributions | 27 | April 16, 2014 16:14 |
centOS 5.6 : paraFoam not working | yossi | OpenFOAM Installation | 2 | October 9, 2013 02:41 |
pisoFoam compiling error with OF 1.7.1 on MAC OSX | Greg Givogue | OpenFOAM Programming & Development | 3 | March 4, 2011 18:18 |