protected override NodeSetController.NodeSetContainer[] CreateNodeSetFamily(Platform.MultidimensionalArray NodesUntransformed) { Simplex volSimplx = m_Context.Grid.GridSimplex; int NoOfEdgesPerSimplex = volSimplx.NoOfEdges; int NoOfTrafos = m_Context.GridDat.InterCellTransformations.Length; int NoOfNodes = NodesUntransformed.GetLength(0); int D = m_Context.Grid.SpatialDimension; //// ====== //// create //// ====== //for (int i = 0; i < m_TestFunctions_1stCell.GetLength(0); i++) { // m_NodesUntransfomedVolCoord_1stEdge[i] = MultidimensionalArray.CreateEmpty(2); // for (int _k = 0; _k < m_NodesUntransfomedVolCoord_2ndEdge.GetLength(1); _k++) // m_NodesUntransfomedVolCoord_2ndEdge[i, _k] = MultidimensionalArray.CreateEmpty(2); //} //// ========================== //// allocate storage structure //// ========================== //for (int e = 0; e < NoOfEdgesPerSimplex; e++) { // m_NodesUntransfomedVolCoord_1stEdge[e].Allocate(NoOfNodes, D); // for (int k = 0; k < NoOfTrafos; k++) { // m_NodesUntransfomedVolCoord_2ndEdge[e, k].Allocate(NoOfNodes, D); // } //} // ================================================================================ // transform quadrature nodes from edge simplex to volume simplex coordinate system // ================================================================================ NodeSetController.NodeSetContainer[] nodeSetFamily = new NodeSetController.NodeSetContainer[NoOfEdgesPerSimplex * (NoOfTrafos + 1)]; int NoOftrafos = m_Context.GridDat.InterCellTransformations.Length; for (int e = 0; e < NoOfEdgesPerSimplex; e++) { var nodes = MultidimensionalArray.Create(NoOfNodes, D); volSimplx.EdgeToVolumeCoordinates(e, NodesUntransformed, nodes); nodeSetFamily[e] = m_Context.NSC.CreateContainer(nodes, 0.0); for (int _k = 0; _k < NoOftrafos; _k++) { var nodes2 = MultidimensionalArray.Create(NoOfNodes, D); m_Context.GridDat.InterCellTransformations[_k].Transform(nodes, nodes2); nodeSetFamily[NodeSetIndex(e, _k)] = m_Context.NSC.CreateContainer(nodes2, 0.0); } } return(nodeSetFamily); }
public LineSegment[] GetReferenceLineSegments() { Stack <Simplex> simplexHierarchy = new Stack <Simplex>(); Simplex currentSimplex = Simplex; int spatialDimension = Simplex.SpatialDimension; int n = 0; while (currentSimplex.GetType() != lineSimplex.GetType()) { if (n > MAX_SIMPLEX_LEVELS) { throw new ApplicationException("Something went terribly wrong. Please contact Björn"); } simplexHierarchy.Push(currentSimplex); currentSimplex = currentSimplex.EdgeSimplex; 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.NoOfEdges, currentSimplex.SpatialDimension); for (int e = 0; e < currentSimplex.NoOfEdges; e++) { MultidimensionalArray coordinates = MultidimensionalArray.Create(noOfVertices, D); currentSimplex.EdgeToVolumeCoordinates(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++) { LineSegment newSegment = new LineSegment(spatialDimension, RootFindingAlgorithm); for (int d = 0; d < spatialDimension; d++) { newSegment.Start[d] = vertexCoordinates[2 * i + 0, d]; newSegment.End[d] = vertexCoordinates[2 * i + 1, d]; } if (!lineSegments.Contains(newSegment)) { lineSegments.Add(newSegment); tracker.Subscribe(newSegment); } } foreach (LineSegment segment in lineSegments) { LevelSet levelSetField = tracker.LevelSets[levSetIndex] as LevelSet; if (levelSetField != null) { segment.ProjectBasisPolynomials(levelSetField.Basis); } } return(lineSegments.ToArray()); }