Skip to content

Commit

Permalink
Azure CI commit ref 8d780d2db08987c824a7498eb77a55e95696d4c4
Browse files Browse the repository at this point in the history
  • Loading branch information
simpeg-bot committed Nov 6, 2024
1 parent 0efa4a5 commit cd6e4e9
Show file tree
Hide file tree
Showing 6,831 changed files with 1,650,141 additions and 1 deletion.
The diff you're trying to view is too large. We only load the first 3000 changed files.
2 changes: 1 addition & 1 deletion en/latest
4 changes: 4 additions & 0 deletions en/v0.11.1/.buildinfo
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Sphinx build info version 1
# This file records the configuration used when building these files. When it is not found, a full rebuild will be done.
config: 03fcd7c1152a1a651a3bc079a15e6708
tags: 645f666f9bcd5a90fca523b33c5a78b7
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Here we compute the values of a scalar function on the z-faces. We then create
# an averaging operator to approximate the function at cell centers. We choose
# to define a scalar function that is strongly discontinuous in some places to
# demonstrate how the averaging operator will smooth out discontinuities.
#
# We start by importing the necessary packages and defining a mesh.
#
from discretize import TensorMesh
import numpy as np
import matplotlib.pyplot as plt
#
h = np.ones(40)
mesh = TensorMesh([h, h, h], x0="CCC")
#
# Create a scalar variable on z-faces
#
phi_z = np.zeros(mesh.nFz)
xyz = mesh.faces_z
phi_z[(xyz[:, 2] > 0)] = 25.0
phi_z[(xyz[:, 2] < -10.0) & (xyz[:, 0] > -10.0) & (xyz[:, 0] < 10.0)] = 50.0
#
# Next, we construct the averaging operator and apply it to
# the discrete scalar quantity to approximate the value at cell centers.
# We plot the original scalar and its average at cell centers for a
# slice at y=0.
#
Azc = mesh.average_face_z_to_cell
phi_c = Azc @ phi_z
#
# And plot the results:
#
fig = plt.figure(figsize=(11, 5))
ax1 = fig.add_subplot(121)
v = np.r_[np.zeros(mesh.nFx+mesh.nFy), phi_z] # create vector for plotting
mesh.plot_slice(v, ax=ax1, normal='Y', slice_loc=0, v_type="Fz")
ax1.set_title("Variable at z-faces", fontsize=16)
ax2 = fig.add_subplot(122)
mesh.plot_image(phi_c, ax=ax2, normal='Y', slice_loc=0, v_type="CC")
ax2.set_title("Averaged to cell centers", fontsize=16)
plt.show()
#
# Below, we show a spy plot illustrating the sparsity and mapping
# of the operator
#
fig = plt.figure(figsize=(9, 9))
ax1 = fig.add_subplot(111)
ax1.spy(Azc, ms=1)
ax1.set_title("Z-Face Index", fontsize=12, pad=5)
ax1.set_ylabel("Cell Index", fontsize=12)
plt.show()
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Here, we construct a 4 by 3 cell 2D tensor mesh and return the indices
# of the x and y-boundary faces. In this case there are 3 x-faces on each
# x-boundary, and there are 4 y-faces on each y-boundary.
#
from discretize import TensorMesh
import numpy as np
import matplotlib.pyplot as plt
#
hx = [1, 1, 1, 1]
hy = [2, 2, 2]
mesh = TensorMesh([hx, hy])
ind_Bx1, ind_Bx2, ind_By1, ind_By2 = mesh.face_boundary_indices
#
ax = plt.subplot(111)
mesh.plot_grid(ax=ax)
ax.scatter(*mesh.faces_x[ind_Bx1].T)
plt.show()
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Here we compute the values of a scalar function on the x-edges. We then create
# an averaging operator to approximate the function at cell centers. We choose
# to define a scalar function that is strongly discontinuous in some places to
# demonstrate how the averaging operator will smooth out discontinuities.
#
# We start by importing the necessary packages and defining a mesh.
#
from discretize import TensorMesh
import numpy as np
import matplotlib.pyplot as plt
h = np.ones(40)
mesh = TensorMesh([h, h], x0="CC")
#
# Then we create a scalar variable on x-edges,
#
phi_x = np.zeros(mesh.nEx)
xy = mesh.edges_x
phi_x[(xy[:, 1] > 0)] = 25.0
phi_x[(xy[:, 1] < -10.0) & (xy[:, 0] > -10.0) & (xy[:, 0] < 10.0)] = 50.0
#
# Next, we construct the averaging operator and apply it to
# the discrete scalar quantity to approximate the value at cell centers.
#
Axc = mesh.average_edge_x_to_cell
phi_c = Axc @ phi_x
#
# And plot the results,
#
fig = plt.figure(figsize=(11, 5))
ax1 = fig.add_subplot(121)
v = np.r_[phi_x, np.zeros(mesh.nEy)] # create vector for plotting function
mesh.plot_image(v, ax=ax1, v_type="Ex")
ax1.set_title("Variable at x-edges", fontsize=16)
ax2 = fig.add_subplot(122)
mesh.plot_image(phi_c, ax=ax2, v_type="CC")
ax2.set_title("Averaged to cell centers", fontsize=16)
plt.show()
#
# Below, we show a spy plot illustrating the sparsity and mapping
# of the operator
#
fig = plt.figure(figsize=(9, 9))
ax1 = fig.add_subplot(111)
ax1.spy(Axc, ms=1)
ax1.set_title("X-Edge Index", fontsize=12, pad=5)
ax1.set_ylabel("Cell Index", fontsize=12)
plt.show()
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# We create a simple mesh and refine the TreeMesh such that all cells that
# intersect the line segment path are at the given levels.
#
import discretize
import matplotlib.pyplot as plt
import matplotlib.patches as patches
mesh = discretize.TreeMesh([32, 32, 32])
mesh.max_level
# Expected:
## 5
#
# Next we define the bottom points of the prism, its heights, and the level we
# want to refine to, then refine the mesh.
#
triangle = [[0.14, 0.31, 0.21], [0.32, 0.96, 0.34], [0.87, 0.23, 0.12]]
height = 0.35
levels = 5
mesh.refine_vertical_trianglular_prism(triangle, height, levels)
#
# Now lets look at the mesh.
#
v = mesh.cell_levels_by_index(np.arange(mesh.n_cells))
fig, axs = plt.subplots(1, 3, figsize=(12,4))
mesh.plot_slice(v, ax=axs[0], normal='x', grid=True, clim=[2, 5])
mesh.plot_slice(v, ax=axs[1], normal='y', grid=True, clim=[2, 5])
mesh.plot_slice(v, ax=axs[2], normal='z', grid=True, clim=[2, 5])
plt.show()
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Here we compute the values of a vector function discretized to the edges.
# We then create an averaging operator to approximate the function at cell centers.
#
# We start by importing the necessary packages and defining a mesh.
#
from discretize import TensorMesh
import numpy as np
import matplotlib.pyplot as plt
h = 0.5 * np.ones(40)
mesh = TensorMesh([h, h], x0="CC")
#
# Then we create a discrete vector on mesh edges
#
edges_x = mesh.edges_x
edges_y = mesh.edges_y
u_ex = -(edges_x[:, 1] / np.sqrt(np.sum(edges_x ** 2, axis=1))) * np.exp(
-(edges_x[:, 0] ** 2 + edges_x[:, 1] ** 2) / 6 ** 2
)
u_ey = (edges_y[:, 0] / np.sqrt(np.sum(edges_y ** 2, axis=1))) * np.exp(
-(edges_y[:, 0] ** 2 + edges_y[:, 1] ** 2) / 6 ** 2
)
u_e = np.r_[u_ex, u_ey]
#
# Next, we construct the averaging operator and apply it to
# the discrete vector quantity to approximate the value at cell centers.
#
Aec = mesh.average_edge_to_cell_vector
u_c = Aec @ u_e
#
# And plot the results:
#
fig = plt.figure(figsize=(11, 5))
ax1 = fig.add_subplot(121)
mesh.plot_image(u_e, ax=ax1, v_type="E", view='vec')
ax1.set_title("Variable at edges", fontsize=16)
ax2 = fig.add_subplot(122)
mesh.plot_image(u_c, ax=ax2, v_type="CCv", view='vec')
ax2.set_title("Averaged to cell centers", fontsize=16)
plt.show()
#
# Below, we show a spy plot illustrating the sparsity and mapping
# of the operator
#
fig = plt.figure(figsize=(9, 9))
ax1 = fig.add_subplot(111)
ax1.spy(Aec, ms=1)
ax1.set_title("Edge Index", fontsize=12, pad=5)
ax1.set_ylabel("Cell Vector Index", fontsize=12)
plt.show()
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Here we compute the values of a scalar function on the nodes. We then create
# an averaging operator to approximate the function at the edges. We choose
# to define a scalar function that is strongly discontinuous in some places to
# demonstrate how the averaging operator will smooth out discontinuities.
#
# We start by importing the necessary packages and defining a mesh.
#
from discretize import TensorMesh
import numpy as np
import matplotlib.pyplot as plt
h = np.ones(40)
mesh = TensorMesh([h, h], x0="CC")
#
# Then we create a scalar variable on nodes,
#
phi_n = np.zeros(mesh.nN)
xy = mesh.nodes
phi_n[(xy[:, 1] > 0)] = 25.0
phi_n[(xy[:, 1] < -10.0) & (xy[:, 0] > -10.0) & (xy[:, 0] < 10.0)] = 50.0
#
# Next, we construct the averaging operator and apply it to
# the discrete scalar quantity to approximate the value on the edges.
#
Ane = mesh.average_node_to_edge
phi_e = Ane @ phi_n
#
# Plot the results,
#
fig = plt.figure(figsize=(11, 5))
ax1 = fig.add_subplot(121)
mesh.plot_image(phi_n, ax=ax1, v_type="N")
ax1.set_title("Variable at nodes")
ax2 = fig.add_subplot(122)
mesh.plot_image(phi_e, ax=ax2, v_type="E")
ax2.set_title("Averaged to edges")
plt.show()
#
# Below, we show a spy plot illustrating the sparsity and mapping
# of the operator
#
fig = plt.figure(figsize=(9, 9))
ax1 = fig.add_subplot(111)
ax1.spy(Ane, ms=1)
ax1.set_title("Node Index", fontsize=12, pad=5)
ax1.set_ylabel("Edge Index", fontsize=12)
plt.show()
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# For the 4 classifications allowable (scalar, isotropic, anistropic and tensor),
# we construct and compare the property tensor on a small 2D mesh. For this
# example, note the following:
#
# - The dimensions for all property tensors are the same
# - All property tensors, except in the case of full anisotropy are diagonal
# sparse matrices
# - For the scalar case, the non-zero elements are equal
# - For the isotropic case, the non-zero elements repreat in order for the x, y
# (and z) components
# - For the anisotropic case (diagonal anisotropy), the non-zero elements do not
# repeat
# - For the tensor caes (full anisotropy), there are off-diagonal components
#
from discretize.utils import make_property_tensor
from discretize import TensorMesh
import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl
rng = np.random.default_rng(421)
#
# Define a 2D tensor mesh
#
h = [1., 1., 1.]
mesh = TensorMesh([h, h], origin='00')
#
# Define a physical property for all cases (2D)
#
sigma_scalar = 4.
sigma_isotropic = rng.integers(1, 10, mesh.nC)
sigma_anisotropic = rng.integers(1, 10, (mesh.nC, 2))
sigma_tensor = rng.integers(1, 10, (mesh.nC, 3))
#
# Construct the property tensor in each case
#
M_scalar = make_property_tensor(mesh, sigma_scalar)
M_isotropic = make_property_tensor(mesh, sigma_isotropic)
M_anisotropic = make_property_tensor(mesh, sigma_anisotropic)
M_tensor = make_property_tensor(mesh, sigma_tensor)
#
# Plot the property tensors.
#
M_list = [M_scalar, M_isotropic, M_anisotropic, M_tensor]
case_list = ['Scalar', 'Isotropic', 'Anisotropic', 'Full Tensor']
ax1 = 4*[None]
fig = plt.figure(figsize=(15, 4))
for ii in range(0, 4):
ax1[ii] = fig.add_axes([0.05+0.22*ii, 0.05, 0.18, 0.9])
ax1[ii].imshow(
M_list[ii].todense(), interpolation='none', cmap='binary', vmax=10.
)
ax1[ii].set_title(case_list[ii], fontsize=24)
ax2 = fig.add_axes([0.92, 0.15, 0.01, 0.7])
norm = mpl.colors.Normalize(vmin=0., vmax=10.)
cbar = mpl.colorbar.ColorbarBase(
ax2, norm=norm, orientation="vertical", cmap=mpl.cm.binary
)
plt.show()
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Create two meshes with the same extent, but different divisions (the meshes
# do not have to be the same extent).
#
import numpy as np
from discretize import TensorMesh
rng = np.random.default_rng(853)
h1 = np.ones(32)
h2 = np.ones(16)*2
mesh_in = TensorMesh([h1, h1])
mesh_out = TensorMesh([h2, h2])
#
# Create a random model defined on the input mesh, and use volume averaging to
# interpolate it to the output mesh.
#
from discretize.utils import volume_average
model1 = rng.random(mesh_in.nC)
model2 = volume_average(mesh_in, mesh_out, model1)
#
# Because these two meshes' cells are perfectly aligned, but the output mesh
# has 1 cell for each 4 of the input cells, this operation should effectively
# look like averaging each of those cells values
#
import matplotlib.pyplot as plt
plt.figure(figsize=(6, 3))
ax1 = plt.subplot(121)
mesh_in.plot_image(model1, ax=ax1)
ax2 = plt.subplot(122)
mesh_out.plot_image(model2, ax=ax2)
plt.show()
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading

0 comments on commit cd6e4e9

Please sign in to comment.