/// <summary> /// common for all constructors /// </summary> protected void Setup1(ISparseSolverExt solver, bool[] temporalOp, MsrMatrix spatialOpMtx, IList <double> spatialOpAffine, CoordinateMapping fields) { // 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.RowPartitioning.LocalLength != fields.LocalLength) { throw new ArgumentException("number of locally stored matrix rows nust be equal to NUpdate of fields mapping.", "fields,spatialOpMtx"); } if (spatialOpAffine.Count < fields.LocalLength) { throw new ArgumentException("length affine offset vector must be equal or larger than NUpdate of the mapping", "spatialOpAffine"); } m_Solver = solver; m_Mapping = fields; m_AffineOffset1 = spatialOpAffine.ToArray(); //Setup2(spatialOpMtx, temporalOp); //} ///// <summary> ///// Common to all constructors; Passes the Matrix <paramref name="eM"/> ///// to the solver and initializes <see cref="m_diagVecOneSec"/>; ///// </summary> ///// <param name="eM"><see cref="eM"/></param> ///// <param name="temporalOp"><see cref="ImplicitTimeStepper"/></param> //private void _Setup2(MsrMatrix eM, bool[] temporalOp) { { // check temporal operator // ----------------------- if (m_Mapping.Fields.Count != temporalOp.Length) { throw new ArgumentException( "length of temporalOp must be equal to number of domain/codomain variables of the spatial differential operator", "temporalOp"); } m_DGCoordinates = new CoordinateVector(m_Mapping); 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"); } // Construct diagonal matrix vector // -------------------------------- m_diagVecOneSec = new double[m_Mapping.MaxTotalNoOfCoordinatesPerCell]; IList <DGField> _fields = m_Mapping.Fields; for (int g = 0; g < temporalOp.Length; g++) { if (temporalOp[g]) { DGField gamma = _fields[g]; for (int n = 0; n < gamma.Basis.MaximalLength; n++) { m_diagVecOneSec[m_Mapping.LocalUniqueCoordinateIndex(g, 0, n)] = 1.0; } } } // initialize linear solver m_Solver.DefineMatrix(spatialOpMtx); } }