MCPcopy Create free account
hub / github.com/FEniCS/dolfinx / random_point_in_reference

Function random_point_in_reference

python/test/unit/fem/test_interpolation.py:53–76  ·  view source on GitHub ↗
(cell_type)

Source from the content-addressed store, hash-verified

51
52
53def random_point_in_reference(cell_type):
54 if cell_type == CellType.interval:
55 return (random.random(), 0, 0)
56 elif cell_type == CellType.triangle:
57 x, y = random.random(), random.random()
58 # If point is outside cell, move it back inside
59 if x + y > 1:
60 x, y = 1 - x, 1 - y
61 return (x, y, 0)
62 elif cell_type == CellType.tetrahedron:
63 x, y, z = random.random(), random.random(), random.random()
64 # If point is outside cell, move it back inside
65 if x + y > 1:
66 x, y = 1 - x, 1 - y
67 if y + z > 1:
68 y, z = 1 - z, 1 - x - y
69 if x + y + z > 1:
70 x, z = 1 - x - y, x + y + z - 1
71 return (x, y, z)
72 elif cell_type == CellType.quadrilateral:
73 x, y = random.random(), random.random()
74 return (x, y, 0)
75 elif cell_type == CellType.hexahedron:
76 return (random.random(), random.random(), random.random())
77
78
79def random_point_in_cell(mesh):

Callers 1

random_point_in_cellFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected