/// <summary> /// Returns the source which contains Au_{n-1}+b for the Operator and the field provided in the constructor /// </summary> /// <param name="k">results of Ay+b</param> /// <param name="dt">optional scaling by time step size</param> public void ExplicitEulerSource(SubgridCoordinateMapping u, out double[] convectiveSource, double dt) { convectiveSource = new double[u.subgridCoordinates.Length]; u.Compress(); SubgridOperatorMatr.SpMVpara <double[], double[]>(dt, u.subgridCoordinates, 1.0, convectiveSource); BLAS.daxpy(SubgridAffine.Length, dt, SubgridAffine, 1, convectiveSource, 1); }
/// <summary> /// method for setting up the timestepper, i.e. the necessary /// </summary> protected void Setup1(Context ctx, ISparseSolver solver, bool[] temporalOp, MsrMatrix spatialOpMtx, IList <double> spatialOpAffine, SubGrid subgrid, SubgridCoordinateMapping fields, double InitialDeltat) { // check operator and arguments if (spatialOpMtx.NoOfRows != spatialOpMtx.NoOfCols) { throw new ArgumentException("matrix must be quadratic.", "spatialOpMtx"); } if (spatialOpMtx.NoOfRows != fields.GlobalCount) { throw new ArgumentException("matrix size must be equal to the GlobalCount of fields mapping", "fields,spatialOpMtx"); } if (spatialOpMtx.RowPartition.LocalLength != fields.NUpdate) { throw new ArgumentException("number of locally stored matrix rows nust be equal to NUpdate of fields mapping.", "fields,spatialOpMtx"); } if (spatialOpAffine.Count < fields.NUpdate) { throw new ArgumentException("length affine offset vector must be equal or larger than NUpdate of the mapping", "spatialOpAffine"); } m_Context = ctx; m_Solver = solver; m_Subgrid = subgrid; m_SubgridMapping = fields; m_AffineOffset1 = spatialOpAffine.ToArray(); this.temporalOp = temporalOp; BLAS.dscal(m_AffineOffset1.Length, -1.0, m_AffineOffset1, 1); { // check temporal operator // ----------------------- if (m_SubgridMapping.Fields.Count != temporalOp.Length) { throw new ArgumentException( "lenght of temporalOp must be equal to number of domain/codomain variables of the spatial differential operator", "temporalOp"); } m_SubgridMapping.Compress(); m_SubgridDGCoordinates = m_SubgridMapping.subgridCoordinates; m_SubgridMapping.SetupSubmatrix(m_AffineOffset1, spatialOpMtx, out m_CompressedAffine, out m_CompressedMatrix); bool timedep = false; bool fullyTimeDep = true; foreach (bool b in temporalOp) { timedep = timedep || b; fullyTimeDep = fullyTimeDep & b; } if (!timedep) { throw new ArgumentException("At least one equation must be time-dependent; one entry in temporalOp must be true;", "temporalOp"); } DefineMatrix(m_CompressedMatrix, InitialDeltat); } }
public OperatorSplitting(Context context, SubGrid subgrid , SubgridCoordinateMapping v) { m_Context = context; sourcevariable = v; sourcevariable.Compress(); Partition part = new Partition(v.NUpdate, 1); affine = new double[v.NUpdate]; //opmatr= new MsrMatrix(part,v.MaxTotalNoOfCoordinatesPerCell * (int)m_Context.GridDat.GlobalNoOfCells); opmatr = new MsrMatrix(part); m_Subgrid = subgrid; }
/// <summary> /// sets the <see cref="SubgridCoordinateMapping"/> to <paramref name="m"/> /// The new mapping is compressed again to the narrow band only. /// </summary> /// <param name="m"></param> protected void SetMapping(SubgridCoordinateMapping m) { m_SubgridMapping = m; m_SubgridMapping.Compress(); m_SubgridDGCoordinates = m_SubgridMapping.subgridCoordinates; }