Example #1
0
        private void CreateNURBSElements3D()
        {
            #region Knots

            Vector singleKnotValuesKsi  = KnotValueVectorKsi.RemoveDuplicatesFindMultiplicity()[0];
            Vector singleKnotValuesHeta = KnotValueVectorHeta.RemoveDuplicatesFindMultiplicity()[0];
            Vector singleKnotValuesZeta = KnotValueVectorZeta.RemoveDuplicatesFindMultiplicity()[0];

            var knots = CreateKnots3D(singleKnotValuesKsi, singleKnotValuesHeta, singleKnotValuesZeta);

            #endregion Knots

            #region Elements

            CreateElements3D(knots);

            #endregion Elements
        }
Example #2
0
        private void CreateElements3D(List <Knot> knots)
        {
            Vector singlesKnotValuesKsi  = KnotValueVectorKsi.RemoveDuplicatesFindMultiplicity()[0];
            Vector multiplicityKsi       = KnotValueVectorKsi.RemoveDuplicatesFindMultiplicity()[1];
            Vector singlesKnotValuesHeta = KnotValueVectorHeta.RemoveDuplicatesFindMultiplicity()[0];
            Vector multiplicityHeta      = KnotValueVectorHeta.RemoveDuplicatesFindMultiplicity()[1];
            Vector singlesKnotValuesZeta = KnotValueVectorZeta.RemoveDuplicatesFindMultiplicity()[0];
            Vector multiplicityZeta      = KnotValueVectorZeta.RemoveDuplicatesFindMultiplicity()[1];

            int numberOfElementsKsi  = singlesKnotValuesKsi.Length - 1;
            int numberOfElementsHeta = singlesKnotValuesHeta.Length - 1;
            int numberOfElementsZeta = singlesKnotValuesZeta.Length - 1;

            if (numberOfElementsKsi * numberOfElementsHeta * numberOfElementsZeta == 0)
            {
                throw new ArgumentException("Number of Elements should be defined before Element Connectivity");
            }

            for (int i = 0; i < numberOfElementsKsi; i++)
            {
                for (int j = 0; j < numberOfElementsHeta; j++)
                {
                    for (int k = 0; k < numberOfElementsZeta; k++)
                    {
                        IList <Knot> knotsOfElement = new List <Knot>
                        {
                            knots[
                                i * singlesKnotValuesZeta.Length * singlesKnotValuesHeta.Length + j * singlesKnotValuesZeta.Length +
                                k],
                            knots[
                                i * singlesKnotValuesZeta.Length * singlesKnotValuesHeta.Length + j * singlesKnotValuesZeta.Length +
                                k + 1],
                            knots[
                                i * singlesKnotValuesZeta.Length * singlesKnotValuesHeta.Length +
                                (j + 1) * singlesKnotValuesZeta.Length + k],
                            knots[
                                i * singlesKnotValuesZeta.Length * singlesKnotValuesHeta.Length +
                                (j + 1) * singlesKnotValuesZeta.Length + k + 1],
                            knots[
                                (i + 1) * singlesKnotValuesZeta.Length * singlesKnotValuesHeta.Length +
                                j * singlesKnotValuesZeta.Length + k],
                            knots[
                                (i + 1) * singlesKnotValuesZeta.Length * singlesKnotValuesHeta.Length +
                                j * singlesKnotValuesZeta.Length + k + 1],
                            knots[
                                (i + 1) * singlesKnotValuesZeta.Length * singlesKnotValuesHeta.Length +
                                (j + 1) * singlesKnotValuesZeta.Length + k],
                            knots[
                                (i + 1) * singlesKnotValuesZeta.Length * singlesKnotValuesHeta.Length +
                                (j + 1) * singlesKnotValuesZeta.Length + k + 1]
                        };

                        int multiplicityElementKsi = 0;
                        if (multiplicityKsi[i + 1] - this.DegreeKsi > 0)
                        {
                            multiplicityElementKsi = (int)multiplicityKsi[i + 1] - DegreeKsi;
                        }

                        int multiplicityElementHeta = 0;
                        if (multiplicityHeta[j + 1] - this.DegreeHeta > 0)
                        {
                            multiplicityElementHeta = (int)multiplicityHeta[j + 1] - this.DegreeHeta;
                        }

                        int multiplicityElementZeta = 0;
                        if (multiplicityZeta[k + 1] - this.DegreeZeta > 0)
                        {
                            multiplicityElementZeta = (int)multiplicityZeta[k + 1] - this.DegreeZeta;
                        }

                        int nurbsSupportKsi  = this.DegreeKsi + 1;
                        int nurbsSupportHeta = this.DegreeHeta + 1;
                        int nurbsSupportZeta = this.DegreeZeta + 1;

                        IList <ControlPoint> elementControlPoints = new List <ControlPoint>();

                        for (int l = 0; l < nurbsSupportKsi; l++)
                        {
                            for (int m = 0; m < nurbsSupportHeta; m++)
                            {
                                for (int n = 0; n < nurbsSupportZeta; n++)
                                {
                                    int controlPointID = (i + multiplicityElementKsi) * NumberOfControlPointsHeta *
                                                         NumberOfControlPointsZeta +
                                                         (j + multiplicityElementHeta) * NumberOfControlPointsZeta +
                                                         (k + multiplicityElementZeta) +
                                                         l * NumberOfControlPointsHeta * NumberOfControlPointsZeta +
                                                         m * NumberOfControlPointsZeta + n;

                                    elementControlPoints.Add(ControlPoints[controlPointID]);
                                }
                            }
                        }

                        int     elementID = i * numberOfElementsHeta * numberOfElementsZeta + j * numberOfElementsZeta + k;
                        Element element   = new NurbsElement3D()
                        {
                            ID          = elementID,
                            Patch       = this,
                            ElementType = new NurbsElement3D()
                        };
                        element.AddKnots(knotsOfElement);
                        element.AddControlPoints(elementControlPoints.ToList());
                        Elements.Add(element);
                    }
                }
            }
        }