MCPcopy Create free account
hub / github.com/PyMesh/PyMesh / compute_divergence

Function compute_divergence

scripts/geodesic.py:106–119  ·  view source on GitHub ↗
(mesh, X)

Source from the content-addressed store, hash-verified

104 return np.array(grad);
105
106def compute_divergence(mesh, X):
107 cotans = mesh.get_attribute("cotan").reshape((-1, 3));
108 edges = mesh.get_attribute("edges").reshape((-1, 3, 3));
109 div_X = np.zeros(mesh.num_vertices);
110
111 for fi,f in enumerate(mesh.faces):
112 x_fi = X[fi];
113 for i in range(3):
114 j = (i+1) % 3;
115 k = (i+2) % 3;
116 div_X[f[i]] += cotans[fi, k] * np.dot(x_fi, edges[fi, i]) / 2.0;
117 div_X[f[i]] += cotans[fi, j] * np.dot(x_fi,-edges[fi, k]) / 2.0;
118
119 return div_X;
120
121def main():
122 args = parse_args();

Callers 1

mainFunction · 0.85

Calls 2

enumerateFunction · 0.85
get_attributeMethod · 0.45

Tested by

no test coverage detected