public Problem(IFiniteElementSpace finiteElementSpace, Dictionary <int, IVectorField> boundaryConditions, BilinearForm bilinearForm, IVectorField rightHandSide, ISolver solver = null, IQuadrature quadrature = null) { this.finiteElementSpace = finiteElementSpace; this.boundaryConditions = boundaryConditions; this.bilinearForm = bilinearForm; this.rightHandSide = rightHandSide; var dim = rightHandSide.Dimension; var mismatch = boundaryConditions.Values .Any(condition => condition.Dimension != dim); if (mismatch) { throw new ArgumentException("Dimension mismatched."); } // TODO: Validate bilinear form. this.solver = solver ?? new ConjugateGradient(1e-6); this.quadrature = quadrature ?? new GaussianQuadrature(); }
/// <summary> /// Creating performance stopwatches and registering them among <see cref="IQuadrature.CustomTimers"/> (and related). /// </summary> static public Stopwatch[][] InitStopWatches <T>(this EquationComponentArgMapping <T>[] fluxes, int FluxEvalPt, IQuadrature quad) where T : IEquationComponent // { Debug.Assert(quad.CustomTimers.Length == quad.CustomTimers_Names.Length); Debug.Assert(quad.CustomTimers.Length == quad.CustomTimers_RootPointer.Length); Debug.Assert(Array.IndexOf(quad.CustomTimers_Names, "Flux-Eval") == FluxEvalPt); Stopwatch[][] FluxesStopwatch = new Stopwatch[fluxes.Length][]; List <string> names = new List <string>(); List <Stopwatch> watches = new List <Stopwatch>(); for (int i = 0; i < fluxes.Length; i++) { FluxesStopwatch[i] = new Stopwatch[fluxes[i].m_AllComponentsOfMyType.Length]; int j = 0; foreach (object obj in fluxes[i].m_AllComponentsOfMyType) { names.Add("Flux-Eval:" + obj.GetType().Name + ":" + obj.ToString()); FluxesStopwatch[i][j] = new Stopwatch(); watches.Add(FluxesStopwatch[i][j]); j++; } } quad.CustomTimers = quad.CustomTimers.Cat(watches); quad.CustomTimers_Names = quad.CustomTimers_Names.Cat(names); int[] Pts = new int[names.Count]; ArrayTools.SetAll(Pts, FluxEvalPt); quad.CustomTimers_RootPointer = quad.CustomTimers_RootPointer.Cat(Pts); return(FluxesStopwatch); }