Exemplo n.º 1
0
        double[] BuildCoordinatesAndQuadRule(int resolution)
        {
            daRuleS = gridDat.Grid.RefElements.Select(Kref => Kref.GetQuadratureRule(2 * (resolution - 3))).ToArray();
            NodeSet QuadNodes = daRuleS[0].Nodes;

            double[] coordinates = new double[resolution];
            coordinates[0] = -1;
            coordinates[resolution - 1] = 1;
            for (int i = 0; i < resolution - 2; ++i)
            {
                coordinates[i + 1] = QuadNodes[i, 0];
            }
            return(coordinates);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Initializes the Solver. Creates the objects that are used in the solver-method.
        /// Outlines the QuadNodesGlobal which are used as nodes for the geometric approach.
        /// Creates the edges on which the values will be defined in the solver-method.
        /// Creates a Cell which holds all the information of the parameters in the inside of the cell
        /// </summary>
        /// <param name="ExtPropertyBasis"></param>
        public ExtVelSolver_Geometric(Basis ExtPropertyBasis)
        {
            this.SolverBasis = ExtPropertyBasis;
            this.GridDat     = (GridData)ExtPropertyBasis.GridDat;

            //Build Edges.
            double[] NodeGrid         = GenericBlas.Linspace(-1, 1, Math.Max(20, (this.SolverBasis.Degree + 1) * 2));
            int      maxNumberOfEdges = 6;

            edgesOfCell = new Edge[maxNumberOfEdges];
            for (int i = 0; i < maxNumberOfEdges; i++)
            {
                edgesOfCell[i] = new Edge(NodeGrid, GridDat);
            }

            DaRuleS         = this.GridDat.Grid.RefElements.Select(Kref => Kref.GetQuadratureRule(this.SolverBasis.Degree * 2)).ToArray();
            QuadNodesGlobal = DaRuleS.Select(rule => MultidimensionalArray.Create(rule.NoOfNodes, GridDat.SpatialDimension)).ToArray();
        }
Exemplo n.º 3
0
        public LocalSolver_Geometric(Basis __LevelSetBasis_Geometric)
        {
            LevelSetBasis_Geometric = __LevelSetBasis_Geometric;
            GridDat = (GridData)(LevelSetBasis_Geometric.GridDat);

            int D = this.GridDat.SpatialDimension;

            if (D != 2)
            {
                throw new NotImplementedException("Geometric solver currently only implemented for 2D.");
            }

            if (!(this.GridDat.Edges.EdgeRefElements.Count() == 1 && this.GridDat.Edges.EdgeRefElements.First().GetType() == typeof(Foundation.Grid.RefElements.Line)))
            {
                throw new NotImplementedException();
            }


            double[] _EdgeNodes = GenericBlas.Linspace(-1, 1, Math.Max(10, (this.LevelSetBasis_Geometric.Degree + 1) * 2));
            int      NN         = _EdgeNodes.Length;

            this.EdgeNodes = new NodeSet(GridDat.Edges.EdgeRefElements[0], NN, 1);
            EdgeNodes.ExtractSubArrayShallow(-1, 0).SetVector(_EdgeNodes);
            this.EdgeNodes.LockForever();

            DaRuleS         = this.GridDat.Grid.RefElements.Select(Kref => Kref.GetQuadratureRule(this.LevelSetBasis_Geometric.Degree * 2)).ToArray();
            QuadNodesGlobal = DaRuleS.Select(rule => MultidimensionalArray.Create(rule.NoOfNodes, D)).ToArray();

            int NNKmax = 4;

            PhiEvalBuffer   = new MultidimensionalArray[NNKmax];
            CellNodesGlobal = new MultidimensionalArray[NNKmax];
            for (int i = 0; i < NNKmax; i++)
            {
                PhiEvalBuffer[i]   = MultidimensionalArray.Create(1, NN);
                CellNodesGlobal[i] = MultidimensionalArray.Create(NN, D);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// adds rules with fixed quadrature order to the quadrature scheme <paramref name="scheme"/>;
        /// this can be used to explicitly specify the quadrature order, the choice of the order during the compilation of the scheme
        /// (see <see cref="QuadratureScheme{A,B}.Compile"/>) will have no effect.
        /// </summary>
        public static EdgeQuadratureScheme AddFixedOrderRules(this EdgeQuadratureScheme scheme, IGridData GridDat, int order)
        {
            var QRs = GridDat.iGeomEdges.EdgeRefElements.Select(Kref => Kref.GetQuadratureRule(order));

            return(scheme.AddFixedRuleS <EdgeQuadratureScheme, QuadRule, EdgeMask>(QRs));
        }
Exemplo n.º 5
0
        /// <summary>
        /// adds rules with fixed quadrature order to the quadrature scheme <paramref name="scheme"/>;
        /// this can be used to explicitly specify the quadrature order, the choice of the order during the compilation of the scheme
        /// (see <see cref="QuadratureScheme{A,B}.Compile"/>) will have no effect.
        /// </summary>
        public static CellQuadratureScheme AddFixedOrderRules(this CellQuadratureScheme scheme, IGridData GridDat, int order)
        {
            var QRs = GridDat.iGeomCells.RefElements.Select(Kref => Kref.GetQuadratureRule(order));

            return(scheme.AddFixedRuleS <QuadRule>(QRs));
        }
Exemplo n.º 6
0
        void UpdateBoundingBoxes()
        {
            var grd              = lsTrk.GridDat;
            int D                = grd.SpatialDimension;
            int J                = grd.Cells.Count;
            var KrefS            = grd.Grid.RefElements;
            var VolQRs           = KrefS.Select(Kref => Kref.GetBruteForceQuadRule(6, 2)).ToArray();
            var BruteForceVolFam = VolQRs;


            // cache some vals
            SubGrid allCut      = lsTrk.Regions.GetCutCellSubGrid();
            int     JsubCC      = allCut.LocalNoOfCells;
            int     NoOfLevSets = lsTrk.LevelSets.Count();

            MultidimensionalArray[] LevSetVals  = new MultidimensionalArray[NoOfLevSets];
            MultidimensionalArray[] GlobalNodes = BruteForceVolFam.Select(nscc => MultidimensionalArray.Create(nscc.Nodes.NoOfNodes, D)).ToArray();

            int[] m_CutCellSubGrid_SubgridIndex2LocalCellIndex = lsTrk.Regions.GetCutCellSubGrid().SubgridIndex2LocalCellIndex;

            // set BoundingBox'es for cut cells
            // ================================

            double[] pt = new double[D];
            for (int jsub = 0; jsub < JsubCC; jsub++)  // loop over all local cells in subgrid ...
            {
                int j_cell        = m_CutCellSubGrid_SubgridIndex2LocalCellIndex[jsub];
                int iKref         = grd.Cells.GetRefElementIndex(j_cell);
                int NoOfQuadNodes = BruteForceVolFam[iKref].NoOfNodes;

                // loop over level sets (evaluation) ...
                for (int levSetIdx = 0; levSetIdx < NoOfLevSets; levSetIdx++)
                {
                    LevSetVals[levSetIdx] = lsTrk.DataHistories[levSetIdx].Current.GetLevSetValues(BruteForceVolFam[iKref].Nodes, j_cell, 1);
                }

                grd.TransformLocal2Global(BruteForceVolFam[iKref].Nodes, GlobalNodes[iKref], j_cell);

                ReducedRegionCode rrc;
                int NoOfSpec = lsTrk.Regions.GetNoOfSpecies(j_cell, out rrc);

                this.BoundingBoxes[j_cell] = NoOfSpec.ForLoop(iSpc => new BoundingBox(D));

                for (int m = 0; m < NoOfQuadNodes; m++)
                {
                    GlobalNodes[iKref].GetRow(m, pt);

                    double val0 = LevSetVals[0][0, m];
                    double val1 = 0;
                    if (NoOfLevSets > 1)
                    {
                        val1 = LevSetVals[1][0, m];
                    }
                    double val2 = 0;
                    if (NoOfLevSets > 2)
                    {
                        val2 = LevSetVals[2][0, m];
                    }
                    double val3 = 0;
                    if (NoOfLevSets > 3)
                    {
                        val3 = LevSetVals[3][0, m];
                    }

                    LevelSetSignCode LevSetCode = LevelSetSignCode.ComputeLevelSetBytecode(val0, val1, val2, val3);
                    int iSpec = lsTrk.GetSpeciesIndex(rrc, LevSetCode);

                    this.BoundingBoxes[j_cell][iSpec].AddPoint(pt);
                }
            }

            // set Boundingboxes for un-cut cells
            // ==================================
            for (int j = 0; j < J; j++)
            {
                if (this.BoundingBoxes[j] == null)
                {
                    ReducedRegionCode rrc;
                    int NoOfSpc = lsTrk.Regions.GetNoOfSpecies(j, out rrc);



                    BoundingBox BB = new BoundingBox(D);
                    grd.Cells.GetCellBoundingBox(j, BB);
                    this.BoundingBoxes[j] = new BoundingBox[] { BB };
                }
            }
        }