MercuryDPM  Alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Overriding functions

Another example is to add additional output to the Example.ene file, in this case the number of particles.

//include as member functions in class definition:
void writeEneHeader(std::ostream& os) const override
{
os << setw(8) << "N";
}
void writeEneTimestep(std::ostream& os) const override
{
os << setw(8) << particleHandler.getNumberOfObjects();
}

To change the terminal output after each written time step, use:

//include as member functions in class definition:
void printTime() const override
{
std::cout << "N" << particleHandler.getNumberOfObjects() << std::endl;
}

Other functions can be overridden, most notably:

// to add additional body forces, such as background dissipation:
void computeExternalForces(BaseParticle* PI) override {...}
// to add commands before restart, such as deleting old files:
void actionsOnRestart() override {...}
// to add commands before the first time step, but after initial forces are computed:
void actionsBeforeTimeLoop() override {...}
// to add commands before each time step:
void actionsBeforeTimeStep() override {...}
// to add commands after each time step:
void actionsAfterTimeStep() override {...}
// to add commands after time integration:
void actionsAfterSolve() override {...}