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();
}
virtual void writeEneTimeStep(std::ostream &os) const
Write the global kinetic, potential energy, etc. in the system.
Definition: DPMBase.cc:2104
virtual void writeEneHeader(std::ostream &os) const
Writes a header with a certain format for ENE file.
Definition: DPMBase.cc:2014

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 {...}
Definition: BaseParticle.h:54