Ejemplo n.º 1
0
        /// <summary>
        /// Ctor for operator analysis class
        /// </summary>
        /// <param name="delComputeOperatorMatrix"></param>
        /// <param name="Mapping"></param>
        /// <param name="CurrentState"></param>
        /// <param name="AgglomeratedCellLengthScales"></param>
        /// <param name="time"></param>
        public OpAnalysisBase(DelComputeOperatorMatrix delComputeOperatorMatrix, UnsetteledCoordinateMapping Mapping, DGField[] CurrentState, Dictionary <SpeciesId, MultidimensionalArray> AgglomeratedCellLengthScales, double time)
        {
            //System.Threading.Thread.Sleep(10000);

            m_OpMtx  = new BlockMsrMatrix(Mapping, Mapping);                                                        //operator matrix
            localRHS = new double[Mapping.LocalLength];                                                             //right hand side
            RHSlen   = Mapping.TotalLength;
            m_map    = Mapping;                                                                                     // mapping

            VarGroup = m_map.BasisS.Count.ForLoop(i => i);                                                          //default: all dependent variables are included in operator matrix
            delComputeOperatorMatrix(m_OpMtx, localRHS, Mapping, CurrentState, AgglomeratedCellLengthScales, time); // delegate for computing the operator matrix
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Constructor;
        /// </summary>
        /// <param name="Fields"></param>
        /// <param name="IterationResiduals"></param>
        /// <param name="LsTrk"></param>
        /// <param name="_ComputeOperatorMatrix">See <see cref="ComputeOperatorMatrix"/>.</param>
        /// <param name="_UpdateLevelset">See <see cref="UpdateLevelset"/>.</param>
        /// <param name="BDForder">
        /// The order of the BDF scheme from 1 to 6; in addition, 0 encodes Explicit Euler and -1 encodes Crank-Nicolson.
        /// </param>
        /// <param name="_LevelSetHandling"></param>
        /// <param name="_MassMatrixShapeandDependence"></param>
        /// <param name="_SpatialOperatorType"></param>
        /// <param name="_MassScale"></param>
        /// <param name="_AgglomerationThreshold"></param>
        /// <param name="_RKscheme"></param>
        /// <param name="useX">
        /// U dont want to know!
        /// </param>
        /// <param name="_MultigridSequence"></param>
        /// <param name="_CutCellQuadOrder">Order of quadrature in cut cells, required e.g. for <see cref="LevelSetTracker.GetXDGSpaceMetrics(SpeciesId[], int, int)"/></param>
        /// <param name="_SpId">Species to compute, actually a subset of <see cref="LevelSetTracker.SpeciesIdS"/></param>
        /// <param name="_MultigridOperatorConfig">
        /// Configuration of block-preconditioner, if null a default value is chosen.
        /// </param>
        public XdgRKTimestepping(DGField[] Fields,
                                 DGField[] IterationResiduals,
                                 LevelSetTracker LsTrk,
                                 DelComputeOperatorMatrix _ComputeOperatorMatrix,
                                 DelUpdateLevelset _UpdateLevelset,
                                 RungeKuttaScheme _RKscheme,
                                 LevelSetHandling _LevelSetHandling,
                                 MassMatrixShapeandDependence _MassMatrixShapeandDependence,
                                 SpatialOperatorType _SpatialOperatorType,
                                 IDictionary <SpeciesId, IEnumerable <double> > _MassScale,
                                 MultigridOperator.ChangeOfBasisConfig[][] _MultigridOperatorConfig,
                                 AggregationGridData[] _MultigridSequence,
                                 SpeciesId[] _SpId,
                                 int _CutCellQuadOrder,
                                 double _AgglomerationThreshold, bool useX,
                                 Control.NonLinearSolverConfig nonlinconfig,
                                 Control.LinearSolverConfig linearconfig) : base(nonlinconfig, linearconfig)
        {
            // check args, set internals
            // -------------------------

            if (Fields.Length != IterationResiduals.Length)
            {
                throw new ArgumentException("Expecting the same number of fields and residuals.");
            }
            for (int iFld = 0; iFld < Fields.Length; iFld++)
            {
                if (!Fields[iFld].Basis.Equals(IterationResiduals[iFld].Basis))
                {
                    throw new ArgumentException(string.Format("Mismatch between {0}-th basis of fields and residuals.", iFld));
                }
            }

            if (_MassScale != null)
            {
                if (!IEnumerableExtensions.SetEquals(_SpId, _MassScale.Keys))
                {
                    throw new ArgumentException();
                }
            }

            base.Residuals = new CoordinateVector(IterationResiduals);

            if (!(_RKscheme.IsExplicit || _RKscheme.IsDiagonallyImplicit))
            {
                throw new NotSupportedException("Only supporting explicit or diagonally implicit schemes.");
            }

            base.m_LsTrk = LsTrk;
            base.Config_LevelSetHandling             = _LevelSetHandling;
            base.Config_MassMatrixShapeandDependence = _MassMatrixShapeandDependence;
            base.Config_SpatialOperatorType          = _SpatialOperatorType;
            base.ComputeOperatorMatrix         = _ComputeOperatorMatrix;
            base.UpdateLevelset                = _UpdateLevelset;
            base.Config_MassScale              = _MassScale;
            base.Config_AgglomerationThreshold = _AgglomerationThreshold;
            this.m_RKscheme                    = _RKscheme.CloneAs();
            base.MultigridSequence             = _MultigridSequence;
            base.Config_SpeciesToCompute       = _SpId;
            base.Config_CutCellQuadratureOrder = _CutCellQuadOrder;
            if (_MultigridSequence == null || _MultigridSequence.Length < 1)
            {
                throw new ArgumentException("At least one grid level is required.");
            }

            m_CurrentState = new CoordinateVector(Fields);

            if (_MultigridOperatorConfig != null)
            {
                Config_MultigridOperator = _MultigridOperatorConfig;
            }
            else
            {
                SetConfig_MultigridOperator_Default(Fields);
            }

            base.CommonConfigurationChecks();

            // configure stack of level-set-tracker
            // ------------------------------------

            if (Config_LevelSetHandling == LevelSetHandling.None)
            {
                m_LsTrk.IncreaseHistoryLength(0);
            }
            else if (Config_LevelSetHandling == LevelSetHandling.LieSplitting ||
                     Config_LevelSetHandling == LevelSetHandling.StrangSplitting)
            {
                m_LsTrk.IncreaseHistoryLength(1);
            }
            else
            {
                m_LsTrk.IncreaseHistoryLength(m_RKscheme.Stages);
            }
            //m_LsTrk.IncreaseHistoryLength(1);

            // multigrid - init
            // ----------------

            InitMultigrid(Fields, useX);
        }