Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

  • 9129b66
  • /
  • notebooks
  • /
  • run_demo_elasticity_2d.ipynb
Raw File Download

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
  • directory
content badge
swh:1:cnt:6ad59db97e587025fe72cf395467eb74332306d9
directory badge
swh:1:dir:3ea03368389b10e9be9528aef049c41602648719

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • content
  • directory
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
run_demo_elasticity_2d.ipynb
{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Test number 1: BNN + GenEO "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Subdomain number 0 contributes 0 coarse vectors as zero energy modes of local solver\n",
      "Subdomain number 1 contributes 3 coarse vectors as zero energy modes of local solver\n",
      "Subdomain number 3 contributes 3 coarse vectors as zero energy modes of local solver\n",
      "Subdomain number 2 contributes 3 coarse vectors as zero energy modes of local solver\n",
      "GenEO eigenvalue number 0 for lambdamax in subdomain 2: (1.4945905644205672e-06+0j)\n",
      "GenEO eigenvalue number 1 for lambdamax in subdomain 2: (1.3826304534084137e-05+0j)\n",
      "GenEO eigenvalue number 2 for lambdamax in subdomain 2: (4.5054862699016505e-05+0j)\n",
      "GenEO eigenvalue number 3 for lambdamax in subdomain 2: (0.05405868128473235+0j) <-- not selected (> 0.002)\n",
      "GenEO eigenvalue number 4 for lambdamax in subdomain 2: (0.054059009027747504+0j) <-- not selected (> 0.002)\n",
      "GenEO eigenvalue number 5 for lambdamax in subdomain 2: (0.056663048124898245+0j) <-- not selected (> 0.002)\n",
      "GenEO eigenvalue number 6 for lambdamax in subdomain 2: (0.05707962286789531+0j) <-- not selected (> 0.002)\n",
      "GenEO eigenvalue number 7 for lambdamax in subdomain 2: (0.1590121284975672+0j) <-- not selected (> 0.002)\n",
      "GenEO eigenvalue number 8 for lambdamax in subdomain 2: (0.15905866059775023+0j) <-- not selected (> 0.002)\n",
      "GenEO eigenvalue number 9 for lambdamax in subdomain 2: (0.22127754627425406+0j) <-- not selected (> 0.002)\n",
      "Subdomain number 2 contributes 6 coarse vectors after first GenEO\n",
      "Subdomain number 2 contributes 6 coarse vectors in total\n",
      "GenEO eigenvalue number 0 for lambdamax in subdomain 1: (1.4945905644205672e-06+0j)\n",
      "GenEO eigenvalue number 1 for lambdamax in subdomain 1: (1.3826304534084137e-05+0j)\n",
      "GenEO eigenvalue number 2 for lambdamax in subdomain 1: (4.5054862699016505e-05+0j)\n",
      "GenEO eigenvalue number 3 for lambdamax in subdomain 1: (0.05405868128473235+0j) <-- not selected (> 0.002)\n",
      "GenEO eigenvalue number 4 for lambdamax in subdomain 1: (0.054059009027747504+0j) <-- not selected (> 0.002)\n",
      "GenEO eigenvalue number 5 for lambdamax in subdomain 1: (0.056663048124898245+0j) <-- not selected (> 0.002)\n",
      "GenEO eigenvalue number 6 for lambdamax in subdomain 1: (0.05707962286789531+0j) <-- not selected (> 0.002)\n",
      "GenEO eigenvalue number 7 for lambdamax in subdomain 1: (0.1590121284975672+0j) <-- not selected (> 0.002)\n",
      "GenEO eigenvalue number 8 for lambdamax in subdomain 1: (0.15905866059775023+0j) <-- not selected (> 0.002)\n",
      "GenEO eigenvalue number 9 for lambdamax in subdomain 1: (0.22127754627425406+0j) <-- not selected (> 0.002)\n",
      "Subdomain number 1 contributes 6 coarse vectors after first GenEO\n",
      "Subdomain number 1 contributes 6 coarse vectors in total\n",
      "GenEO eigenvalue number 0 for lambdamax in subdomain 0: (0.00031732419879194125+0j)\n",
      "GenEO eigenvalue number 1 for lambdamax in subdomain 0: (0.0003370240261628236+0j)\n",
      "GenEO eigenvalue number 2 for lambdamax in subdomain 0: (0.028282401567833855+0j) <-- not selected (> 0.002)\n",
      "GenEO eigenvalue number 3 for lambdamax in subdomain 0: (0.028283168511417482+0j) <-- not selected (> 0.002)\n",
      "GenEO eigenvalue number 4 for lambdamax in subdomain 0: (0.111982986271491+0j) <-- not selected (> 0.002)\n",
      "GenEO eigenvalue number 5 for lambdamax in subdomain 0: (0.11219184197646168+0j) <-- not selected (> 0.002)\n",
      "GenEO eigenvalue number 6 for lambdamax in subdomain 0: (0.22129077270330236+0j) <-- not selected (> 0.002)\n",
      "GenEO eigenvalue number 7 for lambdamax in subdomain 0: (0.2212907735051293+0j) <-- not selected (> 0.002)\n",
      "GenEO eigenvalue number 8 for lambdamax in subdomain 0: (0.5564840670455399+0j) <-- not selected (> 0.002)\n",
      "GenEO eigenvalue number 9 for lambdamax in subdomain 0: (0.5839813243185191+0j) <-- not selected (> 0.002)\n",
      "Subdomain number 0 contributes 2 coarse vectors after first GenEO\n",
      "This is BNN so eigmin = 1, no eigenvalue problem will be solved for eigmin\n",
      "Subdomain number 0 contributes 2 coarse vectors in total\n",
      "GenEO eigenvalue number 0 for lambdamax in subdomain 3: (2.1208234833446384e-05+0j)\n",
      "GenEO eigenvalue number 1 for lambdamax in subdomain 3: (3.18585278025384e-05+0j)\n",
      "GenEO eigenvalue number 2 for lambdamax in subdomain 3: (0.008267951049146533+0j) <-- not selected (> 0.002)\n",
      "GenEO eigenvalue number 3 for lambdamax in subdomain 3: (0.22129069514149202+0j) <-- not selected (> 0.002)\n",
      "GenEO eigenvalue number 4 for lambdamax in subdomain 3: (0.22129069789192596+0j) <-- not selected (> 0.002)\n",
      "GenEO eigenvalue number 5 for lambdamax in subdomain 3: (0.5564838682522003+0j) <-- not selected (> 0.002)\n",
      "GenEO eigenvalue number 6 for lambdamax in subdomain 3: (0.5839813228857347+0j) <-- not selected (> 0.002)\n",
      "GenEO eigenvalue number 7 for lambdamax in subdomain 3: (0.5839813229177968+0j) <-- not selected (> 0.002)\n",
      "GenEO eigenvalue number 8 for lambdamax in subdomain 3: (0.6574284065235355+0j) <-- not selected (> 0.002)\n",
      "GenEO eigenvalue number 9 for lambdamax in subdomain 3: (0.6574287754614184+0j) <-- not selected (> 0.002)\n",
      "GenEO eigenvalue number 10 for lambdamax in subdomain 3: (0.8078884348812645+0j) <-- not selected (> 0.002)\n",
      "Subdomain number 3 contributes 5 coarse vectors after first GenEO\n",
      "Subdomain number 3 contributes 5 coarse vectors in total\n",
      "There are 19 vectors in the coarse space.\n",
      "  0 KSP Residual norm 9.515337417150e+00 \n",
      "  1 KSP Residual norm 2.241544961913e+00 \n",
      "  2 KSP Residual norm 2.096050355878e-01 \n",
      "  3 KSP Residual norm 2.583843851009e-02 \n",
      "  4 KSP Residual norm 2.926817141436e-03 \n",
      "  5 KSP Residual norm 2.212556097743e-03 \n",
      "  6 KSP Residual norm 3.194562886397e-04 \n",
      "  7 KSP Residual norm 5.660224748481e-05 \n",
      "  8 KSP Residual norm 1.603233943223e-05 \n"
     ]
    }
   ],
   "source": [
    "!mpiexec -np 4 --oversubscribe python demo_elasticity_2d.py -ksp_monitor -PCBNN_verbose -AMPCG_tau 0 -PCBNN_GenEO true -PCBNN_GenEO_eigmax 1000"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "from plot import plot_solution"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "7c6dd9363c594bafb15d07ef0b19f0d6",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "HBox(children=(Renderer(camera=PerspectiveCamera(position=(0.0, 0.0, 13.0)), controls=[OrbitControls(controlli…"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plot_solution('output_2d', 'solution_2d.vts')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Test number 2: turn GenEO off, use AMPCG instead"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Subdomain number 0 contributes 0 coarse vectors as zero energy modes of local solver\n",
      "Subdomain number 0 contributes 0 coarse vectors in total\n",
      "Subdomain number 1 contributes 3 coarse vectors as zero energy modes of local solver\n",
      "Subdomain number 3 contributes 3 coarse vectors as zero energy modes of local solver\n",
      "Subdomain number 1 contributes 3 coarse vectors in total\n",
      "Subdomain number 3 contributes 3 coarse vectors in total\n",
      "Subdomain number 2 contributes 3 coarse vectors as zero energy modes of local solver\n",
      "Subdomain number 2 contributes 3 coarse vectors in total\n",
      "There are 9 vectors in the coarse space.\n",
      "multipreconditioning initial iteration\n",
      "  0 KSP Residual norm 2.004620149430e+02 \n",
      "\tnatural_norm -> 2.00462015e+02\n",
      "\tti -> 0.00000000e+00\n",
      "multipreconditioning this iteration\n",
      "  1 KSP Residual norm 4.374828777103e+01 \n",
      "\tnatural_norm -> 4.37482878e+01\n",
      "\tti -> 7.47461287e-02\n",
      "multipreconditioning this iteration\n",
      "  2 KSP Residual norm 2.958649246685e+01 \n",
      "\tnatural_norm -> 2.95864925e+01\n",
      "\tti -> 2.30818061e-04\n",
      "  3 KSP Residual norm 1.024755579359e+01 \n",
      "\tnatural_norm -> 1.02475558e+01\n",
      "\tti -> 5.65467747e-01\n",
      "  4 KSP Residual norm 9.372894221106e+00 \n",
      "\tnatural_norm -> 9.37289422e+00\n",
      "\tti -> 4.89891002e-01\n",
      "  5 KSP Residual norm 2.352543555987e+00 \n",
      "\tnatural_norm -> 2.35254356e+00\n",
      "\tti -> 3.99677455e+00\n",
      "  6 KSP Residual norm 7.435092501873e-01 \n",
      "\tnatural_norm -> 7.43509250e-01\n",
      "\tti -> 5.03558194e+00\n",
      "  7 KSP Residual norm 2.836186311046e-01 \n",
      "\tnatural_norm -> 2.83618631e-01\n",
      "\tti -> 1.11136617e+00\n",
      "  8 KSP Residual norm 5.349601693695e-02 \n",
      "\tnatural_norm -> 5.34960169e-02\n",
      "\tti -> 1.18962182e+01\n",
      "  9 KSP Residual norm 2.654138922049e-02 \n",
      "\tnatural_norm -> 2.65413892e-02\n",
      "\tti -> 2.86043835e+00\n",
      " 10 KSP Residual norm 1.551097234944e-02 \n",
      "\tnatural_norm -> 1.55109723e-02\n",
      "\tti -> 6.35652858e-01\n",
      " 11 KSP Residual norm 1.674013551698e-03 \n",
      "\tnatural_norm -> 1.67401355e-03\n",
      "\tti -> 2.60089314e+01\n",
      " 12 KSP Residual norm 3.869200838851e-04 \n",
      "\tnatural_norm -> 3.86920084e-04\n",
      "\tti -> 9.40812431e+00\n",
      " 13 KSP Residual norm 7.112289906963e-05 \n",
      "\tnatural_norm -> 7.11228991e-05\n",
      "\tti -> 1.70599964e+01\n",
      " 14 KSP Residual norm 1.700329004360e-05 \n",
      "\tnatural_norm -> 1.70032900e-05\n",
      "\tti -> 8.38258375e+00\n"
     ]
    }
   ],
   "source": [
    "!mpiexec -np 4 --oversubscribe python demo_elasticity_2d.py -ksp_monitor -PCBNN_verbose -AMPCG_verbose -AMPCG_tau 0.1 -PCBNN_GenEO false "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Test number 3: turn GenEO off, use AMPCG, switch to Additive Schwarz\n",
    "\n",
    "In this case the $\\tau$-test is useless (because the lower part of the spectrum is problematic) so we turn it off with -AMPCG_fullMP true which means that every iteration is preconditioned"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The user has chosen to switch to Additive Schwarz instead of BNN.\n",
      "Subdomain number 0 contributes 0 coarse vectors as zero energy modes of local solver\n",
      "Subdomain number 1 contributes 0 coarse vectors as zero energy modes of local solver\n",
      "Subdomain number 1 contributes 0 coarse vectors in total\n",
      "Subdomain number 2 contributes 0 coarse vectors as zero energy modes of local solver\n",
      "Subdomain number 3 contributes 0 coarse vectors as zero energy modes of local solver\n",
      "Subdomain number 3 contributes 0 coarse vectors in total\n",
      "Subdomain number 2 contributes 0 coarse vectors in total\n",
      "Subdomain number 0 contributes 0 coarse vectors in total\n",
      "There are 0 vectors in the coarse space.\n",
      "  0 KSP Residual norm 1.724079391945e+00 \n",
      "  1 KSP Residual norm 3.373302734591e-01 \n",
      "  2 KSP Residual norm 2.042876162594e-01 \n",
      "  3 KSP Residual norm 2.156223995841e-01 \n",
      "  4 KSP Residual norm 1.352561227531e-01 \n",
      "  5 KSP Residual norm 1.394282296431e-01 \n",
      "  6 KSP Residual norm 1.942448996389e-01 \n",
      "  7 KSP Residual norm 3.226564021398e-01 \n",
      "  8 KSP Residual norm 4.706847735329e-01 \n",
      "  9 KSP Residual norm 2.371689132224e-01 \n",
      " 10 KSP Residual norm 2.980361010918e-01 \n",
      " 11 KSP Residual norm 1.595884695320e+00 \n",
      " 12 KSP Residual norm 1.225731007444e+00 \n",
      " 13 KSP Residual norm 1.897029642041e+00 \n",
      " 14 KSP Residual norm 2.235755992899e+00 \n",
      " 15 KSP Residual norm 9.182951918913e-01 \n",
      " 16 KSP Residual norm 1.008821812233e+00 \n",
      " 17 KSP Residual norm 7.352608730021e-01 \n",
      " 18 KSP Residual norm 1.109783686886e+00 \n",
      " 19 KSP Residual norm 1.915717554777e+00 \n",
      " 20 KSP Residual norm 2.137625341900e+00 \n",
      " 21 KSP Residual norm 3.282705657299e+00 \n",
      " 22 KSP Residual norm 1.779953007574e+00 \n",
      " 23 KSP Residual norm 4.179889891060e+00 \n",
      " 24 KSP Residual norm 2.662846151493e+00 \n",
      " 25 KSP Residual norm 4.356862947976e-01 \n",
      " 26 KSP Residual norm 6.535717680476e-01 \n",
      " 27 KSP Residual norm 1.877307983243e-01 \n",
      " 28 KSP Residual norm 2.969194716815e-01 \n",
      " 29 KSP Residual norm 3.488046756047e-01 \n",
      " 30 KSP Residual norm 2.286702041179e-02 \n",
      " 31 KSP Residual norm 5.661239229556e-03 \n",
      " 32 KSP Residual norm 1.621064626917e-02 \n",
      " 33 KSP Residual norm 2.489920496400e-02 \n",
      " 34 KSP Residual norm 2.247672471231e-02 \n",
      " 35 KSP Residual norm 5.910146383553e-03 \n",
      " 36 KSP Residual norm 5.660960282547e-04 \n",
      " 37 KSP Residual norm 2.262037471456e-05 \n"
     ]
    }
   ],
   "source": [
    "!mpiexec -np 4 --oversubscribe python demo_elasticity_2d.py -ksp_monitor -PCBNN_verbose -AMPCG_fullMP true -PCBNN_GenEO false -PCBNN_switchtoASM true"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Test number 4: turn GenEO off, don't use AMPCG, switch to Additive Schwarz"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The user has chosen to switch to Additive Schwarz instead of BNN.\n",
      "Subdomain number 0 contributes 0 coarse vectors as zero energy modes of local solver\n",
      "Subdomain number 1 contributes 0 coarse vectors as zero energy modes of local solver\n",
      "Subdomain number 2 contributes 0 coarse vectors as zero energy modes of local solver\n",
      "Subdomain number 3 contributes 0 coarse vectors as zero energy modes of local solver\n",
      "Subdomain number 0 contributes 0 coarse vectors in total\n",
      "Subdomain number 2 contributes 0 coarse vectors in total\n",
      "Subdomain number 3 contributes 0 coarse vectors in total\n",
      "Subdomain number 1 contributes 0 coarse vectors in total\n",
      "There are 0 vectors in the coarse space.\n",
      "  0 KSP Residual norm 1.724079391945e+00 \n",
      "  1 KSP Residual norm 3.374962873737e-01 \n",
      "  2 KSP Residual norm 1.469748887210e-01 \n",
      "  3 KSP Residual norm 2.729956941437e-01 \n",
      "  4 KSP Residual norm 1.497379150637e-01 \n",
      "  5 KSP Residual norm 8.711268434171e-02 \n",
      "  6 KSP Residual norm 9.932062571129e-02 \n",
      "  7 KSP Residual norm 1.308938077458e-01 \n",
      "  8 KSP Residual norm 7.113892815756e-02 \n",
      "  9 KSP Residual norm 3.268246252895e-01 \n",
      " 10 KSP Residual norm 2.787796870991e-01 \n",
      " 11 KSP Residual norm 3.532500573761e-01 \n",
      " 12 KSP Residual norm 8.707159935911e-01 \n",
      " 13 KSP Residual norm 3.080199843197e-01 \n",
      " 14 KSP Residual norm 9.663025317604e-02 \n",
      " 15 KSP Residual norm 1.767978874232e-01 \n",
      " 16 KSP Residual norm 2.783133360999e-01 \n",
      " 17 KSP Residual norm 3.797967838183e-01 \n",
      " 18 KSP Residual norm 2.444097106069e+00 \n",
      " 19 KSP Residual norm 4.703851916928e+00 \n",
      " 20 KSP Residual norm 1.730876887992e+00 \n",
      " 21 KSP Residual norm 2.363568671910e+00 \n",
      " 22 KSP Residual norm 6.055456447926e+00 \n",
      " 23 KSP Residual norm 2.194455974272e+00 \n",
      " 24 KSP Residual norm 5.704302750970e-01 \n",
      " 25 KSP Residual norm 1.433095612482e+00 \n",
      " 26 KSP Residual norm 6.403771961174e-01 \n",
      " 27 KSP Residual norm 2.144832889194e-01 \n",
      " 28 KSP Residual norm 1.400619575381e-01 \n",
      " 29 KSP Residual norm 1.318994656417e-01 \n",
      " 30 KSP Residual norm 2.562475790344e-01 \n",
      " 31 KSP Residual norm 4.513054641844e-01 \n",
      " 32 KSP Residual norm 4.926135067656e-01 \n",
      " 33 KSP Residual norm 4.476392862232e-01 \n",
      " 34 KSP Residual norm 1.341720071537e-01 \n",
      " 35 KSP Residual norm 1.439982024707e-01 \n",
      " 36 KSP Residual norm 1.268024095395e-01 \n",
      " 37 KSP Residual norm 1.941361920604e-02 \n",
      " 38 KSP Residual norm 1.108621764821e-02 \n",
      " 39 KSP Residual norm 5.672737676361e-02 \n",
      " 40 KSP Residual norm 1.726607226972e-01 \n",
      " 41 KSP Residual norm 1.214300901300e-01 \n",
      " 42 KSP Residual norm 1.436946553821e-01 \n",
      " 43 KSP Residual norm 2.131249012577e-01 \n",
      " 44 KSP Residual norm 1.080970611095e-01 \n",
      " 45 KSP Residual norm 1.428241474487e-01 \n",
      " 46 KSP Residual norm 3.100144584693e-02 \n",
      " 47 KSP Residual norm 1.226502474853e-02 \n",
      " 48 KSP Residual norm 4.119697660803e-03 \n",
      " 49 KSP Residual norm 3.077879923914e-03 \n",
      " 50 KSP Residual norm 1.091483838563e-03 \n",
      " 51 KSP Residual norm 3.214339363955e-04 \n",
      " 52 KSP Residual norm 7.505519085313e-04 \n",
      " 53 KSP Residual norm 8.117732046764e-04 \n",
      " 54 KSP Residual norm 8.653837675167e-05 \n",
      " 55 KSP Residual norm 1.413254191641e-05 \n"
     ]
    }
   ],
   "source": [
    "!mpiexec -np 4 --oversubscribe python demo_elasticity_2d.py -ksp_monitor -PCBNN_verbose -AMPCG_tau 0 -PCBNN_GenEO false -PCBNN_switchtoASM true"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}

back to top

Software Heritage — Copyright (C) 2015–2026, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API