/// <summary> /// Sets <see cref="Config_MultigridOperator"/> to a default configuration. /// </summary> protected void SetConfig_MultigridOperator_Default(IEnumerable <DGField> Fields) { int NF = Fields.Count(); // set the MultigridOperator configuration for each level: // it is not necessary to have exactly as many configurations as actual multigrid levels: // the last configuration entry will be used for all higher level MultigridOperator.ChangeOfBasisConfig[][] configs = new MultigridOperator.ChangeOfBasisConfig[3][]; for (int iLevel = 0; iLevel < configs.Length; iLevel++) { configs[iLevel] = new MultigridOperator.ChangeOfBasisConfig[NF]; // configurations for velocity for (int d = 0; d < NF; d++) { int p = Fields.ElementAt(d).Basis.Degree; configs[iLevel][d] = new MultigridOperator.ChangeOfBasisConfig() { DegreeS = new[] { Math.Max(0, p - iLevel) }, mode = MultigridOperator.Mode.IdMass_DropIndefinite, VarIndex = new int[] { d } }; } } this.Config_MultigridOperator = configs; }
/* * /// <summary> * /// Legacy-Constructor for user-specified <see cref="DelComputeOperatorMatrix"/> * /// </summary> * public XdgTimestepping( * DelComputeOperatorMatrix userComputeOperatorMatrix, * IEnumerable<DGField> Fields, * IEnumerable<DGField> IterationResiduals, * TimeSteppingScheme __Scheme, * DelUpdateLevelset _UpdateLevelset, * LevelSetHandling _LevelSetHandling, * MultigridOperator.ChangeOfBasisConfig[][] _MultigridOperatorConfig, * AggregationGridData[] _MultigridSequence, * double _AgglomerationThreshold, * LinearSolverConfig LinearSolver, NonLinearSolverConfig NonLinearSolver) // * { * this.Scheme = __Scheme; * this.XdgOperator = op; * * this.Parameters = op.InvokeParameterFactory(Fields); * * * foreach (var f in Fields.Cat(IterationResiduals).Cat(Parameters)) { * if (f != null && f is XDGField xf) { * if (LsTrk == null) { * LsTrk = xf.Basis.Tracker; * } else { * if (!object.ReferenceEquals(LsTrk, xf.Basis.Tracker)) * throw new ArgumentException(); * } * } * } * if (LsTrk == null) * throw new ArgumentException("unable to get Level Set Tracker reference"); * * bool UseX = Fields.Any(f => f is XDGField) || IterationResiduals.Any(f => f is XDGField); * * ConstructorCommon(op, UseX, * Fields, this.Parameters, IterationResiduals, * myDelComputeXOperatorMatrix, * _UpdateLevelset, * _LevelSetHandling, * _MultigridOperatorConfig, * _MultigridSequence, * _AgglomerationThreshold, * LinearSolver, NonLinearSolver); * * } */ private void ConstructorCommon( ISpatialOperator op, bool UseX, IEnumerable <DGField> Fields, IEnumerable <DGField> __Parameters, IEnumerable <DGField> IterationResiduals, SpeciesId[] spcToCompute, DelUpdateLevelset _UpdateLevelset, LevelSetHandling _LevelSetHandling, MultigridOperator.ChangeOfBasisConfig[][] _MultigridOperatorConfig, AggregationGridData[] _MultigridSequence, double _AgglomerationThreshold, LinearSolverConfig LinearSolver, NonLinearSolverConfig NonLinearSolver) // { RungeKuttaScheme rksch; int bdfOrder; DecodeScheme(this.Scheme, out rksch, out bdfOrder); SpatialOperatorType _SpatialOperatorType = SpatialOperatorType.Nonlinear; int quadOrder = op.QuadOrderFunction( Fields.Select(f => f.Basis.Degree).ToArray(), Parameters.Select(f => f != null ? f.Basis.Degree : 0).ToArray(), IterationResiduals.Select(f => f.Basis.Degree).ToArray()); // default solvers // =============== if (LinearSolver == null) { LinearSolver = new LinearSolverConfig() { SolverCode = LinearSolverCode.automatic }; } if (NonLinearSolver == null) { NonLinearSolver = new NonLinearSolverConfig() { SolverCode = NonLinearSolverCode.Newton }; } // default Multi-Grid // ================== if (_MultigridSequence == null) { _MultigridSequence = new[] { CoarseningAlgorithms.ZeroAggregation(this.GridDat) }; } // default level-set treatment // =========================== if (_UpdateLevelset == null) { _UpdateLevelset = this.UpdateLevelsetWithNothing; if (_LevelSetHandling != LevelSetHandling.None) { throw new ArgumentException($"If level-set handling is set to {_LevelSetHandling} (anything but {LevelSetHandling.None}) an updating routine must be specified."); } } // default multigrid operator config // ================================= if (_MultigridOperatorConfig == null) { int NoOfVar = Fields.Count(); _MultigridOperatorConfig = new MultigridOperator.ChangeOfBasisConfig[0][]; _MultigridOperatorConfig[0] = new MultigridOperator.ChangeOfBasisConfig[NoOfVar]; for (int iVar = 0; iVar < NoOfVar; iVar++) { _MultigridOperatorConfig[0][iVar] = new MultigridOperator.ChangeOfBasisConfig() { DegreeS = new int[] { Fields.ElementAt(iVar).Basis.Degree }, mode = MultigridOperator.Mode.Eye, VarIndex = new int[] { iVar } }; } } // finally, create timestepper // =========================== if (bdfOrder > -1000) { m_BDF_Timestepper = new XdgBDFTimestepping(Fields, __Parameters, IterationResiduals, LsTrk, true, this.ComputeOperatorMatrix, op, _UpdateLevelset, bdfOrder, _LevelSetHandling, MassMatrixShapeandDependence.IsTimeDependent, _SpatialOperatorType, _MultigridOperatorConfig, _MultigridSequence, spcToCompute, quadOrder, _AgglomerationThreshold, UseX, NonLinearSolver, LinearSolver); m_BDF_Timestepper.Config_AgglomerationThreshold = _AgglomerationThreshold; } else { m_RK_Timestepper = new XdgRKTimestepping(Fields.ToArray(), __Parameters, IterationResiduals.ToArray(), LsTrk, this.ComputeOperatorMatrix, op, _UpdateLevelset, rksch, _LevelSetHandling, MassMatrixShapeandDependence.IsTimeDependent, _SpatialOperatorType, _MultigridOperatorConfig, _MultigridSequence, spcToCompute, quadOrder, _AgglomerationThreshold, UseX, NonLinearSolver, LinearSolver); m_RK_Timestepper.Config_AgglomerationThreshold = _AgglomerationThreshold; } }