Beispiel #1
0
        /// <summary>
        /// See also <see cref="GRID_CASE"/> and <see cref="GRID_FILE"/>.
        /// </summary>
        protected override GridCommons CreateOrLoadGrid()
        {
            GridCommons grd;

            switch (GRID_CASE)
            {
            case 1:
                grd = Grid1D.LineGrid(GenericBlas.Linspace(-4, 4, 5));
                break;


            case 2: {
                grd = Grid1D.LineGrid(GenericBlas.Linspace(-4, 4, 20));
                break;
            }

            case 3: {
                double[] xnodes = new double[] { -2, 0, 2 };
                double[] ynodes = new double[] { -2, 0, 2 };
                double   dx     = xnodes[1] - xnodes[0];
                double   dy     = ynodes[1] - ynodes[0];
                //this.CellVolume = dx * dy;
                //if(Math.Abs(dx - dy) <= 1.0e-12)
                //    EdgeArea = dx;
                grd = Grid2D.Cartesian2DGrid(xnodes, ynodes, periodicX: false, periodicY: false, type: CellType.Square_4);
                break;
            }

            case 4: {
                double[] xnodes = GenericBlas.Linspace(-1, 5, 9);
                double[] ynodes = GenericBlas.Linspace(-1, 5, 13);
                double   dx     = xnodes[1] - xnodes[0];
                double   dy     = ynodes[1] - ynodes[0];
                this.CellVolume = dx * dy;
                if (Math.Abs(dx - dy) <= 1.0e-12)
                {
                    EdgeArea = dx;
                }
                grd = Grid2D.Cartesian2DGrid(xnodes, ynodes, periodicX: false, periodicY: false, type: CellType.Square_4);
                break;
            }

            case 5: {
                double[] xnodes = GenericBlas.Linspace(-1, 1, 8);
                double[] ynodes = GenericBlas.Linspace(-1, 1, 13);
                grd = Grid2D.UnstructuredTriangleGrid(xnodes, ynodes, JitterScale: 0.5);
                break;
            }

            case 6: {
                grd = Circle();
                break;
            }

            case 7: {
                // test periodicity

                grd       = Grid2D.CurvedSquareGrid(GenericBlas.Linspace(1, 2, 4), GenericBlas.Linspace(0, 0.25, 10), CellType.Square_9, PeriodicS: true);
                AltRefSol = true;
                break;
            }

            case 8: {
                double[] rNodes = GenericBlas.Linspace(1, 4, 8);
                double[] sNodes = GenericBlas.Linspace(0, 0.5, 15);
                grd = Grid2D.CurvedSquareGrid(rNodes, sNodes, CellType.Square_4, PeriodicS: false);
                break;
            }

            case 9: {
                double[] xNodes1 = GenericBlas.Linspace(-1, 0.3, 7);
                double[] yNodes1 = GenericBlas.Linspace(-1, 1, 13);
                double[] xNodes2 = GenericBlas.Linspace(0.3, 1, 5);
                double[] yNodes2 = GenericBlas.Linspace(-1, 1, 25);
                double[] xNodes3 = GenericBlas.Linspace(-1, 1, 8);
                double[] yNodes3 = GenericBlas.Linspace(-2, -1, 5);

                var grd1 = Grid2D.Cartesian2DGrid(xNodes1, yNodes1, type: CellType.Square_Linear);
                var grd2 = Grid2D.Cartesian2DGrid(xNodes2, yNodes2, type: CellType.Square_Linear);
                var grd3 = Grid2D.Cartesian2DGrid(xNodes3, yNodes3, type: CellType.Square_Linear);
                var grdJ = GridCommons.MergeLogically(grd1, GridCommons.MergeLogically(grd2, grd3));
                grd = GridCommons.Seal(grdJ, 4);

                break;
            }

            case 10: {
                double[] xNodes1 = GenericBlas.Linspace(-1, 0.3, 4);
                double[] xNodes2 = GenericBlas.Linspace(0.3, 1, 5);

                double[] yNodes1 = GenericBlas.Linspace(-1, 1, 9);
                double[] yNodes2 = GenericBlas.Linspace(-1, 1, 5);

                double[] zNodes1 = GenericBlas.Linspace(-1, 1, 5);
                double[] zNodes2 = GenericBlas.Linspace(-1, 1, 3);

                var grd1 = Grid3D.Cartesian3DGrid(xNodes1, yNodes1, zNodes1);
                var grd2 = Grid3D.Cartesian3DGrid(xNodes2, yNodes2, zNodes2);
                var grdJ = GridCommons.MergeLogically(grd1, grd2);
                grd = GridCommons.Seal(grdJ, 4);


                break;
            }

            case 11: {
                grd = Grid2D.Trapezoidal2dGrid(4, 2, 2, GenericBlas.Linspace(0, 1, 2));
                break;
            }

            case 12: {
                var grid1 = Grid2D.Cartesian2DGrid(GenericBlas.Linspace(-3, 5, 5), GenericBlas.Linspace(-1, 1, 2));
                //grd = base_grid;
                //grid1.Plot2DGrid();


                var gdat1 = new GridData(grid1);
                var grid2 = gdat1.Adapt(new int[] { 1, 2 }, null, out GridCorrelation o2c_1);
                //grid2.Plot2DGrid();

                var gdat2 = new GridData(grid2);
                var grid3 = gdat2.Adapt(new int[] { 2, 4 }, null, out GridCorrelation o2c_2);
                //grid3.Plot2DGrid();

                var gdat3 = new GridData(grid3);
                var grid4 = gdat3.Adapt(new int[] { 11, 14, 15 }, null, out GridCorrelation o2c_3);
                //grid4.Plot2DGrid();

                var gdat4 = new GridData(grid4);
                var grid5 = gdat4.Adapt(new[] { 4, 21, 22, 10 }, new[] { new[] { 13, 14, 15, 16 } }, out GridCorrelation o2c_4);

                //grid5.Plot2DGrid();

                grd = grid5;

                break;
            }

            case 13: {
                double[] rNodes = GenericBlas.Linspace(1, 4, 8);
                double[] sNodes = GenericBlas.Linspace(0, 0.5, 15);
                grd = Grid2D.CurvedSquareGrid(rNodes, sNodes, CellType.Square_9, PeriodicS: false);
                break;
            }

            case 14: {
                double[] rNodes = GenericBlas.Linspace(1, 4, 13);
                double[] sNodes = GenericBlas.Linspace(0, 0.5, 25);
                grd = Grid2D.CurvedSquareGrid(rNodes, sNodes, CellType.Square_16, PeriodicS: false);
                break;
            }

            case 15: {
                double[] rNodes = GenericBlas.Linspace(1, 2, 4);
                double[] sNodes = GenericBlas.Linspace(0, 0.5, 4);
                double[] zNodes = GenericBlas.Linspace(-1, 1, 5);
                grd = Grid3D.CylinderGrid(rNodes, sNodes, zNodes, CellType.Cube_27, PeriodicS: false, PeriodicZ: false);
                break;
            }

            case 16: {
                grd = Grid2D.Ogrid(0.5, 1, 5, 3, CellType.Square_4);
                break;
            }

            case 17: {
                grd = Grid3D.Ogrid(0.5, 1, 3, 3, GenericBlas.Linspace(0, 4, 3));
                break;
            }

            case 18: {
                // aggregation grid
                double[] xNodes = GenericBlas.Linspace(-1, 1, 5);
                double[] yNodes = GenericBlas.Linspace(-1, 1, 5);

                var baseGrid = Grid2D.UnstructuredTriangleGrid(xNodes, yNodes);
                var baseGdat = new GridData(baseGrid);
                var aggGrid  = CoarseningAlgorithms.Coarsen(baseGdat, 2);
                base.AggGrid = aggGrid;
                grd          = null;

                double dx = xNodes[1] - xNodes[0];
                double dy = yNodes[1] - yNodes[0];
                this.CellVolume = dx * dy;
                if (Math.Abs(dx - dy) <= 1.0e-12)
                {
                    EdgeArea = dx;
                }


                break;
            }

            // ++++++++++++++++++++++++++++++++++++++++++++++++++++
            // more expensive grids (not tested in DEBUG MODE)
            // ++++++++++++++++++++++++++++++++++++++++++++++++++++

            case 30: {
                double[] xnodes = GenericBlas.Linspace(-1, 1, 7);
                double[] ynodes = GenericBlas.Linspace(-1, 1, 9);
                double[] znodes = GenericBlas.Linspace(-1, 1, 8);
                grd = Grid3D.Cartesian3DGrid(xnodes, ynodes, znodes, periodicX: false, periodicY: false, periodicZ: false);
                break;
            }



            // +++++++++++++++++++++++++++++++++
            // grids imported from GMSH/CGNS
            // +++++++++++++++++++++++++++++++++

            case 50: {
                // gmsh grid import test

                Console.WriteLine("Loading file: '" + GRID_FILE + "'...");
                grd = GridImporter.Import(GRID_FILE);
                //Console.WriteLine("done. " + grd.NoOfUpdateCells.MPISum() + " cells loaded.");

                //Plot2dGridGnuplot(grd);

                HashSet <CellType> cellTypes = new HashSet <CellType>();
                foreach (var cell in grd.Cells)
                {
                    if (!cellTypes.Contains(cell.Type))
                    {
                        cellTypes.Add(cell.Type);
                    }
                }
                Console.Write("Cell types: ");
                foreach (var ct in cellTypes)
                {
                    Console.Write(ct);
                    Console.Write(" ");
                }
                Console.WriteLine();


                break;
            }

            default:
                throw new NotSupportedException();
            }
            return(grd);
        }
Beispiel #2
0
        // 4:1 Contraction Flow
        static public RheologyControl Contraction(string path = @"\\dc1\userspace\kikker\cluster\cluster_db\ContractionNYC", int degree = 1, int GridLevel = 3)   //int kelem = 4
        {
            RheologyControl C = new RheologyControl();

            //Path für cluster
            //\\dc1\userspace\kikker\cluster\cluster_db\ContractionNYC

            //Path für lokale DB
            //C:\AnnesBoSSSdb\Contraction

            //Solver Options
            C.NoOfTimesteps      = 15;
            C.savetodb           = true;
            C.DbPath             = path;
            C.ProjectName        = "Contration";
            C.MaxIter            = 50;
            C.MinIter            = 1;
            C.ConvCrit           = 1E-7;
            C.dt                 = 1E20;
            C.dtMax              = C.dt;
            C.dtMin              = C.dt;
            C.Timestepper_Scheme = RheologyControl.TimesteppingScheme.ImplicitEuler;
            C.NonlinearMethod    = NonlinearSolverMethod.NewtonGMRES;
            C.ObjectiveParam     = 1.0;

            //Debugging and Solver Analysis
            C.OperatorMatrixAnalysis       = false;
            C.SkipSolveAndEvaluateResidual = false;
            C.SetInitialConditions         = true;
            C.SetInitialPressure           = false;
            C.SetParamsAnalyticalSol       = false;
            C.ComputeL2Error = false;

            //Physical Params
            C.Stokes = false;
            C.FixedStreamwisePeriodicBC = false;
            C.beta             = 0.11;
            C.Reynolds         = 1;
            C.Weissenberg      = 0.1;
            C.RaiseWeissenberg = true;

            //Grid Params
            //double GridLevel = 5;
            double h      = Math.Pow(2, -GridLevel + 1);
            double cells  = 1 / h;
            int    cells2 = (int)cells;

            //Penalties
            C.ViscousPenaltyScaling = 1;
            C.Penalty2        = 1;
            C.Penalty1[0]     = 0.0;
            C.Penalty1[1]     = 0.0;
            C.PresPenalty2    = 1;
            C.PresPenalty1[0] = 0.0;
            C.PresPenalty1[1] = 0.0;


            //Exact Solution Contraction

            // Set Initial Conditions
            Func <double[], double, double> VelocityXfunction = (X, t) => ((3 / 2) * 4 * (1 - (X[1] * X[1]) / 4)); //(4 - X[1] * X[1]);
            Func <double[], double, double> VelocityYfunction = (X, t) => (0.0);
            Func <double[], double, double> Pressurefunction  = (X, t) => 2 / C.Reynolds * (20 - X[0]);
            Func <double[], double, double> StressXXfunction  = (X, t) => 2 * C.Weissenberg * (1 - C.beta) * (((-2 * X[1])) * ((-2 * X[1])));
            Func <double[], double, double> StressXYfunction  = (X, t) => (1 - C.beta) * ((-2 * X[1]));
            Func <double[], double, double> StressYYfunction  = (X, t) => (0.0);

            // Insert Exact Solution
            C.ExSol_Velocity = new Func <double[], double, double>[] { VelocityXfunction, VelocityYfunction };
            C.ExSol_Pressure = Pressurefunction;
            C.ExSol_Stress   = new Func <double[], double, double>[] { StressXXfunction, StressXYfunction, StressYYfunction };

            // Create Fields
            //int degree = 2;
            C.FieldOptions.Add("VelocityX", new FieldOpts()
            {
                Degree = degree, SaveToDB = FieldOpts.SaveToDBOpt.TRUE
            });
            C.FieldOptions.Add("VelocityY", new FieldOpts()
            {
                Degree = degree, SaveToDB = FieldOpts.SaveToDBOpt.TRUE
            });
            C.FieldOptions.Add("Pressure", new FieldOpts()
            {
                Degree = degree - 1, SaveToDB = FieldOpts.SaveToDBOpt.TRUE
            });

            C.FieldOptions.Add("StressXX", new FieldOpts()
            {
                Degree = degree, SaveToDB = FieldOpts.SaveToDBOpt.TRUE
            });
            C.FieldOptions.Add("StressXY", new FieldOpts()
            {
                Degree = degree, SaveToDB = FieldOpts.SaveToDBOpt.TRUE
            });
            C.FieldOptions.Add("StressYY", new FieldOpts()
            {
                Degree = degree, SaveToDB = FieldOpts.SaveToDBOpt.TRUE
            });
            C.FieldOptions.Add("PhiDG", new FieldOpts()
            {
                Degree = degree, SaveToDB = FieldOpts.SaveToDBOpt.TRUE
            });
            C.FieldOptions.Add("Phi", new FieldOpts()
            {
                Degree = degree, SaveToDB = FieldOpts.SaveToDBOpt.TRUE
            });

            // Create Grid

            double[] pt1a = new double[] { 10, 0.5 };
            double[] pt1b = new double[] { 20, 2 };

            BoundingBox boundingBox1;

            boundingBox1 = new BoundingBox(pt1a, pt1b);

            double[] pt2a = new double[] { 10, -0.5 };
            double[] pt2b = new double[] { 20, -2 };

            BoundingBox boundingBox2;

            boundingBox2 = new BoundingBox(pt2a, pt2b);

            C.GridFunc = delegate
            {
                // UNIFORM CARTESIAN GRID
                //var _xNodes = GenericBlas.Linspace(0, 20, cells2 + 1);// 10 * GridLevel + 1); //(10 * kelem + 1));
                //var _yNodes = GenericBlas.Linspace(-2, 2, (cells2 / 4) + 1);// (int)(2 * 1.5 * GridLevel) + GridLevel + 1); //(int)((2 * 1.5 * kelem) + kelem + 1));

                // NON_UNIFORM CARTESIAN GRID
                //var _xNodes1 = Grid1D.TanhSpacing(0, 10, (cells2 / 4) + 1, 2, false);
                //_xNodes1 = _xNodes1.GetSubVector(0, (_xNodes1.Length - 1));
                //var _xNodes2 = Grid1D.TanhSpacing(10, 20, (cells2 / 4) + 1, 2, true);
                //var _xNodes = ArrayTools.Cat(_xNodes1, _xNodes2);

                //var _yNodes1 = Grid1D.TanhSpacing(0, 0.5, (cells2 / 6) + 1, 1.5, false);
                //_yNodes1 = _yNodes1.GetSubVector(0, (_yNodes1.Length - 1));
                //var _yNodes2 = Grid1D.TanhSpacing(0.5, 2, (6 * cells2 / 16) + 1, 1.5, true);
                ////var _yNodes = ArrayTools.Cat(_yNodes1, _yNodes2);

                //var _yNodes3 = Grid1D.TanhSpacing(-0.5, 0, (cells2 / 6) + 1, 1.5, true);
                //_yNodes3 = _yNodes3.GetSubVector(0, (_yNodes3.Length - 1));
                //var _yNodes4 = Grid1D.TanhSpacing(-2, -0.5, (6 * cells2 / 16) + 1, 1.5, false);
                //_yNodes4 = _yNodes4.GetSubVector(0, (_yNodes4.Length - 1));
                //var _yNodes = ArrayTools.Cat(_yNodes4, _yNodes3, _yNodes1, _yNodes2);

                //var grd = Grid2D.Cartesian2DGrid(_xNodes, _yNodes, CellType.Square_Linear, C.FixedStreamwisePeriodicBC, false, boundingBox1, boundingBox2);

                //// CARTESIAN GRID WITH HANGING NODES REFINEMENT
                double[] ecke = new double[] { 10, 0.5 };

                var boxA1_p1 = new double[2] {
                    0, -2
                };
                var boxA1_p2 = new double[2] {
                    10, 2
                };
                var boxA1 = new GridCommons.GridBox(boxA1_p1, boxA1_p2, 2 * 40, 2 * 16);

                var boxA2_p1 = new double[2] {
                    9, -1
                };
                var boxA2_p2 = new double[2] {
                    10, 1
                };
                //var boxA2_p1 = new double[2] { ecke[0] - 0.5, ecke[1] - 0.25 };
                //var boxA2_p2 = new double[2] { ecke[0], ecke[1] + 0.25 };
                var boxA2 = new GridCommons.GridBox(boxA2_p1, boxA2_p2, 2 * 8, 2 * 16);

                var boxA3_p1 = new double[2] {
                    9.5, -0.75
                };
                var boxA3_p2 = new double[2] {
                    10, 0.75
                };
                var boxA3 = new GridCommons.GridBox(boxA3_p1, boxA3_p2, 2 * 8, 2 * 24);

                var grdA = Grid2D.HangingNodes2D(boxA1, boxA2, boxA3);

                var boxB1_p1 = new double[2] {
                    10, -0.5
                };
                var boxB1_p2 = new double[2] {
                    20, 0.5
                };
                var boxB1 = new GridCommons.GridBox(boxB1_p1, boxB1_p2, 2 * 40, 2 * 4);

                var boxB2_p1 = new double[2] {
                    10, -0.5
                };
                var boxB2_p2 = new double[2] {
                    11, 0.5
                };
                var boxB2 = new GridCommons.GridBox(boxB2_p1, boxB2_p2, 2 * 8, 2 * 8);

                var boxB3_p1 = new double[2] {
                    10, -0.5
                };
                var boxB3_p2 = new double[2] {
                    10.5, 0.5
                };
                var boxB3 = new GridCommons.GridBox(boxB3_p1, boxB3_p2, 2 * 8, 2 * 16);

                var grdB = Grid2D.HangingNodes2D(boxB1, boxB2, boxB3);

                var grdM = GridCommons.MergeLogically(grdA, grdB);
                var grd  = GridCommons.Seal(grdM);

                // COARSE CARTESIAN GRID WITH HANGING NODES REFINEMENT - FOR DEBUGGING!
                //double[] ecke = new double[] { 10, 0.5 };

                //var boxA1_p1 = new double[2] { 0, -2 };
                //var boxA1_p2 = new double[2] { 10, 2 };
                //var boxA1 = new GridCommons.GridBox(boxA1_p1, boxA1_p2, 2 * 10, 2 * 4);

                //var boxA2_p1 = new double[2] { 9, -1 };
                //var boxA2_p2 = new double[2] { 10, 1 };
                ////var boxA2_p1 = new double[2] { ecke[0] - 0.5, ecke[1] - 0.25 };
                ////var boxA2_p2 = new double[2] { ecke[0], ecke[1] + 0.25 };
                //var boxA2 = new GridCommons.GridBox(boxA2_p1, boxA2_p2, 2 * 2, 2 * 4);

                ////var boxA3_p1 = new double[2] { 9.5, -0.75 };
                ////var boxA3_p2 = new double[2] { 10, 0.75 };
                ////var boxA3 = new GridCommons.GridBox(boxA3_p1, boxA3_p2, 2 * 4, 2 * 12);

                //var grdA = Grid2D.HangingNodes2D(boxA1, boxA2);

                //var boxB1_p1 = new double[2] { 10, -0.5 };
                //var boxB1_p2 = new double[2] { 20, 0.5 };
                //var boxB1 = new GridCommons.GridBox(boxB1_p1, boxB1_p2, 2 * 10, 2 * 1);

                //var boxB2_p1 = new double[2] { 10, -0.5 };
                //var boxB2_p2 = new double[2] { 11, 0.5 };
                //var boxB2 = new GridCommons.GridBox(boxB2_p1, boxB2_p2, 2 * 2, 2 * 2);

                ////var boxB3_p1 = new double[2] { 10, -0.5 };
                ////var boxB3_p2 = new double[2] { 10.5, 0.5 };
                ////var boxB3 = new GridCommons.GridBox(boxB3_p1, boxB3_p2, 2 * 4, 2 * 8);

                //var grdB = Grid2D.HangingNodes2D(boxB1, boxB2);

                //var grdM = GridCommons.MergeLogically(grdA, grdB);
                //var grd = GridCommons.Seal(grdM);

                if (!C.FixedStreamwisePeriodicBC)
                {
                    grd.EdgeTagNames.Add(1, "Velocity_inlet");
                    grd.EdgeTagNames.Add(4, "Pressure_Outlet");
                }

                //grd.EdgeTagNames.Add(2, "FreeSlip");
                grd.EdgeTagNames.Add(2, "Wall_bottom");
                grd.EdgeTagNames.Add(3, "Wall_top");


                grd.EdgeTagNames.Add(5, "Wall_Contraction_bottom");
                grd.EdgeTagNames.Add(6, "Wall_Contraction_top");

                grd.DefineEdgeTags(delegate(double[] _X)
                {
                    var X    = _X;
                    double x = X[0];
                    double y = X[1];

                    if (!C.FixedStreamwisePeriodicBC)
                    {
                        if (Math.Abs(x - (0)) < 1.0e-6)
                        {
                            //left
                            return(1);
                        }

                        if (Math.Abs(x - (20)) < 1.0e-6)
                        {
                            //right
                            return(4);
                        }
                    }

                    if (Math.Abs(y - (-2)) < 1.0e-6 && x < 10 + 1.0e-6)
                    {
                        //bottom front
                        return(2);
                    }

                    //if (Math.Abs(y - (0)) < 1.0e-6)
                    //{
                    //    //symmetry line
                    //    return 2;
                    //}

                    if (Math.Abs(y - (+2)) < 1.0e-6 && x < 10 + 1.0e-6)
                    {
                        //top front
                        return(3);
                    }

                    if (Math.Abs(y - (-0.5)) < 1.0e-6 && x > 10 - 1.0e-6)
                    {
                        // bottom back
                        return(2);
                    }

                    if (Math.Abs(y - (+0.5)) < 1.0e-6 && x > 10 - 1.0e-6)
                    {
                        // top back
                        return(3);
                    }

                    if (Math.Abs(x - (10)) < 1.0e-6 && y < -0.5 - 1.0e-6)
                    {
                        // bottom contraction
                        return(5);
                    }

                    if (Math.Abs(x - (10)) < 1.0e-6 && y > 0.5 - 1.0e-6)
                    {
                        //top contraction
                        return(6);
                    }

                    throw new ArgumentOutOfRangeException("at x = " + x + "and y = " + y);
                });


                return(grd);
            };


            // Analytical Sol for Params
            if (C.SetParamsAnalyticalSol == true)
            {
                C.VelFunctionU = X => VelocityXfunction(X, 0);
                C.VelFunctionV = X => VelocityYfunction(X, 0);
                C.PresFunction = X => Pressurefunction(X, 0);
            }

            // Set Initial Conditions
            if (C.SetInitialConditions == true)
            {
                C.InitialValues_Evaluators.Add("VelocityX", X => VelocityXfunction(X, 0));
                C.InitialValues_Evaluators.Add("VelocityY", X => VelocityYfunction(X, 0));
                C.InitialValues_Evaluators.Add("StressXX", X => StressXXfunction(X, 0));
                C.InitialValues_Evaluators.Add("StressXY", X => StressXYfunction(X, 0));
                C.InitialValues_Evaluators.Add("StressYY", X => StressYYfunction(X, 0));

                if (C.SetInitialPressure == true || C.SkipSolveAndEvaluateResidual == true)
                {
                    C.InitialValues_Evaluators.Add("Pressure", X => Pressurefunction(X, 0));
                }
            }

            C.InitialValues_Evaluators.Add("Phi", X => - 1);

            // Set Boundary Conditions
            C.AddBoundaryValue("Wall_bottom");
            C.AddBoundaryValue("Wall_top");
            C.AddBoundaryValue("Wall_Contraction_bottom");
            C.AddBoundaryValue("Wall_Contraction_top");
            //C.AddBoundaryCondition("FreeSlip");


            if (!C.FixedStreamwisePeriodicBC)
            {
                C.AddBoundaryValue("Velocity_inlet", "VelocityX", VelocityXfunction);
                C.AddBoundaryValue("Velocity_inlet", "VelocityY", VelocityYfunction);
                C.AddBoundaryValue("Velocity_inlet", "StressXX", StressXXfunction);
                C.AddBoundaryValue("Velocity_inlet", "StressXY", StressXYfunction);
                C.AddBoundaryValue("Velocity_inlet", "StressYY", StressYYfunction);
                //C.AddBoundaryCondition("Velocity_inlet", "Pressure", Pressurefunction);
                C.AddBoundaryValue("Pressure_Outlet");
            }
            return(C);
        }