Skip to content

Commit

Permalink
Merge 9d4ca4d into 7f57f87
Browse files Browse the repository at this point in the history
  • Loading branch information
stoiver committed Jan 9, 2020
2 parents 7f57f87 + 9d4ca4d commit 1c9d641
Show file tree
Hide file tree
Showing 152 changed files with 23,363 additions and 23,174 deletions.
19 changes: 7 additions & 12 deletions anuga/__init__.py
Expand Up @@ -21,15 +21,17 @@
# -----------------------------------------------------


from builtins import filter
__version__ = '2.0.3'

__svn_revision__ = filter(str.isdigit, "$Revision: 9737 $")
__svn_revision__ = ''.join(filter(str.isdigit, "$Revision: 9737 $"))

__svn_revision_date__ = "$Date: 2016-10-04 16:13:00 +1100 (Tue, 04 Oct 2016) $"[7:-1]


# We first need to detect if we're being called as part of the anuga setup
# procedure itself in a reliable manner.

try:
__ANUGA_SETUP__
except NameError:
Expand All @@ -41,17 +43,8 @@
_sys.stderr.write('Running from anuga source directory.\n')
del _sys
else:

try:
from anuga.__config__ import show as show_config
except ImportError:
msg = """Error importing anuga: you should not try to import anuga from
its source directory; please exit the anuga source tree, and relaunch
your python interpreter from there."""
raise ImportError(msg)

# ---------------------------------
# NetCDF changes stdout to terminal\
# ----------------------------------
# NetCDF changes stdout to terminal
# Causes trouble when using jupyter
# ---------------------------------
import sys
Expand All @@ -63,6 +56,8 @@
from numpy.testing import Tester
test = Tester().test

from anuga.__config__ import show as show_config

# --------------------------------
# Important basic classes
# --------------------------------
Expand Down
1 change: 1 addition & 0 deletions anuga/compile_all.py
@@ -1,5 +1,6 @@
""" Script to compile all C extensions in ANUGA. """

from past.builtins import execfile
import os
import subprocess
import sys
Expand Down
15 changes: 9 additions & 6 deletions anuga/error_api.py
@@ -1,3 +1,6 @@
from __future__ import division
from builtins import range
from past.utils import old_div
import matplotlib
import matplotlib.pyplot as plt
import matplotlib.tri as tri
Expand Down Expand Up @@ -29,7 +32,7 @@ def addRandomNoiseToStage(domain, samples = 50, dthr = 0.1, mag = 1E-15):

# Sample centroid values with depth greater than dthr
n_tri = int(num.sum(domain.tri_full_flag))
tri_index = num.array(range(0,n_tri))
tri_index = num.array(list(range(0,n_tri)))
submerged = tri_index[depth > dthr]
submerged = random.sample(submerged, min(samples, len(submerged)))

Expand Down Expand Up @@ -70,7 +73,7 @@ def plotCentroidError(domain, control_data, rthr = 1E-7, athr = 1E-12,
stage = domain.get_quantity(quantity)
actual_data = stage.centroid_values[:n_triangles]
adiff = num.fabs((actual_data - local_control_data))
rdiff = adiff/num.fabs(local_control_data)
rdiff = old_div(adiff,num.fabs(local_control_data))

# Compute masks for error (err_mask) and non-error (acc_mask) vertex indices based on thresholds
vertices = domain.get_vertex_coordinates()
Expand Down Expand Up @@ -102,18 +105,18 @@ def plotCentroidError(domain, control_data, rthr = 1E-7, athr = 1E-12,

# Plot non-error triangles in green
for i in range(0,size()):
n = int(len(fx[i])/3)
triang = num.array(range(0,3*n))
n = int(old_div(len(fx[i]),3))
triang = num.array(list(range(0,3*n)))
triang.shape = (n, 3)

if len(fx[i]) > 0:
plt.triplot(fx[i], fy[i], triang, 'g-')

# Plot error triangles in blue
for i in range(0,size()):
n = int(len(gx[i])/3)
n = int(old_div(len(gx[i]),3))

triang = num.array(range(0,3*n))
triang = num.array(list(range(0,3*n)))
triang.shape = (n, 3)

if len(gx[i]) > 0:
Expand Down
5 changes: 3 additions & 2 deletions anuga/operators/base_operator.py
@@ -1,3 +1,4 @@
from __future__ import print_function

from anuga.utilities.system_tools import log_to_file

Expand Down Expand Up @@ -83,11 +84,11 @@ def timestepping_statistics(self):

def print_statistics(self):

print self.statistics()
print(self.statistics())

def print_timestepping_statistics(self):

print self.timestepping_statistics()
print(self.timestepping_statistics())


def log_timestepping_statistics(self):
Expand Down
2 changes: 1 addition & 1 deletion anuga/operators/boundary_flux_integral_operator.py
Expand Up @@ -56,7 +56,7 @@ def __call__(self):
elif(ts_method=='rk3'):
self.boundary_flux_integral = self.boundary_flux_integral + 1.0/6.0*dt*(self.domain.boundary_flux_sum[0] + self.domain.boundary_flux_sum[1] + 4.0*self.domain.boundary_flux_sum[2])
else:
raise Exception, 'Cannot compute boundary flux integral with this timestepping method'
raise Exception('Cannot compute boundary flux integral with this timestepping method')

# Zero the boundary_flux_sum
self.domain.boundary_flux_sum[:]=0.
Expand Down
3 changes: 2 additions & 1 deletion anuga/operators/change_friction_operator.py
Expand Up @@ -3,6 +3,7 @@
"""
from __future__ import print_function

__author__="steve"
__date__ ="$09/03/2012 4:46:39 PM$"
Expand Down Expand Up @@ -112,7 +113,7 @@ def __call__(self):
self.stage_c[:] = self.elev_c + height_c
# self.domain.distribute_to_vertices_and_edges()

print 'time in erosion ',self.get_time(), dt
print('time in erosion ',self.get_time(), dt)



Expand Down
3 changes: 2 additions & 1 deletion anuga/operators/elliptic_operator.py
@@ -1,11 +1,12 @@
from __future__ import absolute_import
from anuga import Domain
from anuga import Quantity
from anuga.utilities.sparse import Sparse, Sparse_CSR
from anuga.utilities.cg_solve import conjugate_gradient
import anuga.abstract_2d_finite_volumes.neighbour_mesh as neighbour_mesh
from anuga import Dirichlet_boundary
import numpy as num
import kinematic_viscosity_operator_ext
from . import kinematic_viscosity_operator_ext
import anuga.utilities.log as log

from anuga.operators.base_operator import Operator
Expand Down
45 changes: 23 additions & 22 deletions anuga/operators/erosion_operators.py
Expand Up @@ -3,6 +3,7 @@
"""
from __future__ import print_function

__author__="steve"
__date__ ="$09/03/2012 4:46:39 PM$"
Expand Down Expand Up @@ -257,7 +258,7 @@ def dump_triangulation(self):
import matplotlib.pyplot as plt
import matplotlib.tri as tri
except:
print "Couldn't import module from matplotlib, probably you need to update matplotlib"
print("Couldn't import module from matplotlib, probably you need to update matplotlib")
raise

domain = self.domain
Expand All @@ -281,9 +282,9 @@ def dump_triangulation(self):
triang = domain.get_triangles()
#triang.shape = (n, 3)

print triang.shape
print fx.shape
print Z.shape
print(triang.shape)
print(fx.shape)
print(Z.shape)

#plt.tricontourf(fx, fy, triang, Z)
plt.triplot(fx, fy, triang)
Expand Down Expand Up @@ -315,9 +316,9 @@ def dump_triangulation(self):
fx1 = fx[self.vols].flatten()
fy1 = fy[self.vols].flatten()

print 'fx1', fx1.shape
print('fx1', fx1.shape)

print self.vols
print(self.vols)
#gx = vertices[ghost_mask,0]
#gy = vertices[ghost_mask,1]

Expand All @@ -326,7 +327,7 @@ def dump_triangulation(self):
n = int(len(fx1)/3)
triang = num.array(range(0,3*n))
triang.shape = (n, 3)
print triang
print(triang)
plt.triplot(fx1, fy1, triang, 'go-')


Expand All @@ -340,9 +341,9 @@ def dump_triangulation(self):
fx0 = fx[self.indices].flatten()
fy0 = fy[self.indices].flatten()

print 'fx0', fx0.shape
print('fx0', fx0.shape)

print self.indices
print(self.indices)
#gx = vertices[ghost_mask,0]
#gy = vertices[ghost_mask,1]

Expand All @@ -351,7 +352,7 @@ def dump_triangulation(self):
n = int(len(fx0)/3)
triang = num.array(range(0,3*n))
triang.shape = (n, 3)
print triang
print(triang)
plt.triplot(fx0, fy0, triang, 'bo-')


Expand All @@ -361,9 +362,9 @@ def dump_triangulation(self):
fx0 = fx[self.indices].flatten()
fy0 = fy[self.indices].flatten()

print 'fx0', fx0.shape
print('fx0', fx0.shape)

print self.indices
print(self.indices)
#gx = vertices[ghost_mask,0]
#gy = vertices[ghost_mask,1]

Expand All @@ -372,7 +373,7 @@ def dump_triangulation(self):
n = int(len(fx0)/3)
triang = num.array(range(0,3*n))
triang.shape = (n, 3)
print triang
print(triang)
plt.triplot(fx0, fy0, triang, 'bo-')


Expand All @@ -381,7 +382,7 @@ def dump_triangulation(self):
fx2 = fx[self.vol_ids,self.vert_ids]
fy2 = fy[self.vol_ids,self.vert_ids]

print 'fx2', fx2.shape
print('fx2', fx2.shape)

plt.plot(fx2,fy2,'yo')

Expand Down Expand Up @@ -809,7 +810,7 @@ def update_quantities(self):
else:
try:
value = self.elevation(t)
print value
print(value)
if value > num.max(self.elev_v[ind]):
self.elev_v[ind] = num.where(self.elev_v[ind] < value, value, self.elev_v[ind])
else:
Expand All @@ -836,13 +837,13 @@ def lineno():


def stage_elev_info(self):
print 80*"="
print(80*"=")

print 'In Evolve: line number ', lineno()
print('In Evolve: line number ', lineno())
import inspect
print inspect.getfile(lineno)
print(inspect.getfile(lineno))

print 80*"="
print(80*"=")
ind = num.array([ 976, 977, 978, 979, 980, 981, 982, 983, 1016, 1017, 1018,
1019, 1020, 1021, 1022, 1023])
elev_v = self.get_quantity('elevation').vertex_values
Expand All @@ -851,11 +852,11 @@ def stage_elev_info(self):
stage_c = self.get_quantity('stage').centroid_values

from pprint import pprint
print 'elev_v, elev_c, elev_avg \n'
print('elev_v, elev_c, elev_avg \n')
pprint( num.concatenate( (elev_v[ind], (elev_c[ind]).reshape(16,1),
num.mean(elev_v[ind],axis=1).reshape(16,1)), axis = 1))
print 'stage_v, stage_c, stage_avg \n'
print('stage_v, stage_c, stage_avg \n')
pprint( num.concatenate( (stage_v[ind], (stage_c[ind]).reshape(16,1),
num.mean(stage_v[ind],axis=1).reshape(16,1)), axis = 1))

print 80*"="
print(80*"=")
3 changes: 2 additions & 1 deletion anuga/operators/kinematic_viscosity_operator.py
@@ -1,11 +1,12 @@
from __future__ import absolute_import
from anuga import Domain
from anuga import Quantity
from anuga.utilities.sparse import Sparse, Sparse_CSR
from anuga.utilities.cg_solve import conjugate_gradient
import anuga.abstract_2d_finite_volumes.neighbour_mesh as neighbour_mesh
from anuga import Dirichlet_boundary
import numpy as num
import kinematic_viscosity_operator_ext
from . import kinematic_viscosity_operator_ext
import anuga.utilities.log as log

from anuga.operators.base_operator import Operator
Expand Down
13 changes: 7 additions & 6 deletions anuga/operators/tests/test_boundary_flux_integral_operator.py
@@ -1,3 +1,4 @@
from __future__ import print_function
import unittest
import anuga
import numpy
Expand Down Expand Up @@ -73,13 +74,13 @@ def test_boundary_flux_operator_DE0(self):
#domain.print_statistics()
for t in domain.evolve(yieldstep=1.0,finaltime=5.0):
if verbose: domain.print_timestepping_statistics()
if verbose: print domain.get_water_volume()
if verbose: print(domain.get_water_volume())
pass
# The domain was initially dry
vol=domain.get_water_volume()
boundaryFluxInt=domain.get_boundary_flux_integral()

if verbose: print flowalg, vol, boundaryFluxInt
if verbose: print(flowalg, vol, boundaryFluxInt)
assert(numpy.allclose(vol,boundaryFluxInt))


Expand All @@ -95,13 +96,13 @@ def test_boundary_flux_operator_DE1(self):
#domain.print_statistics()
for t in domain.evolve(yieldstep=1.0,finaltime=5.0):
if verbose: domain.print_timestepping_statistics()
if verbose: print domain.get_water_volume()
if verbose: print(domain.get_water_volume())
pass
# The domain was initially dry
vol=domain.get_water_volume()
boundaryFluxInt=domain.get_boundary_flux_integral()

if verbose: print flowalg, vol, boundaryFluxInt
if verbose: print(flowalg, vol, boundaryFluxInt)
assert(numpy.allclose(vol,boundaryFluxInt))


Expand All @@ -118,13 +119,13 @@ def test_boundary_flux_operator_DE2(self):
#domain.print_statistics()
for t in domain.evolve(yieldstep=1.0,finaltime=5.0):
if verbose: domain.print_timestepping_statistics()
if verbose: print domain.get_water_volume(), domain.get_boundary_flux_integral()
if verbose: print(domain.get_water_volume(), domain.get_boundary_flux_integral())
pass
# The domain was initially dry
vol=domain.get_water_volume()
boundaryFluxInt=domain.get_boundary_flux_integral()

if verbose: print flowalg, vol, boundaryFluxInt
if verbose: print(flowalg, vol, boundaryFluxInt)
assert(numpy.allclose(vol,boundaryFluxInt))


Expand Down

0 comments on commit 1c9d641

Please sign in to comment.