From 5cd98446e5927f55e949267cc807cd18512623ea Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Fri, 30 Aug 2019 21:48:30 -0500 Subject: [PATCH 1/7] Add Azure Pipelines, attempt 1 --- .test-conda-env-py3.yml | 32 ++++++++++++++++++++ README.rst | 9 ++++-- azure-pipelines.yml | 66 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 105 insertions(+), 2 deletions(-) create mode 100644 .test-conda-env-py3.yml create mode 100644 azure-pipelines.yml diff --git a/.test-conda-env-py3.yml b/.test-conda-env-py3.yml new file mode 100644 index 00000000..cd7ca6a9 --- /dev/null +++ b/.test-conda-env-py3.yml @@ -0,0 +1,32 @@ +name: test-conda-env +channels: +- conda-forge +- defaults + +dependencies: +- python=3 +- git +- conda-forge::numpy +- pocl +- mako +- pyopencl +- islpy + +# Only needed to make pylint succeed +- matplotlib + +- pip +- pip: + - git+https://github.com/inducer/pymbolic + - git+https://github.com/inducer/loopy + + - git+https://gitlab.tiker.net/inducer/gmsh_interop.git + - git+https://gitlab.tiker.net/inducer/modepy.git + + # required by pytential, which is in turn needed for some tests + - git+https://gitlab.tiker.net/inducer/boxtree.git + - git+https://gitlab.tiker.net/inducer/sumpy.git + - git+https://gitlab.tiker.net/inducer/pytential.git + + # requires pymetis for tests for partition_mesh + - git+https://gitlab.tiker.net/inducer/pymetis.git diff --git a/README.rst b/README.rst index 1a033e2e..b012a218 100644 --- a/README.rst +++ b/README.rst @@ -2,9 +2,14 @@ meshmode: High-Order Meshes and Discontinuous Function Spaces ============================================================= .. image:: https://gitlab.tiker.net/inducer/meshmode/badges/master/pipeline.svg - :target: https://gitlab.tiker.net/inducer/meshmode/commits/master + :alt: Gitlab Build Status + :target: https://gitlab.tiker.net/inducer/meshmode/commits/master +.. image:: https://dev.azure.com/ak-spam/inducer/_apis/build/status/inducer.meshmode?branchName=master + :alt: Azure Build Status + :target: https://dev.azure.com/ak-spam/inducer/_build/latest?definitionId=14&branchName=master .. image:: https://badge.fury.io/py/meshmode.png - :target: http://pypi.python.org/pypi/meshmode + :alt: Python Package Index Release Page + :target: https://pypi.org/project/meshmode/ * `Source code on Github `_ * `Documentation `_ diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 00000000..ede72708 --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,66 @@ +jobs: +- + job: 'Python2' + pool: + vmImage: 'ubuntu-latest' + + steps: + - + script: | + set -e + sed 's/python=3/python=2.7/' .test-conda-env-py3.yml > .test-conda-env-py2.yml + cat .test-conda-env-py2.yml + CONDA_ENVIRONMENT=.test-conda-env-py2.yml + curl -L -O -k https://gitlab.tiker.net/inducer/ci-support/raw/master/build-and-test-py-project-within-miniconda.sh + . ./build-and-test-py-project-within-miniconda.sh + + displayName: 'Pytest Conda' + - + task: PublishTestResults@2 + inputs: + testResultsFormat: 'JUnit' + testResultsFiles: 'test/pytest.xml' + +- + job: 'Python3' + pool: + vmImage: 'ubuntu-latest' + + steps: + - + script: | + set -e + CONDA_ENVIRONMENT=.test-conda-env-py3.yml + curl -L -O -k https://gitlab.tiker.net/inducer/ci-support/raw/master/build-and-test-py-project-within-miniconda.sh + . ./build-and-test-py-project-within-miniconda.sh + + displayName: 'Pytest Conda' + + - + task: PublishTestResults@2 + inputs: + testResultsFormat: 'JUnit' + testResultsFiles: 'test/pytest.xml' + +- + job: 'Flake8' + pool: + vmImage: 'ubuntu-latest' + strategy: + matrix: + Python37: + python.version: '3.7' + + steps: + - + task: UsePythonVersion@0 + inputs: + versionSpec: '$(python.version)' + + - + script: | + set -e + curl -L -O -k https://gitlab.tiker.net/inducer/ci-support/raw/master/prepare-and-run-flake8.sh + . ./prepare-and-run-flake8.sh pyopencl test + + displayName: 'Flake8' -- GitLab From 5da6f19336e39c7ed49cf9edd1836d51f827aba6 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Fri, 30 Aug 2019 21:54:42 -0500 Subject: [PATCH 2/7] Conda env file: Add cython for pytential --- .test-conda-env-py3.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.test-conda-env-py3.yml b/.test-conda-env-py3.yml index cd7ca6a9..26220a4b 100644 --- a/.test-conda-env-py3.yml +++ b/.test-conda-env-py3.yml @@ -12,6 +12,9 @@ dependencies: - pyopencl - islpy +# for Pytential +- cython + # Only needed to make pylint succeed - matplotlib -- GitLab From c4ecf65caf753f310f76617bc298a130fd3070a4 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Fri, 30 Aug 2019 22:00:58 -0500 Subject: [PATCH 3/7] Add pybind11 to conda env file for pymetis --- .test-conda-env-py3.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.test-conda-env-py3.yml b/.test-conda-env-py3.yml index 26220a4b..587b7c91 100644 --- a/.test-conda-env-py3.yml +++ b/.test-conda-env-py3.yml @@ -15,6 +15,9 @@ dependencies: # for Pytential - cython +# for pymetis +- pybind11 + # Only needed to make pylint succeed - matplotlib -- GitLab From 755b1a07ac076f20469f50baee22e72d8a8e693b Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Fri, 30 Aug 2019 22:15:14 -0500 Subject: [PATCH 4/7] Add gmsh to conda env file --- .test-conda-env-py3.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.test-conda-env-py3.yml b/.test-conda-env-py3.yml index 587b7c91..a7d4c6d4 100644 --- a/.test-conda-env-py3.yml +++ b/.test-conda-env-py3.yml @@ -11,6 +11,7 @@ dependencies: - mako - pyopencl - islpy +- gmsh # for Pytential - cython -- GitLab From 61108b5384b961da6c9d0becb12be15fcee5fd5f Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Thu, 5 Sep 2019 10:16:59 -0500 Subject: [PATCH 5/7] Fix Azure flake8 call --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index ede72708..4f83fdd1 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -61,6 +61,6 @@ jobs: script: | set -e curl -L -O -k https://gitlab.tiker.net/inducer/ci-support/raw/master/prepare-and-run-flake8.sh - . ./prepare-and-run-flake8.sh pyopencl test + . ./prepare-and-run-flake8.sh meshmode test displayName: 'Flake8' -- GitLab From f06a1ae597c88ea45440709b1d4a1d1c25fd1014 Mon Sep 17 00:00:00 2001 From: "[6~" Date: Sun, 10 Nov 2019 22:49:01 -0600 Subject: [PATCH 6/7] generate_icosphere: Add uniform_refinement_rounds argument --- meshmode/mesh/generation.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/meshmode/mesh/generation.py b/meshmode/mesh/generation.py index ddecc69f..80289cac 100644 --- a/meshmode/mesh/generation.py +++ b/meshmode/mesh/generation.py @@ -427,17 +427,26 @@ def generate_icosahedron(r, order): # {{{ generate_icosphere -def generate_icosphere(r, order): +def generate_icosphere(r, order, uniform_refinement_rounds=0): mesh = generate_icosahedron(r, order) - grp, = mesh.groups + if uniform_refinement_rounds: + # These come out conformal, so we're OK to use the faster refiner. + from meshmode.mesh.refinement import RefinerWithoutAdjacency + refiner = RefinerWithoutAdjacency(mesh) + for i in range(uniform_refinement_rounds): + refiner.refine_uniformly() + + mesh = refiner.get_current_mesh() + vertices = mesh.vertices * r / np.sqrt(np.sum(mesh.vertices**2, axis=0)) + grp, = mesh.groups grp = grp.copy( nodes=grp.nodes * r / np.sqrt(np.sum(grp.nodes**2, axis=0))) from meshmode.mesh import Mesh return Mesh( - mesh.vertices, [grp], + vertices, [grp], is_conforming=True) # }}} -- GitLab From 8ddf62a56504e1f5aa46e3342ca6ca76b12875de Mon Sep 17 00:00:00 2001 From: "[6~" Date: Sun, 10 Nov 2019 22:49:40 -0600 Subject: [PATCH 7/7] Visualizer: add show_scalar_in_matplotlib_3d --- meshmode/discretization/visualization.py | 71 ++++++++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/meshmode/discretization/visualization.py b/meshmode/discretization/visualization.py index 003bb834..e985f3ff 100644 --- a/meshmode/discretization/visualization.py +++ b/meshmode/discretization/visualization.py @@ -101,6 +101,7 @@ class _VisConnectivityGroup(Record): class Visualizer(object): """ .. automethod:: show_scalar_in_mayavi + .. automethod:: show_scalar_in_matplotlib_3d .. automethod:: write_vtk_file """ @@ -348,6 +349,76 @@ class Visualizer(object): # }}} + # {{{ matplotlib 3D + + def show_scalar_in_matplotlib_3d(self, field, **kwargs): + import matplotlib.pyplot as plt + + # This import also registers the 3D projection. + import mpl_toolkits.mplot3d.art3d as art3d + + do_show = kwargs.pop("do_show", True) + vmin = kwargs.pop("vmin", None) + vmax = kwargs.pop("vmax", None) + norm = kwargs.pop("norm", None) + + with cl.CommandQueue(self.vis_discr.cl_context) as queue: + nodes = self.vis_discr.nodes().with_queue(queue).get() + + field = self._resample_and_get(queue, field) + + assert nodes.shape[0] == self.vis_discr.ambient_dim + + vis_connectivity, = self._vis_connectivity() + + fig = plt.gcf() + ax = fig.gca(projection="3d") + + had_data = ax.has_data() + + if self.vis_discr.dim == 2: + nodes = list(nodes) + # pad to 3D with zeros + while len(nodes) < 3: + nodes.append(0*nodes[0]) + + from matplotlib.tri.triangulation import Triangulation + tri, args, kwargs = \ + Triangulation.get_from_args_and_kwargs( + *nodes, + triangles=vis_connectivity.vis_connectivity.reshape(-1, 3)) + + triangles = tri.get_masked_triangles() + xt = nodes[0][triangles] + yt = nodes[1][triangles] + zt = nodes[2][triangles] + verts = np.stack((xt, yt, zt), axis=-1) + + fieldt = field[triangles] + + polyc = art3d.Poly3DCollection(verts, **kwargs) + + # average over the three points of each triangle + avg_field = fieldt.mean(axis=1) + polyc.set_array(avg_field) + + if vmin is not None or vmax is not None: + polyc.set_clim(vmin, vmax) + if norm is not None: + polyc.set_norm(norm) + + ax.add_collection(polyc) + ax.auto_scale_xyz(xt, yt, zt, had_data) + + else: + raise RuntimeError("meshes of bulk dimension %d are currently " + "unsupported" % self.vis_discr.dim) + + if do_show: + plt.show() + + # }}} + def make_visualizer(queue, discr, vis_order, element_shrink_factor=None): from meshmode.discretization import Discretization -- GitLab