Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #18

Merged
merged 5 commits into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
262 changes: 19 additions & 243 deletions content/brom/BromDiffusion.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"id": "e6150636",
"metadata": {},
"outputs": [],
Expand All @@ -43,22 +43,10 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"id": "42847742",
"metadata": {},
"outputs": [
{
"ename": "AttributeError",
"evalue": "module 'ug4py.pyugcore' has no attribute 'Domain3d'",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[0;32mIn[3], line 9\u001b[0m\n\u001b[1;32m 5\u001b[0m numRefs \u001b[38;5;241m=\u001b[39m \u001b[38;5;241m2\u001b[39m \u001b[38;5;66;03m# Number of Refinement steps on given grid\u001b[39;00m\n\u001b[1;32m 7\u001b[0m \u001b[38;5;66;03m# Choosing a domain object\u001b[39;00m\n\u001b[1;32m 8\u001b[0m \u001b[38;5;66;03m# (either 1d, 2d or 3d suffix)\u001b[39;00m\n\u001b[0;32m----> 9\u001b[0m dom \u001b[38;5;241m=\u001b[39m \u001b[43mug4\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mDomain3d\u001b[49m()\n\u001b[1;32m 11\u001b[0m \u001b[38;5;66;03m# Loading the given grid into the domain\u001b[39;00m\n\u001b[1;32m 12\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mLoading Domain \u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;241m+\u001b[39m gridName \u001b[38;5;241m+\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m...\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n",
"\u001b[0;31mAttributeError\u001b[0m: module 'ug4py.pyugcore' has no attribute 'Domain3d'"
]
}
],
"outputs": [],
"source": [
"# Setup:\n",
"# defining needed subsets, grid and number of refinements\n",
Expand Down Expand Up @@ -86,7 +74,7 @@
"\n",
" print(\"Refining done\")\n",
"\n",
"# checking if geometry has the needed subsets of the probelm\n",
"# checking if geometry has the needed subsets of the problem\n",
"sh = dom.subset_handler()\n",
"for e in requiredSubsets:\n",
" if sh.get_subset_index(e) == -1:\n",
Expand All @@ -105,22 +93,10 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"id": "8f75da00",
"metadata": {},
"outputs": [
{
"ename": "AttributeError",
"evalue": "module 'ug4py.pyugcore' has no attribute 'ApproximationSpace3d'",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[0;32mIn[4], line 6\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[38;5;28mtype\u001b[39m \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mLagrange\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 4\u001b[0m order \u001b[38;5;241m=\u001b[39m \u001b[38;5;241m1\u001b[39m \u001b[38;5;66;03m# polynom order for lagrange\u001b[39;00m\n\u001b[0;32m----> 6\u001b[0m approxSpace \u001b[38;5;241m=\u001b[39m \u001b[43mug4\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mApproximationSpace3d\u001b[49m(dom)\n\u001b[1;32m 7\u001b[0m approxSpace\u001b[38;5;241m.\u001b[39madd_fct(fct, \u001b[38;5;28mtype\u001b[39m, order)\n\u001b[1;32m 8\u001b[0m approxSpace\u001b[38;5;241m.\u001b[39minit_levels()\n",
"\u001b[0;31mAttributeError\u001b[0m: module 'ug4py.pyugcore' has no attribute 'ApproximationSpace3d'"
]
}
],
"outputs": [],
"source": [
"\n",
"# Create approximation space which describes the unknowns in the equation\n",
Expand Down Expand Up @@ -181,7 +157,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"id": "f8e0894b",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -213,7 +189,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": null,
"id": "3140f477",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -255,179 +231,10 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": null,
"id": "1b79efbe",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"+++ Integrating: [0, 1]\n",
"+++ Timestep +++1\n",
"+++ Reassemble (t=0, dt=0.00625)\n",
"+++ Timestep +++2\n",
"+++ Timestep +++3\n",
"+++ Timestep +++4\n",
"+++ Timestep +++5\n",
"+++ Timestep +++6\n",
"+++ Timestep +++7\n",
"+++ Timestep +++8\n",
"+++ Timestep +++9\n",
"+++ Timestep +++10\n",
"+++ Timestep +++11\n",
"+++ Timestep +++12\n",
"+++ Timestep +++13\n",
"+++ Timestep +++14\n",
"+++ Timestep +++15\n",
"+++ Timestep +++16\n",
"+++ Timestep +++17\n",
"+++ Timestep +++18\n",
"+++ Timestep +++19\n",
"+++ Timestep +++20\n",
"+++ Timestep +++21\n",
"+++ Timestep +++22\n",
"+++ Timestep +++23\n",
"+++ Timestep +++24\n",
"+++ Timestep +++25\n",
"+++ Timestep +++26\n",
"+++ Timestep +++27\n",
"+++ Timestep +++28\n",
"+++ Timestep +++29\n",
"+++ Timestep +++30\n",
"+++ Timestep +++31\n",
"+++ Timestep +++32\n",
"+++ Timestep +++33\n",
"+++ Timestep +++34\n",
"+++ Timestep +++35\n",
"+++ Timestep +++36\n",
"+++ Timestep +++37\n",
"+++ Timestep +++38\n",
"+++ Timestep +++39\n",
"+++ Timestep +++40\n",
"+++ Timestep +++41\n",
"+++ Timestep +++42\n",
"+++ Timestep +++43\n",
"+++ Timestep +++44\n",
"+++ Timestep +++45\n",
"+++ Timestep +++46\n",
"+++ Timestep +++47\n",
"+++ Timestep +++48\n",
"+++ Timestep +++49\n",
"+++ Timestep +++50\n",
"+++ Timestep +++51\n",
"+++ Timestep +++52\n",
"+++ Timestep +++53\n",
"+++ Timestep +++54\n",
"+++ Timestep +++55\n",
"+++ Timestep +++56\n",
"+++ Timestep +++57\n",
"+++ Timestep +++58\n",
"+++ Timestep +++59\n",
"+++ Timestep +++60\n",
"+++ Timestep +++61\n",
"+++ Timestep +++62\n",
"+++ Timestep +++63\n",
"+++ Timestep +++64\n",
"+++ Timestep +++65\n",
"+++ Timestep +++66\n",
"+++ Timestep +++67\n",
"+++ Timestep +++68\n",
"+++ Timestep +++69\n",
"+++ Timestep +++70\n",
"+++ Timestep +++71\n",
"+++ Timestep +++72\n",
"+++ Timestep +++73\n",
"+++ Timestep +++74\n",
"+++ Timestep +++75\n",
"+++ Timestep +++76\n",
"+++ Timestep +++77\n",
"+++ Timestep +++78\n",
"+++ Timestep +++79\n",
"+++ Timestep +++80\n",
"+++ Timestep +++81\n",
"+++ Timestep +++82\n",
"+++ Timestep +++83\n",
"+++ Timestep +++84\n",
"+++ Timestep +++85\n",
"+++ Timestep +++86\n",
"+++ Timestep +++87\n",
"+++ Timestep +++88\n",
"+++ Timestep +++89\n",
"+++ Timestep +++90\n",
"+++ Timestep +++91\n",
"+++ Timestep +++92\n",
"+++ Timestep +++93\n",
"+++ Timestep +++94\n",
"+++ Timestep +++95\n",
"+++ Timestep +++96\n",
"+++ Timestep +++97\n",
"+++ Timestep +++98\n",
"+++ Timestep +++99\n",
"+++ Timestep +++100\n",
"+++ Timestep +++101\n",
"+++ Timestep +++102\n",
"+++ Timestep +++103\n",
"+++ Timestep +++104\n",
"+++ Timestep +++105\n",
"+++ Timestep +++106\n",
"+++ Timestep +++107\n",
"+++ Timestep +++108\n",
"+++ Timestep +++109\n",
"+++ Timestep +++110\n",
"+++ Timestep +++111\n",
"+++ Timestep +++112\n",
"+++ Timestep +++113\n",
"+++ Timestep +++114\n",
"+++ Timestep +++115\n",
"+++ Timestep +++116\n",
"+++ Timestep +++117\n",
"+++ Timestep +++118\n",
"+++ Timestep +++119\n",
"+++ Timestep +++120\n",
"+++ Timestep +++121\n",
"+++ Timestep +++122\n",
"+++ Timestep +++123\n",
"+++ Timestep +++124\n",
"+++ Timestep +++125\n",
"+++ Timestep +++126\n",
"+++ Timestep +++127\n",
"+++ Timestep +++128\n",
"+++ Timestep +++129\n",
"+++ Timestep +++130\n",
"+++ Timestep +++131\n",
"+++ Timestep +++132\n",
"+++ Timestep +++133\n",
"+++ Timestep +++134\n",
"+++ Timestep +++135\n",
"+++ Timestep +++136\n",
"+++ Timestep +++137\n",
"+++ Timestep +++138\n",
"+++ Timestep +++139\n",
"+++ Timestep +++140\n",
"+++ Timestep +++141\n",
"+++ Timestep +++142\n",
"+++ Timestep +++143\n",
"+++ Timestep +++144\n",
"+++ Timestep +++145\n",
"+++ Timestep +++146\n",
"+++ Timestep +++147\n",
"+++ Timestep +++148\n",
"+++ Timestep +++149\n",
"+++ Timestep +++150\n",
"+++ Timestep +++151\n",
"+++ Timestep +++152\n",
"+++ Timestep +++153\n",
"+++ Timestep +++154\n",
"+++ Timestep +++155\n",
"+++ Timestep +++156\n",
"+++ Timestep +++157\n",
"+++ Timestep +++158\n",
"+++ Timestep +++159\n",
"+++ Timestep +++160\n"
]
}
],
"outputs": [],
"source": [
"\n",
"# Define start time, end time and step size\n",
Expand Down Expand Up @@ -468,53 +275,22 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": null,
"id": "c4a48c79",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"Pyvista input: \n",
"UnstructuredGrid (0x1042a86a0)\n",
" N Cells: 5376\n",
" N Points: 3509\n",
" X Bounds: -1.000e+00, 1.000e+00\n",
" Y Bounds: -1.000e+00, 1.000e+00\n",
" Z Bounds: 0.000e+00, 3.500e+00\n",
" N Arrays: 1\n",
"\n"
]
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "4830ded197494a0cb69378fe42e07e22",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Widget(value=\"<iframe src='http://localhost:55551/index.html?ui=P_0x2a0e72a10_1&reconnect=auto' style='width: …"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"# Exporting the result to a vtu-file\n",
"# can be visualized in paraview or with a python extension\n",
"ug4.WriteGridFunctionToVTK(usol, \"BromFinal\")\n",
"\n",
"# Plotting the result using pyvista\n",
"import pyvista\n",
"result = pyvista.read('BromFinal.vtu')\n",
"print()\n",
"print(\"Pyvista input: \")\n",
"print(result)\n",
"result.plot(scalars=\"u\", show_edges=True, cmap='hot')\n"
"try:\n",
" # Plotting the result using pyvista\n",
" import pyvista\n",
" result = pyvista.read('BromFinal.vtu')\n",
" result.plot(scalars=\"u\", show_edges=True, cmap='hot')\n",
"except:\n",
" print(\"Plotting failed.\")"
]
},
{
Expand Down
Loading
Loading