private void RKstage(double dt, double[][] k, int s, BlockMsrMatrix MsInv, BlockMsrMatrix M0, double[] u0, double[] coefficients) { // Copy coordinates to temp array since SpMV (below) does not // support in-place computation double[] tempCoordinates = DGCoordinates.ToArray(); M0.SpMV(1.0, u0, 0.0, tempCoordinates); // Non-agglomerated for (int l = 0; l < s; l++) { tempCoordinates.AccV(-coefficients[l] * dt, k[l]); // Non-agglomerated } speciesMap.Agglomerator.ManipulateRHS(tempCoordinates, Mapping); MsInv.SpMV(1.0, tempCoordinates, 0.0, DGCoordinates); speciesMap.Agglomerator.Extrapolate(DGCoordinates.Mapping); }
public override double Perform(double dt) { if (TimeStepConstraints != null) { dt = CalculateTimeStep(); } int NoOfStages = this.Scheme.Stages; double[][] k = new double[NoOfStages][]; Mapping.Fields.ForEach(f => f.Clear(speciesMap.SubGrid.VolumeMask.Complement())); UpdateEvaluatorsAndMasks(); AgglomerateAndExtrapolateDGCoordinates(); BlockMsrMatrix M0 = speciesMap.GetMassMatrixFactory(Mapping).NonAgglomeratedMassMatrix; double[] u0 = DGCoordinates.ToArray(); // Lives on non-agglomerated mesh // Initialize RK scheme k[0] = new double[Mapping.LocalLength]; ComputeChangeRate(k[0], Time, 0.0); // Intermediate stages for (int stage = 1; stage < NoOfStages; stage++) { MoveLevelSetTo(Time + dt * this.Scheme.c[stage]); UpdateEvaluatorsAndMasks(); AgglomerateAndExtrapolateDGCoordinates(); BlockMsrMatrix MsInverse = speciesMap.GetMassMatrixFactory(Mapping).InverseMassMatrix; RKstage(dt, k, stage, MsInverse, M0, u0, this.Scheme.a.GetRow(stage)); k[stage] = new double[Mapping.LocalLength]; ComputeChangeRate(k[stage], Time, this.Scheme.c[stage] * dt); } // Final stage MoveLevelSetTo(Time + dt); UpdateEvaluatorsAndMasks(); BlockMsrMatrix M1Inverse = speciesMap.GetMassMatrixFactory(Mapping).InverseMassMatrix; RKstage(dt, k, NoOfStages, M1Inverse, M0, u0, this.Scheme.b); m_Time = Time + dt; return(dt); }
protected override double[] ComputesUpdatedDGCoordinates(double[] completeChangeRate) { double[] y0 = new double[Mapping.LocalLength]; DGCoordinates.CopyTo(y0, 0); DGCoordinates.axpy <double[]>(completeChangeRate, -1); // Speciality for IBM: Do the extrapolation speciesMap.Agglomerator.Extrapolate(DGCoordinates.Mapping); double[] upDGC = DGCoordinates.ToArray(); upDGC = OrderValuesBySgrd(upDGC); // DGCoordinates should be untouched after calling this method DGCoordinates.Clear(); DGCoordinates.CopyFrom(y0, 0); return(upDGC); }