Exemple #1
0
        protected void GridToParticle()
        {
            var sampler = new MacVectorGrid2DSampler();

            for (var i = 0; i < this.CPUData.Length; ++i)
            {
                var pos = this.CPUData[i].position;
                var vel = sampler.Sample(this.velocity, pos);
                this.CPUData[i].velocity = vel;
            }
        }
Exemple #2
0
    static public Vector2 Infnorm(UnityFluid.FaceCenterdVectorGrid2D grid)
    {
        float ru = 0, rv = 0;

        grid.ForEachuData((ref float value, int i, int j) =>
        {
            if (!(Mathf.Abs(value) <= ru))
            {
                ru = Mathf.Abs(value);
            }
        });

        grid.ForEachvData((ref float value, int i, int j) =>
        {
            if (!(Mathf.Abs(value) <= rv))
            {
                rv = Mathf.Abs(value);
            }
        });
        //Debug.Log(ru + " " + rv);
        return(new Vector2(ru, rv));
    }
Exemple #3
0
        protected void InitData()
        {
            Grid2DConfigure config = new Grid2DConfigure();

            config.CellSize   = new Vector2(cellSpace, cellSpace);
            config.Resolution = this.gridSize;

            this.velocity      = factory.MakeGrid2D(GridFactory.CenterType.FaceCentered, GridFactory.DataType.Vector, config) as FaceCenterdVectorGrid2D;
            this.savedVelocity = factory.MakeGrid2D(GridFactory.CenterType.FaceCentered, GridFactory.DataType.Vector, config) as FaceCenterdVectorGrid2D;
            //this.weightSum = factory.MakeGrid2D(GridFactory.CenterType.FaceCentered, GridFactory.DataType.Vector, config) as FaceCenteredGrid2D;

            this.pressure = factory.MakeGrid2D(GridFactory.CenterType.CellCentered, GridFactory.DataType.Scalar, config) as CellCenteredScalarGrid2D;
            this.marker   = factory.MakeGrid2Di(GridFactory.CenterType.CellCentered, GridFactory.DataType.Scalar, config) as CellCenteredScalarGrid2Di;
            this.phi      = factory.MakeGrid2D(GridFactory.CenterType.CellCentered, GridFactory.DataType.Scalar, config) as CellCenteredScalarGrid2D;

            this.poisson        = factory.MakeGrid2D(GridFactory.CenterType.CellCentered, GridFactory.DataType.Vector, config) as CellCenteredVectorGrid2D;
            this.preconditioner = factory.MakeGrid2D(GridFactory.CenterType.CellCentered, GridFactory.DataType.Scalar, config) as CellCenteredScalarGrid2D;

            this.mField = factory.MakeGrid2D(GridFactory.CenterType.CellCentered, GridFactory.DataType.Scalar, config) as CellCenteredScalarGrid2D;
            this.r      = factory.MakeGrid2D(GridFactory.CenterType.CellCentered, GridFactory.DataType.Scalar, config) as CellCenteredScalarGrid2D;
            this.z      = factory.MakeGrid2D(GridFactory.CenterType.CellCentered, GridFactory.DataType.Scalar, config) as CellCenteredScalarGrid2D;
            this.s      = factory.MakeGrid2D(GridFactory.CenterType.CellCentered, GridFactory.DataType.Scalar, config) as CellCenteredScalarGrid2D;
        }