├── .gitignore ├── .gitlab-ci.yml ├── .gitmodules ├── CHANGELOG.md ├── CLA.pdf ├── CMakeLists.txt ├── CONTRIBUTING.md ├── Doxyfile ├── LICENSE ├── MacOS └── makedmgs ├── PARALLEL.HOWTO ├── README.md ├── basiclinalg ├── CMakeLists.txt ├── LUdecomposition.cpp ├── LapackGEP.cpp ├── LapackInterface.hpp ├── avector.cpp ├── avector.hpp ├── bandmatrix.cpp ├── bandmatrix.hpp ├── bla.hpp ├── bla.py ├── calcinverse.cpp ├── calcinverse.hpp ├── cholesky.cpp ├── cholesky.hpp ├── clapack.h ├── complex_wrapper.hpp ├── ectypes.hpp ├── eigensystem.cpp ├── eigensystem.hpp ├── expr.hpp ├── generate_mat_kernels.cpp ├── householder.cpp ├── householder.hpp ├── matkernel.hpp ├── matrix.hpp ├── ng_lapack.hpp ├── ngbla.dxx ├── ngbla_main.dxx ├── ngblas.cpp ├── ngblas.hpp ├── ngblasc.cpp ├── python_bla.cpp ├── simd_complex.hpp ├── svd.cpp ├── symmetricmatrix.hpp ├── tensor.hpp ├── timing_ngblas.cpp ├── triangular.cpp ├── triangular.hpp └── vector.hpp ├── bem ├── CMakeLists.txt ├── bem_diffops.hpp ├── fmmoperator.hpp ├── intrules_SauterSchwab.cpp ├── intrules_SauterSchwab.hpp ├── mptools.cpp ├── mptools.hpp ├── ngbem.cpp ├── ngbem.hpp ├── potentialtools.cpp ├── potentialtools.hpp └── python_bem.cpp ├── cmake ├── NGSolveConfig.cmake.in ├── SuperBuild.cmake ├── check_submodules.cmake ├── cmake_modules │ ├── FindHYPRE.cmake │ ├── FindMKL.cmake │ ├── FindMUMPS.cmake │ └── FindSphinx.cmake ├── cmake_uninstall.cmake.in ├── external_projects │ ├── catch.cmake │ ├── hypre.cmake │ ├── mumps.cmake │ ├── mumps.inc │ ├── parmetis.cmake │ └── parmetis.patch ├── generate_version_file.cmake ├── mic.cmake ├── package.cmake ├── package_linux.cmake ├── package_macos.cmake ├── package_osx_fixup.cmake.in ├── package_windows.cmake ├── resources │ ├── .gitignore │ ├── CMakeLists.txt │ ├── LICENSE.txt │ ├── WIX.template.in │ ├── banner.bmp │ ├── extra_features.wxs │ ├── netgen.ico │ ├── ngsolve.rc.template │ ├── resource.h │ ├── sculpture312_50.bmp │ └── wix_patch.xml └── tkdnd_macosx.patch ├── comp ├── CMakeLists.txt ├── applymassl2.hpp ├── bddc.cpp ├── bilinearform.cpp ├── bilinearform.hpp ├── comp.dxx ├── comp.hpp ├── compressedfespace.cpp ├── compressedfespace.hpp ├── contact.cpp ├── contact.hpp ├── discontinuous.cpp ├── discontinuous.hpp ├── facetfespace.cpp ├── facetfespace.hpp ├── facetsurffespace.cpp ├── facetsurffespace.hpp ├── fesconvert.cpp ├── fesconvert.hpp ├── fespace.cpp ├── fespace.hpp ├── globalinterfacespace.cpp ├── globalinterfacespace.hpp ├── globalspace.cpp ├── globalspace.hpp ├── gridfunction.cpp ├── gridfunction.hpp ├── h1amg.cpp ├── h1amg.hpp ├── h1hofespace.cpp ├── h1hofespace.hpp ├── h1lumping.cpp ├── h1lumping.hpp ├── hcurlamg.cpp ├── hcurlamg.hpp ├── hcurlcurlfespace.cpp ├── hcurlcurlfespace.hpp ├── hcurldivfespace.cpp ├── hcurldivfespace.hpp ├── hcurlhdivfes.cpp ├── hcurlhdivfes.hpp ├── hcurlhofespace.cpp ├── hcurlhofespace.hpp ├── hdivdivfespace.cpp ├── hdivdivfespace.hpp ├── hdivdivsurfacespace.cpp ├── hdivdivsurfacespace.hpp ├── hdivfes.cpp ├── hdivfes.hpp ├── hdivhofespace.cpp ├── hdivhofespace.hpp ├── hdivhosurfacefespace.cpp ├── hdivhosurfacefespace.hpp ├── hidden.cpp ├── hidden.hpp ├── hierarchicalee.cpp ├── hypre_ams_precond.cpp ├── hypre_ams_precond.hpp ├── hypre_precond.cpp ├── hypre_precond.hpp ├── interpolate.cpp ├── interpolate.hpp ├── irspace.cpp ├── irspace.hpp ├── l2hofespace.cpp ├── l2hofespace.hpp ├── linearform.cpp ├── linearform.hpp ├── localsolve.cpp ├── matrixfree.cpp ├── meshaccess.cpp ├── meshaccess.hpp ├── ngcomp.dxx ├── ngcomp_main.dxx ├── ngsobject.cpp ├── ngsobject.hpp ├── normalfacetfespace.cpp ├── normalfacetfespace.hpp ├── normalfacetsurfacefespace.cpp ├── normalfacetsurfacefespace.hpp ├── numberfespace.cpp ├── numberfespace.hpp ├── periodic.cpp ├── periodic.hpp ├── plateaufespace.cpp ├── plateaufespace.hpp ├── pmltrafo.hpp ├── postproc.cpp ├── postproc.hpp ├── preconditioner.cpp ├── preconditioner.hpp ├── python_comp.cpp ├── python_comp.hpp ├── python_comp_mesh.cpp ├── reorderedfespace.cpp ├── reorderedfespace.hpp ├── tangentialfacetfespace.cpp ├── tangentialfacetfespace.hpp ├── tpfes.cpp ├── tpfes.hpp ├── vtkoutput.cpp ├── vtkoutput.hpp ├── webgui.cpp └── webgui.hpp ├── config.h.cmake ├── docs ├── CMakeLists.txt ├── _static │ ├── custom.css │ ├── favicon.ico │ ├── logo.png │ └── shallow2D.mov ├── _templates │ ├── breadcrumbs.html │ ├── layout.html │ └── versions.html ├── central │ └── meshes.rst ├── conf.py ├── how_to │ ├── coefficient.rst │ ├── dg.rst │ ├── howto_definedon.rst │ ├── howto_dirichlet.rst │ ├── howto_linalg.rst │ ├── howto_numpy.rst │ ├── howto_parallel.rst │ ├── howto_preconditioners.rst │ ├── howto_staticcondensation.rst │ ├── howto_traceoperator.rst │ ├── periodic.rst │ ├── pml.rst │ ├── res_definedon │ │ └── definedon.py │ ├── res_periodic │ │ ├── periodic1D.py │ │ ├── periodic2D.py │ │ ├── periodic2d.png │ │ ├── periodic3D.py │ │ └── periodic3d.png │ └── symbolic_integrators.rst ├── i-tutorials │ ├── appendix-pickling │ │ └── pickling.ipynb │ ├── appendix-pitfalls │ │ └── pitfalls.ipynb │ ├── appendix-taskmanager │ │ └── taskmanager.ipynb │ ├── appendix-vtk │ │ ├── vtk.ipynb │ │ ├── vtk_example1.png │ │ └── vtk_example2.png │ ├── appendix-webgui │ │ ├── js_console.png │ │ ├── webgui-internal.ipynb │ │ └── webgui.ipynb │ ├── historic │ │ ├── unit-5.0-mpi_basics │ │ │ └── MPI-Parallelization_in_NGSolve.ipynb │ │ ├── unit-5.1-mpi_ngsolve │ │ │ ├── bf_apart.png │ │ │ ├── mat_distr.png │ │ │ ├── mpi_basics.ipynb │ │ │ ├── square.vol │ │ │ ├── square_apart.png │ │ │ └── usrmeeting_jupyterstuff.py │ │ ├── unit-5.2-fetidp_point2d │ │ │ ├── dd_toolbox.py │ │ │ ├── feti-dp-i.ipynb │ │ │ ├── squaref.vol │ │ │ ├── tix_fetidp_standalone.png │ │ │ └── usrmeeting_jupyterstuff.py │ │ ├── unit-5.3-fetidp_point3d │ │ │ ├── cube.vol │ │ │ ├── dd_toolbox.py │ │ │ ├── feti-dp-ii.ipynb │ │ │ ├── tix_fetidp_standalone.png │ │ │ └── usrmeeting_jupyterstuff.py │ │ ├── unit-5.4-fetidp_edge │ │ │ ├── cube.vol │ │ │ ├── dd_toolbox.py │ │ │ ├── feti-dp-iii.ipynb │ │ │ └── usrmeeting_jupyterstuff.py │ │ └── unit-5.5-fetidp_inexact │ │ │ ├── cube.vol │ │ │ ├── dd_toolbox.py │ │ │ ├── feti-dp-iv.ipynb │ │ │ └── usrmeeting_jupyterstuff.py │ ├── index.ipynb │ ├── index.rst │ ├── unit-1.1-poisson │ │ └── poisson.ipynb │ ├── unit-1.2-coefficient │ │ └── coefficientfunction.ipynb │ ├── unit-1.3-dirichlet │ │ └── dirichlet.ipynb │ ├── unit-1.4-staticcond │ │ └── staticcond.ipynb │ ├── unit-1.5-subdomains │ │ └── subdomains.ipynb │ ├── unit-1.6-adaptivity │ │ └── adaptivity.ipynb │ ├── unit-1.7-helmholtz │ │ ├── helmholtz.ipynb │ │ └── pml.ipynb │ ├── unit-1.8-meshtopology │ │ └── meshtopology.ipynb │ ├── unit-10.1-ngspice │ │ └── NGSpiceNGSolve.ipynb │ ├── unit-10.2-tensorflow │ │ └── TensorFlowNGSolve.ipynb │ ├── unit-11.1-fmm │ │ ├── BiotSavart.ipynb │ │ ├── basisfunctions.ipynb │ │ ├── intro_fmm.ipynb │ │ └── layerpotentials.ipynb │ ├── unit-2.1.1-preconditioners │ │ └── preconditioner.ipynb │ ├── unit-2.1.2-blockjacobi │ │ └── blockjacobi.ipynb │ ├── unit-2.1.3-multigrid │ │ └── multigrid.ipynb │ ├── unit-2.1.4-bddc │ │ ├── bddc.ipynb │ │ └── figs │ │ │ └── auxspace.png │ ├── unit-2.1.5-amg │ │ └── amg.ipynb │ ├── unit-2.1.6-highorder-mg │ │ └── highorder-multigrid.ipynb │ ├── unit-2.1.7-facetspace-mg │ │ └── facetspace-mg.ipynb │ ├── unit-2.10-dualbasis │ │ └── dualbasis.ipynb │ ├── unit-2.11-matrixfree │ │ └── matrixfree.ipynb │ ├── unit-2.12-periodicity │ │ ├── dispersion.ipynb │ │ └── periodicity.ipynb │ ├── unit-2.13-interfaces │ │ └── interfaceresistivity.ipynb │ ├── unit-2.14-globalspaces │ │ └── planewavecoupling.ipynb │ ├── unit-2.2-eigenvalues │ │ └── pinvit.ipynb │ ├── unit-2.3-hcurlhdiv │ │ ├── hcurlhdiv.ipynb │ │ └── resources │ │ │ ├── edgeelement.png │ │ │ ├── faceelement.png │ │ │ ├── l2element.png │ │ │ └── nodalelement.png │ ├── unit-2.4-Maxwell │ │ ├── Maxwell.ipynb │ │ └── Maxwellevp.ipynb │ ├── unit-2.5-mixed │ │ └── mixed.ipynb │ ├── unit-2.6-stokes │ │ └── stokes.ipynb │ ├── unit-2.7-hybrid │ │ └── hybrid.ipynb │ ├── unit-2.8-DG │ │ └── DG.ipynb │ ├── unit-2.9-fourthorder │ │ └── fourthorder.ipynb │ ├── unit-3.1-parabolic │ │ ├── helper.py │ │ └── parabolic.ipynb │ ├── unit-3.2-navierstokes │ │ ├── geometry.png │ │ └── navierstokes.ipynb │ ├── unit-3.3-nonlinear │ │ └── nonlinear.ipynb │ ├── unit-3.4-nonlmin │ │ └── nonlmin.ipynb │ ├── unit-3.5.1-dgapply │ │ └── dgapply-scalar.ipynb │ ├── unit-3.5.2-wavedg │ │ └── wavedg.ipynb │ ├── unit-3.6-surfacehdg │ │ ├── elementupwind.png │ │ ├── facetupwind.png │ │ └── surfacehdg.ipynb │ ├── unit-3.7-opsplit │ │ ├── opsplit.ipynb │ │ └── resources │ │ │ └── stokeshdghdiv.png │ ├── unit-3.8-simplehyp │ │ ├── DGdiffusion.py │ │ ├── geomsketch.png │ │ ├── shallow2D.ipynb │ │ ├── shallow2D.mov │ │ └── shallow2D.mp4 │ ├── unit-4.1.1-geom2d │ │ └── geom2d.ipynb │ ├── unit-4.1.2-csg2d │ │ └── csg2d.ipynb │ ├── unit-4.2-csg │ │ └── csg.ipynb │ ├── unit-4.3-manualmesh │ │ └── manualmeshing.ipynb │ ├── unit-4.4-occ │ │ ├── bottle.ipynb │ │ ├── occ.ipynb │ │ └── workplane.ipynb │ ├── unit-5.5-cuda │ │ ├── EulerEquations.ipynb │ │ ├── pictures │ │ │ ├── auxspace.png │ │ │ └── bddc-tracings.png │ │ ├── poisson_cuda.ipynb │ │ ├── ring_resonator_import.py │ │ └── wave_cuda.ipynb │ ├── unit-5a.1-mpi │ │ ├── drawsolution.py │ │ ├── poisson_mpi.ipynb │ │ └── poisson_mpi.py │ ├── unit-5a.2-pardofs │ │ └── pardofs.ipynb │ ├── unit-5a.3-petsc │ │ ├── PETSc_interface.ipynb │ │ ├── n2p_ex1.py │ │ └── petsc.ipynb │ ├── unit-6.1.1-surfacemeshes │ │ └── surface_meshes.ipynb │ ├── unit-6.1.2-surfacepde │ │ └── surface_pdes.ipynb │ ├── unit-6.1.3-rmplate │ │ └── Reissner_Mindlin_plate.ipynb │ ├── unit-6.1.4-shells │ │ └── shell.ipynb │ ├── unit-6.2-contact │ │ └── contact.ipynb │ ├── unit-6.3-plasticity │ │ └── plasticity.ipynb │ ├── unit-7-optimization │ │ ├── 01_Shape_Derivative_Levelset.ipynb │ │ ├── 02_Shape_Derivative_Laplace.ipynb │ │ ├── 03_Shape_Derivative_Laplace_SemiAuto.ipynb │ │ ├── 03b_Shape_Derivative_Laplace_FullyAuto.ipynb │ │ ├── 04_Topological_Derivative_Levelset.ipynb │ │ ├── 05_Topological_Derivative_Transmission.ipynb │ │ ├── interpolations.py │ │ ├── opt_vs_init.png │ │ └── psi_iter999.png │ ├── unit-8.1-basics │ │ └── basics.ipynb │ ├── unit-8.2-intlset │ │ ├── graphics │ │ │ └── lsetcurv.jpg │ │ └── intlset.ipynb │ ├── unit-8.3-cutfem │ │ ├── cutfem.ipynb │ │ └── graphics │ │ │ ├── SpaceBoth.png │ │ │ ├── SpaceInner.png │ │ │ ├── SpaceOuter.png │ │ │ ├── bubble_coarse.png │ │ │ ├── lsetcurv.jpg │ │ │ ├── xfem1.png │ │ │ └── xfem2.png │ ├── unit-8.4-spacetime_fitted │ │ ├── helper.py │ │ └── spacetime_fitted.ipynb │ ├── unit-8.5-spacetime_unfitted │ │ ├── graphics │ │ │ ├── limits-time-slab.png │ │ │ └── macro-element.png │ │ ├── helper.py │ │ └── spacetime_unfitted.ipynb │ ├── unit-8.6-mlset_basic │ │ ├── graphics │ │ │ └── z_disc.png │ │ └── mlset_basic.ipynb │ ├── unit-8.7-mlset_pde │ │ ├── graphics │ │ │ └── mlset_cuts.png │ │ └── mlset_pde.ipynb │ ├── unit-8.8-aggregation │ │ ├── aggregation.ipynb │ │ └── helper.py │ ├── unit-8.9-unfmixed │ │ ├── graphics │ │ │ └── elpp.png │ │ └── unfmixed.ipynb │ ├── unit-9.1-C++FE │ │ ├── CppExtension.ipynb │ │ ├── myDiffOp.hpp │ │ ├── myElement.cpp │ │ ├── myElement.hpp │ │ ├── myFESpace.cpp │ │ ├── myFESpace.hpp │ │ └── mymodule.cpp │ ├── unit-9.2-C++Assemble │ │ ├── cppassembling.ipynb │ │ ├── myAssembling.cpp │ │ ├── myIntegrator.cpp │ │ ├── myIntegrator.hpp │ │ └── myassemblemodule.cpp │ ├── unit-9.3-highorder │ │ ├── highorder.ipynb │ │ ├── myHOElement.cpp │ │ ├── myHOElement.hpp │ │ ├── myHOFESpace.cpp │ │ ├── myHOFESpace.hpp │ │ └── mymodule.cpp │ └── wta │ │ ├── adaptivity.ipynb │ │ ├── coil.ipynb │ │ ├── elasticity.ipynb │ │ ├── elasticity3D.ipynb │ │ ├── fembem.ipynb │ │ ├── maxwell.ipynb │ │ ├── navierstokes.ipynb │ │ ├── poisson.ipynb │ │ └── rotating.ipynb ├── index.rst ├── install │ ├── cmakeoptions.rst │ ├── compilengsolve.sh │ ├── gettingstarted.rst │ ├── install_sources.rst │ ├── installlinux.rst │ ├── installmacnative.rst │ ├── installwindows.rst │ ├── setenviron_mac.sh │ └── usejupyter.rst ├── netgen_tutorials │ ├── define_2d_geometries.rst │ ├── define_3d_geometries.rst │ ├── manual_mesh_generation.rst │ ├── meshsize.rst │ ├── res_define_2d_geometries │ │ └── twodomains.png │ ├── res_meshsize │ │ ├── closesurface_plate.png │ │ ├── closesurface_plate.py │ │ ├── csg_localmeshsize.png │ │ └── csg_localmeshsize.py │ └── working_with_meshes.rst └── whetting_the_appetite │ ├── adaptive.rst │ ├── cmagnet.rst │ ├── elasticity.rst │ ├── navierstokes.rst │ ├── poisson.rst │ ├── res_adaptive │ ├── adaptive_err.png │ └── adaptive_solution.jpg │ ├── res_cmagnet │ ├── cmagnet_mesh.jpg │ └── cmagnet_solution.jpg │ ├── res_navierstokes │ └── navierstokes_solution.jpg │ └── res_poisson │ └── poisson_solution.jpg ├── doxymain ├── emscripten ├── CMakeLists.txt ├── em_ngs.cpp └── example.ipynb ├── external_dependencies └── CMakeLists.txt ├── fem ├── CMakeLists.txt ├── DGIntegrators.cpp ├── bdbequations.cpp ├── bdbequations.hpp ├── bdbintegrator.hpp ├── code_generation.cpp ├── code_generation.hpp ├── coefficient.cpp ├── coefficient.hpp ├── coefficient_geo.cpp ├── coefficient_impl.hpp ├── coefficient_matrix.cpp ├── coefficient_matrix.hpp ├── coefficient_stdmath.cpp ├── coefficient_stdmath.hpp ├── differentialoperator.hpp ├── diffop.cpp ├── diffop.hpp ├── diffop_grad.cpp ├── diffop_hesse.cpp ├── diffop_id.cpp ├── diffop_impl.hpp ├── elasticity_equations.hpp ├── elementtopology.cpp ├── elementtopology.hpp ├── elementtransformation.cpp ├── elementtransformation.hpp ├── facetfe.hpp ├── facethofe.cpp ├── facethofe.hpp ├── fe_interfaces.hpp ├── fem.hpp ├── fem_kernels.cu ├── finiteelement.cpp ├── finiteelement.hpp ├── h1hofe.cpp ├── h1hofe.hpp ├── h1hofe_hex.cpp ├── h1hofe_impl.hpp ├── h1hofe_prism.cpp ├── h1hofe_pyramid.cpp ├── h1hofe_quad.cpp ├── h1hofe_segm.cpp ├── h1hofe_tet.cpp ├── h1hofe_trig.cpp ├── h1hofefo.cpp ├── h1hofefo.hpp ├── h1hofefo_impl.hpp ├── h1lofe.cpp ├── h1lofe.hpp ├── hcurl_equations.hpp ├── hcurlcurlfe.cpp ├── hcurlcurlfe.hpp ├── hcurldivfe.hpp ├── hcurldivfe_impl.hpp ├── hcurlfe.cpp ├── hcurlfe.hpp ├── hcurlfe_utils.hpp ├── hcurlhdiv_dshape.hpp ├── hcurlhofe.cpp ├── hcurlhofe.hpp ├── hcurlhofe_hex.cpp ├── hcurlhofe_impl.hpp ├── hcurlhofe_prism.cpp ├── hcurlhofe_pyramid.cpp ├── hcurlhofe_tet.cpp ├── hcurllofe.hpp ├── hdiv_equations.cpp ├── hdiv_equations.hpp ├── hdivdivfe.cpp ├── hdivdivfe.hpp ├── hdivfe.cpp ├── hdivfe.hpp ├── hdivfe_utils.hpp ├── hdivhofe.cpp ├── hdivhofe.hpp ├── hdivhofe_impl.hpp ├── hdivhofefo.hpp ├── hdivlofe.hpp ├── hybridDG.cpp ├── integrator.cpp ├── integrator.hpp ├── integratorcf.hpp ├── intrule.cpp ├── intrule.hpp ├── l2hofe.cpp ├── l2hofe.hpp ├── l2hofe_impl.hpp ├── l2hofe_segm.cpp ├── l2hofe_tet.cpp ├── l2hofe_trig.cpp ├── l2hofefo.cpp ├── l2hofefo.hpp ├── l2hofetp.cpp ├── l2hofetp.hpp ├── maxwellintegrator.cpp ├── newtonCF.cpp ├── ngfemcf.py ├── nodalhofe.cpp ├── nodalhofe.hpp ├── nodalhofe_impl.hpp ├── normalfacetfe.cpp ├── normalfacetfe.hpp ├── pml.cpp ├── pml.hpp ├── polynomials.hpp ├── precomp.hpp ├── python_fem.cpp ├── python_fem.hpp ├── recursive_pol.cpp ├── recursive_pol.hpp ├── recursive_pol_tet.hpp ├── recursive_pol_trig.cpp ├── recursive_pol_trig.hpp ├── scalarfe.cpp ├── scalarfe.hpp ├── shapefunction_utils.hpp ├── specialelement.cpp ├── specialelement.hpp ├── symbolicintegrator.cpp ├── symbolicintegrator.hpp ├── tangentialfacetfe.cpp ├── tangentialfacetfe.hpp ├── tensorcoefficient.cpp ├── tensorcoefficient.hpp ├── tensorproductintegrator.cpp ├── tensorproductintegrator.hpp ├── thcurlfe.hpp ├── thcurlfe_impl.hpp ├── thdivfe.hpp ├── thdivfe_impl.hpp ├── tpdiffop.cpp ├── tpdiffop.hpp ├── tpintrule.hpp ├── tscalarfe.hpp ├── tscalarfe_impl.hpp ├── voxelcoefficientfunction.cpp └── voxelcoefficientfunction.hpp ├── include ├── CMakeLists.txt ├── bla.hpp ├── comp.hpp ├── compatibility.hpp ├── fem.hpp ├── la.hpp ├── multigrid.hpp ├── ngs_defines.hpp ├── ngs_stdcpp_include.hpp ├── ngstd.hpp ├── parallelngs.hpp └── solve.hpp ├── linalg ├── CMakeLists.txt ├── arnoldi.cpp ├── arnoldi.hpp ├── basematrix.cpp ├── basematrix.hpp ├── basevector.cpp ├── basevector.hpp ├── blockjacobi.cpp ├── blockjacobi.hpp ├── cg.cpp ├── cg.hpp ├── chebyshev.cpp ├── chebyshev.hpp ├── commutingAMG.cpp ├── commutingAMG.hpp ├── diagonalmatrix.cpp ├── diagonalmatrix.hpp ├── eigen.cpp ├── eigen.hpp ├── elementbyelement.cpp ├── elementbyelement.hpp ├── jacobi.cpp ├── jacobi.hpp ├── la.hpp ├── la.py ├── multivector.cpp ├── multivector.hpp ├── mumpsinverse.cpp ├── mumpsinverse.hpp ├── ngla.dxx ├── ngla_main.dxx ├── order.cpp ├── order.hpp ├── paralleldofs.cpp ├── paralleldofs.hpp ├── pardisoinverse.cpp ├── pardisoinverse.hpp ├── python_linalg.cpp ├── python_linalg.hpp ├── sparsecholesky.cpp ├── sparsecholesky.hpp ├── sparsematrix.cpp ├── sparsematrix.hpp ├── sparsematrix_dyn.cpp ├── sparsematrix_dyn.hpp ├── sparsematrix_impl.hpp ├── special_matrix.cpp ├── special_matrix.hpp ├── superluinverse.cpp ├── superluinverse.hpp ├── umfpackinverse.cpp ├── umfpackinverse.hpp └── vvector.hpp ├── multigrid ├── CMakeLists.txt ├── mgpre.cpp ├── mgpre.hpp ├── multigrid.hpp ├── prolongation.cpp ├── prolongation.hpp ├── smoother.cpp └── smoother.hpp ├── ngs.dxx ├── ngscuda ├── CMakeLists.txt ├── concurrentqueue.h ├── cuda_applyIR.cpp ├── cuda_bla.hpp ├── cuda_linalg.cpp ├── cuda_linalg.hpp ├── cuda_ngbla.hpp ├── cuda_ngstd.cpp ├── cuda_ngstd.hpp ├── cuda_profiler.cu ├── cuda_profiler.hpp ├── cuda_tasks.cpp ├── demo1.cpp ├── dev_blockjacobi.cpp ├── dev_sparsecholesky.cpp ├── examples │ ├── devdmatrix.py │ ├── devsparsemat.py │ ├── jacobi.py │ ├── matrixfree.ipynb │ └── unifiedvector.py ├── linalg_kernels.cu ├── linalg_kernels.hpp ├── python_ngscuda.cpp ├── unifiedvector.cpp └── unifiedvector.hpp ├── ngsolve.tcl ├── ngstd ├── CMakeLists.txt ├── bessel.hpp ├── blockalloc.cpp ├── blockalloc.hpp ├── bspline.cpp ├── bspline.hpp ├── evalfunc.cpp ├── evalfunc.hpp ├── memusage.hpp ├── mycomplex.hpp ├── ngs_utils.hpp ├── ngsstream.hpp ├── ngstd.dxx ├── ngstd.hpp ├── ngstd_main.dxx ├── polorder.hpp ├── python_ngstd.cpp ├── python_ngstd.hpp ├── sample_sort.hpp ├── statushandler.cpp ├── statushandler.hpp ├── stringops.cpp ├── stringops.hpp └── templates.cpp ├── parallel ├── CMakeLists.txt ├── dump.hpp ├── parallel_matrices.cpp ├── parallel_matrices.hpp ├── parallelngs.hpp ├── parallelvector.hpp └── parallelvvector.cpp ├── pde_tutorial ├── CMakeLists.txt ├── beam.geo ├── beam.vol ├── chip.in2d ├── chip.vol ├── coil.geo ├── coil.vol ├── coilshield.geo ├── coilshield.vol ├── cube.geo ├── cube.vol ├── d10_DGdoubleglazing.pde ├── d11_chip_nitsche.pde ├── d1_square.pde ├── d2_chip.pde ├── d3_helmholtz.pde ├── d4_cube.pde ├── d5_beam.pde ├── d6_shaft.pde ├── d7_coil.pde ├── d8_coilshield.pde ├── d9_hybridDG.pde ├── doubleglazing.in2d ├── doubleglazing.vol ├── piezo2d40round4.vol.gz ├── pml │ ├── arperture.geo │ ├── arperture.vol.gz │ ├── cavity.in2d │ ├── cavity.pde │ ├── cavity.py │ ├── cavity.vol.gz │ ├── circle_evs.py │ ├── pml_maxwell.pde │ ├── scattering.in2d │ ├── scattering.pde │ ├── scattering.py │ └── scattering.vol.gz ├── shaft.geo ├── shaft.vol ├── square.in2d └── square.vol ├── pde_tutorial_py ├── beam.geo ├── beam.vol ├── chip.in2d ├── d1_square.py ├── d2_chip.py └── d5_beam.py ├── pictures ├── logo-col-big.xcf ├── logo-col-big2.png ├── logo-col-med.xcf ├── logo-col-med2.png ├── logo-col-small.xcf ├── logo-col-small2.png ├── logo.icns ├── shell-picture.xcf └── shell-picture2.png ├── py_tutorials ├── CMakeLists.txt ├── DG │ ├── nitsche.py │ ├── periodic.py │ ├── timeDG-skeleton.py │ ├── timeDG.py │ ├── timeDGlap.py │ └── timeDGwave.py ├── TensorProduct │ ├── tp_dg_1d_1d.py │ ├── tp_dg_1d_2d.py │ ├── tp_dg_2d_1d.py │ └── tp_dg_2d_2d.py ├── __init__.py ├── adaptive.py ├── ale.pde ├── ale.py ├── all_in_one.py ├── assemble.py ├── bla.py ├── blocksmoothing.py ├── cg.py ├── cmagnet.py ├── compound.py ├── cube.vol.gz ├── d1_square.pde ├── elasticity.py ├── fem1d.py ├── genmesh.py ├── hdivdiv │ ├── hhj.py │ └── tdnns.py ├── hybrid_dg.py ├── instat.pde ├── instat.py ├── integrator.py ├── linalg.py ├── main_instat.py ├── mesh.py ├── mixed.py ├── module1.py ├── mpi │ ├── CMakeLists.txt │ ├── mpi_cmagnet.py │ ├── mpi_navierstokes.py │ ├── mpi_poisson.py │ └── mpi_timeDG.py ├── navierstokes.py ├── nonlin.py ├── pickling.py ├── pml.py ├── pmltest3d.py ├── poisson.ipynb ├── poisson.py ├── scattering.py ├── scattering_triangle.py ├── setorder.py ├── square.in2d ├── square.vol ├── square.vol.gz ├── symbolic.py ├── symbolic_energy.py ├── taskmanager.py ├── timeDGlap.py ├── timing.py └── vtkout.py ├── python ├── CMakeLists.txt ├── TensorProductTools.py ├── __console.py ├── __expr.py ├── __init__.py ├── _scikit_build_core_dependencies.py ├── bvp.py ├── config │ ├── __init__.py │ ├── __main__.py │ └── config.py ├── directsolvers.py ├── eigenvalues.py ├── internal.py ├── krylovspace.py ├── meshes.py ├── ngs2petsc.py ├── ngscxx.py ├── nonlinearsolvers.py ├── preconditioners.py ├── solve_implementation.py ├── solvers.py ├── timestepping.py ├── timing.py ├── utils.py └── webgui.py ├── setup.py ├── solve ├── CMakeLists.txt ├── ngsolve.cpp ├── ngspy.cpp ├── nptests.cpp ├── python_solve.cpp └── solve.hpp └── tests ├── CMakeLists.txt ├── acc_tests ├── circle.in2d ├── circle.vol.gz ├── poisson_circle.pde ├── poisson_circle_HDG.pde └── poisson_circle_HDG_hodc.pde ├── build_debug.sh ├── build_pip.ps1 ├── build_pip.sh ├── build_pip_mac.sh ├── catch ├── 2_doms.vol ├── CMakeLists.txt ├── coefficientfunction.cpp ├── cube.vol ├── finiteelement.cpp ├── line.vol ├── main.cpp ├── meshaccess.cpp ├── ngblas.cpp └── square.vol ├── gitlab-ci ├── conda │ ├── .gitignore │ ├── generate_meta_files.py │ ├── netgen │ │ ├── bld.bat │ │ ├── build.sh │ │ ├── conda_build_config.yaml │ │ └── meta_template.yaml │ └── ngsolve │ │ ├── bld.bat │ │ ├── build.sh │ │ ├── conda_build_config.yaml │ │ └── meta_template.yaml ├── deploy.yml ├── deploy │ ├── mac.sh │ ├── nightly.sh │ ├── release.sh │ └── win.sh ├── linux.yml ├── mac.yml ├── mac │ ├── build.sh │ ├── cleanup.sh │ ├── set_vars.sh │ └── test.sh ├── pip.yml ├── pyodide │ ├── Dockerfile │ ├── build.sh │ ├── build_in_docker.sh │ ├── build_opencascade.sh │ ├── generate_repodata.js │ └── merge.py ├── timings.sh ├── ubuntu │ ├── build.sh │ ├── build_in_docker.sh │ ├── cleanup.sh │ ├── docker_template │ └── test.sh ├── win.yml └── win │ ├── build.bat │ ├── cleanup.bat │ ├── set_vars.bat │ ├── test.bat │ └── upload.bat ├── pde_tutorial ├── d10_DGdoubleglazing.pde.appx ├── d11_chip_nitsche.pde.appx ├── d1_square.pde.appx ├── d2_chip.pde.appx ├── d3_helmholtz.pde.appx ├── d4_cube.pde.appx ├── d5_beam.pde.appx ├── d6_shaft.pde.appx ├── d7_coil.pde.appx ├── d8_coilshield.pde.appx └── d9_hybridDG.pde.appx ├── pytest ├── CMakeLists.txt ├── conftest.py ├── cube.vol.gz ├── elements.py ├── meshes.py ├── mpi_only │ ├── square.vol.gz │ └── test_subcomm.py ├── space_utils.py ├── square.vol.gz ├── test_1d.py ├── test_basematrix.py ├── test_bem.py ├── test_cache.py ├── test_cf_multiplications.py ├── test_code_generation.py ├── test_coefficient.py ├── test_compound_fes.py ├── test_contact.py ├── test_convection1d_dg.py ├── test_detect_symmetric.py ├── test_dual.py ├── test_einsum.py ├── test_evaluate.py ├── test_fespace_diffops.py ├── test_fespaces.py ├── test_hdg1d.py ├── test_hidden.py ├── test_integrate.py ├── test_interpolate.py ├── test_matrix.py ├── test_mesh.py ├── test_newton_cf.py ├── test_nodeaccess.py ├── test_periodic.py ├── test_pickling.py ├── test_shapeoptimization.py ├── test_solvers.py └── test_vector.py ├── timings ├── CMakeLists.txt └── timings.py └── umfpack.py /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | /docs/mylittlengs 3 | *.o 4 | *.so 5 | tests/pytest/code*.cpp 6 | py_tutorials/code*.cpp 7 | .vs 8 | out 9 | CMakeSettings.json 10 | /external_dependencies/*.tar.gz 11 | /external_dependencies/*.tgz 12 | #for using lsp-mode on emacs the compile_commands.json must be in the source folder 13 | compile_commands.json 14 | .cquery_cached_index 15 | ng*.html 16 | ng*.trace 17 | *.vtk 18 | .ipynb_checkpoints/ 19 | dist 20 | _skbuild 21 | .vscode 22 | ngsolve-py3.egg-info 23 | 24 | build 25 | em_build 26 | em_install 27 | __pycache__ 28 | vtk_example1.vtu 29 | vtk_example2.pvd 30 | vtk_example2.vtu 31 | vtk_example3.pvd 32 | vtk_example3.vtu 33 | vtk_example2_step*.vtu 34 | vtk_example3_step*.vtu 35 | tests/pytest/*.log 36 | tests/pytest/*.log_* 37 | docs/i-tutorials/unit-5a.1-mpi/solution.pickle* 38 | -------------------------------------------------------------------------------- /.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | stages: 2 | - build 3 | - test 4 | - timings 5 | - cleanup 6 | - deploy 7 | 8 | variables: 9 | GIT_SUBMODULE_STRATEGY: recursive 10 | UBUNTU_VERSION_LATEST: "24.10" 11 | UBUNTU_VERSION_LTS: "24.04" 12 | 13 | include: 14 | - tests/gitlab-ci/win.yml 15 | - tests/gitlab-ci/mac.yml 16 | - tests/gitlab-ci/linux.yml 17 | - tests/gitlab-ci/deploy.yml 18 | - tests/gitlab-ci/pip.yml 19 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "external_dependencies/netgen"] 2 | path = external_dependencies/netgen 3 | url = https://github.com/NGSolve/netgen.git 4 | ignore = dirty 5 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 2 | - Make Netgen GUI available from Python ('import netgen.gui') 3 | - Add CHANGELOG.md file 4 | -------------------------------------------------------------------------------- /CLA.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NGSolve/ngsolve/cab3abd87bbc83654d6b50d275be06e40cb3f040/CLA.pdf -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | 2 | # How to Contribute 3 | 4 | ## Reporting issues 5 | 6 | If you have a problem using Netgen/NGSolve consider asking a question in our [forum](https://ngsolve.org/forum). 7 | 8 | If you found a bug create an issue in the [Github Issue Tracker](https://github.com/NGSolve/ngsolve/issues). Please be as specific as possible, issues with a reproducible minimal failing example will get more attention than unspecific one liners :) 9 | 10 | ## Contributing patches 11 | 12 | We love and want to encourage community engagement and will review and accept patches and contributions to this project. There are just a few steps to follow: 13 | 14 | On your first contribution, to clear any legal questions, we ask you to sign our [Contributor License Agreement](CLA.pdf). Generally you have to sign this only once for Netgen or NGSolve. Please send the signed agreement to . 15 | 16 | Place a pull request on GitHub. From there we will pull it into our internal testing environment and, if approved, merge it into the main codebase. 17 | 18 | If you have any questions feel free to ask on the [forum](https://ngsolve.org/forum). 19 | -------------------------------------------------------------------------------- /PARALLEL.HOWTO: -------------------------------------------------------------------------------- 1 | Parallel Netgen / NGSolve 2 | 3 | 4 | Netgen/NGSolve supports distributed memory MPI - parallelization. 5 | 6 | 7 | To compile parallel Netgen/NGSolve you need the following packages installed: 8 | 9 | - mpi (tested with openmpi, mpich2) 10 | - metis (mesh partitioning library) 11 | 12 | 13 | Configure Netgen and NGSolve with: 14 | ./configure --enable-parallel CXX=mpic++ 15 | 16 | 17 | run Netgen in parallel (with 8 processes) with 18 | 19 | mpiexec -np 8 netgen 20 | 21 | 22 | 23 | NGS parallelization supports: 24 | 25 | - mesh distribution: 26 | testing: load mesh will distributed it 27 | 28 | - parallel NGSolve - pde data structure including fespaces, biforms, distributed sparse matrices 29 | - BDDC preconditioning 30 | - parallel direct solver mumps 31 | 32 | 33 | 34 | MPI and OpenMP 35 | - parallel compute thread is supported, but it requires multi-threading capable MPI 36 | openmpi (tested with 1.4.3) needs configuration with --enable-mpi-threads 37 | 38 | - openmp threads are disabled 39 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | Multi-purpose finite element library 3 | 4 | Find the Open Source Community on https://ngsolve.org 5 | 6 | Support & Services: https://cerbsim.com 7 | -------------------------------------------------------------------------------- /basiclinalg/bla.hpp: -------------------------------------------------------------------------------- 1 | #ifndef FILE_NGBLA 2 | #define FILE_NGBLA 3 | 4 | 5 | #include 6 | 7 | 8 | #include "complex_wrapper.hpp" 9 | 10 | #include "expr.hpp" 11 | #include "vector.hpp" 12 | #include "matrix.hpp" 13 | #include "ngblas.hpp" 14 | #include "cholesky.hpp" 15 | #include "symmetricmatrix.hpp" 16 | #include "bandmatrix.hpp" 17 | #include "triangular.hpp" 18 | #include "householder.hpp" 19 | #include "tensor.hpp" 20 | #include "eigensystem.hpp" 21 | 22 | // so far we can move stuff to ngcore 23 | 24 | #include "calcinverse.hpp" 25 | #include "simd_complex.hpp" 26 | 27 | #include "ng_lapack.hpp" 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /basiclinalg/bla.py: -------------------------------------------------------------------------------- 1 | ############################################### 2 | # Additional operators 3 | ############################################### 4 | 5 | FlatVector.expr = property(lambda self: VecExpr(self)) 6 | FlatVector.data = property(lambda self: None, lambda self, a: Expr(a).AssignTo(self.expr)) 7 | FlatVector.__add__ = lambda self,y: self.expr+Expr(y) 8 | FlatVector.__rmul__ = lambda self,y: y*self.expr 9 | FlatVector.__getitem__ = GetSlice 10 | FlatVector.__setitem__ = SetSlice 11 | 12 | # FlatMatrix.expr = property(lambda self: MatExpr(self)) 13 | # FlatMatrix.data = property(lambda self: None, lambda self, a: Expr(a).AssignTo(self.expr)) 14 | # FlatMatrix.__add__ = lambda self,y: self.expr+Expr(y) 15 | # FlatMatrix.__rmul__ = lambda self,y: y*self.expr 16 | # FlatMatrix.__mul__ = lambda self,y: MatVecExpr(self.expr, Expr(y)) 17 | -------------------------------------------------------------------------------- /basiclinalg/eigensystem.hpp: -------------------------------------------------------------------------------- 1 | #ifndef EIGENSYSTEM_HPP 2 | #define EIGENSYSTEM_HPP 3 | 4 | 5 | namespace ngbla 6 | { 7 | 8 | /// Computes eigenvalues and vectors of the symmetric matrix mat. 9 | extern NGS_DLL_HEADER void 10 | CalcEigenSystem (const FlatMatrix mat, 11 | FlatVector lami, 12 | FlatMatrix eigenvecs); 13 | 14 | 15 | } 16 | 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /basiclinalg/matkernel.hpp: -------------------------------------------------------------------------------- 1 | #if NETGEN_DEFAULT_SIMD_SIZE==1 2 | #include "matkernel_1.hpp" 3 | #elif NETGEN_DEFAULT_SIMD_SIZE==2 4 | #include "matkernel_2.hpp" 5 | #elif NETGEN_DEFAULT_SIMD_SIZE==4 6 | #include "matkernel_4.hpp" 7 | #elif NETGEN_DEFAULT_SIMD_SIZE==8 8 | #include "matkernel_8.hpp" 9 | #endif 10 | -------------------------------------------------------------------------------- /basiclinalg/ngbla_main.dxx: -------------------------------------------------------------------------------- 1 | //@{ 2 | //@Include: ngbla.dxx 3 | //@} 4 | 5 | //@Include: *.hpp 6 | -------------------------------------------------------------------------------- /bem/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}) 2 | 3 | add_library( ngsbem ${NGS_LIB_TYPE} 4 | ${ngsbem_object_libs} 5 | mptools.cpp potentialtools.cpp python_bem.cpp ngbem.cpp 6 | intrules_SauterSchwab.cpp 7 | ) 8 | 9 | target_include_directories(ngsbem PRIVATE ${NETGEN_PYTHON_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/../ngstd ${CMAKE_CURRENT_SOURCE_DIR}/../linalg) 10 | 11 | target_link_libraries (ngsbem PUBLIC ngcomp ngfem ngla ngbla ngstd ${MPI_CXX_LIBRARIES} PRIVATE "$" ${HYPRE_LIBRARIES}) 12 | target_link_libraries(ngsbem ${LAPACK_CMAKE_LINK_INTERFACE} "$") 13 | install( TARGETS ngsbem ${ngs_install_dir} ) 14 | 15 | install( FILES 16 | mptools.hpp potentialtools.hpp 17 | intrules_SauterSchwab.hpp 18 | DESTINATION ${NGSOLVE_INSTALL_DIR_INCLUDE} 19 | COMPONENT ngsolve_devel 20 | ) 21 | 22 | 23 | -------------------------------------------------------------------------------- /bem/intrules_SauterSchwab.hpp: -------------------------------------------------------------------------------- 1 | #ifndef INTRULES_HPP 2 | #define INTRULES_HPP 3 | 4 | #include 5 | 6 | namespace ngsbem 7 | { 8 | using namespace ngbla; 9 | 10 | // x, y in triangle [(0,0), (1,0), (0,1)] 11 | tuple>, Array>, Array> IdenticPanelIntegrationRule (int order); 12 | 13 | 14 | // x, y in triangle [(0,0), (1,0), (0,1)] 15 | // x=(0,0) and y=(0,0) are common vertices 16 | tuple>, Array>, Array> CommonVertexIntegrationRule (int order); 17 | 18 | 19 | // x, y in triangle [(0,0), (1,0), (0,1)] 20 | // x in [(0,0),(1,0)] and y in [(0,0),(1,0)] are common edges 21 | tuple>, Array>, Array> CommonEdgeIntegrationRule (int order); 22 | 23 | } 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /bem/potentialtools.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | 4 | 5 | namespace ngsbem 6 | { 7 | 8 | void AddCurrentDensity (SingularMLMultiPole> & mp, shared_ptr current, ngcomp::Region reg) 9 | { 10 | LocalHeap lh(10*1000*1000); 11 | auto ma = reg.Mesh(); 12 | 13 | for (auto ei : reg.GetElements()) 14 | { 15 | HeapReset hr(lh); 16 | auto & trafo = ma->GetTrafo(ei, lh); 17 | IntegrationRule ir(trafo.GetElementType(), 3); 18 | auto & mir = trafo(ir, lh); 19 | 20 | FlatMatrix curi(ir.Size(), 3, lh); 21 | current->Evaluate(mir, curi); 22 | 23 | for (int j = 0; j < mir.Size(); j++) 24 | { 25 | 26 | for (int k = 0; k < 3; k++) 27 | { 28 | Vec<3> ek{0.0}; ek(k) = 1; 29 | Vec<3> curi_real = Real(curi.Row(j)); 30 | Vec<3> curi_imag = Imag(curi.Row(j)); 31 | 32 | mp.AddDipole (mir[j].GetPoint(), Cross(curi_real, ek), mir[j].GetWeight()*ek); 33 | mp.AddDipole (mir[j].GetPoint(), Cross(curi_imag, ek), Complex(0,1)*mir[j].GetWeight()*ek); 34 | } 35 | } 36 | } 37 | } 38 | 39 | } 40 | 41 | -------------------------------------------------------------------------------- /bem/potentialtools.hpp: -------------------------------------------------------------------------------- 1 | #ifndef FILE_POTENTIALS 2 | #define FILE_POTENTIALS 3 | 4 | /* 5 | tools for computing with potentials using multipoles 6 | */ 7 | 8 | 9 | #include 10 | #include 11 | 12 | 13 | namespace ngsbem 14 | { 15 | 16 | extern void AddCurrentDensity (SingularMLMultiPole> & mp, shared_ptr current, ngcomp::Region reg); 17 | 18 | } 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /cmake/check_submodules.cmake: -------------------------------------------------------------------------------- 1 | execute_process(COMMAND git submodule status --recursive WORKING_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/.." OUTPUT_VARIABLE git_status_output) 2 | string(REPLACE "\n" ";" git_status_output "${git_status_output}") 3 | foreach( a ${git_status_output}) 4 | if(NOT ${a} MATCHES " [a-f,0-9]* external_dependencies[.]*") 5 | message(WARNING 6 | "***************************************************************** 7 | WARNING: The git submodules are out of sync! Please run 8 | git submodule update --init --recursive 9 | in your source directory 10 | *****************************************************************") 11 | endif() 12 | endforeach() 13 | 14 | -------------------------------------------------------------------------------- /cmake/cmake_modules/FindHYPRE.cmake: -------------------------------------------------------------------------------- 1 | find_path (HYPRE_DIR include/HYPRE.h HINTS "${HYPRE_HINTS}") 2 | if( EXISTS ${HYPRE_DIR}/include/HYPRE.h ) 3 | set(HYPRE_FOUND YES) 4 | set(HYPRE_INCLUDES ${HYPRE_DIR}) 5 | find_path(HYPRE_INCLUDE_DIR HYPRE.h HYPRE_parcsr_ls.h HINTS "${HYPRE_DIR}" PATH_SUFFIXES include NO_DEFAULT_PATH) 6 | list(APPEND HYPRE_INCLUDES ${HYPRE_INCLUDE_DIR}) 7 | find_library(HYPRE_LIBRARIES HYPRE PATHS ${HYPRE_DIR}/lib) 8 | endif( EXISTS ${HYPRE_DIR}/include/HYPRE.h ) 9 | include(FindPackageHandleStandardArgs) 10 | find_package_handle_standard_args(HYPRE DEFAULT_MSG HYPRE_LIBRARIES HYPRE_INCLUDES) 11 | -------------------------------------------------------------------------------- /cmake/cmake_modules/FindMUMPS.cmake: -------------------------------------------------------------------------------- 1 | find_path (MUMPS_DIR include/zmumps_c.h HINTS ENV MUMPS_DIR DOC "Mumps Directory") 2 | if(EXISTS ${MUMPS_DIR}/include/zmumps_c.h) 3 | set(MUMPS_FOUND YES) 4 | set(MUMPS_INCLUDES ${MUMPS_DIR}) 5 | find_path (MUMPS_INCLUDE_DIR mumps_compat.h HINTS "${MUMPS_DIR}" PATH_SUFFIXES include NO_DEFAULT_PATH) 6 | list(APPEND MUMPS_INCLUDES ${MUMPS_INCLUDE_DIR}) 7 | find_library(LIB_MUMPS_COMMON mumps_common PATHS ${MUMPS_DIR}/lib) 8 | find_library(LIB_MUMPS_D dmumps PATHS ${MUMPS_DIR}/lib) 9 | find_library(LIB_MUMPS_Z zmumps PATHS ${MUMPS_DIR}/lib) 10 | find_library(LIB_PORD pord PATHS ${MUMPS_DIR}/lib) 11 | find_library(LIB_PARMETIS parmetis HINTS ${PARMETIS_DIR}/lib REQUIRED) 12 | find_library(LIB_METIS metis HINTS ${PARMETIS_DIR}/lib REQUIRED) 13 | 14 | if (NOT USE_MKL) 15 | find_library(LIB_SCALAPACK scalapack HINTS ${SCALAPACK_DIR}/lib REQUIRED) 16 | endif() 17 | 18 | set(MUMPS_LIBRARIES ${LIB_MUMPS_D} ${LIB_MUMPS_Z} ${LIB_MUMPS_COMMON} ${LIB_PARMETIS} ${LIB_METIS} ${LIB_SCALAPACK}) 19 | 20 | if (LIB_PORD) 21 | list(APPEND MUMPS_LIBRARIES ${LIB_PORD}) 22 | endif() 23 | 24 | endif(EXISTS ${MUMPS_DIR}/include/zmumps_c.h) 25 | include(FindPackageHandleStandardArgs) 26 | find_package_handle_standard_args(MUMPS DEFAULT_MSG MUMPS_LIBRARIES MUMPS_INCLUDES) 27 | -------------------------------------------------------------------------------- /cmake/cmake_modules/FindSphinx.cmake: -------------------------------------------------------------------------------- 1 | find_program(SPHINX_EXECUTABLE NAMES sphinx-build 2 | HINTS 3 | $ENV{SPHINX_DIR} $ENV{PATH} 4 | PATH_SUFFIXES bin 5 | DOC "Sphinx documentation generator" 6 | ) 7 | 8 | include(FindPackageHandleStandardArgs) 9 | 10 | find_package_handle_standard_args(Sphinx DEFAULT_MSG 11 | SPHINX_EXECUTABLE 12 | ) 13 | 14 | mark_as_advanced(SPHINX_EXECUTABLE) 15 | -------------------------------------------------------------------------------- /cmake/cmake_uninstall.cmake.in: -------------------------------------------------------------------------------- 1 | if(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") 2 | message(FATAL_ERROR "Cannot find install manifest: @CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") 3 | endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") 4 | 5 | file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files) 6 | string(REGEX REPLACE "\n" ";" files "${files}") 7 | foreach(file ${files}) 8 | message(STATUS "Uninstalling $ENV{DESTDIR}${file}") 9 | if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") 10 | exec_program( 11 | "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\"" 12 | OUTPUT_VARIABLE rm_out 13 | RETURN_VALUE rm_retval 14 | ) 15 | if(NOT "${rm_retval}" STREQUAL 0) 16 | message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}") 17 | endif(NOT "${rm_retval}" STREQUAL 0) 18 | else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") 19 | message(STATUS "File $ENV{DESTDIR}${file} does not exist.") 20 | endif(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") 21 | endforeach(file) 22 | -------------------------------------------------------------------------------- /cmake/external_projects/catch.cmake: -------------------------------------------------------------------------------- 1 | include (ExternalProject) 2 | find_program(GIT_EXECUTABLE git) 3 | ExternalProject_Add( 4 | project_catch 5 | PREFIX ${CMAKE_BINARY_DIR}/catch 6 | GIT_REPOSITORY https://github.com/catchorg/Catch2.git 7 | GIT_TAG v2.13.7 8 | TIMEOUT 10 9 | UPDATE_COMMAND "" # ${GIT_EXECUTABLE} pull 10 | CONFIGURE_COMMAND "" 11 | BUILD_COMMAND "" 12 | INSTALL_COMMAND "" 13 | LOG_DOWNLOAD ON 14 | ) 15 | 16 | # Expose required variable (CATCH_INCLUDE_DIR) to parent scope 17 | ExternalProject_Get_Property(project_catch source_dir) 18 | set(CATCH_INCLUDE_DIR ${source_dir}/single_include/catch2 CACHE INTERNAL "Path to include folder for Catch") 19 | -------------------------------------------------------------------------------- /cmake/external_projects/hypre.cmake: -------------------------------------------------------------------------------- 1 | if(NOT UNIX) 2 | message(FATAL_ERROR "Building HYPRE as dependency is not supported on this platform. Please configure with USE_HYPRE=OFF or set HYPRE_DIR=path_to_your_hypre_installation") 3 | endif(NOT UNIX) 4 | 5 | set(HYPRE_SRC_DIR ${CMAKE_CURRENT_BINARY_DIR}/dependencies/src/project_parmetis/src) 6 | set(HYPRE_DIR ${CMAKE_CURRENT_BINARY_DIR}/dependencies/src/project_hypre/src/hypre) 7 | 8 | ExternalProject_Add(project_hypre 9 | ${SUBPROJECT_ARGS} 10 | URL "https://github.com/hypre-space/hypre/archive/refs/tags/v2.11.1.tar.gz" 11 | URL_MD5 28f3928b062c79c2eaf54c0978efcbfb 12 | CMAKE_ARGS 13 | ${SUBPROJECT_CMAKE_ARGS} 14 | BUILD_IN_SOURCE 1 15 | DOWNLOAD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external_dependencies 16 | CONFIGURE_COMMAND cmake ${SUBPROJECT_CMAKE_ARGS} src 17 | PATCH_COMMAND "" 18 | UPDATE_COMMAND "" # Disable update 19 | ) 20 | 21 | set_vars( NGSOLVE_CMAKE_ARGS HYPRE_DIR ) 22 | 23 | list(APPEND DEPENDENCIES project_hypre) 24 | -------------------------------------------------------------------------------- /cmake/external_projects/mumps.inc: -------------------------------------------------------------------------------- 1 | ORDERINGSF = -Dmetis -Dparmetis 2 | ORDERINGSC = $(ORDERINGSF) 3 | 4 | LORDERINGS = -L@PARMETIS_DIR@/lib -lparmetis 5 | IORDERINGSF = 6 | IORDERINGSC = -I@PARMETIS_DIR@/include 7 | 8 | PLAT = 9 | LIBEXT = .a 10 | OUTC = -o 11 | OUTF = -o 12 | RM = /bin/rm -f 13 | CC = @MPI_C_COMPILER@ 14 | FC = @MPI_Fortran_COMPILER@ 15 | FL = @MPI_Fortran_COMPILER@ 16 | AR = ar vr 17 | RANLIB = ranlib 18 | SCALAP = @SCALAPACK_LIBRARY@ @BLACS_LIBRARY@ @LAPACK_LIBRARY@ 19 | 20 | INCPAR = -I../include -I/usr/include 21 | 22 | LIBPAR = $(SCALAP) @MPI_C_LIBRARIES@ @MPI_Fortran_LIBRARIES@ 23 | 24 | # INCSEQ = -I$(topdir)/libseq 25 | # LIBSEQ = -L$(topdir)/libseq -lmpiseq 26 | 27 | LIBBLAS = -lblas 28 | LIBOTHERS = -lpthread 29 | 30 | #Preprocessor defs for calling Fortran from C (-DAdd_ or -DAdd__ or -DUPPER) 31 | CDEFS = -DAdd_ 32 | 33 | #Begin Optimized options 34 | # uncomment -fopenmp in lines below to benefit from OpenMP 35 | OPTF = -fallow-argument-mismatch -O -fPIC -DALLOW_NON_INIT # -fopenmp 36 | OPTL = -O -fPIC # -fopenmp 37 | OPTC = -O -fPIC # -fopenmp 38 | #End Optimized options 39 | INCS = $(INCPAR) 40 | LIBS = $(LIBPAR) 41 | LIBSEQNEEDED = 42 | -------------------------------------------------------------------------------- /cmake/external_projects/parmetis.patch: -------------------------------------------------------------------------------- 1 | diff --git a/CMakeLists.txt b/CMakeLists.txt 2 | index ca945dd..7e8070b 100644 3 | --- a/CMakeLists.txt 4 | +++ b/CMakeLists.txt 5 | @@ -34,9 +34,10 @@ include_directories(${METIS_PATH}/include) 6 | 7 | # List of directories that cmake will look for CMakeLists.txt 8 | add_subdirectory(${METIS_PATH}/libmetis ${CMAKE_BINARY_DIR}/libmetis) 9 | +add_subdirectory(${METIS_PATH}/include ${CMAKE_BINARY_DIR}/metis_include) 10 | add_subdirectory(include) 11 | add_subdirectory(libparmetis) 12 | -add_subdirectory(programs) 13 | +# add_subdirectory(programs) 14 | 15 | # This is for testing during development and is not being distributed 16 | #add_subdirectory(test) 17 | -------------------------------------------------------------------------------- /cmake/mic.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_SYSTEM_NAME Linux) 2 | set(CMAKE_SYSTEM_PROCESSOR k1om) 3 | set(CMAKE_SYSTEM_VERSION 1) 4 | 5 | # specify the cross compiler 6 | set(CMAKE_C_COMPILER icc) 7 | set(CMAKE_CXX_COMPILER icpc) 8 | set(MPI_C_COMPILER mpiicc) 9 | set(_CMAKE_TOOLCHAIN_PREFIX x86_64-k1om-linux-) 10 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmic") 11 | set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -limf -lsvml -lirng -lintlc") 12 | 13 | # where is the target environment 14 | set(CMAKE_FIND_ROOT_PATH /usr/linux-k1om-4.7) 15 | 16 | -------------------------------------------------------------------------------- /cmake/package_macos.cmake: -------------------------------------------------------------------------------- 1 | configure_file(${CMAKE_CURRENT_LIST_DIR}/package_osx_fixup.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/package_osx.cmake IMMEDIATE @ONLY) 2 | add_custom_target(bundle COMMAND ${CMAKE_COMMAND} "-P" "${CMAKE_CURRENT_BINARY_DIR}/package_osx.cmake") 3 | -------------------------------------------------------------------------------- /cmake/resources/.gitignore: -------------------------------------------------------------------------------- 1 | ngsolve.rc 2 | -------------------------------------------------------------------------------- /cmake/resources/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | configure_file(ngsolve.rc.template ${CMAKE_CURRENT_SOURCE_DIR}/ngsolve.rc IMMEDIATE @ONLY) 2 | -------------------------------------------------------------------------------- /cmake/resources/banner.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NGSolve/ngsolve/cab3abd87bbc83654d6b50d275be06e40cb3f040/cmake/resources/banner.bmp -------------------------------------------------------------------------------- /cmake/resources/netgen.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NGSolve/ngsolve/cab3abd87bbc83654d6b50d275be06e40cb3f040/cmake/resources/netgen.ico -------------------------------------------------------------------------------- /cmake/resources/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by netgen.rc and nglib.rc 4 | // 5 | #define _USE_DECLSPECS_FOR_SAL 0 6 | #define _USE_ATTRIBUTES_FOR_SAL 0 7 | #define VS_VERSION_INFO 1 8 | #define VFFF_ISSHAREDFILE 0x0001 9 | #define VFF_CURNEDEST 0x0001 10 | #define VIFF_FORCEINSTALL 0x0001 11 | #define VFF_FILEINUSE 0x0002 12 | #define VIFF_DONTDELETEOLD 0x0002 13 | #define VFF_BUFFTOOSMALL 0x0004 14 | #define VS_USER_DEFINED 100 15 | 16 | // Next default values for new objects 17 | // 18 | #ifdef APSTUDIO_INVOKED 19 | #ifndef APSTUDIO_READONLY_SYMBOLS 20 | #define _APS_NEXT_RESOURCE_VALUE 101 21 | #define _APS_NEXT_COMMAND_VALUE 40001 22 | #define _APS_NEXT_CONTROL_VALUE 1000 23 | #define _APS_NEXT_SYMED_VALUE 101 24 | #endif 25 | #endif 26 | -------------------------------------------------------------------------------- /cmake/resources/sculpture312_50.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NGSolve/ngsolve/cab3abd87bbc83654d6b50d275be06e40cb3f040/cmake/resources/sculpture312_50.bmp -------------------------------------------------------------------------------- /cmake/resources/wix_patch.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /cmake/tkdnd_macosx.patch: -------------------------------------------------------------------------------- 1 | diff -Naur orig/tkdnd2.8/configure changed/tkdnd2.8/configure 2 | --- tkdnd2.8/configure 2015-05-13 19:24:32.000000000 +0200 3 | +++ tkdnd2.8/configure 2016-02-22 15:26:37.000000000 +0100 4 | @@ -6145,7 +6145,7 @@ 5 | 6 | 7 | 8 | - PKG_CFLAGS="$PKG_CFLAGS -DMAC_TK_COCOA -std=gnu99 -x objective-c -fobjc-gc" 9 | + PKG_CFLAGS="$PKG_CFLAGS -DMAC_TK_COCOA -std=gnu99 -x objective-c" 10 | 11 | 12 | 13 | diff -Naur orig/tkdnd2.8/configure.in changed/tkdnd2.8/configure.in 14 | --- tkdnd2.8/configure.in 2015-05-13 19:24:32.000000000 +0200 15 | +++ tkdnd2.8/configure.in 2016-02-22 15:26:44.000000000 +0100 16 | @@ -126,7 +126,7 @@ 17 | 18 | if test "${TEA_WINDOWINGSYSTEM}" = "aqua"; then 19 | TEA_ADD_SOURCES([macosx/macdnd.m]) 20 | - TEA_ADD_CFLAGS([-DMAC_TK_COCOA -std=gnu99 -x objective-c -fobjc-gc]) 21 | + TEA_ADD_CFLAGS([-DMAC_TK_COCOA -std=gnu99 -x objective-c]) 22 | TEA_ADD_LIBS([-framework Cocoa -framework Carbon]) 23 | fi 24 | 25 | diff -Naur orig/tkdnd2.8/macosx/macdnd.m changed/tkdnd2.8/macosx/macdnd.m 26 | --- tkdnd2.8/macosx/macdnd.m 2015-07-06 21:49:14.000000000 +0200 27 | +++ tkdnd2.8/macosx/macdnd.m 2016-02-22 15:27:04.000000000 +0100 28 | @@ -16,6 +16,7 @@ 29 | #import 30 | #import 31 | #import 32 | +#undef panic 33 | #import 34 | #import 35 | 36 | -------------------------------------------------------------------------------- /comp/comp.dxx: -------------------------------------------------------------------------------- 1 | /** @name Main Problem-Components 2 | \begin{verbatim} (directory ngsolve/comp)\end{verbatim} 3 | 4 | FE-Spaces (e.g., \Ref{H1HighOrderFESpace}, \Ref{HCurlHighOrderFESpace},...), \Ref{LinearForm}, \Ref{BilinearForm}, 5 | the access to the mesh (\Ref{MeshAccess}), \Ref{GridFunction}s, \Ref{Preconditioner}s, etc. 6 | */ -------------------------------------------------------------------------------- /comp/fesconvert.hpp: -------------------------------------------------------------------------------- 1 | #ifndef FILE_FESCONVERT 2 | #define FILE_FESCONVERT 3 | 4 | namespace ngcomp 5 | { 6 | 7 | shared_ptr ConvertOperator (shared_ptr spacea, shared_ptr spaceb, VorB vb, LocalHeap & lh, 8 | shared_ptr diffop = nullptr, shared_ptr trial_cf = nullptr, 9 | const Region * reg = NULL, shared_ptr range_dofs = nullptr, bool localop = false, bool parmat = true, 10 | bool use_simd = true, int bonus_intorder_ab = 0, int bonus_intorder_bb = 0, bool geom_free = false); 11 | 12 | } // namespace ngcomp 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /comp/h1lumping.hpp: -------------------------------------------------------------------------------- 1 | #ifndef FILE_H1LUMPING 2 | #define FILE_H1LUMPING 3 | 4 | 5 | #include "fespace.hpp" 6 | 7 | namespace ngcomp 8 | { 9 | 10 | class H1LumpingFESpace : public FESpace 11 | { 12 | size_t nvert, nedge, nface; 13 | public: 14 | H1LumpingFESpace (shared_ptr ama, const Flags & flags); 15 | 16 | string GetClassName () const override { return "h1lumping"; } 17 | 18 | static DocInfo GetDocu(); 19 | 20 | void Update() override; 21 | 22 | virtual shared_ptr 23 | GetMassOperator (shared_ptr rho, 24 | shared_ptr defon, LocalHeap & lh) const override; 25 | 26 | 27 | void GetDofNrs (ElementId ei, Array & dnums) const override; 28 | 29 | FiniteElement & GetFE (ElementId ei, Allocator & alloc) const override; 30 | 31 | std::map GetIntegrationRules() const; 32 | }; 33 | } 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /comp/ngcomp.dxx: -------------------------------------------------------------------------------- 1 | /** @name High level FEM components 2 | Hilbert-space objects: \Ref{FESpace} 3 | \Ref{GridFunction}, \Ref{BilinearForm}, \Ref{LinearForm} 4 | \Ref{Preconditioner} 5 | 6 | Postprocessing: \Ref{CalcFlux}, 7 | 8 | Error-estimator: \Ref{ZZErrorEstimate} 9 | */ 10 | -------------------------------------------------------------------------------- /comp/ngcomp_main.dxx: -------------------------------------------------------------------------------- 1 | //@{ 2 | //@Include: ngcomp.dxx 3 | //@} 4 | 5 | //@Include: *.hpp 6 | -------------------------------------------------------------------------------- /comp/numberfespace.hpp: -------------------------------------------------------------------------------- 1 | #ifndef FILE_NUMBERFESPACE 2 | #define FILE_NUMBERFESPACE 3 | 4 | /*********************************************************************/ 5 | /* File: numberfespace.hpp */ 6 | /* Author: Start */ 7 | /* Date: 30.FJan. 2018 */ 8 | /*********************************************************************/ 9 | 10 | #include 11 | 12 | namespace ngcomp 13 | { 14 | 15 | class NumberFESpace : public FESpace 16 | { 17 | public: 18 | NumberFESpace (shared_ptr ama, const Flags & flags, bool checkflags=false); 19 | void Update() override; 20 | 21 | // virtual size_t GetNDof() const { return 1; } 22 | 23 | virtual FiniteElement & GetFE (ElementId ei, Allocator & lh) const override; 24 | 25 | virtual void GetDofNrs (ElementId ei, Array & dnums) const override; 26 | 27 | virtual void GetGlobalDofNrs (int gnr, Array & dnums) const override; 28 | 29 | }; 30 | 31 | } 32 | #endif 33 | -------------------------------------------------------------------------------- /comp/plateaufespace.hpp: -------------------------------------------------------------------------------- 1 | #ifndef PLATEAUFESPACE_HPP 2 | #define PLATEAUFESPACE_HPP 3 | 4 | /*********************************************************************/ 5 | /* File: plateaufespace.hpp */ 6 | /* Author: Joachim Schoeberl */ 7 | /* Date: 23 Oct 2023 */ 8 | /*********************************************************************/ 9 | 10 | #include "fespace.hpp" 11 | 12 | namespace ngcomp 13 | { 14 | 15 | class PlateauFESpace : public CompressedFESpace 16 | { 17 | protected: 18 | Array plateaus; 19 | public: 20 | PlateauFESpace (shared_ptr afes, Array aplateaus); 21 | void Update() override; 22 | }; 23 | 24 | } 25 | #endif 26 | -------------------------------------------------------------------------------- /config.h.cmake: -------------------------------------------------------------------------------- 1 | #cmakedefine HAVE_DLFCN_H 1 2 | #cmakedefine HAVE_CXA_DEMANGLE 1 3 | -------------------------------------------------------------------------------- /docs/_static/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NGSolve/ngsolve/cab3abd87bbc83654d6b50d275be06e40cb3f040/docs/_static/favicon.ico -------------------------------------------------------------------------------- /docs/_static/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NGSolve/ngsolve/cab3abd87bbc83654d6b50d275be06e40cb3f040/docs/_static/logo.png -------------------------------------------------------------------------------- /docs/_static/shallow2D.mov: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NGSolve/ngsolve/cab3abd87bbc83654d6b50d275be06e40cb3f040/docs/_static/shallow2D.mov -------------------------------------------------------------------------------- /docs/_templates/breadcrumbs.html: -------------------------------------------------------------------------------- 1 | {# Support for Sphinx 1.3+ page_source_suffix, but don't break old builds. #} 2 | 3 | {% if page_source_suffix %} 4 | {% set suffix = page_source_suffix %} 5 | {% else %} 6 | {% set suffix = source_suffix %} 7 | {% endif %} 8 | 9 |
10 | 20 | 21 |
22 |
23 | -------------------------------------------------------------------------------- /docs/_templates/layout.html: -------------------------------------------------------------------------------- 1 | {% extends "!layout.html" %} 2 | 3 | {% block footer %} 4 | {{ super() }} 5 | 15 | {% endblock %} 16 | -------------------------------------------------------------------------------- /docs/_templates/versions.html: -------------------------------------------------------------------------------- 1 |
2 | 3 | NGSolve 4 | v: {{ version }} 5 | 6 | 7 |
8 |
9 |
10 | 11 | 12 | -------------------------------------------------------------------------------- /docs/central/meshes.rst: -------------------------------------------------------------------------------- 1 | Meshes 2 | ====== 3 | 4 | A mesh object stores the geometric elements of a mesh. More precisely, Netgen stores volume elements and surface elements. In Netgen/NGSolve, a mesh is usually generated by the automatic mesh generator Netgen from a given geometry object. To allow for geometry-based refinement, or geometry-adapted curved elements, the mesh object has a reference to the original geometry. 5 | 6 | Indeed, we have two Mesh classes, one in Netgen, and one in NGSolve. The Netgen mesh is generated from the Netgen mesh-generator. If we want to adapt the mesh, we can modify the Netgen mesh by directly adding elements to it. It consists of 3D, 2D, 1D and 0D elements. The NGSolve mesh is a wrapper around the Netgen mesh. It does not store big data, but it provides a view of the Netgen mesh. The elements in NGSolve are understood as volume elements or surface elements (i.e. elements of co-dimension 0 or 1). 7 | 8 | ... 9 | -------------------------------------------------------------------------------- /docs/how_to/howto_traceoperator.rst: -------------------------------------------------------------------------------- 1 | The Trace() operator 2 | ==================== 3 | 4 | Mathematically, the trace operator restricts a domain-function to the boundary of the domain. For function spaces like H(curl) or H(div), the trace operator delivers only tangential, and normal components, respectively. 5 | 6 | The trace operator is used in NGS-Py as follows: 7 | 8 | .. code-block:: python 9 | 10 | a.Assemble(u.Trace()*v.Trace(), BND) 11 | 12 | The evaluation of boundary values involves only degrees of freedom geometrically located on the boundary. 13 | 14 | Traces of derivatives can are formed by either one of the following. 15 | For example, the derivative of the trace of an H1-function gives the tangential derivative: 16 | 17 | 18 | .. code-block:: python 19 | 20 | u.Trace().Deriv() 21 | u.Deriv().Trace() 22 | 23 | 24 | As an popular exception, in NGS-Py, the Trace()-operator for H1-functions is optional. 25 | 26 | For element-boundary integrals, the Trace()-operator must not be used. Here, the function is evaluated at a point in the volume-element. 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /docs/how_to/res_definedon/definedon.py: -------------------------------------------------------------------------------- 1 | from netgen.geom2d import * 2 | from ngsolve import * 3 | 4 | geo = SplineGeometry() 5 | geo.AddRectangle ( (0,0), (2,2), bcs=["b","r","t","l"], leftdomain=1) 6 | geo.AddRectangle ( (1,0.9), (1.3,1.4), bcs=["b2","r2","t2","l2"], leftdomain=2, rightdomain=1) 7 | geo.SetMaterial (1, "outer") 8 | geo.SetMaterial (2, "inner") 9 | mesh = Mesh(geo.GenerateMesh(maxh=0.1)) 10 | 11 | fes1 = H1(mesh, definedon="inner") 12 | u1 = GridFunction(fes1, "u1") 13 | u1.Set (x*y) 14 | 15 | fes = H1(mesh, order=3,dirichlet="b|l|r") 16 | u = fes.TrialFunction() 17 | v = fes.TestFunction() 18 | 19 | gfu = GridFunction(fes) 20 | 21 | f = LinearForm(fes) 22 | f += SymbolicLFI (u1*v, definedon=mesh.Materials("inner")) 23 | f.Assemble() 24 | 25 | a = BilinearForm(fes) 26 | a += SymbolicBFI(grad(u)*grad(v)) 27 | a.Assemble() 28 | 29 | gfu.vec.data = a.mat.Inverse(fes.FreeDofs()) * f.vec 30 | 31 | Draw (u1) 32 | Draw (gfu) 33 | -------------------------------------------------------------------------------- /docs/how_to/res_periodic/periodic1D.py: -------------------------------------------------------------------------------- 1 | from netgen.meshing import * 2 | 3 | mesh = Mesh(dim=1) 4 | pids = [] 5 | n = 50 6 | for i in range(n+1): 7 | pids.append (mesh.Add (MeshPoint(Pnt(i/n, 0, 0)))) 8 | for i in range(n): 9 | mesh.Add(Element1D([pids[i],pids[i+1]],index=1)) 10 | mesh.Add (Element0D( pids[0], index=1)) 11 | mesh.Add (Element0D( pids[n], index=2)) 12 | mesh.AddPointIdentification(pids[0],pids[n],1,2) 13 | -------------------------------------------------------------------------------- /docs/how_to/res_periodic/periodic2D.py: -------------------------------------------------------------------------------- 1 | from netgen.geom2d import * 2 | 3 | periodic = SplineGeometry() 4 | pnts = [ (0,0), (1,0), (1,1), (0,1) ] 5 | pnums = [periodic.AppendPoint(*p) for p in pnts] 6 | 7 | periodic.Append ( ["line", pnums[0], pnums[1]],bc="outer") 8 | # This should be our master edge so we need to save its number. 9 | lright = periodic.Append ( ["line", pnums[1], pnums[2]], bc="periodic") 10 | periodic.Append ( ["line", pnums[2], pnums[3]], bc="outer") 11 | # Minion boundaries must be defined in the same direction as master ones, 12 | # this is why the the point numbers of this spline are defined in the reverse direction, 13 | # leftdomain and rightdomain must therefore be switched as well! 14 | # We use the master number as the copy argument to create a slave edge. 15 | periodic.Append ( ["line", pnums[0], pnums[3]], leftdomain=0, rightdomain=1, copy=lright, bc="periodic") 16 | 17 | from ngsolve import * 18 | mesh = Mesh(periodic.GenerateMesh(maxh=0.2)) 19 | 20 | fes = Periodic(H1(mesh,order=3,dirichlet="outer")) 21 | 22 | u,v = fes.TrialFunction(), fes.TestFunction() 23 | 24 | a = BilinearForm(fes,symmetric=True) 25 | a += SymbolicBFI(grad(u) * grad(v)) 26 | 27 | f = LinearForm(fes) 28 | f += SymbolicLFI(x*v) 29 | 30 | u = GridFunction(fes,"u") 31 | 32 | with TaskManager(): 33 | a.Assemble() 34 | f.Assemble() 35 | u.vec.data = a.mat.Inverse(fes.FreeDofs()) * f.vec 36 | 37 | Draw (u) 38 | 39 | -------------------------------------------------------------------------------- /docs/how_to/res_periodic/periodic2d.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NGSolve/ngsolve/cab3abd87bbc83654d6b50d275be06e40cb3f040/docs/how_to/res_periodic/periodic2d.png -------------------------------------------------------------------------------- /docs/how_to/res_periodic/periodic3D.py: -------------------------------------------------------------------------------- 1 | from netgen.csg import * 2 | 3 | geo = CSGeometry() 4 | left = Plane(Pnt(0,0,0),Vec(-1,0,0)) 5 | right = Plane(Pnt(1,0,0),Vec(1,0,0)) 6 | brick = OrthoBrick(Pnt(-1,0,0),Pnt(2,1,1)).bc("outer") 7 | cube = brick * left * right 8 | geo.Add(cube) 9 | geo.PeriodicSurfaces(left,right) 10 | 11 | from ngsolve import * 12 | mesh = Mesh(geo.GenerateMesh(maxh=0.3)) 13 | 14 | fes = Periodic(H1(mesh,order=3,dirichlet="outer")) 15 | 16 | u,v = fes.TrialFunction(), fes.TestFunction() 17 | 18 | a = BilinearForm(fes,symmetric=True) 19 | a += SymbolicBFI(grad(u) * grad(v)) 20 | 21 | f = LinearForm(fes) 22 | f += SymbolicLFI(x*v) 23 | 24 | u = GridFunction(fes,"u") 25 | 26 | with TaskManager(): 27 | a.Assemble() 28 | f.Assemble() 29 | u.vec.data = a.mat.Inverse(fes.FreeDofs()) * f.vec 30 | 31 | Draw(u) 32 | 33 | from ngsolve.internal import * 34 | viewoptions.clipping.enable = 1 35 | visoptions.clipsolution = "scal" 36 | -------------------------------------------------------------------------------- /docs/how_to/res_periodic/periodic3d.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NGSolve/ngsolve/cab3abd87bbc83654d6b50d275be06e40cb3f040/docs/how_to/res_periodic/periodic3d.png -------------------------------------------------------------------------------- /docs/i-tutorials/appendix-vtk/vtk_example1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NGSolve/ngsolve/cab3abd87bbc83654d6b50d275be06e40cb3f040/docs/i-tutorials/appendix-vtk/vtk_example1.png -------------------------------------------------------------------------------- /docs/i-tutorials/appendix-vtk/vtk_example2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NGSolve/ngsolve/cab3abd87bbc83654d6b50d275be06e40cb3f040/docs/i-tutorials/appendix-vtk/vtk_example2.png -------------------------------------------------------------------------------- /docs/i-tutorials/appendix-webgui/js_console.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NGSolve/ngsolve/cab3abd87bbc83654d6b50d275be06e40cb3f040/docs/i-tutorials/appendix-webgui/js_console.png -------------------------------------------------------------------------------- /docs/i-tutorials/historic/unit-5.1-mpi_ngsolve/bf_apart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NGSolve/ngsolve/cab3abd87bbc83654d6b50d275be06e40cb3f040/docs/i-tutorials/historic/unit-5.1-mpi_ngsolve/bf_apart.png -------------------------------------------------------------------------------- /docs/i-tutorials/historic/unit-5.1-mpi_ngsolve/mat_distr.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NGSolve/ngsolve/cab3abd87bbc83654d6b50d275be06e40cb3f040/docs/i-tutorials/historic/unit-5.1-mpi_ngsolve/mat_distr.png -------------------------------------------------------------------------------- /docs/i-tutorials/historic/unit-5.1-mpi_ngsolve/square_apart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NGSolve/ngsolve/cab3abd87bbc83654d6b50d275be06e40cb3f040/docs/i-tutorials/historic/unit-5.1-mpi_ngsolve/square_apart.png -------------------------------------------------------------------------------- /docs/i-tutorials/historic/unit-5.2-fetidp_point2d/tix_fetidp_standalone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NGSolve/ngsolve/cab3abd87bbc83654d6b50d275be06e40cb3f040/docs/i-tutorials/historic/unit-5.2-fetidp_point2d/tix_fetidp_standalone.png -------------------------------------------------------------------------------- /docs/i-tutorials/historic/unit-5.3-fetidp_point3d/tix_fetidp_standalone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NGSolve/ngsolve/cab3abd87bbc83654d6b50d275be06e40cb3f040/docs/i-tutorials/historic/unit-5.3-fetidp_point3d/tix_fetidp_standalone.png -------------------------------------------------------------------------------- /docs/i-tutorials/unit-2.1.4-bddc/figs/auxspace.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NGSolve/ngsolve/cab3abd87bbc83654d6b50d275be06e40cb3f040/docs/i-tutorials/unit-2.1.4-bddc/figs/auxspace.png -------------------------------------------------------------------------------- /docs/i-tutorials/unit-2.3-hcurlhdiv/resources/edgeelement.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NGSolve/ngsolve/cab3abd87bbc83654d6b50d275be06e40cb3f040/docs/i-tutorials/unit-2.3-hcurlhdiv/resources/edgeelement.png -------------------------------------------------------------------------------- /docs/i-tutorials/unit-2.3-hcurlhdiv/resources/faceelement.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NGSolve/ngsolve/cab3abd87bbc83654d6b50d275be06e40cb3f040/docs/i-tutorials/unit-2.3-hcurlhdiv/resources/faceelement.png -------------------------------------------------------------------------------- /docs/i-tutorials/unit-2.3-hcurlhdiv/resources/l2element.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NGSolve/ngsolve/cab3abd87bbc83654d6b50d275be06e40cb3f040/docs/i-tutorials/unit-2.3-hcurlhdiv/resources/l2element.png -------------------------------------------------------------------------------- /docs/i-tutorials/unit-2.3-hcurlhdiv/resources/nodalelement.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NGSolve/ngsolve/cab3abd87bbc83654d6b50d275be06e40cb3f040/docs/i-tutorials/unit-2.3-hcurlhdiv/resources/nodalelement.png -------------------------------------------------------------------------------- /docs/i-tutorials/unit-3.1-parabolic/helper.py: -------------------------------------------------------------------------------- 1 | import scipy.sparse as sp 2 | import matplotlib.pylab as plt 3 | from ngsolve import * 4 | 5 | def ShowPattern(A,precision=-1,binarize=False): 6 | rows_all,cols_all,vals_all = A.COO() 7 | for i,(r,c,v) in enumerate(zip(rows_all,cols_all,vals_all)): 8 | vals_all[i] = abs(vals_all[i]) 9 | if binarize and vals_all[i] > precision: 10 | vals_all[i] = 1.0 11 | minval = 0 12 | maxval = max(vals_all) 13 | A_all = sp.csr_matrix((vals_all,(rows_all,cols_all)),shape=(A.height,A.width)) 14 | plt.figure(figsize=(6,6*A.width/A.width)) 15 | plt.imshow(A_all.todense(),interpolation='none',cmap='jet',vmin=minval,vmax=maxval) 16 | plt.show() 17 | -------------------------------------------------------------------------------- /docs/i-tutorials/unit-3.2-navierstokes/geometry.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NGSolve/ngsolve/cab3abd87bbc83654d6b50d275be06e40cb3f040/docs/i-tutorials/unit-3.2-navierstokes/geometry.png -------------------------------------------------------------------------------- /docs/i-tutorials/unit-3.6-surfacehdg/elementupwind.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NGSolve/ngsolve/cab3abd87bbc83654d6b50d275be06e40cb3f040/docs/i-tutorials/unit-3.6-surfacehdg/elementupwind.png -------------------------------------------------------------------------------- /docs/i-tutorials/unit-3.6-surfacehdg/facetupwind.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NGSolve/ngsolve/cab3abd87bbc83654d6b50d275be06e40cb3f040/docs/i-tutorials/unit-3.6-surfacehdg/facetupwind.png -------------------------------------------------------------------------------- /docs/i-tutorials/unit-3.7-opsplit/resources/stokeshdghdiv.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NGSolve/ngsolve/cab3abd87bbc83654d6b50d275be06e40cb3f040/docs/i-tutorials/unit-3.7-opsplit/resources/stokeshdghdiv.png -------------------------------------------------------------------------------- /docs/i-tutorials/unit-3.8-simplehyp/geomsketch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NGSolve/ngsolve/cab3abd87bbc83654d6b50d275be06e40cb3f040/docs/i-tutorials/unit-3.8-simplehyp/geomsketch.png -------------------------------------------------------------------------------- /docs/i-tutorials/unit-3.8-simplehyp/shallow2D.mov: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NGSolve/ngsolve/cab3abd87bbc83654d6b50d275be06e40cb3f040/docs/i-tutorials/unit-3.8-simplehyp/shallow2D.mov -------------------------------------------------------------------------------- /docs/i-tutorials/unit-3.8-simplehyp/shallow2D.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NGSolve/ngsolve/cab3abd87bbc83654d6b50d275be06e40cb3f040/docs/i-tutorials/unit-3.8-simplehyp/shallow2D.mp4 -------------------------------------------------------------------------------- /docs/i-tutorials/unit-5.5-cuda/pictures/auxspace.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NGSolve/ngsolve/cab3abd87bbc83654d6b50d275be06e40cb3f040/docs/i-tutorials/unit-5.5-cuda/pictures/auxspace.png -------------------------------------------------------------------------------- /docs/i-tutorials/unit-5.5-cuda/pictures/bddc-tracings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NGSolve/ngsolve/cab3abd87bbc83654d6b50d275be06e40cb3f040/docs/i-tutorials/unit-5.5-cuda/pictures/bddc-tracings.png -------------------------------------------------------------------------------- /docs/i-tutorials/unit-5a.1-mpi/drawsolution.py: -------------------------------------------------------------------------------- 1 | from ngsolve import * 2 | import pickle 3 | gfu = pickle.load(open("solution.pickle0", "rb")) 4 | Draw (gfu) 5 | -------------------------------------------------------------------------------- /docs/i-tutorials/unit-5a.1-mpi/poisson_mpi.py: -------------------------------------------------------------------------------- 1 | from ngsolve import * 2 | from mpi4py import MPI 3 | from netgen.occ import unit_square 4 | 5 | comm = MPI.COMM_WORLD 6 | 7 | ngmesh = unit_square.GenerateMesh(maxh=0.1, comm=comm) 8 | 9 | for l in range(3): 10 | ngmesh.Refine() 11 | mesh = Mesh(ngmesh) 12 | 13 | fes = H1(mesh, order=3, dirichlet=".*") 14 | u,v = fes.TnT() 15 | 16 | a = BilinearForm(grad(u)*grad(v)*dx) 17 | pre = preconditioners.Local(a) 18 | a.Assemble() 19 | 20 | f = LinearForm(1*v*dx).Assemble() 21 | gfu = GridFunction(fes) 22 | 23 | inv = CGSolver(a.mat, pre.mat) 24 | gfu.vec.data = inv*f.vec 25 | 26 | ip = InnerProduct(gfu.vec, f.vec) 27 | printonce("(u,f) =", ip) 28 | # (u,f) = 0.03514425357822445 29 | 30 | 31 | import pickle 32 | netgen.meshing.SetParallelPickling(True) 33 | pickle.dump (gfu, open("solution.pickle"+str(comm.rank), "wb")) 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /docs/i-tutorials/unit-7-optimization/opt_vs_init.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NGSolve/ngsolve/cab3abd87bbc83654d6b50d275be06e40cb3f040/docs/i-tutorials/unit-7-optimization/opt_vs_init.png -------------------------------------------------------------------------------- /docs/i-tutorials/unit-7-optimization/psi_iter999.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NGSolve/ngsolve/cab3abd87bbc83654d6b50d275be06e40cb3f040/docs/i-tutorials/unit-7-optimization/psi_iter999.png -------------------------------------------------------------------------------- /docs/i-tutorials/unit-8.2-intlset/graphics/lsetcurv.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NGSolve/ngsolve/cab3abd87bbc83654d6b50d275be06e40cb3f040/docs/i-tutorials/unit-8.2-intlset/graphics/lsetcurv.jpg -------------------------------------------------------------------------------- /docs/i-tutorials/unit-8.3-cutfem/graphics/SpaceBoth.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NGSolve/ngsolve/cab3abd87bbc83654d6b50d275be06e40cb3f040/docs/i-tutorials/unit-8.3-cutfem/graphics/SpaceBoth.png -------------------------------------------------------------------------------- /docs/i-tutorials/unit-8.3-cutfem/graphics/SpaceInner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NGSolve/ngsolve/cab3abd87bbc83654d6b50d275be06e40cb3f040/docs/i-tutorials/unit-8.3-cutfem/graphics/SpaceInner.png -------------------------------------------------------------------------------- /docs/i-tutorials/unit-8.3-cutfem/graphics/SpaceOuter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NGSolve/ngsolve/cab3abd87bbc83654d6b50d275be06e40cb3f040/docs/i-tutorials/unit-8.3-cutfem/graphics/SpaceOuter.png -------------------------------------------------------------------------------- /docs/i-tutorials/unit-8.3-cutfem/graphics/bubble_coarse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NGSolve/ngsolve/cab3abd87bbc83654d6b50d275be06e40cb3f040/docs/i-tutorials/unit-8.3-cutfem/graphics/bubble_coarse.png -------------------------------------------------------------------------------- /docs/i-tutorials/unit-8.3-cutfem/graphics/lsetcurv.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NGSolve/ngsolve/cab3abd87bbc83654d6b50d275be06e40cb3f040/docs/i-tutorials/unit-8.3-cutfem/graphics/lsetcurv.jpg -------------------------------------------------------------------------------- /docs/i-tutorials/unit-8.3-cutfem/graphics/xfem1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NGSolve/ngsolve/cab3abd87bbc83654d6b50d275be06e40cb3f040/docs/i-tutorials/unit-8.3-cutfem/graphics/xfem1.png -------------------------------------------------------------------------------- /docs/i-tutorials/unit-8.3-cutfem/graphics/xfem2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NGSolve/ngsolve/cab3abd87bbc83654d6b50d275be06e40cb3f040/docs/i-tutorials/unit-8.3-cutfem/graphics/xfem2.png -------------------------------------------------------------------------------- /docs/i-tutorials/unit-8.5-spacetime_unfitted/graphics/limits-time-slab.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NGSolve/ngsolve/cab3abd87bbc83654d6b50d275be06e40cb3f040/docs/i-tutorials/unit-8.5-spacetime_unfitted/graphics/limits-time-slab.png -------------------------------------------------------------------------------- /docs/i-tutorials/unit-8.5-spacetime_unfitted/graphics/macro-element.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NGSolve/ngsolve/cab3abd87bbc83654d6b50d275be06e40cb3f040/docs/i-tutorials/unit-8.5-spacetime_unfitted/graphics/macro-element.png -------------------------------------------------------------------------------- /docs/i-tutorials/unit-8.6-mlset_basic/graphics/z_disc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NGSolve/ngsolve/cab3abd87bbc83654d6b50d275be06e40cb3f040/docs/i-tutorials/unit-8.6-mlset_basic/graphics/z_disc.png -------------------------------------------------------------------------------- /docs/i-tutorials/unit-8.7-mlset_pde/graphics/mlset_cuts.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NGSolve/ngsolve/cab3abd87bbc83654d6b50d275be06e40cb3f040/docs/i-tutorials/unit-8.7-mlset_pde/graphics/mlset_cuts.png -------------------------------------------------------------------------------- /docs/i-tutorials/unit-8.9-unfmixed/graphics/elpp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NGSolve/ngsolve/cab3abd87bbc83654d6b50d275be06e40cb3f040/docs/i-tutorials/unit-8.9-unfmixed/graphics/elpp.png -------------------------------------------------------------------------------- /docs/i-tutorials/unit-9.1-C++FE/mymodule.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | // using namespace ngcomp; 5 | 6 | #include "myElement.cpp" 7 | #include "myFESpace.cpp" 8 | 9 | 10 | extern "C" void mymodule(py::object & res) { 11 | cout << "called mymodule" << endl; 12 | // import ngsolve such that python base classes are defined 13 | auto ngs = py::module::import("ngsolve"); 14 | 15 | static py::module::module_def def; 16 | py::module m = py::module::create_extension_module("", "", &def); 17 | 18 | ExportMyFESpace(m); 19 | res = m; 20 | } 21 | 22 | -------------------------------------------------------------------------------- /docs/i-tutorials/unit-9.2-C++Assemble/myassemblemodule.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "myIntegrator.cpp" 5 | #include "myAssembling.cpp" 6 | 7 | 8 | extern "C" void mymodule(py::object & res) { 9 | // import ngsolve such that python base classes are defined 10 | auto ngs = py::module::import("ngsolve"); 11 | 12 | static py::module::module_def def; 13 | py::module m = py::module::create_extension_module("", "", &def); 14 | 15 | // ExportMyFESpace(m); 16 | 17 | using namespace ngfem; 18 | py::class_, BilinearFormIntegrator> 19 | (m, "MyLaplace") 20 | .def(py::init>()) 21 | ; 22 | py::class_, LinearFormIntegrator> 23 | (m, "MySource") 24 | .def(py::init>()) 25 | ; 26 | 27 | m.def ("MyAssembleMatrix", 28 | &ngcomp::MyAssembleMatrix, 29 | py::arg("fes"),py::arg("integrator"), py::arg("parallel")=false); 30 | 31 | res = m; 32 | } 33 | 34 | -------------------------------------------------------------------------------- /docs/i-tutorials/unit-9.3-highorder/myHOFESpace.hpp: -------------------------------------------------------------------------------- 1 | #ifndef FILE_MYHOFESPACE_HPP 2 | #define FILE_MYHOFESPACE_HPP 3 | 4 | /* 5 | 6 | My own FESpace for high order finite elements ... 7 | 8 | */ 9 | 10 | 11 | namespace ngcomp 12 | { 13 | class MyHighOrderFESpace : public FESpace 14 | { 15 | int order; 16 | 17 | Array first_edge_dof; 18 | Array first_cell_dof; 19 | public: 20 | /* 21 | constructor. 22 | Arguments are the access to the mesh data structure, 23 | and the flags from the define command in the pde-file 24 | */ 25 | MyHighOrderFESpace (shared_ptr ama, const Flags & flags); 26 | virtual ~MyHighOrderFESpace() { } 27 | 28 | // a name for our new fe-space 29 | string GetClassName () const override 30 | { 31 | return "MyHighOrderFESpace"; 32 | } 33 | 34 | void Update() override; 35 | 36 | void GetDofNrs (ElementId ei, Array & dnums) const override; 37 | FiniteElement & GetFE (ElementId ei, Allocator & alloc) const override; 38 | }; 39 | } 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /docs/i-tutorials/unit-9.3-highorder/mymodule.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | // using namespace ngcomp; 5 | 6 | #include "myHOElement.cpp" 7 | #include "myHOFESpace.cpp" 8 | 9 | 10 | extern "C" void mymodule(py::object & res) { 11 | cout << "called mymodule" << endl; 12 | // import ngsolve such that python base classes are defined 13 | auto ngs = py::module::import("ngsolve"); 14 | 15 | static py::module::module_def def; 16 | py::module m = py::module::create_extension_module("", "", &def); 17 | 18 | using namespace ngcomp; 19 | ExportFESpace(m, "MyHighOrderFESpace"); 20 | 21 | 22 | res = m; 23 | } 24 | 25 | -------------------------------------------------------------------------------- /docs/install/compilengsolve.sh: -------------------------------------------------------------------------------- 1 | export BASEDIR=~/ngsuite 2 | mkdir -p $BASEDIR 3 | cd $BASEDIR && git clone https://github.com/NGSolve/ngsolve.git ngsolve-src 4 | cd $BASEDIR/ngsolve-src && git submodule update --init --recursive 5 | mkdir $BASEDIR/ngsolve-build 6 | mkdir $BASEDIR/ngsolve-install 7 | cd $BASEDIR/ngsolve-build 8 | cmake -DCMAKE_INSTALL_PREFIX=${BASEDIR}/ngsolve-install ${BASEDIR}/ngsolve-src 9 | make -j4 10 | make install 11 | echo "export NETGENDIR=${BASEDIR}/ngsolve-install/bin" >> ~/.bashrc 12 | echo "export PATH=\$NETGENDIR:\$PATH" >> ~/.bashrc 13 | export PYTHONPATH_TMP=`python3 -c "import os.path, sysconfig;print(os.path.relpath(sysconfig.get_path('platlib'), sysconfig.get_path('data')))"` 14 | echo "export PYTHONPATH=\$NETGENDIR/../${PYTHONPATH_TMP}:\$PATH" >> ~/.bashrc 15 | source ~/.bashrc 16 | cd ${BASEDIR}/ngsolve-install/share/ngsolve/py_tutorials/intro 17 | netgen navierstokes.py 18 | -------------------------------------------------------------------------------- /docs/install/install_sources.rst: -------------------------------------------------------------------------------- 1 | Install from sources 2 | ==================== 3 | 4 | .. toctree:: 5 | :maxdepth: 1 6 | 7 | installlinux.rst 8 | installwindows.rst 9 | installmacnative.rst 10 | cmakeoptions.rst 11 | -------------------------------------------------------------------------------- /docs/install/setenviron_mac.sh: -------------------------------------------------------------------------------- 1 | export PYTHONPATH=$PYTHONPATH:/Applications/Netgen.app/Contents/Resources/lib/python3.8/site-packages:. 2 | export NETGENDIR=/Applications/Netgen.app/Contents/MacOS 3 | export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$NETGENDIR 4 | export DYLD_FRAMEWORK_PATH=$DYLD_FRAMEWORK_PATH:$NETGENDIR/../Frameworks 5 | export PATH=$NETGENDIR:$PATH 6 | -------------------------------------------------------------------------------- /docs/netgen_tutorials/meshsize.rst: -------------------------------------------------------------------------------- 1 | Mesh Size and Refinement 2 | ========================== 3 | 4 | CSGeometry 5 | ----------- 6 | 7 | Local Mesh Size 8 | ^^^^^^^^^^^^^^^^^ 9 | 10 | Local mesh sizes of boundaries are given to the solid object itself, you can set the volume 11 | mesh size when adding them to the geometry object: 12 | 13 | .. literalinclude:: res_meshsize/csg_localmeshsize.py 14 | 15 | .. image:: res_meshsize/csg_localmeshsize.png 16 | 17 | Anisotropic Meshes 18 | ^^^^^^^^^^^^^^^^^^^ 19 | 20 | Netgen can create anisotropic meshes, using the close surface identification. It will fill 21 | the layer with prisms, which can be sliced. This is best explained in an example: 22 | 23 | .. literalinclude:: res_meshsize/closesurface_plate.py 24 | 25 | .. image:: res_meshsize/closesurface_plate.png 26 | 27 | -------------------------------------------------------------------------------- /docs/netgen_tutorials/res_define_2d_geometries/twodomains.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NGSolve/ngsolve/cab3abd87bbc83654d6b50d275be06e40cb3f040/docs/netgen_tutorials/res_define_2d_geometries/twodomains.png -------------------------------------------------------------------------------- /docs/netgen_tutorials/res_meshsize/closesurface_plate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NGSolve/ngsolve/cab3abd87bbc83654d6b50d275be06e40cb3f040/docs/netgen_tutorials/res_meshsize/closesurface_plate.png -------------------------------------------------------------------------------- /docs/netgen_tutorials/res_meshsize/closesurface_plate.py: -------------------------------------------------------------------------------- 1 | 2 | from netgen.csg import * 3 | 4 | geo = CSGeometry() 5 | 6 | box = OrthoBrick(Pnt(0,0,0),Pnt(1,1,1)) 7 | top = Plane(Pnt(0,0,0.52),Vec(0,0,1)) 8 | bot = Plane(Pnt(0,0,0.48),Vec(0,0,-1)) 9 | plate = box * top * bot 10 | 11 | geo.Add((box-top).mat("air")) 12 | geo.Add(plate.mat("plate")) 13 | geo.Add((box-bot).mat("air")) 14 | 15 | slices = [2**(-i) for i in reversed(range(1,6))] 16 | geo.CloseSurfaces(bot,top,slices) 17 | nmesh = geo.GenerateMesh(maxh=0.3) 18 | ZRefinement(nmesh,geo) 19 | 20 | from ngsolve import * 21 | mesh = Mesh(nmesh) 22 | Draw(mesh) 23 | -------------------------------------------------------------------------------- /docs/netgen_tutorials/res_meshsize/csg_localmeshsize.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NGSolve/ngsolve/cab3abd87bbc83654d6b50d275be06e40cb3f040/docs/netgen_tutorials/res_meshsize/csg_localmeshsize.png -------------------------------------------------------------------------------- /docs/netgen_tutorials/res_meshsize/csg_localmeshsize.py: -------------------------------------------------------------------------------- 1 | 2 | from netgen.csg import * 3 | 4 | geo = CSGeometry() 5 | # Set the mesh size on the sphere surface to 0.1 6 | sphere = Sphere(Pnt(0,0,0),1).maxh(0.1) 7 | # meshsize of the surface of the brick will not be finer than 8 | # the volume mesh size 9 | brick = OrthoBrick(Pnt(-2,-2,-2),Pnt(2,2,2)) 10 | # in the outer region we don't give a local mesh size -> global 11 | # is used 12 | geo.Add(brick-sphere) 13 | # in the volume of the sphere we set the meshsize to 0.2 14 | geo.Add(sphere,maxh=0.2) 15 | # the global mesh size is set to 0.4 16 | ngmesh = geo.GenerateMesh(maxh=0.4) 17 | 18 | # for visualization we need a NGSolve mesh 19 | from ngsolve import Mesh 20 | Draw(Mesh(ngmesh)) 21 | -------------------------------------------------------------------------------- /docs/netgen_tutorials/working_with_meshes.rst: -------------------------------------------------------------------------------- 1 | Working with meshes 2 | =================== 3 | 4 | 5 | In this example (:download:`merge.py`) we create two geometries (a cube and a sphere fitting inside), and mesh them. Then, we manually merge the surface meshes, and create a unified volume mesh, where the sphere and its complement are two different sub-domains. 6 | 7 | .. literalinclude:: /../external_dependencies/netgen/py_tutorials/merge.py 8 | -------------------------------------------------------------------------------- /docs/whetting_the_appetite/adaptive.rst: -------------------------------------------------------------------------------- 1 | Adaptive mesh refinement 2 | ======================== 3 | 4 | We are solving a stationary heat equation with highly varying coefficients. 5 | This example shows how to 6 | 7 | * model a 2D geometry be means of line segments 8 | * apply a Zienkiewicz-Zhu type error estimator. The flux is interpolated into an H(div)-conforming finite element space. 9 | * loop over several refinement levels 10 | 11 | Download: :download:`adaptive.py ` 12 | 13 | .. literalinclude:: /../py_tutorials/adaptive.py 14 | 15 | The solution on the adaptively refined mesh, and the convergence plot from matplotlib: 16 | 17 | .. image:: res_adaptive/adaptive_solution.jpg 18 | .. image:: res_adaptive/adaptive_err.png 19 | 20 | -------------------------------------------------------------------------------- /docs/whetting_the_appetite/cmagnet.rst: -------------------------------------------------------------------------------- 1 | .. _whetting-cmagnet: 2 | 3 | Symbolic definition of forms : magnetic field 4 | ============================================= 5 | 6 | We compute the magnetic field generated by a coil placed on a 7 | C-core. We see how to 8 | 9 | * model a 3D constructive solid geometry 10 | * set material properties from domain and boundary labels 11 | * define bilinear- and linear forms symbolically using trial- and testfunctions 12 | 13 | Download :download:`cmagnet.py` 14 | 15 | .. literalinclude:: /../py_tutorials/cmagnet.py 16 | 17 | Mesh and magnitude of magnetic field visualized in Netgen: 18 | 19 | .. image:: res_cmagnet/cmagnet_mesh.jpg 20 | .. image:: res_cmagnet/cmagnet_solution.jpg 21 | -------------------------------------------------------------------------------- /docs/whetting_the_appetite/elasticity.rst: -------------------------------------------------------------------------------- 1 | .. _how-to-elasticity: 2 | 3 | Nonlinear elasticity 4 | ==================== 5 | 6 | We solve the geometric nonlinear elasticity equation using a 7 | hyper-elastic energy density. We solve the stationary equation using 8 | the incremental load method. 9 | 10 | The example teaches how to 11 | 12 | * Define a non-linear variational formulation using SymbolicEnergy 13 | * Solve it by Newton's method 14 | * Use a parameter for increasing the load 15 | 16 | Download: :download:`elasticity.py` 17 | 18 | .. literalinclude:: /../py_tutorials/elasticity.py 19 | -------------------------------------------------------------------------------- /docs/whetting_the_appetite/navierstokes.rst: -------------------------------------------------------------------------------- 1 | .. _how-to-navierstokes: 2 | 3 | Navier Stokes Equation 4 | ====================== 5 | 6 | We solve the time-dependent incompressible Navier Stokes Equation. For 7 | that 8 | 9 | * we use the P3/P2 Taylor-Hood mixed finite element pairing 10 | * and perform operator splitting time-integration with the non-linear term explicit, but time-dependent Stokes fully implicit. 11 | 12 | The example is from the Schäfer-Turek `benchmark ` 13 | a two-dimensional cylinder, at Reynolds number 100 14 | 15 | Download :download:`navierstokes.py` 16 | 17 | .. literalinclude:: /../py_tutorials/navierstokes.py 18 | 19 | The absolute value of velocity: 20 | 21 | .. image:: res_navierstokes/navierstokes_solution.jpg 22 | -------------------------------------------------------------------------------- /docs/whetting_the_appetite/poisson.rst: -------------------------------------------------------------------------------- 1 | Poisson equation 2 | ================ 3 | 4 | We solve the Poisson equation on the unit-square, with homogeneous Dirichlet boundary conditions. You can run the :download:`example` either directly within the Python interpreter (Python version 3 is required!): 5 | 6 | .. code:: bash 7 | 8 | python3 poisson.py 9 | 10 | or you can run it with Netgen providing you also a graphical user interface 11 | 12 | .. code:: bash 13 | 14 | netgen poisson.py 15 | 16 | .. literalinclude:: /../py_tutorials/poisson.py 17 | .. :start-after: ngsglobals.msg_level = 1 18 | 19 | The solution visualized in Netgen: 20 | 21 | .. image:: res_poisson/poisson_solution.jpg 22 | 23 | -------------------------------------------------------------------------------- /docs/whetting_the_appetite/res_adaptive/adaptive_err.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NGSolve/ngsolve/cab3abd87bbc83654d6b50d275be06e40cb3f040/docs/whetting_the_appetite/res_adaptive/adaptive_err.png -------------------------------------------------------------------------------- /docs/whetting_the_appetite/res_adaptive/adaptive_solution.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NGSolve/ngsolve/cab3abd87bbc83654d6b50d275be06e40cb3f040/docs/whetting_the_appetite/res_adaptive/adaptive_solution.jpg -------------------------------------------------------------------------------- /docs/whetting_the_appetite/res_cmagnet/cmagnet_mesh.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NGSolve/ngsolve/cab3abd87bbc83654d6b50d275be06e40cb3f040/docs/whetting_the_appetite/res_cmagnet/cmagnet_mesh.jpg -------------------------------------------------------------------------------- /docs/whetting_the_appetite/res_cmagnet/cmagnet_solution.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NGSolve/ngsolve/cab3abd87bbc83654d6b50d275be06e40cb3f040/docs/whetting_the_appetite/res_cmagnet/cmagnet_solution.jpg -------------------------------------------------------------------------------- /docs/whetting_the_appetite/res_navierstokes/navierstokes_solution.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NGSolve/ngsolve/cab3abd87bbc83654d6b50d275be06e40cb3f040/docs/whetting_the_appetite/res_navierstokes/navierstokes_solution.jpg -------------------------------------------------------------------------------- /docs/whetting_the_appetite/res_poisson/poisson_solution.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NGSolve/ngsolve/cab3abd87bbc83654d6b50d275be06e40cb3f040/docs/whetting_the_appetite/res_poisson/poisson_solution.jpg -------------------------------------------------------------------------------- /emscripten/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if(EMSCRIPTEN AND NOT NETGEN_USE_PYTHON) 2 | add_executable(em_ngs em_ngs.cpp) 3 | target_include_directories(em_ngs PRIVATE ${ZLIB_INCLUDE_DIRS}) 4 | target_link_libraries(em_ngs PUBLIC ngcomp ngfem ngla ngbla ngstd nglib ${NETGEN_ZLIB_LIBRARIES}) 5 | target_link_options(em_ngs PUBLIC -sALLOW_MEMORY_GROWTH) 6 | target_link_options(em_ngs PUBLIC -lembind) 7 | target_link_options(em_ngs PUBLIC -sEXPORT_ES6=1 -sMODULARIZE) # -sLINKABLE) 8 | endif(EMSCRIPTEN AND NOT NETGEN_USE_PYTHON) 9 | -------------------------------------------------------------------------------- /external_dependencies/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # if(BUILD_NETGEN) 2 | # add_subdirectory(netgen) 3 | # endif() 4 | -------------------------------------------------------------------------------- /fem/coefficient_impl.hpp: -------------------------------------------------------------------------------- 1 | #ifndef FILE_COEFFICIENT_IMPL 2 | #define FILE_COEFFICIENT_IMPL 3 | 4 | 5 | namespace ngfem 6 | { 7 | 8 | 9 | struct GenericIdentity 10 | { 11 | template T operator() (T x) const { return x; } 12 | static string Name() { return " "; } 13 | template T Diff (T x) const { throw Exception("no GenericIdentity::Diff"); } 14 | void DoArchive(Archive& ar) {} 15 | }; 16 | 17 | } 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /fem/fe_interfaces.hpp: -------------------------------------------------------------------------------- 1 | 2 | #ifndef FILE_FEINTERFACES_ 3 | #define FILE_FEINTERFACES_ 4 | 5 | namespace ngfem 6 | { 7 | template 8 | class VertexOrientedFE 9 | { 10 | protected: 11 | enum { N_VERTEX = ET_trait::N_VERTEX }; 12 | int vnums[N_VERTEX]; 13 | 14 | public: 15 | template 16 | INLINE void SetVertexNumbers (const TA & avnums) 17 | { for (int i = 0; i < N_VERTEX; i++) vnums[i] = avnums[i]; } 18 | /// assign vertex number 19 | INLINE void SetVertexNumber (int nr, int vnum) { vnums[nr] = vnum; } 20 | INLINE FlatArray GetVertexNumbers () const { return { N_VERTEX, vnums }; } 21 | auto GetVertexOrientedEdge (int nr) const 22 | { 23 | return ET_trait::GetEdgeSort (nr, vnums); 24 | } 25 | auto GetVertexOrientedFace (int nr) const 26 | { 27 | return ET_trait::GetFaceSort (nr, vnums); 28 | } 29 | }; 30 | } 31 | 32 | #endif // FILE_FEINTERFACES_ 33 | -------------------------------------------------------------------------------- /fem/h1hofe.cpp: -------------------------------------------------------------------------------- 1 | /*********************************************************************/ 2 | /* File: h1hofe.cpp */ 3 | /* Author: Start */ 4 | /* Date: 6. Feb. 2003 */ 5 | /*********************************************************************/ 6 | 7 | #define FILE_H1HOFE_CPP 8 | 9 | #include 10 | 11 | -------------------------------------------------------------------------------- /fem/h1hofe_hex.cpp: -------------------------------------------------------------------------------- 1 | /*********************************************************************/ 2 | /* File: h1hofe.cpp */ 3 | /* Author: Start */ 4 | /* Date: 6. Feb. 2003 */ 5 | /*********************************************************************/ 6 | 7 | #include 8 | #include 9 | 10 | namespace ngfem 11 | { 12 | template class H1HighOrderFE; 13 | template class T_ScalarFiniteElement, ET_HEX>; 14 | } 15 | -------------------------------------------------------------------------------- /fem/h1hofe_prism.cpp: -------------------------------------------------------------------------------- 1 | /*********************************************************************/ 2 | /* File: h1hofe.cpp */ 3 | /* Author: Start */ 4 | /* Date: 6. Feb. 2003 */ 5 | /*********************************************************************/ 6 | 7 | #include 8 | #include 9 | 10 | namespace ngfem 11 | { 12 | template class H1HighOrderFE; 13 | template class T_ScalarFiniteElement, ET_PRISM>; 14 | } 15 | -------------------------------------------------------------------------------- /fem/h1hofe_pyramid.cpp: -------------------------------------------------------------------------------- 1 | /*********************************************************************/ 2 | /* File: h1hofe.cpp */ 3 | /* Author: Start */ 4 | /* Date: 6. Feb. 2003 */ 5 | /*********************************************************************/ 6 | 7 | #include 8 | #include 9 | 10 | namespace ngfem 11 | { 12 | template class H1HighOrderFE; 13 | template class T_ScalarFiniteElement, ET_PYRAMID>; 14 | } 15 | -------------------------------------------------------------------------------- /fem/h1hofe_quad.cpp: -------------------------------------------------------------------------------- 1 | /*********************************************************************/ 2 | /* File: h1hofe_segm.cpp */ 3 | /* Author: Start */ 4 | /* Date: 6. Feb. 2003 */ 5 | /*********************************************************************/ 6 | 7 | 8 | #include 9 | #include 10 | 11 | namespace ngfem 12 | { 13 | template class H1HighOrderFE; 14 | template class T_ScalarFiniteElement, ET_QUAD>; 15 | } 16 | -------------------------------------------------------------------------------- /fem/h1hofe_segm.cpp: -------------------------------------------------------------------------------- 1 | /*********************************************************************/ 2 | /* File: h1hofe_segm.cpp */ 3 | /* Author: Start */ 4 | /* Date: 6. Feb. 2003 */ 5 | /*********************************************************************/ 6 | 7 | 8 | // #include 9 | #include 10 | 11 | #include 12 | #include 13 | 14 | 15 | namespace ngfem 16 | { 17 | template class H1HighOrderFE; 18 | template class T_ScalarFiniteElement, ET_SEGM>; 19 | } 20 | -------------------------------------------------------------------------------- /fem/h1hofe_tet.cpp: -------------------------------------------------------------------------------- 1 | /*********************************************************************/ 2 | /* File: h1hofe.cpp */ 3 | /* Author: Start */ 4 | /* Date: 6. Feb. 2003 */ 5 | /*********************************************************************/ 6 | 7 | #include 8 | #include 9 | 10 | namespace ngfem 11 | { 12 | template class H1HighOrderFE; 13 | template class T_ScalarFiniteElement, ET_TET>; 14 | } 15 | -------------------------------------------------------------------------------- /fem/h1hofe_trig.cpp: -------------------------------------------------------------------------------- 1 | /*********************************************************************/ 2 | /* File: h1hofe_segm.cpp */ 3 | /* Author: Start */ 4 | /* Date: 6. Feb. 2003 */ 5 | /*********************************************************************/ 6 | 7 | 8 | #include 9 | #include 10 | 11 | namespace ngfem 12 | { 13 | template class H1HighOrderFE; 14 | template class T_ScalarFiniteElement, ET_TRIG>; 15 | } 16 | -------------------------------------------------------------------------------- /fem/h1hofefo.cpp: -------------------------------------------------------------------------------- 1 | /*********************************************************************/ 2 | /* File: h1hofefo.cpp */ 3 | /* Author: Start */ 4 | /* Date: 6. Feb. 2003 */ 5 | /*********************************************************************/ 6 | 7 | 8 | #define FILE_H1HOFEFO_CPP 9 | 10 | // #include 11 | #include 12 | #include 13 | 14 | 15 | -------------------------------------------------------------------------------- /fem/h1lofe.cpp: -------------------------------------------------------------------------------- 1 | /*********************************************************************/ 2 | /* File: h1lofe.cpp */ 3 | /* Author: Start */ 4 | /* Date: 6. Feb. 2003 */ 5 | /*********************************************************************/ 6 | 7 | #define FILE_H1LOFE_CPP 8 | 9 | // #include 10 | #include "h1lofe.hpp" 11 | 12 | 13 | -------------------------------------------------------------------------------- /fem/hcurlcurlfe.cpp: -------------------------------------------------------------------------------- 1 | /*********************************************************************/ 2 | /* File: hcurlcurlfe.cpp */ 3 | /* Author: Michael Neunteufel */ 4 | /* Date: June 2018 */ 5 | /*********************************************************************/ 6 | 7 | #define FILE_HCURLCURLFE_CPP 8 | 9 | // #include 10 | #include "hcurlcurlfe.hpp" 11 | 12 | -------------------------------------------------------------------------------- /fem/hcurlhofe.cpp: -------------------------------------------------------------------------------- 1 | /*********************************************************************/ 2 | /* File: hcurlhofe.cpp */ 3 | /* Author: Sabine Zaglmayr */ 4 | /* Date: 20. Maerz 2003 */ 5 | /* */ 6 | /* AutoDiff - revision: J. Schoeberl, March 2009 */ 7 | /*********************************************************************/ 8 | 9 | 10 | #include "hcurlhofe.hpp" 11 | #include "thcurlfe_impl.hpp" 12 | #include "hcurlhofe_impl.hpp" 13 | 14 | namespace ngfem 15 | { 16 | template class HCurlHighOrderFE; 17 | template class HCurlHighOrderFE; 18 | template class HCurlHighOrderFE; 19 | 20 | template class 21 | T_HCurlHighOrderFiniteElement>; 22 | template class 23 | T_HCurlHighOrderFiniteElement>; 24 | template class 25 | T_HCurlHighOrderFiniteElement>; 26 | } 27 | -------------------------------------------------------------------------------- /fem/hcurlhofe_hex.cpp: -------------------------------------------------------------------------------- 1 | /*********************************************************************/ 2 | /* File: hcurlhofe_hex.cpp */ 3 | /* Author: Sabine Zaglmayr */ 4 | /* Date: 20. Maerz 2003 */ 5 | /* */ 6 | /* AutoDiff - revision: J. Schoeberl, March 2009 */ 7 | /*********************************************************************/ 8 | 9 | // #include 10 | #include 11 | #include 12 | 13 | namespace ngfem 14 | { 15 | template class HCurlHighOrderFE; 16 | template class 17 | T_HCurlHighOrderFiniteElement>; 18 | } 19 | -------------------------------------------------------------------------------- /fem/hcurlhofe_prism.cpp: -------------------------------------------------------------------------------- 1 | /*********************************************************************/ 2 | /* File: hcurlhofe_prism.cpp */ 3 | /* Author: Sabine Zaglmayr */ 4 | /* Date: 20. Maerz 2003 */ 5 | /* */ 6 | /* AutoDiff - revision: J. Schoeberl, March 2009 */ 7 | /*********************************************************************/ 8 | 9 | 10 | #include 11 | #include 12 | 13 | namespace ngfem 14 | { 15 | template class HCurlHighOrderFE; 16 | template class 17 | T_HCurlHighOrderFiniteElement>; 18 | } 19 | -------------------------------------------------------------------------------- /fem/hcurlhofe_pyramid.cpp: -------------------------------------------------------------------------------- 1 | /*********************************************************************/ 2 | /* File: hcurlhofe_pyramid.cpp */ 3 | /* Author: Sabine Zaglmayr */ 4 | /* Date: 20. Maerz 2003 */ 5 | /* */ 6 | /* AutoDiff - revision: J. Schoeberl, March 2009 */ 7 | /*********************************************************************/ 8 | 9 | // #include 10 | #include 11 | #include 12 | 13 | 14 | namespace ngfem 15 | { 16 | template class HCurlHighOrderFE; 17 | template class 18 | T_HCurlHighOrderFiniteElement>; 19 | } 20 | -------------------------------------------------------------------------------- /fem/hcurlhofe_tet.cpp: -------------------------------------------------------------------------------- 1 | /*********************************************************************/ 2 | /* File: hcurlhofe_tet.cpp */ 3 | /* Author: Sabine Zaglmayr */ 4 | /* Date: 20. Maerz 2003 */ 5 | /* */ 6 | /* AutoDiff - revision: J. Schoeberl, March 2009 */ 7 | /*********************************************************************/ 8 | 9 | 10 | #include 11 | #include 12 | 13 | namespace ngfem 14 | { 15 | template class HCurlHighOrderFE; 16 | template class 17 | T_HCurlHighOrderFiniteElement>; 18 | } 19 | -------------------------------------------------------------------------------- /fem/l2hofe.cpp: -------------------------------------------------------------------------------- 1 | /*********************************************************************/ 2 | /* File: l2hofe.cpp */ 3 | /* Author: Start */ 4 | /* Date: 6. Feb. 2003 */ 5 | /*********************************************************************/ 6 | 7 | #define FILE_L2HOFE_CPP 8 | 9 | // #include 10 | #include "l2hofe.hpp" 11 | #include "l2hofefo.hpp" 12 | 13 | namespace ngfem 14 | { 15 | 16 | template<> 17 | ScalarFiniteElement<2> * CreateL2HighOrderFE (int order, FlatArray vnums, Allocator & lh) 18 | { 19 | DGFiniteElement * hofe = new (lh) L2HighOrderFE (order); 20 | for (int j = 0; j < 4; j++) 21 | hofe->SetVertexNumber (j, vnums[j]); 22 | return hofe; 23 | } 24 | 25 | 26 | } 27 | 28 | -------------------------------------------------------------------------------- /fem/l2hofefo.cpp: -------------------------------------------------------------------------------- 1 | /*********************************************************************/ 2 | /* File: l2hofefo.cpp */ 3 | /* Author: Start */ 4 | /* Date: 6. Feb. 2003 */ 5 | /*********************************************************************/ 6 | 7 | #define FILE_L2HOFEFO_CPP 8 | 9 | #include 10 | #include 11 | 12 | #include 13 | #include 14 | -------------------------------------------------------------------------------- /fem/nodalhofe.cpp: -------------------------------------------------------------------------------- 1 | 2 | #define FILE_NODALHOFE_CPP 3 | 4 | // #include 5 | #include 6 | 7 | -------------------------------------------------------------------------------- /include/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | install( FILES 2 | ngs_stdcpp_include.hpp ngs_defines.hpp compatibility.hpp 3 | DESTINATION ${NGSOLVE_INSTALL_DIR_INCLUDE} 4 | COMPONENT ngsolve_devel 5 | ) 6 | 7 | -------------------------------------------------------------------------------- /include/bla.hpp: -------------------------------------------------------------------------------- 1 | #include "../basiclinalg/bla.hpp" 2 | -------------------------------------------------------------------------------- /include/comp.hpp: -------------------------------------------------------------------------------- 1 | #include "../comp/comp.hpp" 2 | -------------------------------------------------------------------------------- /include/compatibility.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | You may want to include this file to keep your application compatible with 4 | different versions of ngsolve. 5 | 6 | */ 7 | 8 | 9 | 10 | 11 | #ifdef FILE_POSTPROC 12 | 13 | namespace ngcomp 14 | { 15 | 16 | // // argument MeshAccess ma was removed since it is available in GridFunction u 17 | // // change: ngsolve-5.1 - r1177, 20130404 18 | // NGS_DLL_HEADER 19 | // inline void SetValues (const MeshAccess & ma, 20 | // const CoefficientFunction & coef, 21 | // GridFunction & u, 22 | // bool vb, 23 | // DifferentialOperator * diffop, // NULL is FESpace evaluator 24 | // LocalHeap & clh) 25 | // { 26 | // SetValues (coef, u, vb, diffop, clh); 27 | // } 28 | } 29 | 30 | 31 | #endif 32 | 33 | 34 | 35 | #define L2HighOrderFiniteElement DGFiniteElement 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /include/fem.hpp: -------------------------------------------------------------------------------- 1 | #include "../fem/fem.hpp" 2 | -------------------------------------------------------------------------------- /include/la.hpp: -------------------------------------------------------------------------------- 1 | #include "../linalg/la.hpp" 2 | -------------------------------------------------------------------------------- /include/multigrid.hpp: -------------------------------------------------------------------------------- 1 | #include "../multigrid/multigrid.hpp" 2 | -------------------------------------------------------------------------------- /include/ngs_defines.hpp: -------------------------------------------------------------------------------- 1 | #ifndef FILE_NGS_DEFINES 2 | #define FILE_NGS_DEFINES 3 | 4 | /**************************************************************************/ 5 | /* File: ngs_defines.hpp */ 6 | /* Author: Joachim Schoeberl */ 7 | /* Date: 21. Feb. 03 */ 8 | /**************************************************************************/ 9 | 10 | 11 | 12 | 13 | // performs range-checking 14 | // #define DEBUG 15 | 16 | 17 | // maximal system dimension (3D elasticity = 3, piezo = 4) 18 | // 8 for multiharmonic 19 | 20 | #ifndef MAX_SYS_DIM 21 | #define MAX_SYS_DIM 3 22 | #endif 23 | 24 | #ifndef MAX_CACHEBLOCKS 25 | #define MAX_CACHEBLOCKS 0 26 | #endif 27 | 28 | 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /include/ngstd.hpp: -------------------------------------------------------------------------------- 1 | #include "../ngstd/ngstd.hpp" 2 | 3 | -------------------------------------------------------------------------------- /include/parallelngs.hpp: -------------------------------------------------------------------------------- 1 | #include "../parallel/parallelngs.hpp" 2 | -------------------------------------------------------------------------------- /include/solve.hpp: -------------------------------------------------------------------------------- 1 | #include "../solve/solve.hpp" 2 | -------------------------------------------------------------------------------- /linalg/chebyshev.hpp: -------------------------------------------------------------------------------- 1 | #ifndef FILE_CHEBYSHEV 2 | #define FILE_CHEBYSHEV 3 | 4 | /**************************************************************************/ 5 | /* File: chebyshev.hpp */ 6 | /* Author: Joachim Schoeberl */ 7 | /* Date: 30. Jun. 01 */ 8 | /**************************************************************************/ 9 | 10 | 11 | #include "basematrix.hpp" 12 | 13 | namespace ngla 14 | { 15 | 16 | /** 17 | Chebyshev iteraion 18 | */ 19 | class NGS_DLL_HEADER ChebyshevIteration : public BaseMatrix 20 | { 21 | protected: 22 | /// 23 | const BaseMatrix *a, *c; 24 | /// 25 | int steps; 26 | /// 27 | double lmin, lmax; 28 | public: 29 | /// 30 | ChebyshevIteration (const BaseMatrix & aa, const BaseMatrix & ac, int steps); 31 | 32 | bool IsComplex() const override { return a->IsComplex(); } 33 | /// 34 | void SetBounds (double almin, double almax); 35 | /// 36 | void Mult (const BaseVector & v, BaseVector & prod) const override; 37 | /// 38 | AutoVector CreateRowVector () const override { return a->CreateColVector(); } 39 | AutoVector CreateColVector () const override { return a->CreateRowVector(); } 40 | }; 41 | 42 | } 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /linalg/la.hpp: -------------------------------------------------------------------------------- 1 | #ifndef FILE_NGLA 2 | #define FILE_NGLA 3 | 4 | #include 5 | 6 | /** namespace for linear algebra. 7 | */ 8 | 9 | namespace ngla 10 | { 11 | using namespace std; 12 | using namespace ngstd; 13 | using namespace ngbla; 14 | } 15 | 16 | 17 | #include "paralleldofs.hpp" 18 | #include "basevector.hpp" 19 | #include "vvector.hpp" 20 | #include "multivector.hpp" 21 | #include "basematrix.hpp" 22 | #include "sparsematrix.hpp" 23 | #include "sparsematrix_dyn.hpp" 24 | #include "order.hpp" 25 | #include "sparsecholesky.hpp" 26 | #include "pardisoinverse.hpp" 27 | #include "jacobi.hpp" 28 | #include "blockjacobi.hpp" 29 | #include "commutingAMG.hpp" 30 | #include "diagonalmatrix.hpp" 31 | #include "special_matrix.hpp" 32 | #include "elementbyelement.hpp" 33 | #include "cg.hpp" 34 | #include "chebyshev.hpp" 35 | #include "eigen.hpp" 36 | #include "arnoldi.hpp" 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /linalg/la.py: -------------------------------------------------------------------------------- 1 | 2 | sollte nicht mehr verwendet werden 3 | 4 | 5 | ############################################### 6 | # Additional operators 7 | ############################################### 8 | 9 | BaseVector.expr = property(lambda self: VecExpr(self)) 10 | BaseVector.data = property(lambda self: None, lambda self, a: Expr(a).AssignTo(self.expr)) 11 | BaseVector.__add__ = lambda self,y: self.expr+Expr(y) 12 | BaseVector.__sub__ = lambda self,y: self.expr-Expr(y) 13 | BaseVector.__rmul__ = lambda self,y: y*self.expr 14 | BaseVector.__getitem__ = GetSlice 15 | BaseVector.__setitem__ = SetSlice 16 | 17 | BaseMatrix.expr = property(lambda self: MatExpr(self)) 18 | BaseMatrix.data = property(lambda self: None, lambda self, a: Expr(a).AssignTo(self.expr)) 19 | BaseMatrix.__add__ = lambda self,y: self.expr+Expr(y) 20 | BaseMatrix.__rmul__ = lambda self,y: y*self.expr 21 | BaseMatrix.__mul__ = lambda self,y: MatVecExpr(self.expr, Expr(y)) 22 | -------------------------------------------------------------------------------- /linalg/ngla.dxx: -------------------------------------------------------------------------------- 1 | /** @name Linear Algebra 2 | \begin{verbatim} (directory ngsolve/linalg)\end{verbatim} 3 | 4 | The linear algebra library is based on the abstract base classes 5 | \Ref{BaseVector} and \Ref{BaseMatrix}. Derived objects are 6 | vector classes (\Ref{VVector},...) or specific matrix classes 7 | (\Ref{SparseMatrix}, ...). Linear operations (\Ref{KrylovSpaceSolver}) 8 | are derived from BaseMatrix as well. 9 | 10 | Matrices have to provide the matrix times vector operation. 11 | The preferred function is 12 | \begin{verbatim} 13 | virtual void MultAdd (double s, const BaseVector & x, BaseVector & y) const 14 | \end{verbatim} 15 | implementing 16 | \[ 17 | y = y + s * Mat * x 18 | \] 19 | 20 | Expression templates enable a convenient notation. But, in contrast to 21 | the basic linear algebra, the expression tree is expanded to 22 | vector-vector and matrix-vector operations. */ 23 | -------------------------------------------------------------------------------- /linalg/ngla_main.dxx: -------------------------------------------------------------------------------- 1 | //@{ 2 | //@Include: ngla.dxx 3 | //@} 4 | 5 | //@Include: *.hpp 6 | -------------------------------------------------------------------------------- /multigrid/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}) 2 | 3 | install( FILES 4 | mgpre.hpp multigrid.hpp prolongation.hpp smoother.hpp 5 | DESTINATION ${NGSOLVE_INSTALL_DIR_INCLUDE} 6 | COMPONENT ngsolve_devel 7 | ) 8 | 9 | -------------------------------------------------------------------------------- /multigrid/multigrid.hpp: -------------------------------------------------------------------------------- 1 | #ifndef FILE_MULTIGRID 2 | #define FILE_MULTIGRID 3 | 4 | /*********************************************************************/ 5 | /* File: multigrid.hh */ 6 | /* Author: Joachim Schoeberl */ 7 | /* Date: 20. Apr. 2000 */ 8 | /*********************************************************************/ 9 | 10 | /* 11 | Multigrid algorithms 12 | */ 13 | 14 | 15 | // #include 16 | 17 | /// namespace for multigrid components 18 | 19 | /* 20 | namespace ngfem { }; 21 | namespace ngcomp { }; 22 | 23 | namespace ngmg 24 | { 25 | using namespace std; 26 | using namespace ngstd; 27 | using ngcore::INT; 28 | using namespace ngla; 29 | using namespace ngfem; 30 | using namespace ngcomp; 31 | } 32 | */ 33 | 34 | 35 | #include "mgpre.hpp" 36 | #include "prolongation.hpp" 37 | #include "smoother.hpp" 38 | // #include "vefc.hpp" 39 | // #include "evcoarse.hpp" 40 | 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /ngscuda/examples/devdmatrix.py: -------------------------------------------------------------------------------- 1 | # file: devdmatrix.py 2 | # date: 28.09.2022 3 | # 4 | # testing basic functions for dense matrix on device 5 | 6 | from ngsolve.bla import * 7 | from ngsolve.la import * 8 | from ngsolve.ngscuda import * 9 | 10 | m = 3 11 | n = 4 12 | k = 5 13 | 14 | A = MatrixD(m, k) 15 | A[:] = 1 16 | 17 | B = MatrixD(k, n) 18 | B[:] = 2 19 | 20 | C = MatrixD(m, n) 21 | C[:] = 3 22 | 23 | Adev = CreateDevMatrix(A) 24 | Bdev = CreateDevMatrix(B) 25 | Cdev = CreateDevMatrix(C) 26 | 27 | 28 | # scale matrix 29 | print("Scale Matrix") 30 | Cdev.Scale(3) 31 | # print(Cdev) 32 | 33 | # add two matrices 34 | print("Add Matrix") 35 | Bdev.Add(Bdev) 36 | # print(Bdev) 37 | 38 | # set the matrix zero 39 | print("Set Matrix to zero") 40 | Cdev.SetZero() 41 | # print(Cdev) 42 | 43 | # multiply matrix-vector 44 | print("Matrix-Vector Multiplication") 45 | x = Adev.CreateRowVector() 46 | x.FV()[:] = 1 47 | 48 | y = Adev.CreateColVector() 49 | 50 | x.UpdateDevice() 51 | y.UpdateDevice() 52 | Adev.Mult(x, y) 53 | # print(y) 54 | -------------------------------------------------------------------------------- /ngscuda/examples/jacobi.py: -------------------------------------------------------------------------------- 1 | # file: jacobi.py 2 | # date: 28.09.2022 3 | # 4 | # CG-Solver using Jacobi on GPU 5 | 6 | from ngsolve import * 7 | import ngsolve 8 | from ngsolve.la import * 9 | from ngsolve.ngscuda import * 10 | from ngsolve.webgui import Draw 11 | from netgen.geom2d import unit_square 12 | import time 13 | 14 | h = 0.01 15 | p = 5 16 | rep = 3 17 | mesh = Mesh(unit_square.GenerateMesh(maxh=h)) 18 | fes = H1(mesh, order=p, dirichlet="bottom|right") 19 | fes.ndof 20 | 21 | print("h:", h) 22 | print("p:", p) 23 | 24 | u, v = fes.TnT() 25 | 26 | a = BilinearForm(grad(u)*grad(v)*dx) 27 | a.Assemble() 28 | 29 | f = LinearForm(x*v*dx) 30 | f.Assemble() 31 | 32 | gfu = GridFunction(fes) 33 | 34 | 35 | # CG-Solver on CPU 36 | c = a.mat.CreateSmoother(fes.FreeDofs()) 37 | 38 | with TaskManager(): 39 | inv_host = CGSolver(a.mat, c, maxsteps=1000) 40 | gfu.vec.data = inv_host * f.vec 41 | 42 | 43 | # CG-Solver on GPU 44 | fdev = UnifiedVector(f.vec) 45 | adev = CreateDevMatrix(a.mat) 46 | 47 | devjac = CreateDevSmoother(a.mat, fes.FreeDofs()) 48 | 49 | fdev.UpdateDevice() 50 | 51 | inv = CGSolver(adev, devjac, maxsteps=1000) 52 | res = inv * fdev 53 | res.Evaluate() 54 | 55 | 56 | # diff = (res - gfu.vec).Evaluate() 57 | # M = max([abs(diff[i]) for i in range(len(diff))]) 58 | # print("max diff:", M) 59 | 60 | -------------------------------------------------------------------------------- /ngstd/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}) 2 | 3 | add_library( ngstd ${NGS_LIB_TYPE} 4 | blockalloc.cpp evalfunc.cpp templates.cpp 5 | stringops.cpp statushandler.cpp 6 | python_ngstd.cpp 7 | bspline.cpp 8 | ) 9 | 10 | target_compile_definitions(ngstd PUBLIC ${NGSOLVE_COMPILE_DEFINITIONS}) 11 | target_compile_definitions(ngstd PRIVATE ${NGSOLVE_COMPILE_DEFINITIONS_PRIVATE}) 12 | target_compile_options(ngstd PUBLIC ${NGSOLVE_COMPILE_OPTIONS}) 13 | target_include_directories(ngstd PUBLIC ${NGSOLVE_INCLUDE_DIRS} ) 14 | 15 | add_dependencies( ngstd generate_version_file ) 16 | 17 | target_link_libraries(ngstd PUBLIC netgen_libs) 18 | target_link_libraries(ngstd PUBLIC ${MPI_CXX_LIBRARIES} PRIVATE "$") 19 | target_link_libraries(ngstd ${LAPACK_CMAKE_LINK_INTERFACE} "$") 20 | install( TARGETS ngstd ${ngs_install_dir} ) 21 | 22 | install( FILES 23 | bessel.hpp blockalloc.hpp evalfunc.hpp 24 | memusage.hpp ngstd.hpp 25 | stringops.hpp 26 | statushandler.hpp ngsstream.hpp 27 | mycomplex.hpp python_ngstd.hpp ngs_utils.hpp 28 | bspline.hpp sample_sort.hpp 29 | DESTINATION ${NGSOLVE_INSTALL_DIR_INCLUDE} 30 | COMPONENT ngsolve_devel 31 | ) 32 | -------------------------------------------------------------------------------- /ngstd/memusage.hpp: -------------------------------------------------------------------------------- 1 | #ifndef FILE_MEMUSAGE 2 | #define FILE_MEMUSAGE 3 | 4 | /**************************************************************************/ 5 | /* File: memusage.hpp */ 6 | /* Author: Joachim Schoeberl */ 7 | /* Date: 16. June 2002 */ 8 | /**************************************************************************/ 9 | 10 | namespace ngstd 11 | { 12 | 13 | /** 14 | Reports amount of used memory 15 | */ 16 | class MemoryUsage 17 | { 18 | protected: 19 | string name; 20 | size_t nbytes; 21 | size_t nblocks; 22 | public: 23 | MemoryUsage () = default; 24 | MemoryUsage (const string & aname, 25 | size_t anbytes, size_t anblocks) 26 | : name(aname), nbytes(anbytes), nblocks(anblocks) 27 | { ; } 28 | MemoryUsage (const MemoryUsage &) = default; 29 | MemoryUsage (MemoryUsage &&) = default; 30 | MemoryUsage & operator= (const MemoryUsage &) = default; 31 | MemoryUsage & operator= (MemoryUsage &&) = default; 32 | 33 | void AddName (const string & aname) { name += aname; } 34 | const string & Name() const { return name; } 35 | size_t NBytes () const { return nbytes; } 36 | size_t NBlocks () const { return nblocks; } 37 | }; 38 | 39 | } 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /ngstd/ngstd.dxx: -------------------------------------------------------------------------------- 1 | /** Standard Data Types and Algorithms 2 | 3 | The ngstd library contains generic container classes 4 | 5 | - linear containers: FlatArray, Array, ArrayMem 6 | - table containers: Table, DynamicTable, HashTable, SymbolTable, 7 | 8 | 9 | It contains utility classes: 10 | 11 | - For memory management: LocalHeap HeapReset BlockAllocator AutoPtr 12 | - For Profiling: NgProfiler 13 | - Exception handling: Exception 14 | - and some more: BitArray, Flags 15 | - a function parser EvalFunction 16 | - automatic differentiation: AutoDiff, AutoDiffDiff 17 | 18 | */ 19 | 20 | namespace ngstd { ; } -------------------------------------------------------------------------------- /ngstd/ngstd_main.dxx: -------------------------------------------------------------------------------- 1 | //@{ 2 | //@Include: ngstd.dxx 3 | //@} 4 | 5 | //@Include: *.hpp 6 | -------------------------------------------------------------------------------- /ngstd/statushandler.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | namespace ngstd 6 | { 7 | static mutex m; 8 | void BaseStatusHandler::PushStatus (const char * str) 9 | { 10 | lock_guard lock(m); 11 | Ng_PushStatus(str); 12 | } 13 | 14 | void BaseStatusHandler::PopStatus () 15 | { 16 | lock_guard lock(m); 17 | Ng_PopStatus(); 18 | } 19 | 20 | void BaseStatusHandler::SetThreadPercentage (double percent) 21 | { 22 | Ng_SetThreadPercentage(percent); 23 | } 24 | 25 | void BaseStatusHandler::GetStatus (string & str, double & percent) 26 | { 27 | char * s; 28 | Ng_GetStatus(&s, percent); 29 | str = s; 30 | } 31 | 32 | void BaseStatusHandler::SetTerminate(void) 33 | { 34 | Ng_SetTerminate(); 35 | } 36 | 37 | void BaseStatusHandler::UnSetTerminate(void) 38 | { 39 | Ng_UnSetTerminate(); 40 | } 41 | 42 | bool BaseStatusHandler::ShouldTerminate(void) 43 | { 44 | return (Ng_ShouldTerminate() != 0); 45 | } 46 | 47 | } // namespace ngstd 48 | 49 | -------------------------------------------------------------------------------- /ngstd/statushandler.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _STATUSHANDLER_HPP 2 | #define _STATUSHANDLER_HPP 3 | 4 | namespace ngstd 5 | { 6 | 7 | /** Access to statusbar. (and more) 8 | */ 9 | 10 | class NGS_DLL_HEADER BaseStatusHandler 11 | { 12 | public: 13 | static void PushStatus (const char * str); 14 | static void PopStatus (); 15 | static void SetThreadPercentage (double percent); 16 | 17 | static void GetStatus (string & str, double & percent); 18 | 19 | static void SetTerminate(void); 20 | static void UnSetTerminate(void); 21 | static bool ShouldTerminate(void); 22 | 23 | class Region 24 | { 25 | public: 26 | Region(const char * str) { PushStatus(str); } 27 | ~Region() { PopStatus(); } 28 | }; 29 | }; 30 | 31 | } 32 | 33 | #endif // _STATUSHANDLER_HPP 34 | -------------------------------------------------------------------------------- /ngstd/stringops.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _STRINGOPS_HPP 2 | #define _STRINGOPS_HPP 3 | 4 | namespace ngstd 5 | { 6 | 7 | // NGS_DLL_HEADER bool StringFitsPattern(const string & str, const string & pattern); 8 | NGS_DLL_HEADER bool StringFitsPattern(string_view str, string_view pattern); 9 | 10 | } 11 | 12 | #endif // _STRINGOPS_HPP 13 | -------------------------------------------------------------------------------- /parallel/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}) 2 | 3 | install( FILES 4 | parallelngs.hpp parallelvector.hpp parallel_matrices.hpp dump.hpp 5 | DESTINATION ${NGSOLVE_INSTALL_DIR_INCLUDE} 6 | COMPONENT ngsolve_devel 7 | ) 8 | 9 | -------------------------------------------------------------------------------- /parallel/parallelngs.hpp: -------------------------------------------------------------------------------- 1 | #ifndef FILE_PARALLELNGS 2 | #define FILE_PARALLELNGS 3 | 4 | /* 5 | #include 6 | #include 7 | 8 | namespace ngparallel 9 | { 10 | using namespace ngstd; 11 | using namespace ngla; 12 | } 13 | */ 14 | 15 | #include "parallelvector.hpp" 16 | #include "parallel_matrices.hpp" 17 | 18 | 19 | #endif 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /pde_tutorial/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | install( FILES 2 | beam.geo chip.vol coilshield.vol cube.vol d3_helmholtz.pde d6_shaft.pde piezo2d40round4.vol.gz square.in2d beam.vol coil.geo coil.vol d1_square.pde d4_cube.pde d7_coil.pde shaft.geo square.vol chip.in2d coilshield.geo cube.geo d2_chip.pde d5_beam.pde d8_coilshield.pde shaft.vol doubleglazing.in2d doubleglazing.vol d10_DGdoubleglazing.pde d9_hybridDG.pde d11_chip_nitsche.pde 3 | DESTINATION ${NGSOLVE_INSTALL_DIR_RES}/ngsolve 4 | COMPONENT ngsolve_tutorial 5 | ) 6 | 7 | -------------------------------------------------------------------------------- /pde_tutorial/beam.geo: -------------------------------------------------------------------------------- 1 | algebraic3d 2 | 3 | # the first plane gets boundary condition nr 1: 4 | 5 | solid p1 = plane (0, 0, 0; -1, 0, 0) -bc=1; 6 | 7 | # and the other faces b.c. number = 2: 8 | solid beam = plane (0, 0, 0; 0, 0, -1) 9 | and plane (0, 0, 0; 0, -1, 0) 10 | and p1 11 | and plane (10, 2, 1; 0, 0, 1) 12 | and plane (10, 2, 1; 0, 1, 0) 13 | and plane (10, 2, 1; 1, 0, 0) -bc=2 -maxh=2; 14 | 15 | tlo beam; 16 | 17 | 18 | -------------------------------------------------------------------------------- /pde_tutorial/chip.in2d: -------------------------------------------------------------------------------- 1 | splinecurves2dv2 2 | 3 3 | 4 | points 5 | 1 0 0 6 | 2 1 0 7 | 3 1 0.6 8 | 4 0 0.6 9 | 5 0.2 0.6 10 | 6 0.8 0.6 11 | 7 0.8 0.8 12 | 8 0.2 0.8 13 | 9 0.5 0.15 14 | 10 0.65 0.3 15 | 11 0.5 0.45 16 | 12 0.35 0.3 17 | 18 | 19 | segments 20 | 21 | 1 0 2 1 2 -bc=1 22 | 1 0 2 2 3 -bc=2 23 | 1 0 2 3 6 -bc=2 24 | 1 2 2 6 5 -bc=2 25 | 1 0 2 5 4 -bc=2 26 | 1 0 2 4 1 -bc=2 27 | 28 | 2 0 2 6 7 -bc=2 29 | 2 0 2 7 8 -bc=2 30 | 2 0 2 8 5 -bc=2 31 | 32 | 3 1 2 9 10 -bc=2 33 | 3 1 2 10 11 -bc=2 34 | 3 1 2 11 12 -bc=2 35 | 3 1 2 12 9 -bc=2 36 | 37 | materials 38 | 1 d1 -maxh=0.2 39 | 2 d2 -maxh=0.2 40 | 3 d3 -maxh=0.05 41 | 42 | -------------------------------------------------------------------------------- /pde_tutorial/coil.geo: -------------------------------------------------------------------------------- 1 | algebraic3d 2 | solid coil = cylinder (0, 0, -1; 0, 0, 1; 0.4) 3 | and not cylinder (0, 0, -1; 0, 0, 1; 0.2) 4 | and plane (0, 0, 0.4; 0, 0, 1) 5 | and plane (0, 0, -0.4; 0, 0, -1) -bc=2; 6 | 7 | solid box = orthobrick (-2, -2, -2; 3, 2, 2) -bc=1; 8 | 9 | solid air = box and not coil -bc=3; 10 | 11 | tlo coil -col=[0, 1, 0] -material=matcoil; 12 | tlo air -col=[0, 0, 1] -transparent -material=air; 13 | -------------------------------------------------------------------------------- /pde_tutorial/coilshield.geo: -------------------------------------------------------------------------------- 1 | algebraic3d 2 | 3 | solid box = orthobrick (-2, -2, -2; 3, 2, 2) -bc=1; 4 | 5 | solid pl1 = plane (1.1, 0, 0; 1, 0, 0); 6 | solid pl2 = plane (1, 0, 0; -1, 0, 0); 7 | 8 | solid shield = orthobrick (0, -1.5, -1.5; 2, 1.5, 1.5) 9 | and pl1 and pl2; 10 | 11 | solid coil = cylinder (0, 0, -1; 0, 0, 1; 0.4) 12 | and not cylinder (0, 0, -1; 0, 0, 1; 0.2) 13 | and plane (0, 0, 0.4; 0, 0, 1) 14 | and plane (0, 0, -0.4; 0, 0, -1); 15 | 16 | solid air = box and not coil and not shield -bc=2; 17 | 18 | tlo shield -col=[1, 0, 0] -material=iron; 19 | tlo coil -col=[0, 1, 0] -material=coil; 20 | tlo air -col=[0, 0, 1] -transparent -material=air; 21 | 22 | identify closesurfaces pl1 pl2; 23 | 24 | 25 | -------------------------------------------------------------------------------- /pde_tutorial/cube.geo: -------------------------------------------------------------------------------- 1 | # 2 | ## A cube 3 | # 4 | algebraic3d 5 | 6 | # cube consisting of 6 planes: 7 | 8 | solid p1 = plane (0, 0, 0; -1, 0, 0) -bc=1; 9 | solid p2 = plane (0, 0, 0; 0, -1, 0) -bc=1; 10 | solid p3 = plane (0, 0, 0; 0, 0, -1) -bc=1; 11 | solid p4 = plane (1, 1, 1; 1, 0, 0) -bc=1; 12 | solid p5 = plane (1, 1, 1; 0, 1, 0) -bc=1; 13 | solid p6 = plane (1, 1, 1; 0, 0, 1) -bc=2; 14 | 15 | solid cube = p1 and p2 and p3 and p4 and p5 and p6; 16 | 17 | tlo cube; 18 | 19 | 20 | -------------------------------------------------------------------------------- /pde_tutorial/d11_chip_nitsche.pde: -------------------------------------------------------------------------------- 1 | #modified version of the d2_chip.pde example. here boundary conditions 2 | #are incorporated in a weak sense with nitsche penalization 3 | geometry = chip.in2d 4 | mesh = chip.vol 5 | 6 | define coefficient lam 7 | 1, 1000, 10, 8 | 9 | 10 | define coefficient coef_source 11 | 0, 0, 1, 12 | 13 | define fespace v -type=h1ho -order=3 #-dirichlet=[1] 14 | define fespace verr -type=l2 -order=0 15 | 16 | define gridfunction u -fespace=v -nested 17 | define gridfunction err -fespace=verr 18 | 19 | define constant alpha = 10 20 | 21 | define bilinearform a -fespace=v -symmetric 22 | laplace lam 23 | nitsche lam alpha -definedon=1 24 | 25 | define linearform f -fespace=v 26 | source coef_source 27 | #nitsche lam dir alpha -definedon=1 28 | 29 | define preconditioner c -type=multigrid -bilinearform=a -smoothingsteps=3 30 | 31 | numproc bvp np1 -bilinearform=a -linearform=f -gridfunction=u -preconditioner=c -maxsteps=1000 32 | 33 | numproc drawflux np2 -bilinearform=a -solution=u -applyd -label=flux 34 | 35 | numproc zzerrorestimator np3 -bilinearform=a -linearform=f -solution=u -error=err -minlevel=1 36 | numproc markelements np4 -error=err -minlevel=1 -factor=0.5 37 | 38 | 39 | 40 | numproc visualization npv1 -scalarfunction=u -subdivision=2 -nolineartexture 41 | -------------------------------------------------------------------------------- /pde_tutorial/d1_square.pde: -------------------------------------------------------------------------------- 1 | # 2 | # solve the Poisson equation -Delta u = f 3 | # 4 | # with boundary conditions 5 | # u = 0 on Gamma1 6 | # du/dn = 1 on Gamma2 7 | 8 | 9 | # load geometry 10 | geometry = square.in2d 11 | 12 | # and mesh 13 | mesh = square.vol 14 | 15 | 16 | # define a finite element space 17 | # Dirichlet boundary is Gamma_1 18 | # play around with -order=... 19 | fespace v -type=h1ho -order=3 -dirichlet=[1] 20 | 21 | # the solution field 22 | gridfunction u -fespace=v -nested 23 | 24 | linearform f -fespace=v 25 | source x*sin(pi*y) 26 | # neumann 1 --definedon=[2] # Neumann on Gamma_2 27 | 28 | # the bilinear-form 29 | bilinearform a -fespace=v -symmetric -eliminate_internal 30 | laplace 1 31 | 32 | 33 | # preconditioner c -type=direct -bilinearform=a 34 | # preconditioner c -type=local -bilinearform=a 35 | # preconditioner c -type=multigrid -bilinearform=a -smoother=block 36 | preconditioner c -type=bddc -bilinearform=a 37 | 38 | 39 | numproc bvp np1 -bilinearform=a -linearform=f -gridfunction=u -preconditioner=c -maxsteps=1000 40 | 41 | numproc drawflux np2 -bilinearform=a -solution=u -label=flux -applyd 42 | 43 | numproc visualization npv1 -scalarfunction=u -subdivision=2 -nolineartexture 44 | -------------------------------------------------------------------------------- /pde_tutorial/d2_chip.pde: -------------------------------------------------------------------------------- 1 | geometry = chip.in2d 2 | mesh = chip.vol 3 | 4 | # one coefficient per sub-domain 5 | coefficient lam 6 | 1, 1000, 10, 7 | 8 | # source in sub-domain 3 9 | coefficient coef_source 10 | 0, 0, 1, 11 | 12 | fespace v -type=h1ho -order=3 -dirichlet=[1] 13 | fespace verr -type=l2 -order=0 14 | 15 | gridfunction u -fespace=v -nested 16 | gridfunction err -fespace=verr 17 | 18 | bilinearform a -fespace=v -symmetric 19 | laplace lam 20 | 21 | linearform f -fespace=v 22 | source coef_source 23 | 24 | preconditioner c -type=multigrid -bilinearform=a -smoothingsteps=3 25 | 26 | numproc bvp np1 -bilinearform=a -linearform=f -gridfunction=u -preconditioner=c -maxsteps=1000 27 | 28 | numproc drawflux np2 -bilinearform=a -solution=u -applyd -label=flux 29 | 30 | numproc zzerrorestimator np3 -bilinearform=a -solution=u -error=err -minlevel=1 31 | numproc markelements np4 -error=err -minlevel=1 -factor=0.5 32 | 33 | numproc writefile wf -variables=[mesh.levels,fes.v.ndof,ZZerrest.np3.err] -filename=d2_error.out 34 | 35 | numproc visualization npv1 -scalarfunction=u -subdivision=2 -nolineartexture 36 | -------------------------------------------------------------------------------- /pde_tutorial/d3_helmholtz.pde: -------------------------------------------------------------------------------- 1 | mesh = piezo2d40round4.vol.gz 2 | 3 | define constant k = 1.8 4 | 5 | define fespace v -type=h1ho -order=3 -complex -dirichlet=[1,2] 6 | 7 | define gridfunction u -fespace=v -nested 8 | 9 | define bilinearform a -fespace=v -symmetric 10 | laplace 1 11 | mass (-k*k) 12 | robin (-k*I) --definedon=4 13 | 14 | define linearform f -fespace=v 15 | 16 | define coefficient coef_dirichlet 17 | 1, -1, 0, 0, 18 | numproc setvalues npsv -coefficient=coef_dirichlet -gridfunction=u -boundary 19 | 20 | numproc bvp np1 -bilinearform=a -linearform=f -gridfunction=u -solver=direct 21 | 22 | numproc visualization npv1 -scalarfunction=u -subdivision=2 -nolineartexture 23 | -------------------------------------------------------------------------------- /pde_tutorial/d4_cube.pde: -------------------------------------------------------------------------------- 1 | geometry = cube.geo 2 | mesh = cube.vol 3 | 4 | constant heapsize = 10000000 5 | 6 | constant pen = 1e7 7 | 8 | coefficient lam 9 | 1, 10 | 11 | coefficient rho 12 | 1, 13 | 14 | coefficient penalty 15 | (pen), 0, 16 | 17 | coefficient dirich_bc 18 | (pen*x*y), 0, 19 | 20 | fespace v -order=4 -type=h1ho 21 | fespace vp -order=3 -dim=3 -type=h1ho 22 | 23 | gridfunction u -fespace=v -nested 24 | gridfunction p -fespace=vp 25 | 26 | linearform f -fespace=v 27 | source x*x*x*x 28 | neumann dirich_bc 29 | 30 | bilinearform a -fespace=v -symmetric -linearform=f -eliminate_internal 31 | laplace lam 32 | mass rho 33 | robin penalty 34 | 35 | 36 | 37 | # preconditioner c -type=direct -bilinearform=a 38 | # preconditioner c -type=local -bilinearform=a 39 | preconditioner c -type=multigrid -bilinearform=a -smoothingsteps=1 -smoother=block -notest -blocktype=9 40 | # preconditioner c -type=amg -bilinearform=a -coefe=lam -notiming -test 41 | 42 | numproc bvp np1 -bilinearform=a -linearform=f -gridfunction=u -preconditioner=c -maxsteps=200 -noprint -prec=1e-8 43 | 44 | numproc calcflux np2 -bilinearform=a -solution=u -flux=p -applyd 45 | 46 | numproc visualization npv1 -scalarfunction=u -subdivision=2 -nolineartexture 47 | -------------------------------------------------------------------------------- /pde_tutorial/d7_coil.pde: -------------------------------------------------------------------------------- 1 | geometry = coil.geo 2 | mesh = coil.vol 3 | 4 | 5 | define constant geometryorder = 4 6 | # define constant heapsize = 50000000 7 | 8 | define constant mu0 = 1.257e-7 9 | 10 | # nu = 1/mu with mu permeability 11 | define coefficient nu 12 | (1/mu0), (1/mu0), 13 | 14 | # artificial conductivity for regularization 15 | define coefficient sigma 1e-8*nu 16 | 17 | # 1000 Ampere-turns 18 | define coefficient r (sqrt(x*x+y*y)) 19 | define coefficient cs 20 | ( 1000/16 * (y/r,-x/r,0)) 21 | (0, 0, 0), 22 | 23 | define fespace v -type=hcurlho -order=4 -nograds -dirichlet=[1] 24 | 25 | define gridfunction u -fespace=v -novisual 26 | 27 | define linearform f -fespace=v 28 | sourceedge cs -definedon=1 29 | 30 | 31 | define bilinearform a -fespace=v -spd -nonsym_storage -linearform=f -eliminate_internal 32 | curlcurledge nu 33 | massedge sigma 34 | 35 | 36 | define bilinearform acurl -fespace=v -symmetric -nonassemble 37 | curlcurledge nu 38 | 39 | 40 | # define preconditioner c -type=multigrid -bilinearform=a -smoother=block 41 | define preconditioner c -type=bddc -bilinearform=a 42 | 43 | 44 | numproc bvp np1 -bilinearform=a -linearform=f -gridfunction=u -preconditioner=c -prec=1.e-9 45 | 46 | numproc drawflux np5 -bilinearform=acurl -solution=u -label=flux 47 | 48 | 49 | 50 | numproc visualization npv1 -scalarfunction=flux:0 -clipsolution=scalar -subdivision=2 -clipvec=[0,1,0] -nolineartexture 51 | -------------------------------------------------------------------------------- /pde_tutorial/d8_coilshield.pde: -------------------------------------------------------------------------------- 1 | geometry = coilshield.geo 2 | mesh = coilshield.vol 3 | 4 | define constant geometryorder = 4 5 | define constant refinep = 1 6 | define constant heapsize = 200000000 7 | 8 | define coefficient nu material 9 | iron 1e-4 10 | default 1 11 | 12 | define coefficient kappa material 13 | default 1e-6 14 | 15 | define coefficient cs1 16 | 0, ( y ), 0, 0, 0, 17 | define coefficient cs2 18 | 0, ( -x ), 0, 0, 0, 19 | define coefficient cs3 20 | 0, 0, 0, 0, 0, 21 | 22 | define coefficient penalty 23 | 0,0,0,0,0,0,0,0, 24 | #1e+6, 0, 0, 0, 0, 0 25 | 26 | 27 | define fespace v -type=hcurlho -order=5 -nograds 28 | 29 | define gridfunction u -fespace=v 30 | 31 | define linearform f -fespace=v -noprintelvec 32 | sourceedge cs1 cs2 cs3 -definedon=2 33 | 34 | 35 | define bilinearform a -fespace=v -symmetric -eliminate_internal -linearform=f 36 | curlcurledge nu 37 | massedge kappa -order=2 38 | robinedge penalty 39 | 40 | define bilinearform acurl -fespace=v -symmetric -nonassemble 41 | curlcurledge nu 42 | 43 | 44 | define preconditioner c -type=multigrid -bilinearform=a -cylce=1 -smoother=block -coarsetype=direct -coarsesmoothingsteps=5 -notest 45 | 46 | 47 | numproc bvp np1 -bilinearform=a -linearform=f -gridfunction=u -preconditioner=c -maxsteps=400 -prec=1.e-8 48 | 49 | numproc drawflux np3 -bilinearform=acurl -solution=u -label=flux 50 | -------------------------------------------------------------------------------- /pde_tutorial/doubleglazing.in2d: -------------------------------------------------------------------------------- 1 | splinecurves2dv2 2 | 2 3 | points 4 | #point number 5 | # x-coordinate 6 | # y-coordinate 7 | # local refinement 8 | 1 -1 1 9 | 2 1 1 -maxh=0.01 10 | 3 1 -1 -maxh=0.01 11 | 4 -1 -1 12 | 13 | segments 14 | #domain left of the segment 15 | # domain right of the segment 16 | # number of points the segment consists of 17 | # first point of the segment 18 | # second point of the segment 19 | # boundary number 20 | # local refinement 21 | 0 1 2 1 2 -maxh=0.25 -bc=1 22 | 0 1 2 2 3 -maxh=0.1 -bc=2 23 | 0 1 2 3 4 -maxh=0.25 -bc=1 24 | 0 1 2 4 1 -maxh=0.25 -bc=1 25 | 26 | materials 27 | 1 inner -maxh=0.5 28 | -------------------------------------------------------------------------------- /pde_tutorial/piezo2d40round4.vol.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NGSolve/ngsolve/cab3abd87bbc83654d6b50d275be06e40cb3f040/pde_tutorial/piezo2d40round4.vol.gz -------------------------------------------------------------------------------- /pde_tutorial/pml/arperture.geo: -------------------------------------------------------------------------------- 1 | algebraic3d 2 | 3 | solid arperture = 4 | plane (0.1,0,0; 1, 0, 0) 5 | and plane (-1.1, 0, 0; -1, 0, 0) 6 | and cylinder (-1.1, 0, 0; 0.1, 0, 0; 0.5); 7 | 8 | solid pin = plane (-3, 0, 0; -1, 0, 0) -bc=1; 9 | solid cyl = cylinder (-3, 0, 0; 1, 0, 0; 2) 10 | and pin 11 | and plane (-1, 0, 0; 1, 0, 0); 12 | 13 | 14 | solid interface = sphere (0, 0, 0; 2) -bc=3; 15 | 16 | solid free = interface and plane (0, 0, 0; -1, 0, 0) -bc = 2; 17 | solid pml = sphere (0, 0, 0; 3) and not interface and plane (0, 0, 0; -1, 0, 0) -bc=2; 18 | 19 | solid vol = cyl or arperture or free -bc=2; 20 | 21 | 22 | tlo vol -maxh=0.4; 23 | tlo pml -col=[0,1,0] -transparent -maxh=0.4; 24 | -------------------------------------------------------------------------------- /pde_tutorial/pml/arperture.vol.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NGSolve/ngsolve/cab3abd87bbc83654d6b50d275be06e40cb3f040/pde_tutorial/pml/arperture.vol.gz -------------------------------------------------------------------------------- /pde_tutorial/pml/cavity.in2d: -------------------------------------------------------------------------------- 1 | splinecurves2dv2 2 | 2 3 | 4 | points 5 | 1 0.15 -0.6 6 | 2 0.15 0 7 | 3 0.8 0 8 | 4 0.8 0.8 9 | 5 0 0.8 10 | 6 -0.8 0.8 11 | 7 -0.8 0 12 | 8 -0.15 0 13 | 9 -0.15 -0.6 14 | 10 1.2 0 15 | 11 1.2 1.2 16 | 12 0 1.2 17 | 13 -1.2 1.2 18 | 14 -1.2 0 19 | 20 | 21 | 22 | segments 23 | 1 0 2 1 2 -bc=1 24 | 1 0 2 2 3 -bc=1 25 | 1 2 3 3 4 5 -bc=2 26 | 1 2 3 5 6 7 -bc=2 27 | 1 0 2 7 8 -bc=1 28 | 1 0 2 8 9 -bc=1 29 | 1 0 2 9 1 -bc=1 30 | 2 0 2 3 10 -bc=1 31 | 2 0 3 10 11 12 -bc=3 32 | 2 0 3 12 13 14 -bc=3 33 | 2 0 2 14 7 -bc=1 34 | 35 | materials 36 | 1 inner -maxh=0.05 37 | 2 pml -maxh=0.05 38 | 39 | 40 | -------------------------------------------------------------------------------- /pde_tutorial/pml/cavity.pde: -------------------------------------------------------------------------------- 1 | geometry = cavity.in2d 2 | mesh = cavity.vol.gz 3 | 4 | define constant one = 1 5 | define constant pml_r = 0.8 6 | # define constant pml_xmin = -0.8 7 | # define constant pml_xmax = 0.8 8 | # define constant pml_ymin = -1 9 | # define constant pml_ymax = 0.8 10 | define constant pml_alpha = 2 11 | 12 | define constant geometryorder = 5 13 | define constant hpref = 4 14 | 15 | define fespace v -type=h1ho -order=5 -complex -dirichlet=[3] 16 | 17 | define gridfunction u -fespace=v -multidim=100 18 | 19 | define bilinearform a -fespace=v -symmetric 20 | laplace one -definedon=[1] 21 | PML_laplace one -definedon=[2] 22 | 23 | define bilinearform m -fespace=v -symmetric 24 | mass one -definedon=[1] 25 | PML_mass one -definedon=[2] 26 | 27 | 28 | numproc evp np2 -bilinearforma=a -bilinearformm=m -gridfunction=u -num=200 -shift=400 -filename=eigen.out 29 | -------------------------------------------------------------------------------- /pde_tutorial/pml/cavity.py: -------------------------------------------------------------------------------- 1 | from ngsolve import * 2 | from netgen.geom2d import SplineGeometry 3 | 4 | geom = SplineGeometry("cavity.in2d") 5 | # mesh = Mesh("cavity.vol.gz") 6 | mesh = Mesh(geom.GenerateMesh (maxh=0.05)) 7 | print ("nv = ", mesh.nv) 8 | mesh.Curve(5) 9 | # define constant hpref = 4 10 | 11 | SetPMLParameters (rad=0.8, alpha=2) 12 | p=pml.Radial((0,0),0.8,2j) 13 | mesh.SetPML(p,'pml') 14 | 15 | fes = H1(mesh, order=4, complex=True, dirichlet=[3]) 16 | u = fes.TrialFunction() 17 | v = fes.TestFunction() 18 | 19 | a = BilinearForm (fes, symmetric=True) 20 | a += BFI("PML_laplace", coef=1) 21 | 22 | m = BilinearForm (fes, symmetric=True) 23 | m += BFI("PML_mass", coef=1) 24 | a.Assemble() 25 | m.Assemble() 26 | 27 | u = GridFunction(fes, multidim=50) 28 | lam = ArnoldiSolver(a.mat, m.mat, fes.FreeDofs(), u.vecs, shift=400) 29 | print ("lam: ", lam) 30 | 31 | Draw (u) 32 | 33 | -------------------------------------------------------------------------------- /pde_tutorial/pml/cavity.vol.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NGSolve/ngsolve/cab3abd87bbc83654d6b50d275be06e40cb3f040/pde_tutorial/pml/cavity.vol.gz -------------------------------------------------------------------------------- /pde_tutorial/pml/pml_maxwell.pde: -------------------------------------------------------------------------------- 1 | geometry = arperture.geo 2 | mesh = arperture.vol.gz 3 | 4 | define constant geometryorder = 3 5 | 6 | define constant pml_r = 2 7 | 8 | define constant one = 1 9 | define constant k = (2*pi) 10 | define constant mkk = (-k*k) 11 | 12 | define fespace v -type=hcurlho -order=2 -complex 13 | 14 | define gridfunction u -fespace=v 15 | 16 | 17 | define coefficient alpha 18 | (-k), (0), 0, 19 | 20 | define coefficient gin 21 | (0,1,0), (0,0,0), (0,0,0), 22 | 23 | define linearform f -fespace=v 24 | neumannedge gin -definedon=1 25 | 26 | 27 | define bilinearform a -fespace=v -symmetric 28 | curlcurledge one -definedon=1 29 | massedge mkk -definedon=1 30 | PML_curlcurledge one -definedon=2 31 | PML_massedge mkk -definedon=2 32 | robinedge alpha -imag 33 | 34 | define preconditioner c -type=direct -bilinearform=a -inverse=pardiso 35 | 36 | numproc bvp np1 -bilinearform=a -linearform=f -gridfunction=u -preconditioner=c 37 | 38 | 39 | -------------------------------------------------------------------------------- /pde_tutorial/pml/scattering.in2d: -------------------------------------------------------------------------------- 1 | splinecurves2dv2 2 | 2 3 | 4 | points 5 | 1 1 0 6 | 2 1 1 7 | 3 0 1 8 | 4 -1 1 9 | 5 -1 0 10 | 6 -1 -1 11 | 7 0 -1 12 | 8 1 -1 13 | 9 1.4 0 14 | 10 1.4 1.4 15 | 11 0 1.4 16 | 12 -1.4 1.4 17 | 13 -1.4 0 18 | 14 -1.4 -1.4 19 | 15 0 -1.4 20 | 16 1.4 -1.4 21 | 22 | 17 0.1 -0.25 23 | 18 0.1 0.25 24 | 19 -0.1 0.25 25 | 20 -0.1 -0.25 26 | 27 | 28 | segments 29 | # interface inner-pml 30 | 1 2 3 1 2 3 -bc=3 31 | 1 2 3 3 4 5 -bc=3 32 | 1 2 3 5 6 7 -bc=3 33 | 1 2 3 7 8 1 -bc=3 34 | 2 0 3 9 10 11 -bc=2 35 | 2 0 3 11 12 13 -bc=2 36 | 2 0 3 13 14 15 -bc=2 37 | 2 0 3 15 16 9 -bc=2 38 | 39 | 0 1 2 17 18 -bc=1 40 | 0 1 2 18 19 -bc=1 41 | 0 1 2 19 20 -bc=1 42 | 0 1 2 20 17 -bc=1 43 | 44 | materials 45 | 1 inner -maxh=0.04 46 | 2 pml -maxh=0.04 47 | 48 | 49 | -------------------------------------------------------------------------------- /pde_tutorial/pml/scattering.pde: -------------------------------------------------------------------------------- 1 | geometry = scattering.in2d 2 | mesh = scattering.vol.gz 3 | 4 | define constant kx = 50 5 | define constant ky = 10 6 | define constant k = (sqrt (kx*kx+ky*ky)) 7 | define coefficient uin (exp (I*kx*x+I*ky*y)) 8 | 9 | 10 | define fespace v -type=h1ho -order=3 -complex -dirichlet=[1] 11 | 12 | define gridfunction uscat -fespace=v -addcoef 13 | numproc setvalues np1 -gridfunction=uscat -coefficient=uin 14 | 15 | 16 | define bilinearform a -fespace=v -symmetric 17 | laplace 1 --definedon=[1] 18 | mass -k*k --definedon=[1] 19 | PML_laplace 1 --definedon=[2] 20 | PML_mass -k*k --definedon=[2] 21 | 22 | define linearform f -fespace=v 23 | 24 | 25 | define preconditioner c -bilinearform=a -type=direct 26 | 27 | numproc bvp np2 -bilinearform=a -linearform=f -gridfunction=uscat -preconditioner=c 28 | 29 | define coefficient utot uscat-uin 30 | 31 | numproc draw npd1 -coefficient=utot -label=utot 32 | numproc draw npd2 -coefficient=uin -label=uin 33 | 34 | 35 | numproc visualization npv1 -scalarfunction=uscat -subdivision=1 -nolineartexture 36 | -------------------------------------------------------------------------------- /pde_tutorial/pml/scattering.py: -------------------------------------------------------------------------------- 1 | from ngsolve.ngstd import * 2 | from ngsolve.comp import * 3 | from ngsolve.fem import * 4 | from ngsolve.utils import * 5 | from ngsolve.solve import * 6 | 7 | from math import sqrt 8 | 9 | 10 | # geometry = scattering.in2d 11 | mesh = Mesh ("scattering.vol.gz") 12 | 13 | #old version 14 | #SetPMLParameters (rad=1, alpha=0.2) 15 | 16 | #new version 17 | p=pml.Radial(origin=(0,0),rad=1,alpha=0.2j) 18 | mesh.SetPML(p,'pml') 19 | 20 | kx = 50 21 | ky = 10 22 | k = sqrt(kx*kx+ky*ky) 23 | 24 | uin = exp (1J*kx*x+1J*ky*y) 25 | 26 | v = FESpace("h1ho", mesh, complex=True, order=3, dirichlet=[1]) 27 | 28 | uscat = GridFunction (v, "uscat") 29 | uscat.Set (uin,BND) 30 | 31 | Draw (uscat) 32 | u = v.TrialFunction() 33 | w = v.TestFunction() 34 | a = BilinearForm (v, symmetric=True) 35 | 36 | #old 37 | #a += BFI("PML_laplace", coef=1) 38 | #a += BFI("PML_mass", coef=-k*k) 39 | 40 | a+=SymbolicBFI(grad(u)*grad(w)) 41 | a+=SymbolicBFI(-k*k*u*w) 42 | 43 | 44 | f = LinearForm (v) 45 | 46 | a.Assemble() 47 | f.Assemble() 48 | 49 | c = Preconditioner(a, type="direct") 50 | c.Update() 51 | 52 | bvp = BVP(bf=a,lf=f,gf=uscat,pre=c) 53 | bvp.Do() 54 | 55 | Draw (uin, mesh, "uin") 56 | Draw (uscat-uin, mesh, "utot") 57 | -------------------------------------------------------------------------------- /pde_tutorial/pml/scattering.vol.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NGSolve/ngsolve/cab3abd87bbc83654d6b50d275be06e40cb3f040/pde_tutorial/pml/scattering.vol.gz -------------------------------------------------------------------------------- /pde_tutorial/square.in2d: -------------------------------------------------------------------------------- 1 | splinecurves2dv2 2 | 5 3 | 4 | points 5 | 1 0 0 6 | 2 1 0 7 | 3 1 1 8 | 4 0 1 9 | 10 | segments 11 | 1 0 2 1 2 -bc=1 12 | 1 0 2 2 3 -bc=1 13 | 1 0 2 3 4 -bc=1 14 | 1 0 2 4 1 -bc=2 15 | 16 | materials 17 | 1 dom1 -maxh=0.2 18 | -------------------------------------------------------------------------------- /pde_tutorial_py/beam.geo: -------------------------------------------------------------------------------- 1 | algebraic3d 2 | 3 | # the first plane gets boundary condition nr 1: 4 | 5 | solid p1 = plane (0, 0, 0; -1, 0, 0) -bc=1; 6 | 7 | # and the other faces b.c. number = 2: 8 | solid beam = plane (0, 0, 0; 0, 0, -1) 9 | and plane (0, 0, 0; 0, -1, 0) 10 | and p1 11 | and plane (10, 2, 1; 0, 0, 1) 12 | and plane (10, 2, 1; 0, 1, 0) 13 | and plane (10, 2, 1; 1, 0, 0) -bc=2 -maxh=2; 14 | 15 | tlo beam; 16 | 17 | 18 | -------------------------------------------------------------------------------- /pde_tutorial_py/chip.in2d: -------------------------------------------------------------------------------- 1 | splinecurves2dv2 2 | 3 3 | 4 | points 5 | 1 0 0 6 | 2 1 0 7 | 3 1 0.6 8 | 4 0 0.6 9 | 5 0.2 0.6 10 | 6 0.8 0.6 11 | 7 0.8 0.8 12 | 8 0.2 0.8 13 | 9 0.5 0.15 14 | 10 0.65 0.3 15 | 11 0.5 0.45 16 | 12 0.35 0.3 17 | 18 | 19 | segments 20 | 21 | 1 0 2 1 2 -bc=1 22 | 1 0 2 2 3 -bc=2 23 | 1 0 2 3 6 -bc=2 24 | 1 2 2 6 5 -bc=2 25 | 1 0 2 5 4 -bc=2 26 | 1 0 2 4 1 -bc=2 27 | 28 | 2 0 2 6 7 -bc=2 29 | 2 0 2 7 8 -bc=2 30 | 2 0 2 8 5 -bc=2 31 | 32 | 3 1 2 9 10 -bc=2 33 | 3 1 2 10 11 -bc=2 34 | 3 1 2 11 12 -bc=2 35 | 3 1 2 12 9 -bc=2 36 | 37 | materials 38 | 1 d1 -maxh=0.2 39 | 2 d2 -maxh=0.2 40 | 3 d3 -maxh=0.05 41 | 42 | -------------------------------------------------------------------------------- /pde_tutorial_py/d1_square.py: -------------------------------------------------------------------------------- 1 | from ngsolve import * 2 | from math import pi 3 | 4 | # 5 | # solve the Poisson equation -Delta u = f 6 | # 7 | # with boundary conditions 8 | # u = 0 on Gamma1 9 | # du/dn = 1 on Gamma2 10 | 11 | from netgen.geom2d import unit_square 12 | 13 | ngsglobals.msg_level = 1 14 | mesh = Mesh (unit_square.GenerateMesh(maxh=0.1)) 15 | 16 | 17 | # define a finite element space 18 | # Dirichlet boundary is Gamma_1,2,3 19 | # play around with -order=... 20 | v = H1(mesh, order=3, dirichlet=[1,2,3]) 21 | 22 | # the solution field 23 | u = GridFunction (space=v) 24 | 25 | f = LinearForm (space=v) 26 | f += Source (x*sin(pi*y)) 27 | # neumann 1 --definedon=[2] # Neumann on Gamma_2 28 | 29 | # the bilinear-form 30 | a = BilinearForm (space=v, symmetric=True) # -eliminate_internal 31 | a += Laplace (1) 32 | 33 | 34 | # c = Preconditioner(bf=a, type="multigrid", { "smoother" : "block" }) 35 | # c = Preconditioner(bf=a, type="bddc") # c -type=bddc -bilinearform=a 36 | c = Preconditioner(bf=a, type="local") 37 | # c = Preconditioner(bf=a, type="direct") 38 | 39 | a.Assemble() 40 | f.Assemble() 41 | 42 | # c.Update() 43 | 44 | BVP (bf=a,lf=f,gf=u,pre=c,maxsteps=200).Do() 45 | 46 | flux = -u.Deriv() 47 | 48 | Draw (u) 49 | Draw (flux, mesh, "Flux") 50 | 51 | -------------------------------------------------------------------------------- /pde_tutorial_py/d5_beam.py: -------------------------------------------------------------------------------- 1 | from ngsolve import * 2 | 3 | mesh = Mesh("beam.vol") 4 | 5 | V = H1(mesh, order=3, dim=3, dirichlet=[1]) 6 | u = GridFunction(V) 7 | 8 | E = 2.1E11 9 | nu = 0.2 10 | a = BilinearForm(V) 11 | a += BFI("elasticity", coef=[E,nu]) 12 | 13 | c = Preconditioner(a,"multigrid") 14 | # c = Preconditioner(a,"direct") 15 | a.Assemble() 16 | 17 | 18 | traction = DomainConstantCF ([0,1e5]) 19 | f = LinearForm(V) 20 | f += BlockLFI (Neumann(traction), dim=3, comp=2) 21 | f.Assemble() 22 | 23 | 24 | # u.vec.data = a.mat.Inverse(V.FreeDofs()) * f.vec 25 | 26 | BVP(bf=a, gf=u, lf=f, pre=c, maxsteps=1000).Do() 27 | 28 | Draw (u) 29 | 30 | 31 | -------------------------------------------------------------------------------- /pictures/logo-col-big.xcf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NGSolve/ngsolve/cab3abd87bbc83654d6b50d275be06e40cb3f040/pictures/logo-col-big.xcf -------------------------------------------------------------------------------- /pictures/logo-col-big2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NGSolve/ngsolve/cab3abd87bbc83654d6b50d275be06e40cb3f040/pictures/logo-col-big2.png -------------------------------------------------------------------------------- /pictures/logo-col-med.xcf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NGSolve/ngsolve/cab3abd87bbc83654d6b50d275be06e40cb3f040/pictures/logo-col-med.xcf -------------------------------------------------------------------------------- /pictures/logo-col-med2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NGSolve/ngsolve/cab3abd87bbc83654d6b50d275be06e40cb3f040/pictures/logo-col-med2.png -------------------------------------------------------------------------------- /pictures/logo-col-small.xcf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NGSolve/ngsolve/cab3abd87bbc83654d6b50d275be06e40cb3f040/pictures/logo-col-small.xcf -------------------------------------------------------------------------------- /pictures/logo-col-small2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NGSolve/ngsolve/cab3abd87bbc83654d6b50d275be06e40cb3f040/pictures/logo-col-small2.png -------------------------------------------------------------------------------- /pictures/logo.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NGSolve/ngsolve/cab3abd87bbc83654d6b50d275be06e40cb3f040/pictures/logo.icns -------------------------------------------------------------------------------- /pictures/shell-picture.xcf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NGSolve/ngsolve/cab3abd87bbc83654d6b50d275be06e40cb3f040/pictures/shell-picture.xcf -------------------------------------------------------------------------------- /pictures/shell-picture2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NGSolve/ngsolve/cab3abd87bbc83654d6b50d275be06e40cb3f040/pictures/shell-picture2.png -------------------------------------------------------------------------------- /py_tutorials/DG/nitsche.py: -------------------------------------------------------------------------------- 1 | from ngsolve import * 2 | from netgen.geom2d import unit_square 3 | 4 | mesh = Mesh(unit_square.GenerateMesh(maxh=0.05)) 5 | 6 | order = 3 7 | 8 | V = H1(mesh, order=order) 9 | u = V.TrialFunction() 10 | v = V.TestFunction() 11 | 12 | n = specialcf.normal(2) 13 | h = specialcf.mesh_size 14 | penalty = 3*order**2 15 | 16 | udir = CoefficientFunction(x*y) 17 | 18 | a = BilinearForm(V, symmetric=True) 19 | a += grad(u)*grad(v)*dx 20 | a += (-n*grad(u)*v - n*grad(v)*u + penalty/h*u*v)*ds(skeleton=True) 21 | a.Assemble() 22 | 23 | f = LinearForm(V) 24 | f += 1 * v * dx 25 | f += ( -n*grad(v)*udir + penalty/h*udir*v)*ds(skeleton=True) 26 | f.Assemble() 27 | 28 | u = GridFunction(V) 29 | u.vec.data = a.mat.Inverse() * f.vec 30 | 31 | Draw (u) 32 | 33 | 34 | -------------------------------------------------------------------------------- /py_tutorials/DG/timeDG-skeleton.py: -------------------------------------------------------------------------------- 1 | from netgen.geom2d import unit_square 2 | from ngsolve import * 3 | 4 | mesh = Mesh (unit_square.GenerateMesh(maxh=0.1)) 5 | 6 | fes = L2(mesh, order=4) 7 | 8 | u = fes.TrialFunction() 9 | v = fes.TestFunction() 10 | 11 | b = CoefficientFunction( (y-0.5,0.5-x) ) 12 | bn = b*specialcf.normal(2) 13 | 14 | ubnd = CoefficientFunction(0) 15 | 16 | a = BilinearForm(fes) 17 | a += (-u * b*grad(v)) .Compile()*dx 18 | 19 | # the skeleton-formulation, sum over edges: 20 | a += bn*IfPos(bn, u, u.Other()) * (v-v.Other()) * dx(skeleton=True) 21 | a += bn*IfPos(bn, u, ubnd) * v * ds(skeleton=True) 22 | 23 | # or the element-boundary formulation 24 | # note the bnd-value in the .Other operator 25 | # a += bn*IfPos(bn, u, u.Other(bnd=ubnd)) * v * dx(element_boundary=True) 26 | 27 | u = GridFunction(fes) 28 | u.Set(exp (-40 * ( (x-0.7)*(x-0.7) + (y-0.7)*(y-0.7) ))) 29 | 30 | w = u.vec.CreateVector() 31 | 32 | Draw (u, autoscale=False, sd=2) 33 | 34 | t = 0 35 | tau = 1e-3 36 | tend = 10 37 | 38 | with TaskManager(): 39 | while t < tend: 40 | a.Apply (u.vec, w) 41 | fes.SolveM (rho=CoefficientFunction(1), vec=w) 42 | u.vec.data -= tau * w 43 | t += tau 44 | Redraw() 45 | 46 | -------------------------------------------------------------------------------- /py_tutorials/DG/timeDG.py: -------------------------------------------------------------------------------- 1 | from netgen.geom2d import unit_square 2 | from ngsolve import * 3 | 4 | mesh = Mesh (unit_square.GenerateMesh(maxh=0.1)) 5 | 6 | fes = L2(mesh, order=4) 7 | 8 | u = fes.TrialFunction() 9 | v = fes.TestFunction() 10 | 11 | b = CoefficientFunction( (y-0.5,0.5-x) ) 12 | bn = b*specialcf.normal(2) 13 | 14 | ubnd = CoefficientFunction(0) 15 | 16 | a = BilinearForm(fes) 17 | a += -u * b*grad(v) * dx 18 | a += bn*IfPos(bn, u, u.Other(bnd=ubnd)) * v * dx(element_boundary=True) 19 | 20 | u = GridFunction(fes) 21 | u.Set(exp (-40 * ( (x-0.7)*(x-0.7) + (y-0.7)*(y-0.7) ))) 22 | 23 | w = u.vec.CreateVector() 24 | 25 | Draw (u, autoscale=False, sd=2) 26 | 27 | t = 0 28 | tau = 1e-3 29 | tend = 10 30 | 31 | with TaskManager(): 32 | while t < tend: 33 | a.Apply (u.vec, w) 34 | fes.SolveM (rho=CoefficientFunction(1), vec=w) 35 | u.vec.data -= tau * w 36 | t += tau 37 | Redraw() 38 | 39 | -------------------------------------------------------------------------------- /py_tutorials/DG/timeDGlap.py: -------------------------------------------------------------------------------- 1 | from netgen.geom2d import unit_square 2 | from ngsolve import * 3 | 4 | mesh = Mesh (unit_square.GenerateMesh(maxh=0.05)) 5 | 6 | order=2 7 | fes = L2(mesh, order=order) 8 | 9 | u = fes.TrialFunction() 10 | v = fes.TestFunction() 11 | 12 | u0 = exp (-40 * ( (x-0.5)*(x-0.5) + (y-0.5)*(y-0.5) )) 13 | 14 | n = specialcf.normal(2) 15 | h = specialcf.mesh_size 16 | 17 | a = BilinearForm(fes) 18 | a += grad(u) * grad(v) * dx 19 | cf1 = -0.5 * InnerProduct(grad(u), n)*(v-v.Other(bnd=0)) 20 | cf2 = -0.5 * InnerProduct(grad(v), n)*(u-u.Other(bnd=u0)) 21 | cf3 = 2*( (order+1)**2)/h * (u-u.Other(bnd=u0)) * v 22 | a += (cf1+cf2+cf3)*dx(element_boundary=True) 23 | 24 | u = GridFunction(fes) 25 | u.Set(u0) 26 | 27 | w = u.vec.CreateVector() 28 | 29 | Draw (u, mesh, "u") 30 | 31 | tau = 2e-6 32 | tend = 0.5 33 | 34 | t = 0 35 | with TaskManager(): 36 | while t < tend: 37 | a.Apply (u.vec, w) 38 | fes.SolveM (rho=CoefficientFunction(1), vec=w) 39 | u.vec.data -= tau * w 40 | t += tau 41 | Redraw() 42 | 43 | -------------------------------------------------------------------------------- /py_tutorials/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NGSolve/ngsolve/cab3abd87bbc83654d6b50d275be06e40cb3f040/py_tutorials/__init__.py -------------------------------------------------------------------------------- /py_tutorials/ale.pde: -------------------------------------------------------------------------------- 1 | mesh = square.vol 2 | # mesh = squaref.vol.gz 3 | 4 | pymodule = ale 5 | 6 | 7 | fespace v -type=h1ho -order=3 -dirichlet=[1,2] 8 | fespace vd -type=h1ho -order=3 -vec 9 | 10 | variable t = 0 11 | 12 | gridfunction u -fespace=v 13 | gridfunction def -fespace=vd -addcoef 14 | gridfunction defp -fespace=vd -addcoef 15 | 16 | bilinearform a -fespace=v -symmetric 17 | laplace 0.1 18 | 19 | bilinearform m -fespace=v -symmetric 20 | mass 1 21 | 22 | bilinearform b -fespace=v 23 | convection defp -transpose 24 | 25 | linearform f -fespace=v 26 | source 1 27 | 28 | 29 | numproc visualization npvis -scalarfunction=u -vectorfunction=def -deformationscale=1 -subdivision=2 -nolineartexture 30 | # -minval=0 -maxval=0.08 31 | 32 | # stationary equation 33 | # pynumproc npALE np1 34 | 35 | # parabolic equation 36 | pynumproc npALE_instat np1 37 | 38 | -------------------------------------------------------------------------------- /py_tutorials/assemble.py: -------------------------------------------------------------------------------- 1 | from ngsolve import * 2 | from netgen.geom2d import unit_square 3 | 4 | ngmesh = unit_square.GenerateMesh(maxh=0.2) 5 | mesh = Mesh(ngmesh) 6 | 7 | fes = H1(mesh, order=2) 8 | u = fes.TrialFunction() 9 | v = fes.TestFunction() 10 | lap = SymbolicBFI(grad(u)*grad(v)) 11 | 12 | for el in fes.Elements(): 13 | print ("el: ", el) 14 | mat = lap.CalcElementMatrix(el.GetFE(), el.GetTrafo()) 15 | print ("Element matrix of element", ElementId(el), ":\n", mat) 16 | print ("dofs: ", el.dofs, "\n") 17 | 18 | 19 | fes2 = L2(mesh, order=1) 20 | for el1,el2 in zip (fes.Elements(), fes2.Elements()): 21 | print ("el1 dofs:", el1.dofs, "el2 dofs ", el2.dofs) 22 | 23 | 24 | -------------------------------------------------------------------------------- /py_tutorials/bla.py: -------------------------------------------------------------------------------- 1 | from ngsolve.bla import * 2 | 3 | # number of rows 4 | n = 10 5 | 6 | # number of columns 7 | m = 7 8 | 9 | x = Vector(m) 10 | A = Matrix(n,m) 11 | 12 | # initialize A and x 13 | for i in range(m): 14 | x[i] = i+1 15 | for j in range(n): 16 | A[j,i] = j*j+i+1 17 | A[j,i] = i*i+j+1 18 | 19 | 20 | # Arithmetic 21 | y = A*x 22 | z = 5*A*x + 7*y - A*(x-y[0:m]) 23 | 24 | 25 | # Get third row as Vector 26 | A[2] 27 | 28 | # Get third row as Matrix 29 | A[2:3] 30 | 31 | # Get rows 4 to 7 32 | A[4:8] 33 | 34 | # Get columns 1,3,5 (0-based) 35 | A[:, 1:6:2] 36 | 37 | # Set every second element in every third column to ten 38 | A[::2,::3] = 10 39 | 40 | # Multiply this elements by 7 41 | A[::2,::3] *= 7 42 | 43 | # Reset elements in last two rows and last three columns 44 | A[-2:,-3:] = 0 45 | 46 | # other stuff 47 | A[3] = x 48 | A[:, 2] = A*x 49 | 50 | # Complex classes 51 | B = Matrix(10,10, complex=True) 52 | C = Matrix(10,10, True) 53 | w = Vector(10,True) 54 | 55 | for i in range(10): 56 | w[i] = complex(i+1, i*i) 57 | for k in range(10): 58 | B[k,i] = complex(k*k+i+1, i+1+k) 59 | 60 | v = B*w 61 | 62 | 63 | # Create numpy matrix from Matrix 64 | from numpy import * 65 | AA = asmatrix(A) 66 | xx = asmatrix(x).T 67 | print( AA*xx - asmatrix(A*x).T ) 68 | -------------------------------------------------------------------------------- /py_tutorials/blocksmoothing.py: -------------------------------------------------------------------------------- 1 | from ngsolve import * 2 | from netgen.geom2d import unit_square 3 | 4 | mesh = Mesh(unit_square.GenerateMesh(maxh=0.2)) 5 | 6 | fes = H1(mesh, order=3) 7 | u,v = fes.TrialFunction(), fes.TestFunction() 8 | 9 | a = BilinearForm(fes) 10 | a += (grad(u)*grad(v)+u*v)*dx 11 | a.Assemble() 12 | 13 | f = LinearForm(fes) 14 | f += v*dx 15 | f.Assemble() 16 | 17 | blocks = [set() for x in range(mesh.nv)] 18 | for el in fes.Elements(): 19 | for v in el.vertices: 20 | blocks[v.nr] |= set(el.dofs) 21 | 22 | # print (blocks) 23 | 24 | smoother = a.mat.CreateBlockSmoother(blocks) 25 | 26 | u = GridFunction(fes) 27 | u.vec[:] = 0 28 | res = f.vec.CreateVector() 29 | 30 | for it in range(100): 31 | res.data = f.vec - a.mat*u.vec 32 | print ("|res| = ", Norm(res)) 33 | smoother.Smooth(u.vec, f.vec, 1) 34 | 35 | 36 | -------------------------------------------------------------------------------- /py_tutorials/cg.py: -------------------------------------------------------------------------------- 1 | from ngsolve.la import InnerProduct 2 | from math import sqrt 3 | 4 | def pcg(mat, pre, rhs, maxits = 100): 5 | """preconditioned conjugate gradient method""" 6 | 7 | u = rhs.CreateVector() 8 | d = rhs.CreateVector() 9 | w = rhs.CreateVector() 10 | s = rhs.CreateVector() 11 | 12 | u[:] = 0.0 13 | d.data = rhs - mat * u 14 | w.data = pre * d 15 | s.data = w 16 | wdn = InnerProduct (w,d) 17 | print ("|u0| = ", wdn) 18 | 19 | for it in range(maxits): 20 | w.data = mat * s 21 | wd = wdn 22 | Ass = InnerProduct (s, w) 23 | alpha = wd / Ass 24 | u.data += alpha * s 25 | d.data += (-alpha) * w 26 | 27 | w.data = pre * d 28 | wdn = InnerProduct (w, d) 29 | beta = wdn / wd 30 | 31 | s *= beta 32 | s.data += w 33 | 34 | err = sqrt(wd) 35 | if err < 1e-16: 36 | break 37 | print ("it = ", it, " err = ", err) 38 | 39 | return u 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /py_tutorials/compound.py: -------------------------------------------------------------------------------- 1 | from ngsolve.fem import * 2 | from ngsolve.comp import * 3 | 4 | 5 | mesh = Mesh("square.vol") 6 | 7 | fes1 = FESpace("h1ho", mesh, order=3) 8 | fes2 = FESpace("l2ho", mesh, order=2) 9 | 10 | fes = FESpace([fes1,fes2]) 11 | 12 | 13 | f = LinearForm (fes) 14 | # f.components[0] += LFI("neumann", coef=1) 15 | # f.components[1] += LFI("source", coef=1) 16 | f1,f2 = f.components 17 | f1 += LFI("neumann", coef=1) 18 | f2 += LFI("source", coef=1) 19 | 20 | f.Assemble() 21 | 22 | print (f.vec) 23 | 24 | 25 | 26 | a = BilinearForm (fes) 27 | a.components[0] += BFI("mass", coef=1) 28 | a.components[1] += BFI("mass", coef=1) 29 | 30 | print ("integrators: ", a.integrators) 31 | a.Assemble() 32 | # print (a.mat) 33 | 34 | 35 | for el in fes.Elements(VOL): 36 | print (el.GetFE().ndof) 37 | print (el.dofs) 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /py_tutorials/cube.vol.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NGSolve/ngsolve/cab3abd87bbc83654d6b50d275be06e40cb3f040/py_tutorials/cube.vol.gz -------------------------------------------------------------------------------- /py_tutorials/d1_square.pde: -------------------------------------------------------------------------------- 1 | # 2 | # solve the Poisson equation -Delta u = f 3 | # 4 | # with boundary conditions 5 | # u = 0 on Gamma1 6 | # du/dn = 1 on Gamma2 7 | 8 | 9 | # load geometry 10 | geometry = square.in2d 11 | 12 | # and mesh 13 | mesh = square.vol 14 | 15 | 16 | # define a finite element space 17 | # Dirichlet boundary is Gamma_1 18 | # play around with -order=... 19 | fespace v -type=h1ho -order=3 -dirichlet=[1] 20 | 21 | # the solution field 22 | gridfunction u -fespace=v -nested 23 | 24 | linearform f -fespace=v 25 | source x*sin(pi*y) 26 | # neumann 1 --definedon=[2] # Neumann on Gamma_2 27 | 28 | # the bilinear-form 29 | bilinearform a -fespace=v -symmetric -eliminate_internal 30 | laplace 1 31 | 32 | 33 | # preconditioner c -type=direct -bilinearform=a 34 | # preconditioner c -type=local -bilinearform=a 35 | # preconditioner c -type=multigrid -bilinearform=a -smoother=block 36 | preconditioner c -type=bddc -bilinearform=a 37 | 38 | 39 | numproc bvp np1 -bilinearform=a -linearform=f -gridfunction=u -preconditioner=c -maxsteps=1000 40 | 41 | numproc drawflux np2 -bilinearform=a -solution=u -label=flux -applyd 42 | 43 | numproc visualization npv1 -scalarfunction=u -subdivision=2 -nolineartexture -------------------------------------------------------------------------------- /py_tutorials/fem1d.py: -------------------------------------------------------------------------------- 1 | from ngsolve import * 2 | from ngsolve.meshes import Make1DMesh 3 | ngsmesh = Make1DMesh(10) 4 | 5 | V = H1(ngsmesh, order=2, dirichlet="left") 6 | print ("freedofs:\n", V.FreeDofs()) 7 | 8 | 9 | a = BilinearForm(V) 10 | a += Laplace(1) 11 | a.Assemble() 12 | 13 | print ("mat = \n", a.mat) 14 | 15 | f = LinearForm(V) 16 | f += Source(1) 17 | # f += Neumann(1) 18 | f.Assemble() 19 | 20 | print ("rhs = \n", f.vec) 21 | 22 | u = GridFunction(V) 23 | u.vec.data = a.mat.Inverse(V.FreeDofs()) * f.vec 24 | 25 | print ("sol =\n", u.vec) 26 | 27 | 28 | print ("u(0.5) =", u(0.5)) 29 | 30 | 31 | 32 | pnts = [] 33 | for i in range(101): pnts.append (i/100) 34 | 35 | pnts_vals = [ (x,u(x)) for x in pnts if ngsmesh.Contains(x)] 36 | # print (pnts_vals) 37 | 38 | 39 | import matplotlib.pyplot as plt 40 | pnts,vals = zip(*pnts_vals) 41 | plt.plot(pnts,vals, "-*") 42 | 43 | plt.ion() 44 | plt.show() 45 | 46 | 47 | -------------------------------------------------------------------------------- /py_tutorials/genmesh.py: -------------------------------------------------------------------------------- 1 | from ngsolve.ngstd import * 2 | from ngsolve.comp import * 3 | from ngsolve.solve import * 4 | from ngsolve.utils import * 5 | 6 | ngsglobals.msg_level = 1 7 | 8 | # a pre-defined csg geometry: 9 | from netgen.csg import unit_cube 10 | 11 | # generate a netgen-mesh 12 | ngmesh = unit_cube.GenerateMesh (maxh=0.2) 13 | 14 | 15 | # convert to ngsolve-mesh 16 | mesh = Mesh(ngmesh) 17 | 18 | v = H1(mesh, order=3) 19 | u = GridFunction(v) 20 | u.Set (x*y*z) 21 | 22 | Draw (u) 23 | print ("Integral(u) = ", Integrate(u, mesh, order=3)) 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /py_tutorials/hdivdiv/hhj.py: -------------------------------------------------------------------------------- 1 | # 2 | # The Hellan-Herrmann-Johnson method for a Kirchhoff plate 3 | # 4 | # M. I. Comodi: The Hellan–Herrmann-Johnson Method 5 | # Some error estimates and postprocessing. Math. Comp. 52, 17–39, 1989 6 | # 7 | 8 | from ngsolve import * 9 | from netgen.geom2d import unit_square 10 | 11 | mesh = Mesh (unit_square.GenerateMesh(maxh=0.05)) 12 | order = 3 13 | 14 | V = HDivDiv(mesh, order=order-1) 15 | Q = H1(mesh, order=order, dirichlet="left|right|top|bottom") 16 | X = V*Q 17 | 18 | print ("ndof-V:", V.ndof, ", ndof-Q:", Q.ndof) 19 | 20 | sigma, u = X.TrialFunction() 21 | tau, v = X.TestFunction() 22 | 23 | n = specialcf.normal(2) 24 | 25 | def tang(u): return u-(u*n)*n 26 | 27 | a = BilinearForm(X, symmetric=True) 28 | a += (InnerProduct (sigma, tau) + div(sigma)*grad(v) + div(tau)*grad(u) - 1e-10*u*v)*dx 29 | a += (-(sigma*n) * tang(grad(v)) - (tau*n)*tang(grad(u)))*dx(element_boundary=True) 30 | a.Assemble() 31 | 32 | f = LinearForm(X) 33 | f += 1 * v * dx 34 | # f += Trace(tau.Trace()) * ds("bottom") 35 | f.Assemble() 36 | 37 | u = GridFunction(X) 38 | u.vec.data = a.mat.Inverse(X.FreeDofs()) * f.vec 39 | 40 | Draw (u.components[0], mesh, name="sigma") 41 | Draw (u.components[1], mesh, name="disp") 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /py_tutorials/hybrid_dg.py: -------------------------------------------------------------------------------- 1 | from netgen.geom2d import unit_square 2 | from ngsolve import * 3 | 4 | 5 | ngsglobals.msg_level = 1 6 | mesh = Mesh(unit_square.GenerateMesh(maxh=0.4)) 7 | for k in range(5): 8 | mesh.Refine() 9 | 10 | 11 | order = 3 12 | fes1 = L2(mesh, order=order) 13 | fes2 = FacetFESpace(mesh, order=order, dirichlet="bottom|right|top") 14 | 15 | print ("element dofs: ", fes1.ndof) 16 | print ("facet dofs: ", fes2.ndof) 17 | 18 | fes = fes1*fes2 19 | 20 | u,uhat = fes.TrialFunction() 21 | v,vhat = fes.TestFunction() 22 | 23 | n = specialcf.normal(mesh.dim) 24 | h = specialcf.mesh_size 25 | 26 | a = BilinearForm(fes, symmetric=True, condense = True) 27 | a += grad(u) * grad(v) * dx 28 | a += (grad(u)*n*(vhat-v)+grad(v)*n*(uhat-u)+10*order*order/h*(u-uhat)*(v-vhat))*dx(element_boundary=True) 29 | 30 | c = Preconditioner(type="direct", bf=a, inverse = "sparsecholesky") 31 | # c = Preconditioner(type="bddc", bf=a) 32 | 33 | with TaskManager(): 34 | a.Assemble() 35 | ainv = CGSolver(a.mat, c.mat) 36 | 37 | f = LinearForm(fes) 38 | f += 1*v*dx 39 | f.Assemble() 40 | 41 | u = GridFunction(fes) 42 | 43 | 44 | f.vec.data += a.harmonic_extension_trans * f.vec 45 | 46 | u.vec.data = ainv * f.vec 47 | 48 | u.vec.data += a.harmonic_extension * u.vec 49 | u.vec.data += a.inner_solve * f.vec 50 | 51 | Draw (u.components[0], mesh, "sol") 52 | 53 | 54 | -------------------------------------------------------------------------------- /py_tutorials/instat.pde: -------------------------------------------------------------------------------- 1 | geometry = square.in2d 2 | mesh = square.vol 3 | 4 | pymodule = instat 5 | 6 | 7 | define fespace v -type=h1ho -order=5 -dirichlet=[1] 8 | 9 | define gridfunction u -fespace=v 10 | 11 | define bilinearform a -fespace=v -symmetric 12 | laplace 1 13 | 14 | define bilinearform m -fespace=v -symmetric 15 | mass 10 16 | 17 | define linearform f -fespace=v 18 | source 1 19 | 20 | 21 | numproc visualization npv1 -scalarfunction=u -subdivision=2 -nolineartexture 22 | 23 | pynumproc npParabolic np1 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /py_tutorials/instat.py: -------------------------------------------------------------------------------- 1 | from ngsolve.comp import PyNumProc 2 | from ngsolve.solve import Redraw 3 | 4 | from math import sin 5 | from time import sleep 6 | 7 | 8 | class npParabolic(PyNumProc): 9 | 10 | def Do(self, heap): 11 | print ("solve parabolic equation") 12 | 13 | tau = 0.1 14 | 15 | pde = self.pde 16 | v = pde.spaces["v"] 17 | u = pde.gridfunctions["u"].vec 18 | f = pde.linearforms["f"].vec 19 | a = pde.bilinearforms["a"].mat 20 | m = pde.bilinearforms["m"].mat 21 | 22 | hmat = a.CreateMatrix() 23 | hmat.AsVector().data = tau * a.AsVector() + m.AsVector() 24 | 25 | inv = hmat.Inverse(v.FreeDofs()) 26 | 27 | d = u.CreateVector() 28 | w = u.CreateVector() 29 | 30 | t = 0.0; 31 | for j in range (0,100000): 32 | t += tau 33 | d.data = sin(t) * f - a * u 34 | w.data = inv * d 35 | u.data += tau * w 36 | 37 | print ("t = ", t) 38 | Redraw(blocking=True) 39 | # sleep (0.001) 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /py_tutorials/integrator.py: -------------------------------------------------------------------------------- 1 | from ngsolve import * 2 | import ngsolve.utils as utils 3 | 4 | pde = PDE("d1_square.pde") 5 | pde.Solve() 6 | mesh = pde.Mesh() 7 | 8 | v = pde.spaces["v"] 9 | 10 | lap = BFI (name="laplace", coef=utils.x*utils.y) 11 | src = LFI (name="source", coef=4.8) 12 | 13 | i = ElementId(VOL,1) 14 | el = v.GetFE(i) 15 | trafo = mesh.GetTrafo(i) 16 | 17 | mat = lap.CalcElementMatrix (el, trafo) 18 | print ("laplace matrix:\n", mat) 19 | 20 | rhs = src.CalcElementVector (el, trafo) 21 | print ("source vector:\n", rhs) 22 | 23 | 24 | -------------------------------------------------------------------------------- /py_tutorials/linalg.py: -------------------------------------------------------------------------------- 1 | # load a pde, and exec in the py-console 2 | 3 | 4 | pde.Solve() 5 | 6 | vecu = pde.gridfunctions["u"].vec 7 | vecf = pde.linearforms["f"].vec 8 | mata = pde.bilinearforms["a"].mat 9 | 10 | v = pde.spaces["v"] 11 | 12 | vecu.size 13 | mata.height 14 | mata.width 15 | 16 | vecv = vecu.CreateVector() 17 | vecw = vecu.CreateVector() 18 | 19 | # atn: don't use eliminate_internal 20 | inva = mata.Inverse(v.FreeDofs()) 21 | 22 | vecv.data = inva * vecf 23 | vecw.data = vecu - vecv 24 | 25 | print ("diff^2 : ", la.InnerProduct (vecw, vecw)) 26 | 27 | -------------------------------------------------------------------------------- /py_tutorials/main_instat.py: -------------------------------------------------------------------------------- 1 | from ngsolve.fem import * 2 | from ngsolve.comp import * 3 | from ngsolve.la import * 4 | from ngsolve.solve import * 5 | from ngsolve.utils import * 6 | 7 | from math import sin 8 | from time import sleep 9 | 10 | 11 | mesh = Mesh("square.vol.gz") 12 | 13 | v = H1(mesh, order=5) # , dirichlet=[1,2]) 14 | u = GridFunction (v, name="potential") 15 | 16 | u.Set (exp(-40*((x-0.5)*(x-0.5)+(y-0.5)*(y-0.5)))) 17 | Draw (u, sd=1) 18 | 19 | 20 | f = LinearForm (v) 21 | f += Source (coef=1) 22 | f.Assemble() 23 | 24 | a = BilinearForm (v, symmetric=True) 25 | a += Laplace (coef=0.01) 26 | a.Assemble() 27 | 28 | m = BilinearForm (v, symmetric=True) 29 | m += Mass (coef=1) 30 | m.Assemble() 31 | 32 | 33 | tau = 0.01 34 | 35 | mstar = a.mat.CreateMatrix() 36 | mstar.AsVector().data = tau * a.mat.AsVector() + m.mat.AsVector() 37 | inv = mstar.Inverse(v.FreeDofs()) 38 | 39 | d = u.vec.CreateVector() 40 | w = u.vec.CreateVector() 41 | 42 | Redraw(blocking=True) 43 | 44 | # print ("Switch visualization to 'Solution', and set 'ScalarFunction' to 'gfu'") 45 | input("I'm waiting for you ... ") 46 | 47 | t = 0.0; 48 | while (t <= 1): 49 | t += tau 50 | d.data = sin(t) * f.vec - a.mat * u.vec 51 | w.data = inv * d 52 | u.vec.data += tau * w 53 | 54 | print ("t = ", t) 55 | Redraw(blocking=True) 56 | sleep (0.01) 57 | 58 | 59 | -------------------------------------------------------------------------------- /py_tutorials/mesh.py: -------------------------------------------------------------------------------- 1 | # import sys 2 | # import os 3 | # from os import environ 4 | # sys.path.append(environ['NETGENDIR']+"/../lib") 5 | 6 | # from libngspy import * 7 | from ngsolve import * 8 | 9 | 10 | # pde = solve.PDE("../pde_tutorial/d1_square.pde") 11 | # mesh = pde.Mesh() 12 | 13 | # mesh = comp.Mesh("square.vol") 14 | # mesh = comp.Mesh("../pde_tutorial/cube.vol") 15 | 16 | from tkinter import filedialog 17 | filename = filedialog.askopenfilename(filetypes=[("vol-files","*.vol *.vol.gz")]) 18 | mesh = Mesh(filename) 19 | 20 | 21 | for i in mesh.Elements(VOL): 22 | print (i) 23 | print (mesh[i]) 24 | print (mesh[i].vertices) 25 | 26 | 27 | -------------------------------------------------------------------------------- /py_tutorials/mixed.py: -------------------------------------------------------------------------------- 1 | from netgen.geom2d import unit_square 2 | from ngsolve import * 3 | 4 | ngsglobals.msg_level = 1 5 | 6 | mesh = Mesh(unit_square.GenerateMesh(maxh=0.1)) 7 | 8 | order = 2 9 | fes1 = HDiv(mesh, order=order) 10 | fes2 = L2(mesh, order=order-1) 11 | 12 | fes = fes1*fes2 13 | 14 | sigma,u = fes.TrialFunction() 15 | tau,v = fes.TestFunction() 16 | 17 | a = BilinearForm(fes) 18 | a += (sigma*tau + div(sigma)*v + div(tau)*u - 1e-10*u*v)*dx 19 | # (regularization needed for direct solver) 20 | a.Assemble() 21 | 22 | f = LinearForm(fes) 23 | f += -v*dx 24 | f.Assemble() 25 | 26 | u = GridFunction(fes) 27 | u.vec.data = a.mat.Inverse(fes.FreeDofs()) * f.vec 28 | 29 | Draw (u.components[0], mesh, "flux") 30 | Draw (u.components[1], mesh, "sol") 31 | -------------------------------------------------------------------------------- /py_tutorials/module1.py: -------------------------------------------------------------------------------- 1 | print ("**** this is my first ngsolve-py module *****") 2 | 3 | from ngsolve.comp import PyNumProc 4 | from cg import * 5 | from ngsolve.solve import Redraw 6 | 7 | 8 | class pyNP1(PyNumProc): 9 | 10 | def __init__(self, pde, flags): 11 | print ('********* pyNP1 constructor ********') 12 | super(pyNP1,self).__init__(pde,flags) 13 | 14 | def Do(self, heap): 15 | print('******** pyNP1::Do ********************') 16 | print (self.pde.gridfunctions["u"]) 17 | u = self.pde.gridfunctions["u"] 18 | print ("ndof = ", u.space.ndof) 19 | print('*************************************') 20 | 21 | 22 | 23 | 24 | class pybvp(PyNumProc): 25 | 26 | def Do(self, heap): 27 | print('******** pybvp::Do ********************') 28 | 29 | A = self.pde.bilinearforms["a"] 30 | C = self.pde.preconditioners["c"] 31 | f = self.pde.linearforms["f"] 32 | u = self.pde.gridfunctions["u"] 33 | 34 | u.vec.data = pcg (mat = A.mat, pre = C.mat, rhs = f.vec, maxits = 50) 35 | Redraw() 36 | 37 | 38 | 39 | 40 | 41 | print ("*********** module done ****************") 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /py_tutorials/mpi/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | install(FILES 2 | mpi_poisson.py mpi_cmagnet.py mpi_navierstokes.py 3 | mpi_timeDG.py ../__init__.py 4 | DESTINATION ${NGSOLVE_INSTALL_DIR_PYTHON}/ngsolve/demos/mpi 5 | COMPONENT ngsolve_devel 6 | ) 7 | 8 | if(NETGEN_USE_MPI) 9 | include(CTest) 10 | foreach(py_test mpi_poisson.py mpi_cmagnet.py mpi_timeDG.py mpi_navierstokes.py) 11 | add_test(NAME ${py_test} COMMAND mpirun -np 5 --allow-run-as-root ngspy ${py_test} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) 12 | set_tests_properties ( ${py_test} PROPERTIES TIMEOUT ${NGS_TEST_TIMEOUT} ) 13 | endforeach() 14 | endif() 15 | -------------------------------------------------------------------------------- /py_tutorials/nonlin.py: -------------------------------------------------------------------------------- 1 | from netgen.geom2d import unit_square 2 | from ngsolve import * 3 | 4 | m = Mesh (unit_square.GenerateMesh(maxh=0.3)) 5 | 6 | V = H1(m, order=3, dirichlet="left|right|top|bottom") 7 | u = V.TrialFunction() 8 | v = V.TestFunction() 9 | 10 | a = BilinearForm(V) 11 | a += ( grad(u) * grad(v) + 5*u*u*v- 1 * v)*dx 12 | 13 | u = GridFunction(V) 14 | r = u.vec.CreateVector() 15 | w = u.vec.CreateVector() 16 | 17 | for it in range(5): 18 | print ("Iteration",it) 19 | a.Apply(u.vec, r) 20 | a.AssembleLinearization(u.vec) 21 | 22 | w.data = a.mat.Inverse(V.FreeDofs()) * r.data 23 | print ("|w| =", w.Norm()) 24 | u.vec.data -= w 25 | 26 | Draw(u) 27 | input("") 28 | 29 | 30 | -------------------------------------------------------------------------------- /py_tutorials/pickling.py: -------------------------------------------------------------------------------- 1 | from ngsolve import * 2 | import netgen.geom2d 3 | 4 | mesh = Mesh (netgen.geom2d.unit_square.GenerateMesh(maxh=0.1)) 5 | 6 | v = FESpace ("h1ho", mesh, order=4, dirichlet=[1]) 7 | v2 = L2(mesh,order=2) 8 | u = GridFunction (v) 9 | u2 = GridFunction(v) 10 | vec = u.vec 11 | data = [v,v2,u,u2,u.vec] 12 | 13 | import pickle 14 | pickler = pickle.Pickler(open ("1.dat", "wb")) 15 | pickler.dump (data) 16 | del pickler 17 | 18 | unpickler = pickle.Unpickler(open("1.dat","rb")) 19 | fes,fes2,w,w2,z = unpickler.load() 20 | 21 | assert fes.mesh is fes2.mesh 22 | assert w.space is w2.space 23 | 24 | assert len(z) == len(u.vec) 25 | for i in range(len(u.vec)): 26 | assert u.vec[i] == z[i] 27 | -------------------------------------------------------------------------------- /py_tutorials/pml.py: -------------------------------------------------------------------------------- 1 | from netgen.geom2d import SplineGeometry 2 | from ngsolve import * 3 | 4 | geo = SplineGeometry() 5 | geo.AddCircle( (0,0), 1.4, leftdomain=2) 6 | geo.AddCircle( (0,0), 1, leftdomain=1, rightdomain=2) 7 | geo.SetMaterial(1, "inner") 8 | geo.SetMaterial(2, "pml") 9 | mesh = Mesh(geo.GenerateMesh (maxh=0.1)) 10 | 11 | mesh.SetPML(pml.Radial(rad=1,alpha=1j,origin=(0,0)), "pml") 12 | 13 | fes = H1(mesh, order=4, complex=True) 14 | u = fes.TrialFunction() 15 | v = fes.TestFunction() 16 | 17 | omega = 10 18 | 19 | a = BilinearForm(fes) 20 | a += (grad(u)*grad(v)-omega*omega*u*v)*dx 21 | 22 | f = LinearForm(fes) 23 | f += exp(-20**2*((x-0.3)*(x-0.3)+y*y))*v*dx 24 | 25 | a.Assemble() 26 | f.Assemble() 27 | 28 | gfu = GridFunction(fes) 29 | gfu.vec.data = a.mat.Inverse() * f.vec 30 | 31 | Draw(gfu) 32 | -------------------------------------------------------------------------------- /py_tutorials/pmltest3d.py: -------------------------------------------------------------------------------- 1 | from ngsolve import * 2 | from netgen.csg import unit_cube 3 | 4 | 5 | mesh=Mesh(unit_cube.GenerateMesh(maxh=0.1)) 6 | pml_brick=pml.BrickRadial((0.2,0.2,0.2),(0.4,0.4,0.4),(0.3,0.3,0.3),1j) 7 | pml_halfspace=pml.HalfSpace((0.2,0.2,0.2),(2,1,1),1j) 8 | pml_halfspace2=pml.HalfSpace((0.7,0.7,0.7),(-2,1,1),1j) 9 | pml_cartesian=pml.Cartesian((0.2,0.2,0.2),(0.5,0.5,0.5),1j) 10 | pml_radial=pml.Radial(rad=0.3,alpha=1j,origin=(0.3,0.3,0.3)) 11 | pml_cylinder=pml.Compound(pml.Radial(origin=(0.3,0.3),rad=0.2),pml.Cartesian(0.1,0.9)) 12 | 13 | 14 | cf_brick=pml_brick.PML_CF 15 | cf_halfspace=pml_halfspace.PML_CF 16 | cf_cartesian=pml_cartesian.PML_CF 17 | cf_radial=pml_radial.PML_CF 18 | cf_cylinder=pml_cylinder.PML_CF 19 | cf_sum=(pml_halfspace+pml_halfspace2).PML_CF 20 | 21 | Draw(cf_brick-Conj(cf_brick),mesh,"brick") 22 | Draw(cf_halfspace-Conj(cf_halfspace),mesh,"halfspace") 23 | Draw(cf_cartesian-Conj(cf_cartesian),mesh,"cartesian") 24 | Draw(cf_radial-Conj(cf_radial),mesh,"radial") 25 | Draw(cf_cylinder-Conj(cf_cylinder),mesh,"cylinder") 26 | Draw(cf_sum-Conj(cf_sum),mesh,"sum") 27 | -------------------------------------------------------------------------------- /py_tutorials/poisson.py: -------------------------------------------------------------------------------- 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))) 42 | -------------------------------------------------------------------------------- /py_tutorials/scattering.py: -------------------------------------------------------------------------------- 1 | from ngsolve import * 2 | from netgen.geom2d import SplineGeometry 3 | 4 | geo = SplineGeometry() 5 | geo.AddRectangle( (-0.1, -0.25), (0.1, 0.25), leftdomain=0, rightdomain=1, bc = "scatterer") 6 | geo.AddCircle ( (0, 0), r=1, leftdomain=1, rightdomain=2) 7 | geo.AddCircle ( (0, 0), r=1.4, leftdomain=2, rightdomain=0) 8 | 9 | ngmesh = geo.GenerateMesh(maxh=0.04) 10 | # ngmesh.Save("scattering.vol") 11 | mesh = Mesh(ngmesh) 12 | # mesh = Mesh ("scattering.vol") 13 | 14 | mesh.SetPML(pml.Radial(origin=(0,0), rad=1, alpha=0.1j), definedon=2) 15 | 16 | kx = 50 17 | ky = 20 18 | k = sqrt(kx*kx+ky*ky) 19 | 20 | uin = exp (1J*kx*x+1J*ky*y) 21 | 22 | fes = H1(mesh, complex=True, order=5, dirichlet="scatterer") 23 | u = fes.TrialFunction() 24 | v = fes.TestFunction() 25 | 26 | uscat = GridFunction (fes) 27 | uscat.Set (uin, definedon=mesh.Boundaries("scatterer")) 28 | 29 | a = BilinearForm (fes, symmetric=True) 30 | a += grad(u)*grad(v)*dx 31 | a += -k*k*u*v*dx 32 | 33 | f = LinearForm (fes) 34 | 35 | a.Assemble() 36 | f.Assemble() 37 | 38 | res = uscat.vec.CreateVector() 39 | res.data = f.vec - a.mat * uscat.vec 40 | uscat.vec.data += a.mat.Inverse(freedofs=fes.FreeDofs(), inverse="sparsecholesky") * res 41 | 42 | 43 | Draw (uin, mesh, "uin") 44 | Draw (uscat, mesh, "uscat") 45 | Draw (uin-uscat, mesh, "utot") 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /py_tutorials/setorder.py: -------------------------------------------------------------------------------- 1 | from netgen.geom2d import unit_square 2 | from ngsolve import * 3 | 4 | mesh = Mesh (unit_square.GenerateMesh(maxh=0.3)) 5 | 6 | fes = H1(mesh, order=1) 7 | 8 | # defines an order policy 9 | fes.order[EDGE] = 1 # anyway 10 | fes.order[TRIG] = 3 11 | fes.order[QUAD] = 2 12 | 13 | 14 | # sets the order for particular nodes (not yet functional) 15 | for el in fes.Elements(VOL): 16 | if 0 in el.vertices: 17 | for e in el.edges: 18 | fes.order[EDGE,e] = 2 19 | # fes.UpdateDofTable() # missing 20 | 21 | for el in fes.Elements(VOL): 22 | print (el.dofs) 23 | 24 | -------------------------------------------------------------------------------- /py_tutorials/square.in2d: -------------------------------------------------------------------------------- 1 | splinecurves2dv2 2 | 5 3 | 4 | points 5 | 1 0 0 6 | 2 1 0 7 | 3 1 1 8 | 4 0 1 9 | 10 | segments 11 | 1 0 2 1 2 -bc=1 12 | 1 0 2 2 3 -bc=1 13 | 1 0 2 3 4 -bc=1 14 | 1 0 2 4 1 -bc=2 15 | 16 | materials 17 | 1 dom1 -maxh=0.2 18 | -------------------------------------------------------------------------------- /py_tutorials/square.vol.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NGSolve/ngsolve/cab3abd87bbc83654d6b50d275be06e40cb3f040/py_tutorials/square.vol.gz -------------------------------------------------------------------------------- /py_tutorials/symbolic.py: -------------------------------------------------------------------------------- 1 | from ngsolve import * 2 | from netgen.csg import unit_cube 3 | 4 | ngsglobals.msg_level = 1 5 | mesh = Mesh (unit_cube.GenerateMesh(maxh=0.2)) 6 | 7 | import timeit 8 | 9 | 10 | V = H1(mesh, order=3) 11 | 12 | u = V.TrialFunction() 13 | v = V.TestFunction() 14 | 15 | gradu = Grad(u) 16 | gradv = Grad(v) 17 | dvdx = gradv[0] 18 | dvdy = gradv[1] 19 | dvdz = gradv[2] 20 | 21 | a = BilinearForm (V, symmetric=True) 22 | a += (u*v+gradu*gradv)*dx 23 | a.Assemble() 24 | 25 | 26 | f = LinearForm (V) 27 | f += x*v*dx 28 | f.Assemble() 29 | 30 | print (a.mat) 31 | print (f.vec) 32 | -------------------------------------------------------------------------------- /py_tutorials/symbolic_energy.py: -------------------------------------------------------------------------------- 1 | from ngsolve import * 2 | from netgen.geom2d import unit_square 3 | 4 | mesh = Mesh (unit_square.GenerateMesh(maxh=0.2)) 5 | 6 | 7 | V = H1(mesh, order=4, dirichlet="left|right|top|bottom") 8 | 9 | u = V.TrialFunction() 10 | 11 | a = BilinearForm (V, symmetric=False) 12 | a += Variation( (0.05*grad(u)*grad(u) + u*u*u*u - 100*u)*dx ) 13 | 14 | u = GridFunction (V) 15 | u.vec[:] = 0 16 | 17 | res = u.vec.CreateVector() 18 | w = u.vec.CreateVector() 19 | 20 | Draw(u,sd=4) 21 | 22 | for it in range(20): 23 | print ("Newton iteration", it) 24 | print ("energy = ", a.Energy(u.vec)) 25 | 26 | a.Apply (u.vec, res) 27 | a.AssembleLinearization (u.vec) 28 | inv = a.mat.Inverse(V.FreeDofs()) 29 | w.data = inv * res 30 | print ("w*r =", InnerProduct(w,res)) 31 | 32 | u.vec.data -= w 33 | Redraw() 34 | 35 | 36 | -------------------------------------------------------------------------------- /py_tutorials/taskmanager.py: -------------------------------------------------------------------------------- 1 | from netgen.csg import unit_cube 2 | from ngsolve import * 3 | 4 | mesh = Mesh (unit_cube.GenerateMesh(maxh=0.4)) 5 | for l in range(3): 6 | mesh.Refine() 7 | 8 | fes = H1(mesh, order=3) 9 | u,v = fes.TnT() 10 | a = BilinearForm(fes) 11 | a += grad(u) * grad(v) * dx 12 | 13 | 14 | print('sequential assembly...') 15 | a.Assemble() 16 | 17 | print('parallel assembly...') 18 | with TaskManager(): 19 | a.Assemble() 20 | 21 | -------------------------------------------------------------------------------- /py_tutorials/timing.py: -------------------------------------------------------------------------------- 1 | 2 | from netgen.csg import unit_cube 3 | from ngsolve import * 4 | import os 5 | 6 | # Timings can be used to test if performance critical code gets slower when changed. 7 | # The timed class has to export a function __timing__ to python with a list of tuples 8 | # for the timings. 9 | 10 | mesh = Mesh(unit_cube.GenerateMesh(maxh=0.2)) 11 | 12 | fes = H1(mesh,order=3) 13 | 14 | timing = Timing(name="h1",obj=fes,parallel=True,serial=True) 15 | 16 | # first time this file is run create the benchmark 17 | if not os.path.exists("benchmark"): 18 | timing.SaveBenchmark() 19 | print("Benchmark created, run file again to compare to benchmark") 20 | else: 21 | # if benchmark exists compare it to benchmark and print results 22 | results = timing.CompareToBenchmark() 23 | print("Results:") 24 | for key,value in results: 25 | print(key,": ", value) 26 | -------------------------------------------------------------------------------- /py_tutorials/vtkout.py: -------------------------------------------------------------------------------- 1 | from ngsolve.comp import * 2 | from ngsolve.solve import * 3 | from ngsolve.utils import * 4 | from math import pi 5 | 6 | from netgen.geom2d import unit_square 7 | from netgen.meshing import MeshingParameters 8 | 9 | ngsglobals.msg_level = 4 10 | 11 | mesh = Mesh (unit_square.GenerateMesh(maxh=0.3)) 12 | 13 | v = FESpace(type="hdivho",mesh=mesh, order=1, dirichlet=[1,2,3]) 14 | 15 | u = GridFunction (space=v) 16 | 17 | vtk = VTKOutput(mesh,coefs=[u],names=["sol"],filename="vtkout",subdivision=3, 18 | floatsize="single",legacy=False) 19 | for i in range(13,26): 20 | u.vec[:]=0.0 21 | u.vec[i]=1.0 22 | outputfilename = vtk.Do(time=i/100) 23 | 24 | vtk2 = VTKOutput(mesh,coefs=[u],names=["sol"],filename="another_vtkout",subdivision=3, 25 | floatsize="double",legacy=False) 26 | vtk2.Do() 27 | 28 | Draw (u) 29 | -------------------------------------------------------------------------------- /python/_scikit_build_core_dependencies.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | 4 | def dynamic_metadata(field, settings): 5 | 6 | if field != "dependencies": 7 | msg = "Only the 'dependencies' field is supported" 8 | raise ValueError(msg) 9 | 10 | if settings: 11 | msg = "No inline configuration is supported" 12 | raise ValueError(msg) 13 | 14 | if sys.version_info >= (3, 11): 15 | import tomllib 16 | else: 17 | import tomli as tomllib 18 | 19 | import importlib.metadata 20 | 21 | config = tomllib.load(open("pyproject.toml", "rb")) 22 | dependencies = config["project"].get("dependencies", []) 23 | 24 | ngs_version = importlib.metadata.version("ngsolve") 25 | dependencies = dependencies + [f"ngsolve=={ngs_version}"] 26 | return dependencies 27 | 28 | 29 | def get_requires_for_dynamic_metadata(_settings): 30 | return [] 31 | -------------------------------------------------------------------------------- /python/config/__init__.py: -------------------------------------------------------------------------------- 1 | from .config import * 2 | -------------------------------------------------------------------------------- /python/config/__main__.py: -------------------------------------------------------------------------------- 1 | from .config import get_cmake_dir 2 | 3 | if __name__ == '__main__': 4 | print(get_cmake_dir()) 5 | -------------------------------------------------------------------------------- /python/directsolvers.py: -------------------------------------------------------------------------------- 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()) 27 | -------------------------------------------------------------------------------- /python/preconditioners.py: -------------------------------------------------------------------------------- 1 | from ngsolve.comp import MultiGridPreconditioner as MultiGrid 2 | from ngsolve.comp import LocalPreconditioner as Local 3 | from ngsolve.comp import HCurlAMG 4 | from ngsolve.comp import BDDCPreconditioner as BDDC 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /python/solvers.py: -------------------------------------------------------------------------------- 1 | from ngsolve.eigenvalues import PINVIT, LOBPCG 2 | from ngsolve.krylovspace import CG, QMR, MinRes, PreconditionedRichardson, GMRes 3 | from ngsolve.krylovspace import CGSolver 4 | from ngsolve.nonlinearsolvers import Newton, NewtonMinimization 5 | from ngsolve.bvp import BVP 6 | from ngsolve.directsolvers import SuperLU 7 | 8 | -------------------------------------------------------------------------------- /tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Tests currently only working on Linux 2 | if(NETGEN_USE_PYTHON OR NOT WIN32) 3 | 4 | include(CTest) 5 | 6 | if(USE_UMFPACK) 7 | add_test(NAME umfpack.py COMMAND ${NETGEN_PYTHON_EXECUTABLE} umfpack.py WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) 8 | set_tests_properties ( ${py_test} PROPERTIES TIMEOUT ${NGS_TEST_TIMEOUT} ) 9 | endif(USE_UMFPACK) 10 | 11 | endif(NETGEN_USE_PYTHON OR NOT WIN32) 12 | add_subdirectory(pytest) 13 | add_subdirectory(catch) 14 | add_subdirectory(timings) 15 | -------------------------------------------------------------------------------- /tests/acc_tests/circle.in2d: -------------------------------------------------------------------------------- 1 | # keyword for 2D geometry, version 2 2 | splinecurves2dv2 3 | 4 | 5 | # a global grading factor 6 | 2 7 | 8 | 9 | # the points (point number, x and y coordinates) 10 | points 11 | 1 1 0 12 | 2 1 1 13 | 3 0 1 14 | 4 -1 1 15 | 5 -1 0 16 | 6 -1 -1 17 | 7 0 -1 18 | 8 1 -1 19 | 20 | 21 | # boundary curves consisting of 22 | # dl dr np p1 p1 flaglist 23 | # with 24 | # dl ... sub-domain nr on left side 25 | # dr ... sub-domain nr on right side 26 | # np ... curve is given by 2 (or 3) points 27 | # p1, p2 ... points defining the curve 28 | 29 | # flagslist 30 | segments 31 | 1 0 3 1 2 3 -bc=1 32 | 1 0 3 3 4 5 -bc=1 33 | 1 0 3 5 6 7 -bc=1 34 | 1 0 3 7 8 1 -bc=1 35 | 36 | materials 37 | 1 domain1 -maxh=0.5 38 | 39 | 40 | -------------------------------------------------------------------------------- /tests/acc_tests/circle.vol.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NGSolve/ngsolve/cab3abd87bbc83654d6b50d275be06e40cb3f040/tests/acc_tests/circle.vol.gz -------------------------------------------------------------------------------- /tests/build_debug.sh: -------------------------------------------------------------------------------- 1 | set -e 2 | cd 3 | cd src/ngsolve 4 | git submodule update --init --recursive 5 | cd 6 | mkdir -p build/ngsolve 7 | cd build/ngsolve 8 | cmake \ 9 | ../../src/ngsolve \ 10 | -DCMAKE_CXX_COMPILER=g++-7 \ 11 | -DCMAKE_C_COMPILER=gcc-7 \ 12 | -DCMAKE_CXX_FLAGS="-Og -Wall -Wno-sign-compare -DDebug" \ 13 | -DUSE_NATIVE_ARCH=OFF \ 14 | -DUSE_OCC=ON \ 15 | -DUSE_CCACHE=ON \ 16 | -DUSE_MKL=ON \ 17 | -DUSE_UMFPACK=ON \ 18 | -DINSTALL_PROFILES=ON \ 19 | -DMKL_STATIC=ON \ 20 | -DENABLE_UNIT_TESTS=ON \ 21 | -DCMAKE_BUILD_TYPE=Debug \ 22 | -DCPACK_PACKAGING_INSTALL_PREFIX=/opt/netgen \ 23 | $CMAKE_ARGS 24 | make -j12 25 | make install 26 | -------------------------------------------------------------------------------- /tests/build_pip.ps1: -------------------------------------------------------------------------------- 1 | $ErrorActionPreference = "Stop" 2 | 3 | if (test-path _skbuild) { 4 | cmd.exe /c rd /s /q _skbuild 5 | } 6 | if (test-path dist) { 7 | cmd.exe /c rd /s /q dist 8 | } 9 | if (test-path ..\venv_ngs) { 10 | cmd.exe /c rd /s /q ..\venv_ngs 11 | } 12 | 13 | 14 | $env:NETGEN_CCACHE = 1 15 | $py=$args[0] 16 | 17 | cd external_dependencies\netgen 18 | git remote update 19 | .\tests\build_pip.ps1 $args[0] 20 | & $py\python.exe tests\utils.py --wait-pip 21 | cd ..\.. 22 | 23 | $netgen_version=(& $py\python.exe external_dependencies\netgen\tests\utils.py --get-version --dir=.\external_dependencies\netgen) 24 | 25 | & $py\python.exe external_dependencies\netgen\tests\utils.py --check-pip --package ngsolve 26 | if ($LASTEXITCODE -ne 0) { 27 | exit 0 28 | } 29 | 30 | & $py\python.exe -m venv --clear ..\venv_ngs 31 | ..\venv_ngs\scripts\Activate.ps1 32 | $env:PATH += ";$env:CI_PROJECT_DIR\venv_ngs\bin" 33 | python --version 34 | 35 | pip3 install scikit-build wheel numpy twine mkl-devel==2022.* mkl==2022.* 36 | pip3 install netgen-mesher==$netgen_version 37 | python setup.py bdist_wheel -G"Visual Studio 17 2022" 38 | python -m twine upload dist\*.whl 39 | -------------------------------------------------------------------------------- /tests/build_pip_mac.sh: -------------------------------------------------------------------------------- 1 | set -e 2 | rm -rf _skbuild dist ../venv_ngs 3 | 4 | export PYDIR=/Library/Frameworks/Python.framework/Versions/$1/bin 5 | 6 | cd external_dependencies/netgen 7 | git remote update 8 | bash tests/build_pip_mac.sh $1 9 | $PYDIR/python3 tests/utils.py --wait-pip 10 | cd ../.. 11 | 12 | export PATH=/Applications/CMake.app/Contents/bin:$PATH 13 | export NETGEN_CCACHE=1 14 | 15 | export NETGEN_VERSION=`$PYDIR/python3 external_dependencies/netgen/tests/utils.py --get-version --dir=./external_dependencies/netgen` 16 | echo "Netgen version: $NETGEN_VERSION" 17 | 18 | $PYDIR/python3 --version 19 | $PYDIR/python3 external_dependencies/netgen/tests/utils.py --check-pip --package ngsolve || exit 0 20 | $PYDIR/python3 -m venv ../venv_ngs 21 | 22 | source ../venv_ngs/bin/activate 23 | $PYDIR/pip3 install numpy twine scikit-build wheel 24 | 25 | export CMAKE_OSX_ARCHITECTURES='arm64;x86_64' 26 | $PYDIR/pip3 install netgen-mesher==$NETGEN_VERSION 27 | $PYDIR/python3 setup.py bdist_wheel --plat-name macosx-10.15-universal2 -j10 28 | $PYDIR/python3 -m twine upload dist/*.whl || true 29 | -------------------------------------------------------------------------------- /tests/catch/line.vol: -------------------------------------------------------------------------------- 1 | mesh3d 2 | dimension 3 | 1 4 | geomtype 5 | 0 6 | 7 | # surfnr bcnr domin domout np p1 p2 p3 8 | surfaceelements 9 | 0 10 | 11 | 12 | # matnr np p1 p2 p3 p4 13 | volumeelements 14 | 0 15 | 16 | 17 | # surfid 0 p1 p2 trignum1 trignum2 domin/surfnr1 domout/surfnr2 ednr1 dist1 ednr2 dist2 18 | edgesegmentsgi2 19 | 1 20 | 1 0 1 2 8 0 -1 -1 1 0 0 0 21 | 22 | 23 | # X Y Z 24 | points 25 | 2 26 | 0.0000000000000000 0.0000000000000000 0.0000000000000000 27 | 1.0000000000000000 0.0000000000000000 0.0000000000000000 28 | 29 | 30 | endmesh 31 | 32 | -------------------------------------------------------------------------------- /tests/catch/main.cpp: -------------------------------------------------------------------------------- 1 | 2 | #define CATCH_CONFIG_MAIN 3 | #include 4 | -------------------------------------------------------------------------------- /tests/gitlab-ci/conda/.gitignore: -------------------------------------------------------------------------------- 1 | netgen/meta.yaml 2 | ngsolve/meta.yaml 3 | -------------------------------------------------------------------------------- /tests/gitlab-ci/conda/netgen/bld.bat: -------------------------------------------------------------------------------- 1 | mkdir build 2 | cd build 3 | 4 | set PYTHONPATH=%PREFIX%\Lib\site-packages 5 | 6 | cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release ^ 7 | -DCMAKE_SYSTEM_PREFIX_PATH=%LIBRARY_PREFIX% ^ 8 | -DCMAKE_PREFIX_PATH=%LIBRARY_PREFIX% ^ 9 | -DCMAKE_INSTALL_PREFIX:PATH=%PREFIX% ^ 10 | -DUSE_SUPERBUILD=OFF ^ 11 | -DUSE_NATIVE_ARCH=OFF ^ 12 | -DUSE_GUI=ON ^ 13 | -DUSE_JPEG=ON ^ 14 | -DUSE_OCC=ON ^ 15 | -DOCC_INCLUDE_DIR=%LIBRARY_PREFIX%/include/opencascade ^ 16 | -DUSE_MPEG=OFF ^ 17 | -DNG_INSTALL_DIR_LIB=Library/lib/netgen ^ 18 | -DNG_INSTALL_DIR_BIN=Library/bin ^ 19 | -DNG_INSTALL_DIR_RES=Library/lib/share ^ 20 | -DNG_INSTALL_DIR_CMAKE=Library/cmake ^ 21 | -DNG_INSTALL_DIR_INCLUDE=Library/include/netgen ^ 22 | -DTCL_LIBRARY:FILEPATH=%LIBRARY_PREFIX%/lib/tcl86t.lib ^ 23 | -DTK_LIBRARY:FILEPATH=%LIBRARY_PREFIX%/lib/tk86t.lib ^ 24 | -DTK_INCLUDE_PATH=%SRC_DIR%/tk/generic ^ 25 | -DTCL_INCLUDE_PATH=%SRC_DIR%/tcl/generic ^ 26 | -DPYBIND11_INCLUDE_DIR:FILEPATH=%LIBRARY_PREFIX%/include ^ 27 | -DPYTHON_INCLUDE_DIRS:FILEPATH=%LIBRARY_PREFIX%/include ^ 28 | -DNG_INSTALL_PYBIND=OFF ^ 29 | %SRC_DIR% 30 | if errorlevel 1 exit 1 31 | 32 | REM Build 33 | nmake 34 | if errorlevel 1 exit 1 35 | 36 | REM Install 37 | nmake install 38 | if errorlevel 1 exit 1 39 | -------------------------------------------------------------------------------- /tests/gitlab-ci/conda/netgen/conda_build_config.yaml: -------------------------------------------------------------------------------- 1 | python: 2 | - 3.7 3 | - 3.8 4 | 5 | tk: 6 | - 8.6.9 7 | - 8.6.10 8 | 9 | zip_keys: 10 | - python 11 | - tk 12 | 13 | mpi: 14 | - openmpi 15 | # - mpich 16 | 17 | 18 | -------------------------------------------------------------------------------- /tests/gitlab-ci/conda/netgen/meta_template.yaml: -------------------------------------------------------------------------------- 1 | build: 2 | number: 0 3 | package: 4 | name: netgen{{suffix}} 5 | version: '{{version}}' 6 | 7 | requirements: 8 | build: 9 | - python {{ python }} 10 | - {{mpi}} # [not win] 11 | - mpi4py # [not win] 12 | - metis 5.1.0 # [not win] 13 | - jpeg 14 | - cmake 15 | - tk {{tk}} 16 | - zlib 17 | - occt 7.4.* 18 | - ffmpeg 3.4.* 19 | - pybind11 2.8.1 20 | run: 21 | - vs2015_runtime # [win] 22 | - python {{ python }} 23 | - {{mpi}} # [not win] 24 | - mpi4py # [not win] 25 | - metis 5.1.0 # [not win] 26 | - jpeg 27 | - tk {{tk}} 28 | - zlib 29 | - occt 7.4.* 30 | - ffmpeg 3.4.* 31 | - pybind11 2.8.1 32 | 33 | source: 34 | - path: ../../../../external_dependencies/netgen 35 | - url: ftp://ftp.tcl.tk/pub/tcl/tcl8_6/tcl{{tk}}-src.tar.gz 36 | folder: tcl 37 | - url: ftp://ftp.tcl.tk/pub/tcl/tcl8_6/tk{{tk}}-src.tar.gz 38 | folder: tk 39 | 40 | test: 41 | imports: 42 | - netgen 43 | 44 | about: 45 | home: https://ngsolve.org 46 | license: LGPL 47 | summary: "Netgen Mesh Generator" 48 | 49 | -------------------------------------------------------------------------------- /tests/gitlab-ci/conda/ngsolve/bld.bat: -------------------------------------------------------------------------------- 1 | mkdir build 2 | cd build 3 | 4 | set PYTHONPATH=%PREFIX%\Lib\site-packages 5 | 6 | cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release ^ 7 | -DUSE_SUPERBUILD=OFF ^ 8 | -DCMAKE_SYSTEM_PREFIX_PATH=%LIBRARY_PREFIX% ^ 9 | -DCMAKE_PREFIX_PATH=%LIBRARY_PREFIX% ^ 10 | -DCMAKE_INSTALL_PREFIX:PATH=%PREFIX% ^ 11 | -DUSE_MKL=ON ^ 12 | -DMKL_SDL=ON ^ 13 | -DMKL_INCLUDE_DIR=%LIBRARY_PREFIX%/include ^ 14 | -DMKL_MINIMAL_LIBRARY=%LIBRARY_PREFIX%/lib/libmkl_rt.lib ^ 15 | -DMKL_LIBRARY=%LIBRARY_PREFIX%/lib/libmkl_rt.lib ^ 16 | -DMKL_ROOT=%LIBRARY_PREFIX% ^ 17 | -DUSE_UMFPACK=OFF ^ 18 | %SRC_DIR% 19 | if errorlevel 1 exit 1 20 | 21 | REM Build 22 | nmake 23 | if errorlevel 1 exit 1 24 | 25 | REM Install 26 | nmake install 27 | if errorlevel 1 exit 1 28 | -------------------------------------------------------------------------------- /tests/gitlab-ci/conda/ngsolve/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | export OSX_DEPLOYMENT_TARGET=10.15 3 | 4 | PLATFORM=`python -c "import platform; print(platform.system())"` 5 | if [ "$PLATFORM" = "Darwin" ] 6 | then 7 | SHARED_EXT=dylib 8 | else echo "not darwin" 9 | SHARED_EXT=so 10 | fi 11 | 12 | env 13 | echo "BUILD_DIR" `pwd` 14 | echo "SRC_DIR" `${SRC_DIR}` 15 | export CCACHE_BASEDIR=$PREFIX/.. 16 | 17 | cd .. 18 | 19 | ############################################## 20 | # build ngsolve 21 | mkdir -p build_ngsolve 22 | cd build_ngsolve 23 | 24 | cmake -G "Unix Makefiles" \ 25 | -DCMAKE_OSX_SYSROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk \ 26 | -DUSE_CCACHE=ON \ 27 | -DUSE_SUPERBUILD=OFF \ 28 | -DCMAKE_OSX_DEPLOYMENT_TARGET=10.15 \ 29 | -DCMAKE_BUILD_TYPE=Release \ 30 | -DCMAKE_INSTALL_PREFIX=${PREFIX} \ 31 | -DUSE_NATIVE_ARCH=OFF \ 32 | -DUSE_CCACHE=ON \ 33 | -DUSE_MKL=ON \ 34 | -DMKL_ROOT=${PREFIX} \ 35 | -DMKL_SDL=ON \ 36 | -DLAPACK_LIBRARIES=${PREFIX}/lib/libmkl_rt.${SHARED_EXT} \ 37 | -DUSE_UMFPACK=OFF \ 38 | -DBUILD_STUB_FILES=OFF \ 39 | ${SRC_DIR} 40 | 41 | make -j$CPU_COUNT 42 | make install 43 | 44 | -------------------------------------------------------------------------------- /tests/gitlab-ci/conda/ngsolve/conda_build_config.yaml: -------------------------------------------------------------------------------- 1 | python: 2 | - 3.7 3 | - 3.8 4 | 5 | mpi: 6 | - openmpi 7 | # - mpich 8 | -------------------------------------------------------------------------------- /tests/gitlab-ci/conda/ngsolve/meta_template.yaml: -------------------------------------------------------------------------------- 1 | build: 2 | number: 0 3 | package: 4 | name: ngsolve{{suffix}} 5 | version: '{{version}}' 6 | 7 | requirements: 8 | build: 9 | - python {{ python }} 10 | - {{mpi}} # [not win] 11 | - netgen{{suffix}} {{netgen_version}} 12 | - cmake 3.15.* 13 | - mkl-devel 14 | - nodejs # [not win] 15 | 16 | run: 17 | - python {{ python }} 18 | - netgen{{suffix}} {{netgen_version}} 19 | - {{mpi}} # [not win] 20 | - mkl 21 | - mkl-devel 22 | - intel-openmp 23 | 24 | source: 25 | path: ../../../../ 26 | 27 | test: 28 | imports: 29 | - ngsolve 30 | 31 | about: 32 | home: https://ngsolve.org 33 | license: LGPL 34 | summary: "Finite Element library" 35 | 36 | -------------------------------------------------------------------------------- /tests/gitlab-ci/deploy.yml: -------------------------------------------------------------------------------- 1 | deploy_github: 2 | stage: deploy 3 | tags: 4 | - deploy_github 5 | script: 6 | - git remote add github git@github.com:NGSolve/ngsolve.git || true 7 | - git remote update 8 | - git checkout --track origin/master 9 | - git pull origin master 10 | - git push github master 11 | only: 12 | - master 13 | 14 | deploy_release: 15 | stage: deploy 16 | tags: 17 | - deploy_github 18 | script: 19 | - git remote add github git@github.com:NGSolve/ngsolve.git || true 20 | - git push github $CI_BUILD_TAG 21 | - source tests/gitlab-ci/deploy/release.sh 22 | only: 23 | - tags 24 | environment: deploy_release 25 | 26 | deploy_nightly: 27 | stage: deploy 28 | tags: 29 | - deploy_github 30 | script: 31 | - source tests/gitlab-ci/deploy/nightly.sh 32 | only: 33 | - schedules 34 | except: 35 | - tags 36 | environment: deploy_nigthly 37 | -------------------------------------------------------------------------------- /tests/gitlab-ci/deploy/mac.sh: -------------------------------------------------------------------------------- 1 | /home/gitlab-runner/deploy/deploy_mac.sh $CI_PIPELINE_ID; 2 | -------------------------------------------------------------------------------- /tests/gitlab-ci/deploy/nightly.sh: -------------------------------------------------------------------------------- 1 | if [ -n "${RUN_DEPLOY}" ]; 2 | then 3 | /home/gitlab-runner/deploy/deploy_nightly.sh $CI_PIPELINE_ID; 4 | fi 5 | -------------------------------------------------------------------------------- /tests/gitlab-ci/deploy/release.sh: -------------------------------------------------------------------------------- 1 | /home/gitlab-runner/deploy/deploy_release.sh $CI_PIPELINE_ID $CI_BUILD_TAG 2 | -------------------------------------------------------------------------------- /tests/gitlab-ci/deploy/win.sh: -------------------------------------------------------------------------------- 1 | /home/gitlab-runner/deploy/deploy_win.sh $CI_PIPELINE_ID; 2 | -------------------------------------------------------------------------------- /tests/gitlab-ci/mac.yml: -------------------------------------------------------------------------------- 1 | .template_mac: &mac 2 | tags: 3 | - mac 4 | - x64 5 | before_script: 6 | - source tests/gitlab-ci/mac/set_vars.sh 7 | 8 | mac_build: 9 | <<: *mac 10 | stage: build 11 | script: 12 | - source $CI_PROJECT_DIR/tests/gitlab-ci/mac/build.sh 13 | 14 | mac_test: 15 | <<: *mac 16 | stage: test 17 | script: 18 | - source tests/gitlab-ci/mac/test.sh 19 | needs: ["mac_build"] 20 | 21 | mac_cleanup: 22 | <<: *mac 23 | stage: cleanup 24 | script: 25 | - source tests/gitlab-ci/mac/cleanup.sh 26 | when: always 27 | allow_failure: true 28 | needs: ["mac_test"] 29 | 30 | deploy_mac: 31 | stage: deploy 32 | tags: 33 | - deploy 34 | script: 35 | - source tests/gitlab-ci/deploy/mac.sh 36 | when: manual 37 | needs: ["mac_build"] 38 | -------------------------------------------------------------------------------- /tests/gitlab-ci/mac/build.sh: -------------------------------------------------------------------------------- 1 | git submodule update --init --recursive 2 | rm -rf $BUILD_DIR 3 | mkdir -p $BUILD_DIR 4 | rm -rf $SRC_DIR 5 | mkdir -p $SRC_DIR 6 | cp -a . $SRC_DIR/ 7 | cd $BUILD_DIR 8 | 9 | pip3 install --upgrade pybind11-stubgen 10 | 11 | cmake $SRC_DIR \ 12 | -DCMAKE_INSTALL_PREFIX=$CMAKE_INSTALL_PREFIX \ 13 | -DCMAKE_BUILD_TYPE=Release \ 14 | -DUSE_NATIVE_ARCH=OFF \ 15 | -DUSE_CCACHE=ON \ 16 | -DUSE_CGNS=ON \ 17 | -DUSE_UMFPACK=ON \ 18 | -DENABLE_UNIT_TESTS=ON \ 19 | -DCMAKE_OSX_DEPLOYMENT_TARGET=10.15 \ 20 | -DCPACK_PACKAGE_NAME=NGSolve${PACKAGE_NAME_SUFFIX} \ 21 | -DPython3_EXECUTABLE=`which python3` \ 22 | -DUSE_OCC=ON 23 | 24 | make -j5 install 25 | -------------------------------------------------------------------------------- /tests/gitlab-ci/mac/cleanup.sh: -------------------------------------------------------------------------------- 1 | rm -rf $ROOT_DIR 2 | -------------------------------------------------------------------------------- /tests/gitlab-ci/mac/set_vars.sh: -------------------------------------------------------------------------------- 1 | export ROOT_DIR=/tmp/$CI_PIPELINE_ID 2 | export SRC_DIR=$ROOT_DIR/src 3 | export BUILD_DIR=$ROOT_DIR/build 4 | export CMAKE_INSTALL_PREFIX=/tmp/$CI_PIPELINE_ID/install/Netgen.app 5 | export PYTHONPATH=$CMAKE_INSTALL_PREFIX/Contents/Resources/`python3 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1,0,''))"`:. 6 | export PATH=$CMAKE_INSTALL_PREFIX/Contents/MacOS:$PATH 7 | export MACOSX_DEPLOYMENT_TARGET=10.15 8 | -------------------------------------------------------------------------------- /tests/gitlab-ci/mac/test.sh: -------------------------------------------------------------------------------- 1 | cd $BUILD_DIR/ngsolve 2 | 3 | pip3 install scipy 4 | 5 | ctest . --output-on-failure 6 | -------------------------------------------------------------------------------- /tests/gitlab-ci/pip.yml: -------------------------------------------------------------------------------- 1 | pip_linux: 2 | image: cerbsim/manylinux_2_28_x86_64_cuda_12.8 3 | stage: build 4 | tags: 5 | - pip 6 | - linux 7 | - docker 8 | script: 9 | - ./tests/build_pip.sh 10 | when: manual 11 | 12 | pip_macos: 13 | stage: build 14 | tags: 15 | - pip 16 | - macosx 17 | - m1 18 | script: 19 | - ./tests/build_pip_mac.sh 3.13 20 | - ./tests/build_pip_mac.sh 3.12 21 | - ./tests/build_pip_mac.sh 3.11 22 | - ./tests/build_pip_mac.sh 3.10 23 | - ./tests/build_pip_mac.sh 3.9 24 | when: manual 25 | 26 | pip_windows: 27 | stage: build 28 | tags: 29 | - pip 30 | - windows 31 | script: 32 | - .\tests\build_pip.ps1 C:\Python313 33 | - .\tests\build_pip.ps1 C:\Python312 34 | - .\tests\build_pip.ps1 C:\Python311 35 | - .\tests\build_pip.ps1 C:\Python310 36 | - .\tests\build_pip.ps1 C:\Python39 37 | when: manual 38 | 39 | pip_pyodide: 40 | stage: build 41 | tags: 42 | - bash 43 | - avx 44 | - linux 45 | - docker 46 | script: 47 | - ./tests/gitlab-ci/pyodide/build.sh 48 | when: manual 49 | 50 | -------------------------------------------------------------------------------- /tests/gitlab-ci/pyodide/build.sh: -------------------------------------------------------------------------------- 1 | set -e 2 | docker build -t ngsolve_pyodide -f tests/gitlab-ci/pyodide/Dockerfile . 3 | rm -rf dist 4 | mkdir -p dist 5 | USERID=`id -u` 6 | GROUPID=`id -g` 7 | # docker run -u `id -u` -v `pwd`/dist:/dist ngsolve_pyodide bash -c 'cd /root/output && cp ngsolve*.tar.bz2 /dist/' 8 | docker run -v `pwd`/dist:/dist ngsolve_pyodide bash -c "cd /root/output && cp ngsolve*.tar.bz2 /dist/ && chown -R ${USERID}:${GROUPID} /dist/" 9 | 10 | # append branch name to file name if it's other than master 11 | cd dist 12 | if [ "$CI_COMMIT_REF_NAME" != "master" ]; then 13 | rename "s/ngsolve_pyodide_/ngsolve_pyodide_${CI_COMMIT_REF_NAME}_/" *.tar.bz2 14 | fi 15 | scp -P 692 *.tar.bz2 deploy@ngsolve.org:/opt/data/files/ 16 | tar xvf *.tar.bz2 17 | ssh -p 692 deploy@ngsolve.org "mkdir -p /opt/data/files/pyodide-0.27.6/${CI_COMMIT_REF_NAME}" 18 | scp -P 692 pyodide/pyngcore.zip pyodide/netgen.zip pyodide/ngsolve.zip deploy@ngsolve.org:/opt/data/files/pyodide-0.27.6/${CI_COMMIT_REF_NAME}/ 19 | -------------------------------------------------------------------------------- /tests/gitlab-ci/pyodide/generate_repodata.js: -------------------------------------------------------------------------------- 1 | const fs = require("fs"); 2 | 3 | const { loadPyodide } = require("pyodide"); 4 | 5 | async function generateRepodata() { 6 | let pyodide = await loadPyodide(); 7 | await pyodide.loadPackage("micropip"); 8 | return pyodide.runPythonAsync(` 9 | import micropip 10 | await micropip.install('webgui_jupyter_widgets') 11 | micropip.freeze() 12 | `); 13 | } 14 | 15 | generateRepodata().then((result) => { 16 | fs.writeFileSync('pyodide-lock.json', result); 17 | process.exit(0); 18 | }).catch((err) => { 19 | console.log("error", err) 20 | throw(err); 21 | }); 22 | -------------------------------------------------------------------------------- /tests/gitlab-ci/timings.sh: -------------------------------------------------------------------------------- 1 | if [ -n "${RUN_TIMINGS}" ]; 2 | then 3 | git submodule update --init --recursive 4 | mkdir build 5 | mkdir install 6 | cd build 7 | cmake .. 8 | -DUSE_CCACHE=ON 9 | -DCMAKE_INSTALL_PREFIX=$CI_PROJECT_DIR/install 10 | -DUSE_NATIVE_ARCH=ON 11 | -DCMAKE_C_COMPILER=$CMAKE_C_COMPILER 12 | -DCMAKE_CXX_COMPILER=$CMAKE_CXX_COMPILER 13 | -DCMAKE_CXX_FLAGS="-ffast-math $CMAKE_FLAGS" 14 | -DUSE_MKL=ON 15 | -DMKL_ROOT=/opt/intel/mkl 16 | -DCMAKE_BUILD_TYPE=Release 17 | make -j install 18 | export NETGENDIR=$CI_PROJECT_DIR/install/bin 19 | export PATH=$CI_PROJECT_DIR/install/bin:$PATH 20 | export PYTHONPATH=$CI_PROJECT_DIR/install/lib/python3.6/site-packages:. 21 | export LD_LIBRARY_PATH=$CI_PROJECT_DIR/install/lib:.:$LD_LIBRARY_PATH 22 | cd ngsolve 23 | make timings; 24 | fi 25 | -------------------------------------------------------------------------------- /tests/gitlab-ci/ubuntu/build.sh: -------------------------------------------------------------------------------- 1 | sed -e "s/{UBUNTU_VERSION}/$UBUNTU_VERSION/" tests/gitlab-ci/ubuntu/docker_template >> docker_file 2 | docker build -t ngsolve_${CI_PIPELINE_ID}:${IMAGE_NAME} -f docker_file . 3 | 4 | export DOCKER_NAME=ngsolve_${CI_PIPELINE_ID}_${IMAGE_NAME} 5 | docker run \ 6 | --name ${DOCKER_NAME} \ 7 | -e MKLROOT=/opt/intel/mkl \ 8 | -e CI=$CI \ 9 | -e CI_BUILD_REF=$CI_BUILD_REF \ 10 | -e CI_PIPELINE_ID=$CI_PIPELINE_ID \ 11 | -e IMAGE_NAME=$IMAGE_NAME \ 12 | -e CMAKE_ARGS="-DCPACK_DEBIAN_PACKAGE_NAME=ngsolve${PACKAGE_NAME_SUFFIX}" \ 13 | -e CCACHE_DIR=/ccache \ 14 | -e SSH_PRIVATE_KEY="$SSH_PRIVATE_KEY" \ 15 | -e MKL_NUM_THREADS=1 \ 16 | -e MKL_DOMAIN_THREADS="MKL_DOMAIN_PARDISO=6" \ 17 | -e LD_LIBRARY_PATH=/opt/intel/mkl/lib/intel64 \ 18 | -e RUN_SLOW_TESTS="$RUN_SLOW_TESTS" \ 19 | -e SHOW_LOGS="$SHOW_LOGS" \ 20 | -v /opt/intel:/opt/intel \ 21 | -v /mnt/ccache:/ccache ngsolve_${CI_PIPELINE_ID}:${IMAGE_NAME} \ 22 | bash /root/src/ngsolve/tests/gitlab-ci/ubuntu/build_in_docker.sh 23 | 24 | docker wait ${DOCKER_NAME} 25 | docker cp ${DOCKER_NAME}:/logs/ . 26 | docker commit ${DOCKER_NAME} ngsolve_${CI_PIPELINE_ID}_installed:${IMAGE_NAME} 27 | -------------------------------------------------------------------------------- /tests/gitlab-ci/ubuntu/cleanup.sh: -------------------------------------------------------------------------------- 1 | ## delete all containers belonging to images of the current pipeline 2 | docker ps -a | awk '{ print $1,$2 }' | grep ngsolve_${CI_PIPELINE_ID} | awk '{print $1 }' | xargs -I {} docker rm {} || true 3 | 4 | ## list of images to delete 5 | declare -a arr=("16.04" "16.10" "17.04" "17.10" "debug" "avx" "avx512" "latest" "mpi") 6 | 7 | for version in "${arr[@]}" 8 | do 9 | docker rmi -f ngsolve_${CI_PIPELINE_ID}:$version || true 10 | docker rmi -f ngsolve_${CI_PIPELINE_ID}_installed:$version || true 11 | done 12 | -------------------------------------------------------------------------------- /tests/gitlab-ci/ubuntu/test.sh: -------------------------------------------------------------------------------- 1 | docker run \ 2 | -e NETGENDIR=/opt/netgen/bin \ 3 | -e NGS_NUM_THREADS=6 \ 4 | -e PYTHONPATH=/opt/netgen/lib/python3/dist-packages \ 5 | -e MKLROOT=/opt/intel/mkl \ 6 | -e MKL_NUM_THREADS=1 \ 7 | -e MKL_DOMAIN_THREADS="MKL_DOMAIN_PARDISO=6" \ 8 | -e LD_LIBRARY_PATH=/opt/intel/mkl/lib/intel64 \ 9 | -e RUN_SLOW_TESTS="$RUN_SLOW_TESTS" \ 10 | -e NG_BACKTRACE=1 \ 11 | -v /opt/intel:/opt/intel \ 12 | ngsolve_${CI_PIPELINE_ID}_installed:$IMAGE_NAME \ 13 | bash -c 'cd /root/build/ngsolve && make test_ngsolve ARGS="--output-on-failure"' 14 | -------------------------------------------------------------------------------- /tests/gitlab-ci/win.yml: -------------------------------------------------------------------------------- 1 | 2 | ############################################ 3 | # Windows 4 | ############################################ 5 | 6 | .template_win: &win 7 | tags: 8 | - windows 9 | - x64 10 | before_script: 11 | - set NG_USE_NATIVE_ARCH=OFF 12 | - call tests\gitlab-ci\win\set_vars.bat 13 | 14 | win_build: 15 | <<: *win 16 | stage: build 17 | script: 18 | - call tests\gitlab-ci\win\build.bat 19 | - IF %errorlevel% NEQ 0 exit /b %errorlevel% 20 | - cd %CI_PROJECT_DIR% 21 | - call tests\gitlab-ci\win\upload.bat 22 | - IF %errorlevel% NEQ 0 exit /b %errorlevel% 23 | - cd %CI_PROJECT_DIR% 24 | - call tests\gitlab-ci\win\test.bat 25 | - IF %errorlevel% NEQ 0 exit /b %errorlevel% 26 | 27 | .template_win_avx: &win_avx 28 | tags: 29 | - windows 30 | - x64 31 | before_script: 32 | - set NG_USE_NATIVE_ARCH=ON 33 | - call tests\gitlab-ci\win\set_vars.bat 34 | only: 35 | - schedules 36 | - tags 37 | 38 | win_avx_build: 39 | <<: *win_avx 40 | stage: build 41 | script: 42 | - call tests\gitlab-ci\win\build.bat 43 | - IF %errorlevel% NEQ 0 exit /b %errorlevel% 44 | - cd %CI_PROJECT_DIR% 45 | - call tests\gitlab-ci\win\test.bat 46 | 47 | deploy_win: 48 | stage: deploy 49 | tags: 50 | - deploy 51 | script: 52 | - source tests/gitlab-ci/deploy/win.sh 53 | when: manual 54 | needs: ["win_build"] 55 | -------------------------------------------------------------------------------- /tests/gitlab-ci/win/build.bat: -------------------------------------------------------------------------------- 1 | pip3 install --upgrade pybind11-stubgen 2 | 3 | git submodule update --init --recursive 4 | IF %errorlevel% NEQ 0 exit /b %errorlevel% 5 | rd /s /q %NETGEN_BUILD_DIR% 6 | mkdir %NETGEN_BUILD_DIR% 7 | IF %errorlevel% NEQ 0 exit /b %errorlevel% 8 | cd %NETGEN_BUILD_DIR% 9 | IF %errorlevel% NEQ 0 exit /b %errorlevel% 10 | 11 | cmake %SRC_DIR% ^ 12 | -G"%CMAKE_GENERATOR%" ^ 13 | -DCMAKE_INSTALL_PREFIX=%CMAKE_INSTALL_PREFIX% ^ 14 | %CMAKE_CONFIG% ^ 15 | -DUSE_NATIVE_ARCH=%NG_USE_NATIVE_ARCH% ^ 16 | -DUSE_CGNS=ON ^ 17 | -DUSE_OCC=ON ^ 18 | -DUSE_CCACHE=ON ^ 19 | -DUSE_MKL=ON ^ 20 | -DMKL_STATIC=ON ^ 21 | -DMKL_ROOT="C:/Intel/compilers_and_libraries/windows/mkl" ^ 22 | -DUSE_UMFPACK=ON ^ 23 | -DENABLE_UNIT_TESTS=ON ^ 24 | -DCPACK_PACKAGE_NAME=NGSolve ^ 25 | -DCMAKE_BUILD_TYPE=Release 26 | 27 | IF %errorlevel% NEQ 0 exit /b %errorlevel% 28 | cmake --build . --target install --config Release 29 | IF %errorlevel% NEQ 0 exit /b %errorlevel% 30 | -------------------------------------------------------------------------------- /tests/gitlab-ci/win/cleanup.bat: -------------------------------------------------------------------------------- 1 | cd %CI_PROJECT_DIR% 2 | rd /s /q %CI_DIR% 3 | -------------------------------------------------------------------------------- /tests/gitlab-ci/win/set_vars.bat: -------------------------------------------------------------------------------- 1 | call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64" 2 | set CMAKE_GENERATOR=Ninja 3 | set NETGEN_BUILD_DIR=%CI_PROJECT_DIR%\build 4 | set CMAKE_INSTALL_PREFIX=%CI_PROJECT_DIR%\install 5 | set SRC_DIR=%CI_PROJECT_DIR% 6 | set NETGENDIR=%CMAKE_INSTALL_PREFIX%\bin 7 | set PATH=%NETGENDIR%;C:\python312;C:\python312\bin;C:\python312\Scripts;C:\tools\;%PATH% 8 | set PYTHONPATH=%CMAKE_INSTALL_PREFIX%\lib\site-packages 9 | REM set CCACHE_BASEDIR=%CI_DIR% 10 | set HOME=%USERPROFILE% 11 | call ccache -M 20G 12 | call ccache -s 13 | -------------------------------------------------------------------------------- /tests/gitlab-ci/win/test.bat: -------------------------------------------------------------------------------- 1 | cd %NETGEN_BUILD_DIR%/ngsolve 2 | 3 | pip3 install scipy 4 | 5 | ctest -C Release --output-on-failure 6 | -------------------------------------------------------------------------------- /tests/gitlab-ci/win/upload.bat: -------------------------------------------------------------------------------- 1 | cd %NETGEN_BUILD_DIR% 2 | IF %errorlevel% NEQ 0 exit /b %errorlevel% 3 | cmake --build . --target package --config Release 4 | IF %errorlevel% NEQ 0 exit /b %errorlevel% 5 | set HOME=/cygdrive/c/tools 6 | rsync -ztrl --del -e "ssh -o StrictHostKeyChecking=no" ^ 7 | --rsync-path="mkdir -p deploy/builds/%CI_PIPELINE_ID%/windows && rsync" ^ 8 | *.msi ^ 9 | gitlab-runner@vector.asc.tuwien.ac.at:deploy/builds/%CI_PIPELINE_ID%/windows/ 10 | 11 | IF %errorlevel% NEQ 0 exit /b %errorlevel% 12 | -------------------------------------------------------------------------------- /tests/pde_tutorial/d10_DGdoubleglazing.pde.appx: -------------------------------------------------------------------------------- 1 | 2 | numproc testvariable nptv_it -variable=bvp.npdisc.its -refvalue=1 -tolerance=3 -abstol -cdash 3 | -------------------------------------------------------------------------------- /tests/pde_tutorial/d11_chip_nitsche.pde.appx: -------------------------------------------------------------------------------- 1 | 2 | numproc testvariable nptv_it -variable=bvp.np1.its -refvalues=19 -tolerance=3 -abstol -cdash 3 | numproc testvariable nptv_it2 -variable=ZZerrest.np3.err -refvalue=0 -tolerance=0.005 -abstol -cdash 4 | -------------------------------------------------------------------------------- /tests/pde_tutorial/d1_square.pde.appx: -------------------------------------------------------------------------------- 1 | 2 | numproc testvariable nptv_it -variable=bvp.np1.its -refvalue=25 -tolerance=3 -abstol -cdash 3 | -------------------------------------------------------------------------------- /tests/pde_tutorial/d2_chip.pde.appx: -------------------------------------------------------------------------------- 1 | 2 | numproc testvariable nptv_it -variable=bvp.np1.its -refvalue=19 -tolerance=3 -abstol -cdash 3 | numproc testvariable nptv_it2 -variable=ZZerrest.np3.err -refvalue=0 -tolerance=0.005 -abstol -cdash 4 | -------------------------------------------------------------------------------- /tests/pde_tutorial/d3_helmholtz.pde.appx: -------------------------------------------------------------------------------- 1 | 2 | numproc visualization npv1 -scalarfunction=u -subdivision=2 -nolineartexture 3 | -------------------------------------------------------------------------------- /tests/pde_tutorial/d4_cube.pde.appx: -------------------------------------------------------------------------------- 1 | 2 | numproc testvariable nptv_it -variable=bvp.np1.its -refvalues=[39,42] -tolerance=3 -abstol -cdash 3 | -------------------------------------------------------------------------------- /tests/pde_tutorial/d5_beam.pde.appx: -------------------------------------------------------------------------------- 1 | 2 | numproc testvariable nptv_it -variable=bvp.np1.its -refvalue=74 -tolerance=3 -abstol -cdash 3 | -------------------------------------------------------------------------------- /tests/pde_tutorial/d6_shaft.pde.appx: -------------------------------------------------------------------------------- 1 | 2 | numproc testvariable nptv_it -variable=ZZerrest.np3.err -refvalue=0 -tolerance=3 -abstol -cdash 3 | numproc testvariable nptv_it2 -variable=constrbvp.np1.its -refvalue=51 -tolerance=3 -abstol -cdash 4 | -------------------------------------------------------------------------------- /tests/pde_tutorial/d7_coil.pde.appx: -------------------------------------------------------------------------------- 1 | 2 | numproc testvariable nptv_it -variable=bvp.np1.its -refvalue=50 -tolerance=3 -abstol -cdash 3 | -------------------------------------------------------------------------------- /tests/pde_tutorial/d8_coilshield.pde.appx: -------------------------------------------------------------------------------- 1 | 2 | numproc testvariable nptv_it -variable=bvp.np1.its -refvalue=45 -tolerance=3 -abstol -cdash 3 | -------------------------------------------------------------------------------- /tests/pde_tutorial/d9_hybridDG.pde.appx: -------------------------------------------------------------------------------- 1 | 2 | numproc testvariable nptv_it -variable=bvp.np1.its -refvalue=1 -tolerance=3 -abstol -cdash 3 | -------------------------------------------------------------------------------- /tests/pytest/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if(NETGEN_USE_PYTHON) 2 | add_test(NAME pytest COMMAND ${NETGEN_PYTHON_EXECUTABLE} -m pytest --durations=20 --ignore=mpi_only WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) 3 | if(NETGEN_USE_MPI) 4 | add_test(NAME mpi_pytest COMMAND mpirun -np 5 --allow-run-as-root ${NETGEN_PYTHON_EXECUTABLE} -m pytest --durations=20 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/mpi_only ) 5 | set_tests_properties ( mpi_pytest PROPERTIES TIMEOUT 60 ) 6 | endif() 7 | set_tests_properties ( pytest PROPERTIES TIMEOUT 1500 ) 8 | add_custom_target(pytest ${NETGEN_PYTHON_EXECUTABLE} -m pytest --durations=20 --ignore=mpi_only WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) 9 | endif(NETGEN_USE_PYTHON) 10 | -------------------------------------------------------------------------------- /tests/pytest/conftest.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pytest configuration file to run slow test only if pytest is started with option --runslow or if 3 | environment variable RUN_SLOW_TESTS is set. 4 | """ 5 | 6 | import pytest, os 7 | 8 | def pytest_addoption(parser): 9 | parser.addoption("--runslow", action="store_true", default=False, help="run slow tests") 10 | 11 | def pytest_configure(config): 12 | config.addinivalue_line("markers", "slow: mark test as slow to run") 13 | 14 | 15 | def pytest_collection_modifyitems(config, items): 16 | if not (('RUN_SLOW_TESTS' in os.environ and os.environ['RUN_SLOW_TESTS']) or config.getoption("--runslow")): 17 | skip_slow = pytest.mark.skip(reason="need --runslow option to run") 18 | for item in items: 19 | if "slow" in item.keywords: 20 | item.add_marker(skip_slow) 21 | -------------------------------------------------------------------------------- /tests/pytest/cube.vol.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NGSolve/ngsolve/cab3abd87bbc83654d6b50d275be06e40cb3f040/tests/pytest/cube.vol.gz -------------------------------------------------------------------------------- /tests/pytest/meshes.py: -------------------------------------------------------------------------------- 1 | 2 | import pytest 3 | 4 | @pytest.fixture 5 | def unit_mesh_2d(): 6 | import netgen.geom2d as g2d 7 | import ngsolve as ngs 8 | return ngs.Mesh(g2d.unit_square.GenerateMesh(maxh=0.2)) 9 | 10 | @pytest.fixture 11 | def unit_mesh_3d(): 12 | import netgen.csg as csg 13 | import ngsolve as ngs 14 | return ngs.Mesh(csg.unit_cube.GenerateMesh(maxh=0.2)) 15 | 16 | @pytest.fixture 17 | def domain2_mesh_2d(): 18 | import netgen.geom2d as g2d 19 | import ngsolve as ngs 20 | geo = g2d.SplineGeometry() 21 | geo.AddRectangle((-2,-2),(2,2)) 22 | geo.AddRectangle((-1,-1),(1,1),leftdomain=2, rightdomain=1) 23 | geo.SetMaterial(1,"outer") 24 | geo.SetMaterial(2,"inner") 25 | return ngs.Mesh(geo.GenerateMesh(maxh=0.5)) 26 | -------------------------------------------------------------------------------- /tests/pytest/mpi_only/square.vol.gz: -------------------------------------------------------------------------------- 1 | ../square.vol.gz -------------------------------------------------------------------------------- /tests/pytest/square.vol.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NGSolve/ngsolve/cab3abd87bbc83654d6b50d275be06e40cb3f040/tests/pytest/square.vol.gz -------------------------------------------------------------------------------- /tests/pytest/test_1d.py: -------------------------------------------------------------------------------- 1 | import netgen.meshing as meshing 2 | from netgen.csg import * 3 | from math import pi 4 | from ngsolve import * 5 | # generate a 1D mesh 6 | 7 | def test_1dlaplace(): 8 | m = meshing.Mesh() 9 | m.dim = 1 10 | 11 | nel = 20 12 | 13 | pnums = [] 14 | for i in range(0, nel+1): 15 | pnums.append (m.Add (meshing.MeshPoint (meshing.Pnt(i/nel, 0, 0)))) 16 | 17 | for i in range(0,nel): 18 | m.Add (meshing.Element1D ([pnums[i],pnums[i+1]], index=1)) 19 | 20 | m.Add (meshing.Element0D (pnums[0], index=1)) 21 | m.Add (meshing.Element0D (pnums[nel], index=2)) 22 | 23 | 24 | mesh = Mesh(m) 25 | 26 | order=10 27 | 28 | fes = H1(mesh, order=order,dirichlet=[1,2]) 29 | 30 | u = fes.TrialFunction() 31 | v = fes.TestFunction() 32 | 33 | n = specialcf.normal(mesh.dim) 34 | h = specialcf.mesh_size 35 | ugf = GridFunction(fes) 36 | uex = GridFunction(fes) 37 | uex.Set(sin(pi*x)) 38 | 39 | a = BilinearForm(fes) 40 | a += SymbolicBFI ( grad(u) * grad(v) ) 41 | 42 | l = LinearForm(fes) 43 | l += SymbolicLFI ( pi*pi*uex*v ) 44 | 45 | 46 | l.Assemble() 47 | a.Assemble() 48 | invmat = a.mat.Inverse(fes.FreeDofs()) 49 | ugf.vec.data = invmat*l.vec 50 | error = sqrt(Integrate( (ugf-uex)*(ugf-uex) ,mesh )) 51 | assert error <= 1e-14 52 | -------------------------------------------------------------------------------- /tests/pytest/test_bem.py: -------------------------------------------------------------------------------- 1 | 2 | import pytest 3 | 4 | from netgen.occ import * 5 | from ngsolve import * 6 | from ngsolve.bem import * 7 | 8 | def test_transform(): 9 | box = Box((-10,-10,-10), (10,10,10)) 10 | mesh = Mesh(OCCGeometry(box).GenerateMesh(maxh=5)) 11 | 12 | kappa = 0.01 13 | order = 20 14 | mp = SingularMultiPoleCF(order, kappa, (0,0,0), rad=1) 15 | mp.AddCharge((0.3, -0.1,0.5), 1) 16 | 17 | dx,dy,dz = 0, 0.2, 0.3 18 | mp2 = SingularMultiPoleCF(order, kappa, (dx,dy,dz), rad=2) 19 | mp.Transform(mp2) 20 | 21 | meshpnt = mesh(1,1,1) 22 | assert mp(meshpnt) == pytest.approx(mp2(meshpnt)) 23 | 24 | 25 | 26 | 27 | def test_singulartransform(): 28 | box = Box((-10,-10,-10), (10,10,10)) 29 | mesh = Mesh(OCCGeometry(box).GenerateMesh(maxh=5)) 30 | 31 | kappa = 0.01 32 | order = 20 33 | mp = SingularMLMultiPoleCF((0,0,0), r=1, order=-1, kappa=kappa) 34 | num = 200 35 | for i in range(num): 36 | z = i/num 37 | mp.mlmp.AddCharge((0.1, 0, z), 1/num) 38 | 39 | val1 = mp(mesh(1,1,4)) 40 | mp.mlmp.Calc() 41 | val2 = mp(mesh(1,1,4)) 42 | 43 | assert val1 == pytest.approx(val2) 44 | 45 | -------------------------------------------------------------------------------- /tests/pytest/test_dual.py: -------------------------------------------------------------------------------- 1 | 2 | import pytest 3 | from elements import * 4 | from ngsolve import * 5 | import scipy.sparse as sps 6 | import numpy as np 7 | 8 | @pytest.mark.parametrize("element", [Trig, Quad, Tet, Prism]) 9 | def test_dual_hcurl(element): 10 | mesh = Mesh(element()) 11 | fes = HCurl(mesh, order=0) 12 | u,v = fes.TnT() 13 | vdual = v.Operator("dual") 14 | a = BilinearForm(fes) 15 | print("mesh.dim = ", mesh.dim) 16 | a += u * vdual * dx(element_vb=BBND if mesh.dim == 3 else BND) 17 | a.Assemble() 18 | dense = sps.csr_matrix(a.mat.CSR()).todense() 19 | assert dense == pytest.approx(np.identity(a.mat.height)), "mat = " + str(dense) 20 | -------------------------------------------------------------------------------- /tests/pytest/test_evaluate.py: -------------------------------------------------------------------------------- 1 | 2 | from netgen.csg import * 3 | from ngsolve import * 4 | import numpy as np 5 | 6 | def test_eval_curved_surface(): 7 | geo = CSGeometry() 8 | cyl = Cylinder((0,0,-1), (0,0,2), 0.3) 9 | box = OrthoBrick((-1,-1,0), (1,1,1)) 10 | geo.Add(cyl*box) 11 | mesh = Mesh(geo.GenerateMesh(maxh=0.1)) 12 | mesh.Curve(5) 13 | 14 | fes = H1(mesh, order=3) 15 | u = GridFunction(fes) 16 | u.Set(sin(atan2(y,x)), dual=True) 17 | 18 | phivals = np.linspace(0, 2*np.pi, 1000) 19 | xvals = 0.3 * np.cos(phivals) 20 | yvals = 0.3 * np.sin(phivals) 21 | zvals = 0.5 * np.ones(5) 22 | pts = mesh(xvals, yvals, 0.5, VOL_or_BND=BND) 23 | uvals = u(pts).flatten() 24 | sinvals = np.sin(phivals) 25 | assert max(uvals-sinvals) < 1e-5 26 | 27 | -------------------------------------------------------------------------------- /tests/pytest/test_integrate.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | from ngsolve import * 3 | from netgen.geom2d import unit_square 4 | 5 | 6 | def test_integrate_constant(): 7 | mesh = Mesh(unit_square.GenerateMesh(maxh=0.2)) 8 | cfR = [] 9 | cfC = [] 10 | for i in range(5): 11 | cfR.append(CoefficientFunction(i)) 12 | cfC.append(CoefficientFunction(1j*i)) 13 | cfR = CoefficientFunction(tuple(cfR)) 14 | cfC = CoefficientFunction(tuple(cfC)) 15 | with TaskManager(): 16 | intR = Integrate(cfR,mesh,order=1) 17 | intC = Integrate(cfC,mesh,order=1) 18 | for i in range(5): 19 | assert abs(intR[i]-i) < 1e-14 20 | assert abs(intC[i]-1j*i) < 1e-14 21 | 22 | def test_integrate_xy(): 23 | mesh = Mesh(unit_square.GenerateMesh(maxh=0.2)) 24 | intR = Integrate(x*y,mesh) 25 | intC = Integrate(1j*x*y,mesh) 26 | assert abs(intR-1./4) < 1e-14 27 | assert abs(intC- 1j*1./4) < 1e-14 28 | -------------------------------------------------------------------------------- /tests/pytest/test_vector.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | from ngsolve import * 3 | 4 | def test_vector(): 5 | n = 10 6 | a = Vector(n) 7 | assert len(a) == n 8 | for i in range(n): 9 | a[i] = i 10 | assert list(a) == list(range(n)) 11 | assert list(a-a) == [0]*n 12 | 13 | b = Vector(n) 14 | b[:] = 42 15 | b[1:8:3] = 99 16 | 17 | assert list(b)== ([42,99,42]*3)+[42] 18 | 19 | def test_vector_numpy(): 20 | try: 21 | import numpy 22 | except: 23 | pytest.skip("could not import numpy") 24 | n = 10 25 | a = Vector(n) 26 | for i in range(len(a)): 27 | a[i] = i 28 | 29 | v = a.NumPy() 30 | v[0] = 234 31 | assert a[0] == 234 32 | a[1] = 100 33 | assert v[1] == 100 34 | 35 | assert list(v) == list(a) 36 | 37 | c = Vector(n, True) 38 | c[0] = 1j 39 | d = c.NumPy() 40 | assert d[0] == c[0] 41 | d[1] = 1+3j 42 | assert d[1] == c[1] 43 | -------------------------------------------------------------------------------- /tests/timings/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | configure_file(${CMAKE_CURRENT_SOURCE_DIR}/timings.py ${CMAKE_CURRENT_BINARY_DIR}/timings.py) 2 | find_program(NUMACTL_EXECUTABLE numactl) 3 | if(NUMACTL_EXECUTABLE) 4 | set(SET_CPU_BINDING numactl -C 0) 5 | endif(NUMACTL_EXECUTABLE) 6 | 7 | add_custom_target(timings 8 | COMMAND ${SET_CPU_BINDING} ${NETGEN_PYTHON_EXECUTABLE} timings.py -s 9 | COMMAND ${NETGEN_PYTHON_EXECUTABLE} timings.py -ap 10 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} 11 | ) 12 | -------------------------------------------------------------------------------- /tests/umfpack.py: -------------------------------------------------------------------------------- 1 | from ngsolve import * 2 | from netgen.geom2d import unit_square 3 | 4 | ngsglobals.msg_level = 1 5 | 6 | mesh = Mesh (unit_square.GenerateMesh(maxh=0.2)) 7 | V = H1(mesh, order=3, dirichlet=[1,2,3,4]) 8 | u,v = V.TnT() 9 | 10 | f = LinearForm (V) 11 | f += 32 * (y*(1-y)+x*(1-x)) * v * dx 12 | a = BilinearForm (V, symmetric=False) 13 | a += grad(u) * grad(v) * dx 14 | 15 | a.Assemble() 16 | f.Assemble() 17 | 18 | u = GridFunction (V) 19 | u.vec.data = a.mat.Inverse(V.FreeDofs(), inverse="umfpack") * f.vec 20 | 21 | exact = 16*x*(1-x)*y*(1-y) 22 | print ("L2-error:", sqrt (Integrate ( (u-exact)*(u-exact), mesh))) 23 | --------------------------------------------------------------------------------