Ejemplo n.º 1
0
        /// <summary>
        /// Returns the cutcells + neighbours on a global level.
        /// </summary>
        /// <param name="globalCellNeighbourship">
        /// </param>
        private BitArray GetGlobalCutCellNeighbours(int[][] globalCellNeighbourship)
        {
            if (CutCells == null)
            {
                return(null);
            }

            int[] i0 = CellPartitioning.GetI0s();

            BitArray[] exchangeCutCells = CutCells.GetBitMask().MPIGatherO(0);
            exchangeCutCells = exchangeCutCells.MPIBroadcast(0);
            BitArray globalCutCells = new BitArray(GlobalNumberOfCells);

            for (int m = 0; m < exchangeCutCells.Length; m++)
            {
                for (int j = 0; j < exchangeCutCells[m].Length; j++)
                {
                    globalCutCells[j + i0[m]] = exchangeCutCells[m][j];
                    if (globalCutCells[j + i0[m]])
                    {
                        for (int i = 0; i < globalCellNeighbourship[j + i0[m]].Length; i++)
                        {
                            globalCutCells[globalCellNeighbourship[j + i0[m]][i]] = true;
                        }
                    }
                }
            }
            return(globalCutCells);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets the current refinement level for each global cell.
        /// </summary>
        /// <param name="currentGrid">
        /// </param>
        private static int[] GetGlobalCurrentLevel(GridData currentGrid)
        {
            Partitioning cellPartitioning = currentGrid.CellPartitioning;
            int          J       = currentGrid.Cells.NoOfLocalUpdatedCells;
            int          globalJ = cellPartitioning.TotalLength;

            int[] localCurrentLevel  = new int[J];
            int[] globalCurrentLevel = new int[globalJ];
            int[] i0 = cellPartitioning.GetI0s();

            for (int j = 0; j < J; j++)
            {
                localCurrentLevel[j] = currentGrid.Cells.GetCell(j).RefinementLevel;
            }

            int[][] exchangeGlobalCurrentLevel = localCurrentLevel.MPIGatherO(0);
            exchangeGlobalCurrentLevel = exchangeGlobalCurrentLevel.MPIBroadcast(0);

            for (int m = 0; m < currentGrid.MpiSize; m++)
            {
                for (int j = 0; j < exchangeGlobalCurrentLevel[m].Length; j++)
                {
                    globalCurrentLevel[j + i0[m]] = exchangeGlobalCurrentLevel[m][j];
                }
            }

            return(globalCurrentLevel);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Writes the max desired level of the specified cells into an int-array (mpi global).
        /// </summary>
        /// <param name="currentGrid">
        /// </param>
        /// <param name="CellsMaxRefineLevel">
        /// All cells, sorted in CellMask with their desired maximum level of refinement. Due to its nature as a list it is possible to define multiple different mask.
        /// ATTENTION: If to many CellMasks are defined the refinement algorithm might be slow.
        /// </param>
        private static int[] GetAllCellsWithMaxRefineLevel(GridData currentGrid, List <Tuple <int, BitArray> > CellsMaxRefineLevel)
        {
            Partitioning cellPartitioning = currentGrid.CellPartitioning;

            int[] i0                  = cellPartitioning.GetI0s();
            int   globalJ             = cellPartitioning.TotalLength;
            int   localJ              = currentGrid.Cells.NoOfLocalUpdatedCells;
            int   localJ_withExternal = currentGrid.Cells.NoOfExternalCells + localJ;

            int[] localCellsMaxRefineLvl = new int[localJ];

            for (int i = 0; i < CellsMaxRefineLevel.Count(); i++)
            {
                BitArray currentArray = CellsMaxRefineLevel[i].Item2;
                for (int j = 0; j < localJ; j++)
                {
                    if (currentArray[j] && localCellsMaxRefineLvl[j] < CellsMaxRefineLevel[i].Item1)
                    {
                        localCellsMaxRefineLvl[j] = CellsMaxRefineLevel[i].Item1;
                    }
                }
            }
            int[][] exchangeCellsMaxRefineLvl = localCellsMaxRefineLvl.MPIGatherO(0);
            exchangeCellsMaxRefineLvl = exchangeCellsMaxRefineLvl.MPIBroadcast(0);
            int[] globalCellsMaxRefineLvl = new int[globalJ];
            for (int m = 0; m < exchangeCellsMaxRefineLvl.Length; m++)
            {
                for (int j = 0; j < exchangeCellsMaxRefineLvl[m].Length; j++)
                {
                    globalCellsMaxRefineLvl[j + i0[m]] = exchangeCellsMaxRefineLvl[m][j];
                }
            }
            return(globalCellsMaxRefineLvl);
        }
Ejemplo n.º 4
0
        private int[] GetGlobalCellColor(int[] localCellColor, GridData currentGrid)
        {
            Partitioning cellPartitioning = currentGrid.CellPartitioning;
            int          globalJ          = cellPartitioning.TotalLength;

            int[] i0 = cellPartitioning.GetI0s();
            int[] globalCellColor = new int[globalJ];

            int[][] exchangeCellColor = localCellColor.MPIGatherO(0);
            exchangeCellColor = exchangeCellColor.MPIBroadcast(0);

            for (int m = 0; m < currentGrid.MpiSize; m++)
            {
                for (int j = i0[m]; j < i0[m + 1]; j++)
                {
                    globalCellColor[j] = exchangeCellColor[m][j - i0[m]];
                }
            }
            return(globalCellColor);
        }
Ejemplo n.º 5
0
        private int[][] GetGlobalCellNeigbourship(GridData currentGrid)
        {
            Partitioning cellPartitioning = currentGrid.CellPartitioning;
            int          globalJ          = cellPartitioning.TotalLength;
            int          localJ           = currentGrid.Cells.NoOfLocalUpdatedCells;

            int[] i0       = cellPartitioning.GetI0s();
            int   local_i0 = cellPartitioning.i0;

            long[]  externalCellsGlobalIndices = currentGrid.iParallel.GlobalIndicesExternalCells;
            int[][] localCellNeighbourship     = new int[localJ][];
            for (int j = 0; j < localCellNeighbourship.Length; j++)
            {
                currentGrid.GetCellNeighbours(j, GetCellNeighbours_Mode.ViaVertices, out int[] CellNeighbours, out _);
                localCellNeighbourship[j] = CellNeighbours;
                for (int i = 0; i < localCellNeighbourship[j].Length; i++)
                {
                    if (localCellNeighbourship[j][i] < localJ)
                    {
                        localCellNeighbourship[j][i] = localCellNeighbourship[j][i] + local_i0;
                    }
                    else
                    {
                        localCellNeighbourship[j][i] = (int)externalCellsGlobalIndices[localCellNeighbourship[j][i] - localJ];
                    }
                }
            }

            int[][][] exchangeCellNeighbourship = localCellNeighbourship.MPIGatherO(0);
            exchangeCellNeighbourship = exchangeCellNeighbourship.MPIBroadcast(0);

            int[][] globalCellNeigbourship = new int[globalJ][];
            for (int m = 0; m < currentGrid.MpiSize; m++)
            {
                for (int j = 0; j < exchangeCellNeighbourship[m].Length; j++)
                {
                    globalCellNeigbourship[j + i0[m]] = exchangeCellNeighbourship[m][j];
                }
            }
            return(globalCellNeigbourship);
        }