/// <summary> /// accumulates (to field <paramref name="f"/>), in every cell the /// distance form the cut cells times <paramref name="alpha"/>; /// Note: this is NOT the geometric distance, but the distance index /// that identifies the 'Near+1' , 'Near-1', 'Near+2', ..., - layers. /// </summary> public static void AccLevelSetDist(this DGField f, double alpha, LevelSetTracker LevSetTrk, int LevSetIdx) { int J = f.Basis.GridDat.iLogicalCells.NoOfLocalUpdatedCells; var r = LevSetTrk.Regions; for (int j = 0; j < J; j++) { int dist = LevelSetTracker.DecodeLevelSetDist(r.m_LevSetRegions[j], 0); f.SetMeanValue(j, f.GetMeanValue(j) + dist * alpha); } }
/// <summary> /// Diagnostic output. /// </summary> /// <param name="cout"></param> /// <param name="time"></param> public static void PrintCellSpecisTable(LevelSetTracker LsTrk, TextWriter cout, double time) { int J = LsTrk.GridDat.Cells.NoOfLocalUpdatedCells; cout.WriteLine("Species at time {0}: ==============", time); Console.WriteLine("j\tDist\t#Spc\t"); for (int j = 0; j < J; j++) { // cell index cout.Write(j); cout.Write("\t"); // level-set distance int dist = LevelSetTracker.DecodeLevelSetDist(LsTrk.Regions.RegionsCode[j], 0); cout.Write(dist); cout.Write("\t"); // number of species in cell ReducedRegionCode rrc; int NoOfSpc = LsTrk.Regions.GetNoOfSpecies(j, out rrc); cout.Write(NoOfSpc); cout.Write("\t"); // species sequence for (int iSpc = 0; iSpc < NoOfSpc; iSpc++) { var SpId = LsTrk.GetSpeciesIdFromIndex(rrc, iSpc); var SpNm = LsTrk.GetSpeciesName(SpId); cout.Write(SpNm); if (iSpc < (NoOfSpc - 1)) { cout.Write(","); } } cout.Write("\t"); // new 2 old int[] N2O = TimeSteppingUtils.SpeciesUpdate(LsTrk, j, true); cout.Write("new2old: "); if (N2O != null) { for (int i = 0; i < N2O.Length; i++) { cout.Write(N2O[i]); if (i < (N2O.Length - 1)) { cout.Write(","); } } } else { cout.Write("-"); } cout.Write("\t"); // old 2 new int[] O2N = TimeSteppingUtils.SpeciesUpdate(LsTrk, j, false); cout.Write("old2new: "); if (O2N != null) { for (int i = 0; i < O2N.Length; i++) { cout.Write(O2N[i]); if (i < (O2N.Length - 1)) { cout.Write(","); } } } else { cout.Write("-"); } cout.Write("\t"); // end-of-line cout.WriteLine(); } cout.WriteLine("---------------------"); }