예제 #1
0
        private void CreateElements2D(Vector singleKnotValuesKsi, Vector singleKnotValuesHeta, List <Knot> knots)
        {
            Vector multiplicityKsi  = KnotValueVectorKsi.RemoveDuplicatesFindMultiplicity()[1];
            Vector multiplicityHeta = KnotValueVectorHeta.RemoveDuplicatesFindMultiplicity()[1];

            int numberOfElementsKsi  = singleKnotValuesKsi.Length - 1;
            int numberOfElementsHeta = singleKnotValuesHeta.Length - 1;

            if (numberOfElementsKsi * numberOfElementsHeta == 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++)
                {
                    IList <Knot> knotsOfElement = new List <Knot>
                    {
                        knots[i * singleKnotValuesHeta.Length + j],
                        knots[i * singleKnotValuesHeta.Length + j + 1],
                        knots[(i + 1) * singleKnotValuesHeta.Length + j],
                        knots[(i + 1) * singleKnotValuesHeta.Length + j + 1]
                    };

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

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

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

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

                    for (int k = 0; k < nurbsSupportKsi; k++)
                    {
                        for (int l = 0; l < nurbsSupportHeta; l++)
                        {
                            int controlPointID = (i + multiplicityElementKsi) * this.NumberOfControlPointsHeta +
                                                 (j + multiplicityElementHeta) + k * this.NumberOfControlPointsHeta + l;
                            elementControlPoints.Add(this.ControlPoints[controlPointID]);
                        }
                    }

                    int     elementID = i * numberOfElementsHeta + j;
                    Element element   = new NurbsElement2D()
                    {
                        ID          = elementID,
                        Patch       = this,
                        ElementType = new NurbsElement2D()
                    };
                    element.AddKnots(knotsOfElement);
                    element.AddControlPoints(elementControlPoints.ToList());
                    Elements.Add(element);
                }
            }
        }
예제 #2
0
        private void CreateFaceElements()
        {
            #region Knots

            Vector singleKnotValuesKsi  = KnotValueVectors[0].RemoveDuplicatesFindMultiplicity()[0];
            Vector singleKnotValuesHeta = KnotValueVectors[1].RemoveDuplicatesFindMultiplicity()[0];

            List <Knot> knots = new List <Knot>();

            int id = 0;
            for (int i = 0; i < singleKnotValuesKsi.Length; i++)
            {
                for (int j = 0; j < singleKnotValuesHeta.Length; j++)
                {
                    knots.Add(new Knot()
                    {
                        ID = id, Ksi = singleKnotValuesKsi[i], Heta = singleKnotValuesHeta[j], Zeta = 0.0
                    });
                    id++;
                }
            }

            #endregion Knots

            #region Elements

            Vector multiplicityKsi  = KnotValueVectors[0].RemoveDuplicatesFindMultiplicity()[1];
            Vector multiplicityHeta = KnotValueVectors[1].RemoveDuplicatesFindMultiplicity()[1];

            int numberOfElementsKsi  = singleKnotValuesKsi.Length - 1;
            int numberOfElementsHeta = singleKnotValuesHeta.Length - 1;
            if (numberOfElementsKsi * numberOfElementsHeta == 0)
            {
                throw new NullReferenceException("Number of Elements should be defined before Element Connectivity");
            }

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

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

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

                    int nurbsSupportKsi  = this.Degrees[0] + 1;
                    int nurbsSupportHeta = this.Degrees[1] + 1;

                    int NumberOfControlPointsHeta = KnotValueVectors[1].Length - Degrees[1] - 1;

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

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

                            elementControlPoints.Add(this.ControlPointsDictionary[controlPointID]);
                        }
                    }
                    int     elementID = i * numberOfElementsHeta + j;
                    Element element   = new NurbsElement2D()
                    {
                        ID          = elementID,
                        ElementType = new NurbsElement2D(),
                        Patch       = Patch,
                        Model       = Patch.Elements[0].Model
                    };
                    element.AddKnots(knotsOfElement);
                    element.AddControlPoints(elementControlPoints);
                    this.ElementsDictionary.Add(elementID, element);
                    //this.PatchesDictionary[1].ElementsDictionary.Add(element.ID, element);
                }
            }

            #endregion Elements
        }