//public static MultidimensionalArray SortPoints(GridData gridData, SinglePhaseField field, MultidimensionalArray points, bool byFlux = false) {
        //    double[] sortedXCoords = new double[points.Lengths[0]];
        //    double[] sortedYCoords = new double[points.Lengths[0]];
        //    int keptEntries = 0;

        //    for (int i = 0; i < points.Lengths[0]; i++) {
        //        // Compute global cell index of the point
        //        double[] currentPoint = points.ExtractSubArrayShallow(i, 0, -1).To1DArray();
        //        gridData.LocatePoint(currentPoint, out long GlobalId, out long GlobalIndex, out bool IsInside, out bool OnThisProcess);

        //        // Compute local node set
        //        NodeSet nodeSet = GetLocalNodeSet(gridData, currentPoint, (int)GlobalIndex);

        //        // Get local cell index of current point
        //        int j0Grd = gridData.CellPartitioning.i0;
        //        int jLocal = (int)(GlobalIndex - j0Grd);

        //        // Calculate secondDerivative
        //        double secondDerivative;
        //        if (byFlux) {
        //            secondDerivative = SecondDerivativeByFlux(field, jLocal, nodeSet,);
        //        } else {
        //            secondDerivative = SecondDerivative(field, jLocal, nodeSet);
        //        }

        //        // Select points where second derivative is larger than zero
        //        if (secondDerivative > 0.0) {
        //            sortedXCoords[keptEntries] = currentPoint[0];
        //            sortedYCoords[keptEntries] = currentPoint[1];
        //            keptEntries++;
        //        }
        //    }

        //    // Resize final array
        //    MultidimensionalArray result = MultidimensionalArray.Create(keptEntries, points.Lengths[1], points.Lengths[2]);
        //    for (int i = 0; i < keptEntries; i++) {
        //        result[i, 0, 0] = sortedXCoords[i];
        //        result[i, 0, 1] = sortedYCoords[i];
        //    }

        //    return result;
        //}

        /// <summary>
        /// Performs the patch recovery on a given DG field
        /// </summary>
        /// <param name="input">A <see cref="SinglePhaseField"/></param>
        /// <returns>A patch recovered <see cref="SinglePhaseField"/> with a degree of inputDegreee + 2</returns>
        public static SinglePhaseField PatchRecovery(SinglePhaseField input)
        {
            Console.WriteLine(String.Format("Patch recovery of field {0} started...", input.Identification));

            Basis            prcBasis = new Basis(input.GridDat, input.Basis.Degree + 2);
            L2PatchRecovery  prc      = new L2PatchRecovery(input.Basis, prcBasis, CellMask.GetFullMask(input.GridDat), RestrictToCellMask: true);
            SinglePhaseField prcField = new SinglePhaseField(prcBasis, input.Identification + "_prc");

            prc.Perform(prcField, input);

            Console.WriteLine(String.Format("finished", input.Identification));

            return(prcField);
        }
Esempio n. 2
0
        private void Filter(SinglePhaseField FiltrdField, int NoOfSweeps, CellMask CC)
        {
            Basis patchRecoveryBasis = FiltrdField.Basis;

            L2PatchRecovery l2pr = new L2PatchRecovery(patchRecoveryBasis, patchRecoveryBasis, CC, true);

            SinglePhaseField F_org = FiltrdField.CloneAs();

            for (int pass = 0; pass < NoOfSweeps; pass++)
            {
                F_org.Clear();
                F_org.Acc(1.0, FiltrdField);
                FiltrdField.Clear();
                l2pr.Perform(FiltrdField, F_org);
            }
        }