Reputation: 141
I'm writing a Finite element method based on Whitney p-forms, where the solution coefficients are defined on edges and faces.
For example, the electric field can be approximated as
vec(E) = sum e_i vec(W)_i
where the sum is over the edges (e.g. 3 for a triangle).
If I have a function that returns Ex, Ey, and Ez in the computational domain, how do I obtain the e_i coefficients?
Upvotes: 0
Views: 41
Reputation: 141
If anyone is interested, here is a Python code that approximates the degrees of freedom on edges (e_i) and faces for a lowest-order element of the first kind. Here, the field is a function that returns a numpy array of Fx, Fy, and Fz, and v1, v2, and v3 are the coordinates of the vertices comprising the edge and faces.
def get_edge_dof(field, v1, v2):
"""Numerically integrates the field function over an edge."""
return 0.5 * np.dot(field(v1) + field(v2), v2 - v1)
def get_face_dof(field, v1, v2, v3):
"""Numerically integrates the field function over a face."""
c = (v1 + v2 + v3) / 3
return 0.5 * np.dot(field(c), np.cross(v2 - v1, v3 - v1))
Upvotes: 0