Wire fragments and elements
The entire wire is distributed as np-1 WireFragment
objects, where np is the number of
processors/processes. Thus, there is one fragment for each slave
process.
The solution is based on an object-oriented model, where the
elements of the wire are autonomous objects, not just simple values
in a vector. All the wire elements contained in a
WireFragment inherit the superclass AnyElement. The
ends of the entire wire, which are at static temperatures, are of
type StaticElement, and their values do not change at any
time. All other elements are of type WireElement, which
determine their temperature from two neighbouring elements.
As the wire is distributed to several processors (or processes),
some of the WireElements have to communicate with each
other. This is implemented by the CommElement elements, which
inherit the WireElement and send their temperature over the
MPI interface to the CommElements in the neighbouring wire
processes.
Processes
The process hierarchy is such that there is one master process,
which just collects data from all the slaves, which do the actual
computing. The master also tells the slaves when it is time to stop.
Synchronization is somewhat strict; slave processes are synchronized
by the communication between neighbouring segments. The master
process is synchronized with the slaves so that after the master has
received cycle reports from the slaves, it tells them whether to
stop or to continue. I think that this causes a lot of speed-loss,
because the children have to wait the master, and can't go on
computing.
I made some tests where the master was not synchronized with the
slaves, but the slaves sent their cycle reports with non-blocking
messages, and then checked if a (non-blocking) termination order had
arrived from the master. The problem was that, because the master was
too slow in reporting (mostly plotting with Gnuplot), the children
ran maybe twice too long before the master had processed their
results.
Reporting
The master currently reports the results in a Gnuplot window, which
is somewhat slow.
The communication gaps between the wire segments are illustrated
with gaps in the curve (three segments in the wire of the picture on
right).
Notes
The communication is currently handled with the floating-point
values represented as text strings, which really isn't very
efficient.