/// <summary> /// Evaluates this operator for given DG fields; /// </summary> /// <param name="DomainMapping"> /// the domain variables, or "input data" for the operator; the number /// of elements must be equal to the number of elements in the /// <see cref="DomainVar"/>-list; /// </param> /// <param name="Params"> /// List of parameter fields; May be null /// </param> /// <param name="CodomainMapping"> /// the co-domain variables, or "output" for the evaluation of the /// operator; the number of elements must be equal to the number of /// elements in the <see cref="CodomainVar"/>-list; /// </param> /// <param name="alpha"> /// scaling of the operator /// </param> /// <param name="beta"> /// scaling of the accumulator (<paramref name="CodomainMapping"/>); /// </param> /// <param name="sgrd"> /// subgrid, for restricted evaluation; null indicates evaluation on /// the full grid. /// </param> /// <param name="bndMode"> /// Treatment of subgrid boundaries, if <paramref name="sgrd"/> is not /// null. See <see cref="Evaluator"/> /// </param> /// <param name="qInsEdge"> /// Optional definition of the edge quadrature scheme. Since this /// already implies a domain of integration, must be null if /// <paramref name="sgrd"/> is not null. /// </param> /// <param name="qInsVol"> /// Optional definition of the volume quadrature scheme. Since this /// already implies a domain of integration, must be null if /// <paramref name="sgrd"/> is not null. /// </param> /// <remarks> /// If some of the input data, <paramref name="DomainMapping"/>, is /// contained in the output data, <paramref name="CodomainMapping"/>, /// these DG fields will be cloned to ensure correct operation of the /// operator evaluation.<br/> /// It is not a good choice to use this function if this operator /// should be evaluated multiple times and contains linear components /// (i.e. <see cref="ContainsLinear"/> returns true); If the latter is /// the case, the matrix which represents the linear components of the /// operator must be computed first, which is computational- and /// memory-intensive; After execution of this method, the matrix will /// be lost; If multiple evaluation is desired, the /// <see cref="Evaluator"/>-class should be used, in which the matrix /// of the operator will persist; However, if no linear components are /// present, the performance of this function should be almost /// comparable to the use of the <see cref="Evaluator"/>-class; /// </remarks> static public void Evaluate( this SpatialOperator op, double alpha, double beta, CoordinateMapping DomainMapping, IList <DGField> Params, CoordinateMapping CodomainMapping, SubGrid sgrd = null, EdgeQuadratureScheme qInsEdge = null, CellQuadratureScheme qInsVol = null, SpatialOperator.SubGridBoundaryModes bndMode = SubGridBoundaryModes.OpenBoundary, double time = double.NaN) // { using (new FuncTrace()) { if (sgrd != null && (qInsEdge != null || qInsVol != null)) { throw new ArgumentException("Specification of Subgrid and quadrature schemes is exclusive: not allowed to specify both at the same time.", "sgrd"); } #if DEBUG op.Verify(); //this has already been done during this.Commit() #endif IList <DGField> _DomainFields = DomainMapping.Fields; IList <DGField> _CodomainFields = CodomainMapping.Fields; DGField[] _DomainFieldsRevisited = new DGField[_DomainFields.Count]; bool a = false; for (int i = 0; i < _DomainFields.Count; i++) { DGField f = _DomainFields[i]; if (_CodomainFields.Contains(f)) { // some of the domain variables (input data) // is also a member of the codomain variables (output); // the data need to be cloned to provide correct results a = true; _DomainFieldsRevisited[i] = (DGField)f.Clone(); } else { _DomainFieldsRevisited[i] = f; } } CoordinateMapping domainMappingRevisited; if (a) { domainMappingRevisited = new CoordinateMapping(_DomainFieldsRevisited); } else { domainMappingRevisited = DomainMapping; } if (sgrd != null) { CellMask cm = (sgrd == null) ? null : sgrd.VolumeMask; EdgeMask em = (sgrd == null) ? null : sgrd.AllEdgesMask; qInsEdge = new EdgeQuadratureScheme(true, em); qInsVol = new CellQuadratureScheme(true, cm); } var ev = op.GetEvaluatorEx( domainMappingRevisited, Params, CodomainMapping, qInsEdge, qInsVol); if (sgrd != null) { ev.ActivateSubgridBoundary(sgrd.VolumeMask, bndMode); } CoordinateVector outp = new CoordinateVector(CodomainMapping); ev.time = time; ev.Evaluate <CoordinateVector>(alpha, beta, outp); } }