//double m_LastLevelSetResidual; private void MoveLevelSetAndRelatedStuff(DGField[] locCurSt, double PhysTime, double dt, double UnderRelax, BlockMsrMatrix[] MassMatrixStack, double[][] k) { // level-set evolution int oldPushCount = m_LsTrk.PushCount; int oldVersion = m_LsTrk.VersionCnt; m_LastLevelSetResidual = this.UpdateLevelset(locCurSt, PhysTime, dt, UnderRelax, (this.Config_LevelSetHandling == LevelSetHandling.StrangSplitting)); int newVersion = m_LsTrk.VersionCnt; int newPushCount = m_LsTrk.PushCount; if ((newVersion - oldVersion) != 1) { throw new ApplicationException("Expecting exactly one call to 'UpdateTracker(...)' in 'UpdateLevelset(...)'."); } if (oldPushCount != newPushCount) { throw new ApplicationException("Pushing the history stacks of the level-set tracker is reserved to the timestepper (during one timestep)."); } if (MassMatrixStack != null && MassMatrixStack.Length > 1) { Debug.Assert(base.Config_LevelSetHandling == LevelSetHandling.Coupled_Iterative || base.Config_LevelSetHandling == LevelSetHandling.Coupled_Once); var MMS0 = MassMatrixStack.GetSubVector(0, 1); TimeSteppingUtils.OperatorLevelSetUpdate(m_LsTrk, MMS0, CurrentStateMapping, CurrentStateMapping); MassMatrixStack[0] = MMS0[0]; MassMatrixStack[1] = null; // must be re-computed according to new levset pos. } if (k != null) { Debug.Assert(base.Config_LevelSetHandling == LevelSetHandling.Coupled_Iterative || base.Config_LevelSetHandling == LevelSetHandling.Coupled_Once); for (int i = 0; i < k.Length; i++) { if (k[i] != null) { TimeSteppingUtils.OperatorLevelSetUpdate(m_LsTrk, k[i], CurrentStateMapping); } } } m_CurrentAgglomeration = null; // also invalid now m_PrecondMassMatrix = null; // also invalid now }
/// <summary> /// Diagnostic output. /// </summary> static public void PrintMappingUpdate(LevelSetTracker LsTrk, UnsetteledCoordinateMapping Mapping) { int JE = LsTrk.GridDat.Cells.NoOfCells; for (int j = 0; j < JE; j++) { Console.Write(j); Console.Write(":\t"); int[] mu = TimeSteppingUtils.MappingUpdate(LsTrk, j, Mapping, false); if (mu == null) { Console.Write("-"); } else { for (int k = 0; k < mu.Length; k++) { if (mu[k] >= 0) { Console.Write(mu[k]); } else { Console.Write("x"); } if (k < mu.Length - 1) { Console.Write(","); } } } Console.WriteLine(); } }
/// <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("---------------------"); }