ngsolve 6.2.2506.post74.dev0__cp314-cp314-macosx_10_15_universal2.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of ngsolve might be problematic. Click here for more details.
- netgen/include/analytic_integrals.hpp +10 -0
- netgen/include/arnoldi.hpp +55 -0
- netgen/include/bandmatrix.hpp +334 -0
- netgen/include/basematrix.hpp +957 -0
- netgen/include/basevector.hpp +1268 -0
- netgen/include/bdbequations.hpp +2805 -0
- netgen/include/bdbintegrator.hpp +1660 -0
- netgen/include/bem_diffops.hpp +475 -0
- netgen/include/bessel.hpp +1064 -0
- netgen/include/bilinearform.hpp +963 -0
- netgen/include/bla.hpp +29 -0
- netgen/include/blockalloc.hpp +95 -0
- netgen/include/blockjacobi.hpp +328 -0
- netgen/include/bspline.hpp +116 -0
- netgen/include/calcinverse.hpp +141 -0
- netgen/include/cg.hpp +368 -0
- netgen/include/chebyshev.hpp +44 -0
- netgen/include/cholesky.hpp +720 -0
- netgen/include/clapack.h +7254 -0
- netgen/include/code_generation.hpp +296 -0
- netgen/include/coefficient.hpp +2033 -0
- netgen/include/coefficient_impl.hpp +19 -0
- netgen/include/coefficient_stdmath.hpp +167 -0
- netgen/include/commutingAMG.hpp +106 -0
- netgen/include/comp.hpp +79 -0
- netgen/include/compatibility.hpp +41 -0
- netgen/include/complex_wrapper.hpp +73 -0
- netgen/include/compressedfespace.hpp +110 -0
- netgen/include/contact.hpp +235 -0
- netgen/include/diagonalmatrix.hpp +154 -0
- netgen/include/differentialoperator.hpp +276 -0
- netgen/include/diffop.hpp +1286 -0
- netgen/include/diffop_impl.hpp +328 -0
- netgen/include/diffopwithfactor.hpp +123 -0
- netgen/include/discontinuous.hpp +84 -0
- netgen/include/dump.hpp +949 -0
- netgen/include/ectypes.hpp +121 -0
- netgen/include/eigen.hpp +60 -0
- netgen/include/eigensystem.hpp +18 -0
- netgen/include/elasticity_equations.hpp +595 -0
- netgen/include/elementbyelement.hpp +195 -0
- netgen/include/elementtopology.hpp +1760 -0
- netgen/include/elementtransformation.hpp +339 -0
- netgen/include/evalfunc.hpp +405 -0
- netgen/include/expr.hpp +1686 -0
- netgen/include/facetfe.hpp +175 -0
- netgen/include/facetfespace.hpp +180 -0
- netgen/include/facethofe.hpp +111 -0
- netgen/include/facetsurffespace.hpp +112 -0
- netgen/include/fe_interfaces.hpp +32 -0
- netgen/include/fem.hpp +87 -0
- netgen/include/fesconvert.hpp +14 -0
- netgen/include/fespace.hpp +1449 -0
- netgen/include/finiteelement.hpp +286 -0
- netgen/include/globalinterfacespace.hpp +77 -0
- netgen/include/globalspace.hpp +115 -0
- netgen/include/gridfunction.hpp +525 -0
- netgen/include/h1amg.hpp +124 -0
- netgen/include/h1hofe.hpp +188 -0
- netgen/include/h1hofe_impl.hpp +1262 -0
- netgen/include/h1hofefo.hpp +148 -0
- netgen/include/h1hofefo_impl.hpp +185 -0
- netgen/include/h1hofespace.hpp +167 -0
- netgen/include/h1lofe.hpp +1240 -0
- netgen/include/h1lumping.hpp +41 -0
- netgen/include/hcurl_equations.hpp +1381 -0
- netgen/include/hcurlcurlfe.hpp +2241 -0
- netgen/include/hcurlcurlfespace.hpp +78 -0
- netgen/include/hcurlfe.hpp +259 -0
- netgen/include/hcurlfe_utils.hpp +107 -0
- netgen/include/hcurlhdiv_dshape.hpp +857 -0
- netgen/include/hcurlhdivfes.hpp +308 -0
- netgen/include/hcurlhofe.hpp +175 -0
- netgen/include/hcurlhofe_impl.hpp +1871 -0
- netgen/include/hcurlhofespace.hpp +193 -0
- netgen/include/hcurllofe.hpp +1146 -0
- netgen/include/hdiv_equations.hpp +880 -0
- netgen/include/hdivdivfe.hpp +2923 -0
- netgen/include/hdivdivsurfacespace.hpp +76 -0
- netgen/include/hdivfe.hpp +206 -0
- netgen/include/hdivfe_utils.hpp +717 -0
- netgen/include/hdivfes.hpp +75 -0
- netgen/include/hdivhofe.hpp +447 -0
- netgen/include/hdivhofe_impl.hpp +1107 -0
- netgen/include/hdivhofefo.hpp +229 -0
- netgen/include/hdivhofespace.hpp +177 -0
- netgen/include/hdivhosurfacefespace.hpp +106 -0
- netgen/include/hdivlofe.hpp +773 -0
- netgen/include/hidden.hpp +74 -0
- netgen/include/householder.hpp +181 -0
- netgen/include/hypre_ams_precond.hpp +123 -0
- netgen/include/hypre_precond.hpp +73 -0
- netgen/include/integrator.hpp +2012 -0
- netgen/include/integratorcf.hpp +253 -0
- netgen/include/interpolate.hpp +49 -0
- netgen/include/intrule.hpp +2542 -0
- netgen/include/intrules_SauterSchwab.hpp +25 -0
- netgen/include/irspace.hpp +49 -0
- netgen/include/jacobi.hpp +153 -0
- netgen/include/kernels.hpp +762 -0
- netgen/include/l2hofe.hpp +194 -0
- netgen/include/l2hofe_impl.hpp +564 -0
- netgen/include/l2hofefo.hpp +542 -0
- netgen/include/l2hofespace.hpp +344 -0
- netgen/include/la.hpp +38 -0
- netgen/include/linearform.hpp +266 -0
- netgen/include/matrix.hpp +2140 -0
- netgen/include/memusage.hpp +41 -0
- netgen/include/meshaccess.hpp +1359 -0
- netgen/include/mgpre.hpp +204 -0
- netgen/include/mp_coefficient.hpp +145 -0
- netgen/include/mptools.hpp +2281 -0
- netgen/include/multigrid.hpp +42 -0
- netgen/include/multivector.hpp +447 -0
- netgen/include/mumpsinverse.hpp +187 -0
- netgen/include/mycomplex.hpp +361 -0
- netgen/include/ng_lapack.hpp +1661 -0
- netgen/include/ngblas.hpp +1232 -0
- netgen/include/ngs_defines.hpp +30 -0
- netgen/include/ngs_stdcpp_include.hpp +106 -0
- netgen/include/ngs_utils.hpp +121 -0
- netgen/include/ngsobject.hpp +1019 -0
- netgen/include/ngsstream.hpp +113 -0
- netgen/include/ngstd.hpp +72 -0
- netgen/include/nodalhofe.hpp +96 -0
- netgen/include/nodalhofe_impl.hpp +141 -0
- netgen/include/normalfacetfe.hpp +223 -0
- netgen/include/normalfacetfespace.hpp +98 -0
- netgen/include/normalfacetsurfacefespace.hpp +84 -0
- netgen/include/order.hpp +251 -0
- netgen/include/parallel_matrices.hpp +222 -0
- netgen/include/paralleldofs.hpp +340 -0
- netgen/include/parallelngs.hpp +23 -0
- netgen/include/parallelvector.hpp +269 -0
- netgen/include/pardisoinverse.hpp +200 -0
- netgen/include/periodic.hpp +129 -0
- netgen/include/plateaufespace.hpp +25 -0
- netgen/include/pml.hpp +275 -0
- netgen/include/pmltrafo.hpp +631 -0
- netgen/include/postproc.hpp +142 -0
- netgen/include/potentialtools.hpp +22 -0
- netgen/include/precomp.hpp +60 -0
- netgen/include/preconditioner.hpp +602 -0
- netgen/include/prolongation.hpp +377 -0
- netgen/include/python_comp.hpp +107 -0
- netgen/include/python_fem.hpp +89 -0
- netgen/include/python_linalg.hpp +58 -0
- netgen/include/python_ngstd.hpp +386 -0
- netgen/include/recursive_pol.hpp +4896 -0
- netgen/include/recursive_pol_tet.hpp +395 -0
- netgen/include/recursive_pol_trig.hpp +492 -0
- netgen/include/reorderedfespace.hpp +81 -0
- netgen/include/sample_sort.hpp +105 -0
- netgen/include/scalarfe.hpp +335 -0
- netgen/include/shapefunction_utils.hpp +113 -0
- netgen/include/simd_complex.hpp +329 -0
- netgen/include/smoother.hpp +253 -0
- netgen/include/solve.hpp +89 -0
- netgen/include/sparsecholesky.hpp +313 -0
- netgen/include/sparsematrix.hpp +1038 -0
- netgen/include/sparsematrix_dyn.hpp +90 -0
- netgen/include/sparsematrix_impl.hpp +1013 -0
- netgen/include/special_matrix.hpp +463 -0
- netgen/include/specialelement.hpp +125 -0
- netgen/include/statushandler.hpp +33 -0
- netgen/include/stringops.hpp +12 -0
- netgen/include/superluinverse.hpp +136 -0
- netgen/include/symbolicintegrator.hpp +850 -0
- netgen/include/symmetricmatrix.hpp +144 -0
- netgen/include/tangentialfacetfe.hpp +224 -0
- netgen/include/tangentialfacetfespace.hpp +91 -0
- netgen/include/tensor.hpp +522 -0
- netgen/include/tensorcoefficient.hpp +446 -0
- netgen/include/tensorproductintegrator.hpp +113 -0
- netgen/include/thcurlfe.hpp +128 -0
- netgen/include/thcurlfe_impl.hpp +380 -0
- netgen/include/thdivfe.hpp +80 -0
- netgen/include/thdivfe_impl.hpp +492 -0
- netgen/include/tpdiffop.hpp +461 -0
- netgen/include/tpfes.hpp +133 -0
- netgen/include/tpintrule.hpp +224 -0
- netgen/include/triangular.hpp +465 -0
- netgen/include/tscalarfe.hpp +245 -0
- netgen/include/tscalarfe_impl.hpp +1029 -0
- netgen/include/umfpackinverse.hpp +148 -0
- netgen/include/vector.hpp +1273 -0
- netgen/include/voxelcoefficientfunction.hpp +41 -0
- netgen/include/vtkoutput.hpp +198 -0
- netgen/include/vvector.hpp +208 -0
- netgen/include/webgui.hpp +92 -0
- netgen/libngbla.dylib +0 -0
- netgen/libngcomp.dylib +0 -0
- netgen/libngfem.dylib +0 -0
- netgen/libngla.dylib +0 -0
- netgen/libngsbem.dylib +0 -0
- netgen/libngsolve.dylib +0 -0
- netgen/libngstd.dylib +0 -0
- ngsolve/TensorProductTools.py +210 -0
- ngsolve/__console.py +94 -0
- ngsolve/__expr.py +181 -0
- ngsolve/__init__.py +148 -0
- ngsolve/__init__.pyi +233 -0
- ngsolve/_scikit_build_core_dependencies.py +30 -0
- ngsolve/bla.pyi +1153 -0
- ngsolve/bvp.py +78 -0
- ngsolve/bvp.pyi +32 -0
- ngsolve/cmake/NGSolveConfig.cmake +102 -0
- ngsolve/cmake/ngsolve-targets-release.cmake +79 -0
- ngsolve/cmake/ngsolve-targets.cmake +163 -0
- ngsolve/comp/__init__.pyi +5449 -0
- ngsolve/comp/pml.pyi +89 -0
- ngsolve/config/__init__.py +1 -0
- ngsolve/config/__init__.pyi +43 -0
- ngsolve/config/__main__.py +4 -0
- ngsolve/config/config.py +60 -0
- ngsolve/config/config.pyi +45 -0
- ngsolve/demos/TensorProduct/__init__.py +0 -0
- ngsolve/demos/TensorProduct/tp_dg_1d_1d.py +80 -0
- ngsolve/demos/TensorProduct/tp_dg_1d_2d.py +73 -0
- ngsolve/demos/TensorProduct/tp_dg_2d_1d.py +72 -0
- ngsolve/demos/TensorProduct/tp_dg_2d_2d.py +66 -0
- ngsolve/demos/__init__.py +0 -0
- ngsolve/demos/howto/__init__.py +0 -0
- ngsolve/demos/howto/hhj.py +44 -0
- ngsolve/demos/howto/hybrid_dg.py +53 -0
- ngsolve/demos/howto/mixed.py +30 -0
- ngsolve/demos/howto/nonlin.py +29 -0
- ngsolve/demos/howto/pickling.py +26 -0
- ngsolve/demos/howto/pml.py +31 -0
- ngsolve/demos/howto/taskmanager.py +20 -0
- ngsolve/demos/howto/tdnns.py +47 -0
- ngsolve/demos/howto/timeDG-skeleton.py +45 -0
- ngsolve/demos/howto/timeDG.py +38 -0
- ngsolve/demos/howto/timeDGlap.py +42 -0
- ngsolve/demos/howto/timeDGwave.py +61 -0
- ngsolve/demos/intro/__init__.py +0 -0
- ngsolve/demos/intro/adaptive.py +123 -0
- ngsolve/demos/intro/cmagnet.py +59 -0
- ngsolve/demos/intro/elasticity.py +76 -0
- ngsolve/demos/intro/navierstokes.py +74 -0
- ngsolve/demos/intro/poisson.ipynb +170 -0
- ngsolve/demos/intro/poisson.py +41 -0
- ngsolve/demos/mpi/__init__.py +0 -0
- ngsolve/demos/mpi/mpi_cmagnet.py +87 -0
- ngsolve/demos/mpi/mpi_navierstokes.py +117 -0
- ngsolve/demos/mpi/mpi_poisson.py +89 -0
- ngsolve/demos/mpi/mpi_timeDG.py +82 -0
- ngsolve/directsolvers.py +26 -0
- ngsolve/directsolvers.pyi +15 -0
- ngsolve/eigenvalues.py +364 -0
- ngsolve/eigenvalues.pyi +30 -0
- ngsolve/fem.pyi +1647 -0
- ngsolve/internal.py +89 -0
- ngsolve/krylovspace.py +1013 -0
- ngsolve/krylovspace.pyi +298 -0
- ngsolve/la.pyi +1230 -0
- ngsolve/meshes.py +748 -0
- ngsolve/ngs2petsc.py +310 -0
- ngsolve/ngscxx.py +42 -0
- ngsolve/ngslib.so +0 -0
- ngsolve/ngstd.pyi +59 -0
- ngsolve/nonlinearsolvers.py +203 -0
- ngsolve/nonlinearsolvers.pyi +95 -0
- ngsolve/preconditioners.py +11 -0
- ngsolve/preconditioners.pyi +7 -0
- ngsolve/solve.pyi +109 -0
- ngsolve/solve_implementation.py +168 -0
- ngsolve/solve_implementation.pyi +42 -0
- ngsolve/solvers.py +7 -0
- ngsolve/solvers.pyi +14 -0
- ngsolve/timestepping.py +185 -0
- ngsolve/timestepping.pyi +28 -0
- ngsolve/timing.py +108 -0
- ngsolve/timing.pyi +54 -0
- ngsolve/utils.py +167 -0
- ngsolve/utils.pyi +273 -0
- ngsolve/webgui.py +670 -0
- ngsolve-6.2.2506.post74.dev0.data/data/Netgen.icns +0 -0
- ngsolve-6.2.2506.post74.dev0.data/data/bin/ngscxx +17 -0
- ngsolve-6.2.2506.post74.dev0.data/data/bin/ngsld +13 -0
- ngsolve-6.2.2506.post74.dev0.data/data/bin/ngsolve.tcl +648 -0
- ngsolve-6.2.2506.post74.dev0.data/data/bin/ngspy +2 -0
- ngsolve-6.2.2506.post74.dev0.data/data/share/ngsolve/beam.geo +17 -0
- ngsolve-6.2.2506.post74.dev0.data/data/share/ngsolve/beam.vol +240 -0
- ngsolve-6.2.2506.post74.dev0.data/data/share/ngsolve/chip.in2d +41 -0
- ngsolve-6.2.2506.post74.dev0.data/data/share/ngsolve/chip.vol +614 -0
- ngsolve-6.2.2506.post74.dev0.data/data/share/ngsolve/coil.geo +12 -0
- ngsolve-6.2.2506.post74.dev0.data/data/share/ngsolve/coil.vol +2560 -0
- ngsolve-6.2.2506.post74.dev0.data/data/share/ngsolve/coilshield.geo +24 -0
- ngsolve-6.2.2506.post74.dev0.data/data/share/ngsolve/coilshield.vol +3179 -0
- ngsolve-6.2.2506.post74.dev0.data/data/share/ngsolve/cube.geo +19 -0
- ngsolve-6.2.2506.post74.dev0.data/data/share/ngsolve/cube.vol +1832 -0
- ngsolve-6.2.2506.post74.dev0.data/data/share/ngsolve/d10_DGdoubleglazing.pde +50 -0
- ngsolve-6.2.2506.post74.dev0.data/data/share/ngsolve/d11_chip_nitsche.pde +40 -0
- ngsolve-6.2.2506.post74.dev0.data/data/share/ngsolve/d1_square.pde +43 -0
- ngsolve-6.2.2506.post74.dev0.data/data/share/ngsolve/d2_chip.pde +35 -0
- ngsolve-6.2.2506.post74.dev0.data/data/share/ngsolve/d3_helmholtz.pde +22 -0
- ngsolve-6.2.2506.post74.dev0.data/data/share/ngsolve/d4_cube.pde +46 -0
- ngsolve-6.2.2506.post74.dev0.data/data/share/ngsolve/d5_beam.pde +74 -0
- ngsolve-6.2.2506.post74.dev0.data/data/share/ngsolve/d6_shaft.pde +73 -0
- ngsolve-6.2.2506.post74.dev0.data/data/share/ngsolve/d7_coil.pde +50 -0
- ngsolve-6.2.2506.post74.dev0.data/data/share/ngsolve/d8_coilshield.pde +49 -0
- ngsolve-6.2.2506.post74.dev0.data/data/share/ngsolve/d9_hybridDG.pde +72 -0
- ngsolve-6.2.2506.post74.dev0.data/data/share/ngsolve/doubleglazing.in2d +27 -0
- ngsolve-6.2.2506.post74.dev0.data/data/share/ngsolve/doubleglazing.vol +737 -0
- ngsolve-6.2.2506.post74.dev0.data/data/share/ngsolve/piezo2d40round4.vol.gz +0 -0
- ngsolve-6.2.2506.post74.dev0.data/data/share/ngsolve/shaft.geo +73 -0
- ngsolve-6.2.2506.post74.dev0.data/data/share/ngsolve/shaft.vol +4291 -0
- ngsolve-6.2.2506.post74.dev0.data/data/share/ngsolve/square.in2d +17 -0
- ngsolve-6.2.2506.post74.dev0.data/data/share/ngsolve/square.vol +149 -0
- ngsolve-6.2.2506.post74.dev0.dist-info/METADATA +13 -0
- ngsolve-6.2.2506.post74.dev0.dist-info/RECORD +315 -0
- ngsolve-6.2.2506.post74.dev0.dist-info/WHEEL +5 -0
- ngsolve-6.2.2506.post74.dev0.dist-info/licenses/LICENSE +504 -0
- ngsolve-6.2.2506.post74.dev0.dist-info/top_level.txt +2 -0
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
{
|
|
2
|
+
"cells": [
|
|
3
|
+
{
|
|
4
|
+
"cell_type": "markdown",
|
|
5
|
+
"metadata": {},
|
|
6
|
+
"source": [
|
|
7
|
+
"Poisson Equation\n",
|
|
8
|
+
"==="
|
|
9
|
+
]
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"cell_type": "markdown",
|
|
13
|
+
"metadata": {},
|
|
14
|
+
"source": [
|
|
15
|
+
"Import Netgen/NGSolve Python modules:"
|
|
16
|
+
]
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"cell_type": "code",
|
|
20
|
+
"execution_count": null,
|
|
21
|
+
"metadata": {},
|
|
22
|
+
"outputs": [],
|
|
23
|
+
"source": [
|
|
24
|
+
"from ngsolve import *\n",
|
|
25
|
+
"from netgen.geom2d import unit_square\n",
|
|
26
|
+
"import netgen.gui\n",
|
|
27
|
+
"%gui tk"
|
|
28
|
+
]
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"cell_type": "markdown",
|
|
32
|
+
"metadata": {},
|
|
33
|
+
"source": [
|
|
34
|
+
"The unit_square is a predefined domain, use Netgen to generate a mesh:"
|
|
35
|
+
]
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"cell_type": "code",
|
|
39
|
+
"execution_count": null,
|
|
40
|
+
"metadata": {},
|
|
41
|
+
"outputs": [],
|
|
42
|
+
"source": [
|
|
43
|
+
"mesh = Mesh(unit_square.GenerateMesh(maxh=0.2))\n",
|
|
44
|
+
"Draw (mesh)"
|
|
45
|
+
]
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"cell_type": "markdown",
|
|
49
|
+
"metadata": {},
|
|
50
|
+
"source": [
|
|
51
|
+
"Define a finite element space on that mesh. "
|
|
52
|
+
]
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"cell_type": "code",
|
|
56
|
+
"execution_count": null,
|
|
57
|
+
"metadata": {},
|
|
58
|
+
"outputs": [],
|
|
59
|
+
"source": [
|
|
60
|
+
"fes = H1(mesh, order=3, dirichlet=\"left|right|bottom|top\")\n",
|
|
61
|
+
"print (\"ndof =\", fes.ndof)"
|
|
62
|
+
]
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"cell_type": "markdown",
|
|
66
|
+
"metadata": {},
|
|
67
|
+
"source": [
|
|
68
|
+
"Define linear and bilinear-forms. Forms are expressed in terms of trial and test-functions:"
|
|
69
|
+
]
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"cell_type": "code",
|
|
73
|
+
"execution_count": null,
|
|
74
|
+
"metadata": {},
|
|
75
|
+
"outputs": [],
|
|
76
|
+
"source": [
|
|
77
|
+
"u = fes.TrialFunction()\n",
|
|
78
|
+
"v = fes.TestFunction()\n",
|
|
79
|
+
"\n",
|
|
80
|
+
"f = LinearForm(fes)\n",
|
|
81
|
+
"f += 32 * (y*(1-y)+x*(1-x)) * v * dx\n",
|
|
82
|
+
"\n",
|
|
83
|
+
"a = BilinearForm(fes)\n",
|
|
84
|
+
"a += grad(u)*grad(v)*dx\n",
|
|
85
|
+
"\n",
|
|
86
|
+
"a.Assemble()\n",
|
|
87
|
+
"f.Assemble()"
|
|
88
|
+
]
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
"cell_type": "markdown",
|
|
92
|
+
"metadata": {},
|
|
93
|
+
"source": [
|
|
94
|
+
"Solve the problem:"
|
|
95
|
+
]
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
"cell_type": "code",
|
|
99
|
+
"execution_count": null,
|
|
100
|
+
"metadata": {},
|
|
101
|
+
"outputs": [],
|
|
102
|
+
"source": [
|
|
103
|
+
"gfu = GridFunction(fes)\n",
|
|
104
|
+
"gfu.vec.data = a.mat.Inverse(fes.FreeDofs()) * f.vec"
|
|
105
|
+
]
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
"cell_type": "markdown",
|
|
109
|
+
"metadata": {},
|
|
110
|
+
"source": [
|
|
111
|
+
"Plot the solution:"
|
|
112
|
+
]
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
"cell_type": "code",
|
|
116
|
+
"execution_count": null,
|
|
117
|
+
"metadata": {},
|
|
118
|
+
"outputs": [],
|
|
119
|
+
"source": [
|
|
120
|
+
"Draw (gfu)\n",
|
|
121
|
+
"Draw (-grad(gfu), mesh, \"Flux\")"
|
|
122
|
+
]
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
"cell_type": "code",
|
|
126
|
+
"execution_count": null,
|
|
127
|
+
"metadata": {},
|
|
128
|
+
"outputs": [],
|
|
129
|
+
"source": [
|
|
130
|
+
"exact = 16*x*(1-x)*y*(1-y)\n",
|
|
131
|
+
"print (\"L2-error:\", sqrt (Integrate ( (gfu-exact)*(gfu-exact), mesh)))"
|
|
132
|
+
]
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
"cell_type": "code",
|
|
136
|
+
"execution_count": null,
|
|
137
|
+
"metadata": {},
|
|
138
|
+
"outputs": [],
|
|
139
|
+
"source": []
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
"cell_type": "code",
|
|
143
|
+
"execution_count": null,
|
|
144
|
+
"metadata": {},
|
|
145
|
+
"outputs": [],
|
|
146
|
+
"source": []
|
|
147
|
+
}
|
|
148
|
+
],
|
|
149
|
+
"metadata": {
|
|
150
|
+
"kernelspec": {
|
|
151
|
+
"display_name": "Python 3",
|
|
152
|
+
"language": "python",
|
|
153
|
+
"name": "python3"
|
|
154
|
+
},
|
|
155
|
+
"language_info": {
|
|
156
|
+
"codemirror_mode": {
|
|
157
|
+
"name": "ipython",
|
|
158
|
+
"version": 3
|
|
159
|
+
},
|
|
160
|
+
"file_extension": ".py",
|
|
161
|
+
"mimetype": "text/x-python",
|
|
162
|
+
"name": "python",
|
|
163
|
+
"nbconvert_exporter": "python",
|
|
164
|
+
"pygments_lexer": "ipython3",
|
|
165
|
+
"version": "3.8.5"
|
|
166
|
+
}
|
|
167
|
+
},
|
|
168
|
+
"nbformat": 4,
|
|
169
|
+
"nbformat_minor": 2
|
|
170
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# solve the Poisson equation -Delta u = f
|
|
2
|
+
# with Dirichlet boundary condition u = 0
|
|
3
|
+
|
|
4
|
+
from ngsolve import *
|
|
5
|
+
# from netgen.geom2d import unit_square
|
|
6
|
+
|
|
7
|
+
ngsglobals.msg_level = 1
|
|
8
|
+
|
|
9
|
+
# generate a triangular mesh of mesh-size 0.2
|
|
10
|
+
mesh = Mesh(unit_square.GenerateMesh(maxh=0.2))
|
|
11
|
+
|
|
12
|
+
# H1-conforming finite element space
|
|
13
|
+
fes = H1(mesh, order=3, dirichlet=[1,2,3,4])
|
|
14
|
+
|
|
15
|
+
# define trial- and test-functions
|
|
16
|
+
u = fes.TrialFunction()
|
|
17
|
+
v = fes.TestFunction()
|
|
18
|
+
|
|
19
|
+
# the right hand side
|
|
20
|
+
f = LinearForm(fes)
|
|
21
|
+
f += 32 * (y*(1-y)+x*(1-x)) * v * dx
|
|
22
|
+
|
|
23
|
+
# the bilinear-form
|
|
24
|
+
a = BilinearForm(fes, symmetric=True)
|
|
25
|
+
a += grad(u)*grad(v)*dx
|
|
26
|
+
|
|
27
|
+
a.Assemble()
|
|
28
|
+
f.Assemble()
|
|
29
|
+
|
|
30
|
+
# the solution field
|
|
31
|
+
gfu = GridFunction(fes)
|
|
32
|
+
gfu.vec.data = a.mat.Inverse(fes.FreeDofs(), inverse="sparsecholesky") * f.vec
|
|
33
|
+
# print (u.vec)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
# plot the solution (netgen-gui only)
|
|
37
|
+
Draw (gfu)
|
|
38
|
+
Draw (-grad(gfu), mesh, "Flux")
|
|
39
|
+
|
|
40
|
+
exact = 16*x*(1-x)*y*(1-y)
|
|
41
|
+
print ("L2-error:", sqrt (Integrate ( (gfu-exact)*(gfu-exact), mesh)))
|
|
File without changes
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
from netgen.csg import *
|
|
2
|
+
import netgen.meshing
|
|
3
|
+
|
|
4
|
+
from ngsolve import *
|
|
5
|
+
|
|
6
|
+
from mpi4py.MPI import COMM_WORLD as comm
|
|
7
|
+
rank = comm.rank
|
|
8
|
+
np = comm.size
|
|
9
|
+
|
|
10
|
+
do_vtk = False
|
|
11
|
+
|
|
12
|
+
def MakeGeometry():
|
|
13
|
+
geometry = CSGeometry()
|
|
14
|
+
box = OrthoBrick(Pnt(-1,-1,-1),Pnt(2,1,2)).bc("outer")
|
|
15
|
+
|
|
16
|
+
core = OrthoBrick(Pnt(0,-0.05,0),Pnt(0.8,0.05,1))- \
|
|
17
|
+
OrthoBrick(Pnt(0.1,-1,0.1),Pnt(0.7,1,0.9))- \
|
|
18
|
+
OrthoBrick(Pnt(0.5,-1,0.4),Pnt(1,1,0.6)).maxh(0.2).mat("core")
|
|
19
|
+
|
|
20
|
+
coil = (Cylinder(Pnt(0.05,0,0), Pnt(0.05,0,1), 0.3) - \
|
|
21
|
+
Cylinder(Pnt(0.05,0,0), Pnt(0.05,0,1), 0.15)) * \
|
|
22
|
+
OrthoBrick (Pnt(-1,-1,0.3),Pnt(1,1,0.7)).maxh(0.2).mat("coil")
|
|
23
|
+
|
|
24
|
+
geometry.Add ((box-core-coil).mat("air"))
|
|
25
|
+
geometry.Add (core)
|
|
26
|
+
geometry.Add (coil)
|
|
27
|
+
return geometry
|
|
28
|
+
|
|
29
|
+
# For curving, we need the geometry. We have to
|
|
30
|
+
# generate it everywhere and then set it.
|
|
31
|
+
# It is not distributed automatically.
|
|
32
|
+
geom = MakeGeometry()
|
|
33
|
+
if rank==0:
|
|
34
|
+
# master proc generates and immediately distributes
|
|
35
|
+
ngmesh = geom.GenerateMesh(maxh=0.5)
|
|
36
|
+
ngmesh.Distribute(comm)
|
|
37
|
+
else:
|
|
38
|
+
# worker procs receive mesh
|
|
39
|
+
ngmesh = netgen.meshing.Mesh.Receive(comm)
|
|
40
|
+
# and then manually set the geometry
|
|
41
|
+
ngmesh.SetGeometry(geom)
|
|
42
|
+
mesh = Mesh(ngmesh)
|
|
43
|
+
|
|
44
|
+
# now we can curve!
|
|
45
|
+
mesh.Curve(5)
|
|
46
|
+
|
|
47
|
+
ngsglobals.msg_level = 5
|
|
48
|
+
|
|
49
|
+
fes = HCurl(mesh, order=4, dirichlet="outer", nograds = True)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
u = fes.TrialFunction()
|
|
53
|
+
v = fes.TestFunction()
|
|
54
|
+
|
|
55
|
+
mur = { "core" : 1000, "coil" : 1, "air" : 1 }
|
|
56
|
+
mu0 = 1.257e-6
|
|
57
|
+
|
|
58
|
+
nu_coef = [ 1/(mu0*mur[mat]) for mat in mesh.GetMaterials() ]
|
|
59
|
+
|
|
60
|
+
nu = CoefficientFunction(nu_coef)
|
|
61
|
+
a = BilinearForm(fes, symmetric=True)
|
|
62
|
+
a += SymbolicBFI(nu*curl(u)*curl(v) + 1e-6*nu*u*v)
|
|
63
|
+
|
|
64
|
+
c = Preconditioner(a, type="bddc", flags={"inverse":"masterinverse"})
|
|
65
|
+
#c = Preconditioner(a, type="bddc", inverse = "mumps")
|
|
66
|
+
|
|
67
|
+
f = LinearForm(fes)
|
|
68
|
+
f += SymbolicLFI(CoefficientFunction((y,0.05-x,0)) * v, definedon=mesh.Materials("coil"))
|
|
69
|
+
|
|
70
|
+
u = GridFunction(fes)
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
a.Assemble()
|
|
74
|
+
f.Assemble()
|
|
75
|
+
solver = CGSolver(mat=a.mat, pre=c.mat)
|
|
76
|
+
u.vec.data = solver * f.vec
|
|
77
|
+
|
|
78
|
+
if do_vtk:
|
|
79
|
+
import os
|
|
80
|
+
output_path = os.path.dirname(os.path.realpath(__file__)) + "/cmagnet_output"
|
|
81
|
+
if rank==0 and not os.path.exists(output_path):
|
|
82
|
+
os.mkdir(output_path)
|
|
83
|
+
comm.Barrier() #wait until master has created the directory!!
|
|
84
|
+
vtk = VTKOutput(ma=mesh, coefs=[u.Deriv()], names=["sol"], filename=output_path+"/vtkout", subdivision=2)
|
|
85
|
+
vtk.Do()
|
|
86
|
+
|
|
87
|
+
#Draw (u.Deriv(), mesh, "B-field", draw_surf=False)
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import netgen.meshing
|
|
2
|
+
from netgen.geom2d import SplineGeometry
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
from ngsolve import *
|
|
6
|
+
|
|
7
|
+
SetNumThreads(1)
|
|
8
|
+
|
|
9
|
+
from mpi4py.MPI import COMM_WORLD as comm
|
|
10
|
+
rank = comm.rank
|
|
11
|
+
np = comm.size
|
|
12
|
+
|
|
13
|
+
do_vtk = False
|
|
14
|
+
|
|
15
|
+
# viscosity
|
|
16
|
+
nu = 0.001
|
|
17
|
+
|
|
18
|
+
# timestepping parameters
|
|
19
|
+
tau = 0.001
|
|
20
|
+
tend = 3
|
|
21
|
+
|
|
22
|
+
# mesh = Mesh("cylinder.vol")
|
|
23
|
+
geo = SplineGeometry()
|
|
24
|
+
geo.AddRectangle( (0, 0), (2, 0.41), bcs = ("wall", "outlet", "wall", "inlet"))
|
|
25
|
+
geo.AddCircle ( (0.2, 0.2), r=0.05, leftdomain=0, rightdomain=1, bc="cyl")
|
|
26
|
+
if rank==0:
|
|
27
|
+
ngmesh = geo.GenerateMesh(maxh=0.08)
|
|
28
|
+
ngmesh.Distribute(comm)
|
|
29
|
+
else:
|
|
30
|
+
ngmesh = netgen.meshing.Mesh.Receive(comm)
|
|
31
|
+
ngmesh.SetGeometry(geo)
|
|
32
|
+
|
|
33
|
+
mesh = Mesh(ngmesh)
|
|
34
|
+
|
|
35
|
+
#does not work with mpi yet...
|
|
36
|
+
#mesh.Curve(3)
|
|
37
|
+
|
|
38
|
+
V = H1(mesh,order=3, dirichlet="wall|cyl|inlet")
|
|
39
|
+
Q = H1(mesh,order=2)
|
|
40
|
+
|
|
41
|
+
X = FESpace([V,V,Q])
|
|
42
|
+
|
|
43
|
+
ux,uy,p = X.TrialFunction()
|
|
44
|
+
vx,vy,q = X.TestFunction()
|
|
45
|
+
|
|
46
|
+
div_u = grad(ux)[0]+grad(uy)[1]
|
|
47
|
+
div_v = grad(vx)[0]+grad(vy)[1]
|
|
48
|
+
|
|
49
|
+
stokes = nu*grad(ux)*grad(vx)+nu*grad(uy)*grad(vy)+div_u*q+div_v*p - 1e-10*p*q
|
|
50
|
+
a = BilinearForm(X)
|
|
51
|
+
a += SymbolicBFI(stokes)
|
|
52
|
+
a.Assemble()
|
|
53
|
+
|
|
54
|
+
# nothing here ...
|
|
55
|
+
f = LinearForm(X)
|
|
56
|
+
f.Assemble()
|
|
57
|
+
|
|
58
|
+
# gridfunction for the solution
|
|
59
|
+
gfu = GridFunction(X)
|
|
60
|
+
|
|
61
|
+
# parabolic inflow at bc=1:
|
|
62
|
+
uin = 1.5*4*y*(0.41-y)/(0.41*0.41)
|
|
63
|
+
gfu.components[0].Set(uin, definedon=mesh.Boundaries("inlet"))
|
|
64
|
+
|
|
65
|
+
velocity = CoefficientFunction(gfu.components[0:2])
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
# solve Stokes problem for initial conditions:
|
|
69
|
+
#inv_stokes = a.mat.Inverse(X.FreeDofs(), inverse="mumps")
|
|
70
|
+
inv_stokes = a.mat.Inverse(X.FreeDofs(), inverse="masterinverse")
|
|
71
|
+
res = f.vec.CreateVector()
|
|
72
|
+
res.data = f.vec - a.mat*gfu.vec
|
|
73
|
+
gfu.vec.data += inv_stokes * res
|
|
74
|
+
|
|
75
|
+
# matrix for implicit Euler
|
|
76
|
+
mstar = BilinearForm(X)
|
|
77
|
+
mstar += SymbolicBFI(ux*vx+uy*vy + tau*stokes)
|
|
78
|
+
mstar.Assemble()
|
|
79
|
+
|
|
80
|
+
# inv = mstar.mat.Inverse(X.FreeDofs(), inverse="masterinverse")
|
|
81
|
+
inv = mstar.mat.Inverse(X.FreeDofs(), inverse="masterinverse")
|
|
82
|
+
|
|
83
|
+
# the non-linear term
|
|
84
|
+
conv = BilinearForm(X, nonassemble = True)
|
|
85
|
+
conv += SymbolicBFI( CoefficientFunction( (ux,uy) ) * (grad(ux)*vx+grad(uy)*vy) )
|
|
86
|
+
|
|
87
|
+
t = 0
|
|
88
|
+
vtk_interval = int(0.05/tau);
|
|
89
|
+
|
|
90
|
+
import os
|
|
91
|
+
#output_path = os.path.dirname(os.path.realpath(__file__)) + "/navierstokes_output"
|
|
92
|
+
output_path = os.path.dirname(os.path.realpath(__file__)) + "/navierstokes_output"
|
|
93
|
+
if rank==0 and not os.path.exists(output_path):
|
|
94
|
+
os.mkdir(output_path)
|
|
95
|
+
comm.Barrier() #wait until master has created the directory!!
|
|
96
|
+
|
|
97
|
+
if do_vtk:
|
|
98
|
+
vtk = VTKOutput(ma=mesh,coefs=[velocity],names=["u"],filename=output_path+"/vtkout",subdivision=2)
|
|
99
|
+
vtk.Do()
|
|
100
|
+
|
|
101
|
+
count = 1;
|
|
102
|
+
# implicit Euler/explicit Euler splitting method:
|
|
103
|
+
with TaskManager():
|
|
104
|
+
while t < tend:
|
|
105
|
+
if rank==0:
|
|
106
|
+
print ("t=", t)
|
|
107
|
+
|
|
108
|
+
conv.Apply (gfu.vec, res)
|
|
109
|
+
res.data += a.mat*gfu.vec
|
|
110
|
+
gfu.vec.data -= tau * inv * res
|
|
111
|
+
|
|
112
|
+
if count%vtk_interval==0 and do_vtk:
|
|
113
|
+
vtk.Do(time = t)
|
|
114
|
+
count = count+1;
|
|
115
|
+
|
|
116
|
+
t = t + tau
|
|
117
|
+
comm.Barrier()
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# Call with:
|
|
2
|
+
# mpirun -np 5 ngspy mpi_poisson.py
|
|
3
|
+
|
|
4
|
+
# Solves -laplace(u)=f on [0,1]^3
|
|
5
|
+
|
|
6
|
+
# netgen-imports
|
|
7
|
+
#from netgen.geom2d import unit_square
|
|
8
|
+
from netgen.csg import unit_cube
|
|
9
|
+
import netgen.meshing
|
|
10
|
+
|
|
11
|
+
# ngsolve-imports
|
|
12
|
+
from ngsolve import *
|
|
13
|
+
|
|
14
|
+
# initialize MPI
|
|
15
|
+
from mpi4py.MPI import COMM_WORLD as comm
|
|
16
|
+
rank = comm.rank
|
|
17
|
+
np = comm.size
|
|
18
|
+
|
|
19
|
+
do_vtk = False
|
|
20
|
+
|
|
21
|
+
print("Hello from rank "+str(rank)+" of "+str(np))
|
|
22
|
+
|
|
23
|
+
if rank==0:
|
|
24
|
+
# master-proc generates mesh
|
|
25
|
+
mesh = unit_cube.GenerateMesh(maxh=0.3)
|
|
26
|
+
# and saves it to file
|
|
27
|
+
mesh.Save("some_mesh.vol")
|
|
28
|
+
|
|
29
|
+
# wait for master to be done meshing
|
|
30
|
+
comm.Barrier()
|
|
31
|
+
|
|
32
|
+
# now load mesh from file
|
|
33
|
+
ngmesh = netgen.meshing.Mesh(dim=3, comm=comm)
|
|
34
|
+
ngmesh.Load("some_mesh.vol")
|
|
35
|
+
|
|
36
|
+
#refine once?
|
|
37
|
+
# ngmesh.Refine()
|
|
38
|
+
|
|
39
|
+
mesh = Mesh(ngmesh)
|
|
40
|
+
|
|
41
|
+
# build H1-FESpace as usual
|
|
42
|
+
V = H1(mesh, order=3, dirichlet=[1,2,3,4])
|
|
43
|
+
u = V.TrialFunction()
|
|
44
|
+
v = V.TestFunction()
|
|
45
|
+
|
|
46
|
+
print("rank "+str(rank)+" has "+str(V.ndof)+" of "+str(V.ndofglobal)+" dofs!")
|
|
47
|
+
|
|
48
|
+
# RHS does not change either!
|
|
49
|
+
f = LinearForm (V)
|
|
50
|
+
f += SymbolicLFI(32 * (y*(1-y)+x*(1-x)) * v)
|
|
51
|
+
f.Assemble()
|
|
52
|
+
|
|
53
|
+
# neither does the BLF!
|
|
54
|
+
a = BilinearForm (V, symmetric=False)
|
|
55
|
+
a += SymbolicBFI(grad(u)*grad(v))
|
|
56
|
+
|
|
57
|
+
# Some possible preconditioners:
|
|
58
|
+
c = Preconditioner(a, type="direct", inverse = "masterinverse") # direct solve with mumps
|
|
59
|
+
#c = Preconditioner(a, type="bddc", inverse = "mumps") # BBDC + mumps for coarse inverse
|
|
60
|
+
#c = Preconditioner(a, type="hypre") # BoomerAMG (use only for order 1)
|
|
61
|
+
#c = Preconditioner(a, type="bddc", usehypre = True) # BDDC + BoomerAMG for coarse matrix
|
|
62
|
+
|
|
63
|
+
a.Assemble()
|
|
64
|
+
|
|
65
|
+
# solve the equation
|
|
66
|
+
u = GridFunction (V)
|
|
67
|
+
u.vec.data = CGSolver(a.mat, c.mat) * f.vec # use CG-solver with preconditioner c
|
|
68
|
+
# u.vec.data = a.mat.Inverse(V.FreeDofs(), inverse="mumps") * f.vec # use MUMPS parallel inverse
|
|
69
|
+
# u.vec.data = a.mat.Inverse(V.FreeDofs(), inverse="masterinverse") * f.vec # use masterinverse (master proc does all the work!)
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
#exact solution
|
|
73
|
+
exact = 16*x*(1-x)*y*(1-y)
|
|
74
|
+
|
|
75
|
+
# error
|
|
76
|
+
error = Integrate ( (u-exact)*(u-exact) , mesh)
|
|
77
|
+
if rank==0:
|
|
78
|
+
print("L2-error", error )
|
|
79
|
+
|
|
80
|
+
if do_vtk:
|
|
81
|
+
# do VTK-output
|
|
82
|
+
import os
|
|
83
|
+
output_path = os.path.dirname(os.path.realpath(__file__)) + "/poisson_output"
|
|
84
|
+
if rank==0 and not os.path.exists(output_path):
|
|
85
|
+
os.mkdir(output_path)
|
|
86
|
+
comm.Barrier() #wait until master has created the directory!!
|
|
87
|
+
|
|
88
|
+
vtk = VTKOutput(mesh, coefs=[u], names=["sol"], filename=output_path+"/vtkout", subdivision=2)
|
|
89
|
+
vtk.Do()
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# Call with:
|
|
2
|
+
# mpirun -np 5 ngspy mpi_timeDG.py
|
|
3
|
+
|
|
4
|
+
# Then make movie with:
|
|
5
|
+
# python3 make_timeDG_movie.py
|
|
6
|
+
# (this only works if you have paraview+python3 configured properly)
|
|
7
|
+
|
|
8
|
+
# circular convection; time-DG with skeleton-formulation
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
from netgen.geom2d import unit_square
|
|
12
|
+
import netgen.meshing
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
from ngsolve import *
|
|
16
|
+
|
|
17
|
+
SetNumThreads(1)
|
|
18
|
+
|
|
19
|
+
from mpi4py.MPI import COMM_WORLD as comm
|
|
20
|
+
rank = comm.rank
|
|
21
|
+
np = comm.size
|
|
22
|
+
|
|
23
|
+
do_vtk = False
|
|
24
|
+
|
|
25
|
+
if rank==0:
|
|
26
|
+
ngmesh = unit_square.GenerateMesh(maxh=0.05)
|
|
27
|
+
ngmesh.Distribute(comm)
|
|
28
|
+
else:
|
|
29
|
+
ngmesh = netgen.meshing.Mesh.Receive(comm)
|
|
30
|
+
mesh = Mesh(ngmesh)
|
|
31
|
+
|
|
32
|
+
# build L2-FESpace
|
|
33
|
+
fes = L2(mesh, order=4)
|
|
34
|
+
|
|
35
|
+
# Trial- and Test-functions
|
|
36
|
+
u = fes.TrialFunction()
|
|
37
|
+
v = fes.TestFunction()
|
|
38
|
+
|
|
39
|
+
# RHS
|
|
40
|
+
b = CoefficientFunction( (y-0.5,0.5-x) )
|
|
41
|
+
bn = b*specialcf.normal(2)
|
|
42
|
+
|
|
43
|
+
# Skeleton DG-formulation
|
|
44
|
+
a = BilinearForm(fes)
|
|
45
|
+
a += SymbolicBFI (-u * b*grad(v))
|
|
46
|
+
a += SymbolicBFI ( bn*IfPos(bn, u, u.Other()) * (v-v.Other()), VOL, skeleton=True)
|
|
47
|
+
a += SymbolicBFI ( bn*IfPos(bn, u, 0) * v, BND, skeleton=True)
|
|
48
|
+
|
|
49
|
+
u = GridFunction(fes)
|
|
50
|
+
u.Set(exp (-40 * ( (x-0.7)*(x-0.7) + (y-0.7)*(y-0.7) )))
|
|
51
|
+
|
|
52
|
+
w = u.vec.CreateVector()
|
|
53
|
+
|
|
54
|
+
t = 0
|
|
55
|
+
tau = 5e-4
|
|
56
|
+
tend = 2
|
|
57
|
+
count = 0
|
|
58
|
+
|
|
59
|
+
vtk_interval = int(0.02/tau);
|
|
60
|
+
|
|
61
|
+
if do_vtk:
|
|
62
|
+
import os
|
|
63
|
+
output_path = os.path.dirname(os.path.realpath(__file__)) + "/timeDG_output"
|
|
64
|
+
if rank==0 and not os.path.exists(output_path):
|
|
65
|
+
os.mkdir(output_path)
|
|
66
|
+
comm.Barrier() #wait until master has created the directory!!
|
|
67
|
+
vtk = VTKOutput(ma=mesh,coefs=[u],names=["sol"],filename=output_path+"/vtkout",subdivision=2)
|
|
68
|
+
|
|
69
|
+
with TaskManager():
|
|
70
|
+
while t < tend:
|
|
71
|
+
if rank==0:
|
|
72
|
+
print("t = ", t)
|
|
73
|
+
a.Apply (u.vec, w)
|
|
74
|
+
fes.SolveM (rho=CoefficientFunction(1), vec=w)
|
|
75
|
+
u.vec.data -= tau * w
|
|
76
|
+
t += tau
|
|
77
|
+
|
|
78
|
+
if count%vtk_interval==0 and do_vtk:
|
|
79
|
+
vtk.Do(time=t)
|
|
80
|
+
count = count+1;
|
|
81
|
+
|
|
82
|
+
comm.Barrier()
|
ngsolve/directsolvers.py
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
from ngsolve import BaseMatrix, BitArray, BilinearForm, BaseVector
|
|
2
|
+
|
|
3
|
+
class SuperLU(BaseMatrix):
|
|
4
|
+
# def __init__(self, a: BaseMatrix | BilinearForm, freedofs: BitArray = None):
|
|
5
|
+
def __init__(self, a, freedofs: BitArray = None):
|
|
6
|
+
super().__init__()
|
|
7
|
+
self.a = a
|
|
8
|
+
self.freedofs = freedofs
|
|
9
|
+
|
|
10
|
+
def Update(self):
|
|
11
|
+
import scipy.sparse as sp
|
|
12
|
+
import scipy.sparse.linalg as spla
|
|
13
|
+
a = self.a if isinstance(self.a, BaseMatrix) else self.a.mat
|
|
14
|
+
mat = sp.csr_matrix(a.CSR())
|
|
15
|
+
if self.freedofs is not None:
|
|
16
|
+
self.fd = list(self.freedofs)
|
|
17
|
+
mat = mat[self.fd,:][:,self.fd]
|
|
18
|
+
self.lu = spla.factorized(sp.csc_matrix(mat))
|
|
19
|
+
|
|
20
|
+
def Mult(self, x: BaseVector, y: BaseVector):
|
|
21
|
+
if not hasattr(self, "lu"):
|
|
22
|
+
self.Update()
|
|
23
|
+
if self.freedofs is not None:
|
|
24
|
+
y.FV().NumPy()[self.fd] = self.lu(x.FV().NumPy()[self.fd])
|
|
25
|
+
else:
|
|
26
|
+
y.FV().NumPy()[:] = self.lu(x.FV().NumPy())
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
from ngsolve.comp import BilinearForm
|
|
3
|
+
import ngsolve.la
|
|
4
|
+
from ngsolve.la import BaseMatrix
|
|
5
|
+
from ngsolve.la import BaseVector
|
|
6
|
+
import pyngcore.pyngcore
|
|
7
|
+
from pyngcore.pyngcore import BitArray
|
|
8
|
+
__all__: list[str] = ['BaseMatrix', 'BaseVector', 'BilinearForm', 'BitArray', 'SuperLU']
|
|
9
|
+
class SuperLU(ngsolve.la.BaseMatrix):
|
|
10
|
+
def Mult(self, x: ngsolve.la.BaseVector, y: ngsolve.la.BaseVector):
|
|
11
|
+
...
|
|
12
|
+
def Update(self):
|
|
13
|
+
...
|
|
14
|
+
def __init__(self, a, freedofs: pyngcore.pyngcore.BitArray = None):
|
|
15
|
+
...
|