Releases: simpeg/discretize
NumPy Build & Bug Fixes
summary of changes
This is a patch to fix a few bugs that have popped up over the last few months, as well as a single function addition to output only the model for a TreeMesh.
Also we have dropped testing of discretize on Python 2.7 as it is officially in end-of-life stage (as of January 1st, 2020).
-
From #191:
Enables discretize to be installed on a system without NumPy present beforehand (for example when pip installing discretize).
It also contains a small update to the curvilinear mesh view that updates that function to be in line with the otherplotImagefunctions. -
From #189:
Bugfix. Slicer failed ifxslicewas provided without ayslice, because of wrong comparison.
Before, if you provided a homogenous model, it looked like this:

So the colour in the xy- and xz-plots is wrong. As soon as you scroll, the colour in the yz-plot will change to the wrong colour too.
With the bug-fix, they all get the right colour, and will remain correct if scrolling:

The bug only affects homogeneous fullspaces, which caused an issue with the range used bycolorbar(). -
From #187:
We can output models through thewriteUBCmethod of the TreeMesh. However, we might want, for symmetry withTensorMesh, also have thewriteModelUBCfunction, which will only write out the model.
serialization of meshes
summary of changes
-
Update instantiation of basemesh so meshes can be formed from their serialized state, e.g.
mesh = discretize.BaseMesh.deserialize(mesh_json)will have the value of
_nstored, thus,ndoes not need to be provided on instantiation -
Update the x0 property on the TreeMesh so that it goes through the
-
Allow
complexscalars to return true in theisScalarutil, as well asnumpy.number(rather than specificallynp.int,np.float) -
Add testing on the serialization / deserialization of meshes
Tree functions
Updates
- Several of the functions are used to integrate line source terms for FDEM.
- The TreeCell object now exposes it's node/edge/face indices to python, a TreeCell object can be obtained by directly indexing the TreeMesh.
- Added much documentation to the TreeMesh objects and their functions.
- The TreeMesh plotSlice and plotGrid functions now have the same calling conventions as the respective TensorMesh functions
0.4.7
- from pr: #172
- commits from: @dccowan
- review from: @sarahgarre, @sgkang, @lheagy
Tutorials in the discretize docs
Addition of tutorials for:
- Mesh generation (tensor, cyl and tree)
- Averaging and differential operators
- Discretized approximations to inner products using finite volume (basic, constitutive relations, differential operators and an advanced section)
- Solving PDE examples
Update TensorMesh-OMF interface
- from pr #174
- commits from @banesullivan
- review from @lheagy
Overview
This release adds full support for going back and forth between OMF and discretize.TensorMesh. The OMF support implemented in a previous release only went one way (disscretize ➡️ OMF) and had a bug that messed up the spatial reference of the OMF mesh. This release makes it seamless to go back and forth (discretize to_omf(models) method and load your TensorMeshs into other software that supports OMF (e.g. Leapfrog)!
Notes
- At the moment, only
TensorMeshs are supported by OMF - OMFv2 should bring more support for Curvilinear and Tree meshes. When that's released we can fill in the methods that currently raises a
NotImplementedError - These changes makes updates to the
TensorMesh-OMF interface to make going to/from OMF/discretize more fluid.
Example
import discretize
import omf
import numpy as np
# Make a TensorMesh
h = np.ones(16)
mesh = discretize.TensorMesh([h, 2*h, 3*h])
vec = np.arange(mesh.nC)
models = {'arange': vec}
# Make an OMF Element
omf_element = mesh.to_omf(models)
# Use OMF to save that element to an OMF project
proj = omf.Project(
name='My project',
description='The most awesome project I have ever worked '\
'on and this is a lengthy description of how '\
'awesome it is.',
)
# Add the volume element
proj.elements = [omf_element,]
# Verify all is good
assert proj.validate()
# Write it out
omf.OMFWriter(proj, 'myproject.omf')And now you can use the .omf project file with your tensor mesh or many tensor meshes in your favorite software that supports OMF (e.g. Leapfrog).
Or you could verify this all worked with omfvista:
import omfvista
foo = omfvista.load_project('myproject.omf')
foo.plot()Make matplotlib a soft dependency
Make matplotlib a soft dependency; reasoning:
- it is "only" used for the plotting of meshes, which is sort of a relatively small (yet important) part of the whole discretize scope.
- it would help to install discretize on minimal conda-environments for running models on a server, without having to install matplotlib.
This is achieved by
- using a decorator on functions where matplotlib is required
- removing matplotlib from the setup.py
`plot_3d_slicer` improvements; `refine_mesh_xyz` bug fix; `VTK` interaction improvements
Commits: @dccowan ; @prisae ; @banesullivan ; @lheagy
Reviewers: @lheagy ; @thast
Merged from PR #159 #160 #163 #166
- Add
(x,y,z)limto limit the axis. It works with the interactive tools and the home-button will reset to the provided limits. Resolves #165.
-
Fix Broken Example: plot_3d_slicer
-
Fix
refine_mesh_xyzfor Tree mesh class -
Change model array shape check for VTK mixin: It must be an array of size
nC
PyVista updates & deploy docs to GitHub Pages
- from pr: #152
- commits from: @banesullivan
- review from: @lheagy
Changes
- Update
discretizeto work with PyVista (previouslyvtki) - Enable the PyVista 3D visualization examples to be run when making the docs on CI services
- Switch the documentation hosting service to GitHub Pages from Read The Docs
- New
InterfaceOMFmixin for convertingdiscretizemeshes to Open Mining Format (OMF) objects pep8refactoring ofmixins- Drop Windows testing on Python 3.5
Add representation methods for `TensorMesh`
- from pr: #143
- commits from: @prisae, @banesullivan
- review from: @lheagy
This PR adds html and non-html representations which should be more generally applicable, for small and big TensorMesh's.
Based on work by @banesullivan on vtki and @prisae on the printversion-tool.


