├── grudge
├── py.typed
├── version.py
├── __init__.py
├── interpolation.py
├── geometry
│ └── __init__.py
├── projection.py
├── models
│ └── __init__.py
└── shortcuts.py
├── doc
├── upload-docs.sh
├── dof_desc.rst
├── geometry.rst
├── discretization.rst
├── models.rst
├── utils.rst
├── operators.rst
├── Makefile
├── references.rst
├── index.rst
├── conf.py
└── misc.rst
├── .github
├── dependabot.yml
└── workflows
│ ├── autopush.yml
│ └── ci.yml
├── .test-conda-env-py3.yml
├── .gitignore
├── contrib
├── maxima
│ ├── ehcleanbase.mac
│ ├── em_units.mac
│ ├── bilinearmap.mac
│ ├── ehclean.mac
│ ├── ecleanbase.mac
│ ├── cns.mac
│ ├── pml.mac
│ ├── maxwellrectcav3d.mac
│ ├── maxwellbase.mac
│ ├── bgk-flow.mac
│ ├── maxwell.mac
│ ├── wave.mac
│ ├── gedney-pml.mac
│ ├── abarbanel-pml.mac
│ ├── em-modes.mac
│ ├── myhelpers.mac
│ ├── euler.mac
│ └── eclean.mac
└── notes
│ ├── mystyle.ts
│ ├── fluxfan.fig
│ ├── em-cheat.tm
│ ├── ip-primal.tm
│ └── ip-primal-nu.tm
├── .editorconfig
├── requirements.txt
├── README.rst
├── examples
├── geometry.py
├── hello-grudge.py
├── maxwell
│ └── cavities.py
├── wave
│ ├── var-propagation-speed.py
│ ├── wave-min-mpi.py
│ └── wave-op-var-velocity.py
├── advection
│ ├── weak.py
│ └── var-velocity.py
└── euler
│ ├── vortex.py
│ └── acoustic_pulse.py
├── test
├── test_trace_pair.py
├── test_metrics.py
├── mesh_data.py
├── test_euler_model.py
├── test_modal_connections.py
├── test_tools.py
└── test_dt_utils.py
├── .gitlab-ci.yml
└── pyproject.toml
/grudge/py.typed:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/doc/upload-docs.sh:
--------------------------------------------------------------------------------
1 | #! /bin/sh
2 |
3 | rsync --verbose --archive --delete _build/html/ doc-upload:doc/grudge
4 |
--------------------------------------------------------------------------------
/doc/dof_desc.rst:
--------------------------------------------------------------------------------
1 | Degree of freedom (DOF) descriptions
2 | ====================================
3 |
4 | .. automodule:: grudge.dof_desc
5 |
--------------------------------------------------------------------------------
/doc/geometry.rst:
--------------------------------------------------------------------------------
1 | Metric terms and transformations
2 | ================================
3 |
4 | .. automodule:: grudge.geometry.metrics
5 |
--------------------------------------------------------------------------------
/doc/discretization.rst:
--------------------------------------------------------------------------------
1 | Discretization Collection
2 | =========================
3 |
4 | .. module:: grudge
5 |
6 | .. automodule:: grudge.discretization
7 |
--------------------------------------------------------------------------------
/doc/models.rst:
--------------------------------------------------------------------------------
1 | Discontinuous Galerkin Models
2 | =============================
3 |
4 | Compressible Euler Equations
5 | ----------------------------
6 |
7 | .. automodule:: grudge.models.euler
8 |
--------------------------------------------------------------------------------
/.github/dependabot.yml:
--------------------------------------------------------------------------------
1 | version: 2
2 | updates:
3 | # Set update schedule for GitHub Actions
4 | - package-ecosystem: "github-actions"
5 | directory: "/"
6 | schedule:
7 | interval: "weekly"
8 |
9 | # vim: sw=4
10 |
--------------------------------------------------------------------------------
/doc/utils.rst:
--------------------------------------------------------------------------------
1 | Helper functions
2 | ================
3 |
4 | Estimating stable time-steps
5 | ----------------------------
6 |
7 | .. automodule:: grudge.dt_utils
8 |
9 | Array contexts
10 | --------------
11 |
12 | .. automodule:: grudge.array_context
13 |
14 | Miscellaneous tools
15 | -------------------
16 |
17 | .. automodule:: grudge.tools
18 |
--------------------------------------------------------------------------------
/doc/operators.rst:
--------------------------------------------------------------------------------
1 | Discontinuous Galerkin operators
2 | ================================
3 |
4 | .. automodule:: grudge.op
5 | .. automodule:: grudge.trace_pair
6 |
7 |
8 | Transferring data between discretizations
9 | =========================================
10 |
11 | .. automodule:: grudge.projection
12 |
13 | Reductions
14 | ==========
15 |
16 | .. automodule:: grudge.reductions
17 |
--------------------------------------------------------------------------------
/.test-conda-env-py3.yml:
--------------------------------------------------------------------------------
1 | name: test-conda-env-py3
2 | channels:
3 | - conda-forge
4 | - nodefaults
5 | dependencies:
6 | - git
7 | - numpy
8 | - libhwloc=2
9 | # pocl 3.1 needed for SVM functionality
10 | # pocl<7 because of https://github.com/inducer/grudge/issues/396
11 | - pocl>=3.1,<7
12 | - islpy
13 | - pyopencl
14 | - python=3
15 | - gmsh
16 | - jax
17 |
18 | # test scripts use ompi-specific arguments
19 | - openmpi
20 | - mpi4py
21 |
--------------------------------------------------------------------------------
/grudge/version.py:
--------------------------------------------------------------------------------
1 | from __future__ import annotations
2 |
3 | from importlib import metadata
4 |
5 |
6 | def _parse_version(version: str) -> tuple[tuple[int, ...], str]:
7 | import re
8 |
9 | m = re.match(r"^([0-9.]+)([a-z0-9]*?)$", VERSION_TEXT)
10 | assert m is not None
11 |
12 | return tuple(int(nr) for nr in m.group(1).split(".")), m.group(2)
13 |
14 |
15 | VERSION_TEXT = metadata.version("grudge")
16 | VERSION, VERSION_STATUS = _parse_version(VERSION_TEXT)
17 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | _build
2 | .sw[po]
3 | .*.sw[po]
4 | *~
5 | *.pyc
6 | *.pyo
7 | *.egg-info
8 | MANIFEST
9 | dist
10 | setuptools*egg
11 | setuptools.pth
12 | distribute*egg
13 | distribute*tar.gz
14 | a.out
15 | hk
16 | test/*.pdf
17 | examples/*.pdf
18 |
19 | *.dot
20 |
21 | *.vtu
22 | *.vts
23 |
24 | run-debug-*
25 |
26 | *.vtu
27 | *.pvtu
28 | *.pvd
29 | *.dot
30 | *.vtk
31 | *.silo
32 | *.dat
33 |
34 | .cache
35 | .pytest_cache
36 |
37 | # pylint stuff
38 | .pylintrc.yml
39 | .run-pylint.py
40 |
--------------------------------------------------------------------------------
/contrib/maxima/ehcleanbase.mac:
--------------------------------------------------------------------------------
1 | load("maxwellbase.mac");
2 |
3 | assume(%chi>0);
4 |
5 | ehclean_Asimp:blockmat(
6 | max_Asimp,
7 | hstack(
8 | vstack(epsinv*muinv*covect(n),zeromatrix(3,1)),
9 | vstack(zeromatrix(3,1),epsinv*muinv*covect(n))
10 | ),
11 |
12 | vstack(
13 | hstack(%chi^2*n,zeromatrix(1,3)),
14 | hstack(zeromatrix(1,3),%chi^2*n)
15 | ),
16 | zeromatrix(2,2)
17 | );
18 | ehclean_A:max_invsubst(ehclean_Asimp);
19 | [ehclean_V, ehclean_D, ehclean_invV]:max_invsubst(hypdiagonalize(ehclean_Asimp));
20 |
--------------------------------------------------------------------------------
/contrib/maxima/em_units.mac:
--------------------------------------------------------------------------------
1 | kill(all);
2 | load("myhelpers.mac");
3 | assume(m>0);
4 | assume(N>0);
5 | assume(s>0);
6 |
7 | N:kg*m/s^2;
8 |
9 | C : A*s;
10 | J : N*m;
11 | V : J/C;
12 | F : C/V;
13 | T : V*s/m^2;
14 | N : kg*m/s^2;
15 |
16 | u_c0 : m/s;
17 | u_mu0 : N / A^2;
18 | u_epsilon0 : 1/(u_c0^2*u_mu0);
19 |
20 |
21 | c0 : 299792458 * u_c0;
22 | mu0 : 4*%pi * 10^(-7) * u_mu0;
23 | epsilon0 : 1/(c0^2*mu0);
24 |
25 | u_E : V/m;
26 | u_D : C/m^2;
27 | u_B : T;
28 | u_H : A/m;
29 | u_J : A/m^2;
30 | u_t : s;
31 | u_x : m;
32 |
33 | u_sigma : u_J/u_E;
34 |
35 | u_ndE : u_E;
36 | u_ndH : sqrt(u_mu0/u_epsilon0) * u_H;
37 |
38 |
--------------------------------------------------------------------------------
/.github/workflows/autopush.yml:
--------------------------------------------------------------------------------
1 | name: Gitlab mirror
2 | on:
3 | push:
4 | branches:
5 | - main
6 |
7 | jobs:
8 | autopush:
9 | name: Automatic push to gitlab.tiker.net
10 | if: startsWith(github.repository, 'inducer/')
11 | runs-on: ubuntu-latest
12 | steps:
13 | - uses: actions/checkout@v6
14 | - run: |
15 | curl -L -O https://tiker.net/ci-support-v0
16 | . ./ci-support-v0
17 | mirror_github_to_gitlab
18 |
19 | env:
20 | GITLAB_AUTOPUSH_KEY: ${{ secrets.GITLAB_AUTOPUSH_KEY }}
21 |
22 | # vim: sw=4
23 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | # https://editorconfig.org/
2 | # https://github.com/editorconfig/editorconfig-vim
3 | # https://github.com/editorconfig/editorconfig-emacs
4 |
5 | root = true
6 |
7 | [*]
8 | indent_style = space
9 | end_of_line = lf
10 | charset = utf-8
11 | trim_trailing_whitespace = true
12 | insert_final_newline = true
13 |
14 | [*.py]
15 | indent_size = 4
16 |
17 | [*.rst]
18 | indent_size = 4
19 |
20 | [*.cpp]
21 | indent_size = 2
22 |
23 | [*.hpp]
24 | indent_size = 2
25 |
26 | # There may be one in doc/
27 | [Makefile]
28 | indent_style = tab
29 |
30 | # https://github.com/microsoft/vscode/issues/1679
31 | [*.md]
32 | trim_trailing_whitespace = false
33 |
--------------------------------------------------------------------------------
/doc/Makefile:
--------------------------------------------------------------------------------
1 | # Minimal makefile for Sphinx documentation
2 | #
3 |
4 | # You can set these variables from the command line, and also
5 | # from the environment for the first two.
6 | SPHINXOPTS ?= -n
7 | SPHINXBUILD ?= python $(shell which sphinx-build)
8 | SOURCEDIR = .
9 | BUILDDIR = _build
10 |
11 | # Put it first so that "make" without argument is like "make help".
12 | help:
13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14 |
15 | .PHONY: help Makefile
16 |
17 | # Catch-all target: route all unknown targets to Sphinx using the new
18 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19 | %: Makefile
20 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
21 |
--------------------------------------------------------------------------------
/requirements.txt:
--------------------------------------------------------------------------------
1 | numpy
2 | mpi4py
3 | git+https://github.com/inducer/pytools.git#egg=pytools
4 | git+https://github.com/inducer/pymbolic.git#egg=pymbolic
5 | git+https://github.com/inducer/islpy.git#egg=islpy
6 | git+https://github.com/inducer/pyopencl.git#egg=pyopencl
7 | git+https://github.com/inducer/loopy.git#egg=loopy
8 | git+https://github.com/inducer/meshpy.git#egg=meshpy
9 | git+https://github.com/inducer/modepy.git#egg=modepy
10 | git+https://github.com/inducer/arraycontext.git#egg=arraycontext
11 | git+https://github.com/inducer/meshmode.git#egg=meshmode
12 | git+https://github.com/inducer/pyvisfile.git#egg=pyvisfile
13 | git+https://github.com/inducer/pymetis.git#egg=pymetis
14 | git+https://github.com/illinois-ceesd/logpyle.git#egg=logpyle
15 | git+https://github.com/inducer/pytato.git#egg=pytato
16 |
17 | # for test_wave_dt_estimate
18 | sympy
19 |
--------------------------------------------------------------------------------
/doc/references.rst:
--------------------------------------------------------------------------------
1 | References
2 | ==========
3 |
4 | ..
5 | When adding references here, please use the demonstrated format:
6 | [FirstAuthor_pubyear]
7 |
8 | .. [Shewchuk_2002] J. R. Shewchuk (2002),
9 | *What Is a Good Linear Element? - Interpolation, Conditioning, Quality Measures*,
10 | In Proceedings of the 11th International Meshing Roundtable.
11 | `(link) `__
12 | `(slides) `__
13 |
14 | .. [Hesthaven_2008] J. S. Hesthaven and T. Warburton (2008),
15 | *Nodal Discontinuous Galerkin Methods: Algorithms, Analysis, and Applications*,
16 | Springer.
17 | `(doi) `__
18 |
19 | .. [Chan_2016] J. Chan, R. J. Hewett, and T. Warburton (2016),
20 | *Weight-Adjusted Discontinuous Galerkin Methods: Curvilinear Meshes*,
21 | SIAM Journal on Scientific Computing.
22 | `(doi) `__
23 |
--------------------------------------------------------------------------------
/contrib/maxima/bilinearmap.mac:
--------------------------------------------------------------------------------
1 | kill(all);
2 | lflatten(l):=apply(append, l);
3 | dims:3;
4 | origpoints: [[-1],[1]];
5 | for i:2 thru dims do
6 | origpoints:lflatten(
7 | makelist(
8 | makelist(
9 | append(opi, [j])
10 | ,j, [-1, 1]
11 | ),
12 | opi, origpoints));
13 | points : makelist(ascii(97+i), i, 0, length(origpoints)-1);
14 |
15 | vars:makelist(concat(v,ascii(97+i)), i, 0, dims-1);
16 | mapargs:append(
17 | [1], vars,
18 | lflatten(
19 | makelist(
20 | makelist(vars[i]*vars[j], j, i+1, length(vars)),
21 | i, 1, length(vars)
22 | )
23 | )
24 | );
25 |
26 | /* Idea: (x,y)^T = MAT*(1,u,v,uv) */
27 | mapmat:genmatrix(mm, dims, length(mapargs));
28 |
29 | f:mapmat.mapargs;
30 |
31 | myjacobian(f, vars):=genmatrix(
32 | lambda([i,j], diff(f[i], vars[j])),
33 | length(f), length(vars));
34 |
35 | fjac:myjacobian(f, vars);
36 |
37 | print("bilinear map jacobian:");
38 | print(fjac);
39 | print("bilinear map jacobian det:");
40 | print(expand(determinant(fjac)));
41 |
--------------------------------------------------------------------------------
/contrib/maxima/ehclean.mac:
--------------------------------------------------------------------------------
1 | kill(all);
2 | load("ehcleanbase.mac");
3 |
4 | /* ------------------------------------------------------------------------- */
5 | /* flux */
6 | /* ------------------------------------------------------------------------- */
7 |
8 | ehclean_Dinc:ratsubst(c,1/(sqrt(%epsilon)*sqrt(%mu)), ehclean_D);
9 | print(ehclean_Dinc);
10 | ehclean_sflux:hyp_upwind_flux([-%chi*c,-c,c,%chi*c], ehclean_Dinc);
11 |
12 | print("eh-clean system flux in terms of characteristic variables:");
13 | print(covect(ehclean_sflux));
14 |
15 | /* FIXME: ehclean_V should not depend on epsilon and mu, but it does
16 | For now, make cp and cm equal. */
17 | /*
18 | ehclean_sflux:subst(
19 | [cp=1/(sqrt(%epsilon)*sqrt(%mu)),
20 | cm=1/(sqrt(%epsilon)*sqrt(%mu)),
21 | %chip=%chi,
22 | %chim=%chi],
23 | ehclean_sflux);
24 |
25 | print("e-clean system flux in terms of physical variables:");
26 | ehclean_wflux:fullhypsimp(ehclean_V.ev(ehclean_sflux,
27 | [sm=ehclean_sminw,sp=ehclean_spinw]));
28 | print(ehclean_wflux);
29 | */
30 |
--------------------------------------------------------------------------------
/doc/index.rst:
--------------------------------------------------------------------------------
1 | Welcome to grudge's Documentation!
2 | ==================================
3 |
4 | Here's an example to solve the PDE
5 |
6 | .. math::
7 | \begin{cases}
8 | u_t + 2\pi u_x = 0, \\
9 | u(0, t) = -\sin(2\pi t), \\
10 | u(x, 0) = \sin(x),
11 | \end{cases}
12 |
13 | on the domain :math:`x \in [0, 2\pi]`. We closely follow Chapter 3 of
14 | [Hesthaven_2008]_.
15 |
16 |
17 | .. literalinclude:: ../examples/hello-grudge.py
18 | :start-after: BEGINEXAMPLE
19 | :end-before: ENDEXAMPLE
20 |
21 | Plotting numerical solution ``uh`` in results in
22 |
23 | .. plot:: ../examples/hello-grudge.py
24 |
25 | Contents:
26 |
27 | .. toctree::
28 | :maxdepth: 2
29 |
30 | discretization
31 | dof_desc
32 | geometry
33 | operators
34 | utils
35 | models
36 | references
37 | misc
38 | 🚀 Github
39 | 💾 Download Releases
40 |
41 | Indices and Tables
42 | ==================
43 |
44 | * :ref:`genindex`
45 | * :ref:`modindex`
46 | * :ref:`search`
47 |
--------------------------------------------------------------------------------
/contrib/maxima/ecleanbase.mac:
--------------------------------------------------------------------------------
1 | load("maxwellbase.mac");
2 |
3 | assume(%chi>0);
4 |
5 | /*
6 | eclean_Asimp:blockmat(
7 | max_Asimp,
8 | vstack(epsinv*muinv*covect(n),constmatrix(3,1,0)),
9 | hstack(%chi^2*n,constmatrix(1,3,0)),
10 | zeromatrix(1,1)
11 | );
12 | */
13 |
14 | eclean_Asimp:blockmat(
15 | max_Asimp,
16 | vstack(%chi*sqrt(epsinv*muinv)*covect(n),constmatrix(3,1,0)),
17 | hstack(%chi*sqrt(epsinv*muinv)*n,constmatrix(1,3,0)),
18 | zeromatrix(1,1)
19 | );
20 |
21 | [eclean_V, eclean_D, eclean_invV]:max_invsubst(hypdiagonalize(eclean_Asimp));
22 | eclean_A:max_invsubst(eclean_Asimp);
23 |
24 | eclean_wm:vstack(max_wm,[%phi[m]]);
25 | eclean_wp:vstack(max_wp,[%phi[p]]);
26 |
27 | eclean_sm:makelist(sm[i],i,1,length(eclean_D));
28 | eclean_sp:makelist(sp[i],i,1,length(eclean_D));
29 |
30 | eclean_sminw:hypsimp(eclean_invV.eclean_wm);
31 | eclean_spinw:hypsimp(eclean_invV.eclean_wp);
32 |
33 | eclean_wmins:hypsimp(eclean_V.eclean_sm);
34 | eclean_wpins:hypsimp(eclean_V.eclean_sp);
35 |
36 | eclean_Emins:makelist(eclean_wmins[i,1],i,1,3);
37 | eclean_Hmins:makelist(eclean_wmins[i,1],i,4,6);
38 | eclean_phimins:eclean_wmins[7,1];
39 |
--------------------------------------------------------------------------------
/contrib/notes/mystyle.ts:
--------------------------------------------------------------------------------
1 |
2 |
3 |