Example #1
0
        public void RecomposePeriodicEdges(Domain <T> mesh, IEnumerable <Edge <T> > periodicEdges)
        {
            CellPairCollecter <T>  collecter  = new CellPairCollecter <T>(map);
            CellPairCollection <T> candidates = collecter.FollowBoundaryAndCollectCandidates(periodicEdges);

            RecomposeCutCells(mesh, candidates);
        }
Example #2
0
 public void RemoveAlreadyDealtWithCornerCellMergePairsFrom <T>(CellPairCollection <T> .EdgeCombo edge)
 {
     if (edge.Outer.Count > 0)
     {
         MeshCell <T> firstCandidate = edge.Outer[0].cell;
         if (edge.Inner.Count > 1)
         {
             MeshCell <T> secondCandidate = edge.Outer[edge.Outer.Count - 1].cell;
             if (cornerCandidates.Contains(secondCandidate.ID))
             {
                 edge.Inner.RemoveAt(edge.Outer.Count - 1);
                 edge.Outer.RemoveAt(edge.Outer.Count - 1);
             }
             else
             {
                 cornerCandidates.Add(secondCandidate.ID);
             }
         }
         if (cornerCandidates.Contains(firstCandidate.ID))
         {
             edge.Inner.RemoveAt(0);
             edge.Outer.RemoveAt(0);
         }
         else
         {
             cornerCandidates.Add(firstCandidate.ID);
         }
     }
 }
Example #3
0
        CellPairCollection <T> .EdgeCombo ExtractMergePairs(
            CellPairCollection <T> .EdgeCombo edgePair,
            CellPairCollection <T> candidates)
        {
            var mergePair = new CellPairCollection <T> .EdgeCombo(edgePair.EdgeNumber);

            int pairedBoundary = map.PeriodicBoundaryCorrelation[edgePair.EdgeNumber];

            candidates.TryGetOuterCells(pairedBoundary, out List <(MeshCell <T>, bool)> pairedOuterCells);
            mergePair.Outer = pairedOuterCells;
            mergePair.Inner = new List <(MeshCell <T>, bool)>(ArrayMethods.GetReverseOrderArray(edgePair.Inner));
            Debug.Assert(mergePair.Outer.Count == mergePair.Inner.Count);
            cleaner.RemoveAlreadyDealtWithCornerCellMergePairsFrom(mergePair);
            InitializeGlueMapOf(mergePair);

            return(mergePair);
        }
Example #4
0
        IEnumerable <CellPairCollection <T> .EdgeCombo> MergePairsOfEachEdge(
            CellPairCollection <T> candidates)
        {
            foreach (Pair <CellPairCollection <T> .EdgeCombo> opposingEdges in candidates.GetCollectedEdgeComboPairs(map))
            {
                CellPairCollection <T> .EdgeCombo mergePair        = ExtractMergePairs(opposingEdges.Previous, candidates);
                CellPairCollection <T> .EdgeCombo opposedMergePair = ExtractMergePairs(opposingEdges.Current, candidates);

                MoveBoundary(mergePair);
                MoveBoundary(opposedMergePair);

                Transform(mergePair);
                Transform(opposedMergePair);

                yield return(mergePair);

                yield return(opposedMergePair);
            }
        }
Example #5
0
        void RecomposeCutCells(Domain <T> mesh, CellPairCollection <T> candidates)
        {
            cellDetacher = new CellDetacher <T>(mesh, map);
            cleaner      = new CornerCleaner(map.PeriodicCornerCorrelation.Count);

            int i = 0;

            //MatlabPlotter.Plot(mesh, "Anfang");
            foreach (CellPairCollection <T> .EdgeCombo mergePair in MergePairsOfEachEdge(candidates))
            {
                //MatlabPlotter.Plot(mesh, i + "aMerge");
                Debug.Assert(CellNodePositionsMatch(mergePair));
                MergeAtBoundary(mergePair);
                //MatlabPlotter.Plot(mesh, i + "Merge");
                ++i;
            }

            //MatlabPlotter.Plot(mesh,"2aRemove");
            RemoveOuterCellsFromMesh(mesh);
            //MatlabPlotter.Plot(mesh, "2bRemove");
        }
Example #6
0
        public CellPairCollection <T> FollowBoundaryAndCollectCandidates(IEnumerable <Edge <T> > periodicEdges)
        {
            LinkedListDictionary <int, List <Edge <T> > > edges = DivideIntoBoundaries(periodicEdges);

            Debug.Assert(edges.Count % 2 == 0);
            CellPairCollection <T> candidates = new CellPairCollection <T>();


            while (edges.Count > 0)
            {
                List <Edge <T> > boundary = edges.First().Value;
                int        boundaryNumber = edges.First().Key;
                Position[] positions      = new Position[boundary.Count];
                for (int i = 0; i < boundary.Count; ++i)
                {
                    Edge <T> edge = boundary[i];
                    if (NodeIsOnRightSideOfEdge(edge.Cell.Node, edge))
                    {
                        if (edge.Twin.Cell.Node != null && NodeIsOnRightSideOfEdge(edge.Twin.Cell.Node, edge))
                        {
                            positions[i] = Position.right;
                            candidates.AddOuterSplitCell(edge.Cell, edge.BoundaryEdgeNumber);
                        }
                        else
                        {
                            positions[i] = Position.rightUnsplit;
                            candidates.AddOuterUnsplitCell(edge.Cell, edge.BoundaryEdgeNumber);
                        }
                    }
                    else
                    {
                        if (edge.Twin.Cell.Node != null && !NodeIsOnRightSideOfEdge(edge.Twin.Cell.Node, edge))
                        {
                            positions[i] = Position.left;
                            candidates.AddInnerSplitCell(edge.Cell, edge.BoundaryEdgeNumber);
                        }
                        else
                        {
                            positions[i] = Position.leftUnsplit;
                            candidates.AddInnerUnsplitCell(edge.Cell, edge.BoundaryEdgeNumber);
                        }
                    }
                }
                edges.Remove(boundaryNumber);

                boundaryNumber = map.PeriodicBoundaryCorrelation[boundaryNumber];
                boundary       = edges[boundaryNumber];
                for (int i = 0; i < boundary.Count; ++i)
                {
                    Edge <T> edge = boundary[i];
                    switch (positions[boundary.Count - 1 - i])
                    {
                    case Position.left:
                        candidates.AddOuterSplitCell(edge.Cell, edge.BoundaryEdgeNumber);
                        break;

                    case Position.right:
                        candidates.AddInnerSplitCell(edge.Cell, edge.BoundaryEdgeNumber);
                        break;

                    case Position.leftUnsplit:
                        candidates.AddOuterUnsplitCell(edge.Cell, edge.BoundaryEdgeNumber);
                        break;

                    case Position.rightUnsplit:
                        candidates.AddInnerUnsplitCell(edge.Cell, edge.BoundaryEdgeNumber);
                        break;

                    default:
                        throw new Exception();
                    }
                }
                edges.Remove(boundaryNumber);
            }
            return(candidates);
        }
Example #7
0
 void InitializeGlueMapOf(CellPairCollection <T> .EdgeCombo cellsOfABoundary)
 {
     (int outerEdge, int innerEdge, bool glue)[] glueMap = ExtractEdgeGlueMap(cellsOfABoundary);