Inner Products#
By using the weak formulation of many of the PDEs in geophysical applications, we can rapidly develop discretizations. Much of this work, however, needs a good understanding of how to approximate inner products on our discretized meshes. We will define the inner product as:
where a and b are either scalars or vectors.
Note
The InnerProducts class is a base class providing inner product matrices for meshes and cannot run on its own.
Example problem for DC resistivity#
We will start with the formulation of the Direct Current (DC) resistivity problem in geophysics.
In the following discretization,
We can define in weak form by integrating with a general face function
Here we can integrate the right side by parts,
and rearrange it, and apply the Divergence theorem.
We can then discretize for every cell:
Note
We have discretized the dot product above, but remember that we do not
really have a single vector
Regardless of how we choose to approximate this dot product, we can represent this in vector form (again this is for every cell), and will generalize for the case of anisotropic (tensor) sigma.
We multiply by square-root of volume on each side of the tensor conductivity
to keep symmetry in the system. Here
Here the
Or, when generalizing to the entire mesh and dropping our general face function:
By defining the faceInnerProduct (8 combinations of fluxes in 3D, 4 in 2D, 2 in 1D) to be:
Where
Here each
Note
This is actually completed for each cell in the mesh at the same time, and the full matrices are returned.
If returnP=True
is requested in any of these methods the projection matrices are returned as a list ordered by nodes around which the fluxes were approximated:
# In 3D
P = [P000, P100, P010, P110, P001, P101, P011, P111]
# In 2D
P = [P00, P10, P01, P11]
# In 1D
P = [P0, P1]
The derivation for edgeInnerProducts
is exactly the same, however, when we
approximate the integral using the fields around each node, the projection
matrices look a bit different because we have 12 edges in 3D instead of just 6
faces. The interface to the code is exactly the same.
Defining Tensor Properties#
For 3D:
Depending on the number of columns (either 1, 3, or 6) of mu, the material property is interpreted as follows:
For 2D:
Depending on the number of columns (either 1, 2, or 3) of mu, the material property is interpreted as follows:
Structure of Matrices#
Both the isotropic, and anisotropic material properties result in a diagonal mass matrix. Which is nice and easy to invert if necessary, however, in the fully anisotropic case which is not aligned with the grid, the matrix is not diagonal. This can be seen for a 3D mesh in the figure below.
import discretize
import numpy as np
import matplotlib.pyplot as plt
mesh = discretize.TensorMesh([10,50,3])
m1 = np.random.rand(mesh.nC)
m2 = np.random.rand(mesh.nC,3)
m3 = np.random.rand(mesh.nC,6)
M = list(range(3))
M[0] = mesh.get_face_inner_product(m1)
M[1] = mesh.get_face_inner_product(m2)
M[2] = mesh.get_face_inner_product(m3)
plt.figure(figsize=(13,5))
for i, lab in enumerate(['Isotropic','Anisotropic','Tensor']):
plt.subplot(131 + i)
plt.spy(M[i],ms=0.5,color='k')
plt.tick_params(axis='both',which='both',labeltop='off',labelleft='off')
plt.title(lab + ' Material Property')
plt.show()
(Source code
, png
, pdf
)

Taking Derivatives#
We will take the derivative of the fully anisotropic tensor for a 3D mesh, the
other cases are easier and will not be discussed here. Let us start with one
part of the sum which makes up
Here we will let
Now it is easy to take the derivative with respect to any one of the
parameters, for example,
Whereas
These are computed for each of the 8 projections, horizontally concatenated, and returned.