Skip to content

Commit b97acb9

Browse files
authored
Merge pull request #69 from python-hydro/norm2
eliminate norm from the Grid2d class
2 parents 9a816e3 + 3de596c commit b97acb9

4 files changed

Lines changed: 138 additions & 35 deletions

File tree

mesh/array_indexer.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,13 @@ def norm(self, n=0):
103103
"""
104104
c = len(self.shape)
105105
if c == 2:
106-
return self.g.norm(self)
106+
return np.sqrt(self.g.dx * self.g.dy *
107+
np.sum((self[self.g.ilo:self.g.ihi+1, self.g.jlo:self.g.jhi+1]**2).flat))
108+
107109
else:
108-
return self.g.norm(self[:, :, n])
110+
_tmp = self[:, :, n]
111+
return np.sqrt(self.g.dx * self.g.dy *
112+
np.sum((_tmp[self.g.ilo:self.g.ihi+1, self.g.jlo:self.g.jhi+1]**2).flat))
109113

110114
def copy(self):
111115
"""make a copy of the array, defined on the same grid"""

0 commit comments

Comments
 (0)