Documentation

Doxygen documentation

WarpX uses a Doxygen documentation. Whenever you create a new class, please document it where it is declared (typically in the header file):

/** A brief title
 *
 * few-line description explaining the purpose of my_class.
 *
 * If you are kind enough, also quickly explain how things in my_class work.
 * (typically a few more lines)
 */
class my_class
{ ... }

Doxygen reads this docstring, so please be accurate with the syntax! See Doxygen manual for more information. Similarly, please document functions when you declare them (typically in a header file) like:

/** A brief title
 *
 * few-line description explaining the purpose of my_function.
 *
 * \param[in,out] my_int a pointer to an integer variable on which
 *                       my_function will operate.
 * \return what is the meaning and value range of the returned value
 */
int my_class::my_function(int* my_int);

An online version of this documentation is linked here.

Breathe documentation

Your Doxygen documentation is not only useful for people looking into the code, it is also part of the WarpX online documentation based on Sphinx! This is done using the Python module Breathe, that allows you to read Doxygen documentation dorectly in the source and include it in your Sphinx documentation, by calling Breathe functions. For instance, the following line will get the Doxygen documentation for WarpXParticleContainer in Source/Particles/WarpXParticleContainer.H and include it to the html page generated by Sphinx:

class WarpXParticleContainer : public amrex::ParticleContainer<0, 0, PIdx::nattribs>

WarpXParticleContainer is the base polymorphic class from which all concrete particle container classes (that store a collection of particles) derive. Derived classes can be used for plasma particles, photon particles, or non-physical particles (e.g., for the laser antenna). It derives from amrex::ParticleContainer<0,0,PIdx::nattribs>, where the template arguments stand for the number of int and amrex::Real SoA and AoS data in amrex::Particle.

  • AoS amrex::Real: x, y, z (default), 0 additional (first template parameter)

  • AoS int: id, cpu (default), 0 additional (second template parameter)

  • SoA amrex::Real: PIdx::nattribs (third template parameter), see PIdx for the list.

WarpXParticleContainer contains the main functions for initialization, interaction with the grid (field gather and current deposition) and particle push.

Note: many functions are pure virtual (meaning they MUST be defined in derived classes, e.g., Evolve) or actual functions (e.g. CurrentDeposition).

Subclassed by LaserParticleContainer, PhysicalParticleContainer

Building the documentation

To build the documentation on your local computer, you will need to install Doxygen as well as the Python module breathe. First, change into Docs/ and install the Python requirements:

cd Docs/
pip install -r requirements.txt

You will also need Doxygen (macOS: brew install doxygen; Ubuntu: sudo apt install doxygen).

Then, to compile the documentation, use

make html
# This will first compile the Doxygen documentation (execute doxygen)
# and then build html pages from rst files using sphinx and breathe.

Open the created build/html/index.html file with your favorite browser. Rebuild and refresh as needed.