Polymorphic glue for calling Charm++ entry methods to base class Discretization, its children implementing specific discretization schemes, and helper classes.
The advantages of this class over traditional runtime polymorphism are (1) value semantics (both internally and to client code), (2) not templated, and (3) PUPable, i.e., an instance of Scheme can be sent across the network using Charm++'s pup framework. Also, since the class only holds a couple of chare proxies, it is lightweight.
Example usage from client code:
// Instantiate a Scheme object Scheme s( ctr::SchemeType::DG ); // see Control/Inciter/Options/Scheme.h // Issue broadcast to child scheme entry method s.bcast< Scheme::setup >(...); // Issue broadcast to base (Discretization) entry method s.disc().totalvol();
Organization, implementation details, end extension of the class:
Scheme contains (at least) two Charm++ proxies: discproxy and proxy. The former contains data and functionality common to all discretizations, and this can be considered as an equivalent to a base class in the OOP sense. The latter, proxy, contains data and functionality specific to a particular discretization. When instantiated, Scheme is configured for a single specific discretization which must be selected from the list of types in SchemeBase::Proxy.
The underlying type of proxy is a variant, which allows storing exactly one object. A variant is a type-safe union. An instance of a variant at any given time either holds a value of one of its alternative types. Read more on std::variant on how they work.
Adding a new child scheme is done by (1) Adding a new type of Charm++ chare array proxy to Scheme::Proxy, (2) Adding a new type of Charm++ chare array element proxy to Scheme::ProxyElem, and (3) Adding a new branch to the if test in Scheme's constructor.
- namespace inciter
- Inciter declarations and definitions.