Version 1 (modified by jorisborgdorff, 12 years ago) (diff) |
---|
The examples on this page are all specified in the CxA files in the src/cxa directory of the MUSCLE source package. The implementation of the submodels is in different locations, based on the language used.
Java examples
The code for the Java examples is contained in src/java/examples.
SimpleExample?
The simple example model is specified in src/cxa/SimpleExample.cxa.rb and implemented in src/java/examples/simplejava contains a writer submodel instance w and the reader submodel instance r. Both submodels use the MUSCLE 2's free-form API. Instance w creates some data in the form of an array of doubles, and sends it to instance r, which reads the data and prints it out. The former has a conduit entrance called data, and the latter a conduit exit called data. In the CxA file, a multiplication filter is applied the conduit, with parameter 0.5, so all the data is multiplied by 0.5.
SimpleSubmodel?
The scenario of SimpleSubmodel? is the same as the SimpleExample?, but it uses the formal MUSCLE 2 Java API.
MacroMicro?
The MacroMicro? model has two submodels with formal implementation, in a typical loop that Macro Micro models typically exhibit: in its loop, macro initializes the micro model, and the micro model sends its final observation back to the macro model. The macro model continues iterating for as long as there is simulation time.
Terminals
In the Terminals model, a submodel instance proc processes data, by checking whether it is larger than a threshold. Incoming data is from a terminal src, which reads an array of doubles from a file. Outgoing data is an array of booleans for whether the values are larger than a threshold which is stored to file by the terminal sink.
LaplaceExample?
Runs a Laplace heat flow solver of two connected systems. At each iteration, the boundary condition of the systems is updated with the boundary data of the other.
PingPong?
Does a benchmark, sending packages from the Ping submodel instance to the Pong submodel instance and back again, with different message sizes. Its parameters are set in src/cxa/PingPong.cxa.rb, and the code is in src/java/examples/pingpong.
C/C++ examples
The MUSCLE C/C++ API is used in the src/cpp/examples directory.
SimpleCpp2
The new MUSCLE 2 C++ API is used in SimpleCpp2, with CxA file src/cxa/NativeExample2.cxa.rb. It is the same scenario as the SimpleExample? for the MUSCLE 2 Java API, but the sender is now a C++ submodel.
DataIntegrity?
To ensure the integrity of data sent over a range of connections, the DataIntegrity? model sends random data with different data types back and forth in different submodels. If you are worried that a non-standard protocol or network mechanism is used, this is the model with which you can be sure that MUSCLE leaves your data intact.
SimpleMPI
Similar to SimpleCpp2, SimpleMPI has a C implementation of the sender. This time, however, the sender consists of two MPI processes, that communicate their data with a standard MPI_Bcast.