Example #1
0
        /// <summary>
        /// Transformation matrices, for cell subdivision, as computed by <see cref="RefElement.SubdivisionTreeNode.GetBasisTrafo(int)"/>,
        /// are cached by this method.
        /// </summary>
        /// <param name="iKref">Reference element index, correlates with 1st index of <see cref="KrefS_SubdivLeaves"/>.</param>
        /// <param name="iSubdiv">Subdivision leaf index, correlates with 2nd index of <see cref="KrefS_SubdivLeaves"/>.</param>
        /// <param name="p">Requested polynomial degree.</param>
        /// <returns></returns>
        public MultidimensionalArray GetSubdivBasisTransform(int iKref, int iSubdiv, int p)
        {
            if (Subdiv_BasisTransform == null)
            {
                Subdiv_BasisTransform = new MultidimensionalArray[KrefS_SubdivLeaves.Length][];
            }

            if (Subdiv_BasisTransform[iKref] == null)
            {
                Subdiv_BasisTransform[iKref] = new MultidimensionalArray[KrefS_SubdivLeaves[iKref].Length];
            }

            RefElement Kref = KrefS_SubdivLeaves[iKref][0].RefElement;
            int        Np   = Kref.GetNoOfOrthonormalPolynomialsUptoDegree(p);

            if (Subdiv_BasisTransform[iKref][iSubdiv] == null || Subdiv_BasisTransform[iKref][iSubdiv].NoOfCols < Np)
            {
                Subdiv_BasisTransform[iKref][iSubdiv] = KrefS_SubdivLeaves[iKref][iSubdiv].GetBasisTrafo(p);
            }

            if (Subdiv_BasisTransform[iKref][iSubdiv].NoOfCols >= Np)
            {
                return(Subdiv_BasisTransform[iKref][iSubdiv].ExtractSubArrayShallow(new[] { 0, 0 }, new[] { Np - 1, Np - 1 }));
            }
            else
            {
                Debug.Assert(Subdiv_BasisTransform[iKref][iSubdiv].NoOfCols == Np);
                Debug.Assert(Subdiv_BasisTransform[iKref][iSubdiv].NoOfRows == Np);
                return(Subdiv_BasisTransform[iKref][iSubdiv]);
            }
        }
Example #2
0
        /// <summary>
        /// Transformation matrices, for cell subdivision, as computed by <see cref="RefElement.SubdivisionTreeNode.GetBasisTrafo(int)"/>,
        /// are cached by this method.
        /// </summary>
        /// <param name="iKref">Reference element index, correlates with 1st index of <see cref="KrefS_SubdivLeaves"/>.</param>
        /// <param name="iSubdiv">Subdivision leaf index, correlates with 2nd index of <see cref="KrefS_SubdivLeaves"/>.</param>
        /// <param name="p">Requested polynomial degree.</param>
        /// <returns></returns>
        public Tuple <MultidimensionalArray, double> GetSubdivBasisTransform(int iKref, int iSubdiv, int p)
        {
            if (Subdiv_BasisTransform == null)
            {
                Subdiv_BasisTransform = new Tuple <MultidimensionalArray, double> [KrefS_SubdivLeaves.Length][];
            }

            if (Subdiv_BasisTransform[iKref] == null)
            {
                Subdiv_BasisTransform[iKref] = new Tuple <MultidimensionalArray, double> [KrefS_SubdivLeaves[iKref].Length];
            }

            RefElement Kref = KrefS_SubdivLeaves[iKref][0].RefElement;
            int        Np   = Kref.GetNoOfOrthonormalPolynomialsUptoDegree(p);

            if (Subdiv_BasisTransform[iKref][iSubdiv] == null || Subdiv_BasisTransform[iKref][iSubdiv].Item1.NoOfCols < Np)
            {
                MultidimensionalArray R = KrefS_SubdivLeaves[iKref][iSubdiv].GetBasisTrafo(p);
                Subdiv_BasisTransform[iKref][iSubdiv] = new Tuple <MultidimensionalArray, double>(
                    R,
                    KrefS_SubdivLeaves[iKref][iSubdiv].TrafoFromRoot.Matrix.Determinant()
                    );
            }

            if (Subdiv_BasisTransform[iKref][iSubdiv].Item1.NoOfCols >= Np)
            {
                return(new Tuple <MultidimensionalArray, double>(
                           Subdiv_BasisTransform[iKref][iSubdiv].Item1.ExtractSubArrayShallow(new[] { 0, 0 }, new[] { Np - 1, Np - 1 }),
                           Subdiv_BasisTransform[iKref][iSubdiv].Item2
                           ));
            }
            else
            {
                Debug.Assert(Subdiv_BasisTransform[iKref][iSubdiv].Item1.NoOfCols == Np);
                Debug.Assert(Subdiv_BasisTransform[iKref][iSubdiv].Item1.NoOfRows == Np);
                return(Subdiv_BasisTransform[iKref][iSubdiv]);
            }
        }