private void AssignXdgBlocksModification(SubBlockSelector sbs, MultigridOperator op, bool IsLowSelector) { var Filter = sbs.ModeFilter; Func <int, int, int, int, bool> Modification = delegate(int iCell, int iVar, int iSpec, int pDeg) { int NoOfSpec = op.Mapping.AggBasis[0].GetNoOfSpecies(iCell); if (NoOfSpec >= 2) { return(IsLowSelector); } else { return(Filter(iCell, iVar, iSpec, pDeg)); } }; sbs.ModeSelector(Modification); }
/// <summary> /// Krankplätze müssen verdichtet werden /// -Kranführer Ronny, ProSieben Reportage /// </summary> public void Init(MultigridOperator op) { // //System.Threading.Thread.Sleep(10000); // //ilPSP.Environment.StdoutOnlyOnRank0 = false; m_op = op; if (m_CoarseLowOrder > m_op.Mapping.DgDegree.Max()) { throw new ArgumentOutOfRangeException("CoarseLowOrder is higher than maximal DG degree"); } #if TEST var debugerSW = new StreamWriter(String.Concat("debug_of_", ilPSP.Environment.MPIEnv.MPI_Rank)); Console.WriteLine("variable TEST is defined"); //debugerSW.WriteLine("proc {0} reporting Num of Blocks {1}", ilPSP.Environment.MPIEnv.MPI_Rank, HighOrderBlocks_LUpivots.Length); #endif int D = this.m_op.GridData.SpatialDimension; var DGlowSelect = new SubBlockSelector(op.Mapping); Func <int, int, int, int, bool> lowFilter = (int iCell, int iVar, int iSpec, int pDeg) => pDeg <= (iVar != D ? CoarseLowOrder : CoarseLowOrder - 1); DGlowSelect.ModeSelector(lowFilter); if (AssignXdGCellsToLowBlocks) { ModifyLowSelector(DGlowSelect, op); } lMask = new BlockMask(DGlowSelect); m_lowMaskLen = lMask.GetNoOfMaskedRows; if (UseHiOrderSmoothing) { var DGhighSelect = new SubBlockSelector(op.Mapping); Func <int, int, int, int, bool> highFilter = (int iCell, int iVar, int iSpec, int pDeg) => pDeg > (iVar != D ? CoarseLowOrder : CoarseLowOrder - 1); DGhighSelect.ModeSelector(highFilter); if (AssignXdGCellsToLowBlocks) { ModifyHighSelector(DGhighSelect, op); } hMask = new BlockMask(DGhighSelect); m_highMaskLen = hMask.GetNoOfMaskedRows; BlockMsrMatrix P01HiMatrix = null; if (UseDiagonalPmg) { HighOrderBlocks_LU = hMask.GetDiagonalBlocks(op.OperatorMatrix, false, false); int NoOfBlocks = HighOrderBlocks_LU.Length; HighOrderBlocks_LUpivots = new int[NoOfBlocks][]; for (int jLoc = 0; jLoc < NoOfBlocks; jLoc++) { int len = HighOrderBlocks_LU[jLoc].NoOfRows; HighOrderBlocks_LUpivots[jLoc] = new int[len]; HighOrderBlocks_LU[jLoc].FactorizeLU(HighOrderBlocks_LUpivots[jLoc]); } } else { P01HiMatrix = hMask.GetSubBlockMatrix(op.OperatorMatrix, csMPI.Raw._COMM.SELF); hiSolver = new PARDISOSolver() { CacheFactorization = true, UseDoublePrecision = true, // keep it true, experiments showed, that this leads to fewer iterations SolverVersion = Parallelism.OMP }; hiSolver.DefineMatrix(P01HiMatrix); } } var P01SubMatrix = lMask.GetSubBlockMatrix(op.OperatorMatrix, csMPI.Raw._COMM.WORLD); intSolver = new PARDISOSolver() { CacheFactorization = true, UseDoublePrecision = false, // no difference towards =true observed for XDGPoisson SolverVersion = Parallelism.OMP }; intSolver.DefineMatrix(P01SubMatrix); #if TEST P01SubMatrix.SaveToTextFileSparseDebug("lowM"); P01SubMatrix.SaveToTextFileSparse("lowM_full"); if (!UseDiagonalPmg) { //P01HiMatrix.SaveToTextFileSparseDebug("hiM"); //P01HiMatrix.SaveToTextFileSparse("hiM_full"); } m_op.OperatorMatrix.SaveToTextFileSparseDebug("M"); m_op.OperatorMatrix.SaveToTextFileSparse("M_full"); debugerSW.Flush(); debugerSW.Close(); long[] bla = m_op.BaseGridProblemMapping.GridDat.CurrentGlobalIdPermutation.Values; bla.SaveToTextFileDebug("permutation_"); List <int> BlockI0 = new List <int>(); List <int> Block_N = new List <int>(); foreach (long Block in bla) { BlockI0.Add(m_op.Mapping.GetBlockI0((int)Block)); Block_N.Add(m_op.Mapping.GetBlockLen((int)Block)); } BlockI0.SaveToTextFileDebug("BlockI0"); Block_N.SaveToTextFileDebug("Block_N"); #endif }