コード例 #1
0
        public override void Execute()
        {
            var grid = GridImporter.ImportGrid(sourceEpsgCode, rutenettType, dataFile);

            GridImporter.BulkStore(grid);
            Log.i("DB", $"Imported {grid.Cells.Count} cells from {dataFile}.");
        }
コード例 #2
0
        private static void ImportGrid(string shapeFilePath, int sourceEpsgCode, RutenettType rutenettType)
        {
            string fullPath = FileLocator.FindFileInTree(Path.Combine(@"Data\Grid\SSB", shapeFilePath));

            var grid = GridImporter.ImportGrid(sourceEpsgCode, rutenettType, fullPath);

            GridImporter.BulkStore(grid);
        }
コード例 #3
0
        /// <summary>
        /// Imports the grid stored at the given location into
        /// <paramref name="database"/>.
        /// </summary>
        /// <param name="database">
        /// The database where the grid should be stored
        /// </param>
        /// <param name="fileName">
        /// The path to the grid file
        /// </param>
        /// <param name="test">
        /// If set to true, a <see cref="GridData"/> object is created in order to do more extensive testing on the imported grid.
        /// </param>
        /// <returns>
        /// The newly imported grid
        /// </returns>
        public static IGridInfo ImportGrid(this IDatabaseInfo database, string fileName, bool test = true)
        {
            GridCommons grid = GridImporter.Import(fileName);

            if (test)
            {
                new GridData(grid);
            }
            database.Controller.SaveGridInfo(grid);
            return(grid);
        }
コード例 #4
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);
        }
コード例 #5
0
        //__________________________________________________________________________________________________________________

        // Confined cylinder in a channel flow
        static public RheologyControl ConfinedCylinder(string path = @"\\dc1\userspace\kikker\cluster\cluster_db\ConfinedCylinder", int degree = 3)
        {
            RheologyControl C = new RheologyControl();

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

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

            //Solver Options
            C.NoOfTimesteps = 1;
            C.savetodb      = true;
            C.DbPath        = path;
            C.ProjectName   = "Cylinder";
            C.MaxIter       = 100;
            C.MinIter       = 1;
            C.ConvCrit      = 1E-6;
            //C.UnderRelax = 1.0;
            C.dt    = 1E20;
            C.dtMax = C.dt;
            C.dtMin = C.dt;
            C.Timestepper_Scheme = RheologyControl.TimesteppingScheme.ImplicitEuler;
            C.NonlinearMethod    = NonlinearSolverMethod.Newton;
            C.ObjectiveParam     = 1.0;

            C.UsePerssonSensor = true;
            C.SensorLimit      = 1e-4;

            C.AdaptiveMeshRefinement = false;
            C.RefinementLevel        = 10;

            C.UseArtificialDiffusion = true;

            C.Bodyforces = true;

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

            //Physical Params
            double u0 = 1.5; // 0.375;// 0.66;// 3 / 2;
            double h  = 4;

            C.Stokes = false;
            C.FixedStreamwisePeriodicBC = false;
            C.beta                 = 0.59;
            C.Reynolds             = 1;
            C.Weissenberg          = 0.1; //aim Weissenberg number!
            C.RaiseWeissenberg     = true;
            C.WeissenbergIncrement = 0.1;

            //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;
            C.alpha           = 1;
            C.StressPenalty   = 1.0;

            //Exact Solution Confined Cylinder

            // Set Initial Conditions / Boundary Conditions
            Func <double[], double, double> VelocityXfunction = (X, t) => u0 * (1 - (X[1] * X[1]) / h);
            Func <double[], double, double> VelocityYfunction = (X, t) => 0.0;
            Func <double[], double, double> Pressurefunction  = (X, t) => u0 * 0.5 * C.Reynolds * (35 - X[0]);
            //since C.Weissenberg is the aim Weissenberg, StressXX must be zero -> would be wrong for first Newtonian shot!
            Func <double[], double, double> StressXXfunction = (X, t) => 2 * C.Weissenberg * (1 - C.beta) * u0 * (-2 / h) * X[1] * u0 * (-2 / h) * X[1];
            Func <double[], double, double> StressXYfunction = (X, t) => (1 - C.beta) * u0 * (-2 / h) * 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("ResidualMomentumX", new FieldOpts()
            {
                Degree = degree, SaveToDB = FieldOpts.SaveToDBOpt.TRUE
            });
            C.FieldOptions.Add("ResidualMomentumY", new FieldOpts()
            {
                Degree = degree, SaveToDB = FieldOpts.SaveToDBOpt.TRUE
            });
            C.FieldOptions.Add("ResidualConti", new FieldOpts()
            {
                Degree = degree - 1, SaveToDB = FieldOpts.SaveToDBOpt.TRUE
            });

            C.FieldOptions.Add("ResidualStressXX", new FieldOpts()
            {
                Degree = degree, SaveToDB = FieldOpts.SaveToDBOpt.TRUE
            });
            C.FieldOptions.Add("ResidualStressXY", new FieldOpts()
            {
                Degree = degree, SaveToDB = FieldOpts.SaveToDBOpt.TRUE
            });
            C.FieldOptions.Add("ResidualStressYY", new FieldOpts()
            {
                Degree = degree, SaveToDB = FieldOpts.SaveToDBOpt.TRUE
            });

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

            // Create Grid
            //fine grid - only on cluster!
            //string grid = "70797022-eba0-4c77-b179-334c665044b5";

            //more refined in wake of cylinder - only on cluster!
            //string grid = "3637610b-bcdf-4cdd-a647-cd7f91e373e8";


            //coarser grid - works without cluster!
            string grid = "f9aa12dc-53bb-4e2c-81b3-ffccc251a3f7";

            //very coarse grid as starting point for refinement
            //string grid = "e296a1b2-98f9-4fdf-8a32-04e0954ff369";

            //Dennis Zylinder for drag validation
            //string grid = "a67192f5-6b59-4caf-a95a-0a08730c3365";


            Guid gridGuid;

            if (Guid.TryParse(grid, out gridGuid))
            {
                C.GridGuid = gridGuid;
            }
            else
            {
                C.GridFunc = delegate()
                {
                    GridCommons _grid;

                    _grid = GridImporter.Import(grid);

                    return(_grid);
                };
            }


            // 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);
            }

            //restart
            //var database = new DatabaseInfo(path);
            //Guid restartID = new Guid("b919f595-9304-4d3c-a5f3-55d3cf4a9749");
            //C.RestartInfo = new Tuple<Guid, Foundation.IO.TimestepNumber>(restartID, null);

            //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 => 0);// 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", "VelocityX", X => 0);
            C.AddBoundaryValue("Wall_top", "VelocityX", X => 0);
            C.AddBoundaryValue("Wall_bottom", "VelocityY", X => 0);
            C.AddBoundaryValue("Wall_top", "VelocityY", X => 0);
            C.AddBoundaryValue("Wall_cylinder", "VelocityX", X => 0);
            C.AddBoundaryValue("Wall_cylinder", "VelocityY", X => 0);


            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);
        }
コード例 #6
0
        //__________________________________________________________________________________________________________________

        /// <summary>
        /// Confined cylinder in a channel flow
        /// </summary>
        static public RheologyControl ConfinedCylinder(string path = @"\\dc1\userspace\kikker\cluster\cluster_db\ConfinedCylinder_Drag", int degree = 2)
        {
            RheologyControl C = new RheologyControl();

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

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

            //Solver Options
            C.NoOfTimesteps = 1;
            C.savetodb      = false;
            C.DbPath        = path;
            C.ProjectName   = "Cylinder";

            C.NonLinearSolver.MaxSolverIterations  = 50;
            C.NonLinearSolver.MinSolverIterations  = 1;
            C.NonLinearSolver.ConvergenceCriterion = 1E-7;

            C.LinearSolver.MaxSolverIterations  = 50;
            C.LinearSolver.MinSolverIterations  = 1;
            C.LinearSolver.ConvergenceCriterion = 1E-7;

            //C.UnderRelax = 1.0;
            C.dt    = 1e6;
            C.dtMax = C.dt;
            C.dtMin = C.dt;
            C.Timestepper_Scheme           = RheologyControl.TimesteppingScheme.ImplicitEuler;
            C.NonLinearSolver.SolverCode   = NonLinearSolverCode.Newton;
            C.LinearSolver.SolverCode      = LinearSolverCode.classic_pardiso;
            C.ObjectiveParam               = 1.0;
            C.useJacobianForOperatorMatrix = true;

            C.UsePerssonSensor = false;
            C.SensorLimit      = 1e-4;

            C.AdaptiveMeshRefinement = false;
            C.RefinementLevel        = 10;

            C.UseArtificialDiffusion = false;

            C.Bodyforces = true;

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

            //Physical Params
            double u0 = 1.5; // 0.375;// 0.66;// 3 / 2;
            double h  = 4;

            C.Stokes = false;
            C.FixedStreamwisePeriodicBC = false;
            C.beta                 = 0.59;
            C.Reynolds             = 1;
            C.Weissenberg          = 0.0; //aim Weissenberg number!
            C.RaiseWeissenberg     = false;
            C.WeissenbergIncrement = 0.1;

            //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;
            C.alpha           = 1;
            C.StressPenalty   = 1.0;

            //Exact Solution Confined Cylinder

            // Set Initial Conditions / Boundary Conditions
            Func <double[], double, double> VelocityXfunction = (X, t) => u0 * (1 - (X[1] * X[1]) / h);
            Func <double[], double, double> VelocityYfunction = (X, t) => 0.0;
            Func <double[], double, double> Pressurefunction  = (X, t) => u0 * 0.5 * C.Reynolds * (35 - X[0]);
            Func <double[], double, double> StressXXfunction  = (X, t) => 2 * C.Weissenberg * (1 - C.beta) * u0 * (-2 / h) * X[1] * u0 * (-2 / h) * X[1];
            Func <double[], double, double> StressXYfunction  = (X, t) => (1 - C.beta) * u0 * (-2 / h) * 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("ResidualMomentumX", new FieldOpts()
            {
                Degree = degree, SaveToDB = FieldOpts.SaveToDBOpt.TRUE
            });
            C.FieldOptions.Add("ResidualMomentumY", new FieldOpts()
            {
                Degree = degree, SaveToDB = FieldOpts.SaveToDBOpt.TRUE
            });
            C.FieldOptions.Add("ResidualConti", new FieldOpts()
            {
                Degree = degree - 1, SaveToDB = FieldOpts.SaveToDBOpt.TRUE
            });

            C.FieldOptions.Add("ResidualStressXX", new FieldOpts()
            {
                Degree = degree, SaveToDB = FieldOpts.SaveToDBOpt.TRUE
            });
            C.FieldOptions.Add("ResidualStressXY", new FieldOpts()
            {
                Degree = degree, SaveToDB = FieldOpts.SaveToDBOpt.TRUE
            });
            C.FieldOptions.Add("ResidualStressYY", new FieldOpts()
            {
                Degree = degree, SaveToDB = FieldOpts.SaveToDBOpt.TRUE
            });

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

            // Create Grid

            // half channel mesh3 for cond tests
            string grid = " 962bc97f-0298-4e2f-ac18-06940cb84956";

            // half channel mesh0 for cond tests - schneller?
            //string grid = "55c34774-1769-4f6b-bfc8-cc6c4d74076a";

            // full channel mesh0 for cond tests comparison - schneller?
            //string grid = "ecd6444f-ddfe-46c4-9df5-a1390f9371d7";

            //fine grid - only on cluster!
            //string grid = "70797022-eba0-4c77-b179-334c665044b5";

            //more refined in wake of cylinder - only on cluster!
            //string grid = "3637610b-bcdf-4cdd-a647-cd7f91e373e8";


            //coarser grid - works without cluster!
            //string grid = "f9aa12dc-53bb-4e2c-81b3-ffccc251a3f7";

            //very coarse grid as starting point for refinement
            //string grid = "e296a1b2-98f9-4fdf-8a32-04e0954ff369";

            //Dennis Zylinder for drag validation
            //string grid = "a67192f5-6b59-4caf-a95a-0a08730c3365";


            Guid gridGuid;

            if (Guid.TryParse(grid, out gridGuid))
            {
                C.GridGuid = gridGuid;
            }
            else
            {
                C.GridFunc = delegate()
                {
                    GridCommons _grid;

                    _grid = GridImporter.Import(grid);

                    return(_grid);
                };
            }


            // 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);
            }

            //restart
            //var database = new DatabaseInfo(path);
            //Guid restartID = new Guid("9ae08191-ee15-4803-9e3f-566f119c9de4");
            //C.RestartInfo = new Tuple<Guid, Foundation.IO.TimestepNumber>(restartID, null);

            //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 => 0);// 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", "VelocityX", X => 0);
            C.AddBoundaryValue("Wall_top", "VelocityX", X => 0);
            //C.AddBoundaryValue("Wall_bottom", "VelocityY", X => 0);
            C.AddBoundaryValue("Wall_top", "VelocityY", X => 0);
            C.AddBoundaryValue("Wall_cylinder", "VelocityX", X => 0);
            C.AddBoundaryValue("Wall_cylinder", "VelocityY", X => 0);
            C.AddBoundaryValue("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);
        }