Skip to content

Commit

Permalink
Apply suggestions from Steven Brus
Browse files Browse the repository at this point in the history
Co-authored-by: Steven Brus <[email protected]>
  • Loading branch information
cbegeman and sbrus89 committed May 30, 2023
1 parent 9b2ae94 commit 329a319
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ implements a test case according to the Method of Manufactured Solutions
(see {ref}`ocean-manufactured-solution`) at 4 resolutions (200, 100, 50, and 25 km). Here,
we describe the shared framework for this test group and the 1 test case.

(dev-ocean-baroclinic-channel-framework)=
(dev-ocean-manufactured-solution)=

## framework

Expand Down
69 changes: 69 additions & 0 deletions polaris/ocean/tests/manufactured_solution/exact_solution.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,52 @@


class ExactSolution():
"""
Class to compute the exact solution for the manufactured solution
test case
Attributes
----------
angleEdge : xr.DataArray
angle between edge normals and positive x direction
xCell : xr.DataArray
x coordinates of mesh cell centers
yCell : xr.DataArray
y coordinates of mesh cell centers
xEdge: xr.DataArray
x coordinates of mesh edges
yEdge : xr.DataArray
y coordinates of mesh edges
eta0 : float
Amplitide of sea surface height
kx : float
Wave number in the x direction
ky : float
Wave number in the y direction
omega : float
Angular frequency
"""

def __init__(self, config, ds=None):
"""
Create a new exact solution object
Parameters
----------
ds : xr.DataSet
MPAS mesh information
config : polaris.config.PolarisConfigParser
Config options for test case
"""
bottom_depth = config.getfloat('vertical_grid', 'bottom_depth')
section = config['manufactured_solution']
self.g = 9.80616
Expand All @@ -28,6 +71,20 @@ def __init__(self, config, ds=None):
self.yEdge = ds.yEdge

def ssh(self, t):
"""
Exact solution for sea surface height
Parameters
----------
t : float
time at which to evaluate exact solution
Returns
-------
eta : xr.DataArray
the exact sea surface height solution on cells at time t
"""

eta = self.eta0 * np.sin(self.kx * self.xCell +
self.ky * self.yCell -
Expand All @@ -36,7 +93,19 @@ def ssh(self, t):
return eta

def normalVelocity(self, t):
"""
Exact solution for normal velocity
Parameters
----------
t : float
time at which to evaluate exact solution
Returns
-------
normalvelocity : xr.DataArray
the exact normal velocity solution on edges at time t
"""
u = self.eta0 * np.cos(self.kx * self.xEdge +
self.ky * self.yEdge -
self.omega * t)
Expand Down

0 comments on commit 329a319

Please sign in to comment.