Skip to content

Commit

Permalink
Merge pull request #88 from simpeg/aveCC2FV
Browse files Browse the repository at this point in the history
Creating aveCCV2F
  • Loading branch information
lheagy authored Feb 16, 2018
2 parents 4dc94be + e10a980 commit 51dd456
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[bumpversion]
current_version = 0.1.14
current_version = 0.1.15
files = setup.py discretize/__init__.py docs/conf.py

32 changes: 31 additions & 1 deletion discretize/DiffOperators.py
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,7 @@ def aveFz2CC(self):

@property
def aveCC2F(self):
"Construct the averaging operator on cell cell centers to faces."
"Construct the averaging operator on cell centers to faces."
if getattr(self, '_aveCC2F', None) is None:
if self.dim == 1:
self._aveCC2F = av_extrap(self.nCx)
Expand All @@ -774,6 +774,36 @@ def aveCC2F(self):
), format="csr")
return self._aveCC2F

@property
def aveCCV2F(self):
"""
Construct the averaging operator on cell centers to
faces as a vector.
"""
if getattr(self, '_aveCCV2F', None) is None:
if self.dim == 1:
self._aveCCV2F = self.aveCC2F
elif self.dim == 2:
aveCCV2Fx = sp.kron(speye(self.nCy), av_extrap(self.nCx))
aveCC2VFy = sp.kron(av_extrap(self.nCy), speye(self.nCx))
self._aveCCV2F = sp.block_diag((
aveCCV2Fx, aveCC2VFy
), format="csr")
elif self.dim == 3:
aveCCV2Fx = kron3(
speye(self.nCz), speye(self.nCy), av_extrap(self.nCx)
)
aveCC2VFy = kron3(
speye(self.nCz), av_extrap(self.nCy), speye(self.nCx)
)
aveCC2BFz = kron3(
av_extrap(self.nCz), speye(self.nCy), speye(self.nCx)
)
self._aveCCV2F = sp.block_diag((
aveCCV2Fx, aveCC2VFy, aveCC2BFz
), format="csr")
return self._aveCCV2F

@property
def aveE2CC(self):
"Construct the averaging operator on cell edges to cell centers."
Expand Down
2 changes: 1 addition & 1 deletion discretize/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"""
)

__version__ = '0.1.14'
__version__ = '0.1.15'
__author__ = 'SimPEG Team'
__license__ = 'MIT'
__copyright__ = '2013 - 2017, SimPEG Developers, http://simpeg.xyz'
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@
# built documents.
#
# The short X.Y version.
version = '0.1.14'
version = '0.1.15'
# The full version, including alpha/beta/rc tags.
release = '0.1.14'
release = '0.1.15'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def configuration(parent_package='', top_path=None):

setup(
name="discretize",
version="0.1.14",
version="0.1.15",
install_requires=[
'numpy>=1.7',
'scipy>=0.13',
Expand Down
22 changes: 22 additions & 0 deletions tests/base/test_operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,17 @@ def test_orderE2CCV(self):
self.getAve = lambda M: M.aveE2CCV
self.orderTest()

def test_orderCC2FV(self):
self.name = "Averaging 2D: CC2FV"
funX = lambda x, y: (np.cos(x)+np.sin(y))
funY = lambda x, y: (np.cos(y)*np.sin(x))
self.getHere = lambda M: np.r_[call2(funX, M.gridCC), call2(funY, M.gridCC)]
self.getThere = lambda M: np.r_[call2(funX, M.gridFx), call2(funY, M.gridFy)]
self.getAve = lambda M: M.aveCCV2F
self.expectedOrders = ORDERS/2.0
self.orderTest()
self.expectedOrders = ORDERS


class TestAverating3DSimple(unittest.TestCase):
def setUp(self):
Expand Down Expand Up @@ -527,6 +538,17 @@ def test_orderCC2F(self):
self.orderTest()
self.expectedOrders = ORDERS

def test_orderCCV2F(self):
self.name = "Averaging 3D: CC2FV"
funX = lambda x, y, z: (np.cos(x)+np.sin(y)+np.exp(z))
funY = lambda x, y, z: (np.cos(x)+np.sin(y)*np.exp(z))
funZ = lambda x, y, z: (np.cos(x)*np.sin(y)+np.exp(z))
self.getHere = lambda M: np.r_[call3(funX, M.gridCC), call3(funY, M.gridCC), call3(funZ, M.gridCC)]
self.getThere = lambda M: np.r_[call3(funX, M.gridFx), call3(funY, M.gridFy), call3(funZ, M.gridFz)]
self.getAve = lambda M: M.aveCCV2F
self.expectedOrders = ORDERS/2.0
self.orderTest()
self.expectedOrders = ORDERS

if __name__ == '__main__':
unittest.main()

0 comments on commit 51dd456

Please sign in to comment.