# How to add options to OpenFOAM applications

A (testing) application needs to do additional work depending on a simulation / test case. The decision to do additional work is decided by an option passed to the application.

### Step-by-step guide

1. Extend the argument list object (argList) with a new boolean option.
2. Check if the boolean option is in the argument list when executing a conditional code block.

Adding options in the OpenFOAM potentialFoam solver

 argList::addOption
(
"pName",
"pName",
"Name of the pressure field"
);

(
"initialiseUBCs",
"Initialise U boundary conditions"
);

....

#include "setRootCase.H"
#include "createTime.H"
#include "createMesh.H"

...

// Optionally write Phi
if (args.optionFound("writePhi"))
{
Phi.write();
}