[CIG-LONG] Help for reading source code
Walter Landry
walter at geodynamics.org
Wed Apr 11 06:06:50 PDT 2012
Feng Lin <rimbong at gmail.com> wrote:
> Hey everyone,
>
> Sometimes, I hope I could understand the source code of Gale(2.0) so
> that I could check and solve some questions by myself.
> But when I went into the directory of the Gale, there are like 12
> directories inside there and a lot of subdirectories in each
> directory.
> Anyone can give me any advice for how to get start ?
The code, is, unfortunately, not easy to read. To briefly describe
what the directories contain
json_parser/
Code to handle parsing the json input format. It mostly sets up
defaults and handles the actual parsing off to json_spirit.
json_spirit/
A copy of the JSON Spirit library that does the actual parsing of
the json files. It uses the boost library.
boost/
A copy of the boost library from boost.org. This is mainly used by
the json parser.
muparserx/
A copy of the muParserX library used for parsing equations in input files.
doc/
The images and source files for building the manual.
input/
Benchmark and cookbook input files
config/
Python code to handle the initial configuration of Gale when
building from source.
script/
A Python script to assist the configuration. I do think that I use it.
StGermain/
Foundational code to handle parallelism, boundary
conditions, initial conditions, reading XML, plugins, and the object
system. The object system, in a sense, reinvents C++ classes using
all sorts of macro tricks.
StgDomain/
Handles Shapes and meshing. It also has some basic code for particles.
StgFEM/
Implements the Finite Element method. This is where the basic
physics gets implemented (Stokes, advection/diffusion).
PICellerator/
Handles the mapping between particles and material properties. Also
handles population control for the particle.
Underworld/
Implements the various rheologies (Drucker-Prager, Non-Newtonian, etc.)
gLucifer/
Code for creating visualizations during a run. Not used.
If you want to see where the code starts, that is
StGermain/src/main.cxx
It reads in the input file and creates components based on that. It
then dynamically calls functions based on these components. I have
not found it profitable to use a debugger to single-step through the
code starting from main().
If you want to debug a component, I would recommend setting a
breakpoint in that component with a debugger. Then run the code and
you can get a stack trace showing how that component is called.
Cheers,
Walter Landry
More information about the CIG-LONG
mailing list