public void CheckForEscapedParticles(MinimalDistanceSearchMode Correction, bool CellPosSure = false) { foreach (ParticlesofCell CellObj in Points) { foreach (KeyValuePair <int, List <SingleLvlSetParticle> > DictEntry in CellObj.ItemList) { foreach (SingleLvlSetParticle SingleParticle in DictEntry.Value) { SingleParticle.Phi = Evaluate(new DGField[] { Interface }, SingleParticle.Coordinates, CellObj.CellIndex, CellPosSure); MultidimensionalArray Normal_new = AdjustNormal(SingleParticle.Coordinates, CellObj.CellIndex, CellPosSure); if (DotProduct(SingleParticle.Normal, Normal_new) < 0.0) { SingleParticle.Active = false; } SingleParticle.Normal = Normal_new; if (SingleParticle.Escaped == false && -1 * DictEntry.Key * SingleParticle.Phi[0, 0] >= SingleParticle.Radius) { SingleParticle.Escaped = true; } if (SingleParticle.Escaped == true && -1 * DictEntry.Key * SingleParticle.Phi[0, 0] < SingleParticle.Radius) { SingleParticle.Escaped = false; } } } } }
public FrontTrackingLevelSet2D(VectorField <SinglePhaseField> Velocity_New, VectorField <SinglePhaseField> Velocity_Old, SinglePhaseField Interface, LevelSetTracker InterfaceTrck, VectorField <SinglePhaseField> LevelSetGradient, int max_AddandAttract_Iteration, int NarrowBandWidth, IGridData Grid, bool LevelSetCorrectionWithNeighbourCells, int ReseedingInterval, MinimalDistanceSearchMode LevelSetCorrection, TopologyMergingMode TopologyMerging, NormalVectorDampingMode NormalVectorDamping, double EdgeLengthToCurvatureFraction) : base(Velocity_New, Velocity_Old, Interface, InterfaceTrck, LevelSetGradient, NarrowBandWidth, Grid, ReseedingInterval, LevelSetCorrection, TopologyMerging, NormalVectorDamping, 1) { this.EdgeLengthToCurvatureFraction = EdgeLengthToCurvatureFraction; }
public bool AddVerticeToMemory(SingleVertice Vertice, int CellIndexGuess, MinimalDistanceSearchMode LevelSetCorrection) { int CellIndex; if ((CellIndex = FindCellIndexofPoint(Vertice.Coordinates, CellIndexGuess)) == -1) { return(false); } if (CelltoArrayindex.ContainsKey(CellIndex)) { Points[CelltoArrayindex[CellIndex]].ItemList[1].Add(Vertice); //Console.Write("Added Vertice to Cell: " + CellIndex); } else { Points.Add(new VerticesofCell(CellIndex, Grid, LevelSetCorrection)); CelltoArrayindex[CellIndex] = Points.Count - 1; Points[CelltoArrayindex[CellIndex]].ItemList[1].Add(Vertice); } return(true); }
protected override ParticlesofCell NewPointsofCellObject(int CellIndex, IGridData Grid, MinimalDistanceSearchMode LevelSetCorrection) { return(new ParticlesofCell(CellIndex, Grid, LevelSetCorrection, FilterDepth)); }
public void CheckForEscapedParticles_Fast(MinimalDistanceSearchMode Correction, bool CellPosSure = false) { DGField[] Fields = new DGField[1 + SpatialDimension]; Fields[0] = Interface; for (int dim = 0; dim < SpatialDimension; dim++) { Fields[1 + dim] = InterfaceLevelSetGradient[dim]; } MultidimensionalArray Results; foreach (ParticlesofCell CellObj in Points) { int TotalNbrOfPoints = 0; Dictionary <int, int> NbrofPointsperType = new Dictionary <int, int>(); foreach (KeyValuePair <int, List <SingleLvlSetParticle> > DictEntry in CellObj.ItemList) { TotalNbrOfPoints += DictEntry.Value.Count; NbrofPointsperType.Add(DictEntry.Key, DictEntry.Value.Count); } MultidimensionalArray PointsCoordinates = MultidimensionalArray.Create(TotalNbrOfPoints, SpatialDimension); int indx = 0; foreach (KeyValuePair <int, List <SingleLvlSetParticle> > DictEntry in CellObj.ItemList) { for (int k = 0; k < NbrofPointsperType[DictEntry.Key]; k++) { for (int dim = 0; dim < SpatialDimension; dim++) { PointsCoordinates[indx, dim] = DictEntry.Value[k].Coordinates[0, dim]; } indx++; } } Results = MultiEvaluatePointsInCell(Fields, PointsCoordinates, CellObj.CellIndex, CellPosSure); indx = 0; foreach (KeyValuePair <int, List <SingleLvlSetParticle> > DictEntry in CellObj.ItemList) { foreach (SingleLvlSetParticle SingleParticle in DictEntry.Value) { SingleParticle.Phi[0, 0] = Results[0, indx]; MultidimensionalArray Normal_new = MultidimensionalArray.Create(1, SpatialDimension); for (int dim = 0; dim < SpatialDimension; dim++) { Normal_new[0, dim] = Results[dim + 1, indx]; } Normal_new = NormalizeVector(Normal_new); if (DotProduct(SingleParticle.Normal, Normal_new) < 0.0) { SingleParticle.Active = false; } SingleParticle.Normal = Normal_new; if (SingleParticle.Escaped == false && -1 * DictEntry.Key * SingleParticle.Phi[0, 0] >= SingleParticle.Radius) { SingleParticle.Escaped = true; } if (SingleParticle.Escaped == true && -1 * DictEntry.Key * SingleParticle.Phi[0, 0] < SingleParticle.Radius) { SingleParticle.Escaped = false; } indx++; } } } }
public ParticleLevelSet(VectorField <SinglePhaseField> Velocity_New, VectorField <SinglePhaseField> Velocity_Old, SinglePhaseField Interface, LevelSetTracker InterfaceTrck, VectorField <SinglePhaseField> LevelSetGradient, int TargetNbrParticlesPerCell, int UpperLimitParticlesPerCell, int LowerLimitParticlesPerCell, double Band_max, double Band_min, double Radius_max, double Radius_min, int max_AddandAttract_Iteration, int NarrowBandWidth, IGridData Grid, bool LevelSetCorrectionWithNeighbourCells, int ReseedingInterval, MinimalDistanceSearchMode LevelSetCorrection, TopologyMergingMode TopologyMerging, NormalVectorDampingMode NormalVectorDamping) : base(Velocity_New, Velocity_Old, Interface, InterfaceTrck, LevelSetGradient, NarrowBandWidth, Grid, ReseedingInterval, LevelSetCorrection, TopologyMerging, NormalVectorDamping, TargetNbrParticlesPerCell, UpperLimitParticlesPerCell, LowerLimitParticlesPerCell) { if (TargetNbrParticlesPerCell <= 0) { throw new Exception("Target number of particles per cell must not be lower than 1."); } if (TargetNbrParticlesPerCell > UpperLimitParticlesPerCell) { throw new Exception("The upper limit of particles per cell must be equal or higher than the target number of particles per cell."); } if (TargetNbrParticlesPerCell < LowerLimitParticlesPerCell) { throw new Exception("The lower limit of particles per cell must be equal or lower than the target number of particles per cell."); } this.Band_max = Band_max; this.Band_min = Band_min; this.Radius_max = Radius_max; this.Radius_min = Radius_min; this.max_AddandAttract_Iteration = max_AddandAttract_Iteration; CorrectionCells = InterfaceTracker.Regions.GetNearFieldMask(1); ReseedingWdith = NarrowBandWidth; Reinitialization = new FastMarchReinit(Interface.Basis); }
protected override VerticesofCell NewPointsofCellObject(int CellIndex, IGridData Grid, MinimalDistanceSearchMode LevelSetCorrection) { return(new VerticesofCell(CellIndex, Grid, LevelSetCorrection)); }