Exemple #1
0
        protected Grid <Vector2Int, Vector2> MakeScalar(CenterType center, Grid2DConfigure config)
        {
            switch (center)
            {
            case CenterType.CellCentered:
                return(new CellCenteredScalarGrid2D(config.Resolution, config.CellSize, config.Origin));

            case CenterType.VertexCentered:
                return(new VertexCenteredScalarGrid2D(config.Resolution, config.CellSize, config.Origin));

            case CenterType.FaceCentered:
            default:
                Assert.IsFalse(true);
                return(Grid <Vector2Int, Vector2> .NullGrid.Instance);
            }
        }
Exemple #2
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;
        }
Exemple #3
0
        public Grid <Vector2Int, Vector2> MakeGrid2Di(CenterType type, DataType dataType, Grid2DConfigure config)
        {
            Grid <Vector2Int, Vector2> ret = Grid <Vector2Int, Vector2> .NullGrid.Instance;

            switch (dataType)
            {
            case DataType.Scalar:
            {
                if (type == CenterType.CellCentered)
                {
                    ret = new CellCenteredScalarGrid2Di(config.Resolution, config.CellSize, config.Origin);
                }
                else
                {
                    Assert.IsFalse(true);
                }
            }
            break;

            case DataType.Vector:     //no vector int grid for now
            default: Assert.IsFalse(true); break;
            }

            return(ret);
        }
Exemple #4
0
        public Grid <Vector2Int, Vector2> MakeGrid2D(CenterType type, DataType dataType, Grid2DConfigure config)
        {
            Grid <Vector2Int, Vector2> ret = Grid <Vector2Int, Vector2> .NullGrid.Instance;

            switch (dataType)
            {
            case DataType.Scalar: ret = this.MakeScalar(type, config); break;

            case DataType.Vector: ret = this.MakeVector(type, config); break;

            default: Assert.IsFalse(true); break;
            }

            return(ret);
        }