#r "BoSSSpad.dll"
//#r "D:\BoSSS2\experimental\public\src\L4-application\BoSSSpad\bin\Release\net5.0\bossspad.dll"
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Data;
using System.Globalization;
using System.Threading;
using ilPSP;
using ilPSP.Utils;
using BoSSS.Platform;
using BoSSS.Foundation;
using BoSSS.Foundation.Grid;
using BoSSS.Foundation.Grid.Classic;
using BoSSS.Foundation.IO;
using BoSSS.Solution;
using BoSSS.Solution.Control;
using BoSSS.Solution.GridImport;
using BoSSS.Solution.Statistic;
using BoSSS.Solution.Utils;
using BoSSS.Solution.Gnuplot;
using BoSSS.Application.BoSSSpad;
using BoSSS.Application.XNSE_Solver;
using static BoSSS.Application.BoSSSpad.BoSSSshell;
using BoSSS.Foundation.Grid.RefElements;
using BoSSS.Platform.LinAlg;
using BoSSS.Solution.NSECommon;
Init();
using BoSSS.Application.XNSEC;
BoSSSshell.WorkflowMgm.Init("DiffFlameConvergenceStudy");
Project name is set to 'DiffFlameConvergenceStudy'. Default Execution queue is chosen for the database. Opening existing database '\\fdygitrunner\ValidationTests\databases\DiffFlameConvergenceStudy'.
var myBatch = BoSSSshell.GetDefaultQueue();
var myDb = BoSSSshell.WorkflowMgm.DefaultDatabase;
int[] DGDegrees = new int[] {1,2,3,4} ;
// // Find number of cells used in the finest mesh
// int NCellsFinestMesh = 0;
// var allsess = myDb.Sessions;
// foreach(var sess in allsess){
// int c = Convert.ToInt32(sess.KeysAndQueries["Grid:NoOfCells"]);
// if( c > NCellsFinestMesh)
// NCellsFinestMesh = c;
// }
string[] varNames = new string[]{"VelocityX", "Pressure","Temperature", "MassFraction0","MassFraction1", "MassFraction2"};
IEnumerable<KeyValuePair<string, double>>[] RegressionS = new IEnumerable<KeyValuePair<string, double>>[varNames.Length];
Plot2Ddata[,] PlotTable = new Plot2Ddata[3, 2];
int cnt2 = -1;
for (int iCol = 0; iCol < 3; iCol++) {
for (int iRow = 0; iRow < 2; iRow++) {
var allColors = Enum.GetValues(typeof(LineColors)).Cast<LineColors>().ToArray();
var allPointTypes = Enum.GetValues(typeof(PointTypes)).Cast<PointTypes>().ToArray();
PointTypes[] myPointTypes = new PointTypes[] { PointTypes.Diamond, PointTypes.Box, PointTypes.LowerTriangle, PointTypes.OpenLowerTriangle, };
cnt2++;
string varname = varNames[cnt2];
var ExpPlotS = new List<Plot2Ddata>();
var fmt = new PlotFormat();
fmt.Style = Styles.Lines;
fmt.LineColor = allColors[cnt2 % allColors.Length];
fmt.PointType = allPointTypes[cnt2 % allPointTypes.Length];
fmt.DashType = DashTypes.Solid;
foreach (int pDeg in DGDegrees) {
int actualDGDeg = varname == "Pressure" ? pDeg-1:pDeg;
string dgDegStr = (varname == "VelocityX" || varname == "VelocityY" ) ? "DGdegree:Velocity*":"DGdegree:"+varname;
var pDegSessions1 = myDb.Sessions.Where(Si => ( Si.Name.StartsWith("FS") == false )).ToArray(); // Dont account for mixture fraction calculation
var pDegSessions = pDegSessions1.Where(Si => (Convert.ToInt32(Si.KeysAndQueries[dgDegStr]) == actualDGDeg)).ToArray();
Plot2Ddata pDegPlot =
pDegSessions.ToEstimatedGridConvergenceData(
varname,
xAxis_Is_hOrDof: true, // false selects DOFs for x-axis
normType: varname == "Pressure" ? NormType.L2noMean_embedded : NormType.L2_embedded); // Mean value of pressure is not fixed
ExpPlotS.Add(pDegPlot);
}
var ExpPlot = ExpPlotS [0]; // select 0-th object
foreach (var p in ExpPlotS.Skip(1)) { // loop over other ( skip 0-th entry )
ExpPlot = ExpPlot.Merge(p); // merge
}
ExpPlot.LogX = true;
ExpPlot.LogY = true;
ExpPlot.Title = varNames[cnt2];
ExpPlot.TitleFont = 20;
ExpPlot.Xlabel = "h";
ExpPlot.Ylabel = "L_2 Error";
PlotTable[iCol, iRow] = ExpPlot;
RegressionS[cnt2] = ExpPlot.Regression();
}
}
var gp = PlotTable.ToGnuplot();
gp.PlotSVG(xRes:1000,yRes:1000)
Using gnuplot: C:\Program Files (x86)\FDY\BoSSS\bin\native\win\gnuplot-gp510-20160418-win32-mingw\gnuplot\bin\gnuplot.exe Note: In a Jupyter Worksheet, you must NOT have a trailing semicolon in order to see the plot on screen; otherwise, the output migth be surpressed.!
warning CS1701: Assuming assembly reference 'Microsoft.AspNetCore.Html.Abstractions, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' used by 'BoSSSpad' matches identity 'Microsoft.AspNetCore.Html.Abstractions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' of 'Microsoft.AspNetCore.Html.Abstractions', you may need to supply runtime policy
int cnt = 0;
foreach(var reg in RegressionS){
Console.WriteLine(varNames[cnt]);
var regB = reg.ToArray();
for(int j = 0; j < regB.Length; j++){
int dgDeg = ( regB[j].Key).Last() - '0';
Console.Write("DG degree: "+ dgDeg+ " \t");
double slope = regB[j].Value;
Console.Write("Slope: " +slope + "\t");
if((slope - (dgDeg + 1) ) >= -0.2)
Console.WriteLine("Expected slope archieved");
else
Console.WriteLine("The slope value is too low");
}
cnt++;
}
VelocityX DG degree: 1 Slope: 1.7566987428137497 The slope value is too low DG degree: 2 Slope: 2.143437973697295 The slope value is too low DG degree: 3 Slope: 2.5672965028351107 The slope value is too low DG degree: 4 Slope: 2.807955872963965 The slope value is too low Pressure DG degree: 0 Slope: 1.063562176859694 Expected slope archieved DG degree: 1 Slope: 1.9205112187928153 Expected slope archieved DG degree: 2 Slope: 2.402917387694637 The slope value is too low DG degree: 3 Slope: 2.3340408570962077 The slope value is too low Temperature DG degree: 1 Slope: 1.7590235212179681 The slope value is too low DG degree: 2 Slope: 2.1453120902225025 The slope value is too low DG degree: 3 Slope: 2.573269785462294 The slope value is too low DG degree: 4 Slope: 2.935553960254484 The slope value is too low MassFraction0 DG degree: 1 Slope: 1.9481865251493269 Expected slope archieved DG degree: 2 Slope: 2.6002319273118704 The slope value is too low DG degree: 3 Slope: 2.607848096167863 The slope value is too low DG degree: 4 Slope: 2.359612009800998 The slope value is too low MassFraction1 DG degree: 1 Slope: 1.754723605500739 The slope value is too low DG degree: 2 Slope: 2.144366231328975 The slope value is too low DG degree: 3 Slope: 2.573305382464815 The slope value is too low DG degree: 4 Slope: 2.963520258119672 The slope value is too low MassFraction2 DG degree: 1 Slope: 1.7585576479385554 The slope value is too low DG degree: 2 Slope: 2.1453247772115476 The slope value is too low DG degree: 3 Slope: 2.573270592040615 The slope value is too low DG degree: 4 Slope: 2.9355517144259125 The slope value is too low