discretize.CylindricalMesh.average_edge_to_face_vector#
- property CylindricalMesh.average_edge_to_face_vector#
Averaging operator from edges to faces (vector quantities).
This property constructs the averaging operator that independently maps the Cartesian components of vector quantities from edges to faces. This averaging operators is used when a discrete vector quantity defined on mesh edges must be approximated at faces. The operation is implemented as a matrix vector product, i.e.:
u_f = Aef @ u_e
Once constructed, the operator is stored permanently as a property of the mesh.
- Returns
- (
n_faces
,n_edges
)scipy.sparse.csr_matrix
The vector averaging operator from edges to faces.
- (
Notes
Let \(\mathbf{u_e}\) be the discrete representation of a vector quantity whose Cartesian components are defined on their respective edges; e.g. the x-component is defined on x-edges. average_edge_to_face_vector constructs a discrete linear operator \(\mathbf{A_{ef}}\) that projects each Cartesian component of \(\mathbf{u_e}\) to its corresponding face, i.e.:
\[\mathbf{u_f} = \mathbf{A_{ef}} \, \mathbf{u_e}\]where \(\mathbf{u_f}\) is a discrete vector quantity whose Cartesian components are defined on their respective faces; e.g. the x-component is defined on x-faces.
Examples
Here we compute the values of a vector function discretized to the edges. We then create an averaging operator to approximate the function on the faces.
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")
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 the faces.
>>> Aef = mesh.average_edge_to_face_vector >>> u_f = Aef @ u_e
Plot the results,
(Source code, png, pdf)
Below, we show a spy plot illustrating the sparsity and mapping of the operator