Esempio n. 1
0
        public void TestBSplines1DValues()
        {
            var degree          = 3;
            var knotValueVector = KnotValueVector;

            var parametricCoordinates = ParametricCoordinates;

            var bsplines1D = new BSPLines1D(degree, knotValueVector, parametricCoordinates);

            bsplines1D.calculateBSPLinesAndDerivatives();

            var expectedValues = new double[4, 4]
            {
                { 0.8058320948251374, 0.3007502363228445, 0.035940096838251105, 3.3471572805268126E-4 },
                { 0.18718777049037877, 0.5628454528272727, 0.5162916318030126, 0.30510371716505036 },
                { 0.006924348732218876, 0.13041429476462738, 0.39764323219603925, 0.5602562184023526 },
                { 5.5785952265056314E-5, 0.005990016085255392, 0.05012503916269711, 0.13430534870454433 },
            };

            for (var i = 0; i < 4; i++)
            {
                for (var j = 0; j < 4; j++)
                {
                    Assert.True(Utilities.AreValuesEqual(expectedValues[i, j], bsplines1D.BSPLineValues[i, j],
                                                         Tolerance));
                }
            }
        }
Esempio n. 2
0
        public void TestBSplines1DDerivativeValues()
        {
            var degree          = 3;
            var knotValueVector = KnotValueVector;

            var parametricCoordinates = ParametricCoordinates;

            var bsplines1D = new BSPLines1D(degree, knotValueVector, parametricCoordinates);

            bsplines1D.calculateBSPLinesAndDerivatives();

            var expectedDerivativeValues = new double[4, 4]
            {
                { -23.380841503242923, -12.119957092815207, -2.940468916024088, -0.13016109020350003 },
                { 21.603802526477924, 5.4150528637737025, -6.0593073618049385, -7.4595480014466915 },
                { 1.7553454623559663, 6.214826079340906, 6.979783435056406, 3.6929021828181523 },
                { 0.02169351440903006, 0.49007814970059616, 2.01999284277262, 3.8968069088320396 },
            };

            for (var i = 0; i < 4; i++)
            {
                for (var j = 0; j < 4; j++)
                {
                    Assert.True(Utilities.AreValuesEqual(expectedDerivativeValues[i, j], bsplines1D.BSPLineDerivativeValues[i, j],
                                                         Tolerance));
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Defines an 1D NURBS shape function for an edge element.
        /// </summary>
        /// <param name="element">An <see cref="Element"/> of type <see cref="NurbsElement1D"/>.</param>
        /// <param name="controlPoints">A <see cref="List{T}"/> containing the control points of the element.</param>
        /// <param name="edge">The one-dimensional boundary entity that contains the <paramref name="element"/>.</param>
        public Nurbs1D(Element element, IList <ControlPoint> controlPoints, Edge edge)
        {
            GaussQuadrature gauss = new GaussQuadrature();
            IList <GaussLegendrePoint3D> gaussPoints = gauss.CalculateElementGaussPoints(edge.Degree, element.Knots.ToArray());

            var parametricGaussPointKsi = Vector.CreateZero(edge.Degree + 1);

            for (int i = 0; i < edge.Degree + 1; i++)
            {
                parametricGaussPointKsi[i] = gaussPoints[i].Ksi;
            }
            var bsplinesKsi = new BSPLines1D(edge.Degree, edge.KnotValueVector, parametricGaussPointKsi);

            bsplinesKsi.calculateBSPLinesAndDerivatives();

            int supportKsi = edge.Degree + 1;
            int numberOfElementControlPoints = supportKsi;

            NurbsValues = Matrix.CreateZero(numberOfElementControlPoints, gaussPoints.Count);
            NurbsDerivativeValuesKsi = Matrix.CreateZero(numberOfElementControlPoints, gaussPoints.Count);

            for (int i = 0; i < supportKsi; i++)
            {
                double sumKsi  = 0;
                double sumdKsi = 0;

                for (int j = 0; j < numberOfElementControlPoints; j++)
                {
                    int index = controlPoints[j].ID;
                    sumKsi  += bsplinesKsi.BSPLineValues[index, i] * controlPoints[j].WeightFactor;
                    sumdKsi += bsplinesKsi.BSPLineDerivativeValues[index, i] * controlPoints[j].WeightFactor;
                }
                for (int j = 0; j < numberOfElementControlPoints; j++)
                {
                    int indexKsi = controlPoints[j].ID;
                    NurbsValues[j, i] = bsplinesKsi.BSPLineValues[indexKsi, i] * controlPoints[j].WeightFactor / sumKsi;
                    NurbsDerivativeValuesKsi[j, i] = controlPoints[j].WeightFactor * (bsplinesKsi.BSPLineDerivativeValues[indexKsi, i] * sumKsi -
                                                                                      bsplinesKsi.BSPLineValues[indexKsi, i] * sumdKsi) / Math.Pow(sumKsi, 2);
                }
            }
        }
Esempio n. 4
0
        public void TestBSplines1DPartitionOfUnity()
        {
            var degree          = 3;
            var knotValueVector = KnotValueVector;

            var parametricCoordinates = ParametricCoordinates;

            var bsplines1D = new BSPLines1D(degree, knotValueVector, parametricCoordinates);

            bsplines1D.calculateBSPLinesAndDerivatives();

            for (var p = 0; p < 4; p++)
            {
                var sum = 0.0;
                for (var f = 0; f < bsplines1D.BSPLineValues.GetLength(0); f++)
                {
                    sum += bsplines1D.BSPLineValues[f, p];
                }
                Assert.True(Utilities.AreValuesEqual(1.0, sum, Tolerance));
            }
        }
        /// <summary>
        /// Two-dimensional T-spline shape functions from Bezier extraction for <see cref="TSplineKirchhoffLoveShellElementMaterial"/>.
        /// </summary>
        /// <param name="element">An <see cref="Element"/> of type <see cref="TSplineKirchhoffLoveShellElementMaterial"/>.</param>
        /// <param name="controlPoints">A <see cref="List{T}"/> containing the control points of the element.</param>
        public ShapeTSplines2DFromBezierExtraction(TSplineKirchhoffLoveShellElementMaterial element, ControlPoint[] controlPoints)
        {
            GaussQuadrature gauss = new GaussQuadrature();
            IList <GaussLegendrePoint3D> gaussPoints = gauss.CalculateElementGaussPoints(element.DegreeKsi, element.DegreeHeta,
                                                                                         new List <Knot>
            {
                new Knot()
                {
                    ID = 0, Ksi = -1, Heta = -1, Zeta = 0
                },
                new Knot()
                {
                    ID = 1, Ksi = -1, Heta = 1, Zeta = 0
                },
                new Knot()
                {
                    ID = 2, Ksi = 1, Heta = -1, Zeta = 0
                },
                new Knot()
                {
                    ID = 3, Ksi = 1, Heta = 1, Zeta = 0
                }
            });

            var parametricGaussPointKsi = Vector.CreateZero(element.DegreeKsi + 1);

            for (int i = 0; i < element.DegreeKsi + 1; i++)
            {
                parametricGaussPointKsi[i] = gaussPoints[i * (element.DegreeHeta + 1)].Ksi;
            }

            var parametricGaussPointHeta = Vector.CreateZero(element.DegreeHeta + 1);

            for (int i = 0; i < element.DegreeHeta + 1; i++)
            {
                parametricGaussPointHeta[i] = gaussPoints[i].Heta;
            }

            Vector knotValueVectorKsi  = Vector.CreateZero((element.DegreeKsi + 1) * 2);
            Vector knotValueVectorHeta = Vector.CreateZero((element.DegreeHeta + 1) * 2);

            for (int i = 0; i < element.DegreeKsi + 1; i++)
            {
                knotValueVectorKsi[i] = -1;
                knotValueVectorKsi[element.DegreeKsi + 1 + i] = 1;
            }
            for (int i = 0; i < element.DegreeHeta + 1; i++)
            {
                knotValueVectorHeta[i] = -1;
                knotValueVectorHeta[element.DegreeHeta + 1 + i] = 1;
            }

            BSPLines1D bernsteinKsi  = new BSPLines1D(element.DegreeKsi, knotValueVectorKsi, parametricGaussPointKsi);
            BSPLines1D bernsteinHeta = new BSPLines1D(element.DegreeHeta, knotValueVectorHeta, parametricGaussPointHeta);

            bernsteinKsi.calculateBSPLinesAndDerivatives();
            bernsteinHeta.calculateBSPLinesAndDerivatives();

            int supportKsi  = element.DegreeKsi + 1;
            int supportHeta = element.DegreeHeta + 1;

            var bKsi   = MatrixPart(supportKsi, bernsteinKsi.BSPLineValues);
            var bdKsi  = MatrixPart(supportKsi, bernsteinKsi.BSPLineDerivativeValues);
            var bddKsi = MatrixPart(supportKsi, bernsteinKsi.BSPLineSecondDerivativeValues);

            var bheta   = MatrixPart(supportHeta, bernsteinHeta.BSPLineValues);
            var bdheta  = MatrixPart(supportHeta, bernsteinHeta.BSPLineDerivativeValues);
            var bddheta = MatrixPart(supportHeta, bernsteinHeta.BSPLineSecondDerivativeValues);

            var    bernsteinShapeFunctions = KroneckerProduct(bKsi, bheta);
            Matrix bernsteinShapeFunctionDerivativesKsi           = KroneckerProduct(bheta, bdKsi);
            Matrix bernsteinShapeFunctionDerivativesHeta          = KroneckerProduct(bdheta, bKsi);
            Matrix bernsteinShapeFunctionSecondDerivativesKsi     = KroneckerProduct(bheta, bddKsi);
            Matrix bernsteinShapeFunctionSecondDerivativesHeta    = KroneckerProduct(bddheta, bKsi);
            Matrix bernsteinShapeFunctionSecondDerivativesKsiHeta = KroneckerProduct(bdheta, bdKsi);

            Matrix rationalTSplines = element.ExtractionOperator * bernsteinShapeFunctions;
            Matrix rationalTSplineDerivativesKsi           = element.ExtractionOperator * bernsteinShapeFunctionDerivativesKsi;
            Matrix rationalTSplineDerivativesHeta          = element.ExtractionOperator * bernsteinShapeFunctionDerivativesHeta;
            Matrix rationalTSplineSecondDerivativesKsi     = element.ExtractionOperator * bernsteinShapeFunctionSecondDerivativesKsi;
            Matrix rationalTSplineSecondDerivativesHeta    = element.ExtractionOperator * bernsteinShapeFunctionSecondDerivativesHeta;
            Matrix rationalTSplineSecondDerivativesKsiHeta = element.ExtractionOperator * bernsteinShapeFunctionSecondDerivativesKsiHeta;

            TSplineValues = Matrix.CreateZero(controlPoints.Length, supportKsi * supportHeta);
            TSplineDerivativeValuesKsi           = Matrix.CreateZero(controlPoints.Length, supportKsi * supportHeta);
            TSplineDerivativeValuesHeta          = Matrix.CreateZero(controlPoints.Length, supportKsi * supportHeta);
            TSplineSecondDerivativesValueKsi     = Matrix.CreateZero(controlPoints.Length, supportKsi * supportHeta);
            TSplineSecondDerivativesValueHeta    = Matrix.CreateZero(controlPoints.Length, supportKsi * supportHeta);
            TSplineSecondDerivativesValueKsiHeta = Matrix.CreateZero(controlPoints.Length, supportKsi * supportHeta);

            for (int i = 0; i < supportKsi; i++)
            {
                for (int j = 0; j < supportHeta; j++)
                {
                    double sumKsiHeta    = 0;
                    double sumdKsiHeta   = 0;
                    double sumKsidHeta   = 0;
                    double sumdKsidKsi   = 0;
                    double sumdHetadHeta = 0;
                    double sumdKsidHeta  = 0;

                    var index = i * supportHeta + j;

                    for (int k = 0; k < controlPoints.Length; k++)
                    {
                        sumKsiHeta    += rationalTSplines[k, index] * controlPoints[k].WeightFactor;
                        sumdKsiHeta   += rationalTSplineDerivativesKsi[k, index] * controlPoints[k].WeightFactor;
                        sumKsidHeta   += rationalTSplineDerivativesHeta[k, index] * controlPoints[k].WeightFactor;
                        sumdKsidKsi   += rationalTSplineSecondDerivativesKsi[k, index] * controlPoints[k].WeightFactor;
                        sumdHetadHeta += rationalTSplineSecondDerivativesHeta[k, index] * controlPoints[k].WeightFactor;
                        sumdKsidHeta  += rationalTSplineSecondDerivativesKsiHeta[k, index] * controlPoints[k].WeightFactor;
                    }

                    for (int k = 0; k < controlPoints.Length; k++)
                    {
                        TSplineValues[k, index] = rationalTSplines[k, index] * controlPoints[k].WeightFactor / sumKsiHeta;
                        TSplineDerivativeValuesKsi[k, index] = (rationalTSplineDerivativesKsi[k, index] * sumKsiHeta -
                                                                rationalTSplines[k, index] * sumdKsiHeta) /
                                                               Math.Pow(sumKsiHeta, 2) * controlPoints[k].WeightFactor;
                        TSplineDerivativeValuesHeta[k, index] = (rationalTSplineDerivativesHeta[k, index] * sumKsiHeta -
                                                                 rationalTSplines[k, index] * sumKsidHeta) /
                                                                Math.Pow(sumKsiHeta, 2) * controlPoints[k].WeightFactor;
                        TSplineSecondDerivativesValueKsi[k, index] = (rationalTSplineSecondDerivativesKsi[k, index] / sumKsiHeta -
                                                                      2 * rationalTSplineDerivativesKsi[k, index] * sumdKsiHeta /
                                                                      Math.Pow(sumKsiHeta, 2) -
                                                                      rationalTSplines[k, index] * sumdKsidKsi / Math.Pow(sumKsiHeta, 2) +
                                                                      2 * rationalTSplines[k, index] * Math.Pow(sumdKsiHeta, 2) /
                                                                      Math.Pow(sumKsiHeta, 3)) * controlPoints[k].WeightFactor;
                        TSplineSecondDerivativesValueHeta[k, index] = (rationalTSplineSecondDerivativesHeta[k, index] / sumKsiHeta -
                                                                       2 * rationalTSplineDerivativesHeta[k, index] * sumKsidHeta /
                                                                       Math.Pow(sumKsiHeta, 2) -
                                                                       rationalTSplines[k, index] * sumdHetadHeta /
                                                                       Math.Pow(sumKsiHeta, 2) +
                                                                       2 * rationalTSplines[k, index] * Math.Pow(sumKsidHeta, 2) /
                                                                       Math.Pow(sumKsiHeta, 3)) * controlPoints[k].WeightFactor;
                        TSplineSecondDerivativesValueKsiHeta[k, index] = (rationalTSplineSecondDerivativesKsiHeta[k, index] / sumKsiHeta -
                                                                          rationalTSplineDerivativesKsi[k, index] * sumKsidHeta /
                                                                          Math.Pow(sumKsiHeta, 2) -
                                                                          rationalTSplineDerivativesHeta[k, index] * sumdKsiHeta /
                                                                          Math.Pow(sumKsiHeta, 2) -
                                                                          rationalTSplines[k, index] * sumdKsidHeta /
                                                                          Math.Pow(sumKsiHeta, 2) +
                                                                          2 * rationalTSplines[k, index] * sumdKsiHeta * sumKsidHeta /
                                                                          Math.Pow(sumKsiHeta, 3)) *
                                                                         controlPoints[k].WeightFactor;
                    }
                }
            }
        }
        /// <summary>
        /// Two-dimensional T-spline shape functions from Bezier extraction for <see cref="TSplineKirchhoffLoveShellElement"/>.
        /// </summary>
        /// <param name="element">An <see cref="Element"/> of type <see cref="TSplineKirchhoffLoveShellElement"/>.</param>
        /// <param name="controlPoints">A <see cref="List{T}"/> containing the control points of the element.</param>
        /// <param name="parametricGaussPointKsi">An <see cref="IVector"/> containing Gauss points of axis Ksi.</param>
        /// <param name="parametricGaussPointHeta">An <see cref="IVector"/> containing Gauss points of axis Heta.</param>
        public ShapeTSplines2DFromBezierExtraction(TSplineKirchhoffLoveShellElement element, ControlPoint[] controlPoints, Vector parametricGaussPointKsi, Vector parametricGaussPointHeta)
        {
            Vector knotValueVectorKsi  = Vector.CreateZero((element.DegreeKsi + 1) * 2);
            Vector knotValueVectorHeta = Vector.CreateZero((element.DegreeHeta + 1) * 2);

            for (int i = 0; i < element.DegreeKsi + 1; i++)
            {
                knotValueVectorKsi[i] = -1;
                knotValueVectorKsi[element.DegreeKsi + 1 + i] = 1;
            }
            for (int i = 0; i < element.DegreeHeta + 1; i++)
            {
                knotValueVectorHeta[i] = -1;
                knotValueVectorHeta[element.DegreeHeta + 1 + i] = 1;
            }

            BSPLines1D bernsteinKsi  = new BSPLines1D(element.DegreeKsi, knotValueVectorKsi, parametricGaussPointKsi);
            BSPLines1D bernsteinHeta = new BSPLines1D(element.DegreeHeta, knotValueVectorHeta, parametricGaussPointHeta);

            bernsteinKsi.calculateBSPLinesAndDerivatives();
            bernsteinHeta.calculateBSPLinesAndDerivatives();

            int supportElementKsi  = element.DegreeKsi + 1;
            int supportElementHeta = element.DegreeHeta + 1;
            int supportKsi         = parametricGaussPointKsi.Length;
            int supportHeta        = parametricGaussPointHeta.Length;

            var bKsi   = MatrixPart(supportElementKsi, supportKsi, bernsteinKsi.BSPLineValues);
            var bdKsi  = MatrixPart(supportElementKsi, supportKsi, bernsteinKsi.BSPLineDerivativeValues);
            var bddKsi = MatrixPart(supportElementKsi, supportKsi, bernsteinKsi.BSPLineSecondDerivativeValues);

            var bheta   = MatrixPart(supportElementHeta, supportHeta, bernsteinHeta.BSPLineValues);
            var bdheta  = MatrixPart(supportElementHeta, supportHeta, bernsteinHeta.BSPLineDerivativeValues);
            var bddheta = MatrixPart(supportElementHeta, supportHeta, bernsteinHeta.BSPLineSecondDerivativeValues);

            var    bernsteinShapeFunctions = KroneckerProduct(bKsi, bheta);
            Matrix bernsteinShapeFunctionDerivativesKsi           = KroneckerProduct(bheta, bdKsi);
            Matrix bernsteinShapeFunctionDerivativesHeta          = KroneckerProduct(bdheta, bKsi);
            Matrix bernsteinShapeFunctionSecondDerivativesKsi     = KroneckerProduct(bheta, bddKsi);
            Matrix bernsteinShapeFunctionSecondDerivativesHeta    = KroneckerProduct(bddheta, bKsi);
            Matrix bernsteinShapeFunctionSecondDerivativesKsiHeta = KroneckerProduct(bdheta, bdKsi);

            Matrix rationalTSplines = element.ExtractionOperator * bernsteinShapeFunctions;
            Matrix rationalTSplineDerivativesKsi           = element.ExtractionOperator * bernsteinShapeFunctionDerivativesKsi;
            Matrix rationalTSplineDerivativesHeta          = element.ExtractionOperator * bernsteinShapeFunctionDerivativesHeta;
            Matrix rationalTSplineSecondDerivativesKsi     = element.ExtractionOperator * bernsteinShapeFunctionSecondDerivativesKsi;
            Matrix rationalTSplineSecondDerivativesHeta    = element.ExtractionOperator * bernsteinShapeFunctionSecondDerivativesHeta;
            Matrix rationalTSplineSecondDerivativesKsiHeta = element.ExtractionOperator * bernsteinShapeFunctionSecondDerivativesKsiHeta;

            TSplineValues = Matrix.CreateZero(controlPoints.Length, supportKsi * supportHeta);
            TSplineDerivativeValuesKsi           = Matrix.CreateZero(controlPoints.Length, supportKsi * supportHeta);
            TSplineDerivativeValuesHeta          = Matrix.CreateZero(controlPoints.Length, supportKsi * supportHeta);
            TSplineSecondDerivativesValueKsi     = Matrix.CreateZero(controlPoints.Length, supportKsi * supportHeta);
            TSplineSecondDerivativesValueHeta    = Matrix.CreateZero(controlPoints.Length, supportKsi * supportHeta);
            TSplineSecondDerivativesValueKsiHeta = Matrix.CreateZero(controlPoints.Length, supportKsi * supportHeta);

            for (int i = 0; i < supportKsi; i++)
            {
                for (int j = 0; j < supportHeta; j++)
                {
                    double sumKsiHeta    = 0;
                    double sumdKsiHeta   = 0;
                    double sumKsidHeta   = 0;
                    double sumdKsidKsi   = 0;
                    double sumdHetadHeta = 0;
                    double sumdKsidHeta  = 0;

                    var index = i * supportHeta + j;

                    for (int k = 0; k < controlPoints.Length; k++)
                    {
                        sumKsiHeta    += rationalTSplines[k, index] * controlPoints[k].WeightFactor;
                        sumdKsiHeta   += rationalTSplineDerivativesKsi[k, index] * controlPoints[k].WeightFactor;
                        sumKsidHeta   += rationalTSplineDerivativesHeta[k, index] * controlPoints[k].WeightFactor;
                        sumdKsidKsi   += rationalTSplineSecondDerivativesKsi[k, index] * controlPoints[k].WeightFactor;
                        sumdHetadHeta += rationalTSplineSecondDerivativesHeta[k, index] * controlPoints[k].WeightFactor;
                        sumdKsidHeta  += rationalTSplineSecondDerivativesKsiHeta[k, index] * controlPoints[k].WeightFactor;
                    }

                    for (int k = 0; k < controlPoints.Length; k++)
                    {
                        TSplineValues[k, index] = rationalTSplines[k, index] * controlPoints[k].WeightFactor / sumKsiHeta;
                        TSplineDerivativeValuesKsi[k, index] = (rationalTSplineDerivativesKsi[k, index] * sumKsiHeta -
                                                                rationalTSplines[k, index] * sumdKsiHeta) /
                                                               Math.Pow(sumKsiHeta, 2) * controlPoints[k].WeightFactor;
                        TSplineDerivativeValuesHeta[k, index] = (rationalTSplineDerivativesHeta[k, index] * sumKsiHeta -
                                                                 rationalTSplines[k, index] * sumKsidHeta) /
                                                                Math.Pow(sumKsiHeta, 2) * controlPoints[k].WeightFactor;
                        TSplineSecondDerivativesValueKsi[k, index] = (rationalTSplineSecondDerivativesKsi[k, index] / sumKsiHeta -
                                                                      2 * rationalTSplineDerivativesKsi[k, index] * sumdKsiHeta /
                                                                      Math.Pow(sumKsiHeta, 2) -
                                                                      rationalTSplines[k, index] * sumdKsidKsi / Math.Pow(sumKsiHeta, 2) +
                                                                      2 * rationalTSplines[k, index] * Math.Pow(sumdKsiHeta, 2) /
                                                                      Math.Pow(sumKsiHeta, 3)) * controlPoints[k].WeightFactor;
                        TSplineSecondDerivativesValueHeta[k, index] = (rationalTSplineSecondDerivativesHeta[k, index] / sumKsiHeta -
                                                                       2 * rationalTSplineDerivativesHeta[k, index] * sumKsidHeta /
                                                                       Math.Pow(sumKsiHeta, 2) -
                                                                       rationalTSplines[k, index] * sumdHetadHeta /
                                                                       Math.Pow(sumKsiHeta, 2) +
                                                                       2 * rationalTSplines[k, index] * Math.Pow(sumKsidHeta, 2) /
                                                                       Math.Pow(sumKsiHeta, 3)) * controlPoints[k].WeightFactor;
                        TSplineSecondDerivativesValueKsiHeta[k, index] = (rationalTSplineSecondDerivativesKsiHeta[k, index] / sumKsiHeta -
                                                                          rationalTSplineDerivativesKsi[k, index] * sumKsidHeta /
                                                                          Math.Pow(sumKsiHeta, 2) -
                                                                          rationalTSplineDerivativesHeta[k, index] * sumdKsiHeta /
                                                                          Math.Pow(sumKsiHeta, 2) -
                                                                          rationalTSplines[k, index] * sumdKsidHeta /
                                                                          Math.Pow(sumKsiHeta, 2) +
                                                                          2 * rationalTSplines[k, index] * sumdKsiHeta * sumKsidHeta /
                                                                          Math.Pow(sumKsiHeta, 3)) *
                                                                         controlPoints[k].WeightFactor;
                    }
                }
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Defines 3D NURBS shape functions given the control points.
        /// </summary>
        /// <param name="element">An <see cref="Element"/> of type <see cref="NurbsElement3D"/>.</param>
        /// <param name="controlPoints">A <see cref="List{T}"/> containing the control points of the element.</param>
        public Nurbs3D(Element element, ControlPoint[] controlPoints)
        {
            GaussQuadrature gauss = new GaussQuadrature();
            IList <GaussLegendrePoint3D> gaussPoints = gauss.CalculateElementGaussPoints(element.Patch.DegreeKsi, element.Patch.DegreeHeta, element.Patch.DegreeZeta, element.Knots.ToArray());

            var parametricGaussPointKsi = Vector.CreateZero(element.Patch.DegreeKsi + 1);

            for (int i = 0; i < element.Patch.DegreeKsi + 1; i++)
            {
                parametricGaussPointKsi[i] = gaussPoints[i * (element.Patch.DegreeZeta + 1) * (element.Patch.DegreeHeta + 1)].Ksi;
            }

            var parametricGaussPointHeta = Vector.CreateZero(element.Patch.DegreeHeta + 1);

            for (int i = 0; i < element.Patch.DegreeHeta + 1; i++)
            {
                parametricGaussPointHeta[i] = gaussPoints[i * (element.Patch.DegreeZeta + 1)].Heta;
            }

            var parametricGaussPointZeta = Vector.CreateZero(element.Patch.DegreeZeta + 1);

            for (int i = 0; i < element.Patch.DegreeZeta + 1; i++)
            {
                parametricGaussPointZeta[i] = gaussPoints[i].Zeta;
            }

            BSPLines1D bsplinesKsi  = new BSPLines1D(element.Patch.DegreeKsi, element.Patch.KnotValueVectorKsi, parametricGaussPointKsi);
            BSPLines1D bsplinesHeta = new BSPLines1D(element.Patch.DegreeHeta, element.Patch.KnotValueVectorHeta, parametricGaussPointHeta);
            BSPLines1D bsplinesZeta = new BSPLines1D(element.Patch.DegreeZeta, element.Patch.KnotValueVectorZeta, parametricGaussPointZeta);

            bsplinesKsi.calculateBSPLinesAndDerivatives();
            bsplinesHeta.calculateBSPLinesAndDerivatives();
            bsplinesZeta.calculateBSPLinesAndDerivatives();

            int supportKsi  = element.Patch.DegreeKsi + 1;
            int supportHeta = element.Patch.DegreeHeta + 1;
            int supportZeta = element.Patch.DegreeZeta + 1;
            int numberOfElementControlPoints = supportKsi * supportHeta * supportZeta;

            NurbsValues = Matrix.CreateZero(numberOfElementControlPoints, gaussPoints.Count);
            NurbsDerivativeValuesKsi  = Matrix.CreateZero(numberOfElementControlPoints, gaussPoints.Count);
            NurbsDerivativeValuesHeta = Matrix.CreateZero(numberOfElementControlPoints, gaussPoints.Count);
            NurbsDerivativeValuesZeta = Matrix.CreateZero(numberOfElementControlPoints, gaussPoints.Count);

            for (int i = 0; i < supportKsi; i++)
            {
                for (int j = 0; j < supportHeta; j++)
                {
                    for (int k = 0; k < supportZeta; k++)
                    {
                        double sumKsiHetaZeta  = 0;
                        double sumdKsiHetaZeta = 0;
                        double sumKsidHetaZeta = 0;
                        double sumKsiHetadZeta = 0;

                        for (int m = 0; m < numberOfElementControlPoints; m++)
                        {
                            int indexKsi  = controlPoints[m].ID / (element.Patch.NumberOfControlPointsHeta * element.Patch.NumberOfControlPointsZeta);
                            int indexHeta = controlPoints[m].ID % (element.Patch.NumberOfControlPointsHeta * element.Patch.NumberOfControlPointsZeta) / element.Patch.NumberOfControlPointsZeta;
                            int indexZeta = controlPoints[m].ID % (element.Patch.NumberOfControlPointsHeta * element.Patch.NumberOfControlPointsZeta) % element.Patch.NumberOfControlPointsZeta;

                            sumKsiHetaZeta += bsplinesKsi.BSPLineValues[indexKsi, i] *
                                              bsplinesHeta.BSPLineValues[indexHeta, j] *
                                              bsplinesZeta.BSPLineValues[indexZeta, k] *
                                              controlPoints[m].WeightFactor;

                            sumdKsiHetaZeta += bsplinesKsi.BSPLineDerivativeValues[indexKsi, i] *
                                               bsplinesHeta.BSPLineValues[indexHeta, j] *
                                               bsplinesZeta.BSPLineValues[indexZeta, k] *
                                               controlPoints[m].WeightFactor;

                            sumKsidHetaZeta += bsplinesKsi.BSPLineValues[indexKsi, i] *
                                               bsplinesHeta.BSPLineDerivativeValues[indexHeta, j] *
                                               bsplinesZeta.BSPLineValues[indexZeta, k] *
                                               controlPoints[m].WeightFactor;

                            sumKsiHetadZeta += bsplinesKsi.BSPLineValues[indexKsi, i] *
                                               bsplinesHeta.BSPLineValues[indexHeta, j] *
                                               bsplinesZeta.BSPLineDerivativeValues[indexZeta, k] *
                                               controlPoints[m].WeightFactor;
                        }
                        for (int m = 0; m < numberOfElementControlPoints; m++)
                        {
                            int indexKsi  = controlPoints[m].ID / (element.Patch.NumberOfControlPointsHeta * element.Patch.NumberOfControlPointsZeta);
                            int indexHeta = controlPoints[m].ID % (element.Patch.NumberOfControlPointsHeta * element.Patch.NumberOfControlPointsZeta) / element.Patch.NumberOfControlPointsZeta;
                            int indexZeta = controlPoints[m].ID % (element.Patch.NumberOfControlPointsHeta * element.Patch.NumberOfControlPointsZeta) % element.Patch.NumberOfControlPointsZeta;

                            NurbsValues[m, i *supportHeta *supportZeta + j * supportZeta + k] =
                                bsplinesKsi.BSPLineValues[indexKsi, i] *
                                bsplinesHeta.BSPLineValues[indexHeta, j] *
                                bsplinesZeta.BSPLineValues[indexZeta, k] *
                                controlPoints[m].WeightFactor / sumKsiHetaZeta;

                            NurbsDerivativeValuesKsi[m, i *supportHeta *supportZeta + j * supportZeta + k] =
                                (bsplinesKsi.BSPLineDerivativeValues[indexKsi, i] * sumKsiHetaZeta -
                                 bsplinesKsi.BSPLineValues[indexKsi, i] * sumdKsiHetaZeta) *
                                bsplinesHeta.BSPLineValues[indexHeta, j] *
                                bsplinesZeta.BSPLineValues[indexZeta, k] *
                                controlPoints[m].WeightFactor / Math.Pow(sumKsiHetaZeta, 2);

                            NurbsDerivativeValuesHeta[m, i *supportHeta *supportZeta + j * supportZeta + k] =
                                bsplinesKsi.BSPLineValues[indexKsi, i] *
                                (bsplinesHeta.BSPLineDerivativeValues[indexHeta, j] * sumKsiHetaZeta -
                                 bsplinesHeta.BSPLineValues[indexHeta, j] * sumKsidHetaZeta) *
                                bsplinesZeta.BSPLineValues[indexZeta, k] *
                                controlPoints[m].WeightFactor / Math.Pow(sumKsiHetaZeta, 2);

                            NurbsDerivativeValuesZeta[m, i *supportHeta *supportZeta + j * supportZeta + k] =
                                bsplinesKsi.BSPLineValues[indexKsi, i] *
                                bsplinesHeta.BSPLineValues[indexHeta, j] *
                                (bsplinesZeta.BSPLineDerivativeValues[indexZeta, k] * sumKsiHetaZeta -
                                 bsplinesZeta.BSPLineValues[indexZeta, k] * sumKsiHetadZeta) *
                                controlPoints[m].WeightFactor / Math.Pow(sumKsiHetaZeta, 2);
                        }
                    }
                }
            }
        }
Esempio n. 8
0
        /// <summary>
        /// Defines 3D NURBS shape functions given per axis gauss points.
        /// </summary>
        /// <param name="element">An <see cref="Element"/> of type <see cref="NurbsElement3D"/>.</param>
        /// <param name="controlPoints">A <see cref="List{T}"/> containing the control points of the element.</param>
        /// <param name="parametricGaussPointKsi">An <see cref="IVector"/> containing Gauss points of axis Ksi.</param>
        /// <param name="parametricGaussPointHeta">An <see cref="IVector"/> containing Gauss points of axis Heta.</param>
        /// <param name="parametricGaussPointZeta">An <see cref="IVector"/> containing Gauss points of axis Zeta.</param>
        public Nurbs3D(Element element, IList <ControlPoint> controlPoints, Vector parametricGaussPointKsi,
                       Vector parametricGaussPointHeta, Vector parametricGaussPointZeta)
        {
            var parametricPointsCount = parametricGaussPointKsi.Length * parametricGaussPointHeta.Length *
                                        parametricGaussPointZeta.Length;

            BSPLines1D bsplinesKsi = new BSPLines1D(element.Patch.DegreeKsi, element.Patch.KnotValueVectorKsi,
                                                    parametricGaussPointKsi);
            BSPLines1D bsplinesHeta = new BSPLines1D(element.Patch.DegreeHeta, element.Patch.KnotValueVectorHeta,
                                                     parametricGaussPointHeta);
            BSPLines1D bsplinesZeta = new BSPLines1D(element.Patch.DegreeZeta, element.Patch.KnotValueVectorZeta,
                                                     parametricGaussPointZeta);

            bsplinesKsi.calculateBSPLinesAndDerivatives();
            bsplinesHeta.calculateBSPLinesAndDerivatives();
            bsplinesZeta.calculateBSPLinesAndDerivatives();

            int supportKsi  = parametricGaussPointKsi.Length;
            int supportHeta = parametricGaussPointHeta.Length;
            int supportZeta = parametricGaussPointZeta.Length;
            int numberOfElementControlPoints = (element.Patch.DegreeKsi + 1) * (element.Patch.DegreeHeta + 1) *
                                               (element.Patch.DegreeZeta + 1);

            NurbsValues = Matrix.CreateZero(numberOfElementControlPoints, parametricPointsCount);
            NurbsDerivativeValuesKsi  = Matrix.CreateZero(numberOfElementControlPoints, parametricPointsCount);
            NurbsDerivativeValuesHeta = Matrix.CreateZero(numberOfElementControlPoints, parametricPointsCount);
            NurbsDerivativeValuesZeta = Matrix.CreateZero(numberOfElementControlPoints, parametricPointsCount);

            for (int i = 0; i < supportKsi; i++)
            {
                for (int j = 0; j < supportHeta; j++)
                {
                    for (int k = 0; k < supportZeta; k++)
                    {
                        double sumKsiHetaZeta  = 0;
                        double sumdKsiHetaZeta = 0;
                        double sumKsidHetaZeta = 0;
                        double sumKsiHetadZeta = 0;

                        for (int m = 0; m < numberOfElementControlPoints; m++)
                        {
                            int indexKsi = controlPoints[m].ID /
                                           (element.Patch.NumberOfControlPointsHeta *
                                            element.Patch.NumberOfControlPointsZeta);
                            int indexHeta = controlPoints[m].ID %
                                            (element.Patch.NumberOfControlPointsHeta *
                                             element.Patch.NumberOfControlPointsZeta) /
                                            element.Patch.NumberOfControlPointsZeta;
                            int indexZeta = controlPoints[m].ID %
                                            (element.Patch.NumberOfControlPointsHeta *
                                             element.Patch.NumberOfControlPointsZeta) %
                                            element.Patch.NumberOfControlPointsZeta;

                            sumKsiHetaZeta += bsplinesKsi.BSPLineValues[indexKsi, i] *
                                              bsplinesHeta.BSPLineValues[indexHeta, j] *
                                              bsplinesZeta.BSPLineValues[indexZeta, k] *
                                              controlPoints[m].WeightFactor;

                            sumdKsiHetaZeta += bsplinesKsi.BSPLineDerivativeValues[indexKsi, i] *
                                               bsplinesHeta.BSPLineValues[indexHeta, j] *
                                               bsplinesZeta.BSPLineValues[indexZeta, k] *
                                               controlPoints[m].WeightFactor;

                            sumKsidHetaZeta += bsplinesKsi.BSPLineValues[indexKsi, i] *
                                               bsplinesHeta.BSPLineDerivativeValues[indexHeta, j] *
                                               bsplinesZeta.BSPLineValues[indexZeta, k] *
                                               controlPoints[m].WeightFactor;

                            sumKsiHetadZeta += bsplinesKsi.BSPLineValues[indexKsi, i] *
                                               bsplinesHeta.BSPLineValues[indexHeta, j] *
                                               bsplinesZeta.BSPLineDerivativeValues[indexZeta, k] *
                                               controlPoints[m].WeightFactor;
                        }

                        for (int m = 0; m < numberOfElementControlPoints; m++)
                        {
                            int indexKsi = controlPoints[m].ID /
                                           (element.Patch.NumberOfControlPointsHeta *
                                            element.Patch.NumberOfControlPointsZeta);
                            int indexHeta = controlPoints[m].ID %
                                            (element.Patch.NumberOfControlPointsHeta *
                                             element.Patch.NumberOfControlPointsZeta) /
                                            element.Patch.NumberOfControlPointsZeta;
                            int indexZeta = controlPoints[m].ID %
                                            (element.Patch.NumberOfControlPointsHeta *
                                             element.Patch.NumberOfControlPointsZeta) %
                                            element.Patch.NumberOfControlPointsZeta;

                            NurbsValues[m, i *supportHeta *supportZeta + j * supportZeta + k] =
                                bsplinesKsi.BSPLineValues[indexKsi, i] *
                                bsplinesHeta.BSPLineValues[indexHeta, j] *
                                bsplinesZeta.BSPLineValues[indexZeta, k] *
                                controlPoints[m].WeightFactor / sumKsiHetaZeta;

                            NurbsDerivativeValuesKsi[m, i *supportHeta *supportZeta + j * supportZeta + k] =
                                (bsplinesKsi.BSPLineDerivativeValues[indexKsi, i] * sumKsiHetaZeta -
                                 bsplinesKsi.BSPLineValues[indexKsi, i] * sumdKsiHetaZeta) *
                                bsplinesHeta.BSPLineValues[indexHeta, j] *
                                bsplinesZeta.BSPLineValues[indexZeta, k] *
                                controlPoints[m].WeightFactor / Math.Pow(sumKsiHetaZeta, 2);

                            NurbsDerivativeValuesHeta[m, i *supportHeta *supportZeta + j * supportZeta + k] =
                                bsplinesKsi.BSPLineValues[indexKsi, i] *
                                (bsplinesHeta.BSPLineDerivativeValues[indexHeta, j] * sumKsiHetaZeta -
                                 bsplinesHeta.BSPLineValues[indexHeta, j] * sumKsidHetaZeta) *
                                bsplinesZeta.BSPLineValues[indexZeta, k] *
                                controlPoints[m].WeightFactor / Math.Pow(sumKsiHetaZeta, 2);

                            NurbsDerivativeValuesZeta[m, i *supportHeta *supportZeta + j * supportZeta + k] =
                                bsplinesKsi.BSPLineValues[indexKsi, i] *
                                bsplinesHeta.BSPLineValues[indexHeta, j] *
                                (bsplinesZeta.BSPLineDerivativeValues[indexZeta, k] * sumKsiHetaZeta -
                                 bsplinesZeta.BSPLineValues[indexZeta, k] * sumKsiHetadZeta) *
                                controlPoints[m].WeightFactor / Math.Pow(sumKsiHetaZeta, 2);
                        }
                    }
                }
            }
        }
Esempio n. 9
0
        /// <summary>
        /// Define 3D NURBS shape function for a collocation point.
        /// </summary>
        /// <param name="numberOfControlPointsKsi">Number of control points along parametric axis Ksi.</param>
        /// <param name="numberOfControlPointsHeta">Number of control points along parametric axis Heta.</param>
        /// <param name="numberOfControlPointsZeta">Number of control points along parametric axis Zeta.</param>
        /// <param name="degreeKsi">Polynomial degree of the parametric axis Ksi.</param>
        /// <param name="degreeHeta">Polynomial degree of the parametric axis Heta.</param>
        /// <param name="degreeZeta">Polynomial degree of the parametric axis Zeta.</param>
        /// <param name="knotValueVectorKsi">Knot value vector of the parametric axis Ksi.</param>
        /// <param name="knotValueVectorHeta">Knot value vector of the parametric axis Heta.</param>
        /// <param name="knotValueVectorZeta">Knot value vector of the parametric axis Zeta.</param>
        /// <param name="controlPoints">A <see cref="List{T}"/> containing the control points of the <see cref="Model"/>.</param>
        /// <param name="collocationPoint">A <see cref="NaturalPoin"/> for which the shape functions will be evaluated.</param>
        public Nurbs3D(int numberOfControlPointsKsi, int numberOfControlPointsHeta, int numberOfControlPointsZeta,
                       int degreeKsi, int degreeHeta, int degreeZeta, Vector knotValueVectorKsi,
                       Vector knotValueVectorHeta, Vector knotValueVectorZeta, ControlPoint[] controlPoints,
                       NaturalPoint collocationPoint)
        {
            BSPLines1D bsplinesKsi =
                new BSPLines1D(degreeKsi, knotValueVectorKsi, Vector.CreateFromArray(new double[] { collocationPoint.Xi }));
            BSPLines1D bsplinesHeta = new BSPLines1D(degreeHeta, knotValueVectorHeta,
                                                     Vector.CreateFromArray(new double[] { collocationPoint.Eta }));
            BSPLines1D bsplinesZeta = new BSPLines1D(degreeZeta, knotValueVectorZeta,
                                                     Vector.CreateFromArray(new double[] { collocationPoint.Zeta }));

            bsplinesKsi.calculateBSPLinesAndDerivatives();
            bsplinesHeta.calculateBSPLinesAndDerivatives();
            bsplinesZeta.calculateBSPLinesAndDerivatives();

            int supportKsi     = degreeKsi + 1;
            int supportHeta    = degreeHeta + 1;
            int supportZeta    = degreeZeta + 1;
            int numberOfGPKsi  = 1;
            int numberOfGPHeta = 1;
            int numberOfGPZeta = 1;
            int numberOfElementControlPoints = supportKsi * supportHeta * supportZeta;

            NurbsValues = Matrix.CreateZero(numberOfElementControlPoints, 1);
            NurbsDerivativeValuesKsi           = Matrix.CreateZero(numberOfElementControlPoints, 1);
            NurbsDerivativeValuesHeta          = Matrix.CreateZero(numberOfElementControlPoints, 1);
            NurbsDerivativeValuesZeta          = Matrix.CreateZero(numberOfElementControlPoints, 1);
            NurbsSecondDerivativeValueKsi      = Matrix.CreateZero(numberOfElementControlPoints, 1);
            NurbsSecondDerivativeValueHeta     = Matrix.CreateZero(numberOfElementControlPoints, 1);
            NurbsSecondDerivativeValueZeta     = Matrix.CreateZero(numberOfElementControlPoints, 1);
            NurbsSecondDerivativeValueKsiHeta  = Matrix.CreateZero(numberOfElementControlPoints, 1);
            NurbsSecondDerivativeValueKsiZeta  = Matrix.CreateZero(numberOfElementControlPoints, 1);
            NurbsSecondDerivativeValueHetaZeta = Matrix.CreateZero(numberOfElementControlPoints, 1);

            for (int i = 0; i < numberOfGPKsi; i++)
            {
                for (int j = 0; j < numberOfGPHeta; j++)
                {
                    for (int k = 0; k < numberOfGPZeta; k++)
                    {
                        double sumKsiHetaZeta  = 0;
                        double sumdKsiHetaZeta = 0;
                        double sumKsidHetaZeta = 0;
                        double sumKsiHetadZeta = 0;

                        double sumdKsidKsi   = 0;
                        double sumdHetadHeta = 0;
                        double sumdZetadZeta = 0;
                        double sumdKsidHeta  = 0;
                        double sumdKsidZeta  = 0;
                        double sumdHetadZeta = 0;

                        for (int m = 0; m < numberOfElementControlPoints; m++)
                        {
                            int indexKsi = controlPoints[m].ID /
                                           (numberOfControlPointsHeta *
                                            numberOfControlPointsZeta);
                            int indexHeta = controlPoints[m].ID %
                                            (numberOfControlPointsHeta *
                                             numberOfControlPointsZeta) /
                                            numberOfControlPointsZeta;
                            int indexZeta = controlPoints[m].ID %
                                            (numberOfControlPointsHeta *
                                             numberOfControlPointsZeta) %
                                            numberOfControlPointsZeta;

                            sumKsiHetaZeta += bsplinesKsi.BSPLineValues[indexKsi, i] *
                                              bsplinesHeta.BSPLineValues[indexHeta, j] *
                                              bsplinesZeta.BSPLineValues[indexZeta, k] *
                                              controlPoints[m].WeightFactor;

                            sumdKsiHetaZeta += bsplinesKsi.BSPLineDerivativeValues[indexKsi, i] *
                                               bsplinesHeta.BSPLineValues[indexHeta, j] *
                                               bsplinesZeta.BSPLineValues[indexZeta, k] *
                                               controlPoints[m].WeightFactor;

                            sumKsidHetaZeta += bsplinesKsi.BSPLineValues[indexKsi, i] *
                                               bsplinesHeta.BSPLineDerivativeValues[indexHeta, j] *
                                               bsplinesZeta.BSPLineValues[indexZeta, k] *
                                               controlPoints[m].WeightFactor;

                            sumKsiHetadZeta += bsplinesKsi.BSPLineValues[indexKsi, i] *
                                               bsplinesHeta.BSPLineValues[indexHeta, j] *
                                               bsplinesZeta.BSPLineDerivativeValues[indexZeta, k] *
                                               controlPoints[m].WeightFactor;

                            sumdKsidKsi += bsplinesKsi.BSPLineSecondDerivativeValues[indexKsi, i] *
                                           bsplinesHeta.BSPLineValues[indexHeta, j] *
                                           bsplinesZeta.BSPLineValues[indexZeta, k] *
                                           controlPoints[m].WeightFactor;

                            sumdHetadHeta += bsplinesKsi.BSPLineValues[indexKsi, i] *
                                             bsplinesHeta.BSPLineSecondDerivativeValues[indexHeta, j] *
                                             bsplinesZeta.BSPLineValues[indexZeta, k] *
                                             controlPoints[m].WeightFactor;

                            sumdZetadZeta += bsplinesKsi.BSPLineValues[indexKsi, i] *
                                             bsplinesHeta.BSPLineValues[indexHeta, j] *
                                             bsplinesZeta.BSPLineSecondDerivativeValues[indexZeta, k] *
                                             controlPoints[m].WeightFactor;

                            sumdKsidHeta += bsplinesKsi.BSPLineDerivativeValues[indexKsi, i] *
                                            bsplinesHeta.BSPLineDerivativeValues[indexHeta, j] *
                                            bsplinesZeta.BSPLineValues[indexZeta, k] *
                                            controlPoints[m].WeightFactor;

                            sumdKsidZeta += bsplinesKsi.BSPLineDerivativeValues[indexKsi, i] *
                                            bsplinesHeta.BSPLineValues[indexHeta, j] *
                                            bsplinesZeta.BSPLineDerivativeValues[indexZeta, k] *
                                            controlPoints[m].WeightFactor;

                            sumdHetadZeta += bsplinesKsi.BSPLineValues[indexKsi, i] *
                                             bsplinesHeta.BSPLineDerivativeValues[indexHeta, j] *
                                             bsplinesZeta.BSPLineDerivativeValues[indexZeta, k] *
                                             controlPoints[m].WeightFactor;
                        }

                        for (int m = 0; m < numberOfElementControlPoints; m++)
                        {
                            int indexKsi = controlPoints[m].ID /
                                           (numberOfControlPointsHeta *
                                            numberOfControlPointsZeta);
                            int indexHeta = controlPoints[m].ID %
                                            (numberOfControlPointsHeta *
                                             numberOfControlPointsZeta) /
                                            numberOfControlPointsZeta;
                            int indexZeta = controlPoints[m].ID %
                                            (numberOfControlPointsHeta *
                                             numberOfControlPointsZeta) %
                                            numberOfControlPointsZeta;

                            NurbsValues[m, i *supportHeta *supportZeta + j * supportZeta + k] =
                                bsplinesKsi.BSPLineValues[indexKsi, i] *
                                bsplinesHeta.BSPLineValues[indexHeta, j] *
                                bsplinesZeta.BSPLineValues[indexZeta, k] *
                                controlPoints[m].WeightFactor / sumKsiHetaZeta;

                            NurbsDerivativeValuesKsi[m, i *supportHeta *supportZeta + j * supportZeta + k] =
                                (bsplinesKsi.BSPLineDerivativeValues[indexKsi, i] * sumKsiHetaZeta -
                                 bsplinesKsi.BSPLineValues[indexKsi, i] * sumdKsiHetaZeta) *
                                bsplinesHeta.BSPLineValues[indexHeta, j] *
                                bsplinesZeta.BSPLineValues[indexZeta, k] *
                                controlPoints[m].WeightFactor / Math.Pow(sumKsiHetaZeta, 2);

                            NurbsDerivativeValuesHeta[m, i *supportHeta *supportZeta + j * supportZeta + k] =
                                bsplinesKsi.BSPLineValues[indexKsi, i] *
                                (bsplinesHeta.BSPLineDerivativeValues[indexHeta, j] * sumKsiHetaZeta -
                                 bsplinesHeta.BSPLineValues[indexHeta, j] * sumKsidHetaZeta) *
                                bsplinesZeta.BSPLineValues[indexZeta, k] *
                                controlPoints[m].WeightFactor / Math.Pow(sumKsiHetaZeta, 2);

                            NurbsDerivativeValuesZeta[m, i *supportHeta *supportZeta + j * supportZeta + k] =
                                bsplinesKsi.BSPLineValues[indexKsi, i] *
                                bsplinesHeta.BSPLineValues[indexHeta, j] *
                                (bsplinesZeta.BSPLineDerivativeValues[indexZeta, k] * sumKsiHetaZeta -
                                 bsplinesZeta.BSPLineValues[indexZeta, k] * sumKsiHetadZeta) *
                                controlPoints[m].WeightFactor / Math.Pow(sumKsiHetaZeta, 2);

                            NurbsSecondDerivativeValueKsi[m, i *supportHeta *supportZeta + j * supportZeta + k] =
                                (bsplinesKsi.BSPLineSecondDerivativeValues[indexKsi, i] / sumKsiHetaZeta -
                                 2 * bsplinesKsi.BSPLineDerivativeValues[indexKsi, i] * sumdKsiHetaZeta /
                                 Math.Pow(sumKsiHetaZeta, 2) -
                                 bsplinesKsi.BSPLineValues[indexKsi, i] * sumdKsidKsi / Math.Pow(sumKsiHetaZeta, 2) +
                                 2 * bsplinesKsi.BSPLineValues[indexKsi, i] * Math.Pow(sumdKsiHetaZeta, 2) /
                                 Math.Pow(sumKsiHetaZeta, 3)) *
                                bsplinesHeta.BSPLineValues[indexHeta, j] *
                                bsplinesZeta.BSPLineValues[indexZeta, k] *
                                controlPoints[m].WeightFactor;

                            NurbsSecondDerivativeValueHeta[m, i *supportHeta *supportZeta + j * supportZeta + k] =
                                bsplinesKsi.BSPLineValues[indexKsi, i] *
                                (bsplinesHeta.BSPLineSecondDerivativeValues[indexHeta, j] / sumKsiHetaZeta -
                                 2 * bsplinesHeta.BSPLineDerivativeValues[indexHeta, j] * sumKsidHetaZeta / Math.Pow(sumKsiHetaZeta, 2) -
                                 bsplinesHeta.BSPLineValues[indexHeta, j] * sumdHetadHeta / Math.Pow(sumKsiHetaZeta, 2) +
                                 2 * bsplinesHeta.BSPLineValues[indexHeta, j] * Math.Pow(sumKsidHetaZeta, 2) / Math.Pow(sumKsiHetaZeta, 3)) *
                                bsplinesZeta.BSPLineValues[indexZeta, k] *
                                controlPoints[m].WeightFactor;

                            NurbsSecondDerivativeValueZeta[m, i *supportHeta *supportZeta + j * supportZeta + k] =
                                bsplinesKsi.BSPLineValues[indexKsi, i] *
                                bsplinesHeta.BSPLineValues[indexHeta, j] *
                                (bsplinesZeta.BSPLineSecondDerivativeValues[indexZeta, k] / sumKsiHetaZeta -
                                 2 * bsplinesZeta.BSPLineDerivativeValues[indexZeta, k] * sumKsiHetadZeta /
                                 Math.Pow(sumKsiHetaZeta, 2) -
                                 bsplinesZeta.BSPLineValues[indexZeta, k] * sumdZetadZeta /
                                 Math.Pow(sumKsiHetaZeta, 2) +
                                 2 * bsplinesZeta.BSPLineValues[indexZeta, k] * Math.Pow(sumKsiHetadZeta, 2) /
                                 Math.Pow(sumKsiHetaZeta, 3)) *
                                controlPoints[m].WeightFactor;

                            NurbsSecondDerivativeValueKsiHeta[m, i *supportHeta *supportZeta + j * supportZeta + k] =
                                (bsplinesKsi.BSPLineDerivativeValues[indexKsi, i] *
                                 bsplinesHeta.BSPLineDerivativeValues[indexHeta, j] / sumKsiHetaZeta -
                                 bsplinesKsi.BSPLineDerivativeValues[indexKsi, i] *
                                 bsplinesHeta.BSPLineValues[indexHeta, j] *
                                 sumKsidHetaZeta / Math.Pow(sumKsiHetaZeta, 2) -
                                 bsplinesKsi.BSPLineValues[indexKsi, i] *
                                 bsplinesHeta.BSPLineDerivativeValues[indexHeta, j] *
                                 sumdKsiHetaZeta / Math.Pow(sumKsiHetaZeta, 2) -
                                 bsplinesKsi.BSPLineValues[indexKsi, i] * bsplinesHeta.BSPLineValues[indexHeta, j] *
                                 sumdKsidHeta / Math.Pow(sumKsiHetaZeta, 2) +
                                 2 * bsplinesKsi.BSPLineValues[indexKsi, i] * bsplinesHeta.BSPLineValues[indexHeta, j] *
                                 sumdKsiHetaZeta * sumKsidHetaZeta / Math.Pow(sumKsiHetaZeta, 3)) *
                                bsplinesZeta.BSPLineValues[indexZeta, k] *
                                controlPoints[m].WeightFactor;

                            NurbsSecondDerivativeValueKsiZeta[m, i *supportHeta *supportZeta + j * supportZeta + k] =
                                (bsplinesKsi.BSPLineDerivativeValues[indexKsi, i] *
                                 bsplinesZeta.BSPLineDerivativeValues[indexZeta, k] / sumKsiHetaZeta -
                                 bsplinesKsi.BSPLineDerivativeValues[indexKsi, i] *
                                 bsplinesZeta.BSPLineValues[indexZeta, k] *
                                 sumKsiHetadZeta / Math.Pow(sumKsiHetaZeta, 2) -
                                 bsplinesKsi.BSPLineValues[indexKsi, i] *
                                 bsplinesZeta.BSPLineDerivativeValues[indexZeta, k] *
                                 sumdKsiHetaZeta / Math.Pow(sumKsiHetaZeta, 2) -
                                 bsplinesKsi.BSPLineValues[indexKsi, i] * bsplinesZeta.BSPLineValues[indexZeta, k] *
                                 sumdKsidZeta / Math.Pow(sumKsiHetaZeta, 2) +
                                 2 * bsplinesKsi.BSPLineValues[indexKsi, i] * bsplinesZeta.BSPLineValues[indexZeta, k] *
                                 sumdKsiHetaZeta * sumKsiHetadZeta / Math.Pow(sumKsiHetaZeta, 3)) *
                                bsplinesHeta.BSPLineValues[indexHeta, j] *
                                controlPoints[m].WeightFactor;

                            NurbsSecondDerivativeValueHetaZeta[m, i *supportHeta *supportZeta + j * supportZeta + k] =
                                bsplinesKsi.BSPLineValues[indexKsi, i] *
                                (bsplinesHeta.BSPLineDerivativeValues[indexHeta, j] *
                                 bsplinesZeta.BSPLineDerivativeValues[indexZeta, k] / sumKsiHetaZeta -
                                 bsplinesHeta.BSPLineDerivativeValues[indexHeta, j] *
                                 bsplinesZeta.BSPLineValues[indexZeta, k] *
                                 sumKsiHetadZeta / Math.Pow(sumKsiHetaZeta, 2) -
                                 bsplinesHeta.BSPLineValues[indexHeta, j] *
                                 bsplinesZeta.BSPLineDerivativeValues[indexZeta, k] *
                                 sumKsidHetaZeta / Math.Pow(sumKsiHetaZeta, 2) -
                                 bsplinesHeta.BSPLineValues[indexHeta, j] * bsplinesZeta.BSPLineValues[indexZeta, k] *
                                 sumdHetadZeta / Math.Pow(sumKsiHetaZeta, 2) +
                                 2 * bsplinesHeta.BSPLineValues[indexHeta, j] *
                                 bsplinesZeta.BSPLineValues[indexZeta, k] *
                                 sumKsidHetaZeta * sumKsiHetadZeta / Math.Pow(sumKsiHetaZeta, 3)) *
                                controlPoints[m].WeightFactor;
                        }
                    }
                }
            }
        }
Esempio n. 10
0
        /// <summary>
        /// Define 3D  NURBS shape function without needing an element definition.
        /// </summary>
        /// <param name="numberOfControlPointsKsi">Number of control points along parametric axis Ksi.</param>
        /// <param name="numberOfControlPointsHeta">Number of control points along parametric axis Heta.</param>
        /// <param name="numberOfControlPointsZeta">Number of control points along parametric axis Zeta.</param>
        /// <param name="degreeKsi">Polynomial degree of the parametric axis Ksi.</param>
        /// <param name="degreeHeta">Polynomial degree of the parametric axis Heta.</param>
        /// <param name="degreeZeta">Polynomial degree of the parametric axis Zeta.</param>
        /// <param name="knotValueVectorKsi">Knot value vector of the parametric axis Ksi.</param>
        /// <param name="knotValueVectorHeta">Knot value vector of the parametric axis Heta.</param>
        /// <param name="knotValueVectorZeta">Knot value vector of the parametric axis Zeta.</param>
        /// <param name="controlPoints">A <see cref="List{T}"/> containing the control points of the element.</param>
        /// <param name="gaussPoints">A <see cref="List{T}"/> containing the control points where the shape functions will be evaluated.</param>
        public Nurbs3D(int numberOfControlPointsKsi, int numberOfControlPointsHeta, int numberOfControlPointsZeta,
                       int degreeKsi, int degreeHeta, int degreeZeta, Vector knotValueVectorKsi,
                       Vector knotValueVectorHeta, Vector knotValueVectorZeta, ControlPoint[] controlPoints,
                       GaussLegendrePoint3D[] gaussPoints)
        {
            var numberOfGaussPoints     = gaussPoints.Length;
            var parametricGaussPointKsi = Vector.CreateZero(degreeKsi + 1);

            for (int i = 0; i < degreeKsi + 1; i++)
            {
                parametricGaussPointKsi[i] = gaussPoints[i * (degreeZeta + 1) * (degreeHeta + 1)].Ksi;
            }

            var parametricGaussPointHeta = Vector.CreateZero(degreeHeta + 1);

            for (int i = 0; i < degreeHeta + 1; i++)
            {
                parametricGaussPointHeta[i] = gaussPoints[i * (degreeZeta + 1)].Heta;
            }

            var parametricGaussPointZeta = Vector.CreateZero(degreeZeta + 1);

            for (int i = 0; i < degreeZeta + 1; i++)
            {
                parametricGaussPointZeta[i] = gaussPoints[i].Zeta;
            }

            BSPLines1D bsplinesKsi =
                new BSPLines1D(degreeKsi, knotValueVectorKsi, parametricGaussPointKsi);
            BSPLines1D bsplinesHeta = new BSPLines1D(degreeHeta, knotValueVectorHeta,
                                                     parametricGaussPointHeta);
            BSPLines1D bsplinesZeta = new BSPLines1D(degreeZeta, knotValueVectorZeta,
                                                     parametricGaussPointZeta);

            bsplinesKsi.calculateBSPLinesAndDerivatives();
            bsplinesHeta.calculateBSPLinesAndDerivatives();
            bsplinesZeta.calculateBSPLinesAndDerivatives();

            int supportKsi  = degreeKsi + 1;
            int supportHeta = degreeHeta + 1;
            int supportZeta = degreeZeta + 1;
            int numberOfElementControlPoints = supportKsi * supportHeta * supportZeta;

            NurbsValues = Matrix.CreateZero(numberOfElementControlPoints, numberOfGaussPoints);
            NurbsDerivativeValuesKsi  = Matrix.CreateZero(numberOfElementControlPoints, numberOfGaussPoints);
            NurbsDerivativeValuesHeta = Matrix.CreateZero(numberOfElementControlPoints, numberOfGaussPoints);
            NurbsDerivativeValuesZeta = Matrix.CreateZero(numberOfElementControlPoints, numberOfGaussPoints);

            for (int i = 0; i < supportKsi; i++)
            {
                for (int j = 0; j < supportHeta; j++)
                {
                    for (int k = 0; k < supportZeta; k++)
                    {
                        double sumKsiHetaZeta  = 0;
                        double sumdKsiHetaZeta = 0;
                        double sumKsidHetaZeta = 0;
                        double sumKsiHetadZeta = 0;

                        for (int m = 0; m < numberOfElementControlPoints; m++)
                        {
                            int indexKsi = controlPoints[m].ID /
                                           (numberOfControlPointsHeta *
                                            numberOfControlPointsZeta);
                            int indexHeta = controlPoints[m].ID %
                                            (numberOfControlPointsHeta *
                                             numberOfControlPointsZeta) /
                                            numberOfControlPointsZeta;
                            int indexZeta = controlPoints[m].ID %
                                            (numberOfControlPointsHeta *
                                             numberOfControlPointsZeta) %
                                            numberOfControlPointsZeta;

                            sumKsiHetaZeta += bsplinesKsi.BSPLineValues[indexKsi, i] *
                                              bsplinesHeta.BSPLineValues[indexHeta, j] *
                                              bsplinesZeta.BSPLineValues[indexZeta, k] *
                                              controlPoints[m].WeightFactor;

                            sumdKsiHetaZeta += bsplinesKsi.BSPLineDerivativeValues[indexKsi, i] *
                                               bsplinesHeta.BSPLineValues[indexHeta, j] *
                                               bsplinesZeta.BSPLineValues[indexZeta, k] *
                                               controlPoints[m].WeightFactor;

                            sumKsidHetaZeta += bsplinesKsi.BSPLineValues[indexKsi, i] *
                                               bsplinesHeta.BSPLineDerivativeValues[indexHeta, j] *
                                               bsplinesZeta.BSPLineValues[indexZeta, k] *
                                               controlPoints[m].WeightFactor;

                            sumKsiHetadZeta += bsplinesKsi.BSPLineValues[indexKsi, i] *
                                               bsplinesHeta.BSPLineValues[indexHeta, j] *
                                               bsplinesZeta.BSPLineDerivativeValues[indexZeta, k] *
                                               controlPoints[m].WeightFactor;
                        }

                        for (int m = 0; m < numberOfElementControlPoints; m++)
                        {
                            int indexKsi = controlPoints[m].ID /
                                           (numberOfControlPointsHeta *
                                            numberOfControlPointsZeta);
                            int indexHeta = controlPoints[m].ID %
                                            (numberOfControlPointsHeta *
                                             numberOfControlPointsZeta) /
                                            numberOfControlPointsZeta;
                            int indexZeta = controlPoints[m].ID %
                                            (numberOfControlPointsHeta *
                                             numberOfControlPointsZeta) %
                                            numberOfControlPointsZeta;

                            NurbsValues[m, i *supportHeta *supportZeta + j * supportZeta + k] =
                                bsplinesKsi.BSPLineValues[indexKsi, i] *
                                bsplinesHeta.BSPLineValues[indexHeta, j] *
                                bsplinesZeta.BSPLineValues[indexZeta, k] *
                                controlPoints[m].WeightFactor / sumKsiHetaZeta;

                            NurbsDerivativeValuesKsi[m, i *supportHeta *supportZeta + j * supportZeta + k] =
                                (bsplinesKsi.BSPLineDerivativeValues[indexKsi, i] * sumKsiHetaZeta -
                                 bsplinesKsi.BSPLineValues[indexKsi, i] * sumdKsiHetaZeta) *
                                bsplinesHeta.BSPLineValues[indexHeta, j] *
                                bsplinesZeta.BSPLineValues[indexZeta, k] *
                                controlPoints[m].WeightFactor / Math.Pow(sumKsiHetaZeta, 2);

                            NurbsDerivativeValuesHeta[m, i *supportHeta *supportZeta + j * supportZeta + k] =
                                bsplinesKsi.BSPLineValues[indexKsi, i] *
                                (bsplinesHeta.BSPLineDerivativeValues[indexHeta, j] * sumKsiHetaZeta -
                                 bsplinesHeta.BSPLineValues[indexHeta, j] * sumKsidHetaZeta) *
                                bsplinesZeta.BSPLineValues[indexZeta, k] *
                                controlPoints[m].WeightFactor / Math.Pow(sumKsiHetaZeta, 2);

                            NurbsDerivativeValuesZeta[m, i *supportHeta *supportZeta + j * supportZeta + k] =
                                bsplinesKsi.BSPLineValues[indexKsi, i] *
                                bsplinesHeta.BSPLineValues[indexHeta, j] *
                                (bsplinesZeta.BSPLineDerivativeValues[indexZeta, k] * sumKsiHetaZeta -
                                 bsplinesZeta.BSPLineValues[indexZeta, k] * sumKsiHetadZeta) *
                                controlPoints[m].WeightFactor / Math.Pow(sumKsiHetaZeta, 2);
                        }
                    }
                }
            }
        }
Esempio n. 11
0
        /// <summary>
        /// Defines n 2D NURBS shape function for a face element.
        /// </summary>
        /// <param name="element">An <see cref="Element"/> of type <see cref="NurbsElement2D"/>.</param>
        /// <param name="controlPoints">A <see cref="List{T}"/> containing the control points of the element.</param>
        /// <param name="face">The two-dimensional boundary entities where the <paramref name="element"/> shape functions will be evaluated.</param>
        public Nurbs2D(Element element, ControlPoint[] controlPoints, Face face)
        {
            var degreeKsi                 = face.Degrees[0];
            var degreeHeta                = face.Degrees[1];
            var knotValueVectorKsi        = face.KnotValueVectors[0];
            var knotValueVectorHeta       = face.KnotValueVectors[1];
            var numberOfControlPointsHeta = knotValueVectorHeta.Length - degreeHeta - 1;

            GaussQuadrature gauss = new GaussQuadrature();
            IList <GaussLegendrePoint3D> gaussPoints =
                gauss.CalculateElementGaussPoints(degreeKsi, degreeHeta, element.Knots.ToArray());

            var parametricGaussPointKsi = Vector.CreateZero(degreeKsi + 1);

            for (int i = 0; i < degreeKsi + 1; i++)
            {
                parametricGaussPointKsi[i] = gaussPoints[i * (degreeHeta + 1)].Ksi;
            }

            var parametricGaussPointHeta = Vector.CreateZero(degreeHeta + 1);

            for (int i = 0; i < degreeHeta + 1; i++)
            {
                parametricGaussPointHeta[i] = gaussPoints[i].Heta;
            }

            BSPLines1D bsplinesKsi  = new BSPLines1D(degreeKsi, knotValueVectorKsi, parametricGaussPointKsi);
            BSPLines1D bsplinesHeta = new BSPLines1D(degreeHeta, knotValueVectorHeta, parametricGaussPointHeta);

            bsplinesKsi.calculateBSPLinesAndDerivatives();
            bsplinesHeta.calculateBSPLinesAndDerivatives();

            int supportKsi  = degreeKsi + 1;
            int supportHeta = degreeHeta + 1;
            int numberOfElementControlPoints = supportKsi * supportHeta;

            NurbsValues = Matrix.CreateZero(numberOfElementControlPoints, gaussPoints.Count);
            NurbsDerivativeValuesKsi          = Matrix.CreateZero(numberOfElementControlPoints, gaussPoints.Count);
            NurbsDerivativeValuesHeta         = Matrix.CreateZero(numberOfElementControlPoints, gaussPoints.Count);
            NurbsSecondDerivativeValueKsi     = Matrix.CreateZero(numberOfElementControlPoints, gaussPoints.Count);
            NurbsSecondDerivativeValueHeta    = Matrix.CreateZero(numberOfElementControlPoints, gaussPoints.Count);
            NurbsSecondDerivativeValueKsiHeta = Matrix.CreateZero(numberOfElementControlPoints, gaussPoints.Count);

            for (int i = 0; i < supportKsi; i++)
            {
                for (int j = 0; j < supportHeta; j++)
                {
                    double sumKsiHeta    = 0;
                    double sumdKsiHeta   = 0;
                    double sumKsidHeta   = 0;
                    double sumdKsidKsi   = 0;
                    double sumdHetadHeta = 0;
                    double sumdKsidHeta  = 0;

                    for (int k = 0; k < numberOfElementControlPoints; k++)
                    {
                        int indexKsi =
                            face.ControlPointsDictionary.First(cp => cp.Value.ID == controlPoints[k].ID).Key /
                            numberOfControlPointsHeta;
                        int indexHeta =
                            face.ControlPointsDictionary.First(cp => cp.Value.ID == controlPoints[k].ID).Key %
                            numberOfControlPointsHeta;
                        sumKsiHeta += bsplinesKsi.BSPLineValues[indexKsi, i] *
                                      bsplinesHeta.BSPLineValues[indexHeta, j] *
                                      controlPoints[k].WeightFactor;
                        sumdKsiHeta += bsplinesKsi.BSPLineDerivativeValues[indexKsi, i] *
                                       bsplinesHeta.BSPLineValues[indexHeta, j] *
                                       controlPoints[k].WeightFactor;
                        sumKsidHeta += bsplinesKsi.BSPLineValues[indexKsi, i] *
                                       bsplinesHeta.BSPLineDerivativeValues[indexHeta, j] *
                                       controlPoints[k].WeightFactor;
                        sumdKsidKsi += bsplinesKsi.BSPLineSecondDerivativeValues[indexKsi, i] *
                                       bsplinesHeta.BSPLineValues[indexHeta, j] *
                                       controlPoints[k].WeightFactor;
                        sumdHetadHeta += bsplinesKsi.BSPLineValues[indexKsi, i] *
                                         bsplinesHeta.BSPLineSecondDerivativeValues[indexHeta, j] *
                                         controlPoints[k].WeightFactor;
                        sumdKsidHeta += bsplinesKsi.BSPLineDerivativeValues[indexKsi, i] *
                                        bsplinesHeta.BSPLineDerivativeValues[indexHeta, j] *
                                        controlPoints[k].WeightFactor;
                    }

                    for (int k = 0; k < numberOfElementControlPoints; k++)
                    {
                        int indexKsi =
                            face.ControlPointsDictionary.First(cp => cp.Value.ID == controlPoints[k].ID).Key /
                            numberOfControlPointsHeta;
                        int indexHeta =
                            face.ControlPointsDictionary.First(cp => cp.Value.ID == controlPoints[k].ID).Key %
                            numberOfControlPointsHeta;

                        NurbsValues[k, i *supportHeta + j] =
                            bsplinesKsi.BSPLineValues[indexKsi, i] *
                            bsplinesHeta.BSPLineValues[indexHeta, j] *
                            controlPoints[k].WeightFactor / sumKsiHeta;

                        NurbsDerivativeValuesKsi[k, i *supportHeta + j] =
                            bsplinesHeta.BSPLineValues[indexHeta, j] * controlPoints[k].WeightFactor *
                            (bsplinesKsi.BSPLineDerivativeValues[indexKsi, i] * sumKsiHeta -
                             bsplinesKsi.BSPLineValues[indexKsi, i] * sumdKsiHeta) / Math.Pow(sumKsiHeta, 2);

                        NurbsDerivativeValuesHeta[k, i *supportHeta + j] =
                            bsplinesKsi.BSPLineValues[indexKsi, i] * controlPoints[k].WeightFactor *
                            (bsplinesHeta.BSPLineDerivativeValues[indexHeta, j] * sumKsiHeta -
                             bsplinesHeta.BSPLineValues[indexHeta, j] * sumKsidHeta) / Math.Pow(sumKsiHeta, 2);

                        NurbsSecondDerivativeValueKsi[k, i *supportHeta + j] =
                            bsplinesHeta.BSPLineValues[indexHeta, j] * controlPoints[k].WeightFactor *
                            (bsplinesKsi.BSPLineSecondDerivativeValues[indexKsi, i] / sumKsiHeta -
                             2 * bsplinesKsi.BSPLineDerivativeValues[indexKsi, i] * sumdKsiHeta /
                             Math.Pow(sumKsiHeta, 2) -
                             bsplinesKsi.BSPLineValues[indexKsi, i] * sumdKsidKsi / Math.Pow(sumKsiHeta, 2) +
                             2 * bsplinesKsi.BSPLineValues[indexKsi, i] * Math.Pow(sumdKsiHeta, 2) /
                             Math.Pow(sumKsiHeta, 3));

                        NurbsSecondDerivativeValueHeta[k, i *supportHeta + j] =
                            bsplinesKsi.BSPLineValues[indexKsi, i] * controlPoints[k].WeightFactor *
                            (bsplinesHeta.BSPLineSecondDerivativeValues[indexHeta, j] / sumKsiHeta -
                             2 * bsplinesHeta.BSPLineDerivativeValues[indexHeta, j] * sumKsidHeta /
                             Math.Pow(sumKsiHeta, 2) -
                             bsplinesHeta.BSPLineValues[indexHeta, j] * sumdHetadHeta / Math.Pow(sumKsiHeta, 2) +
                             2 * bsplinesHeta.BSPLineValues[indexHeta, j] * Math.Pow(sumKsidHeta, 2) /
                             Math.Pow(sumKsiHeta, 3));

                        NurbsSecondDerivativeValueKsiHeta[k, i *supportHeta + j] =
                            controlPoints[k].WeightFactor *
                            (bsplinesKsi.BSPLineDerivativeValues[indexKsi, i] *
                             bsplinesHeta.BSPLineDerivativeValues[indexHeta, j] / sumKsiHeta -
                             bsplinesKsi.BSPLineDerivativeValues[indexKsi, i] *
                             bsplinesHeta.BSPLineValues[indexHeta, j] *
                             sumKsidHeta / Math.Pow(sumKsiHeta, 2) -
                             bsplinesKsi.BSPLineValues[indexKsi, i] *
                             bsplinesHeta.BSPLineDerivativeValues[indexHeta, j] *
                             sumdKsiHeta / Math.Pow(sumKsiHeta, 2) -
                             bsplinesKsi.BSPLineValues[indexKsi, i] * bsplinesHeta.BSPLineValues[indexHeta, j] *
                             sumdKsidHeta / Math.Pow(sumKsiHeta, 2) +
                             2 * bsplinesKsi.BSPLineValues[indexKsi, i] * bsplinesHeta.BSPLineValues[indexHeta, j] *
                             sumdKsiHeta * sumKsidHeta / Math.Pow(sumKsiHeta, 3));
                    }
                }
            }
        }
Esempio n. 12
0
        /// <summary>
        /// Defines a 2D NURBS shape function for an element given the per axis gauss point coordinates.
        /// </summary>
        /// <param name="element">An <see cref="Element"/> of type <see cref="NurbsElement2D"/>.</param>
        /// <param name="controlPoints">A <see cref="List{T}"/> containing the control points of the element.</param>
        /// <param name="parametricGaussPointKsi">An <see cref="IVector"/> containing Gauss points of axis Ksi.</param>
        /// <param name="parametricGaussPointHeta">An <see cref="IVector"/> containing Gauss points of axis Heta.</param>
        public Nurbs2D(Element element, ControlPoint[] controlPoints, IVector parametricGaussPointKsi,
                       IVector parametricGaussPointHeta)
        {
            var parametricPointsCount = parametricGaussPointKsi.Length * parametricGaussPointHeta.Length;

            BSPLines1D bsplinesKsi = new BSPLines1D(element.Patch.DegreeKsi, element.Patch.KnotValueVectorKsi,
                                                    parametricGaussPointKsi);
            BSPLines1D bsplinesHeta = new BSPLines1D(element.Patch.DegreeHeta, element.Patch.KnotValueVectorHeta,
                                                     parametricGaussPointHeta);

            bsplinesKsi.calculateBSPLinesAndDerivatives();
            bsplinesHeta.calculateBSPLinesAndDerivatives();

            int supportKsi  = parametricGaussPointKsi.Length;
            int supportHeta = parametricGaussPointHeta.Length;
            int numberOfElementControlPoints = (element.Patch.DegreeKsi + 1) * (element.Patch.DegreeHeta + 1);

            NurbsValues = Matrix.CreateZero(numberOfElementControlPoints, parametricPointsCount);
            NurbsDerivativeValuesKsi          = Matrix.CreateZero(numberOfElementControlPoints, parametricPointsCount);
            NurbsDerivativeValuesHeta         = Matrix.CreateZero(numberOfElementControlPoints, parametricPointsCount);
            NurbsSecondDerivativeValueKsi     = Matrix.CreateZero(numberOfElementControlPoints, parametricPointsCount);
            NurbsSecondDerivativeValueHeta    = Matrix.CreateZero(numberOfElementControlPoints, parametricPointsCount);
            NurbsSecondDerivativeValueKsiHeta = Matrix.CreateZero(numberOfElementControlPoints, parametricPointsCount);

            for (int i = 0; i < supportKsi; i++)
            {
                for (int j = 0; j < supportHeta; j++)
                {
                    double sumKsiHeta    = 0;
                    double sumdKsiHeta   = 0;
                    double sumKsidHeta   = 0;
                    double sumdKsidKsi   = 0;
                    double sumdHetadHeta = 0;
                    double sumdKsidHeta  = 0;

                    for (int k = 0; k < numberOfElementControlPoints; k++)
                    {
                        int indexKsi  = controlPoints[k].ID / element.Patch.NumberOfControlPointsHeta;
                        int indexHeta = controlPoints[k].ID % element.Patch.NumberOfControlPointsHeta;
                        sumKsiHeta += bsplinesKsi.BSPLineValues[indexKsi, i] *
                                      bsplinesHeta.BSPLineValues[indexHeta, j] *
                                      controlPoints[k].WeightFactor;
                        sumdKsiHeta += bsplinesKsi.BSPLineDerivativeValues[indexKsi, i] *
                                       bsplinesHeta.BSPLineValues[indexHeta, j] *
                                       controlPoints[k].WeightFactor;
                        sumKsidHeta += bsplinesKsi.BSPLineValues[indexKsi, i] *
                                       bsplinesHeta.BSPLineDerivativeValues[indexHeta, j] *
                                       controlPoints[k].WeightFactor;
                        sumdKsidKsi += bsplinesKsi.BSPLineSecondDerivativeValues[indexKsi, i] *
                                       bsplinesHeta.BSPLineValues[indexHeta, j] *
                                       controlPoints[k].WeightFactor;
                        sumdHetadHeta += bsplinesKsi.BSPLineValues[indexKsi, i] *
                                         bsplinesHeta.BSPLineSecondDerivativeValues[indexHeta, j] *
                                         controlPoints[k].WeightFactor;
                        sumdKsidHeta += bsplinesKsi.BSPLineDerivativeValues[indexKsi, i] *
                                        bsplinesHeta.BSPLineDerivativeValues[indexHeta, j] *
                                        controlPoints[k].WeightFactor;
                    }

                    for (int k = 0; k < numberOfElementControlPoints; k++)
                    {
                        int indexKsi  = controlPoints[k].ID / element.Patch.NumberOfControlPointsHeta;
                        int indexHeta = controlPoints[k].ID % element.Patch.NumberOfControlPointsHeta;

                        NurbsValues[k, i *supportHeta + j] =
                            bsplinesKsi.BSPLineValues[indexKsi, i] *
                            bsplinesHeta.BSPLineValues[indexHeta, j] *
                            controlPoints[k].WeightFactor / sumKsiHeta;

                        NurbsDerivativeValuesKsi[k, i *supportHeta + j] =
                            bsplinesHeta.BSPLineValues[indexHeta, j] * controlPoints[k].WeightFactor *
                            (bsplinesKsi.BSPLineDerivativeValues[indexKsi, i] * sumKsiHeta -
                             bsplinesKsi.BSPLineValues[indexKsi, i] * sumdKsiHeta) / Math.Pow(sumKsiHeta, 2);

                        NurbsDerivativeValuesHeta[k, i *supportHeta + j] =
                            bsplinesKsi.BSPLineValues[indexKsi, i] * controlPoints[k].WeightFactor *
                            (bsplinesHeta.BSPLineDerivativeValues[indexHeta, j] * sumKsiHeta -
                             bsplinesHeta.BSPLineValues[indexHeta, j] * sumKsidHeta) / Math.Pow(sumKsiHeta, 2);

                        NurbsSecondDerivativeValueKsi[k, i *supportHeta + j] =
                            bsplinesHeta.BSPLineValues[indexHeta, j] * controlPoints[k].WeightFactor *
                            (bsplinesKsi.BSPLineSecondDerivativeValues[indexKsi, i] / sumKsiHeta -
                             2 * bsplinesKsi.BSPLineDerivativeValues[indexKsi, i] * sumdKsiHeta /
                             Math.Pow(sumKsiHeta, 2) -
                             bsplinesKsi.BSPLineValues[indexKsi, i] * sumdKsidKsi / Math.Pow(sumKsiHeta, 2) +
                             2 * bsplinesKsi.BSPLineValues[indexKsi, i] * Math.Pow(sumdKsiHeta, 2) /
                             Math.Pow(sumKsiHeta, 3));

                        NurbsSecondDerivativeValueHeta[k, i *supportHeta + j] =
                            bsplinesKsi.BSPLineValues[indexKsi, i] * controlPoints[k].WeightFactor *
                            (bsplinesHeta.BSPLineSecondDerivativeValues[indexHeta, j] / sumKsiHeta -
                             2 * bsplinesHeta.BSPLineDerivativeValues[indexHeta, j] * sumKsidHeta /
                             Math.Pow(sumKsiHeta, 2) -
                             bsplinesHeta.BSPLineValues[indexHeta, j] * sumdHetadHeta / Math.Pow(sumKsiHeta, 2) +
                             2 * bsplinesHeta.BSPLineValues[indexHeta, j] * Math.Pow(sumKsidHeta, 2) /
                             Math.Pow(sumKsiHeta, 3));

                        NurbsSecondDerivativeValueKsiHeta[k, i *supportHeta + j] =
                            controlPoints[k].WeightFactor *
                            (bsplinesKsi.BSPLineDerivativeValues[indexKsi, i] *
                             bsplinesHeta.BSPLineDerivativeValues[indexHeta, j] / sumKsiHeta -
                             bsplinesKsi.BSPLineDerivativeValues[indexKsi, i] *
                             bsplinesHeta.BSPLineValues[indexHeta, j] *
                             sumKsidHeta / Math.Pow(sumKsiHeta, 2) -
                             bsplinesKsi.BSPLineValues[indexKsi, i] *
                             bsplinesHeta.BSPLineDerivativeValues[indexHeta, j] *
                             sumdKsiHeta / Math.Pow(sumKsiHeta, 2) -
                             bsplinesKsi.BSPLineValues[indexKsi, i] * bsplinesHeta.BSPLineValues[indexHeta, j] *
                             sumdKsidHeta / Math.Pow(sumKsiHeta, 2) +
                             2 * bsplinesKsi.BSPLineValues[indexKsi, i] * bsplinesHeta.BSPLineValues[indexHeta, j] *
                             sumdKsiHeta * sumKsidHeta / Math.Pow(sumKsiHeta, 3));
                    }
                }
            }
        }
Esempio n. 13
0
        /// <summary>
        /// Defines a 2D NURBS shape functions for a collocation point.
        /// Calculates NURBS for only Control Points affected by the collocation point.
        /// </summary>
        /// <param name="degreeKsi">Polynomial degree of the parametric axis Ksi.</param>
        /// <param name="degreeHeta">Polynomial degree of the parametric axis Heta.</param>
        /// <param name="knotValueVectorKsi">Knot value vector of the parametric axis Ksi.</param>
        /// <param name="knotValueVectorHeta">Knot value vector of the parametric axis Heta.</param>
        /// <param name="collocationPoint">A <see cref="NaturalPoin"/> for which the shape functions will be evaluated.</param>
        /// <param name="controlPoints">A <see cref="List{T}"/> containing the control points of the element.</param>
        public Nurbs2D(int degreeKsi, int degreeHeta, Vector knotValueVectorKsi, Vector knotValueVectorHeta,
                       NaturalPoint collocationPoint, IList <ControlPoint> controlPoints)
        {
            var numberOfControlPointsHeta = knotValueVectorHeta.Length - degreeHeta - 1;

            BSPLines1D bsplinesKsi = new BSPLines1D(degreeKsi, knotValueVectorKsi,
                                                    Vector.CreateFromArray(new double[] { collocationPoint.Xi }));
            BSPLines1D bsplinesHeta = new BSPLines1D(degreeHeta, knotValueVectorHeta,
                                                     Vector.CreateFromArray(new double[] { collocationPoint.Eta }));

            bsplinesKsi.calculateBSPLinesAndDerivatives();
            bsplinesHeta.calculateBSPLinesAndDerivatives();

            int numberOfGPKsi  = 1;
            int numberOfGPHeta = 1;
            int numberOfElementControlPoints = (degreeKsi + 1) * (degreeHeta + 1);

            NurbsValues = Matrix.CreateZero(numberOfElementControlPoints, 1);
            NurbsDerivativeValuesKsi          = Matrix.CreateZero(numberOfElementControlPoints, 1);
            NurbsDerivativeValuesHeta         = Matrix.CreateZero(numberOfElementControlPoints, 1);
            NurbsSecondDerivativeValueKsi     = Matrix.CreateZero(numberOfElementControlPoints, 1);
            NurbsSecondDerivativeValueHeta    = Matrix.CreateZero(numberOfElementControlPoints, 1);
            NurbsSecondDerivativeValueKsiHeta = Matrix.CreateZero(numberOfElementControlPoints, 1);

            for (int i = 0; i < numberOfGPKsi; i++)
            {
                for (int j = 0; j < numberOfGPHeta; j++)
                {
                    double sumKsiHeta    = 0;
                    double sumdKsiHeta   = 0;
                    double sumKsidHeta   = 0;
                    double sumdKsidKsi   = 0;
                    double sumdHetadHeta = 0;
                    double sumdKsidHeta  = 0;

                    for (int k = 0; k < numberOfElementControlPoints; k++)
                    {
                        // Why type casting is needed.?

                        int indexKsi  = controlPoints[k].ID / numberOfControlPointsHeta;
                        int indexHeta = controlPoints[k].ID % numberOfControlPointsHeta;
                        sumKsiHeta += bsplinesKsi.BSPLineValues[indexKsi, i] *
                                      bsplinesHeta.BSPLineValues[indexHeta, j] *
                                      controlPoints[k].WeightFactor;
                        sumdKsiHeta += bsplinesKsi.BSPLineDerivativeValues[indexKsi, i] *
                                       bsplinesHeta.BSPLineValues[indexHeta, j] *
                                       controlPoints[k].WeightFactor;
                        sumKsidHeta += bsplinesKsi.BSPLineValues[indexKsi, i] *
                                       bsplinesHeta.BSPLineDerivativeValues[indexHeta, j] *
                                       controlPoints[k].WeightFactor;
                        sumdKsidKsi += bsplinesKsi.BSPLineSecondDerivativeValues[indexKsi, i] *
                                       bsplinesHeta.BSPLineValues[indexHeta, j] *
                                       controlPoints[k].WeightFactor;
                        sumdHetadHeta += bsplinesKsi.BSPLineValues[indexKsi, i] *
                                         bsplinesHeta.BSPLineSecondDerivativeValues[indexHeta, j] *
                                         controlPoints[k].WeightFactor;
                        sumdKsidHeta += bsplinesKsi.BSPLineDerivativeValues[indexKsi, i] *
                                        bsplinesHeta.BSPLineDerivativeValues[indexHeta, j] *
                                        controlPoints[k].WeightFactor;
                    }

                    for (int k = 0; k < numberOfElementControlPoints; k++)
                    {
                        int indexKsi  = controlPoints[k].ID / numberOfControlPointsHeta;
                        int indexHeta = controlPoints[k].ID % numberOfControlPointsHeta;

                        NurbsValues[k, i *numberOfGPHeta + j] =
                            bsplinesKsi.BSPLineValues[indexKsi, i] *
                            bsplinesHeta.BSPLineValues[indexHeta, j] *
                            controlPoints[k].WeightFactor / sumKsiHeta;

                        NurbsDerivativeValuesKsi[k, i *numberOfGPHeta + j] =
                            bsplinesHeta.BSPLineValues[indexHeta, j] * controlPoints[k].WeightFactor *
                            (bsplinesKsi.BSPLineDerivativeValues[indexKsi, i] * sumKsiHeta -
                             bsplinesKsi.BSPLineValues[indexKsi, i] * sumdKsiHeta) / Math.Pow(sumKsiHeta, 2);

                        NurbsDerivativeValuesHeta[k, i *numberOfGPHeta + j] =
                            bsplinesKsi.BSPLineValues[indexKsi, i] * controlPoints[k].WeightFactor *
                            (bsplinesHeta.BSPLineDerivativeValues[indexHeta, j] * sumKsiHeta -
                             bsplinesHeta.BSPLineValues[indexHeta, j] * sumKsidHeta) / Math.Pow(sumKsiHeta, 2);

                        NurbsSecondDerivativeValueKsi[k, i *numberOfGPHeta + j] =
                            bsplinesHeta.BSPLineValues[indexHeta, j] * controlPoints[k].WeightFactor *
                            (bsplinesKsi.BSPLineSecondDerivativeValues[indexKsi, i] / sumKsiHeta -
                             2 * bsplinesKsi.BSPLineDerivativeValues[indexKsi, i] * sumdKsiHeta /
                             Math.Pow(sumKsiHeta, 2) -
                             bsplinesKsi.BSPLineValues[indexKsi, i] * sumdKsidKsi / Math.Pow(sumKsiHeta, 2) +
                             2 * bsplinesKsi.BSPLineValues[indexKsi, i] * Math.Pow(sumdKsiHeta, 2) /
                             Math.Pow(sumKsiHeta, 3));

                        NurbsSecondDerivativeValueHeta[k, i *numberOfGPHeta + j] =
                            bsplinesKsi.BSPLineValues[indexKsi, i] * controlPoints[k].WeightFactor *
                            (bsplinesHeta.BSPLineSecondDerivativeValues[indexHeta, j] / sumKsiHeta -
                             2 * bsplinesHeta.BSPLineDerivativeValues[indexHeta, j] * sumKsidHeta /
                             Math.Pow(sumKsiHeta, 2) -
                             bsplinesHeta.BSPLineValues[indexHeta, j] * sumdHetadHeta / Math.Pow(sumKsiHeta, 2) +
                             2 * bsplinesHeta.BSPLineValues[indexHeta, j] * Math.Pow(sumKsidHeta, 2) /
                             Math.Pow(sumKsiHeta, 3));

                        NurbsSecondDerivativeValueKsiHeta[k, i *numberOfGPHeta + j] =
                            controlPoints[k].WeightFactor *
                            (bsplinesKsi.BSPLineDerivativeValues[indexKsi, i] *
                             bsplinesHeta.BSPLineDerivativeValues[indexHeta, j] / sumKsiHeta -
                             bsplinesKsi.BSPLineDerivativeValues[indexKsi, i] *
                             bsplinesHeta.BSPLineValues[indexHeta, j] *
                             sumKsidHeta / Math.Pow(sumKsiHeta, 2) -
                             bsplinesKsi.BSPLineValues[indexKsi, i] *
                             bsplinesHeta.BSPLineDerivativeValues[indexHeta, j] *
                             sumdKsiHeta / Math.Pow(sumKsiHeta, 2) -
                             bsplinesKsi.BSPLineValues[indexKsi, i] * bsplinesHeta.BSPLineValues[indexHeta, j] *
                             sumdKsidHeta / Math.Pow(sumKsiHeta, 2) +
                             2 * bsplinesKsi.BSPLineValues[indexKsi, i] * bsplinesHeta.BSPLineValues[indexHeta, j] *
                             sumdKsiHeta * sumKsidHeta / Math.Pow(sumKsiHeta, 3));
                    }
                }
            }
        }