diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 9ac952d57..f1d5e886b 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,4 +1,4 @@ [bumpversion] -current_version = 0.1.14 +current_version = 0.1.15 files = setup.py discretize/__init__.py docs/conf.py diff --git a/discretize/DiffOperators.py b/discretize/DiffOperators.py index 2948ba51c..3f29e1bc2 100644 --- a/discretize/DiffOperators.py +++ b/discretize/DiffOperators.py @@ -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) @@ -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." diff --git a/discretize/__init__.py b/discretize/__init__.py index b7494c0be..5ee809549 100644 --- a/discretize/__init__.py +++ b/discretize/__init__.py @@ -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' diff --git a/docs/conf.py b/docs/conf.py index fe39b6c37..1f6a82aab 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -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. diff --git a/setup.py b/setup.py index 5dd2d71f2..d526e3f9d 100644 --- a/setup.py +++ b/setup.py @@ -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', diff --git a/tests/base/test_operators.py b/tests/base/test_operators.py index 057cca29a..324294bd4 100644 --- a/tests/base/test_operators.py +++ b/tests/base/test_operators.py @@ -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): @@ -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()