Skip to content

Commit

Permalink
Merge branch 'root-public'
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianKummer committed May 6, 2024
2 parents a9c605f + 0beed13 commit 4486230
Show file tree
Hide file tree
Showing 188 changed files with 56,311 additions and 18,607 deletions.
140 changes: 115 additions & 25 deletions doc/handbook/BoundaryAndInitialData/BoundaryAndInitialData.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,15 @@
"## Textual and Embedded formulas\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"One of the most common ways of specifying an initial value, in general, is a mathamathical formula.\n",
"In BoSSS, such formulas also have to be encoded in C#.\n",
"The respective C#-code for the formula has to be given as a `string`."
]
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -158,14 +167,14 @@
},
"outputs": [],
"source": [
"SipControl c1 = PreDefinedControl();"
"SipControl c1 = PreDefinedControl(); // use the template defined above"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Provide **initial data** as a text:"
"The following snippet will add a `Formula` object to the inital data:"
]
},
{
Expand All @@ -178,6 +187,7 @@
},
"outputs": [],
"source": [
"// Setting an intial value for the right-hand-side:\n",
"c1.AddInitialValue(\"RHS\",\"X => Math.Sin(X[0])*Math.Cos(X[1])\",\n",
" TimeDependent:false);"
]
Expand All @@ -186,16 +196,18 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Finally, all initial data is stored in the \n",
"`AppControl.InitialValues` dictionary and \n",
"all boundary data is stored in the \n",
"`AppControl.BoundaryValues` dictionary.\n",
" \n",
"The common interface for all varinats to specify boundary\n",
"and initial data is `IBoundaryAndInitialData`\n",
"Note: \n",
"* All initial data object are stored in the \n",
" `AppControl.InitialValues` dictionary, while\n",
" all boundary data objects are stored in the \n",
" `AppControl.BoundaryValues` dictionary.\n",
"* The common interface for all varinats to specify boundary\n",
" and initial data is `IBoundaryAndInitialData`\n",
"\n",
"The snippet above is only a shortcut to add a `Formula` object,\n",
"which implements the `IBoundaryAndInitialData` interface."
"which implements the `IBoundaryAndInitialData` interface.\n",
"\n",
"After we added this initial value, we can observe it in the control object:"
]
},
{
Expand Down Expand Up @@ -272,7 +284,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Creates a Job named **J1** and runs it"
"We create a job **J1** and execute it on the default batch processor:"
]
},
{
Expand Down Expand Up @@ -352,9 +364,26 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## 1D Splines\n",
"The results of every compute job are stured in the database as so-calles **sessions**. One session is created for each solver run. The most recent result of a job can be aquired through the `LatesSession` property:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"J1.LatestSession"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 1D Splines\n",
"\n",
"**Splines** can be used to interpolate nodal data onto a DG field;\n",
"If no analytical expression for some inital or boundary data can be specified, \n",
"**Splines** can be used to interpolate nodal data onto a DG field.\n",
"currently, only 1D is supported."
]
},
Expand Down Expand Up @@ -411,15 +440,15 @@
},
"outputs": [],
"source": [
"/// BoSSScmdSilent\n",
"// verify that the spline does what it is suposed to do:\n",
"double err = 0;\n",
"// test the spline: a line must be interpolated exactly.\n",
"foreach(double xtst in GenericBlas.Linspace(-3,3,77)) { \n",
" double sVal = rhsSpline.Evaluate(new double[] {xtst , 0, 0 }, 0.0);\n",
" double rVal = xtst*0.4;\n",
" err += Math.Abs(sVal - rVal);\n",
"}\n",
"NUnit.Framework.Assert.Less(err, 1.0e-10, \"Slpine implementation fail.\");"
"NUnit.Framework.Assert.Less(err, 1.0e-10, \"Spline implementation fail.\");"
]
},
{
Expand All @@ -435,6 +464,13 @@
"c2.AddInitialValue(\"RHS\", rhsSpline);"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Again, create a job **J2** and execute it on the default batch processor:"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -488,12 +524,26 @@
"NUnit.Framework.Assert.IsTrue(J2.Status == JobStatus.FinishedSuccessful);"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"J2.LatestSession"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"## Interpolating values from other Calculations\n",
"## Interpolating values from other solver runs\n",
"\n",
"Very often, also the result of some previous solver run could serve as the input for a new solver run.\n",
"These previous results not neccessarily need to be on the same mesh. \n",
"The `ForeignGridValue` class is capeable of interpolating some results from an existing solver un in the database\n",
"onto a different mesh.\n",
"\n",
"For demonstrational purposes, we use the result (i.e. the last time-step) \n",
"of a previous calculation as a right-hand-side for the next calculation."
Expand Down Expand Up @@ -548,14 +598,14 @@
},
"outputs": [],
"source": [
"var lastTimeStep = j2Sess.Timesteps.Last();"
"var lastTimeStep = j2Sess.Timesteps.Last(); // select the last timestep computed in J2:"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We encapsulate the value `T` in the `ForeignGridValue` object,\n",
"We encapsulate the value of DG field `T` in the `ForeignGridValue` object,\n",
"which allows interpolation between different meshes:"
]
},
Expand All @@ -582,10 +632,17 @@
},
"outputs": [],
"source": [
"/// Use different mesh in the control file:\n",
"SipControl c3 = PreDefinedControl();"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To demonstrate the mesh interpolation capabilities, \n",
"we define a different mesh in the control object."
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -622,7 +679,7 @@
},
"outputs": [],
"source": [
"/// finally, we define the RHS:\n",
"// finally, we define the RHS:\n",
"c3.AddInitialValue(\"RHS\", newForeignMesh);"
]
},
Expand All @@ -636,12 +693,19 @@
},
"outputs": [],
"source": [
"/// BoSSScmdSilent\n",
"double orgProbe = newForeignMesh.Evaluate(new double[] {0.5,0.5}, 0.0);\n",
"double newProbe = lastTimeStep.GetField(\"T\").ProbeAt(new double[] {0.5,0.5});\n",
"// a brief check to see if the interpolation wors.\n",
"double orgProbe = newForeignMesh.Evaluate(new double[] {0.5,0.5}, 0.0); // evaluate at (0.5, 0.5) in interpolated mesh\n",
"double newProbe = lastTimeStep.GetField(\"T\").ProbeAt(new double[] {0.5,0.5}); // evaluate at (0.5, 0.5) in original mesh\n",
"NUnit.Framework.Assert.Less(Math.Abs(orgProbe - newProbe), 1.0e-10, \"Check (1) on ForeignGridValue failed\");"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Execute the job on the basth processor:"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -767,7 +831,12 @@
"source": [
"## Restart from Dummy-Sessions\n",
"\n",
"Dummy sessions are kind of fake siolver runs, with the only purpose \n",
"Mesh interpolation is a quite expensive task. \n",
"If pre-existing values from the database shall be used, but no mesh interpolation is required,\n",
"one can also store the initial values in a so-called **dummy session**\n",
"and trhen run the solver as a restart from this dummy session.\n",
"\n",
"Dummy sessions are kind of fake solver runs, with the only purpose \n",
"of using them for a restart."
]
},
Expand Down Expand Up @@ -851,6 +920,13 @@
"var c4 = PreDefinedControl();"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We specify a **restart form the dummy session**:"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -865,6 +941,13 @@
"c4.SetRestart(RestartTimestep);"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"And run the solver:"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -933,6 +1016,13 @@
"mesh interpolation once **use `ProjectFromForeignGrid`** in BoSSSpad and\n",
"save the interpolation in a dummy session."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand All @@ -946,7 +1036,7 @@
"mimetype": "text/x-csharp",
"name": "C#",
"pygments_lexer": "csharp",
"version": "9.0"
"version": "10.0"
}
},
"nbformat": 4,
Expand Down
3 changes: 2 additions & 1 deletion doc/handbook/BoundaryAndInitialData/getbossspad.sh
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
dotnet publish ../../../src/L4-application/BoSSSpad/BoSSSpad.csproj -c Release -v q -o .
dotnet publish ../../../src/L4-application/BoSSSpad/BoSSSpad.csproj -c Release -v q -o . > b.out
echo $?
2 changes: 1 addition & 1 deletion doc/handbook/MetaJobManager/MetaJobManager.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -857,7 +857,7 @@
},
"outputs": [],
"source": [
"BoSSSshell.WorkflowMgm.BlockUntilAllJobsTerminate(1000);"
"BoSSSshell.WorkflowMgm.BlockUntilAllJobsTerminate(3600);"
]
},
{
Expand Down
Loading

0 comments on commit 4486230

Please sign in to comment.