Driver¶
Note
under construction
The Driver class is the highest level object for managing simulations. Its principle method is the virtual function Update. The simulation cycle invokes Update for each driver. The order of Update calls is determined by a sorting index stored with each Driver instance.
Communication between drivers can be accomplished in two ways.
Publisher-consumer mechanism
Containment hierarchy
Publisher-Consumer Model¶
In the publisher-consumer model, derived modules override the InspectResource and ExchangeResources methods. Typically InspectResource copies pointers passed in by other modules:
- bool InspectResource(void *resource, const std::string &description)¶
This is the function which consumes resources provided by other modules.
- Parameters:
resource – Pointer from another module to be copied to a member of the inspecting module.
description – String used to identify the resource.
- Returns:
Whether the resource was copied or not
- Rtype:
bool
The body of the function will test several string literals against description, and if a match is found copy resource to an appropriate member pointer.
The ExchangeResources method calls the PublishResource method for each pointer the module wants to share. The PublishResource method, which does not need to be overridden, simply calls InspectResource for every module (note that nothing stops a module from consuming its own resource).
- void ExchangeResources()¶
This function is intended to be populated with one or more calls to
PublishResource.
- void PublishResource(void *resource, const std::string &description)¶
Shares a resource with all modules. Does not need to be overridden.
- Parameters:
resource – Pointer to share with other modules.
description – String used to identify the resource, typically a literal.
Containment Model¶
Drivers can contain other Drivers, but it is more common for Drivers to contain ComputeTools. There is also an intermediate object called an Engine, but this is rarely needed for high level extensions.
The Driver tree is built out of ordinary pointers, while ComputeTools are referenced by a std::shared_ptr.
The entire containment hierarchy is created while reading the input file.
Implementing a Driver¶
Best Practices¶
Do not use upper case in defining your input file keys or directives.
Use descriptive English language keys and directives, but without excessive verbosity.