Ejemplo n.º 1
0
        private void RKstageImplicit(double PhysTime, double dt, double[][] k, int s, BlockMsrMatrix[] Mass, CoordinateVector u0, double ActualLevSetRelTime, double[] RK_as, double RelTime)
        {
            Debug.Assert(s < m_RKscheme.Stages);
            Debug.Assert(m_RKscheme.c[s] > 0);
            Debug.Assert(RK_as[s] != 0);

            int Ndof = m_CurrentState.Count;

            // =========
            // RHS setup
            // =========

            m_ImplStParams = new ImplicitStage_AssiParams()
            {
                m_CurrentDt           = dt,
                m_CurrentPhystime     = PhysTime,
                m_IterationCounter    = 0,
                m_ActualLevSetRelTime = ActualLevSetRelTime,
                m_RelTime             = RelTime,
                m_k     = k,
                m_u0    = u0,
                m_Mass  = Mass,
                m_RK_as = RK_as,
                m_s     = s
            };


            // ================
            // solve the system
            // ================

            NonlinearSolver         nonlinSolver;
            ISolverSmootherTemplate linearSolver;

            GetSolver(out nonlinSolver, out linearSolver);


            if (RequiresNonlinearSolver)
            {
                // Nonlinear Solver (Navier-Stokes)
                // --------------------------------

                nonlinSolver.SolverDriver(m_CurrentState, default(double[])); // Note: the RHS is passed as the affine part via 'this.SolverCallback'
            }
            else
            {
                // Linear Solver (Stokes)
                // ----------------------


                // build the saddle-point matrix
                BlockMsrMatrix System, MaMa;
                double[]       RHS;
                this.AssembleMatrixCallback(out System, out RHS, out MaMa, CurrentStateMapping.Fields.ToArray(), true);
                RHS.ScaleV(-1);

                // update the multigrid operator
                MultigridOperator mgOperator = new MultigridOperator(this.MultigridBasis, CurrentStateMapping,
                                                                     System, MaMa,
                                                                     this.Config_MultigridOperator);

                // init linear solver
                linearSolver.Init(mgOperator);

                // try to solve the saddle-point system.
                mgOperator.UseSolver(linearSolver, m_CurrentState, RHS);

                // 'revert' agglomeration
                m_CurrentAgglomeration.Extrapolate(CurrentStateMapping);
            }

            // ================
            // reset
            // ================
            m_ImplStParams = null;
        }