示例#1
0
 def test_compare_MRST_triangleGrid3D(self):
     G_mrst = loadMRSTGrid(
         getpath(
             "test_gridprocessing/computeGeometry_triangleGrid3D_expected.mat"
         ))
     G_prst = loadMRSTGrid(
         getpath("test_gridprocessing/computeGeometry_triangleGrid3D.mat"))
     computeGeometry(G_prst)
     assert G_mrst == G_prst, G_mrst._cmp(G_prst)
示例#2
0
 def test_findNeighbors3D(self):
     # Tests that computeGeometry finds neighbors properly
     # Load grid without computeGeometry from MATLAB
     G_prst = loadMRSTGrid(getpath("test_gridprocessing/computeGeometry_findNeighbors3D.mat"))
     # ComputeGeometry using PRST
     computeGeometry(G_prst)
     assert G_prst.cells.volumes.ndim == 2
     assert G_prst.faces.areas.ndim == 2
     # Load grid WITH computeGeometry from MATLAB
     G_mrst = loadMRSTGrid(getpath("test_gridprocessing/computeGeometry_findNeighbors3D_expected.mat"))
     assert G_mrst == G_prst, G_mrst._cmp(G_prst)
示例#3
0
 def test_findNeighbors3D(self):
     # Tests that computeGeometry finds neighbors properly
     # Load grid without computeGeometry from MATLAB
     G_prst = loadMRSTGrid(
         getpath("test_gridprocessing/computeGeometry_findNeighbors3D.mat"))
     # ComputeGeometry using PRST
     computeGeometry(G_prst)
     assert G_prst.cells.volumes.ndim == 2
     assert G_prst.faces.areas.ndim == 2
     # Load grid WITH computeGeometry from MATLAB
     G_mrst = loadMRSTGrid(
         getpath(
             "test_gridprocessing/computeGeometry_findNeighbors3D_expected.mat"
         ))
     assert G_mrst == G_prst, G_mrst._cmp(G_prst)
示例#4
0
    def test_compare_MRST_simple(self):
        # G = cartGrid([3 5], [1 1]);
        G_mrst = loadMRSTGrid(getpath("test_gridprocessing/cartGrid2D_simple.mat"))

        # Using numpy array parameters
        G_prst = cartGrid(np.array([3, 5]), np.array([1, 1]))
        print(G_mrst.cells.indexMap)
        print(G_prst.cells.indexMap)
        assert G_mrst == G_prst, G_mrst._cmp(G_prst)
示例#5
0
 def test_compare_MRST_without_depthz(self):
     # Load grid created in Matlab
     #    G = tensorGrid([1 2 3], [0.5, 1, 1.5], [10, 20])
     G_mrst = loadMRSTGrid(getpath("test_gridprocessing/expected_tensorGrid3D_2.mat"))
     # Create grid using PRST
     x = np.array([1, 2, 3])
     y = np.array([0.5, 1, 1.5])
     z = np.array([10, 20])
     G_prst = tensorGrid(x, y, z)
     assert G_mrst == G_prst, G_mrst._cmp(G_prst)
示例#6
0
    def test_compare_MRST_simple(self):
        # Load grid created in Matlab using tensorGrid([0 1 2], [0 1 2])
        G_mrst = loadMRSTGrid(getpath("test_gridprocessing/expected_tensorGrid2D_1.mat"))

        # Create grid using PRST
        x = np.array([0, 1, 2])
        y = np.array([0, 1, 2])
        G_prst = tensorGrid(x, y)

        assert G_mrst == G_prst, G_mrst._cmp(G_prst)
示例#7
0
    def test_compare_MRST_simple(self):
        # G = cartGrid([3 5], [1 1]);
        G_mrst = loadMRSTGrid(
            getpath("test_gridprocessing/cartGrid2D_simple.mat"))

        # Using numpy array parameters
        G_prst = cartGrid(np.array([3, 5]), np.array([1, 1]))
        print(G_mrst.cells.indexMap)
        print(G_prst.cells.indexMap)
        assert G_mrst == G_prst, G_mrst._cmp(G_prst)
示例#8
0
 def test_compare_MRST_with_depthz(self):
     # Load grid created in Matlab
     #    G = tensorGrid([1 2 3], [0.5, 1, 1.5], [10, 20], 'depthz', [ 1 2 3; 4 5 6; 7 8 9]);
     G_mrst = loadMRSTGrid(getpath("test_gridprocessing/expected_tensorGrid3D_1.mat"))
     # Create grid using PRST
     x = np.array([1, 2, 3])
     y = np.array([0.5, 1, 1.5])
     z = np.array([10, 20])
     depthz = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
     G_prst = tensorGrid(x, y, z, depthz=depthz)
     assert G_mrst == G_prst, G_mrst._cmp(G_prst)
示例#9
0
 def test_compare_MRST_without_depthz(self):
     # Load grid created in Matlab
     #    G = tensorGrid([1 2 3], [0.5, 1, 1.5], [10, 20])
     G_mrst = loadMRSTGrid(
         getpath("test_gridprocessing/expected_tensorGrid3D_2.mat"))
     # Create grid using PRST
     x = np.array([1, 2, 3])
     y = np.array([0.5, 1, 1.5])
     z = np.array([10, 20])
     G_prst = tensorGrid(x, y, z)
     assert G_mrst == G_prst, G_mrst._cmp(G_prst)
示例#10
0
    def test_compare_MRST_simple(self):
        # Load grid created in Matlab using tensorGrid([0 1 2], [0 1 2])
        G_mrst = loadMRSTGrid(
            getpath("test_gridprocessing/expected_tensorGrid2D_1.mat"))

        # Create grid using PRST
        x = np.array([0, 1, 2])
        y = np.array([0, 1, 2])
        G_prst = tensorGrid(x, y)

        assert G_mrst == G_prst, G_mrst._cmp(G_prst)
示例#11
0
 def test_compare_MRST_with_depthz(self):
     # Load grid created in Matlab
     #    G = tensorGrid([1 2 3], [0.5, 1, 1.5], [10, 20], 'depthz', [ 1 2 3; 4 5 6; 7 8 9]);
     G_mrst = loadMRSTGrid(
         getpath("test_gridprocessing/expected_tensorGrid3D_1.mat"))
     # Create grid using PRST
     x = np.array([1, 2, 3])
     y = np.array([0.5, 1, 1.5])
     z = np.array([10, 20])
     depthz = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
     G_prst = tensorGrid(x, y, z, depthz=depthz)
     assert G_mrst == G_prst, G_mrst._cmp(G_prst)
示例#12
0
文件: test_io.py 项目: zwgzwz/PRST
    def test_tensorGrid2D(self):
        G = loadMRSTGrid(getpath("test_io/expected_tensorGrid2D_1G.mat"))

        # Check existence of top-level attributes
        assert hasattr(G, "cells")
        assert hasattr(G, "faces")
        assert hasattr(G, "nodes")
        assert hasattr(G, "cartDims")
        assert hasattr(G, "gridType")

        # Cells
        assert hasattr(G.cells, "num")
        assert G.cells.num == 4
        assert np.array_equal(G.cells.facePos, np.array(
            [[0], [4], [8], [12], [16]]))
        assert np.array_equal(G.cells.indexMap, np.array(
            [[0], [1], [2], [3]]))
        assert np.array_equal(G.cells.faces, np.array([
                [0, 0],
                [6, 2],
                [1, 1],
                [8, 3],
                [1, 0],
                [7, 2],
                [2, 1],
                [9, 3],
                [3, 0],
                [8, 2],
                [4, 1],
                [10, 3],
                [4, 0],
                [9, 2],
                [5, 1],
                [11, 3],
            ]))

        # Faces
        assert G.faces.num == 12
        assert np.array_equal(G.faces.nodePos, np.array([
                 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24
             ])[:,np.newaxis])
        # This array is saved as uint8, and if not carefully loaded, -1 will
        # become 255.
        assert G.faces.neighbors[0,0] == -1
        assert np.array_equal(G.faces.neighbors, np.array([
                [-1, 0],
                [0, 1],
                [1, -1],
                [-1, 2],
                [2, 3],
                [3, -1],
                [-1, 0],
                [-1, 1],
                [0, 2],
                [1, 3],
                [2, -1],
                [3, -1],
            ]))
        # G.faces.tag is not available in PRST
        assert np.array_equal(G.faces.nodes, np.array([
                0, 3, 1, 4, 2, 5, 3, 6, 4, 7, 5, 8, 1, 0, 2, 1, 4, 3, 5, 4, 7,
                6, 8, 7
            ])[:,np.newaxis])

        # Nodes
        assert G.nodes.num == 9
        # G.nodes.coords
        assert np.array_equal(G.nodes.coords, np.array([
                [0, 0],
                [1, 0],
                [2, 0],
                [0, 1],
                [1, 1],
                [2, 1],
                [0, 2],
                [1, 2],
                [2, 2],
            ]))

        # Top-level attribues
        # cartDims
        assert G.cartDims[0] == 2 and G.cartDims[1] == 2
        assert "tensorGrid" in G.gridType
        assert G.gridType == ["tensorGrid"]
        assert G.gridDim == 2
示例#13
0
 def test_findNeighbors2D(self):
     G_prst = loadMRSTGrid(getpath("test_gridprocessing/computeGeometry_findNeighbors2D.mat"))
     with pytest.raises(ValueError):
         computeGeometry(G_prst)
示例#14
0
 def test_findNeighbors2D(self):
     G_prst = loadMRSTGrid(
         getpath("test_gridprocessing/computeGeometry_findNeighbors2D.mat"))
     with pytest.raises(ValueError):
         computeGeometry(G_prst)
示例#15
0
 def test_findNeighbors3D_force(self):
     G_mrst = loadMRSTGrid(
         getpath(
             "test_gridprocessing/computeGeometry_findNeighbors3D_expected.mat"
         ))
     computeGeometry(G_mrst, findNeighbors=True)
示例#16
0
文件: test_io.py 项目: zwgzwz/PRST
 def test_single_grid_type(self):
     G = loadMRSTGrid(getpath("test_io/expected_tensorGrid2D_1G.mat"))
     assert isinstance(G.gridType, list)
示例#17
0
文件: test_io.py 项目: zwgzwz/PRST
 def test_array_shapes(self):
     G = loadMRSTGrid(getpath("test_io/expected_tensorGrid2D_1G.mat"))
     assert G.cells.facePos.shape[1] == 1
     assert G.cells.indexMap.shape[1] == 1
示例#18
0
文件: test_io.py 项目: zwgzwz/PRST
 def test_tensorGrid2D_V(self):
     V = loadMRSTGrid(getpath("test_io/expected_tensorGrid2D_1V.mat"), "V")
     assert V.cells.num == 4
示例#19
0
 def test_findNeighbors3D_force(self):
     G_mrst = loadMRSTGrid(getpath("test_gridprocessing/computeGeometry_findNeighbors3D_expected.mat"))
     computeGeometry(G_mrst, findNeighbors=True)
示例#20
0
 def test_equal_without_indexMap(self):
     V = loadMRSTGrid(getpath("test_gridprocessing/grid_equal_without_indexMap.mat"), "V")
     V == V
示例#21
0
 def test_compare_MRST_simple(self):
     # G = cartGrid([3 5 7], [1 1 3]);
     G_mrst = loadMRSTGrid(
         getpath("test_gridprocessing/cartGrid3D_simple.mat"))
     G_prst = cartGrid(np.array([3, 5, 7]), np.array([1, 1, 3]))
     assert G_mrst == G_prst, G_mrst._cmp(G_prst)
示例#22
0
文件: test_io.py 项目: zwgzwz/PRST
 def test_malformed_gridType(self):
     with pytest.raises(ValueError):
         G = loadMRSTGrid(getpath("test_io/malformed_gridType.mat"))
示例#23
0
 def test_compare_MRST_simple(self):
     # G = cartGrid([3 5 7], [1 1 3]);
     G_mrst = loadMRSTGrid(getpath("test_gridprocessing/cartGrid3D_simple.mat"))
     G_prst = cartGrid(np.array([3, 5, 7]), np.array([1, 1, 3]))
     assert G_mrst == G_prst, G_mrst._cmp(G_prst)
示例#24
0
文件: test_io.py 项目: zwgzwz/PRST
 def test_no_cartDims(self):
     G = loadMRSTGrid(getpath("test_io/grid_without_indexMap_or_cartDims.mat"), "V")
     assert not hasattr(G, "cartDims")
示例#25
0
文件: test_io.py 项目: zwgzwz/PRST
 def test_computeGeometry_shapes(self):
     G = loadMRSTGrid(getpath("test_gridprocessing/computeGeometry_findNeighbors3D_expected.mat"))
     assert G.cells.centroids.ndim == 2
示例#26
0
 def test_compare_MRST_triangleGrid3D(self):
     G_mrst = loadMRSTGrid(getpath("test_gridprocessing/computeGeometry_triangleGrid3D_expected.mat"))
     G_prst = loadMRSTGrid(getpath("test_gridprocessing/computeGeometry_triangleGrid3D.mat"))
     computeGeometry(G_prst)
     assert G_mrst == G_prst, G_mrst._cmp(G_prst)
示例#27
0
文件: crash.py 项目: zwgzwz/PRST
import logging
import sys

import prst
from prst.io import loadMRSTGrid

from helpers import getpath

logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)

print("yah")
print(getpath("test_gridprocessing/grid_equal_without_indexMap.mat"))
V = loadMRSTGrid(
    getpath("test_gridprocessing/grid_equal_without_indexMap.mat"), "V")
print("duew")
V == V
print("wat")
示例#28
0
文件: test_io.py 项目: zwgzwz/PRST
 def test_multiple_grid_types(self):
     G = loadMRSTGrid(getpath("test_io/multiple_gridtypes.mat"))
     assert isinstance(G.gridType, list)