예제 #1
0
            /// <summary>
            /// Defines a mapping between BoSSS elements (<see cref="RefElement"/>)
            /// and the Tecplot representations.
            /// </summary>
            /// <returns>The Tecplot zone type for the current grid</returns>
            private ZoneType GetZoneType(RefElement Kref)
            {
                ZoneType zoneType;

                if (Kref.GetType() == typeof(Line))
                {
                    zoneType = ZoneType.FELineSeg;
                }
                else if (Kref.GetType() == typeof(Square))
                {
                    zoneType = ZoneType.FEQuad;
                }
                else if (Kref.GetType() == typeof(Triangle))
                {
                    zoneType = ZoneType.FETriangle;
                }
                else if (Kref.GetType() == typeof(Cube))
                {
                    zoneType = ZoneType.FEBrick;
                }
                else if (Kref.GetType() == typeof(Tetra))
                {
                    zoneType = ZoneType.FETetrahedron;
                }
                else
                {
                    throw new NotSupportedException(Kref.GetType().ToString() + " - simplex currently not supported in tecplot.");
                }
                return(zoneType);
            }
예제 #2
0
 public ExactCircleLevelSetIntegration(int iLs, GridData c, RefElement simplex)
 {
     if (!Rem)
     {
         for (int i = 0; i < RADIUS.Length; i++)
         {
             Console.WriteLine("ACHTUNG: ExactCircleLevelSetIntegration; Radius = " + RADIUS[i]);
         }
         Rem = true;
     }
     if (simplex.GetType() != typeof(Square))
     {
         throw new ArgumentOutOfRangeException();
     }
     this.RefElement = simplex;
     this.iLevSet    = iLs;
     this._Context   = c;
 }
예제 #3
0
        /// <summary>
        /// Determines the line segments bounding the selected reference
        /// element (cf. <see cref="RefElement"/>) in reference coordinates
        /// </summary>
        /// <returns></returns>
        private LineSegment[] GetReferenceLineSegments()
        {
            Stack <RefElement> simplexHierarchy = new Stack <RefElement>();
            RefElement         currentSimplex   = RefElement;
            int spatialDimension = RefElement.SpatialDimension;

            int n = 0;

            while (currentSimplex.GetType() != lineSimplex.GetType())
            {
                // If n > 2, the edge of the edge of a simplex is not a line.
                // This is hardly likely in 2d/3d.
                if (n > 2)
                {
                    throw new ApplicationException("Something went terribly wrong.");
                }

                simplexHierarchy.Push(currentSimplex);

                currentSimplex = currentSimplex.FaceRefElement;
                n++;
            }

            MultidimensionalArray vertexCoordinates = MultidimensionalArray.Create(2, 1);

            vertexCoordinates[0, 0] = -1.0;
            vertexCoordinates[1, 0] = 1.0;

            while (simplexHierarchy.Count > 0)
            {
                currentSimplex = simplexHierarchy.Pop();

                int noOfVertices = vertexCoordinates.GetLength(0);
                int D            = currentSimplex.SpatialDimension;
                MultidimensionalArray volumeCoordinates = MultidimensionalArray.Create(
                    noOfVertices * currentSimplex.NoOfFaces, currentSimplex.SpatialDimension);

                for (int e = 0; e < currentSimplex.NoOfFaces; e++)
                {
                    MultidimensionalArray coordinates = MultidimensionalArray.Create(noOfVertices, D);
                    currentSimplex.TransformFaceCoordinates(e, vertexCoordinates, coordinates);

                    for (int i = 0; i < noOfVertices; i++)
                    {
                        for (int d = 0; d < D; d++)
                        {
                            volumeCoordinates[e * noOfVertices + i, d] = coordinates[i, d];
                        }
                    }
                }

                vertexCoordinates = volumeCoordinates;
            }

            Debug.Assert(
                vertexCoordinates.GetLength(0) % 2 == 0,
                "Even number of vertices expected");
            int initialNumberOfLineSegments = vertexCoordinates.GetLength(0) / 2;

            List <LineSegment> lineSegments = new List <LineSegment>(initialNumberOfLineSegments);

            for (int i = 0; i < initialNumberOfLineSegments; i++)
            {
                var p0  = vertexCoordinates.GetRow(2 * i + 0);
                int iP0 = this.RefElement.Vertices.FindRow(p0, 1.0e-8);
                var p1  = vertexCoordinates.GetRow(2 * i + 1);
                int iP1 = this.RefElement.Vertices.FindRow(p1, 1.0e-8);

                LineSegment newSegment = new LineSegment(spatialDimension, this.RefElement,
                                                         p0, p1, iP0, iP1,
                                                         RootFindingAlgorithm);

                if (!lineSegments.Contains(newSegment))
                {
                    lineSegments.Add(newSegment);
                    //tracker.Subscribe(newSegment);
                }
            }

            foreach (LineSegment segment in lineSegments)
            {
                LevelSet levelSetField = levelSetData.LevelSet as LevelSet;
                if (levelSetField != null)
                {
                    segment.ProjectBasisPolynomials(levelSetField.Basis);
                }
            }

            return(lineSegments.ToArray());
        }
예제 #4
0
        /// <summary>
        /// Uses <see cref="GetPolynomials2D"/> or
        /// <see cref="GetPolynomials3D"/> to retrieve the polynomials with
        /// order less than or equal <paramref name="order"/>
        /// </summary>
        /// <param name="simplex"></param>
        /// <param name="order"></param>
        /// <returns></returns>
        private static IEnumerable <Polynomial> GetPolynomials(RefElement simplex, int order)
        {
            int numberOfPolynomials;

            if (simplex.SpatialDimension == 2)
            {
                numberOfPolynomials = (order + 2) * (order + 3) / 2 - 1;
            }
            else if (simplex.SpatialDimension == 3)
            {
                numberOfPolynomials = (order + 1) * (order + 2) * (2 * order + 9) / 6;
            }
            else
            {
                throw new Exception();
            }
            numberOfPolynomials *= simplex.SpatialDimension;

            Polynomial[] allPolys;
            if (simplex is Square)
            {
                allPolys = PolynomialsSquare;
            }
            else if (simplex is Triangle)
            {
                allPolys = PolynomialsTriangle;
            }
            else if (simplex is Cube)
            {
                allPolys = PolynomialsCube;
            }
            else if (simplex is Tetra)
            {
                allPolys = PolynomialsTetra;
            }
            else
            {
                throw new Exception();
            }

            if (numberOfPolynomials > allPolys.Length)
            {
                throw new NotSupportedException("Divergence-free basis for reference element '" + simplex.GetType().ToString() + "' is not specified for degree " + order + ", max. supported degree is " + (allPolys.Max(poly => poly.AbsoluteDegree)) + ".");
            }

#if DEBUG
            for (int i = 0; i < Math.Min(allPolys.Length, numberOfPolynomials); i++)
            {
                Debug.Assert(allPolys[i].AbsoluteDegree <= order);
            }
            int D = simplex.SpatialDimension;
            Debug.Assert(allPolys.Length % D == 0);
            for (int i = numberOfPolynomials / D; i < allPolys.Length / D; i++)
            {
                int DegMax = 0;
                for (int d = 0; d < D; d++)
                {
                    DegMax = Math.Max(DegMax, allPolys[i * D + d].AbsoluteDegree);
                }
                Debug.Assert(DegMax > order);
            }
#endif

            Polynomial[] ret = new Polynomial[numberOfPolynomials];
            Array.Copy(allPolys, 0, ret, 0, numberOfPolynomials);
            return(ret);
        }