Esempio n. 1
0
        /// <summary>
        /// Initializes the subdivision of the given simplex. Initially, the
        /// simplex remains undivided.
        /// </summary>
        /// <param name="refElement">
        /// The simplex to subdivide.
        /// </param>
        /// <param name="tracker">
        /// The level set tracker. Allows for the check if a simplex ist cut.
        /// </param>
        /// <param name="levSetIndex">Index of the level set</param>
        /// <param name="maxDivisions">
        /// The maximum number of subdivisions of the simplex
        /// </param>
        public AdaptiveSubdivisionStrategy(RefElement refElement, LevelSetTracker.LevelSetData levelSetData, int maxDivisions)
        {
            this.RefElement    = refElement;
            this.maxDivisions  = maxDivisions;
            this.baseVertexSet = new NestedVertexSet(refElement.SpatialDimension);
            this.LevelSetData  = levelSetData;

            int verticesPerCell = refElement.Vertices.GetLength(0);

            int[] simplexVertices = new int[verticesPerCell];
            for (int i = 0; i < verticesPerCell; i++)
            {
                double[] vertex = refElement.Vertices.GetRow(i);
                simplexVertices[i] = baseVertexSet.RegisterVertex(vertex);
            }
            this.subdivisionTree = new SimplexSubdivisionTree(
                refElement, baseVertexSet, simplexVertices);

            this.subdivisionTree.SetSavePoint();
        }
Esempio n. 2
0
            /// <summary>
            /// Creates a new child of <paramref name="parrent"/>.
            /// </summary>
            /// <param name="owner">
            /// <see cref="Node.Node(SimplexSubdivisionTree, Node, int, NestedVertexSet, int[], AffineTrafo)"/>
            /// </param>
            /// <param name="parrent">
            /// The parrent of this node.
            /// </param>
            /// <param name="level">
            /// <see cref="Node.Node(SimplexSubdivisionTree, Node, int, NestedVertexSet, int[], AffineTrafo)"/>
            /// </param>
            /// <param name="vertexSet">
            /// <see cref="Node.Node(SimplexSubdivisionTree, Node, int, NestedVertexSet, int[], AffineTrafo)"/>
            /// </param>
            /// <param name="vertexIndices">
            /// <see cref="Node.Node(SimplexSubdivisionTree, Node, int, NestedVertexSet, int[], AffineTrafo)"/>
            /// </param>
            /// <param name="transformationFromRoot">
            /// <see cref="Node.Node(SimplexSubdivisionTree, Node, int, NestedVertexSet, int[], AffineTrafo)"/>
            /// </param>
            private Node(SimplexSubdivisionTree owner, Node parrent, int level, NestedVertexSet vertexSet, int[] vertexIndices, AffineTrafo transformationFromRoot)
                : base(transformationFromRoot)
            {
                Debug.Assert(vertexIndices.Length == owner.refElement.NoOfVertices, "Wrong number of vertices");
                Debug.Assert(vertexIndices.All((i) => i >= 0), "All vertex indices must be positive");
                Debug.Assert(vertexIndices.Distinct().Count() == vertexIndices.Length, "Vertex indices must be unique");

                this.owner               = owner;
                this.level               = level;
                this.vertexSet           = vertexSet;
                this.globalVertexIndices = vertexIndices;

                Children  = new List <Node>();
                distances = new double[globalVertexIndices.Length];
                ArrayTools.SetAll(distances, double.NaN);

                if (parrent != null)
                {
                    for (int i = 0; i < globalVertexIndices.Length; i++)
                    {
                        int parrentIndex = -1;
                        for (int j = 0; j < parrent.globalVertexIndices.Length; j++)
                        {
                            if (parrent.globalVertexIndices[j] == globalVertexIndices[i])
                            {
                                parrentIndex = j;
                                break;
                            }
                        }

                        if (parrentIndex >= 0)
                        {
                            distances[i] = parrent.distances[parrentIndex];
                        }
                    }
                }
            }
Esempio n. 3
0
 /// <summary>
 /// Constructs a root node of a tree.
 /// </summary>
 /// <param name="owner">
 /// The creator of this object.
 /// </param>
 /// <param name="level">
 /// The level of this node in the subdivision tree, i.e. the number
 /// of ancestors.
 /// </param>
 /// <param name="vertexSet">
 /// The set containing all vertices of <b>all</b> nodes on this
 /// level of the subdivision tree (i.e., of this node and its
 /// siblings).
 /// </param>
 /// <param name="vertexIndices">
 /// The indices of the vertices of this node in
 /// <see cref="vertexSet"/>.
 /// </param>
 /// <param name="transformationFromRoot">
 /// The affine transformation that transforms a vertex of the root
 /// simplex to a vertex of this node.
 /// </param>
 public Node(SimplexSubdivisionTree owner, int level, NestedVertexSet vertexSet, int[] vertexIndices, AffineTrafo transformationFromRoot)
     : this(owner, null, level, vertexSet, vertexIndices, transformationFromRoot)
 {
 }