// do the particle-fitting in another thread public static void Preprocess() { // deduce number of particles int inner_count = 150000; int outer_count = 600000; int pause_count = 250000; if (Settings.LowQualityRendering) { inner_count /= 5; outer_count /= 5; pause_count /= 5; } // start time UInt64 time = Lib.Clocks(); // create all magnetic fields and do particle-fitting List <string> done = new List <string>(); foreach (var pair in models) { // get radiation data RadiationModel mf = pair.Value; // skip if model is already done if (done.Contains(mf.name)) { continue; } // add to the skip list done.Add(mf.name); // if it has a field if (mf.Has_field()) { // some feedback in the log // note: can't use BuildString here, as it is not thread-safe Lib.Log("particle-fitting '" + mf.name + "'..."); } // particle-fitting for the inner radiation belt if (mf.has_inner) { mf.inner_pmesh = new ParticleMesh(mf.Inner_func, mf.Inner_domain(), mf.Inner_offset(), inner_count, mf.inner_quality); } // particle-fitting for the outer radiation belt if (mf.has_outer) { mf.outer_pmesh = new ParticleMesh(mf.Outer_func, mf.Outer_domain(), mf.Outer_offset(), outer_count, mf.outer_quality); } // particle-fitting for the magnetopause if (mf.has_pause) { mf.pause_pmesh = new ParticleMesh(mf.Pause_func, mf.Pause_domain(), mf.Pause_offset(), pause_count, mf.pause_quality); } } // measure time required // note: can't use BuildString here, as it is not thread-safe Lib.Log("particle-fitting completed in " + Lib.Seconds(Lib.Clocks() - time).ToString("F3") + " seconds"); }
/// <summary> /// do the particle-fitting in another thread /// </summary> public static void Preprocess() { // ############################################################# // # DO NOT LOG FROM A THREAD IN UNITY. IT IS NOT THREAD SAFE. # // ############################################################# // deduce number of particles int inner_count = 150000; int outer_count = 600000; int pause_count = 250000; if (Settings.LowQualityRendering) { inner_count /= 5; outer_count /= 5; pause_count /= 5; } // create all magnetic fields and do particle-fitting List <string> done = new List <string>(); foreach (var pair in models) { // get radiation data RadiationModel mf = pair.Value; // skip if model is already done if (done.Contains(mf.name)) { continue; } // add to the skip list done.Add(mf.name); // particle-fitting for the inner radiation belt if (mf.has_inner) { mf.inner_pmesh = new ParticleMesh(mf.Inner_func, mf.Inner_domain(), mf.Inner_offset(), inner_count, mf.inner_quality); } // particle-fitting for the outer radiation belt if (mf.has_outer) { mf.outer_pmesh = new ParticleMesh(mf.Outer_func, mf.Outer_domain(), mf.Outer_offset(), outer_count, mf.outer_quality); } // particle-fitting for the magnetopause if (mf.has_pause) { mf.pause_pmesh = new ParticleMesh(mf.Pause_func, mf.Pause_domain(), mf.Pause_offset(), pause_count, mf.pause_quality); } } }