/// <summary> /// get cut cells describing the boundary of this particle /// </summary> /// <param name="LsTrk"></param> /// <returns></returns> public CellMask cutCells_P(LevelSetTracker LsTrk) { // tolerance is very important var radiusTolerance = radius_P + LsTrk.GridDat.Cells.h_minGlobal;// +2.0*Math.Sqrt(2*LsTrk.GridDat.Cells.h_minGlobal.Pow2()); CellMask cellCollection; CellMask cells = null; double alpha = -(currentAng_P[0]); switch (m_shape) { case ParticleShape.spherical: cells = CellMask.GetCellMask(LsTrk.GridDat, X => (-(X[0] - currentPos_P[0][0]).Pow2() + -(X[1] - currentPos_P[0][1]).Pow2() + radiusTolerance.Pow2()) > 0); break; case ParticleShape.elliptic: double a = 3.0; double b = 1.0; cells = CellMask.GetCellMask(LsTrk.GridDat, X => - ((((X[0] - currentPos_P[0][0]) * Math.Cos(alpha) - (X[1] - currentPos_P[0][1]) * Math.Sin(alpha)).Pow2()) / length_P.Pow2()) + -(((X[0] - currentPos_P[0][0]) * Math.Sin(alpha) + (X[1] - currentPos_P[0][1]) * Math.Cos(alpha)).Pow2() / thickness_P.Pow2()) + radiusTolerance.Pow2() > 0); break; case ParticleShape.hippopede: a = 4.0 * radiusTolerance.Pow2(); b = 1.0 * radiusTolerance.Pow2(); cells = CellMask.GetCellMask(LsTrk.GridDat, X => - ((((X[0] - currentPos_P[0][0]) * Math.Cos(alpha) - (X[1] - currentPos_P[0][1]) * Math.Sin(alpha)).Pow(2) + ((X[0] - currentPos_P[0][0]) * Math.Sin(alpha) + (X[1] - currentPos_P[0][1]) * Math.Cos(alpha)).Pow(2)).Pow2() - a * ((X[0] - currentPos_P[0][0]) * Math.Cos(alpha) - (X[1] - currentPos_P[0][1]) * Math.Sin(alpha)).Pow2() - b * ((X[0] - currentPos_P[0][0]) * Math.Sin(alpha) + (X[1] - currentPos_P[0][1]) * Math.Cos(alpha)).Pow2()) > 0); break; case ParticleShape.bean: a = 4.0 * radiusTolerance.Pow2(); b = 1.0 * radiusTolerance.Pow2(); cells = CellMask.GetCellMask(LsTrk.GridDat, X => - ((((X[0] - currentPos_P[0][0]) * Math.Cos(alpha) - (X[1] - currentPos_P[0][1]) * Math.Sin(alpha)).Pow(2) + ((X[0] - currentPos_P[0][0]) * Math.Sin(alpha) + (X[1] - currentPos_P[0][1]) * Math.Cos(alpha)).Pow(2)).Pow2() - a * ((X[0] - currentPos_P[0][0]) * Math.Cos(alpha) - (X[1] - currentPos_P[0][1]) * Math.Sin(alpha)).Pow(3) - b * ((X[0] - currentPos_P[0][0]) * Math.Sin(alpha) + (X[1] - currentPos_P[0][1]) * Math.Cos(alpha)).Pow2()) > 0); break; case ParticleShape.squircle: cells = CellMask.GetCellMask(LsTrk.GridDat, X => - ((((X[0] - currentPos_P[0][0]) * Math.Cos(alpha) - (X[1] - currentPos_P[0][1]) * Math.Sin(alpha)).Pow(4) + ((X[0] - currentPos_P[0][0]) * Math.Sin(alpha) + (X[1] - currentPos_P[0][1]) * Math.Cos(alpha)).Pow(4)) - radiusTolerance.Pow(4)) > 0); break; default: throw new NotImplementedException("Shape is not implemented yet"); } CellMask allCutCells = LsTrk.Regions.GetCutCellMask(); cellCollection = cells.Intersect(allCutCells); return(cellCollection); }
protected override double RunSolverOneStep(int TimestepNo, double phystime, double dt) { origin.ProjectField((x, y) => (Math.Sin(x) + Math.Cos(x) + x - (Math.Cos(y) + 1))); // 2D //origin.ProjectField((x, y, z) => (Math.Sin(x) + Math.Cos(x) + x - (y + 1) + Math.Sin(z))); // 3D //origin.ProjectField((x, y, z) => Math.Sqrt(x.Pow2() + y.Pow2() + z.Pow2()) - 1); //origin.ProjectField((x, y) => x * x + y * y * y - x * y); //origin.ProjectField((x,y) => x + y); //origin.ProjectField((x, y) => Math.Sin(2 * Math.PI * (x / 3.0))); CellMask msk2D = CellMask.GetCellMask((BoSSS.Foundation.Grid.Classic.GridData)(this.GridData), X => (X[0] > 0.0 && X[0] < 4.0 && X[1] > 0.0 && X[1] < 1.0)); //|| (X[0] > 1.0 && X[0] < 3.0 && X[1] > 1.0 && X[1] < 2.0) //|| (X[0] > 2.0 && X[0] < 4.0 && X[1] > 2.0 && X[1] < 3.0) //|| (X[0] > 3.0 && X[0] < 4.0 && X[1] > 3.0 && X[1] < 4.0)); //CellMask msk3D = CellMask.GetCellMask(this.GridData, X => (X[0] > 0.0 && X[0] < 3.0 && X[1] > 0.0 && X[1] < 3.0 && X[2] > 0.0 && X[2] < 1.5) //|| (X[0] > 0.0 && X[0] < 1.5 && X[1] > 0.0 && X[1] < 3.0 && X[2] > 0.0 && X[2] < 3.0) //|| (X[0] > 0.0 && X[0] < 3.0 && X[1] > 0.0 && X[1] < 1.5 && X[2] > 0.0 && X[2] < 3.0)); CellMask test = null; cdgField.ProjectDGField(1.0, origin, test); cdgField.AccToDGField(1.0, result); //specField.ProjectDGField(1.0, origin, test); //specField.AccToDGField(1.0, specFieldDG); //MultidimensionalArray n4 = MultidimensionalArray.Create(3, 2); //n4[0, 0] = 0.3; //n4[0, 1] = -1; //n4[1, 0] = 0.6; //n4[1, 1] = -1; //n4[2, 0] = 0.9; //n4[2, 1] = -1; //MultidimensionalArray n11 = MultidimensionalArray.Create(3, 2); //n11[0, 0] = -0.4; //n11[0, 1] = 1; //n11[1, 0] = 0.2; //n11[1, 1] = 1; //n11[2, 0] = 0.8; //n11[2, 1] = 1; //NodeSet ns4 = new NodeSet(Grid.GetRefElement(0), n4); //NodeSet ns11 = new NodeSet(Grid.GetRefElement(0), n11); //MultidimensionalArray res4 = MultidimensionalArray.Create(1, 3); //MultidimensionalArray res11 = MultidimensionalArray.Create(1, 3); //result.Evaluate(4,1,ns4, res4); //result.Evaluate(11, 1, ns11, res11); PlotCurrentState(0.0, 0, 4); //var err = origin.CloneAs(); //err.Acc(-1.0, result); double L2err = 0.0; //err.L2Norm(); double L2jump = JumpNorm(result, test); Console.WriteLine(""); //double L2jump_specFEM = JumpNorm(specFieldDG, test); //Console.WriteLine("L2 error = " + L2err); Console.WriteLine("L2 Norm of [[u]] = " + L2jump); //Console.WriteLine("L2 Norm of [[u]] = " + L2jump_specFEM); if (L2err < 1.0e-10 && L2jump < 1.0e-12) { Console.WriteLine("Test PASSED"); passed = true; } else { Console.WriteLine("Test FAILED"); passed = false; } base.TerminationKey = true; return(0.0); }