Skip to content

Commit

Permalink
Prefer np.zeros over np.ndarray
Browse files Browse the repository at this point in the history
  • Loading branch information
JDBetteridge committed Oct 4, 2024
1 parent 6e97b7f commit 3831f7c
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions ngsPETSc/utils/firedrake/meshes.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,21 +160,13 @@ def curveField(self, order, tol=1e-8, CG=False):
ref.append(pt)
reference_space_points = np.array(ref)

# Map to the physical domain
physical_space_points = np.ndarray(
(ng_dimension, reference_space_points.shape[0], geom_dim)
)
curved_space_points = np.ndarray(
(ng_dimension, reference_space_points.shape[0], geom_dim)
)

# Curve the mesh on rank 0 only
if self.comm.rank == 0:
# Construct numpy arrays for physical domain data
physical_space_points = np.ndarray(
physical_space_points = np.zeros(
(ng_dimension, reference_space_points.shape[0], geom_dim)
)
curved_space_points = np.ndarray(
curved_space_points = np.zeros(
(ng_dimension, reference_space_points.shape[0], geom_dim)
)
self.netgen_mesh.CalcElementMapping(reference_space_points, physical_space_points)
Expand All @@ -189,10 +181,10 @@ def curveField(self, order, tol=1e-8, CG=False):
curved = self.comm.bcast(None, root=0)
# Construct numpy arrays as buffers to receive physical domain data
ncurved = np.sum(curved)
physical_space_points = np.ndarray(
physical_space_points = np.zeros(
(ncurved, reference_space_points.shape[0], geom_dim)
)
curved_space_points = np.ndarray(
curved_space_points = np.zeros(
(ncurved, reference_space_points.shape[0], geom_dim)
)

Expand Down

0 comments on commit 3831f7c

Please sign in to comment.