예제 #1
0
        /// <summary>
        /// exchange of an <see cref="MultidimensionalArray"/>
        /// </summary>
        /// <param name="master"></param>
        /// <param name="vector">
        /// The array must be continuous and have zero offset;
        /// first dimension must match local number of cells (including external).
        /// </param>
        static public void MPIExchange(this MultidimensionalArray vector, IGridData master)
        {
            int[] i0     = new int[vector.Dimension];
            int   offset = vector.Index(i0);

            if (!vector.IsContinious || !(offset == 0) || !(vector.Storage.Length == vector.Length))
            {
                throw new NotSupportedException();
            }

            if (vector.GetLength(0) != master.iLogicalCells.Count)
            {
                throw new ArgumentException("fist dimension must match number of local cells (including external)");
            }

            double[] Stor = vector.Storage;
            int      J    = master.iLogicalCells.Count;
            int      L    = Stor.Length;

            Debug.Assert(L % J == 0);

            var Trx = new VectorTransceiver <double[], double>(master, Stor, L / J);

            Trx.TransceiveStartImReturn();
            Trx.TransceiveFinish();
        }
예제 #2
0
        /// <summary>
        /// most elegant way of MPI vector exchange....
        /// </summary>
        /// <typeparam name="Tlst"></typeparam>
        /// <typeparam name="Titm"></typeparam>
        /// <param name="vector"></param>
        /// <param name="master"></param>
        static public void MPIExchange <Tlst, Titm>(this Tlst vector, IGridData master)
            where Tlst : IList <Titm>
            where Titm : struct
        {
            int J = master.iLogicalCells.Count;
            int L = vector.Count;

            if (L % J != 0)
            {
                throw new ArgumentException("Length of vector must be equal or a multiple of number of cells (including external).");
            }

            var Trx = new VectorTransceiver <Tlst, Titm>(master, vector, L / J);

            Trx.TransceiveStartImReturn();
            Trx.TransceiveFinish();
        }