/// <summary> /// Method that is called by the base class constructor. In this implicit euler scheme, it simply /// adds the diagonal entries to the operator matrix. /// Currently only working for fields that should be included in the time stepping. /// </summary> /// <param name="OperatorMatrix">The operator matrix that should be adjusted and passed onto the solver</param> /// <param name="dt">time step size</param> protected override void DefineMatrix(MsrMatrix OperatorMatrix, double dt) { int[] cells = m_Subgrid.SubgridIndex2LocalCellIndex; IList <Field> fields = m_SubgridMapping.Fields; int CoordinateOffset = 0; for (int g = 0; g < temporalOp.Length; g++) { if (temporalOp[g]) { Field gamma = fields[g]; for (int j = 0; j < cells.Length; j++) { int iglob = j * m_SubgridMapping.MaxTotalNoOfCoordinatesPerCell + CoordinateOffset + (int)OperatorMatrix.RowPartition.i0; for (int n = 0; n < gamma.Basis.MaximalLength; n++) { double vadd = 1.0 / dt; double v = OperatorMatrix.GetDiagElement(iglob); v += vadd; OperatorMatrix.SetDiagElement(iglob, v); iglob++; } } } CoordinateOffset += fields[g].Basis.MaximalLength; } m_Solver.DefineMatrix(OperatorMatrix); OperatorMatrix.SaveToTextFileSparse("Matrix.txt"); }