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

Function solve_harmonic

python/pymesh/meshutils/generate_minimal_surface.py:10–30  ·  view source on GitHub ↗
(L, bd_indices, bd_values)

Source from the content-addressed store, hash-verified

8from ..meshio import form_mesh
9
10def solve_harmonic(L, bd_indices, bd_values):
11 N = L.shape[0]
12 m = bd_values.shape[1]
13 x = np.zeros((N, m))
14 x[bd_indices,:] = bd_values
15 rhs = -L * x
16
17 mask = np.ones(N, dtype=bool)
18 mask[bd_indices] = False
19 L = L[mask,:][:, mask]
20 rhs = rhs[mask,:]
21
22 solver = SparseSolver.create("LDLT")
23 solver.compute(L)
24 sol = solver.solve(rhs)
25
26 full_solution = np.zeros((N, m))
27 full_solution[bd_indices, :] = bd_values
28 full_solution[mask, :] = sol
29
30 return full_solution
31
32def generate_minimal_surface(loop, resolution=10):
33 """ Generate a minimal surface (e.g. soap membrane) to fill the region

Callers 1

generate_minimal_surfaceFunction · 0.85

Calls 3

createMethod · 0.45
computeMethod · 0.45
solveMethod · 0.45

Tested by

no test coverage detected